collectionPayment.vue 21 KB

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