receiptSettleDetailsPage.vue 15 KB

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