paymentSettleDetailsPage.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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="warning"
  10. class="el-button--small-yh"
  11. size="small"
  12. :disabled="!form.id"
  13. @click.stop="confirmSettlement"
  14. >{{financeButton?"付费":"撤销付费"}}
  15. </el-button>
  16. <el-button class="el-button--small-yh"
  17. type="primary"
  18. size="small"
  19. @click.stop="saveSettlement"
  20. >{{form.id?"确认修改" :"确认新增"}}
  21. </el-button>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="customer-main">
  26. <containerTitle title="基础信息"></containerTitle>
  27. <basic-container>
  28. <avue-form class="trading-form" ref="form" v-model="form" :option="option">
  29. <template slot="corpId">
  30. <select-component
  31. :disabled="!financeDisabled && form.id"
  32. v-model="form.corpId"
  33. @returnBack="returnBack"
  34. :configuration="configuration"
  35. ></select-component>
  36. </template>
  37. <template slot="accountNo">
  38. <el-select v-model="form.accountNo"
  39. placeholder="请选择"
  40. :disabled="!financeDisabled && form.id"
  41. @change="accountNoChange"
  42. clearable
  43. filterable>
  44. <el-option v-for="(item,index) in form.bankList"
  45. :key="index"
  46. :label="item.accountNo"
  47. :value="item.accountNo"
  48. >
  49. </el-option>
  50. </el-select>
  51. </template>
  52. </avue-form>
  53. </basic-container>
  54. <basic-container>
  55. <avue-crud :option="itemsOption"
  56. :data="dataList"
  57. ref="crud"
  58. v-model="itemsForm"
  59. :page.sync="page"
  60. @search-reset="searchReset"
  61. @row-update="rowUpdate"
  62. @selection-change="selectionChange"
  63. @current-change="currentChange"
  64. @size-change="sizeChange"
  65. @refresh-change="refreshChange">
  66. <template slot="menuLeft">
  67. <el-button type="primary"
  68. size="small"
  69. icon="el-icon-shopping-cart-2"
  70. @click="selectPurchase">选择采购合同
  71. </el-button>
  72. </template>
  73. <template slot-scope="scope" slot="menu">
  74. <el-button
  75. type="text"
  76. size="small"
  77. @click.stop="rowCell(scope.row,scope.index)"
  78. > {{ scope.row.$cellEdit ? '修改完成' : '修改' }}
  79. </el-button>
  80. <el-button
  81. type="text"
  82. size="small"
  83. @click.stop="rowDel(scope.row,scope.index)"
  84. >删除
  85. </el-button>
  86. <!-- :disabled="!financeDisabled || financeButton"-->
  87. </template>
  88. <template slot-scope="{ row }" slot="currency">
  89. <el-select v-if="row.$cellEdit" v-model="row.currency" size="small" placeholder="请选择 币别" clearable filterable>
  90. <el-option v-for="(item,index) in currencyDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  91. </el-select>
  92. <span v-else>{{ row.currency }}</span>
  93. </template>
  94. <template slot="thisAmount" slot-scope="{ row }">
  95. <el-input
  96. v-if="row.$cellEdit"
  97. v-model="row.thisAmount"
  98. placeholder="请输入"
  99. size="small"
  100. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
  101. @change="thisAmountChange(row)"
  102. ></el-input>
  103. <span v-else>{{ row.thisAmount }}</span>
  104. </template>
  105. </avue-crud>
  106. </basic-container>
  107. <el-dialog
  108. title="导入采购"
  109. append-to-body
  110. class="el-dialogDeep"
  111. :visible.sync="billDetailDialog"
  112. width="60%"
  113. :close-on-click-modal="false"
  114. :destroy-on-close="true"
  115. :close-on-press-escape="false"
  116. top="10vh"
  117. v-dialog-drag>
  118. <bill-detail
  119. :params="params"
  120. :billType="billType"
  121. @closeFun="closeBillDetail"
  122. @importProMent="importProMent"
  123. >
  124. </bill-detail>
  125. </el-dialog>
  126. </div>
  127. </div>
  128. </template>
  129. <script>
  130. import option from "./configuration/detailsPage.json";
  131. import { getDetail,editFinance } from "@/api/financialManagement/financialManagement"
  132. import { getDetails,modify,cancelModify,saveOrEdit } from "@/api/financialManagement/paymentRequest";
  133. import { contrastObj,contrastList } from "@/util/contrastData";
  134. import billDetail from "@/components/bill/billDetailList";
  135. import { getlistBankBy } from "@/api/financialManagement/paymentRequest";
  136. import _ from "lodash";
  137. export default {
  138. name: "paymentDetailsPage",
  139. props: {
  140. detailData: {
  141. type: Object
  142. }
  143. },
  144. data() {
  145. return {
  146. form: {},
  147. itemsForm:{},
  148. itemsOption: option,
  149. billDetailDialog:false,
  150. financeDisabled:false,
  151. financeButton:true,
  152. billType:"申请",
  153. params:{},
  154. id:"",
  155. dataList: [],
  156. currencyDic:[],
  157. page: {
  158. pageSize: 10,
  159. pagerCount: 5,
  160. total: 0,
  161. },
  162. query:{},
  163. option: {
  164. menuBtn: false,
  165. labelWidth: 100,
  166. column: [
  167. {
  168. label: '系统号',
  169. prop: 'sysNo',
  170. span: 8,
  171. disabled: true
  172. },{
  173. label: '合同号',
  174. prop: 'srcOrderno',
  175. span: 8,
  176. rules: [
  177. {
  178. required: false,
  179. message: ' ',
  180. trigger: 'blur'
  181. }
  182. ]
  183. }, {
  184. label: '客户名称',
  185. prop: 'corpId',
  186. sort:true,
  187. span: 8,
  188. rules: [
  189. {
  190. required: true,
  191. message: ' ',
  192. trigger: 'blur'
  193. }
  194. ]
  195. },
  196. {
  197. label: '银行账号',
  198. prop: 'accountNo',
  199. span: 8,
  200. rules: [
  201. {
  202. required: false,
  203. message: ' ',
  204. trigger: 'blur'
  205. }
  206. ]
  207. },
  208. {
  209. label: '开户银行',
  210. prop: 'accountBank',
  211. span: 8,
  212. rules: [
  213. {
  214. required: false,
  215. message: ' ',
  216. trigger: 'blur'
  217. }
  218. ]
  219. }, {
  220. label: '银行户头',
  221. prop: 'accountName',
  222. span: 8,
  223. rules: [
  224. {
  225. required: false,
  226. message: ' ',
  227. trigger: 'blur'
  228. }
  229. ]
  230. },
  231. {
  232. label: '人民币金额',
  233. prop: 'amount',
  234. span: 8,
  235. rules: [
  236. {
  237. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  238. message: ' ',
  239. trigger: 'blur'
  240. },
  241. {
  242. required: false,
  243. message: ' ',
  244. trigger: 'blur'
  245. }
  246. ]
  247. },
  248. {
  249. label: '外币金额',
  250. prop: 'foreignAmount',
  251. span: 8,
  252. rules: [
  253. {
  254. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  255. message: ' ',
  256. trigger: 'blur'
  257. }
  258. ]
  259. },
  260. {
  261. label: '付款日期',
  262. prop: 'settlementDate',
  263. format:"yyyy-MM-dd",
  264. valueFormat:"yyyy-MM-dd 00:00:00",
  265. span: 8,
  266. type:"date",
  267. rules: [
  268. {
  269. required: false,
  270. message: ' ',
  271. trigger: 'blur'
  272. }
  273. ]
  274. },
  275. {
  276. label: '制单人',
  277. prop: 'createUserName',
  278. span: 8,
  279. disabled:true,
  280. rules: [
  281. {
  282. required: false,
  283. message: ' ',
  284. trigger: 'blur'
  285. }
  286. ]
  287. },
  288. {
  289. label: '制单日期',
  290. prop: 'createTime',
  291. span: 8,
  292. type:"date",
  293. disabled:true,
  294. rules: [
  295. {
  296. required: false,
  297. message: ' ',
  298. trigger: 'blur'
  299. }
  300. ]
  301. },
  302. {
  303. label: '备注',
  304. prop: 'remark',
  305. span:24,
  306. minRows: 2,
  307. rules: [
  308. {
  309. required: false,
  310. message: ' ',
  311. trigger: 'blur'
  312. }
  313. ]
  314. },
  315. ],
  316. },
  317. //客户组件配置控制
  318. configuration:{
  319. multipleChoices:false,
  320. multiple:false,
  321. disabled:false,
  322. searchShow:true,
  323. collapseTags:false,
  324. placeholder:'请点击右边按钮选择',
  325. dicData:[]
  326. },
  327. financeStatusDic:[{
  328. label:'正常',
  329. value:0
  330. },{
  331. label:'停用',
  332. value:1
  333. }],
  334. //顶部from数据
  335. oldForm:{},
  336. oldDataList:[],
  337. }
  338. },
  339. components:{
  340. billDetail
  341. },
  342. created() {
  343. //币别
  344. this.getWorkDicts("currency").then(res =>{
  345. this.currencyDic = res.data.data
  346. })
  347. if (this.detailData.id) {
  348. this.id = this.detailData.id;//字符串转数字 超长用BigInt
  349. getDetail(this.id).then(res => {
  350. this.afterEcho(res.data.data)
  351. })
  352. }else{
  353. this.form.financeStatus = "待结算"
  354. }
  355. if(this.detailData.params){
  356. getDetails(this.detailData.params).then(res =>{
  357. delete res.data.data.id;
  358. delete res.data.data.sysNo;
  359. delete res.data.data.billType;
  360. res.data.data.itemsList.map((items)=>{
  361. delete items.id ;
  362. items.thisAmount = items.amount
  363. })
  364. this.afterEcho(res.data.data)
  365. })
  366. }
  367. },
  368. mounted() {
  369. },
  370. methods: {
  371. //选择客户
  372. returnBack(corpValue){
  373. this.corpId = corpValue
  374. getlistBankBy(corpValue).then(res =>{
  375. this.$set(this.form,"bankList",res.data)
  376. })
  377. },
  378. //选择卡号
  379. accountNoChange(value){
  380. this.form.bankList.forEach(item =>{
  381. if(item.accountNo == value){
  382. this.$set(this.form,"accountBank",item.accountBank)
  383. this.$set(this.form,"accountName",item.accountName)
  384. }
  385. })
  386. },
  387. thisAmountChange(row){
  388. // if(row.thisAmount > row.maxThisAmount){
  389. // this.$message.error("本次结算金额不能大于剩余结算金额!")
  390. // row.thisAmount = 0;
  391. // }
  392. },
  393. selectPurchase(){
  394. if(!this.form.corpId){
  395. this.$message.warning("请先选择客户!")
  396. return
  397. }
  398. this.params = {
  399. corpId: this.form.corpId
  400. }
  401. this.billDetailDialog = true;
  402. },
  403. closeBillDetail(){
  404. this.billDetailDialog = false;
  405. },
  406. importProMent(list){
  407. list.forEach((item,index) =>{
  408. item.accId = item.id;
  409. item.srcOrderno = item.accSysNo
  410. item.billNo = item.srcBillNo
  411. item.thisAmount = _.subtract(item.amount, item.settlementAmount) //设置本次结算最大限度
  412. item.maxThisAmount = item.thisAmount
  413. delete item.id;
  414. this.$refs.crud.rowCellAdd(item);
  415. })
  416. //明细列表金额总和等于form总金额
  417. // this.form.amount = _.sum(this.dataList.map(item =>{ return parseFloat(item.amount)}));
  418. // this.form.srcOrderno = this.dataList.map(item =>{return item.srcOrderno}).join(",")
  419. this.billDetailDialog = false;
  420. },
  421. rowUpdate(row, index, done) {
  422. done(row);
  423. },
  424. rowCell(row,index){
  425. this.$refs.crud.rowCell(row, index)
  426. },
  427. rowDel(row,index){
  428. this.dataList.splice(index, 1);
  429. },
  430. searchReset() {
  431. console.log('1')
  432. },
  433. selectionChange() {
  434. console.log('1')
  435. },
  436. currentChange() {
  437. console.log('1')
  438. },
  439. sizeChange() {
  440. console.log('1')
  441. },
  442. refreshChange() {
  443. console.log('1')
  444. },
  445. confirmSettlement(status){
  446. this.$refs["form"].validate((valid,done) => {
  447. done();
  448. if(valid){
  449. this.$confirm("是否确认付费?", "提示", {
  450. confirmButtonText: "确认",
  451. cancelButtonText: "取消",
  452. type: "warning",
  453. }).then(()=>{
  454. for (let i = 0; i < this.dataList.length; i++) {
  455. if (this.dataList[i].thisAmount == null) {
  456. return this.$message.error(`第${i + 1}行的本次金额不能为空`);
  457. }
  458. if (this.dataList[i].thisAmount === 0) {
  459. return this.$message.error(`第${i + 1}行的本次金额不能为0`);
  460. }
  461. }
  462. this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
  463. const params = {
  464. ...this.form,
  465. billType:"付费",
  466. itemsList:this.dataList
  467. }
  468. if(this.financeButton){
  469. modify(params).then(res =>{
  470. this.$message.success("操作成功!")
  471. this.afterEcho(res.data.data)
  472. })
  473. }else{
  474. cancelModify(params).then(res =>{
  475. this.$message.success("操作成功!")
  476. this.afterEcho(res.data.data)
  477. })
  478. }
  479. })
  480. if(status === true){
  481. this.$emit("goBack");
  482. }
  483. }
  484. })
  485. },
  486. saveSettlement(){
  487. this.$refs["form"].validate((valid,done) => {
  488. if(valid){
  489. this.form.billNo = this.dataList.map(item =>{return item.billNo}).join(",")
  490. const params = {
  491. ...this.form,
  492. billType:"付费",
  493. itemsList:this.dataList
  494. }
  495. saveOrEdit(params).then(res=>{
  496. this.$message.success("操作成功!")
  497. this.afterEcho(res.data.data)
  498. done();
  499. })
  500. }})
  501. },
  502. afterEcho(data){
  503. this.form = data;
  504. this.oldForm = Object.assign({},data);
  505. this.financeDisabled = this.form.financeStatus == "待结算"?true:false;
  506. //审核状态为空时 说明为新单进来
  507. if(this.financeDisabled){
  508. this.financeButton = true
  509. this.option.column.forEach(item =>{
  510. if( item.prop === "remark" || item.prop === "settlementDate"){
  511. this.$set(item,"disabled",false)
  512. }else if( item.prop === "createUserName" || item.prop === "createTime" || item.prop === "sysNo" ){
  513. this.$set(item,"disabled",true)
  514. }else{
  515. this.$set(item,"disabled",false)
  516. }
  517. })
  518. }
  519. else{
  520. this.financeButton = false
  521. this.option.column.forEach(item =>{
  522. if( item.prop === "remark"){
  523. this.$set(item,"disabled",false)
  524. }else if( item.prop === "createUserName" || item.prop === "createTime" || item.prop === "sysNo"){
  525. this.$set(item,"disabled",true)
  526. }else{
  527. this.$set(item,"disabled",true)
  528. }
  529. })
  530. }
  531. if(data.itemsList){
  532. this.dataList = data.itemsList
  533. this.oldDataList = this.deepClone(data.itemsList)
  534. }
  535. },
  536. backToList() {
  537. if(contrastObj(this.form,this.oldForm) || contrastList(this.dataList,this.oldDataList)
  538. ){
  539. this.$confirm("是否保存当前页面?", "提示", {
  540. confirmButtonText: "保存",
  541. cancelButtonText: "取消",
  542. type: "warning",
  543. }).then(() => {
  544. this.editCustomer(true)
  545. }).catch(()=>{
  546. this.$emit("goBack");
  547. })
  548. }else{
  549. this.$emit("goBack");
  550. }
  551. },
  552. }
  553. }
  554. </script>
  555. <style lang="scss" scoped>
  556. ::v-deep .el-form-item {
  557. margin-bottom: 0;
  558. }
  559. .trading-form ::v-deep .el-form-item {
  560. margin-bottom: 8px !important;
  561. }
  562. .upper_right_button{
  563. display: flex;
  564. position: fixed;
  565. right: 12px;
  566. top: 47px;
  567. }
  568. </style>