detailsPage.vue 18 KB

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