receiptSettleDetailsPage.vue 17 KB

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