Contract.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <div class="form">
  3. <van-tabs v-model:active="active">
  4. <van-tab :title="proxy.t('funds.basicInformation')"> </van-tab>
  5. <van-tab :title="proxy.t('funds.claimDetails')"> </van-tab>
  6. <van-tab :title="proxy.t('funds.receiptPaymentInformation')"> </van-tab>
  7. <div class="common-process-card" v-show="active == 0">
  8. <div class="common-title">{{ proxy.t("funds.basicInformation") }}</div>
  9. <testForm v-model="formData.data" :formOption="formOption" :formConfig="formConfig" :rules="rules" ref="formDom1"> </testForm>
  10. </div>
  11. <div class="common-process-card" v-show="active == 1">
  12. <div class="common-title">{{ proxy.t("funds.claimDetails") }}</div>
  13. <testForm v-model="formData.data" :formOption="formDetailOption" :formConfig="formDetailConfig" :rules="rules" ref="formDom2"> </testForm>
  14. <testForm v-model="formData.data" :formOption="formDetailTwoOption" :formConfig="formDetailTwoConfig" :rules="rules" ref="formDom3"> </testForm>
  15. </div>
  16. <div class="common-process-card" v-show="active == 2">
  17. <div class="common-title">{{ proxy.t("funds.receiptPaymentInformation") }}</div>
  18. <testForm v-model="formData.data" :formOption="formReceiptPaymentOption" :formConfig="formReceiptPaymentConfig" :rules="rules" ref="formDom4">
  19. </testForm>
  20. </div>
  21. </van-tabs>
  22. </div>
  23. </template>
  24. <script setup>
  25. import { ref, getCurrentInstance, onMounted, defineProps, defineExpose, watch, reactive } from "vue";
  26. import { showSuccessToast, showFailToast } from "vant";
  27. import { useRoute } from "vue-router";
  28. import testForm from "@/components/testForm/index.vue";
  29. import { getUserInfo } from "@/utils/auth";
  30. // 接收父组件的传值
  31. const props = defineProps({
  32. queryData: String,
  33. });
  34. const proxy = getCurrentInstance().proxy;
  35. const route = useRoute();
  36. const active = ref(0);
  37. const oldType = ref("");
  38. const formData = reactive({
  39. data: {
  40. corporationId: null,
  41. departmentId: null,
  42. type: null,
  43. advanceId: null,
  44. currency: null,
  45. paymentRemarks: null,
  46. accountRequestFundsDetailList: [],
  47. total: null,
  48. quantity: null,
  49. paymentMethod: null,
  50. accountManagementId: null,
  51. username: null,
  52. accountOpening: null,
  53. openingBank: null,
  54. interbankNumber: null,
  55. },
  56. });
  57. const formDom1 = ref(null);
  58. const formDom2 = ref(null);
  59. const formDom3 = ref(null);
  60. const formDom4 = ref(null);
  61. const formOption = reactive({
  62. readonly: false, //用于控制整个表单是否只读
  63. disabled: false,
  64. labelAlign: "top",
  65. scroll: true,
  66. labelWidth: "62pk",
  67. hiddenSubmitBtn: true,
  68. });
  69. const formConfig = reactive([
  70. {
  71. type: "picker",
  72. label: proxy.t("funds.corporationId"),
  73. prop: "corporationId",
  74. itemType: "onePicker",
  75. showPicker: false,
  76. fieldNames: {
  77. text: "label",
  78. value: "value",
  79. },
  80. data: [],
  81. changeFn: (val, item) => {
  82. formData.data.corporationId = val.selectedValues[0];
  83. let list = item.data.filter((aa) => aa[item.fieldNames.value] == val.selectedValues[0]);
  84. if (list && list.length > 0) {
  85. formData.data.corporationIdName = list[0][item.fieldNames.text];
  86. } else {
  87. formData.data.corporationIdName = "";
  88. }
  89. if (formData.data.type == "3") {
  90. getAdvanceList();
  91. }
  92. item.showPicker = false;
  93. },
  94. },
  95. {
  96. type: "picker",
  97. label: proxy.t("funds.departmentId"),
  98. prop: "departmentId",
  99. itemType: "onePicker",
  100. showPicker: false,
  101. fieldNames: {
  102. text: "label",
  103. value: "value",
  104. },
  105. data: [],
  106. },
  107. {
  108. type: "picker",
  109. label: proxy.t("funds.type"),
  110. prop: "type",
  111. itemType: "onePicker",
  112. showPicker: false,
  113. fieldNames: {
  114. text: "label",
  115. value: "value",
  116. },
  117. data: [],
  118. changeFn: (val, item) => {
  119. if (val.selectedValues[0] === "3" || oldType.value === "3") {
  120. for (let text in formData.data) {
  121. if (text === "advanceId") {
  122. formData.data.advanceId = "";
  123. } else if (["corporationId", "corporationIdName", "type", "typeName", "paymentTime", "paymentTimeName"].includes(text)) {
  124. } else if (text === "accountRequestFundsDetailList") {
  125. formData.data.accountRequestFundsDetailList = [];
  126. } else if (text === "fileList") {
  127. formData.data.fileList = [];
  128. } else {
  129. delete formData.data[text];
  130. }
  131. }
  132. }
  133. oldType.value = JSON.parse(JSON.stringify(val.selectedValues[0]));
  134. formData.data.type = JSON.parse(JSON.stringify(val.selectedValues[0]));
  135. let list = item.data.filter((aa) => aa[item.fieldNames.value] == val.selectedValues[0]);
  136. if (list && list.length > 0) {
  137. formData.data.typeName = list[0][item.fieldNames.text];
  138. } else {
  139. formData.data.typeName = "";
  140. }
  141. if (val.selectedValues[0] === "3") {
  142. formConfig[3].type = "picker";
  143. getAdvanceList();
  144. } else {
  145. formConfig[3].type = "pickerAAA";
  146. }
  147. item.showPicker = false;
  148. },
  149. },
  150. {
  151. type: "pickerAAA",
  152. label: proxy.t("funds.advanceId"),
  153. prop: "advanceId",
  154. itemType: "onePicker",
  155. showPicker: false,
  156. fieldNames: {
  157. text: "label",
  158. value: "value",
  159. },
  160. data: [],
  161. changeFn: (val, item) => {
  162. formData.data.advanceId = val.selectedValues[0];
  163. let list = item.data.filter((aa) => aa[item.fieldNames.value] == val.selectedValues[0]);
  164. if (list && list.length > 0) {
  165. formData.data.advanceIdName = list[0][item.fieldNames.text];
  166. } else {
  167. formData.data.advanceIdName = "";
  168. }
  169. if (val.selectedValues && val.selectedValues.length > 0) {
  170. proxy.post("/accountRequestFunds/detail", { id: val.selectedValues[0] }).then((res) => {
  171. formData.data.departmentId = res.data.departmentId;
  172. formData.data.currency = res.data.currency;
  173. formData.data.paymentRemarks = res.data.paymentRemarks;
  174. formData.data.accountRequestFundsDetailList = res.data.accountRequestFundsDetailList.map((item) => {
  175. return {
  176. costType: item.costType,
  177. amount: item.amount,
  178. contractId: item.contractId,
  179. advanceAmount: item.amount,
  180. remarks: item.remarks,
  181. };
  182. });
  183. handleChangeAmount();
  184. formData.data.advanceAmounts = res.data.total;
  185. formData.data.quantity = res.data.quantity;
  186. formData.data.paymentMethod = res.data.paymentMethod;
  187. formData.data.accountManagementId = res.data.accountManagementId;
  188. formData.data.name = res.data.name;
  189. formData.data.accountOpening = res.data.accountOpening;
  190. formData.data.openingBank = res.data.openingBank;
  191. formData.data.interbankNumber = res.data.interbankNumber;
  192. formDom1.value.formDataShowLabelOne();
  193. formDom2.value.formDataListShowLabelOne();
  194. formDom4.value.formDataShowLabelOne();
  195. });
  196. }
  197. item.showPicker = false;
  198. },
  199. },
  200. {
  201. type: "picker",
  202. label: proxy.t("funds.currency"),
  203. prop: "currency",
  204. itemType: "onePicker",
  205. showPicker: false,
  206. fieldNames: {
  207. text: "label",
  208. value: "value",
  209. },
  210. data: [],
  211. },
  212. {
  213. type: "input",
  214. label: proxy.t("funds.paymentRemarks"),
  215. prop: "paymentRemarks",
  216. itemType: "textarea",
  217. },
  218. ]);
  219. const formDetailOption = reactive({
  220. readonly: false, //用于控制整个表单是否只读
  221. disabled: false,
  222. labelAlign: "top",
  223. scroll: true,
  224. labelWidth: "62pk",
  225. hiddenSubmitBtn: true,
  226. btnConfig: {
  227. isNeed: true,
  228. prop: "accountRequestFundsDetailList",
  229. plain: true,
  230. listTitle: proxy.t("funds.claimDetails"),
  231. listConfig: [
  232. {
  233. type: "picker",
  234. label: proxy.t("funds.costType"),
  235. prop: "costType",
  236. itemType: "onePicker",
  237. showPicker: false,
  238. readonly: false,
  239. fieldNames: {
  240. text: "label",
  241. value: "value",
  242. },
  243. data: [],
  244. },
  245. {
  246. type: "picker",
  247. label: proxy.t("funds.contractId"),
  248. prop: "contractId",
  249. itemType: "onePicker",
  250. showPicker: false,
  251. readonly: false,
  252. fieldNames: {
  253. text: "label",
  254. value: "value",
  255. },
  256. data: [],
  257. },
  258. {
  259. type: "input",
  260. label: proxy.t("funds.amount"),
  261. prop: "amount",
  262. itemType: "number",
  263. changeFn: () => {
  264. handleChangeAmount();
  265. },
  266. },
  267. {
  268. type: "input",
  269. label: proxy.t("funds.remarks"),
  270. prop: "remarks",
  271. itemType: "textarea",
  272. },
  273. ],
  274. clickFn: () => {
  275. if (formData.data.accountRequestFundsDetailList && formData.data.accountRequestFundsDetailList.length > 0) {
  276. formData.data.accountRequestFundsDetailList.push({
  277. costType: null,
  278. contractId: null,
  279. amount: null,
  280. remarks: null,
  281. });
  282. } else {
  283. formData.data.accountRequestFundsDetailList = [
  284. {
  285. costType: null,
  286. contractId: null,
  287. amount: null,
  288. remarks: null,
  289. },
  290. ];
  291. }
  292. },
  293. deleteFn: (index) => {
  294. formData.data.accountRequestFundsDetailList.splice(index, 1);
  295. handleChangeAmount();
  296. },
  297. },
  298. });
  299. const formDetailConfig = reactive([]);
  300. const formDetailTwoOption = reactive({
  301. readonly: false, //用于控制整个表单是否只读
  302. disabled: false,
  303. labelAlign: "top",
  304. scroll: true,
  305. labelWidth: "62pk",
  306. hiddenSubmitBtn: true,
  307. });
  308. const formDetailTwoConfig = reactive([
  309. {
  310. type: "input",
  311. label: proxy.t("funds.total"),
  312. prop: "total",
  313. itemType: "number",
  314. readonly: true,
  315. },
  316. {
  317. type: "input",
  318. label: proxy.t("funds.quantity"),
  319. prop: "quantity",
  320. itemType: "number",
  321. },
  322. ]);
  323. const formReceiptPaymentOption = reactive({
  324. readonly: false, //用于控制整个表单是否只读
  325. disabled: false,
  326. labelAlign: "top",
  327. scroll: true,
  328. labelWidth: "62pk",
  329. hiddenSubmitBtn: true,
  330. });
  331. const formReceiptPaymentConfig = reactive([
  332. {
  333. type: "picker",
  334. label: proxy.t("funds.paymentMethod"),
  335. prop: "paymentMethod",
  336. itemType: "onePicker",
  337. showPicker: false,
  338. fieldNames: {
  339. text: "label",
  340. value: "value",
  341. },
  342. data: [],
  343. },
  344. {
  345. type: "picker",
  346. label: proxy.t("funds.accountManagementId"),
  347. prop: "accountManagementId",
  348. itemType: "onePicker",
  349. showPicker: false,
  350. fieldNames: {
  351. text: "label",
  352. value: "value",
  353. },
  354. data: [],
  355. },
  356. {
  357. type: "input",
  358. label: proxy.t("funds.username"),
  359. prop: "name",
  360. itemType: "text",
  361. },
  362. {
  363. type: "input",
  364. label: proxy.t("funds.accountOpening"),
  365. prop: "accountOpening",
  366. itemType: "text",
  367. },
  368. {
  369. type: "input",
  370. label: proxy.t("funds.openingBank"),
  371. prop: "openingBank",
  372. itemType: "text",
  373. },
  374. {
  375. type: "input",
  376. label: proxy.t("funds.interbankNumber"),
  377. prop: "interbankNumber",
  378. itemType: "text",
  379. },
  380. ]);
  381. const rules = {
  382. corporationId: [{ required: true, message: proxy.t("funds.corporationIdMsg") }],
  383. departmentId: [{ required: true, message: proxy.t("funds.departmentIdMsg") }],
  384. type: [{ required: true, message: proxy.t("funds.typeMsg") }],
  385. advanceId: [{ required: true, message: proxy.t("funds.advanceIdMsg") }],
  386. currency: [{ required: true, message: proxy.t("funds.currencyMsg") }],
  387. costType: [{ required: true, message: proxy.t("funds.costTypeMsg") }],
  388. contractId: [{ required: true, message: proxy.t("funds.contractIdMsg") }],
  389. amount: [{ required: true, message: proxy.t("funds.amountMsg") }],
  390. remarks: [{ required: true, message: proxy.t("funds.remarksMsg") }],
  391. quantity: [{ required: true, message: proxy.t("funds.quantityMsg") }],
  392. paymentMethod: [{ required: true, message: proxy.t("funds.paymentMethodMsg") }],
  393. accountManagementId: [{ required: true, message: proxy.t("funds.accountManagementIdMsg") }],
  394. };
  395. const getAdvanceList = () => {
  396. proxy
  397. .post("/accountRequestFunds/page", {
  398. pageNum: 1,
  399. pageSize: 999,
  400. type: "1",
  401. writeOffStatus: "0",
  402. corporationId: formData.data.corporationId,
  403. status: "30",
  404. createUser: getUserInfo().userId,
  405. })
  406. .then((res) => {
  407. if (res.data.rows && res.data.rows.length > 0) {
  408. formConfig[3].data = res.data.rows.map((item) => {
  409. return {
  410. label: item.createTime.substr(0, 10) + " " + item.currency + " " + item.total,
  411. value: item.id,
  412. };
  413. });
  414. }
  415. });
  416. };
  417. const getDict = () => {
  418. let query = {
  419. pageNum: 1,
  420. pageSize: 999,
  421. tenantId: getUserInfo().tenantId,
  422. };
  423. proxy.post("/corporation/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
  424. if (res.data.rows && res.data.rows.length > 0) {
  425. formConfig[0].data = res.data.rows.map((item) => {
  426. return {
  427. label: item.name,
  428. value: item.id,
  429. };
  430. });
  431. }
  432. });
  433. proxy.get("/tenantDept/list", query).then((res) => {
  434. if (res.data && res.data.length > 0) {
  435. formConfig[1].data = res.data
  436. .filter((item) => item.parentId != "0")
  437. .map((item) => {
  438. return {
  439. label: item.deptName,
  440. value: item.deptId,
  441. };
  442. });
  443. }
  444. });
  445. proxy.post("/dictTenantData/page", { ...query, dictCode: "founds_type" }).then((res) => {
  446. if (res.data.rows && res.data.rows.length > 0) {
  447. formConfig[2].data = res.data.rows.map((item) => {
  448. return {
  449. label: item.dictValue,
  450. value: item.dictKey,
  451. };
  452. });
  453. }
  454. });
  455. proxy.post("/dictTenantData/page", { ...query, dictCode: "account_currency" }).then((res) => {
  456. if (res.data.rows && res.data.rows.length > 0) {
  457. formConfig[4].data = res.data.rows.map((item) => {
  458. return {
  459. label: item.dictValue,
  460. value: item.dictKey,
  461. };
  462. });
  463. }
  464. });
  465. proxy.post("/dictTenantData/page", { ...query, dictCode: "funds_cost_type" }).then((res) => {
  466. if (res.data.rows && res.data.rows.length > 0) {
  467. formDetailOption.btnConfig.listConfig[0].data = res.data.rows.map((item) => {
  468. return {
  469. label: item.dictValue,
  470. value: item.dictKey,
  471. };
  472. });
  473. }
  474. });
  475. proxy.post("/contract/page1", { pageNum: 1, pageSize: 9999, status: 30 }).then((res) => {
  476. if (res.data.rows && res.data.rows.length > 0) {
  477. formDetailOption.btnConfig.listConfig[1].data = res.data.rows.map((item) => {
  478. return {
  479. label: item.code,
  480. value: item.id,
  481. };
  482. });
  483. }
  484. });
  485. proxy.post("/dictTenantData/page", { ...query, dictCode: "funds_payment_method" }).then((res) => {
  486. if (res.data.rows && res.data.rows.length > 0) {
  487. formReceiptPaymentConfig[0].data = res.data.rows.map((item) => {
  488. return {
  489. label: item.dictValue,
  490. value: item.dictKey,
  491. };
  492. });
  493. }
  494. });
  495. proxy.post("/accountManagement/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
  496. if (res.data.rows && res.data.rows.length > 0) {
  497. formReceiptPaymentConfig[1].data = res.data.rows.map((item) => {
  498. return {
  499. label: item.alias,
  500. value: item.id,
  501. };
  502. });
  503. }
  504. });
  505. };
  506. getDict();
  507. const handleChangeAmount = () => {
  508. let sum = 0;
  509. for (let i = 0; i < formData.data.accountRequestFundsDetailList.length; i++) {
  510. const e = formData.data.accountRequestFundsDetailList[i];
  511. if (e.amount) {
  512. sum = Number(parseFloat(Number(sum) + Number(e.amount)).toFixed(2));
  513. }
  514. }
  515. formData.data.total = sum;
  516. };
  517. const handleSubmit = async () => {
  518. return formData.data;
  519. };
  520. watch(
  521. props.queryData,
  522. () => {
  523. if (props.queryData && [10, 20, 30].includes(route.query.processType)) {
  524. for (const key in props.queryData) {
  525. formData.data[key] = props.queryData[key];
  526. }
  527. }
  528. },
  529. {
  530. deep: true,
  531. }
  532. );
  533. defineExpose({
  534. handleSubmit,
  535. });
  536. onMounted(() => {});
  537. </script>
  538. <style lang="scss" scoped></style>