detailsPage.vue 21 KB

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