collectionPayment2.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <template>
  2. <div class="app-container">
  3. <!-- 查询和其他操作 -->
  4. <div class="filter-container">
  5. <el-input v-model="listQuery.type.receivingWithdrawingPeople" clearable class="filter-item" size="small"
  6. style="width: 200px;" placeholder="请输入提款人姓名" />
  7. <!-- <el-input v-model="listQuery.type.receivingWithdrawingRegion" clearable class="filter-item" size="small"
  8. style="width: 200px;" placeholder="请输入提款地" /> -->
  9. <!-- <el-input v-model="listQuery.receiptPaymentDate" clearable class="filter-item" size="small"
  10. style="width: 200px;" placeholder="请输入提款日期" /> -->
  11. <el-select v-model="listQuery.type.receivingWithdrawingRegion" placeholder="请选择收款地" style="margin:0 20px;"
  12. size="small">
  13. <el-option :label="item.country" :value="item.country" v-for="(item, index) in placeList" :key="index">
  14. </el-option>
  15. </el-select>
  16. <el-date-picker style="margin-right:20px" size="small" v-model="selectDate" type="daterange" value-format="yyyy-MM-dd"
  17. range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
  18. </el-date-picker>
  19. <el-button v-permission="['collectionPayment:collectionpayment:list']" class="filter-item" type="primary"
  20. size="mini" icon="el-icon-search" @click="handleFilter">查找</el-button>
  21. <el-button v-permission="['collectionPayment:collectionpayment:create']" class="filter-item" type="primary"
  22. size="mini" icon="el-icon-edit" @click="handleCreate">添加</el-button>
  23. <el-button v-permission="['collectionPayment:collectionpayment:create']" class="filter-item" type="primary"
  24. size="mini" icon="el-icon-edit" @click="exportlist">导出</el-button>
  25. <el-upload style="margin-left: 8px;margin-bottom:0" class="filter-item" action="" :on-change="importClick"
  26. :show-file-list="false"
  27. accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
  28. :auto-upload="false">
  29. <el-button v-permission="['collectionPayment:collectionpayment:create']" class="filter-item"
  30. type="primary" size="mini" icon="el-icon-edit">导入</el-button>
  31. </el-upload>
  32. </div>
  33. <!-- 查询结果 -->
  34. <el-table v-loading="listLoading" :data="list" size="small" element-loading-text="正在查询中。。。" border fit
  35. highlight-current-row show-summary :summary-method="getSummaries" @selection-change="handleSelectionChange">
  36. <el-table-column :selectable="selectInit" type="selection"></el-table-column>
  37. <el-table-column type="index" label="序号">
  38. <template scope="scope">
  39. <span v-if="scope.$index < 9">0{{ scope.$index + 1 }}</span>
  40. <span v-else>{{ scope.$index + 1 }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column align="center" label="提款日期" prop="receiptPaymentDate">
  44. <template slot-scope="scope">
  45. {{ scope.row.receiptPaymentDate | formatDate }}</template>
  46. </el-table-column>
  47. <el-table-column align="center" label="提款地" prop="receivingWithdrawingRegion" />
  48. <el-table-column align="center" label="提款人" prop="receivingWithdrawingPeople" />
  49. <el-table-column align="center" label="金额(欧元)" prop="deductionEuro" />
  50. <el-table-column align="center" label="金额(人民币)" prop="deductionRmb" />
  51. <el-table-column align="center" label="备注1" prop="remarks" />
  52. <el-table-column align="center" label="备注2" prop="remark" />
  53. <el-table-column align="center" label="状态" prop="status">
  54. <template slot-scope="scope">
  55. {{ scope.row.status == 1 ? '已作废' : '' }}</template>
  56. </el-table-column>
  57. <el-table-column align="center" label="操作人" prop="updatePeople" />
  58. <el-table-column align="center" label="操作" class-name="small-padding fixed-width">
  59. <template slot-scope="scope">
  60. <el-button v-permission="['collectionPayment:collectionpayment:edit']" type="primary" size="mini"
  61. @click="handleUpdate(scope.row)">编辑</el-button>
  62. <el-button v-permission="['collectionPayment:collectionpayment:edit']" type="primary" size="mini"
  63. @click="updateData1(scope.row)">作废</el-button>
  64. <!-- <el-button v-permission="['collectionPayment:collectionpayment:delete']" type="danger" size="mini"
  65. @click="handleDelete(scope.row)">删除</el-button> -->
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!-- <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
  70. @pagination="getList"/> -->
  71. <el-pagination
  72. @size-change="handleSizeChange"
  73. @current-change="handleCurrentChange"
  74. :current-page="currentPage"
  75. :page-size="[100,200,300,400,500,600]"
  76. layout="total, sizes, prev, pager, next, jumper"
  77. :total="total"
  78. >
  79. </el-pagination>
  80. <!-- 添加或修改对话框 -->
  81. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
  82. <el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-position="left"
  83. label-width="150px" style="width: 400px; margin-left:50px;">
  84. <el-form-item label="id" prop="id" hidden>
  85. <el-input v-model="dataForm.id" />
  86. </el-form-item>
  87. <el-form-item label="提款人" prop="receivingWithdrawingPeople">
  88. <el-input v-model="dataForm.receivingWithdrawingPeople" />
  89. </el-form-item>
  90. <el-form-item label="提款地" prop="receivingWithdrawingRegion">
  91. <!-- <el-input v-model="dataForm.receivingWithdrawingRegion" /> -->
  92. <el-select v-model="dataForm.receivingWithdrawingRegion" placeholder="请选择提款地点" style="width:100%">
  93. <el-option :label="item.country" :value="item.country" v-for="(item, index) in placeList"
  94. :key="index"></el-option>
  95. </el-select>
  96. </el-form-item>
  97. <el-form-item label="提款日期" prop="receiptPaymentDate">
  98. <!-- <el-input v-model="dataForm.receiptPaymentDate" /> -->
  99. <el-date-picker v-model="dataForm.receiptPaymentDate" type="date" class="tkdate" value-format="yyyy-MM-dd"
  100. style="width: 100%;">
  101. </el-date-picker>
  102. </el-form-item>
  103. <el-form-item label="金额(欧元)" prop="deductionEuro">
  104. <el-input v-model="dataForm.deductionEuro" />
  105. </el-form-item>
  106. <el-form-item label="金额(人民币)" prop="deductionRmb">
  107. <el-input v-model="dataForm.deductionRmb" />
  108. </el-form-item>
  109. <el-form-item label="备注1" prop="remarks">
  110. <el-input v-model="dataForm.remarks" />
  111. </el-form-item>
  112. <el-form-item label="备注2" prop="remark">
  113. <el-input v-model="dataForm.remark" />
  114. </el-form-item>
  115. </el-form>
  116. <div slot="footer" class="dialog-footer">
  117. <el-button @click="dialogFormVisible = false">取消</el-button>
  118. <el-button v-if="dialogStatus == 'create'" :loading="submiting" type="primary" @click="createData">确定
  119. </el-button>
  120. <el-button v-else type="primary" :loading="submiting" @click="updateData">确定</el-button>
  121. </div>
  122. </el-dialog>
  123. </div>
  124. </template>
  125. <script>
  126. import {
  127. dayjs,
  128. EventBus
  129. } from 'base-core-lib'
  130. import {
  131. listCountry
  132. } from '@/api/country'
  133. import {
  134. downloadFile
  135. } from '@/utils/batchDown'
  136. import {
  137. importWord,
  138. listCollectionPayment,
  139. createCollectionPayment,
  140. updateCollectionPayment,
  141. deleteCollectionPayment,
  142. exportXlsx
  143. } from '@/api/collectionPayment'
  144. // import {
  145. // exportXlsx
  146. // } from '@/model/export'
  147. import Pagination from '@/components/Pagination'
  148. import store from '@/store'
  149. export default {
  150. name: 'CollectionPayment',
  151. components: { Pagination },
  152. data() {
  153. return {
  154. isAllowExport: true,
  155. countryList: [],
  156. modification: [],
  157. selectDate: '',
  158. date: {
  159. year: dayjs().format('YYYY'),
  160. month: dayjs().format('MM'),
  161. },
  162. accessoryTFs: false,
  163. fileList: [],
  164. appendixIdsAdd: '',
  165. excelFreightspace: [],
  166. fileTemp: null,
  167. placeList: [],
  168. list: null,
  169. total: 0,
  170. listLoading: true,
  171. listQuery: {
  172. page: 1,
  173. limit: 20,
  174. type: {
  175. businessType: 2,
  176. receivingWithdrawingPeople: '',
  177. receivingWithdrawingRegion: '',
  178. startDate: '',
  179. endDate: '',
  180. },
  181. },
  182. listPlace: {
  183. page: 1,
  184. limit: 2000,
  185. type: {
  186. country: ''
  187. }
  188. },
  189. dataForm: {
  190. id: undefined
  191. },
  192. dialogFormVisible: false,
  193. submiting: false,
  194. dialogStatus: '',
  195. textMap: {
  196. update: '编辑',
  197. create: '创建'
  198. },
  199. rules: {
  200. }
  201. }
  202. },
  203. created() {
  204. this.getList()
  205. },
  206. methods: {
  207. handleSizeChange(val) {
  208. console.log(`每页 ${val} 条`)
  209. this.pageSize = val
  210. this.getList()
  211. },
  212. handleCurrentChange(val) {
  213. this.currentPage = val
  214. console.log(`当前页: ${val}`)
  215. this.getList()
  216. },
  217. handleSelectionChange(val) {
  218. this.modification = val
  219. },
  220. selectInit(row) {
  221. return true
  222. },
  223. async exportlist() {
  224. if (this.modification.length == 0) {
  225. this.$message.warning('请选择要导出的条目!')
  226. } else {
  227. console.log('导出数据', this.modification)
  228. let _data = {
  229. collectionPaymentTiDTOList: this.modification,
  230. }
  231. const {
  232. data
  233. } = await exportXlsx(_data).then((response) => {
  234. this.download(response.data.data)
  235. // downloadFile({
  236. // res: data,
  237. // fileName: `${
  238. // this.date.year + (this.date.month ? `-${this.date.month}` : '')
  239. // }提款信息`,
  240. // type: 'xls',
  241. // })
  242. if (response.status == '200') {
  243. }
  244. })
  245. }
  246. },
  247. importClick(file, fileList) {
  248. this.fileTemp = file.raw
  249. let fileName = file.raw.name
  250. let fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
  251. // 判断上传文件格式
  252. if (this.fileTemp) {
  253. if (fileType == 'xlsx' || fileType == 'xls') {
  254. this.importf(this.fileTemp)
  255. } else {
  256. this.$message({
  257. type: 'warning',
  258. message: '附件格式错误,请删除后重新上传!',
  259. })
  260. }
  261. } else {
  262. this.$message({
  263. type: 'warning',
  264. message: '请上传附件!',
  265. })
  266. }
  267. },
  268. importf(obj) {
  269. this.excelFreightspace = []
  270. // this.dialogVisible = true;
  271. let _this = this;
  272. let inputDOM = this.$refs.inputer; // 通过DOM取文件数据
  273. this.file = event.currentTarget.files[0];
  274. var rABS = false; //是否将文件读取为二进制字符串
  275. var f = this.file;
  276. var reader = new FileReader();
  277. //if (!FileReader.prototype.readAsBinaryString) {
  278. FileReader.prototype.readAsBinaryString = function (f) {
  279. var binary = '';
  280. var rABS = false; //是否将文件读取为二进制字符串
  281. var pt = this;
  282. var wb; //读取完成的数据
  283. var outdata;
  284. var reader = new FileReader();
  285. reader.onload = function (e) {
  286. var bytes = new Uint8Array(reader.result);
  287. var length = bytes.byteLength;
  288. for (var i = 0; i < length; i++) {
  289. binary += String.fromCharCode(bytes[i]);
  290. }
  291. var XLSX = require('xlsx');
  292. if (rABS) {
  293. wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
  294. type: 'base64',
  295. cellDates: true
  296. });
  297. } else {
  298. wb = XLSX.read(binary, {
  299. type: 'binary'
  300. });
  301. }
  302. // outdata就是你想要的东西 excel导入的数据
  303. outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
  304. // excel 数据再处理
  305. let arr = []
  306. outdata.map(v => {
  307. // let jsonString = JSON.stringify(v).replace(/\*/g, '').replace(/\s/ig,'');
  308. let jsonString = JSON.stringify(v).replace(/\//g, '').replace(/\s/ig, '');
  309. v = JSON.parse(jsonString);
  310. let obj = {}
  311. //xxx代表列名
  312. obj.receiptPaymentDate = v.提款日期
  313. obj.receivingWithdrawingRegion = v.提款地
  314. obj.receivingWithdrawingPeople = v.提款人
  315. obj.deductionEuro = v.金额EUR
  316. obj.deductionRmb = v.金额RMB
  317. obj.businessType = 2
  318. obj.remarks = v.备注1
  319. obj.remark = v.备注2
  320. obj.updatePeople = _this.$store.getters.name
  321. if (!obj.deductionEuro) {
  322. obj.deductionEuro = 0
  323. }
  324. if (!obj.deductionRmb) {
  325. obj.deductionRmb = 0
  326. }
  327. for (let i = 0; i < _this.placeList.length; i++) {
  328. _this.countryList.push(_this.placeList[i].country)
  329. }
  330. if (!_this.countryList.includes(obj.receivingWithdrawingRegion)) {
  331. _this.isAllowExport = false
  332. _this.$notify({
  333. title: '失败',
  334. message: '导入失败,导入数据中收款地在系统中不存在,请重新编辑',
  335. type: 'error'
  336. });
  337. return
  338. } else {
  339. _this.excelFreightspace.push(obj)
  340. _this.isAllowExport = true
  341. }
  342. })
  343. if (_this.excelFreightspace && _this.isAllowExport) {
  344. importWord(_this.excelFreightspace).then((response) => {
  345. if (response.status == '200') {
  346. _this.$notify({
  347. title: '成功',
  348. message: '导入成功',
  349. type: 'success'
  350. });
  351. _this.getList()
  352. }
  353. })
  354. }
  355. }
  356. reader.readAsArrayBuffer(f);
  357. }
  358. if (rABS) {
  359. reader.readAsArrayBuffer(f);
  360. } else {
  361. reader.readAsBinaryString(f);
  362. }
  363. },
  364. formatDate(numb, format) {
  365. const old = numb - 1;
  366. const t = Math.round((old - Math.floor(old)) * 24 * 60 * 60);
  367. const time = new Date(1900, 0, old, 0, 0, t)
  368. const year = time.getFullYear();
  369. const month = time.getMonth() + 1;
  370. const date = time.getDate();
  371. return year + format + (month < 10 ? '0' + month : month) + format + (date < 10 ? '0' + date : date) + ' 00:00:00'
  372. },
  373. getSummaries(param) {
  374. const { columns, data } = param;
  375. const sums = [];
  376. columns.forEach((column, index) => {
  377. if (index === 0) {
  378. sums[index] = "合计";
  379. return;
  380. } else if (index == 5 || index == 6) {
  381. const values = data.map((item) => Number(item[column.property]));
  382. if (!values.every((value) => isNaN(value))) {
  383. sums[index] = values.reduce((prev, curr) => {
  384. const value = Number(curr);
  385. if (!isNaN(value)) {
  386. return prev + curr;
  387. } else {
  388. return prev;
  389. }
  390. }, 0);
  391. sums[index] += "";
  392. } else {
  393. sums[index] = "--";
  394. }
  395. } else {
  396. // sums[index] = "--";
  397. }
  398. });
  399. return sums;
  400. },
  401. getList() {
  402. console.log(this.selectDate)
  403. listCountry(this.listPlace).then(response => {
  404. this.placeList = response.data.data.items
  405. })
  406. .catch(() => {
  407. this.placeList = []
  408. })
  409. this.listLoading = true
  410. console.log(this.selectDate)
  411. if (this.selectDate.length > 0) {
  412. this.listQuery.type.startDate = dayjs(this.selectDate[0]).format('YYYY-MM-DD')
  413. this.listQuery.type.endDate = dayjs(this.selectDate[1]).format('YYYY-MM-DD')
  414. }
  415. listCollectionPayment(this.listQuery).then(response => {
  416. this.list = response.data.data.items
  417. this.total = response.data.data.total
  418. this.listLoading = false
  419. })
  420. .catch(() => {
  421. this.list = []
  422. this.total = 0
  423. this.listLoading = false
  424. })
  425. },
  426. handleFilter() {
  427. this.listQuery.page = 1
  428. this.getList()
  429. },
  430. resetForm() {
  431. this.dataForm = {
  432. id: undefined
  433. }
  434. },
  435. handleCreate() {
  436. this.resetForm()
  437. this.dialogStatus = 'create'
  438. this.dialogFormVisible = true
  439. this.$nextTick(() => {
  440. this.$refs['dataForm'].clearValidate()
  441. })
  442. },
  443. createData() {
  444. this.$refs['dataForm'].validate(valid => {
  445. if (valid) {
  446. this.submiting = true
  447. this.dataForm.businessType = 2
  448. this.dataForm.updatePeople = this.$store.getters.name
  449. if (!this.dataForm.deductionEuro) {
  450. this.dataForm.deductionEuro = 0
  451. }
  452. if (!this.dataForm.deductionRmb) {
  453. this.dataForm.deductionRmb = 0
  454. }
  455. createCollectionPayment(this.dataForm).then(response => {
  456. this.list.unshift(response.data.data)
  457. this.dialogFormVisible = false
  458. this.$notify.success({
  459. title: '成功',
  460. message: '添加成功'
  461. })
  462. this.submiting = false
  463. })
  464. .catch(response => {
  465. this.$notify.error({
  466. title: '失败',
  467. message: response.data.errmsg
  468. })
  469. this.submiting = false
  470. })
  471. }
  472. })
  473. },
  474. handleUpdate(row) {
  475. this.dataForm = Object.assign({}, row)
  476. this.dialogStatus = 'update'
  477. this.dialogFormVisible = true
  478. this.$nextTick(() => {
  479. this.$refs['dataForm'].clearValidate()
  480. })
  481. },
  482. updateData() {
  483. this.$refs['dataForm'].validate(valid => {
  484. if (valid) {
  485. this.submiting = true
  486. this.dataForm.updatePeople = this.$store.getters.name
  487. updateCollectionPayment(this.dataForm).then(() => {
  488. for (const v of this.list) {
  489. if (v.id === this.dataForm.id) {
  490. const index = this.list.indexOf(v)
  491. this.list.splice(index, 1, this.dataForm)
  492. break
  493. }
  494. }
  495. this.dialogFormVisible = false
  496. this.submiting = false
  497. this.$notify.success({
  498. title: '成功',
  499. message: '更新成功'
  500. })
  501. })
  502. .catch(response => {
  503. this.$notify.error({
  504. title: '失败',
  505. message: response.data.errmsg
  506. })
  507. this.submiting = false
  508. })
  509. }
  510. })
  511. },
  512. updateData1(row) {
  513. this.dataForm.flag = 1
  514. this.dataForm.id = row.id
  515. updateCollectionPayment(this.dataForm).then(() => {
  516. this.submiting = false
  517. this.$notify.success({
  518. title: '成功',
  519. message: '更新成功',
  520. })
  521. this.getList()
  522. })
  523. .catch(response => {
  524. this.$notify.error({
  525. title: '失败',
  526. message: response.data.errmsg
  527. })
  528. this.submiting = false
  529. })
  530. },
  531. handleDelete(row) {
  532. this.$confirm('此操作将永久删除该记录---' + row.id + '---, 是否继续?', '提示', {
  533. confirmButtonText: '确定',
  534. cancelButtonText: '取消',
  535. type: 'warning'
  536. }).then(() => {
  537. deleteCollectionPayment(row.id).then(response => {
  538. this.$notify.success({
  539. title: '成功',
  540. message: '删除成功'
  541. })
  542. const index = this.list.indexOf(row)
  543. this.list.splice(index, 1)
  544. })
  545. .catch(response => {
  546. this.$notify.error({
  547. title: '失败',
  548. message: response.data.errmsg
  549. })
  550. })
  551. }).catch(() => {
  552. return false
  553. })
  554. }
  555. }
  556. }
  557. </script>
  558. <style>
  559. </style>