applyPayment.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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" 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: 'amount',
  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: 'price',
  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: false,
  206. message: ' ',
  207. trigger: 'blur'
  208. }
  209. ]
  210. },
  211. {
  212. label: '计价单位',
  213. prop: 'unit',
  214. type: "select",
  215. span: 8,
  216. rules: [
  217. {
  218. required: false,
  219. message: ' ',
  220. trigger: 'blur'
  221. }
  222. ],
  223. dicUrl: "/api/blade-system/dict-biz/dictionary?code=unit",
  224. props: {
  225. label: "dictValue",
  226. value: "dictKey"
  227. }
  228. },
  229. {
  230. label: '币别',
  231. prop: 'currency',
  232. span: 8,
  233. type: "select",
  234. dicUrl: "/api/blade-system/dict-biz/dictionary?code=currency",
  235. props: {
  236. label: "dictValue",
  237. value: "dictKey"
  238. },
  239. rules: [
  240. {
  241. required: true,
  242. message: ' ',
  243. trigger: 'blur'
  244. }
  245. ]
  246. },
  247. {
  248. label: '汇率',
  249. prop: 'exchangeRate',
  250. span: 8,
  251. rules: [
  252. {
  253. required: true,
  254. message: ' ',
  255. trigger: 'blur'
  256. }
  257. ]
  258. },
  259. {
  260. label: '税率',
  261. prop: 'taxRate',
  262. value:0,
  263. span: 8,
  264. rules: [
  265. {
  266. required: true,
  267. message: ' ',
  268. trigger: 'blur'
  269. }
  270. ]
  271. },
  272. {
  273. label: '备注',
  274. prop: 'remarks',
  275. span: 24,
  276. type: 'textarea',
  277. row: true,
  278. minRows: 2,
  279. isRules: false
  280. }
  281. ]
  282. },
  283. }
  284. },
  285. created() {
  286. //币别
  287. this.getWorkDicts("currency").then(res => {
  288. this.currencyDic = res.data.data
  289. })
  290. if (this.arrList.length == 0) {
  291. this.form.form = this.billData
  292. if(this.billData.billNoList && this.billData.billNoList.length === 1){
  293. this.form.form.billNo = this.billData.billNoList[0]
  294. }
  295. this.corpId = this.billData.corpId
  296. this.configuration.dicData = this.billData.corpsName
  297. this.addForm();
  298. }
  299. if (this.arrList.length > 0) {
  300. this.list = this.arrList
  301. this.corpId = this.list[0].form.corpId
  302. let arr = []
  303. this.list.forEach(item => {
  304. let a = {
  305. id: item.form.corpId,
  306. cname: item.form.corpsName
  307. }
  308. arr.push(a)
  309. })
  310. this.configuration.dicData = this.configuration.dicData.concat(arr)
  311. }
  312. },
  313. methods: {
  314. addForm() {
  315. //去除form身上双向绑定
  316. this.list.push(JSON.parse(JSON.stringify(this.form)))
  317. },
  318. deleteGroup(index) {
  319. this.list.splice(index, 1);
  320. },
  321. //计算单价 数量
  322. // calculate(valueForm){
  323. // if(valueForm.price && valueForm.quantity){
  324. // valueForm.amount = _.multiply(valueForm.price, valueForm.quantity).toFixed(2);
  325. // }
  326. // },
  327. //币别选择
  328. currencyChange(valueForm) {
  329. if (valueForm.currency === "CNY") {
  330. valueForm.exchangeRate = 1;
  331. } else if (valueForm.currency === "USD"){
  332. valueForm.exchangeRate = 6.3686;
  333. }else{
  334. valueForm.exchangeRate = 7.1749;
  335. }
  336. },
  337. async submit() {
  338. let result = [];
  339. await this.handleRulesValid(["form"], result)
  340. if (result.some(item => item)) {
  341. const itemsList = this.list.map(item => {
  342. item.form.corpId = this.corpId;
  343. return item.form
  344. })
  345. const params = {
  346. billType : this.billType,
  347. DC : this.billData.itemType === "采购"?"C":"D", //账单明细会根据D C区分采购 销售搜索
  348. itemsList: itemsList
  349. }
  350. // 采购申请货款 销售申请退款 都会走申请 走审核 => 付款申请
  351. if(this.billType === "申请"){
  352. applyLoan(params).then(res =>{
  353. if(res.data.success){
  354. this.$message.success("操作成功!")
  355. this.$emit("choceFun");
  356. //跳转付款申请页面
  357. if(this.$store.getters.pqStatus){
  358. this.$alert("无法自动跳转到付款申请页面,因为页面已存在。", "温馨提示", {
  359. confirmButtonText: "确定",
  360. type: 'warning',
  361. callback: action => {
  362. }
  363. });
  364. }else{
  365. //关闭一下存在的列表页 跳转
  366. this.$router.$avueRouter.closeTag('/financialManagement/paymentRequest/paymentRequest');
  367. this.$router.push({
  368. path: "/financialManagement/paymentRequest/paymentRequest",
  369. query: {params: res.data.data.id},
  370. });
  371. }
  372. }
  373. })
  374. }
  375. //采购退款结算 销售收款结算 不需申请请核 直接结算 => 结算
  376. if(this.billType === "收费"){
  377. paymentApply(params).then(res=>{
  378. if(res.data.success){
  379. this.$message.success("操作成功!")
  380. this.$emit("choceFun");
  381. }
  382. })
  383. }
  384. }
  385. },
  386. /**
  387. * @param instance 实例
  388. * @param result 校验结果数组
  389. * 递归校验每个表格实例
  390. */
  391. handleValid(instance,result) {
  392. if(!instance) {
  393. result.push(true)
  394. }else if(Array.isArray(instance)) {
  395. instance.map(item => this.handleValid(item,result))
  396. }else{
  397. if(instance.validate) {
  398. instance.validate(valid => {
  399. result.push(valid)
  400. instance.hide && instance.hide()
  401. })
  402. }else {
  403. instance.validateCellForm().then(msg=>{
  404. if((msg && !Object.keys(msg).length) || undefined === msg){
  405. result.push(true)
  406. }else{
  407. result.push(false)
  408. }
  409. })
  410. }
  411. }
  412. },
  413. /**
  414. * @param resultArr 校验结果数组
  415. * 统一校验方法
  416. */
  417. handleRulesValid(refsList,resultArr) {
  418. refsList.map(item => this.handleValid(this.$refs[`${item}`],resultArr))
  419. }
  420. }
  421. }
  422. </script>
  423. <style lang="scss" scoped>
  424. .delete_group{
  425. display: inline-block;
  426. line-height: 50px;
  427. color: #b80000;
  428. margin-right: 20px;
  429. float: right;
  430. }
  431. .trading-form ::v-deep .el-form-item {
  432. margin-bottom: 8px !important;
  433. }
  434. </style>