receiptSettleDetailsPage.vue 36 KB

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