keypwd-keep.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :permission="permissionList"
  7. :before-open="beforeOpen"
  8. v-model="form"
  9. ref="crud"
  10. @row-update="rowUpdate"
  11. @row-save="rowSave"
  12. @row-del="rowDel"
  13. :search.sync="search"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="primary" size="small" icon="el-icon-download"
  23. plain @click="handleDownload">下載
  24. </el-button>
  25. </template>
  26. <template slot="receiverNameForm">
  27. <select-dialog-user :name="form.receiverName" :ehr="form.receiverNo" :disabled="disabeldReceiver" :callback="selectCallback"></select-dialog-user>
  28. </template>
  29. <template slot="handoverPersonNameForm">
  30. <select-dialog-user :name="form.handoverPersonName" :ehr="form.handoverPersonNo" :disabled="disabeldHandover" :callback="handoverSelectCallback"></select-dialog-user>
  31. </template>
  32. <template slot-scope="{disabled,size}" slot="categorySearch">
  33. <avue-input-tree :check-strictly="false" v-model="search.category" placeholder="請選擇內容" type="tree" :dic="typeList" :props="props"></avue-input-tree>
  34. </template>
  35. </avue-crud>
  36. </basic-container>
  37. </template>
  38. <script>
  39. import {getKeepList, getDetail, add, update, remove, getByCategoryAndType, getKeyType} from "@/api/bank/keypwd";
  40. import {mapGetters} from "vuex";
  41. import {dateFormat} from "../../util/date";
  42. import SelectDialogUser from "../../components/select-dialog/select-dialog-user";
  43. import { getCurrentDept } from "@/api/system/dept";
  44. import {getDeptTree, getTree} from "@/api/system/dept";
  45. export default {
  46. name: "keypwd-keep",
  47. components: {SelectDialogUser},
  48. data() {
  49. return {
  50. search: {},
  51. typeList: [],
  52. props:{
  53. label: "dictValue",
  54. value: "dictKey",
  55. },
  56. form: {},
  57. query: {},
  58. loading: true,
  59. page: {
  60. pageSize: 10,
  61. currentPage: 1,
  62. total: 0
  63. },
  64. disabeldReceiver: false,
  65. disabeldHandover: true,
  66. selectionList: [],
  67. selectReceiver: '',
  68. selectHandover: '',
  69. type: '',
  70. option: {
  71. height:'auto',
  72. calcHeight: 30,
  73. tip: false,
  74. searchShow: true,
  75. searchMenuSpan: 6,
  76. border: true,
  77. index: true,
  78. viewBtn: true,
  79. addBtn: false,
  80. editBtn: false,
  81. delBtn: false,
  82. selection: true,
  83. dialogClickModal: false,
  84. column: [
  85. {
  86. label: "銀行號",
  87. prop: "bankNo",
  88. hide: true,
  89. disabled: true,
  90. search: true,
  91. searchSpan: 4,
  92. rules: [{
  93. required: true,
  94. message: "請輸入銀行號",
  95. trigger: "blur"
  96. }]
  97. },
  98. {
  99. label: "機構號",
  100. prop: "orgNo",
  101. hide: true,
  102. disabled: true,
  103. rules: [{
  104. required: true,
  105. message: "請輸入機構號",
  106. trigger: "blur"
  107. }]
  108. },
  109. {
  110. label: "機構名稱",
  111. prop: "orgName",
  112. disabled: true,
  113. rules: [{
  114. required: true,
  115. message: "請輸入機構號",
  116. trigger: "blur"
  117. }]
  118. },
  119. {
  120. label: "區域/支行",
  121. prop: "orgNos",
  122. hide: true,
  123. display: false,
  124. searchMultiple: true,
  125. search: true,
  126. type: "tree",
  127. dicData: [],
  128. props: {
  129. label: "title",
  130. value: "key"
  131. },
  132. checkStrictly: true,
  133. rules: [{
  134. required: true,
  135. message: "請輸入機構號",
  136. trigger: "blur"
  137. }]
  138. },
  139. {
  140. label: "分類種類",
  141. prop: "category",
  142. search: true,
  143. checkStrictly: true,
  144. // multiple: true,
  145. dataType: "string",
  146. type: "tree",
  147. // dicUrl: "/api/blade-system/dict/dictionary?code=key_type",
  148. dicData: [],
  149. props:{
  150. label: "dictValue",
  151. value: "dictKey",
  152. },
  153. searchslot: true,
  154. change: ({value, column}) => {
  155. if (!value || this.type == 'view' || this.type == 'edit') return;
  156. getByCategoryAndType(value, this.form.orgNo).then(res => {
  157. const data = res.data.data;
  158. let $handoverNo = this.findObject(this.option.column, 'handoverPersonNo');
  159. let $handoverName = this.findObject(this.option.column, 'handoverPersonName');
  160. if (Object.keys(data).length == 0){
  161. // $handoverNo.disabled = false;
  162. this.form.handoverPersonNo = '';
  163. this.form.handoverPersonName = '';
  164. } else {
  165. $handoverNo.disabled = true;
  166. this.form.handoverPersonNo = data.receiverNo;
  167. this.form.handoverPersonName = data.receiverName;
  168. }
  169. });
  170. },
  171. rules: [{
  172. required: true,
  173. message: "請輸入分類",
  174. trigger: "blur"
  175. }]
  176. },
  177. /*{
  178. label: "種類",
  179. prop: "type",
  180. type: "select",
  181. dicUrl: "/api/blade-system/dict/dictionary?code={{key}}",
  182. props:{
  183. label: "dictValue",
  184. value: "dictKey",
  185. },
  186. change: ({value, column}) => {
  187. if (!value || this.type == 'view' || this.type == 'edit') return;
  188. getByCategoryAndType(this.form.category, value, this.form.orgNo).then(res => {
  189. const data = res.data.data;
  190. let $handoverNo = this.findObject(this.option.column, 'handoverPersonNo');
  191. let $handoverName = this.findObject(this.option.column, 'handoverPersonName');
  192. if (Object.keys(data).length == 0){
  193. // $handoverNo.disabled = false;
  194. this.form.handoverPersonNo = '';
  195. this.form.handoverPersonName = '';
  196. } else {
  197. $handoverNo.disabled = true;
  198. this.form.handoverPersonNo = data.receiverNo;
  199. this.form.handoverPersonName = data.receiverName;
  200. }
  201. });
  202. },
  203. rules: [{
  204. required: true,
  205. message: "請輸入種類",
  206. trigger: "blur"
  207. }]
  208. },*/
  209. {
  210. label: "數量",
  211. prop: "number",
  212. type: "number",
  213. disabled: true,
  214. rules: [{
  215. required: true,
  216. message: "請輸入數量",
  217. trigger: "blur"
  218. }]
  219. },
  220. {
  221. label: "交出人",
  222. prop: "handoverPersonName",
  223. formslot: true,
  224. hide: true,
  225. rules: [{
  226. required: false,
  227. message: "請輸入交出人姓名",
  228. trigger: "blur"
  229. }]
  230. },
  231. {
  232. label: "交出人員工號",
  233. prop: "handoverPersonNo",
  234. disabled: true,
  235. hide: true,
  236. rules: [{
  237. required: false,
  238. message: "請輸入交出人員工號",
  239. trigger: "blur"
  240. }]
  241. },
  242. {
  243. label: "保管人",
  244. prop: "receiverName",
  245. search: true,
  246. searchPlaceholder: "保管人",
  247. searchTip: "保管人",
  248. searchSpan: 4,
  249. formslot: true,
  250. rules: [{
  251. required: true,
  252. message: "請輸入接收人員工號",
  253. trigger: "focus"
  254. }]
  255. },
  256. {
  257. label: "保管人員工號",
  258. prop: "receiverNo",
  259. disabled: true,
  260. rules: [{
  261. required: true,
  262. message: "請輸入接收人員工號",
  263. trigger: "change"
  264. }]
  265. },
  266. {
  267. label: "開始保管時間",
  268. prop: "handoverDate",
  269. type: "datetime",
  270. format: "yyyy-MM-dd HH:mm",
  271. valueFormat: "yyyy-MM-dd HH:mm",
  272. },
  273. {
  274. label: "備註",
  275. prop: "remark",
  276. hide: true,
  277. },
  278. {
  279. label: "填報時間",
  280. prop: "fillingDate",
  281. addDisplay: false,
  282. editDisplay: false,
  283. hide: true,
  284. },
  285. {
  286. label: "填報人",
  287. prop: "fillingPerson",
  288. addDisplay: false,
  289. editDisplay: false,
  290. hide: true,
  291. },
  292. ]
  293. },
  294. data: []
  295. };
  296. },
  297. computed: {
  298. ...mapGetters(["permission"]),
  299. ...mapGetters(["userInfo"]),
  300. permissionList() {
  301. return {
  302. addBtn: this.vaildData(this.permission.keypwd_add, false),
  303. viewBtn: this.vaildData(this.permission.keypwd_view, false),
  304. delBtn: this.vaildData(this.permission.keypwd_delete, false),
  305. editBtn: this.vaildData(this.permission.keypwd_edit, false)
  306. };
  307. },
  308. ids() {
  309. let ids = [];
  310. this.selectionList.forEach(ele => {
  311. ids.push(ele.id);
  312. });
  313. return ids.join(",");
  314. }
  315. },
  316. created() {
  317. this.initTypeDict();
  318. getDeptTree().then(res => {
  319. const column = this.findObject(this.option.column, "orgNos");
  320. let treeData = getTree(res.data.data, this.userInfo.dept_id);
  321. column.dicData = treeData;
  322. });
  323. },
  324. methods: {
  325. handleDownload(){
  326. if (this.selectionList.length === 0) {
  327. this.$message.warning("請選擇至少一條數據");
  328. return;
  329. }
  330. let columns = this.deepClone(this.option.column);
  331. for (let i = 0; i < columns.length; i++) {
  332. let item = columns[i];
  333. if (item.hide || item.prop == 'process'){
  334. columns.splice(i, 1);
  335. i--;
  336. }
  337. if (item.type == 'select' || item.type == 'tree'){
  338. item.prop = '$' + item.prop;
  339. }
  340. }
  341. this.$Export.excel({
  342. title: "網點鎖匙密碼實物保管人" || new Date().getTime(),
  343. columns: columns,
  344. data: this.selectionList
  345. });
  346. },
  347. initTypeDict(){
  348. getKeyType().then(res => {
  349. let data = res.data.data;
  350. let pid = new Set();
  351. for (let i = 0; i < data.length; i++) {
  352. let item = data[i];
  353. pid.add(item.parentId);
  354. }
  355. let arr = [];
  356. pid.forEach(id => {
  357. data.forEach(item => {
  358. if (id == item.id){
  359. arr.push(item)
  360. }
  361. })
  362. })
  363. arr.forEach(item => {
  364. data.forEach(it => {
  365. if (item.id == it.parentId){
  366. if (!item.children){
  367. item.children = [];
  368. }
  369. it.dictValue = item.dictValue + '-' + it.dictValue;
  370. item.children.push(it)
  371. item.hasChildren = true;
  372. }
  373. })
  374. })
  375. this.typeList = arr;
  376. this.findObject(this.option.column, 'category').dicData = arr;
  377. return arr;
  378. })
  379. },
  380. handoverSelectCallback(value){
  381. this.form.handoverPersonNo = value.ehr;
  382. this.form.handoverPersonName = value.name;
  383. },
  384. selectCallback(value){
  385. this.form.receiverNo = value.ehr;
  386. this.form.receiverName = value.name;
  387. },
  388. rowSave(row, done, loading) {
  389. add(row).then(() => {
  390. this.onLoad(this.page);
  391. this.$message({
  392. type: "success",
  393. message: "操作成功!"
  394. });
  395. done();
  396. }, error => {
  397. loading();
  398. window.console.log(error);
  399. });
  400. },
  401. rowUpdate(row, index, done, loading) {
  402. update(row).then(() => {
  403. this.onLoad(this.page);
  404. this.$message({
  405. type: "success",
  406. message: "操作成功!"
  407. });
  408. done();
  409. }, error => {
  410. loading();
  411. console.log(error);
  412. });
  413. },
  414. rowDel(row) {
  415. this.$confirm("確定將選擇數據刪除?", {
  416. confirmButtonText: "確定",
  417. cancelButtonText: "取消",
  418. type: "warning"
  419. })
  420. .then(() => {
  421. return remove(row.id);
  422. })
  423. .then(() => {
  424. this.onLoad(this.page);
  425. this.$message({
  426. type: "success",
  427. message: "操作成功!"
  428. });
  429. });
  430. },
  431. handleDelete() {
  432. if (this.selectionList.length === 0) {
  433. this.$message.warning("請選擇至少一條數據");
  434. return;
  435. }
  436. this.$confirm("確定將選擇數據刪除?", {
  437. confirmButtonText: "確定",
  438. cancelButtonText: "取消",
  439. type: "warning"
  440. })
  441. .then(() => {
  442. return remove(this.ids);
  443. })
  444. .then(() => {
  445. this.onLoad(this.page);
  446. this.$message({
  447. type: "success",
  448. message: "操作成功!"
  449. });
  450. this.$refs.crud.toggleSelection();
  451. });
  452. },
  453. beforeOpen(done, type) {
  454. this.type = type;
  455. if (type === 'add'){
  456. let userInfo = localStorage.getItem("saber-userInfo");
  457. this.form.number = 1;
  458. this.form.handoverDate = dateFormat(new Date(), "yyyy-MM-dd hh:mm");
  459. getCurrentDept().then(res => {
  460. const data = res.data.data;
  461. this.form.bankNo = data.bankNo;
  462. this.form.orgNo = data.orgNo;
  463. this.form.orgName = data.deptName;
  464. });
  465. }
  466. if (["edit", "view"].includes(type)) {
  467. getDetail(this.form.id).then(res => {
  468. this.form = res.data.data;
  469. });
  470. }
  471. done();
  472. },
  473. searchReset() {
  474. this.query = {};
  475. this.onLoad(this.page);
  476. },
  477. searchChange(params, done) {
  478. if (params.category){
  479. params.category = params.category.join();
  480. }
  481. if (params.orgNos){
  482. params.orgNostr = params.orgNos.join();
  483. params.orgNos = '';
  484. }
  485. if (params.handoverDateRange){
  486. params.handoverDate_begin = params.handoverDateRange[0], params.handoverDate_end = params.handoverDateRange[1];
  487. params.handoverDateRange = null;
  488. }
  489. this.query = params;
  490. this.page.currentPage = 1;
  491. this.onLoad(this.page, params);
  492. done();
  493. },
  494. selectionChange(list) {
  495. this.selectionList = list;
  496. },
  497. selectionClear() {
  498. this.selectionList = [];
  499. this.$refs.crud.toggleSelection();
  500. },
  501. currentChange(currentPage){
  502. this.page.currentPage = currentPage;
  503. },
  504. sizeChange(pageSize){
  505. this.page.pageSize = pageSize;
  506. },
  507. refreshChange() {
  508. this.onLoad(this.page, this.query);
  509. },
  510. onLoad(page, params = {}) {
  511. this.loading = true;
  512. getKeepList(params).then(res => {
  513. const data = res.data.data;
  514. this.data = data;
  515. this.loading = false;
  516. this.selectionClear();
  517. });
  518. }
  519. }
  520. };
  521. </script>
  522. <style>
  523. </style>