detailsPage.vue 20 KB

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