init-checkwarehouse.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  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="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.checkwarehouse_delete"
  27. @click="handleDelete">刪 除
  28. </el-button>
  29. <el-button type="primary"
  30. size="small"
  31. icon="el-icon-download"
  32. plain
  33. v-if="permission.checkwarehouse_download"
  34. @click="handleDownload">下載
  35. </el-button>
  36. </template>
  37. <template slot-scope="{row}" slot="menu">
  38. <el-button size="small" class="el-button--text" v-if="permission.checkwarehouse_edit && userInfo.user_id == row.createUser" @click="$refs.crud.rowEdit(row, index)"><i class="el-icon-edit"></i> 編 輯</el-button>
  39. <el-button size="small" class="el-button--text" v-if="permission.checkwarehouse_delete && userInfo.user_id == row.createUser" @click="$refs.crud.rowDel(row, index)"><i class="el-icon-delete"></i> 刪 除</el-button>
  40. <el-button type="text" icon="el-icon-download" size="small" v-if="permission.checkwarehouse_download_file && row.enclosure" @click="fileDownload(row)">附件下載</el-button>
  41. </template>
  42. <!-- <template slot="checkPersonNameForm">
  43. <select-dialog-user :name="form.checkPersonName" :ehr="form.checkPersonNo" :disabled="false" :callback="selectCallback"></select-dialog-user>
  44. </template>-->
  45. <template slot="enclosureForm" slot-scope="{row}">
  46. <avue-form ref="form" :option="attachOption" v-model="attachForm" :upload-after="uploadAfter" :upload-error="uploadError" :upload-delete="uploadDelete" :upload-preview="uploadPreview">
  47. </avue-form>
  48. </template>
  49. <template slot="titleForm" slot-scope="{row, index}">
  50. <div v-html="title" style="white-space: pre-line;font-size: 8px;"></div>
  51. </template>
  52. </avue-crud>
  53. </basic-container>
  54. </template>
  55. <script>
  56. import {getList, getDetail, add, update, remove, getDownloadList} from "@/api/bank/checkwarehouse";
  57. import {mapGetters} from "vuex";
  58. import { getCurrentDept } from "@/api/system/dept";
  59. import {dateFormat} from "@/util/date";
  60. import SelectDialogUser from "@/components/select-dialog/select-dialog-user";
  61. import {getDeptTree, getTree} from "@/api/system/dept";
  62. import {getStandardByCode} from "@/api/bank/handoverstandard";
  63. import {downloadFileBase64} from "@/util/util";
  64. export default {
  65. name: "init-checkwarehouse",
  66. components: {SelectDialogUser},
  67. data() {
  68. return {
  69. title: "",
  70. attachBox: false,
  71. attachForm: {},
  72. attachOption: {
  73. submitBtn: false,
  74. emptyBtn: false,
  75. column: [
  76. {
  77. // label: '附件上傳',
  78. prop: 'attachFile',
  79. type: 'upload',
  80. disabled: true,
  81. drag: true,
  82. loadText: '模板上傳中,請稍等',
  83. span: 24,
  84. fileSize: 5120,
  85. propsHttp: {
  86. res: 'data'
  87. },
  88. name: "namesrc",
  89. action: "/api/blade-resource/oss/endpoint/put-file-attach"
  90. }
  91. ]
  92. },
  93. form: {
  94. },
  95. query: {},
  96. loading: true,
  97. page: {
  98. pageSize: 10,
  99. currentPage: 1,
  100. total: 0
  101. },
  102. selectionList: [],
  103. option: {
  104. addTitle: '新增【查庫流水帳記錄表】',
  105. editTitle: '編輯【查庫流水帳記錄表】',
  106. viewTitle: '查看【查庫流水帳記錄表】',
  107. height:'auto',
  108. calcHeight: 30,
  109. index: false,
  110. tip: false,
  111. searchShow: true,
  112. searchMenuSpan: 6,
  113. border: true,
  114. viewBtn: true,
  115. editBtn: false,
  116. delBtn: false,
  117. selection: true,
  118. dialogClickModal: false,
  119. column: [
  120. {
  121. label: '交接標準',
  122. prop: 'title',
  123. formslot: true,
  124. hide: true,
  125. type: 'text',
  126. span: 24
  127. },
  128. {
  129. label: "填報時間",
  130. prop: "fillingDate",
  131. addDisplay: false,
  132. editDisplay: false,
  133. rules: [{
  134. required: true,
  135. message: "請輸入填報時間",
  136. trigger: "blur"
  137. }]
  138. },
  139. {
  140. label: "填報人",
  141. prop: "fillingPerson",
  142. addDisplay: false,
  143. editDisplay: false,
  144. rules: [{
  145. required: true,
  146. message: "請輸入填報人",
  147. trigger: "blur"
  148. }]
  149. },
  150. {
  151. label: "銀行號",
  152. prop: "bankNo",
  153. disabled: true,
  154. search: true,
  155. searchSpan: 4,
  156. rules: [{
  157. required: true,
  158. message: "請輸入銀行號",
  159. trigger: "blur"
  160. }]
  161. },
  162. {
  163. label: "機構號",
  164. prop: "orgNo",
  165. disabled: true,
  166. rules: [{
  167. required: true,
  168. message: "請輸入機構號",
  169. trigger: "blur"
  170. }]
  171. },
  172. {
  173. label: "區域/支行",
  174. prop: "orgNos",
  175. hide: true,
  176. display: false,
  177. searchMultiple: true,
  178. search: true,
  179. type: "tree",
  180. dicData: [],
  181. props: {
  182. label: "title",
  183. value: "key"
  184. },
  185. checkStrictly: true,
  186. rules: [{
  187. required: true,
  188. message: "請輸入機構號",
  189. trigger: "blur"
  190. }]
  191. },
  192. {
  193. label: "查庫時間",
  194. prop: "checkTimeRange",
  195. type: "datetime",
  196. format: "yyyy-MM-dd HH:mm",
  197. valueFormat: "yyyy-MM-dd HH:mm",
  198. searchRange:true,
  199. hide: true,
  200. addDisplay: false,
  201. editDisplay: false,
  202. viewDisplay: false,
  203. search: true,
  204. rules: [{
  205. required: true,
  206. message: "請輸入交接日期",
  207. trigger: "blur"
  208. }]
  209. },
  210. {
  211. label: "檢查時間開始",
  212. prop: "checkTimeBegin",
  213. type: "datetime",
  214. format: "yyyy-MM-dd HH:mm",
  215. valueFormat: "yyyy-MM-dd HH:mm",
  216. rules: [{
  217. required: true,
  218. message: "請輸入檢查時間開始",
  219. trigger: "blur"
  220. }]
  221. },
  222. {
  223. label: "檢查時間結束",
  224. prop: "checkTimeEnd",
  225. type: "datetime",
  226. format: "yyyy-MM-dd HH:mm",
  227. valueFormat: "yyyy-MM-dd HH:mm",
  228. rules: [{
  229. required: true,
  230. message: "請輸入檢查時間結束",
  231. trigger: "blur"
  232. }]
  233. },
  234. {
  235. label: "檢查單位",
  236. prop: "checkUnit",
  237. type: "select",
  238. search: true,
  239. searchSpan: 4,
  240. multiple: true,
  241. dicUrl: "/api/blade-system/dict/dictionary?code=unit_type",
  242. props:{
  243. label: "dictValue",
  244. value: "dictKey",
  245. },
  246. dicFormatter: (res) => {
  247. res.data.forEach(item => {item.disabled = item.isSealed == 1;})
  248. return res.data;
  249. },
  250. change: ({value, column}) => {
  251. /*if (!value) return;
  252. let $nameOut = this.findObject(this.option.column, 'checkPersonNameOut');
  253. $nameOut.display = value != '1';
  254. let $noOut = this.findObject(this.option.column, 'checkPersonNoOut');
  255. $noOut.display = value != '1';
  256. let $name = this.findObject(this.option.column, 'checkPersonName');
  257. $name.display = value == '1';
  258. let $no = this.findObject(this.option.column, 'checkPersonNo');
  259. $no.display = value == '1';
  260. $no.disabled = value == '1';
  261. if (!this.form.checkResult) return;
  262. let $remark = this.findObject(this.option.column, 'remark');
  263. if (value == '1' && this.form.checkResult == '1'){
  264. $remark.rules[0].required = false;
  265. }else{
  266. $remark.rules[0].required = true;
  267. }*/
  268. },
  269. rules: [{
  270. required: true,
  271. message: "請輸入檢查單位",
  272. trigger: "blur"
  273. }]
  274. },
  275. {
  276. label: "檢查目的",
  277. prop: "checkPurpose",
  278. type: "select",
  279. dicUrl: "/api/blade-system/dict/dictionary?code=check_purpose",
  280. props:{
  281. label: "dictValue",
  282. value: "dictKey",
  283. },
  284. multiple: true,
  285. search: true,
  286. searchSpan: 4,
  287. dicFormatter: (res) => {
  288. res.data.forEach(item => {item.disabled = item.isSealed == 1;})
  289. return res.data;
  290. },
  291. rules: [{
  292. required: true,
  293. message: "請輸入檢查目的",
  294. trigger: "blur"
  295. }]
  296. },
  297. {
  298. label: "檢查內容",
  299. prop: "checkContent",
  300. type: "select",
  301. search: true,
  302. searchSpan: 4,
  303. multiple: true,
  304. dicUrl: "/api/blade-system/dict/dictionary?code=check_content_warehouse",
  305. props:{
  306. label: "dictValue",
  307. value: "dictKey",
  308. },
  309. dicFormatter: (res) => {
  310. res.data.forEach(item => {item.disabled = item.isSealed == 1;})
  311. return res.data;
  312. },
  313. rules: [{
  314. required: true,
  315. message: "請輸入檢查內容",
  316. trigger: "blur"
  317. }]
  318. },
  319. {
  320. label: "核對結果",
  321. prop: "checkResult",
  322. type: "select",
  323. dicUrl: "/api/blade-system/dict/dictionary?code=check_result",
  324. props:{
  325. label: "dictValue",
  326. value: "dictKey",
  327. },
  328. dicFormatter: (res) => {
  329. res.data.forEach(item => {item.disabled = item.isSealed == 1;})
  330. return res.data;
  331. },
  332. tip: "不能為空值;如選擇〝帳實不符〞需要在備註欄解釋原因",
  333. change: ({value, column}) => {
  334. /* if (!this.form.checkUnit || !value) return;
  335. let $remark = this.findObject(this.option.column, 'remark');
  336. if (this.form.checkUnit == '1' && value == '1'){
  337. $remark.rules[0].required = false;
  338. }else{
  339. $remark.rules[0].required = true;
  340. }*/
  341. },
  342. rules: [{
  343. required: true,
  344. message: "請輸入核對結果",
  345. trigger: "blur"
  346. }]
  347. },
  348. {
  349. label: "查庫人員",
  350. prop: "checkPersonName",
  351. // formslot: true,
  352. type: "array",
  353. span: 12,
  354. dataType: 'string',
  355. rules: [{
  356. required: true,
  357. message: "請輸入查庫人員姓名",
  358. trigger: "change"
  359. }]
  360. },
  361. {
  362. label: "查庫人員工號或身份證後四位",
  363. prop: "checkPersonNo",
  364. type: "array",
  365. span: 12,
  366. dataType: 'string',
  367. rules: [{
  368. required: true,
  369. message: "請輸入查庫人員工號或身份證後四位",
  370. trigger: "blur"
  371. }]
  372. },
  373. {
  374. label: "備註",
  375. prop: "remark",
  376. // span: 24,
  377. type: 'textarea',
  378. rules: [{
  379. required: false,
  380. message: "請輸入備註(可間要補充檢查發現情況)",
  381. trigger: "blur"
  382. }]
  383. },
  384. {
  385. label: "附件",
  386. prop: "enclosure",
  387. formslot: true,
  388. hide: true,
  389. rules: [{
  390. required: false,
  391. message: "請上傳附件",
  392. trigger: "blur"
  393. }]
  394. },
  395. ]
  396. },
  397. data: []
  398. };
  399. },
  400. computed: {
  401. ...mapGetters(["permission"]),
  402. ...mapGetters(["userInfo"]),
  403. permissionList() {
  404. return {
  405. addBtn: this.vaildData(this.permission.checkwarehouse_add, false),
  406. viewBtn: this.vaildData(this.permission.checkwarehouse_view, false),
  407. delBtn: this.vaildData(this.permission.checkwarehouse_delete, false),
  408. editBtn: this.vaildData(this.permission.checkwarehouse_edit, false)
  409. };
  410. },
  411. ids() {
  412. let ids = [];
  413. this.selectionList.forEach(ele => {
  414. ids.push(ele.id);
  415. });
  416. return ids.join(",");
  417. },
  418. },
  419. mounted() {
  420. getDeptTree().then(res => {
  421. const column = this.findObject(this.option.column, "orgNos");
  422. let treeData = getTree(res.data.data, this.userInfo.dept_id);
  423. column.dicData = treeData;
  424. });
  425. getStandardByCode("checkwarehouse").then(res => {
  426. const data = res.data.data;
  427. if (Object.keys(data).length > 0){
  428. this.title = data.content;
  429. }else {
  430. this.option.column.splice(0,1)
  431. }
  432. });
  433. },
  434. methods: {
  435. fileDownload(row){
  436. downloadFileBase64(row.enclosure, row.enclosureName);
  437. },
  438. uploadPreview(){
  439. },
  440. uploadError(error,column){
  441. this.$message.warning(error + ',不能大於' + column.fileSize + 'KB');
  442. },
  443. uploadAfter(res, done, loading, column) {
  444. this.attachForm.attachFile = [res];
  445. this.form.enclosure = res.link;
  446. this.form.enclosureName = res.originalName;
  447. this.attachBox = false;
  448. done(res);
  449. },
  450. uploadDelete(column,file) {
  451. return this.$confirm(`是否確定移除該選項?`);
  452. },
  453. handleDownload(){
  454. if (this.selectionList.length === 0) {
  455. let tip = "確定下載篩選的" + this.page.total + "條數據嗎?"
  456. this.$confirm(tip, {
  457. confirmButtonText: "確定",
  458. cancelButtonText: "取消",
  459. type: "warning"
  460. })
  461. .then(() => {
  462. getDownloadList(this.query).then(res => {
  463. this.downLoadData(res.data.data, true)
  464. });
  465. })
  466. }else{
  467. this.downLoadData(this.selectionList, false)
  468. }
  469. },
  470. downLoadData(data, isAll){
  471. let columns = this.deepClone(this.option.column);
  472. for (let i = 0; i < columns.length; i++) {
  473. let item = columns[i];
  474. if (item.hide || item.prop == 'process'){
  475. columns.splice(i, 1);
  476. i--;
  477. }
  478. if (!isAll && (item.type == 'select' || item.type == 'tree')){
  479. item.prop = '$' + item.prop;
  480. }
  481. }
  482. this.$Export.excel({
  483. title: "查庫流水帳記錄表" || new Date().getTime(),
  484. columns: columns,
  485. data: data
  486. });
  487. },
  488. selectCallback(value){
  489. this.form.checkPersonNo = value.ehr;
  490. this.form.checkPersonName = value.name;
  491. },
  492. rowSave(row, done, loading) {
  493. if ( row.checkUnit instanceof Array) row.checkUnit = row.checkUnit.join();
  494. if ( row.checkPurpose instanceof Array) row.checkPurpose = row.checkPurpose.join();
  495. if ( row.checkContent instanceof Array) row.checkContent = row.checkContent.join();
  496. add(row).then(() => {
  497. this.onLoad(this.page);
  498. this.$message({
  499. type: "success",
  500. message: "操作成功!"
  501. });
  502. done();
  503. }, error => {
  504. loading();
  505. window.console.log(error);
  506. });
  507. },
  508. rowUpdate(row, index, done, loading) {
  509. if ( row.checkUnit instanceof Array) row.checkUnit = row.checkUnit.join();
  510. if ( row.checkPurpose instanceof Array) row.checkPurpose = row.checkPurpose.join();
  511. if ( row.checkContent instanceof Array) row.checkContent = row.checkContent.join();
  512. update(row).then(() => {
  513. this.onLoad(this.page);
  514. this.$message({
  515. type: "success",
  516. message: "操作成功!"
  517. });
  518. done();
  519. }, error => {
  520. loading();
  521. console.log(error);
  522. });
  523. },
  524. rowDel(row) {
  525. this.$confirm("確定將選擇數據刪除?", {
  526. confirmButtonText: "確定",
  527. cancelButtonText: "取消",
  528. type: "warning"
  529. })
  530. .then(() => {
  531. return remove(row.id);
  532. })
  533. .then(() => {
  534. this.onLoad(this.page);
  535. this.$message({
  536. type: "success",
  537. message: "操作成功!"
  538. });
  539. });
  540. },
  541. handleDelete() {
  542. if (this.selectionList.length === 0) {
  543. this.$message.warning("請選擇至少一條數據");
  544. return;
  545. }
  546. this.$confirm("確定將選擇數據刪除?", {
  547. confirmButtonText: "確定",
  548. cancelButtonText: "取消",
  549. type: "warning"
  550. })
  551. .then(() => {
  552. return remove(this.ids);
  553. })
  554. .then(() => {
  555. this.onLoad(this.page);
  556. this.$message({
  557. type: "success",
  558. message: "操作成功!"
  559. });
  560. this.$refs.crud.toggleSelection();
  561. });
  562. },
  563. beforeOpen(done, type) {
  564. this.attachForm = {};
  565. this.attachOption.column[0].disabled = type == 'view';
  566. if (type === 'add'){
  567. let userInfo = localStorage.getItem("saber-userInfo");
  568. this.form.number = 1;
  569. this.form.handoverDate = dateFormat(new Date(), "yyyy-MM-dd hh:mm");
  570. getCurrentDept().then(res => {
  571. const data = res.data.data;
  572. this.form.bankNo = data.bankNo;
  573. this.form.orgNo = data.orgNo;
  574. });
  575. }
  576. if (["edit", "view"].includes(type)) {
  577. getDetail(this.form.id).then(res => {
  578. const data = res.data.data;
  579. data.name = data.enclosureName;
  580. if (data.name){
  581. this.attachForm.attachFile = [
  582. {label: data.name, value: data.originalName}
  583. ];
  584. }
  585. this.form = data;
  586. });
  587. }
  588. done();
  589. },
  590. searchReset() {
  591. this.query = {};
  592. this.onLoad(this.page);
  593. },
  594. searchChange(params, done) {
  595. if (params.orgNos){
  596. params.orgNostr = params.orgNos.join();
  597. params.orgNos = '';
  598. }
  599. if (params.checkTimeRange){
  600. params.checkTime_begin = params.checkTimeRange[0], params.checkTime_end = params.checkTimeRange[1];
  601. params.checkTimeRange = null;
  602. }
  603. this.query = params;
  604. this.page.currentPage = 1;
  605. this.onLoad(this.page, params);
  606. done();
  607. },
  608. selectionChange(list) {
  609. this.selectionList = list;
  610. },
  611. selectionClear() {
  612. this.selectionList = [];
  613. this.$refs.crud.toggleSelection();
  614. },
  615. currentChange(currentPage){
  616. this.page.currentPage = currentPage;
  617. },
  618. sizeChange(pageSize){
  619. this.page.pageSize = pageSize;
  620. },
  621. refreshChange() {
  622. this.onLoad(this.page, this.query);
  623. },
  624. onLoad(page, params = {}) {
  625. this.loading = true;
  626. params.createUser = this.userInfo.user_id;
  627. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  628. const data = res.data.data;
  629. this.page.total = data.total;
  630. data.records.forEach(item => {
  631. item.checkPurpose = item.checkPurpose.split(',');
  632. item.checkContent = item.checkContent.split(',');
  633. item.checkUnit = item.checkUnit.split(',');
  634. })
  635. this.data = data.records;
  636. this.loading = false;
  637. this.selectionClear();
  638. });
  639. }
  640. }
  641. };
  642. </script>
  643. <style scoped>
  644. >>>.el-form-item__content{
  645. margin-left: 10px !important;
  646. }
  647. </style>