customerBillingInfo.vue 18 KB

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