receiptSettleDetailsPage.vue 36 KB

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