SendPurchasePayment.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <div class="form">
  3. <testForm
  4. v-model="formData.data"
  5. :formOption="formOption"
  6. :formConfig="formConfig"
  7. :rules="rules"
  8. @onSubmit="onSubmit"
  9. ref="formDom"
  10. ></testForm>
  11. <testForm
  12. v-model="formData.data"
  13. :formOption="formOptionOne"
  14. :formConfig="formConfigOne"
  15. :rules="rules"
  16. @onSubmit="onSubmit"
  17. ref="formDomOne"
  18. ></testForm>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { ref, reactive, getCurrentInstance, onMounted } from "vue";
  23. import { showSuccessToast, showFailToast } from "vant";
  24. import { useRoute } from "vue-router";
  25. import testForm from "@/components/testForm/index.vue";
  26. const proxy = getCurrentInstance().proxy;
  27. const route = useRoute();
  28. const formDom = ref(null);
  29. const formDomOne = ref(null);
  30. const formData = reactive({
  31. data: {},
  32. });
  33. const rules = {
  34. supplyId: [
  35. {
  36. required: true,
  37. message: proxy.t("purchasePayment.supplyNameCanNotBeEmpty"),
  38. },
  39. ],
  40. type: [
  41. {
  42. required: true,
  43. message: proxy.t("purchasePayment.paymentTypeCanNotBeEmpty"),
  44. },
  45. ],
  46. advanceCode: [
  47. {
  48. required: true,
  49. message: proxy.t("purchasePayment.prepaymentCodeCanNotBeEmpty"),
  50. },
  51. ],
  52. remark: [
  53. {
  54. required: true,
  55. message: proxy.t("purchasePayment.descriptionCanNotBeEmpty"),
  56. },
  57. ],
  58. invoiceType: [
  59. {
  60. required: true,
  61. message: proxy.t("purchasePayment.invoiceTypeCanNotBeEmpty"),
  62. },
  63. ],
  64. rate: [
  65. {
  66. required: true,
  67. message: proxy.t("purchasePayment.taxRateCanNotBeEmpty"),
  68. },
  69. ],
  70. purchaseId: [
  71. {
  72. required: true,
  73. message: proxy.t("purchasePayment.purchaseContractCanNotBeEmpty"),
  74. },
  75. ],
  76. money: [
  77. {
  78. required: true,
  79. message: proxy.t("purchasePayment.paymentAmountCanNotBeEmpty"),
  80. },
  81. ],
  82. payType: [
  83. {
  84. required: true,
  85. message: proxy.t("purchasePayment.paymentMethonCanNotBeEmpty"),
  86. },
  87. ],
  88. accountManagementId: [
  89. {
  90. required: true,
  91. message: proxy.t("purchasePayment.paymentAccountCanNotBeEmpty"),
  92. },
  93. ],
  94. name: [
  95. {
  96. required: true,
  97. message: proxy.t("purchasePayment.accountNameCanNotBeEmpty"),
  98. },
  99. ],
  100. };
  101. const formOption = reactive({
  102. readonly: false, //用于控制整个表单是否只读
  103. disabled: false,
  104. labelAlign: "top",
  105. scroll: true,
  106. labelWidth: "62pk",
  107. submitBtnText: proxy.t("common.submit"),
  108. hiddenSubmitBtn: true,
  109. btnConfig: {
  110. isNeed: true,
  111. label: proxy.t("purchasePayment.paymentDetails"),
  112. prop: "payDetailList",
  113. plain: true,
  114. listConfig: [
  115. {
  116. type: "picker",
  117. label: proxy.t("purchasePayment.purchaseContract"),
  118. prop: "purchaseId",
  119. itemType: "onePicker",
  120. showPicker: false,
  121. readonly: false,
  122. fieldNames: {
  123. text: "name",
  124. value: "id",
  125. },
  126. data: [],
  127. changeFn: function (option, item, index, currentSonIndex) {
  128. formData.data.list[index][item.prop] = option.selectedOptions[0].id;
  129. formData.data.list[index][item.prop + "Name"] =
  130. option.selectedOptions[0].name;
  131. formDom.value.btnConfigCopy.listConfig[
  132. currentSonIndex
  133. ].showPicker = false;
  134. getStokeQuantity();
  135. },
  136. },
  137. {
  138. type: "input",
  139. itemType: "number",
  140. label: proxy.t("purchasePayment.contractAmount"),
  141. prop: "amount",
  142. readonly: true,
  143. },
  144. {
  145. type: "input",
  146. itemType: "number",
  147. label: proxy.t("purchasePayment.paidAmount"),
  148. prop: "sumPayMoney",
  149. readonly: true,
  150. },
  151. {
  152. type: "input",
  153. itemType: "textarea",
  154. label: proxy.t("purchasePayment.paymentDescription"),
  155. prop: "remark",
  156. readonly: false,
  157. },
  158. {
  159. type: "input",
  160. itemType: "number",
  161. label: proxy.t("purchasePayment.paymentAmount"),
  162. prop: "money",
  163. readonly: false,
  164. },
  165. ],
  166. clickFn: () => {
  167. if (
  168. formData.data.payDetailList &&
  169. formData.data.payDetailList.length > 0
  170. ) {
  171. formData.data.payDetailList.push({
  172. purchaseId: "",
  173. money: "",
  174. remark: "",
  175. });
  176. } else {
  177. formData.data.payDetailList = [
  178. { purchaseId: "", money: "", remark: "" },
  179. ];
  180. }
  181. },
  182. },
  183. });
  184. const formConfig = reactive([
  185. {
  186. type: "picker",
  187. label: proxy.t("purchasePayment.supplyName"),
  188. prop: "supplyId",
  189. itemType: "onePicker",
  190. showPicker: false,
  191. readonly: false,
  192. fieldNames: {
  193. text: "label",
  194. value: "value",
  195. },
  196. data: [],
  197. changeFn: function (option, item, index) {
  198. formData.data[item.prop] = option.selectedOptions[0].value;
  199. formData.data[item.prop + "Name"] = option.selectedOptions[0].label;
  200. formConfig[index].showPicker = false;
  201. changeSupply(option.selectedOptions[0].value);
  202. },
  203. },
  204. {
  205. type: "picker",
  206. label: proxy.t("purchasePayment.paymentTerm"),
  207. prop: "deadline",
  208. itemType: "datePickerTime",
  209. showPicker: false,
  210. readonly: false,
  211. needDefault: false,
  212. },
  213. {
  214. type: "picker",
  215. label: proxy.t("purchasePayment.paymentType"),
  216. prop: "type",
  217. itemType: "onePicker",
  218. showPicker: false,
  219. readonly: false,
  220. fieldNames: {
  221. text: "label",
  222. value: "value",
  223. },
  224. data: [
  225. { label: "未核销", value: "0" },
  226. { label: "发票核销", value: "1" },
  227. ],
  228. changeFn: function (option, item, index) {
  229. proxy.formChange(option, item, formData);
  230. formConfig[index].showPicker = false;
  231. changeType(formData.data[item.prop]);
  232. },
  233. },
  234. {
  235. type: "pickerOne",
  236. label: proxy.t("purchasePayment.prepaymentCode"),
  237. prop: "advanceCode",
  238. itemType: "onePicker",
  239. showPicker: false,
  240. readonly: false,
  241. fieldNames: {
  242. text: "label",
  243. value: "value",
  244. },
  245. data: [],
  246. changeFn: function (option, item, index) {
  247. formData.data[item.prop] = option.selectedOptions[0].value;
  248. formData.data[item.prop + "Name"] = option.selectedOptions[0].label;
  249. formConfig[index].showPicker = false;
  250. changeSupply(option.selectedOptions[0].value);
  251. },
  252. },
  253. {
  254. type: "input",
  255. label: proxy.t("purchasePayment.paymentDescription"),
  256. prop: "remark",
  257. itemType: "textarea",
  258. readonly: false,
  259. },
  260. {
  261. type: "input",
  262. label: proxy.t("purchasePayment.documentNumber"),
  263. prop: "receiptsNum",
  264. itemType: "number",
  265. readonly: false,
  266. },
  267. {
  268. type: "picker",
  269. label: proxy.t("purchasePayment.invoiceType"),
  270. prop: "invoiceType",
  271. itemType: "onePicker",
  272. showPicker: false,
  273. readonly: false,
  274. fieldNames: {
  275. text: "label",
  276. value: "value",
  277. },
  278. data: [],
  279. changeFn: function (option, item, index) {
  280. proxy.formChange(option, item, formData);
  281. formConfig[index].showPicker = false;
  282. changeInvoiceType(formData.data[item.prop]);
  283. },
  284. },
  285. {
  286. type: "input",
  287. label: proxy.t("purchasePayment.taxRate") + "(%)",
  288. prop: "rate",
  289. itemType: "number",
  290. readonly: false,
  291. },
  292. ]);
  293. const formOptionOne = reactive({
  294. readonly: false, //用于控制整个表单是否只读
  295. disabled: false,
  296. labelAlign: "top",
  297. scroll: true,
  298. labelWidth: "62pk",
  299. submitBtnText: proxy.t("common.submit"),
  300. hiddenSubmitBtn: true,
  301. });
  302. const formConfigOne = reactive([
  303. {
  304. type: "input",
  305. label: proxy.t("purchasePayment.totalPaymentAmount"),
  306. prop: "amount",
  307. itemType: "number",
  308. readonly: false,
  309. },
  310. {
  311. type: "picker",
  312. label: proxy.t("purchasePayment.paymentMethon"),
  313. prop: "payType",
  314. itemType: "onePicker",
  315. showPicker: false,
  316. readonly: false,
  317. fieldNames: {
  318. text: "label",
  319. value: "value",
  320. },
  321. data: [],
  322. changeFn: function (option, item, index) {
  323. proxy.formChange(option, item, formData);
  324. formConfigOne[index].showPicker = false;
  325. },
  326. },
  327. {
  328. type: "picker",
  329. label: proxy.t("purchasePayment.paymentAccount"),
  330. prop: "accountManagementId",
  331. itemType: "onePicker",
  332. showPicker: false,
  333. readonly: false,
  334. fieldNames: {
  335. text: "label",
  336. value: "value",
  337. },
  338. data: [],
  339. changeFn: function (option, item, index) {
  340. proxy.formChange(option, item, formData);
  341. formConfigOne[index].showPicker = false;
  342. changeAccount(formData.data[item.prop]);
  343. },
  344. },
  345. {
  346. type: "input",
  347. label: proxy.t("purchasePayment.accountName"),
  348. prop: "name",
  349. itemType: "text",
  350. readonly: false,
  351. },
  352. {
  353. type: "input",
  354. label: proxy.t("purchasePayment.bankAccount"),
  355. prop: "accountOpening",
  356. itemType: "text",
  357. readonly: false,
  358. },
  359. {
  360. type: "input",
  361. label: proxy.t("purchasePayment.bankOfDeposit"),
  362. prop: "openingBank",
  363. itemType: "text",
  364. readonly: false,
  365. },
  366. {
  367. type: "input",
  368. label: proxy.t("purchasePayment.interbankNumber"),
  369. prop: "interbankNumber",
  370. itemType: "text",
  371. readonly: false,
  372. },
  373. ]);
  374. const supplierList = ref([]);
  375. const accountList = ref([]);
  376. const invoiceType = ref([]);
  377. const fundsPaymentMethod = ref([]);
  378. const contractList = ref([]);
  379. const changeSupply = (val) => {
  380. if (val) {
  381. proxy.get("/purchase/getListBySupplyId", { supplyId: val }).then((res) => {
  382. if (res.data && res.data.length > 0) {
  383. contractList.value = res.data.map((item) => {
  384. return {
  385. value: item.id,
  386. label: item.code,
  387. amount: item.amount,
  388. sumPayMoney: item.sumPayMoney,
  389. sumInvoiceMoney: item.sumInvoiceMoney,
  390. };
  391. });
  392. } else {
  393. contractList.value = [];
  394. }
  395. });
  396. } else {
  397. contractList.value = [];
  398. }
  399. formData.data.payDetailList = [];
  400. };
  401. const changeType = (val) => {
  402. if (val == "1") {
  403. formConfig[3].type = "picker";
  404. } else {
  405. formConfig[3].type = "pickerOne";
  406. }
  407. };
  408. const changeInvoiceType = (val) => {
  409. if (val == "1") {
  410. formConfig[7].type = "input";
  411. formData.data.rate = "13";
  412. } else if (val == "2") {
  413. formConfig[7].type = "input";
  414. formData.data.rate = "6";
  415. } else {
  416. formConfig[7].type = "inputOne";
  417. formData.data.rate = "";
  418. }
  419. };
  420. const changeAccount = (val) => {
  421. if (val) {
  422. let data = accountList.value.filter((item) => item.value === val);
  423. if (data && data.length > 0) {
  424. formData.data.name = data[0].bankName;
  425. formData.data.accountOpening = data[0].accountOpening;
  426. formData.data.openingBank = data[0].openingBank;
  427. formData.data.interbankNumber = data[0].interbankNumber;
  428. }
  429. }
  430. };
  431. const getDict = () => {
  432. proxy
  433. .post("/supplierInfo/page", { pageNum: 1, pageSize: 999 })
  434. .then((res) => {
  435. if (res.data.rows && res.data.rows.length > 0) {
  436. supplierList.value = res.data.rows.map((item) => {
  437. return {
  438. label: item.name,
  439. value: item.id,
  440. };
  441. });
  442. formConfig[0].data = supplierList.value;
  443. }
  444. });
  445. proxy
  446. .post("/accountManagement/page", { pageNum: 1, pageSize: 999 })
  447. .then((res) => {
  448. accountList.value = res.data.rows.map((item) => {
  449. return {
  450. bankName: item.name,
  451. accountOpening: item.accountOpening,
  452. openingBank: item.openingBank,
  453. interbankNumber: item.interbankNumber,
  454. label: item.alias,
  455. value: item.id,
  456. };
  457. });
  458. formConfigOne[2].data = accountList.value;
  459. });
  460. proxy.getDictOne(["invoice_type", "funds_payment_method"]).then((res) => {
  461. invoiceType.value = res["invoice_type"].data.map((x) => ({
  462. label: x.dictValue,
  463. value: x.dictKey,
  464. }));
  465. fundsPaymentMethod.value = res["funds_payment_method"].data.map((x) => ({
  466. label: x.dictValue,
  467. value: x.dictKey,
  468. }));
  469. formConfig[6].data = invoiceType.value;
  470. formConfigOne[1].data = fundsPaymentMethod.value;
  471. });
  472. };
  473. getDict();
  474. const handleSubmit = async () => {
  475. if (formData.data.payDetailList && formData.data.payDetailList.length > 0) {
  476. console.log(formDom.value.testForm.value.submit(), "ss");
  477. } else {
  478. showFailToast(proxy.t("purchasePayment.pleaseAddPaymentDetails"));
  479. return false;
  480. }
  481. };
  482. defineExpose({
  483. handleSubmit,
  484. });
  485. </script>
  486. <style lang="scss" scoped>
  487. </style>