paymentSettleDetailsPage.vue 15 KB

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