applyPayment.vue 13 KB

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