applyPayment.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <div>
  3. <div v-for="(item, index) in list" :key="index">
  4. <el-row>
  5. <el-col :span="24"><span class="delete_group" v-if="list.length !== 1" @click="deleteGroup(index)">删除组</span>
  6. </el-col>
  7. </el-row>
  8. <basic-container>
  9. <avue-form class="trading-form" :option="option" ref="form" v-model="item.form">
  10. <template slot-scope="scope" slot="corpId">
  11. <selectComponent v-model="item.form.corpId" :configuration="configuration"/>
  12. </template>
  13. <template slot-scope="scope" slot="billNo">
  14. <el-select placeholder="请选择" v-model="item.form.billNo" clearable>
  15. <el-option
  16. v-for="item in item.form.billNoList"
  17. :key="item"
  18. :label="item"
  19. :value="item"
  20. ></el-option>
  21. </el-select>
  22. </template>
  23. <template slot-scope="scope" slot="costType">
  24. <breakdown-select
  25. v-model="item.form.costType"
  26. :configuration="breakConfiguration">
  27. </breakdown-select>
  28. </template>
  29. <!-- <template slot-scope="scope" slot="price">
  30. <el-input
  31. v-model="item.form.price"
  32. autocomplete="off"
  33. placeholder="请输入 单价"
  34. @input="calculate(item.form)"
  35. ></el-input>
  36. </template>
  37. <template slot-scope="scope" slot="quantity">
  38. <el-input
  39. v-model="item.form.quantity"
  40. autocomplete="off"
  41. placeholder="请输入 数量"
  42. @input="calculate(item.form)"
  43. ></el-input>
  44. </template>-->
  45. <template slot-scope="scope" slot="currency">
  46. <el-select v-model="item.form.currency" size="small" placeholder="请选择 币别" @change="currencyChange(item.form)" clearable filterable>
  47. <el-option v-for="(item,index) in currencyDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  48. </el-select>
  49. </template>
  50. </avue-form>
  51. </basic-container>
  52. </div>
  53. <el-button style="margin: 8px;" icon="el-icon-plus" size="small" @click="addForm">
  54. 添加账单
  55. </el-button>
  56. <div style="float: right;margin: 8px">
  57. <el-button size="small" @click="$emit('choceFun')">取消</el-button>
  58. <el-button type="primary" size="small" @click="submit()">确定</el-button>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import {applyLoan, paymentApply} from "@/api/financialManagement/paymentRequest";
  64. import _ from "lodash";
  65. export default {
  66. name: "applyPayment",
  67. props: {
  68. billType: {
  69. type: String
  70. },
  71. billData: {
  72. type: Object
  73. },
  74. choceFun: {
  75. type: Function
  76. },
  77. arrList: {
  78. type: Array,
  79. default: []
  80. }
  81. },
  82. data() {
  83. return {
  84. form: {
  85. form: {}
  86. },
  87. list: [],
  88. currencyDic: [],
  89. corpId: "",
  90. configuration: {
  91. multipleChoices: false,
  92. multiple: false,
  93. disabled: true,
  94. searchShow: true,
  95. collapseTags: false,
  96. placeholder: '请点击右边按钮选择',
  97. dicData: []
  98. },
  99. breakConfiguration: {
  100. multipleChoices: false,
  101. multiple: false,
  102. disabled: true,
  103. searchShow: true,
  104. collapseTags: false,
  105. placeholder: '请点击右边按钮选择',
  106. dicData: []
  107. },
  108. option: {
  109. emptyBtn: false,
  110. submitBtn: false,
  111. labelWidth: 120,
  112. menuSpan: 8,
  113. column: [
  114. {
  115. label: this.billData.optionType === "JK" ? "合同号" : "订单号",
  116. prop: 'srcOrderno',
  117. span: 8,
  118. disabled: true,
  119. rules: [
  120. {
  121. required: true,
  122. message: ' ',
  123. trigger: 'blur'
  124. }
  125. ]
  126. },
  127. {
  128. label: '客户名称',
  129. prop: 'corpId',
  130. span: 16,
  131. rules: [
  132. {
  133. required: true,
  134. message: ' ',
  135. trigger: 'blur'
  136. }
  137. ]
  138. },
  139. this.billData.optionType === "JK" ?
  140. {
  141. label: '提单号',
  142. prop: 'billNo',
  143. span: 8,
  144. rules: [
  145. {
  146. required: true,
  147. message: ' ',
  148. trigger: 'blur'
  149. }
  150. ]
  151. } : {display: false},
  152. {
  153. label: '费用名称',
  154. prop: 'costType',
  155. span: 8,
  156. rules: [
  157. {
  158. required: true,
  159. message: ' ',
  160. trigger: 'blur'
  161. }
  162. ]
  163. },
  164. {
  165. label: this.billData.optionType === "JK" ? '合同日期' : "订单日期",
  166. type: "date",
  167. prop: 'accDate',
  168. span: 8,
  169. rules: [
  170. {
  171. required: true,
  172. message: ' ',
  173. trigger: 'blur'
  174. }
  175. ]
  176. },
  177. {
  178. label: '单价',
  179. prop: 'price',
  180. span: 8,
  181. rules: [
  182. {
  183. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  184. message: ' ',
  185. trigger: 'blur'
  186. },
  187. {
  188. required: true,
  189. message: ' ',
  190. trigger: 'blur'
  191. }
  192. ]
  193. },
  194. {
  195. label: '金额',
  196. prop: 'amount',
  197. span: 8,
  198. rules: [
  199. {
  200. pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
  201. message: ' ',
  202. trigger: 'blur'
  203. },
  204. {
  205. required: true,
  206. message: ' ',
  207. trigger: 'blur'
  208. }
  209. ]
  210. },
  211. {
  212. label: this.billData.itemType === "采购" ? '付款日期' : "收款日期",
  213. prop: 'date',
  214. type: 'date',
  215. span: 8,
  216. rules: [
  217. {
  218. required: false,
  219. message: ' ',
  220. trigger: 'blur'
  221. }
  222. ]
  223. },
  224. {
  225. label: '计价单位',
  226. prop: 'unit',
  227. type: "select",
  228. span: 8,
  229. rules: [
  230. {
  231. required: true,
  232. message: ' ',
  233. trigger: 'blur'
  234. }
  235. ],
  236. dicUrl: "/api/blade-system/dict-biz/dictionary?code=unit",
  237. props: {
  238. label: "dictValue",
  239. value: "dictKey"
  240. }
  241. },
  242. {
  243. label: '币别',
  244. prop: 'currency',
  245. span: 8,
  246. type: "select",
  247. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  248. props: {
  249. label: "dictValue",
  250. value: "dictKey"
  251. },
  252. rules: [
  253. {
  254. required: true,
  255. message: ' ',
  256. trigger: 'blur'
  257. }
  258. ]
  259. },
  260. {
  261. label: '汇率',
  262. prop: 'exchangeRate',
  263. span: 8,
  264. rules: [
  265. {
  266. required: true,
  267. message: ' ',
  268. trigger: 'blur'
  269. }
  270. ]
  271. },
  272. {
  273. label: '税率',
  274. prop: 'taxRate',
  275. span: 8,
  276. rules: [
  277. {
  278. required: true,
  279. message: ' ',
  280. trigger: 'blur'
  281. }
  282. ]
  283. },
  284. {
  285. label: '备注',
  286. prop: 'remarks',
  287. span: 24,
  288. type: 'textarea',
  289. row: true,
  290. minRows: 2,
  291. isRules: false
  292. }
  293. ]
  294. },
  295. }
  296. },
  297. created() {
  298. //币别
  299. this.getWorkDicts("currency").then(res => {
  300. this.currencyDic = res.data.data
  301. })
  302. if (this.arrList.length == 0) {
  303. this.form.form = this.billData
  304. this.corpId = this.billData.corpId
  305. this.configuration.dicData = this.billData.corpsName
  306. this.addForm();
  307. }
  308. if (this.arrList.length > 0) {
  309. this.list = this.arrList
  310. let arr = []
  311. this.list.forEach(item => {
  312. let a = {
  313. id: item.form.corpId,
  314. cname: item.form.corpsName
  315. }
  316. arr.push(a)
  317. })
  318. this.configuration.dicData = this.configuration.dicData.concat(arr)
  319. }
  320. },
  321. methods: {
  322. addForm() {
  323. //去除form身上双向绑定
  324. this.list.push(JSON.parse(JSON.stringify(this.form)))
  325. },
  326. deleteGroup(index) {
  327. this.list.splice(index, 1);
  328. },
  329. //计算单价 数量
  330. // calculate(valueForm){
  331. // if(valueForm.price && valueForm.quantity){
  332. // valueForm.amount = _.multiply(valueForm.price, valueForm.quantity).toFixed(2);
  333. // }
  334. // },
  335. //币别选择
  336. currencyChange(valueForm) {
  337. if (valueForm.currency === "USD") {
  338. valueForm.exchangeRate = 6.3686;
  339. } else {
  340. valueForm.exchangeRate = 1;
  341. }
  342. },
  343. async submit() {
  344. let result = [];
  345. await this.handleRulesValid(["form"], result)
  346. if (result.some(item => item)) {
  347. const itemsList = this.list.map(item => {
  348. item.form.corpId = this.corpId;
  349. return item.form
  350. })
  351. const params = {
  352. billType : this.billType,
  353. DC : this.billData.itemType === "采购"?"C":"D", //账单明细会根据D C区分采购 销售搜索
  354. itemsList: itemsList
  355. }
  356. // 采购申请货款 销售申请退款 都会走申请 走审核 => 付款申请
  357. if(this.billType === "采购申请货款" || this.billType === "销售申请退款" ){
  358. applyLoan(params).then(res =>{
  359. if(res.data.success){
  360. this.$message.success("操作成功!")
  361. this.$emit("choceFun");
  362. //跳转付款申请页面
  363. if(this.$store.getters.pqStatus){
  364. this.$alert("无法自动跳转到付款申请页面,因为页面已存在。", "温馨提示", {
  365. confirmButtonText: "确定",
  366. type: 'warning',
  367. callback: action => {
  368. }
  369. });
  370. }else{
  371. //关闭一下存在的列表页 跳转
  372. this.$router.$avueRouter.closeTag('/payment_request');
  373. this.$router.push({
  374. path: "/payment_request",
  375. query: {params: res.data.data.id},
  376. });
  377. }
  378. }
  379. })
  380. }
  381. //采购退款结算 销售收款结算 不需申请请核 直接结算 => 结算
  382. if(this.billType === "采购退款结算" || this.billType === "销售收款结算"){
  383. paymentApply(params).then(res=>{
  384. if(res.data.success){
  385. this.$message.success("操作成功!")
  386. this.$emit("choceFun");
  387. }
  388. })
  389. }
  390. }
  391. },
  392. /**
  393. * @param instance 实例
  394. * @param result 校验结果数组
  395. * 递归校验每个表格实例
  396. */
  397. handleValid(instance,result) {
  398. if(!instance) {
  399. result.push(true)
  400. }else if(Array.isArray(instance)) {
  401. instance.map(item => this.handleValid(item,result))
  402. }else{
  403. if(instance.validate) {
  404. instance.validate(valid => {
  405. result.push(valid)
  406. instance.hide && instance.hide()
  407. })
  408. }else {
  409. instance.validateCellForm().then(msg=>{
  410. if((msg && !Object.keys(msg).length) || undefined === msg){
  411. result.push(true)
  412. }else{
  413. result.push(false)
  414. }
  415. })
  416. }
  417. }
  418. },
  419. /**
  420. * @param resultArr 校验结果数组
  421. * 统一校验方法
  422. */
  423. handleRulesValid(refsList,resultArr) {
  424. refsList.map(item => this.handleValid(this.$refs[`${item}`],resultArr))
  425. }
  426. }
  427. }
  428. </script>
  429. <style lang="scss" scoped>
  430. .delete_group{
  431. display: inline-block;
  432. line-height: 50px;
  433. color: #b80000;
  434. margin-right: 20px;
  435. float: right;
  436. }
  437. .trading-form ::v-deep .el-form-item {
  438. margin-bottom: 8px !important;
  439. }
  440. </style>