detailsPage.vue 19 KB

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