applyPayment.vue 13 KB

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