receiptSettleDetailsPage.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. <template>
  2. <div class="borderless">
  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">返回列表
  7. </el-button>
  8. <div class="upper_right_button">
  9. <el-button
  10. type="primary"
  11. size="small"
  12. @click="editHandle"
  13. v-if="editDisable"
  14. :loading="buttonLoading"
  15. >编 辑</el-button>
  16. <el-button type="primary"
  17. size="small"
  18. :disabled="!form.id || editDisable"
  19. @click="postMessage"
  20. :loading="buttonLoading"
  21. >发送消息</el-button>
  22. <el-button type="warning"
  23. size="small"
  24. class="el-button--small-yh"
  25. :loading="buttonLoading"
  26. :disabled="!form.id || editDisable"
  27. v-if="form.id"
  28. @click.stop="confirmSettlement"
  29. >{{financeDisabled?"对账":"撤销对账"}}
  30. </el-button>
  31. <el-button class="el-button--small-yh"
  32. type="primary"
  33. size="small"
  34. :loading="buttonLoading"
  35. :disabled="!financeDisabled || editDisable"
  36. @click.stop="saveSettlement">保存数据
  37. </el-button>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="customer-main">
  42. <containerTitle title="基础信息"></containerTitle>
  43. <basic-container>
  44. <avue-form class="trading-form" ref="form" v-model="form" :option="option">
  45. <template slot="corpId">
  46. <crop-select
  47. v-model="form.corpId"
  48. corpType="KG"
  49. :disabled="!financeDisabled || editDisable"
  50. @getCorpData="returnBack"
  51. style="width: 100%"
  52. ></crop-select>
  53. </template>
  54. <template slot="salesCompany">
  55. <crop-select
  56. v-model="form.salesCompany"
  57. corpType="GS"
  58. :disabled="!financeDisabled || editDisable"
  59. @getCorpData="getGSName"
  60. style="width: 100%"
  61. ></crop-select>
  62. </template>
  63. <template slot="accountNo">
  64. <el-select v-model="form.accountNo"
  65. placeholder="请选择"
  66. :disabled="!financeDisabled || editDisable"
  67. @change="accountNoChange"
  68. clearable
  69. filterable>
  70. <el-option v-for="(item,index) in form.bankList"
  71. :key="index"
  72. :label="item.accountNo"
  73. :value="item.accountNo">
  74. </el-option>
  75. </el-select>
  76. </template>
  77. <template slot="type">
  78. <el-select v-model="form.type" placeholder="请选择" :disabled="!financeDisabled || editDisable || dataList.length > 0">
  79. <el-option label="收费" value="收费"></el-option>
  80. <el-option label="付费" value="申请"></el-option>
  81. </el-select>
  82. </template>
  83. <template slot="caseOverPayment">
  84. <el-input
  85. placeholder="请输入"
  86. clearable
  87. v-model="form.caseOverPayment"
  88. @change="caseOverPaymentChange"
  89. v-input-limit="2"
  90. :disabled="dataList.length == 0 || !financeDisabled || editDisable"
  91. ></el-input>
  92. </template>
  93. <template slot="remark">
  94. <el-input type="textarea"
  95. v-model="form.remark"
  96. size="small"
  97. rows="2"
  98. autocomplete="off"
  99. placeholder="">
  100. </el-input>
  101. </template>
  102. </avue-form>
  103. </basic-container>
  104. <containerTitle title="明细列表"></containerTitle>
  105. <basic-container>
  106. <avue-crud :option="itemsOption"
  107. :data="dataList"
  108. ref="crud"
  109. v-model="itemsForm"
  110. :page.sync="page"
  111. :cell-style="cellStyle"
  112. @search-reset="searchReset"
  113. @row-update="rowUpdate"
  114. @selection-change="selectionChange"
  115. @current-change="currentChange"
  116. @size-change="sizeChange"
  117. @refresh-change="refreshChange">
  118. <template slot="menuLeft">
  119. <el-button type="primary"
  120. size="small"
  121. icon="el-icon-shopping-cart-2"
  122. :disabled="!financeDisabled || editDisable"
  123. :buttonLoading="buttonLoading"
  124. @click="selectRecipt"
  125. >选择对账合同
  126. </el-button>
  127. <el-button
  128. :disabled="!form.id"
  129. type="info"
  130. size="small"
  131. icon="el-icon-printer"
  132. @click.stop="openReport"
  133. >报表打印</el-button>
  134. </template>
  135. <template slot-scope="{ row }" slot="currency">
  136. <el-select v-if="row.$cellEdit" v-model="row.currency" size="small" placeholder="请选择 币别" clearable filterable>
  137. <el-option v-for="(item,index) in currencyDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  138. </el-select>
  139. <span v-else>{{ row.currency }}</span>
  140. </template>
  141. <template slot="thisAmount" slot-scope="{ row }">
  142. <span v-if="row.$cellEdit" class="required_fields">*</span>
  143. <el-input
  144. v-if="row.$cellEdit"
  145. v-model="row.thisAmount"
  146. style="width: 90%"
  147. placeholder="请输入"
  148. size="small"
  149. @input="thisAmountVerify(row)"
  150. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  151. ></el-input>
  152. <span v-else>{{ row.thisAmount }}</span>
  153. </template>
  154. <template slot-scope="scope" slot="menu">
  155. <el-button
  156. type="text"
  157. size="small"
  158. icon="el-icon-edit"
  159. :disabled="!financeDisabled || editDisable"
  160. @click.stop="rowCell(scope.row,scope.index)"
  161. > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
  162. </el-button>
  163. <el-button
  164. type="text"
  165. size="small"
  166. icon="el-icon-delete"
  167. :disabled="!financeDisabled || editDisable"
  168. @click.stop="rowDel(scope.row,scope.index)"
  169. >删除
  170. </el-button>
  171. </template>
  172. <template slot="srcOrderno" slot-scope="scope">
  173. <span style="color: #409EFF;cursor: pointer" @click="jumpPage(scope.row, scope.index)">{{scope.row.srcOrderno}}</span>
  174. </template>
  175. </avue-crud>
  176. </basic-container>
  177. <el-dialog
  178. title="导入对账"
  179. append-to-body
  180. class="el-dialogDeep"
  181. :visible.sync="billDetailDialog"
  182. width="80%"
  183. :close-on-click-modal="false"
  184. :destroy-on-close="true"
  185. :close-on-press-escape="false"
  186. top="10vh"
  187. v-dialog-drag>
  188. <bill-detail
  189. :params="params"
  190. :billType="form.type"
  191. :flag="1"
  192. v-if="billDetailDialog"
  193. @closeFun="closeBillDetail"
  194. @importProMent="importProMent"
  195. ></bill-detail>
  196. </el-dialog>
  197. </div>
  198. <messagePost
  199. v-if="messageVisble"
  200. ref="messagePost"
  201. @closeDialog="closeDialog"
  202. ></messagePost>
  203. <report-dialog
  204. :switchDialog="switchDialog"
  205. :reportId="form.id"
  206. reportName="对账单"
  207. @onClose="onClose()"
  208. />
  209. </div>
  210. </template>
  211. <script>
  212. import option from "./configuration/detailsPage.json";
  213. import { getDetail } from "@/api/financialManagement/financialManagement"
  214. import { getDetails,modify,cancelModify,saveOrEdit } from "@/api/financialManagement/paymentRequest";
  215. import billDetail from "@/components/bill/billDetailList";
  216. import _ from "lodash";
  217. import { getlistBankBy,deleteDetail } from "@/api/financialManagement/paymentRequest";
  218. import { contrastObj,contrastList } from "@/util/contrastData";
  219. import {getUserInfo} from "@/api/system/user";
  220. import {getCorpDetail} from "@/api/maintenance/overpayment";
  221. import { getlistBankBy as GYSGetBank } from "@/api/basicData/configuration"
  222. import reportDialog from "@/components/report-dialog/main";
  223. import {dateFormat} from "@/util/date";
  224. export default {
  225. name: "receiptDetailsPage",
  226. props: {
  227. detailData: {
  228. type: Object
  229. }
  230. },
  231. components:{
  232. billDetail,
  233. reportDialog,
  234. },
  235. data() {
  236. return {
  237. category: '',
  238. form: {},
  239. itemsForm:{},
  240. params:{},
  241. buttonLoading:false,
  242. itemsOption: option,
  243. option: {
  244. menuBtn: false,
  245. labelWidth: 100,
  246. column: [
  247. {
  248. label: '所属公司',
  249. prop: 'salesCompany',
  250. sort:true,
  251. span: 8,
  252. rules: [
  253. {
  254. required: true,
  255. message: ' ',
  256. trigger: 'blur'
  257. }
  258. ]
  259. },
  260. {
  261. label: '合同号',
  262. prop: 'srcOrderno',
  263. span: 8,
  264. rules: [
  265. {
  266. required: false,
  267. message: ' ',
  268. trigger: 'blur'
  269. }
  270. ]
  271. },
  272. {
  273. label: '系统号',
  274. prop: 'sysNo',
  275. span: 8,
  276. disabled: true
  277. },
  278. {
  279. label: '银行账号',
  280. prop: 'accountNo',
  281. span: 8,
  282. rules: [
  283. {
  284. required: false,
  285. message: ' ',
  286. trigger: 'blur'
  287. }
  288. ]
  289. },
  290. {
  291. label: '开户银行',
  292. prop: 'accountBank',
  293. span: 8,
  294. rules: [
  295. {
  296. required: false,
  297. message: ' ',
  298. trigger: 'blur'
  299. }
  300. ]
  301. }, {
  302. label: '银行户头',
  303. prop: 'accountName',
  304. span: 8,
  305. rules: [
  306. {
  307. required: false,
  308. message: ' ',
  309. trigger: 'blur'
  310. }
  311. ]
  312. }, {
  313. label: '科目编码',
  314. prop: 'subjectNumber',
  315. span: 8,
  316. rules: [
  317. {
  318. required: false,
  319. message: ' ',
  320. trigger: 'blur'
  321. }
  322. ]
  323. },
  324. {
  325. label: '往来单位',
  326. prop: 'corpId',
  327. sort:true,
  328. span: 8,
  329. rules: [
  330. {
  331. required: true,
  332. message: ' ',
  333. trigger: 'blur'
  334. }
  335. ]
  336. },
  337. {
  338. label: '对账日期',
  339. prop: 'settlementDate',
  340. format:"yyyy-MM-dd",
  341. valueFormat:"yyyy-MM-dd 00:00:00",
  342. span: 8,
  343. type:"date",
  344. rules: [
  345. {
  346. required: true,
  347. message: ' ',
  348. trigger: 'blur'
  349. }
  350. ]
  351. },
  352. {
  353. label: '制单人',
  354. prop: 'createUserName',
  355. span: 8,
  356. disabled:true,
  357. rules: [
  358. {
  359. required: false,
  360. message: ' ',
  361. trigger: 'blur'
  362. }
  363. ]
  364. },
  365. {
  366. label: '人民币金额',
  367. prop: 'amount',
  368. span: 8,
  369. rules: [
  370. {
  371. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  372. message: ' ',
  373. trigger: 'blur'
  374. },
  375. {
  376. required: false,
  377. message: ' ',
  378. trigger: 'blur'
  379. }
  380. ]
  381. },
  382. {
  383. label: '外币金额',
  384. prop: 'foreignAmount',
  385. display: true,
  386. span: 8,
  387. rules: [
  388. {
  389. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  390. message: ' ',
  391. trigger: 'blur'
  392. }
  393. ]
  394. },
  395. {
  396. label: '使用溢付款',
  397. prop: 'caseOverPayment',
  398. display: false,
  399. span: 8,
  400. rules: [
  401. {
  402. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  403. message: ' ',
  404. trigger: 'blur'
  405. }
  406. ]
  407. },
  408. {
  409. label: '溢付款余额',
  410. prop: 'overPayment',
  411. display: false,
  412. disabled: true,
  413. span: 8,
  414. // rules: [
  415. // {
  416. // pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  417. // message: ' ',
  418. // trigger: 'blur'
  419. // }
  420. // ]
  421. },
  422. {
  423. label: '制单日期',
  424. prop: 'createTime',
  425. span: 8,
  426. type:"date",
  427. disabled:true,
  428. rules: [
  429. {
  430. required: false,
  431. message: ' ',
  432. trigger: 'blur'
  433. }
  434. ]
  435. },
  436. {
  437. label: '业务类型',
  438. prop: 'type',
  439. span: 8,
  440. rules: [
  441. {
  442. required: true,
  443. message: ' ',
  444. trigger: 'blur'
  445. }
  446. ]
  447. },
  448. {
  449. label: '备注',
  450. prop: 'remark',
  451. span:24,
  452. row:2,
  453. rules: [
  454. {
  455. required: false,
  456. message: ' ',
  457. trigger: 'blur'
  458. }
  459. ]
  460. },
  461. ],
  462. },
  463. id:'',
  464. dataList: [],
  465. currencyDic:[],
  466. page: {
  467. pageSize: 10,
  468. pagerCount: 5,
  469. total: 0,
  470. },
  471. billDetailDialog:false,
  472. financeDisabled:true,
  473. billType:"收费",
  474. // 明细本次金额总计
  475. allAmount: 0,
  476. // 消息弹窗
  477. messageVisble: false,
  478. //新旧数据对比
  479. oldForm:{},
  480. oldDataList:[],
  481. financeStatusDic:[{
  482. value: '正常',
  483. label: '正常'
  484. },
  485. {
  486. value: '停用',
  487. label: '停用'
  488. }],
  489. editDisable: false, //编辑状态禁用
  490. switchDialog: false,
  491. statementData: {},
  492. }
  493. },
  494. created() {
  495. // 人民币金额默认为0
  496. this.$set(this.form,"amount", 0)
  497. getUserInfo().then(res=>{
  498. this.category = res.data.data.billType
  499. if (this.category == 2) {
  500. this.$set(this.form,"overPayment", 0)
  501. this.$set(this.form,"caseOverPayment", 0)
  502. this.option.column.forEach(item => {
  503. if (item.prop == 'caseOverPayment' || item.prop == 'overPayment') {
  504. item.display = true
  505. }
  506. if (item.prop == 'foreignAmount') {
  507. item.display = false
  508. }
  509. })
  510. }
  511. })
  512. //币别
  513. this.getWorkDicts("currency").then(res =>{
  514. this.currencyDic = res.data.data
  515. })
  516. this.detailData.disabled && (this.editDisable = true)
  517. if (this.detailData.id) {
  518. this.buttonLoading = true
  519. this.id = this.detailData.id;//字符串转数字 超长用BigInt
  520. getDetail(this.id).then(res => {
  521. this.afterEcho(res.data.data)
  522. }).finally(()=>{
  523. this.buttonLoading = false
  524. })
  525. }else{
  526. this.form.financeStatus = "待结算"
  527. this.form.type = "收费"
  528. this.oldForm.financeStatus = "待结算"
  529. this.form.settlementDate = dateFormat(new Date(), "yyyy-MM-dd") + " 00:00:00"
  530. }
  531. },
  532. mounted() {
  533. },
  534. methods: {
  535. //选择客户
  536. returnBack(corpValue){
  537. this.corpId = corpValue.id
  538. if (this.category != 2) {
  539. getlistBankBy(corpValue.id).then(res =>{
  540. this.$set(this.form,"bankList",res.data)
  541. })
  542. }
  543. // 溢付款余额获取
  544. if (this.category == 2) {
  545. getCorpDetail({corpId:corpValue.id}).then(res => {
  546. this.form.overPayment = res.data.data? res.data.data.balanceOverpaymen: 0
  547. })
  548. }
  549. },
  550. //选择卡号
  551. accountNoChange(value){
  552. let isTrue = false
  553. this.form.bankList.forEach(item =>{
  554. if(item.accountNo == value){
  555. this.$set(this.form,"accountBank",item.accountBank)
  556. this.$set(this.form,"accountName",item.accountName)
  557. this.$set(this.form,"subjectNumber",item.subjectNumber)
  558. isTrue = true
  559. }
  560. })
  561. this.$nextTick(() => {
  562. if (!isTrue) {
  563. this.$set(this.form, 'accountBank', null)
  564. this.$set(this.form, 'accountName', null)
  565. this.$set(this.form,"subjectNumber",null)
  566. }
  567. })
  568. },
  569. //本次金额验证
  570. thisAmountVerify(row){
  571. if(parseFloat(row.thisAmount) > parseFloat(row.amount)){
  572. this.$message.warning('本次金额不得大于金额!')
  573. this.$set(row,'thisAmount','')
  574. }
  575. },
  576. selectRecipt(){
  577. if(!this.form.corpId){
  578. this.$message.warning("请先选择客户!")
  579. return
  580. }
  581. if(!this.form.type){
  582. this.$message.warning("请先选择业务类型!")
  583. return
  584. }
  585. this.params = {
  586. corpId: this.form.corpId,
  587. duiZhangStatus:"对账"
  588. }
  589. this.billDetailDialog = true;
  590. },
  591. closeBillDetail(){
  592. this.billDetailDialog = false;
  593. },
  594. importProMent(list){
  595. for (let item of this.dataList){
  596. for (let li of list){
  597. if (item.srcSysno == li.srcSysno && item.srcRefno == li.srcRefno && new Date(item.rentEndDate) == new Date(li.rentEndDate)){
  598. return this.$message.error(`合同号${item.accSysNo}已存在`)
  599. }
  600. }
  601. }
  602. list.forEach((item,index) =>{
  603. item.accId = item.id;
  604. item.srcOrderno = item.accSysNo
  605. item.billNo = item.srcBillNo
  606. item.thisAmount = (Number(item.amount) - Number(item.checkAmount))
  607. delete item.id;
  608. this.$refs.crud.rowCellAdd(item);
  609. })
  610. //明细列表所有合同号 去重 加, 为主表合同号
  611. this.$set(this.form,'srcOrderno',Array.from(new Set(this.dataList.map(item =>{ return item.srcOrderno}))).join(','))
  612. this.billDetailDialog = false;
  613. },
  614. rowUpdate(row, index, done) {
  615. done(row);
  616. },
  617. rowCell(row,index){
  618. // row.$cellEdit = !row.$cellEdit
  619. // this.$refs.crud.rowCell(row, index)
  620. if (row.$cellEdit == true) {
  621. this.$set(row, "$cellEdit", false);
  622. } else {
  623. this.$set(row, "$cellEdit", true);
  624. }
  625. },
  626. rowDel(row,index){
  627. if (row.id) {
  628. deleteDetail({ids: row.id}).then(res => {
  629. this.$message({
  630. type: "success",
  631. message: "操作成功!"
  632. });
  633. this.dataList.splice(index, 1);
  634. this.$set(this.form,'srcOrderno',Array.from(new Set(this.dataList.map(item =>{ return item.srcOrderno}))).join(','))
  635. })
  636. } else {
  637. this.dataList.splice(index, 1);
  638. this.$set(this.form,'srcOrderno',Array.from(new Set(this.dataList.map(item =>{ return item.srcOrderno}))).join(','))
  639. }
  640. },
  641. searchReset() {
  642. console.log('1')
  643. },
  644. selectionChange() {
  645. console.log('1')
  646. },
  647. currentChange() {
  648. console.log('1')
  649. },
  650. sizeChange() {
  651. console.log('1')
  652. },
  653. refreshChange() {
  654. console.log('1')
  655. },
  656. confirmSettlement(status){
  657. if (!this.form.corpId) return this.$message.error('往来单位不能为空')
  658. this.$refs["form"].validate((valid,done) => {
  659. done();
  660. if(valid && this.verificationData('对账')){
  661. this.$confirm("是否确认" + (this.financeDisabled? '对账': '撤销对账'), "提示", {
  662. confirmButtonText: "确认",
  663. cancelButtonText: "取消",
  664. type: "warning",
  665. }).then(()=>{
  666. for (let i = 0; i < this.dataList.length; i++) {
  667. if (this.dataList[i].thisAmount == null || this.dataList[i].thisAmount == 0) {
  668. return this.$message.error(`第${i + 1}行的本次金额不能为空`);
  669. }
  670. }
  671. this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
  672. if (this.category == 2 && this.financeDisabled) {
  673. this.allAmount = 0;
  674. this.form.amount = this.form.amount? this.form.amount: 0
  675. this.dataList.forEach(e => {
  676. this.allAmount = Number(this.allAmount) + Number(e.thisAmount)
  677. })
  678. if (this.allAmount == 0 && this.form.amount == 0) {
  679. return this.$message.error('人民币金额不能为空')
  680. } else if (Number(this.allAmount) > 0 && (Number(this.form.amount) > Number(this.allAmount))) {
  681. this.form.caseOverPayment = 0;
  682. } else if (Number(this.allAmount) > 0 && (Number(this.form.amount) < Number(this.allAmount))) {
  683. this.form.caseOverPayment = Number(this.allAmount) - Number(this.form.amount)
  684. if (Number(this.form.caseOverPayment) > Number(this.form.overPayment)) {
  685. return this.$message.error('溢付款余额不足,无法对账')
  686. }
  687. }
  688. }
  689. const params = {
  690. ...this.form,
  691. billType:"对账",
  692. itemsList:this.dataList
  693. }
  694. this.buttonLoading = true
  695. if(this.financeDisabled){
  696. modify(params).then(res =>{
  697. this.$message.success("操作成功!")
  698. this.afterEcho(res.data.data)
  699. }).finally(()=>{
  700. this.buttonLoading = false
  701. })
  702. }else{
  703. cancelModify(params).then(res =>{
  704. this.$message.success("操作成功!")
  705. this.afterEcho(res.data.data)
  706. }).finally(()=>{
  707. this.buttonLoading = false
  708. })
  709. }
  710. })
  711. if(status === true){
  712. this.$emit("goBack");
  713. this.leaveDetailsKey(this.$route.name)
  714. }
  715. }
  716. })
  717. },
  718. saveSettlement(type){
  719. this.$refs["form"].validate((valid,done) => {
  720. done();
  721. console.log(valid)
  722. if(valid){
  723. for (let i = 0; i < this.dataList.length; i++) {
  724. if (this.dataList[i].thisAmount === (null || "")) {
  725. return this.$message.error(`第${i + 1}行的本次金额不能为空`);
  726. }
  727. }
  728. this.buttonLoading = true
  729. this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
  730. const params = {
  731. ...this.form,
  732. billType:"对账",
  733. itemsList:this.dataList,
  734. settlementType:1
  735. }
  736. // 如果有id解锁,没有跳过
  737. // this.form.id && this.unLock({moduleName: 'sf',tableName: 'finance_settlement', billId: this.form.id})
  738. saveOrEdit(params).then(res=>{
  739. this.$message.success("操作成功!")
  740. // this.detailData.disabled = true
  741. // this.editDisable = true
  742. this.afterEcho(res.data.data, type)
  743. }).finally(()=>{
  744. this.buttonLoading = false
  745. })
  746. }})
  747. },
  748. async afterEcho(data, type){
  749. this.form = data;
  750. this.financeDisabled = this.form.financeStatus === "待结算"?true:false;
  751. // 溢付款余额获取
  752. if (this.category == 2) {
  753. await getCorpDetail({corpId: this.form.corpId}).then(res => {
  754. if (Number(this.form.overPayment) != (res.data.data? res.data.data.balanceOverpaymen: '0.00')) {
  755. this.form.overPayment = res.data.data? res.data.data.balanceOverpaymen: '0.00'
  756. }
  757. })
  758. }
  759. this.oldForm = Object.assign({},this.form);
  760. if(this.financeDisabled || !this.editDisable){
  761. this.option.column.forEach(item =>{
  762. if( item.prop === "remark"){
  763. this.$set(item,"disabled",false)
  764. }else if( item.prop === "createUserName" || item.prop === "createTime" || item.prop === "sysNo" || item.prop === "overPayment"){
  765. this.$set(item,"disabled",true)
  766. }else{
  767. this.$set(item,"disabled",false)
  768. }
  769. })
  770. }
  771. if(this.financeDisabled === false || this.editDisable){
  772. this.option.column.forEach(item =>{
  773. if( item.prop === "remark"){
  774. this.$set(item,"disabled",false)
  775. }else if( item.prop === "createUserName" || item.prop === "createTime" || item.prop === "sysNo"){
  776. this.$set(item,"disabled",true)
  777. }else{
  778. this.$set(item,"disabled",true)
  779. }
  780. })
  781. }
  782. if(data.itemsList){
  783. this.dataList = data.itemsList
  784. this.oldDataList = this.deepClone(data.itemsList)
  785. }
  786. if (type == '对账') {
  787. this.confirmSettlement()
  788. }
  789. },
  790. verificationData(type){
  791. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  792. ){
  793. this.$confirm("数据发生变化,请先提交保存!", "提示", {
  794. confirmButtonText: "保存",
  795. cancelButtonText: "取消",
  796. type: "warning",
  797. }).then(() => {
  798. this.saveSettlement(type)
  799. }).catch(()=>{
  800. return false
  801. })
  802. }else{
  803. return true
  804. }
  805. },
  806. backToList(){
  807. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  808. ){
  809. this.$confirm("是否保存当前页面?", "提示", {
  810. confirmButtonText: "保存",
  811. cancelButtonText: "取消",
  812. type: "warning",
  813. }).then(() => {
  814. this.saveSettlement()
  815. }).catch(()=>{
  816. !this.editDisable && this.form.id && this.unLock({moduleName: 'sf',tableName: 'finance_settlement', billId: this.form.id})
  817. this.$emit("goBack");
  818. this.leaveDetailsKey(this.$route.name)
  819. })
  820. }else{
  821. !this.editDisable && this.form.id && this.unLock({moduleName: 'sf',tableName: 'finance_settlement', billId: this.form.id})
  822. this.$emit("goBack");
  823. this.leaveDetailsKey(this.$route.name)
  824. }
  825. },
  826. // 溢付款更改时
  827. caseOverPaymentChange() {
  828. if (!this.form.caseOverPayment) this.form.caseOverPayment = 0;
  829. if (Number(this.form.caseOverPayment) > Number(this.form.overPayment)) {
  830. this.form.caseOverPayment = 0;
  831. return this.$message.error('本次使用的溢付款不能超过总溢付款')
  832. }
  833. },
  834. // 发送消息
  835. postMessage() {
  836. this.messageVisble = true
  837. this.$nextTick(() => {
  838. this.$refs.messagePost.init()
  839. })
  840. },
  841. closeDialog() {
  842. this.messageVisble = false
  843. },
  844. editHandle() {
  845. const data = {
  846. moduleName: 'sf',
  847. tableName: 'finance_settlement',
  848. billId: this.form.id,
  849. no: localStorage.getItem('browserID'),
  850. billNo: this.form.srcOrderno
  851. }
  852. this.checkLock(data).then(res => {
  853. if (res.data.code == 200) {
  854. this.onLock(data).then(response => {
  855. })
  856. this.inDetailsKey(this.$route.name, {
  857. moduleName: 'sf',
  858. tableName: 'finance_settlement',
  859. billId: this.form.id,
  860. })
  861. this.detailData.disabled = false;
  862. this.editDisable = false;
  863. this.buttonLoading = true
  864. getDetail(this.form.id).then(data => {
  865. this.afterEcho(data.data.data)
  866. }).finally(()=>{
  867. this.buttonLoading = false
  868. })
  869. }
  870. }).catch(error => {
  871. }).finally(() => {
  872. this.buttonLoading = false
  873. })
  874. },
  875. getGSName(row) {
  876. this.form.belongCompany = row.cname
  877. if (this.category == 2) {
  878. GYSGetBank(row.id).then(res =>{
  879. this.$set(this.form,"bankList",res.data)
  880. if (this.form.bankList.length > 0) {
  881. this.form.accountNo = this.form.bankList[0].accountNo
  882. this.form.accountName = this.form.bankList[0].accountName
  883. this.form.accountBank = this.form.bankList[0].accountBank
  884. this.form.subjectNumber = this.form.bankList[0].subjectNumber
  885. }
  886. })
  887. }
  888. },
  889. cellStyle() {
  890. return "padding:0;height:40px;";
  891. },
  892. openReport() {
  893. this.statementData = {...this.search};
  894. this.switchDialog = !this.switchDialog;
  895. },
  896. onClose(val) {
  897. this.switchDialog = val;
  898. },
  899. // 跳转页面
  900. jumpPage(row, index) {
  901. if (this.category == 2) {
  902. this.$router.$avueRouter.closeTag("/businessManagement/salesOrder/index");
  903. this.$router.push({
  904. path: "/businessManagement/salesOrder/index",
  905. query: {
  906. params: row.srcParentId
  907. },
  908. });
  909. } else if (this.category == 3) {
  910. this.$router.$avueRouter.closeTag("/salesManagement/salesContract/index");
  911. this.$router.push({
  912. path: "/salesManagement/salesContract/index",
  913. query: {
  914. params: row.srcParentId
  915. },
  916. });
  917. } else if (this.category == 4) {
  918. this.$router.$avueRouter.closeTag("/exportTrade/salesContract/index");
  919. this.$router.push({
  920. path: "/exportTrade/salesContract/index",
  921. query: {
  922. params: row.srcParentId
  923. },
  924. });
  925. }
  926. },
  927. }
  928. }
  929. </script>
  930. <style lang="scss" scoped>
  931. ::v-deep .el-form-item {
  932. margin-bottom: 0;
  933. }
  934. .trading-form ::v-deep .el-form-item {
  935. margin-bottom: 8px !important;
  936. }
  937. .required_fields{
  938. color: #F56C6C;
  939. display:inline-block;
  940. width: 7%
  941. }
  942. .upper_right_button{
  943. display: flex;
  944. position: fixed;
  945. right: 12px;
  946. top: 47px;
  947. }
  948. </style>