paymentSettleDetailsPage.vue 33 KB

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