detailsPage.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <div>
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
  6. @click="backToList(0)">返回列表
  7. </el-button>
  8. </div>
  9. <div class="add-customer-btn">
  10. <el-button class="el-button&#45;&#45;small-yh" style="margin-right: 10px" type="primary" size="small"
  11. v-if="!editButton" @click="confirmEditing">编辑
  12. </el-button>
  13. <el-button class="el-button--small-yh" type="primary" :disabled="isSaveBtn" size="small"
  14. @click="editCustomer">保存数据
  15. </el-button>
  16. <el-button class="el-button--small-yh" type="warning" size="small" :disabled="isFinanceBtn" @click="collection">{{
  17. form.financeStatus ==
  18. '已付款' ? '撤销付款' : '付款' }}
  19. </el-button>
  20. <!-- <el-button class="el-button--small-yh" type="primary" size="small" v-if="form.id">启用
  21. </el-button> -->
  22. </div>
  23. </div>
  24. <div style="margin-top: 50px">
  25. <trade-card title="基础信息">
  26. <avue-form :option="optionForm" v-model="form" ref="form"></avue-form>
  27. </trade-card>
  28. <trade-card title="明细信息">
  29. <avue-crud :option="optionContacts" v-model="formContacts" ref="formContacts" :data="form.settlementItemsList"
  30. @row-save="rowSave" @row-update="rowUpdate"
  31. @resetColumn="resetColumnTwo('formContacts', 'optionContacts', 'optionContactsBack', 266.1)"
  32. @saveColumn="saveColumnTwo('formContacts', 'optionContacts', 'optionContactsBack', 266.1)">
  33. <template slot-scope="scope" slot="menuLeft">
  34. <el-button type="primary" icon="el-icon-plus" :disabled="form.financeStatus == '已付款' || isMenu" size="small"
  35. @click="rowAdd()">选择订单</el-button>
  36. </template>
  37. <template slot-scope="{ row, index }" slot="contractNumber">
  38. <span style="color: #409EFF;cursor: pointer" @click.stop="payBtn(row)">{{ row.contractNumber }}
  39. </span>
  40. </template>
  41. <template slot-scope="{ row, index }" slot="thisAmount">
  42. <el-input-number size="small" v-model="row.thisAmount" :precision="2" :controls="false"
  43. v-if="row.$cellEdit && row.businesType == 'CG'" @change="thisAmountChange(row)"></el-input-number>
  44. <span v-else>{{ row.thisAmount }}</span>
  45. </template>
  46. <template slot-scope="{ row, index }" slot="thisRefundAmount">
  47. <el-input-number size="small" width="100" v-model="row.thisRefundAmount" :precision="2" :controls="false"
  48. v-if="row.$cellEdit && row.businesType == 'TKCG'" @change="thisReAmountChange(row)"></el-input-number>
  49. <span v-else>{{ row.thisRefundAmount }}</span>
  50. </template>
  51. <template slot-scope="{type,size,row,index,disabled}" slot="menu">
  52. <el-button :size="size" :type="type" :disabled="form.financeStatus == '已付款' || isMenu"
  53. :icon="row.$cellEdit ? 'el-icon-plus' : 'el-icon-edit'" @click="$refs.formContacts.rowCell(row, index)">{{
  54. row.$cellEdit ? '确认' : '修改' }}
  55. </el-button>
  56. <el-button icon="el-icon-delete" :size="size" :disabled="form.financeStatus == '已付款' || isMenu" :type="type"
  57. @click="rowDelBox(row, index)">删除
  58. </el-button>
  59. </template>
  60. </avue-crud>
  61. </trade-card>
  62. <containerTitle title="上传附件"></containerTitle>
  63. <c-upload v-loading="loadingBtn" typeUpload="LT" deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId"
  64. :data="filesList" display :enumerationValue="35.1"></c-upload>
  65. </div>
  66. <el-dialog title="导入订单" append-to-body class="el-dialogDeep" :visible.sync="billDetailDialog" width="80%"
  67. :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" top="10vh" v-dialog-drag>
  68. <bill-detail ref="billDetailRef" :params="params" :billType="billType" :flag="1" @closeFun="closeBillDetail"
  69. @importProMent="importProMent">
  70. </bill-detail>
  71. </el-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import billDetail from "@/components/bill/selectOrderDetailListCG";
  76. import { saveSubmit, collectionAndPayment, revokeCollectionAndPayment, detail, removeItems, getFinanceList, remove } from '@/api/accountingManagement/index.js';
  77. import { number } from "echarts";
  78. export default {
  79. name: "detailsPage",
  80. components: {
  81. billDetail
  82. },
  83. data() {
  84. return {
  85. // 上传附件的需要参数
  86. loadingBtn: false,
  87. filesList: [],
  88. params: {},
  89. // 经办人list
  90. financeList: [],
  91. billDetailDialog: false,
  92. isSave: 0,
  93. isMenu: false,
  94. isSaveBtn: false,
  95. isFinanceBtn: false,
  96. editButton: false,
  97. disabled: false,
  98. form: {
  99. settlementItemsList: []
  100. },
  101. optionForm: {
  102. menuBtn: false,
  103. span: 8,
  104. column: [{
  105. label: '供应商',
  106. prop: "corpId",
  107. type: "select",
  108. props: {
  109. label: 'cname',
  110. value: 'id'
  111. },
  112. dicUrl: '/api/blade-sales-part/corpsDesc/listAll?cname={{key}}&corpType=GYS&enableOrNot=1',
  113. rules: [{
  114. required: true,
  115. message: " ",
  116. trigger: "blur"
  117. }]
  118. }, {
  119. label: '付款账户',
  120. prop: "accountName",
  121. props: {
  122. label: 'cname',
  123. value: 'cname'
  124. },
  125. type: "select",
  126. dicUrl: '/api/blade-sales-part/accountManagement/list?enableOrNot=1&cname={{key}}&billType=HYCK',
  127. dicFormatter: (res => {
  128. return res.data.records
  129. }),
  130. change: (data => {
  131. console.log(data);
  132. console.log(this.$refs.form.DIC);
  133. const targetObject = this.$refs.form.DIC.accountName.find(obj => obj.cname == data.value);
  134. this.form.accountId = targetObject.id
  135. }),
  136. rules: [{
  137. required: true,
  138. message: " ",
  139. trigger: "blur"
  140. }]
  141. }, {
  142. label: '金额',
  143. prop: "amount",
  144. disabled: true,
  145. rules: [{
  146. required: true,
  147. message: " ",
  148. trigger: "blur"
  149. }]
  150. }, {
  151. label: "经办人",
  152. prop: "handledByName",
  153. type: "select",
  154. props: {
  155. label: "name",
  156. value: "name"
  157. },
  158. dicUrl: "/api/blade-user/financeList",
  159. rules: [{
  160. required: true,
  161. message: " ",
  162. trigger: "blur"
  163. }],
  164. }, {
  165. label: '付款日期',
  166. prop: "settlementDate",
  167. type: "date",
  168. overHidden: true,
  169. width: 100,
  170. searchRange: true,
  171. searchDefaultTime: ["00:00:00", "23:59:59"],
  172. format: "yyyy-MM-dd",
  173. valueFormat: "yyyy-MM-dd HH:mm:ss",
  174. value: '',
  175. rules: [{
  176. required: true,
  177. message: " ",
  178. trigger: "blur"
  179. }]
  180. }, {
  181. label: '单据编号',
  182. prop: "sysNo",
  183. disabled: true
  184. }, {
  185. label: '备注',
  186. prop: "remarks",
  187. type: 'textarea',
  188. span: 24,
  189. minRows: 2
  190. }]
  191. },
  192. formContacts: {},
  193. optionContacts: {},
  194. optionContactsBack: {
  195. align: 'center',
  196. index: true,
  197. addBtnText: "录入明细",
  198. refreshBtn: false,
  199. dialogDrag: true,
  200. addBtn: false,
  201. span: 8,
  202. height: 600,
  203. addRowBtn: false,
  204. editBtn: false,
  205. delBtn: false,
  206. menuWidth: 140,
  207. dialogTop: 25,
  208. dialogWidth: "80%",
  209. column: [
  210. // {
  211. // label: '单据编号',
  212. // prop: 'attn',
  213. // cell: true
  214. // },
  215. {
  216. label: '合同号',
  217. prop: 'contractNumber',
  218. cell: false
  219. }, {
  220. label: '应付金额',
  221. prop: 'accountsAmount',
  222. cell: false
  223. }, {
  224. label: '结算金额',
  225. prop: 'settlmentAmount',
  226. cell: false
  227. }, {
  228. label: '本次金额',
  229. prop: 'thisAmount',
  230. width: 140,
  231. }, {
  232. label: '本次退货金额',
  233. prop: 'thisRefundAmount',
  234. width: 140,
  235. }, {
  236. label: '业务日期',
  237. prop: "businesDate",
  238. disabled: false,
  239. type: "datetime",
  240. format: "yyyy-MM-dd",
  241. valueFormat: "yyyy-MM-dd",
  242. rules: [
  243. {
  244. required: true,
  245. message: "",
  246. trigger: "blur"
  247. }
  248. ]
  249. }, {
  250. label: '备注',
  251. prop: 'remarks',
  252. cell: true
  253. }]
  254. }
  255. }
  256. },
  257. props: {
  258. onLoad: Object,
  259. detailData: Object
  260. },
  261. async created() {
  262. // 获取今天的日期
  263. var today = new Date();
  264. var year = today.getFullYear();
  265. var month = String(today.getMonth() + 1).padStart(2, '0');
  266. var day = String(today.getDate()).padStart(2, '0');
  267. var hours = String(today.getHours()).padStart(2, '0');
  268. var minutes = String(today.getMinutes()).padStart(2, '0');
  269. var seconds = String(today.getSeconds()).padStart(2, '0');
  270. // 查询经办人
  271. getFinanceList().then(res => {
  272. this.financeList = res.data.data
  273. const logInUser = JSON.parse(localStorage.getItem('saber-userInfo'));
  274. if (logInUser.content.role_name.includes('财务')) {
  275. for (let finance of res.data.data) {
  276. if (finance.name === logInUser.content.nick_name) {
  277. console.log(finance.name)
  278. this.form.handledByName = finance.name;
  279. break;
  280. }
  281. }
  282. }
  283. })
  284. // 构建今天的日期时间字符串
  285. var todayDateTime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
  286. if (this.onLoad.id) {
  287. this.refresh(this.onLoad.id)
  288. this.$set(this.optionForm, 'disabled', true)
  289. this.$set(this.optionContactsBack, 'disabled', true)
  290. this.isSaveBtn = true
  291. this.isFinanceBtn = true
  292. this.isMenu = true
  293. } else {
  294. this.findObject(this.optionForm.column, 'settlementDate').value = todayDateTime
  295. this.editButton = true
  296. }
  297. this.optionContacts = await this.getColumnData(this.getColumnName(266.1), this.optionContactsBack);
  298. // let thisAmountSum = 0
  299. this.findObject(this.optionContacts.column, "thisAmount").change = ({ value, column }) => {
  300. let thisAmountSum = 0
  301. for (let item of this.form.settlementItemsList) {
  302. thisAmountSum += item.thisAmount;
  303. }
  304. this.form.amount = Number(thisAmountSum)
  305. }
  306. console.log(this.onLoad.id);
  307. },
  308. methods: {
  309. thisAmountChange(row) {
  310. let num = Number(row.totalMoney) - Number(row.paymentAmountTl)
  311. if (row.thisAmount > num) {
  312. this.$message.error("请正确输入本次金额!");
  313. this.$set(row, 'thisAmount', 0)
  314. }
  315. let sum1 = 0
  316. let sum2 = 0
  317. this.form.settlementItemsList.forEach(e => {
  318. sum1 += e.thisAmount;
  319. sum2 += e.thisRefundAmount;
  320. this.$set(this.form, 'amount', sum1 - sum2)
  321. })
  322. },
  323. thisReAmountChange(row) {
  324. let num = Number(row.totalMoney) - Number(row.paymentAmountTl)
  325. if (row.thisRefundAmount > num) {
  326. this.$message.error("请正确输入本次金额!");
  327. this.$set(row, 'thisRefundAmount', 0)
  328. }
  329. let sum1 = 0
  330. let sum2 = 0
  331. this.form.settlementItemsList.forEach(e => {
  332. sum1 += e.thisAmount;
  333. sum2 += e.thisRefundAmount;
  334. this.$set(this.form, 'amount', sum1 - sum2)
  335. })
  336. },
  337. rowDelBox(row, index) {
  338. this.$confirm("确定将选择数据删除?", {
  339. confirmButtonText: "确定",
  340. cancelButtonText: "取消",
  341. type: "warning"
  342. }).then(() => {
  343. if (row.id) {
  344. console.log(this.form);
  345. removeItems({ ids: row.id }).then(res => {
  346. this.form.settlementItemsList.splice(index, 1);
  347. this.$message.success("操作成功!");
  348. });
  349. } else {
  350. this.form.settlementItemsList.splice(index, 1);
  351. this.$message.success("操作成功!");
  352. }
  353. }
  354. )
  355. ;
  356. },
  357. refresh(id, type) {
  358. const loading = this.$loading({
  359. lock: true,
  360. text: '加载中',
  361. spinner: 'el-icon-loading',
  362. background: 'rgba(255,255,255,0.7)'
  363. })
  364. detail({ id: id }).then(res => {
  365. this.form = res.data.data
  366. this.filesList = res.data.data.filesList
  367. loading.close();
  368. }).catch(() => {
  369. loading.close();
  370. })
  371. },
  372. rowAdd() {
  373. if (!this.form.corpId) {
  374. this.$message.warning("请先选择客户!")
  375. return
  376. }
  377. console.log(this.form, 329)
  378. this.params = {
  379. customerId: this.form.corpId,
  380. status: '待确认',
  381. bsType: 'CG,TKCG',
  382. actualPaymentStatus: '2'
  383. }
  384. this.billDetailDialog = true;
  385. // 调用一次弹窗的方法,防止不刷新数据
  386. let page = {
  387. pageSize: 20,
  388. pagerCount: 1,
  389. total: 0,
  390. pageSizes: [20, 200, 300, 500, 700, 1000]
  391. }
  392. this.$refs.billDetailRef.onLoad(page, this.params)
  393. },
  394. confirmEditing() {
  395. this.editButton = true
  396. if (this.form.financeStatus == '已付款') {
  397. this.$set(this.optionForm, 'disabled', true)
  398. this.$set(this.optionContactsBack, 'disabled', true)
  399. this.isFinanceBtn = false
  400. } else {
  401. this.$set(this.optionForm, 'disabled', false)
  402. this.$set(this.optionContactsBack, 'disabled', false)
  403. this.isFinanceBtn = false
  404. this.isSaveBtn = false
  405. this.isMenu = false
  406. }
  407. },
  408. //关闭
  409. closeBillDetail() {
  410. this.billDetailDialog = false;
  411. },
  412. //保存数据
  413. editCustomer() {
  414. this.$refs["form"].validate((valid, done) => {
  415. done()
  416. if (valid) {
  417. let data = {
  418. ...this.form,
  419. dc: 'c',
  420. billType: 'FK',
  421. corpName: this.form.$corpId,
  422. filesList: this.filesList
  423. }
  424. const loading = this.$loading({
  425. lock: true,
  426. text: '加载中',
  427. spinner: 'el-icon-loading',
  428. background: 'rgba(255,255,255,0.7)'
  429. });
  430. for (let finance of this.financeList) {
  431. if (finance.name == data.handledByName) {
  432. data.handledById = finance.id
  433. break;
  434. }
  435. }
  436. saveSubmit(data).then(res => {
  437. console.log(res);
  438. this.refresh(res.data.data.id)
  439. this.$message.success('保存成功')
  440. loading.close();
  441. }).catch(() => {
  442. loading.close()
  443. })
  444. }
  445. })
  446. },
  447. //导入
  448. importProMent(list) {
  449. console.log(list);
  450. // return
  451. // for (let item of this.dataList){
  452. // for (let li of list){
  453. // if (item.srcSysno == li.srcSysno && item.srcRefno == li.srcRefno && new Date(item.rentEndDate) == new Date(li.rentEndDate)){
  454. // return this.$message.error(`合同号${item.accSysNo}已存在`)
  455. // }
  456. // }
  457. // }
  458. let sum1 = 0
  459. let sum2 = 0
  460. list.forEach((item, index) => {
  461. item.contractNumber = item.ordNo;
  462. item.accountsAmount = item.bsType == "CG"?item.totalMoney:item.returnsAmount
  463. item.settlmentAmount = item.paymentAmountTl
  464. item.businesType = item.bsType
  465. this.$set(item, 'thisAmount', item.bsType == "CG" ? (Number(item.totalMoney) - Number(item.paymentAmountTl)) : 0)
  466. this.$set(item, 'thisRefundAmount', item.bsType == "TKCG" ? (Number(item.returnsAmount) - Number(item.paymentAmountTl)) : 0)
  467. item.srcParentId = item.id
  468. item.srcBillNo = item.ordNo
  469. item.salesCompanyId = item.salesCompanyId
  470. item.salesCompanyName = item.salesCompanyName
  471. item.id = null
  472. delete item.ordNo;
  473. this.$refs.formContacts.rowCellAdd(item);
  474. //计算主表金额
  475. sum1 += item.bsType == "CG" ? (Number(item.totalMoney) - Number(item.paymentAmountTl)) : 0
  476. sum2 += item.bsType == "TKCG" ? (Number(item.totalMoney) - Number(item.paymentAmountTl)) : 0
  477. this.form.amount = sum1 - sum2
  478. })
  479. //明细列表所有合同号 去重 加, 为主表合同号
  480. // this.$set(this.form,'srcOrderno',Array.from(new Set(this.dataList.map(item =>{ return item.srcOrderno}))).join(','))
  481. this.billDetailDialog = false;
  482. },
  483. //收款
  484. collection() {
  485. this.$refs["form"].validate((valid, done) => {
  486. done()
  487. if (valid) {
  488. if (this.form.financeStatus !== '已付款') {
  489. console.log('this.form.financeStatus', this.form.financeStatus);
  490. this.$confirm("确认付款?", {
  491. confirmButtonText: "确定",
  492. cancelButtonText: "取消",
  493. type: "warning"
  494. }).then(() => {
  495. const loading = this.$loading({
  496. lock: true,
  497. text: '加载中',
  498. spinner: 'el-icon-loading',
  499. background: 'rgba(255,255,255,0.7)'
  500. });
  501. let data = {
  502. ...this.form,
  503. dc: 'c',
  504. billType: 'FK'
  505. }
  506. saveSubmit(data).then(res => {
  507. collectionAndPayment(data)
  508. .then((res) => {
  509. console.log(res);
  510. this.refresh(res.data.data.id);
  511. this.$set(this.optionForm, 'disabled', true)
  512. this.$set(this.optionContactsBack, 'disabled', true)
  513. this.$message.success('付款成功');
  514. loading.close();
  515. })
  516. .catch((error) => {
  517. console.error(error);
  518. loading.close();
  519. });
  520. }).catch(() => {
  521. loading.close()
  522. })
  523. })
  524. } else {
  525. this.$confirm("确认撤销付款?", {
  526. confirmButtonText: "确定",
  527. cancelButtonText: "取消",
  528. type: "warning"
  529. }).then(() => {
  530. const loading = this.$loading({
  531. lock: true,
  532. text: '加载中',
  533. spinner: 'el-icon-loading',
  534. background: 'rgba(255,255,255,0.7)'
  535. });
  536. let data = {
  537. ...this.form,
  538. dc: 'c',
  539. billType: 'FK',
  540. corpName: this.form.$corpId
  541. }
  542. revokeCollectionAndPayment(data).then((res => {
  543. this.refresh(res.data.data.id)
  544. this.editButton = false
  545. this.$message.success('撤销付款成功')
  546. loading.close()
  547. }))
  548. })
  549. }
  550. }
  551. })
  552. },
  553. payBtn(row) {
  554. console.log(row);
  555. this.$router.$avueRouter.closeTag('/tirePartsMall/salesManagement/purchaseOrder/index');
  556. this.$router.push({
  557. path: "/tirePartsMall/salesManagement/purchaseOrder/index",
  558. query: { detail: row, type: 'F' },
  559. });
  560. },
  561. rowSave(form, done, loading) {
  562. done(form)
  563. },
  564. rowUpdate(form, index, done, loading) {
  565. done(form)
  566. },
  567. //自定义列保存
  568. async saveColumnTwo(ref, option, optionBack, code) {
  569. /**
  570. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  571. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  572. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  573. */
  574. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  575. if (inSave) {
  576. this.$message.success("保存成功");
  577. //关闭窗口
  578. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  579. }
  580. },
  581. //自定义列重置
  582. async resetColumnTwo(ref, option, optionBack, code) {
  583. this[option] = this[optionBack];
  584. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  585. if (inSave) {
  586. this.$message.success("重置成功");
  587. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  588. }
  589. },
  590. backToList(type) {
  591. this.$emit("backToList", type);
  592. }
  593. }
  594. }
  595. </script>
  596. <style lang="scss" scoped>
  597. ::v-deep .el-form-item {
  598. margin-bottom: 8px !important;
  599. }
  600. </style>