receiptSettleDetailsPage.vue 33 KB

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