init-tellertrunk.vue 24 KB

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