tellertrunk.vue 22 KB

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