EhsdContractChange.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. <template>
  2. <div class="form">
  3. <van-tabs v-model:active="active">
  4. <van-tab :title="proxy.t('contract.transactionInformation')" />
  5. <van-tab title="付款信息" />
  6. <van-tab :title="proxy.t('contract.commodityInformation')" />
  7. <van-tab :title="proxy.t('contract.otherCharges')" />
  8. <van-tab :title="proxy.t('contract.shipmentPlan')" />
  9. <div class="common-process-card" v-show="active == 0">
  10. <div class="common-title">
  11. {{ proxy.t("contract.transactionInformation") }}
  12. </div>
  13. <testForm
  14. v-model="formData.data"
  15. :formOption="formOption"
  16. :formConfig="formConfig"
  17. :rules="rules"
  18. ref="formDom1"
  19. >
  20. </testForm>
  21. </div>
  22. <div class="common-process-card" v-show="active == 1">
  23. <div class="common-title">付款信息</div>
  24. <testForm
  25. v-model="formData.data"
  26. :formOption="formOption"
  27. :formConfig="formConfigOne"
  28. :rules="rules"
  29. ref="formDom2"
  30. >
  31. </testForm>
  32. </div>
  33. <div class="common-process-card" v-show="active == 2">
  34. <div class="common-title">商品信息</div>
  35. <testForm
  36. v-model="formData.data"
  37. :formOption="formGoodsOption"
  38. :formConfig="formEmptyConfig"
  39. :rules="rules"
  40. ref="formDom3"
  41. >
  42. </testForm>
  43. </div>
  44. <div class="common-process-card" v-show="active == 3">
  45. <div class="common-title">其他收费</div>
  46. <testForm
  47. v-model="formData.data"
  48. :formOption="formProjectOption"
  49. :formConfig="formEmptyConfig"
  50. :rules="rules"
  51. ref="formDom4"
  52. >
  53. </testForm>
  54. <testForm
  55. v-model="formData.data"
  56. :formOption="formOption"
  57. :formConfig="formAmountProjectConfig"
  58. :rules="rules"
  59. ref="formDom5"
  60. >
  61. </testForm>
  62. </div>
  63. <div class="common-process-card" v-show="active == 4">
  64. <div class="common-title">出货计划</div>
  65. <testForm
  66. v-model="formData.data"
  67. :formOption="formShipmentOption"
  68. :formConfig="formEmptyConfig"
  69. :rules="rulesTwo"
  70. ref="formDom6"
  71. >
  72. </testForm>
  73. </div>
  74. </van-tabs>
  75. </div>
  76. </template>
  77. <script setup>
  78. import {
  79. ref,
  80. getCurrentInstance,
  81. onMounted,
  82. defineProps,
  83. defineExpose,
  84. watch,
  85. reactive,
  86. toRefs,
  87. } from "vue";
  88. import { useRoute } from "vue-router";
  89. import testForm from "@/components/testForm/index.vue";
  90. import { getUserInfo } from "@/utils/auth";
  91. import { showFailToast } from "vant";
  92. // 接收父组件的传值
  93. const props = defineProps({
  94. queryData: Object,
  95. });
  96. const refProps = toRefs(props);
  97. const proxy = getCurrentInstance().proxy;
  98. const route = useRoute();
  99. const active = ref(0);
  100. const tabsChange = () => {
  101. active.value++;
  102. };
  103. const formData = reactive({
  104. data: {
  105. contractProductList: [],
  106. contractProjectList: [],
  107. contractShipmentList: [],
  108. },
  109. });
  110. const formDom1 = ref(null);
  111. const formDom2 = ref(null);
  112. const formDom3 = ref(null);
  113. const formDom4 = ref(null);
  114. const formDom5 = ref(null);
  115. const formDom6 = ref(null);
  116. const formOption = reactive({
  117. readonly: false,
  118. disabled: false,
  119. labelAlign: "top",
  120. scroll: true,
  121. labelWidth: "62pk",
  122. hiddenSubmitBtn: true,
  123. });
  124. const formConfig = reactive([
  125. {
  126. type: "picker",
  127. label: proxy.t("contract.contractTemplateId"),
  128. prop: "contractTemplateId",
  129. itemType: "onePicker",
  130. showPicker: false,
  131. fieldNames: {
  132. text: "label",
  133. value: "value",
  134. },
  135. data: [],
  136. changeFn: (val, data) => {},
  137. },
  138. {
  139. type: "title",
  140. title: proxy.t("contract.sellerInformation"),
  141. },
  142. {
  143. type: "picker",
  144. label: proxy.t("contract.sellCorporationId"),
  145. prop: "sellCorporationId",
  146. itemType: "onePicker",
  147. showPicker: false,
  148. fieldNames: {
  149. text: "label",
  150. value: "value",
  151. },
  152. data: [],
  153. readonly: true,
  154. },
  155. {
  156. type: "input",
  157. label: proxy.t("contract.cityText"),
  158. prop: "sellCity",
  159. itemType: "text",
  160. readonly: true,
  161. },
  162. {
  163. type: "input",
  164. label: proxy.t("contract.address"),
  165. prop: "sellAddress",
  166. itemType: "textarea",
  167. },
  168. {
  169. type: "input",
  170. label: proxy.t("contract.contactName"),
  171. prop: "sellContactName",
  172. itemType: "text",
  173. },
  174. {
  175. type: "input",
  176. label: proxy.t("contract.contactNumber"),
  177. prop: "sellContactNumber",
  178. itemType: "text",
  179. },
  180. {
  181. type: "title",
  182. title: proxy.t("contract.buyerInformation"),
  183. },
  184. {
  185. type: "picker",
  186. label: proxy.t("contract.buyCorporationId"),
  187. prop: "buyCorporationId",
  188. itemType: "onePicker",
  189. showPicker: false,
  190. fieldNames: {
  191. text: "label",
  192. value: "value",
  193. },
  194. data: [],
  195. changeFn: (val, data) => {},
  196. },
  197. {
  198. type: "cascader",
  199. label: proxy.t("contract.cityText"),
  200. prop: "countryId",
  201. itemType: "city",
  202. showPicker: false,
  203. },
  204. {
  205. type: "input",
  206. label: proxy.t("contract.address"),
  207. prop: "buyAddress",
  208. itemType: "textarea",
  209. },
  210. {
  211. type: "input",
  212. label: proxy.t("contract.postalCode"),
  213. prop: "buyPostalCode",
  214. itemType: "text",
  215. },
  216. {
  217. type: "input",
  218. label: proxy.t("contract.contactName"),
  219. prop: "buyContactName",
  220. itemType: "text",
  221. },
  222. {
  223. type: "input",
  224. label: proxy.t("contract.contactNumber"),
  225. prop: "buyContactNumber",
  226. itemType: "text",
  227. },
  228. ]);
  229. const formConfigOne = reactive([
  230. {
  231. type: "picker",
  232. label: "币种",
  233. prop: "currency",
  234. itemType: "onePicker",
  235. showPicker: false,
  236. fieldNames: {
  237. text: "label",
  238. value: "value",
  239. },
  240. data: [],
  241. readonly: true,
  242. },
  243. {
  244. type: "input",
  245. label: "汇率",
  246. prop: "rate",
  247. itemType: "number",
  248. readonly: true,
  249. },
  250. {
  251. type: "picker",
  252. label: "付款方式",
  253. prop: "paymentMethod",
  254. itemType: "onePicker",
  255. showPicker: false,
  256. fieldNames: {
  257. text: "label",
  258. value: "value",
  259. },
  260. data: [],
  261. readonly: true,
  262. },
  263. {
  264. type: "input",
  265. label: "预付比例",
  266. prop: "advanceRatio",
  267. itemType: "number",
  268. readonly: true,
  269. },
  270. {
  271. type: "input",
  272. label: "付款条件",
  273. prop: "remark",
  274. itemType: "textarea",
  275. },
  276. {
  277. type: "picker",
  278. label: "收款账号",
  279. prop: "shroffAccountId",
  280. itemType: "onePicker",
  281. showPicker: false,
  282. fieldNames: {
  283. text: "label",
  284. value: "value",
  285. },
  286. data: [],
  287. readonly: true,
  288. },
  289. {
  290. type: "input",
  291. label: "Beneficiary Name",
  292. prop: "beneficiaryName",
  293. itemType: "text",
  294. },
  295. {
  296. type: "input",
  297. label: "Beneficiary Account Number",
  298. prop: "beneficiaryAccountNumber",
  299. itemType: "text",
  300. },
  301. {
  302. type: "input",
  303. label: "Beneficiary Bank",
  304. prop: "beneficiaryBank",
  305. itemType: "text",
  306. },
  307. {
  308. type: "input",
  309. label: "Swift Code",
  310. prop: "swiftCode",
  311. itemType: "text",
  312. },
  313. {
  314. type: "input",
  315. label: "Beneficiary Bank Address",
  316. prop: "beneficiaryBankAddress",
  317. itemType: "text",
  318. },
  319. {
  320. type: "input",
  321. label: "Beneficiary Address",
  322. prop: "beneficiaryAddress",
  323. itemType: "text",
  324. },
  325. {
  326. type: "title",
  327. title: "交付信息",
  328. },
  329. {
  330. type: "input",
  331. label: "报价有效期 (天)",
  332. prop: "effective",
  333. itemType: "number",
  334. readonly: true,
  335. },
  336. {
  337. type: "picker",
  338. label: "交货期限",
  339. prop: "deliveryTime",
  340. itemType: "datePicker",
  341. showPicker: false,
  342. split: "-",
  343. columnsType: ["year", "month", "day"],
  344. },
  345. {
  346. type: "picker",
  347. label: "运输方式",
  348. prop: "transportMethod",
  349. itemType: "onePicker",
  350. showPicker: false,
  351. fieldNames: {
  352. text: "label",
  353. value: "value",
  354. },
  355. data: [],
  356. readonly: true,
  357. },
  358. {
  359. type: "input",
  360. label: "运输说明",
  361. prop: "transportRemark",
  362. itemType: "text",
  363. },
  364. ]);
  365. const formGoodsOption = reactive({
  366. readonly: false,
  367. disabled: false,
  368. labelAlign: "top",
  369. scroll: true,
  370. labelWidth: "62pk",
  371. hiddenSubmitBtn: true,
  372. btnConfig: {
  373. isNeed: true,
  374. prop: "contractProductList",
  375. plain: true,
  376. listTitle: "商品信息",
  377. listConfig: [
  378. {
  379. type: "input",
  380. label: "商品中文名",
  381. prop: "productCnName",
  382. itemType: "text",
  383. },
  384. {
  385. type: "input",
  386. label: "商品英文名",
  387. prop: "productName",
  388. itemType: "text",
  389. },
  390. {
  391. type: "input",
  392. label: "尺寸 cm*cm*cm",
  393. prop: "productModel",
  394. itemType: "text",
  395. },
  396. {
  397. type: "input",
  398. label: "包装方式",
  399. prop: "packMethod",
  400. itemType: "text",
  401. },
  402. {
  403. type: "input",
  404. label: "数量",
  405. prop: "quantity",
  406. itemType: "number",
  407. // changeFn: () => {
  408. // calculatedAmount();
  409. // },
  410. },
  411. {
  412. type: "input",
  413. label: "单价",
  414. prop: "price",
  415. itemType: "number",
  416. // changeFn: () => {
  417. // calculatedAmount();
  418. // },
  419. },
  420. {
  421. type: "picker",
  422. label: "贸易方式",
  423. prop: "tradeMethods",
  424. itemType: "onePicker",
  425. showPicker: false,
  426. fieldNames: {
  427. text: "label",
  428. value: "value",
  429. },
  430. data: [],
  431. readonly: true,
  432. },
  433. {
  434. type: "input",
  435. label: "金额",
  436. prop: "amount",
  437. itemType: "number",
  438. // changeFn: () => {
  439. // calculatedAmount();
  440. // },
  441. },
  442. ],
  443. clickFn: () => {
  444. if (
  445. formData.data.contractProductList &&
  446. formData.data.contractProductList.length > 0
  447. ) {
  448. formData.data.contractProductList.push({
  449. productId: null,
  450. productName: null,
  451. productModel: null,
  452. quantity: null,
  453. price: null,
  454. amount: null,
  455. remark: null,
  456. });
  457. formData.data.contractShipmentList.push({
  458. productId: null,
  459. productName: null,
  460. shipmentTime: null,
  461. quantity: null,
  462. remark: null,
  463. });
  464. } else {
  465. formData.data.contractProductList = [
  466. {
  467. productId: null,
  468. productName: null,
  469. productModel: null,
  470. quantity: null,
  471. price: null,
  472. amount: null,
  473. remark: null,
  474. },
  475. ];
  476. formData.data.contractShipmentList = [
  477. {
  478. productId: null,
  479. productName: null,
  480. shipmentTime: null,
  481. quantity: null,
  482. remark: null,
  483. },
  484. ];
  485. }
  486. },
  487. deleteFn: (index) => {
  488. formData.data.contractProductList.splice(index, 1);
  489. formData.data.contractShipmentList.splice(index, 1);
  490. handleChangeAmount();
  491. },
  492. },
  493. });
  494. const formEmptyConfig = reactive([]);
  495. const formAmountProjectConfig = reactive([
  496. {
  497. type: "title",
  498. title: "合同总金额",
  499. },
  500. {
  501. type: "input",
  502. label: "合同总金额",
  503. prop: "amount",
  504. itemType: "text",
  505. readonly: true,
  506. },
  507. ]);
  508. const formProjectOption = reactive({
  509. readonly: false,
  510. disabled: false,
  511. labelAlign: "top",
  512. scroll: true,
  513. labelWidth: "62pk",
  514. hiddenSubmitBtn: true,
  515. btnConfig: {
  516. isNeed: true,
  517. prop: "contractProjectList",
  518. plain: true,
  519. listTitle: "收费项目",
  520. listConfig: [
  521. {
  522. type: "input",
  523. label: "收费项目",
  524. prop: "payName",
  525. itemType: "text",
  526. },
  527. {
  528. type: "input",
  529. label: "金额",
  530. prop: "amount",
  531. itemType: "number",
  532. changeFn: () => {
  533. handleChangeAmount();
  534. },
  535. },
  536. {
  537. type: "input",
  538. label: "备注",
  539. prop: "remark",
  540. itemType: "textarea",
  541. },
  542. ],
  543. clickFn: () => {
  544. if (
  545. formData.data.contractProjectList &&
  546. formData.data.contractProjectList.length > 0
  547. ) {
  548. formData.data.contractProjectList.push({
  549. payName: null,
  550. amount: null,
  551. remark: null,
  552. });
  553. } else {
  554. formData.data.contractProjectList = [
  555. {
  556. payName: null,
  557. amount: null,
  558. remark: null,
  559. },
  560. ];
  561. }
  562. },
  563. deleteFn: (index) => {
  564. formData.data.contractProjectList.splice(index, 1);
  565. handleChangeAmount();
  566. },
  567. },
  568. });
  569. const formShipmentOption = reactive({
  570. readonly: false,
  571. disabled: false,
  572. labelAlign: "top",
  573. scroll: true,
  574. labelWidth: "62pk",
  575. hiddenSubmitBtn: true,
  576. btnConfig: {
  577. isNeed: false,
  578. prop: "contractShipmentList",
  579. plain: true,
  580. listTitle: "商品",
  581. listConfig: [
  582. {
  583. type: "picker",
  584. label: "出货日期",
  585. prop: "shipmentTime",
  586. itemType: "datePicker",
  587. showPicker: false,
  588. split: "-",
  589. columnsType: ["year", "month", "day"],
  590. },
  591. {
  592. type: "input",
  593. label: "商品编码",
  594. prop: "productCode",
  595. itemType: "text",
  596. },
  597. {
  598. type: "input",
  599. label: "商品名称",
  600. prop: "productName",
  601. itemType: "text",
  602. },
  603. {
  604. type: "input",
  605. label: "出货数量",
  606. prop: "quantity",
  607. itemType: "number",
  608. },
  609. ],
  610. },
  611. });
  612. const rules = {
  613. contractType: [
  614. { required: true, message: proxy.t("contract.contractTypeMsg") },
  615. ],
  616. contractTemplateId: [
  617. { required: true, message: proxy.t("contract.contractTemplateIdMsg") },
  618. ],
  619. sellCorporationId: [
  620. { required: true, message: proxy.t("contract.sellCorporationIdMsg") },
  621. ],
  622. buyCorporationId: [
  623. { required: true, message: proxy.t("contract.buyCorporationIdMsg") },
  624. ],
  625. sellCity: [{ required: true, message: proxy.t("contract.cityMsg") }],
  626. countryCity: [{ required: true, message: proxy.t("contract.cityMsg") }],
  627. sellAddress: [{ required: true, message: proxy.t("contract.addressMsg") }],
  628. buyAddress: [{ required: true, message: proxy.t("contract.addressMsg") }],
  629. sellContactName: [
  630. { required: true, message: proxy.t("contract.contactNameMsg") },
  631. ],
  632. sellContactNumber: [
  633. { required: true, message: proxy.t("contract.contactNumberMsg") },
  634. ],
  635. // buyPostalCode: [{ required: true, message: proxy.t("contract.postalCodeMsg") }],
  636. buyContactName: [
  637. { required: true, message: proxy.t("contract.contactNameMsg") },
  638. ],
  639. buyContactNumber: [
  640. { required: true, message: proxy.t("contract.contactNumberMsg") },
  641. ],
  642. productId: [{ required: true, message: proxy.t("contract.productIdMsg") }],
  643. productName: [
  644. { required: true, message: proxy.t("contract.productNameMsg") },
  645. ],
  646. productModel: [
  647. { required: true, message: proxy.t("contract.productModelMsg") },
  648. ],
  649. quantity: [{ required: true, message: proxy.t("contract.quantityMsg") }],
  650. price: [{ required: true, message: proxy.t("contract.priceMsg") }],
  651. payName: [{ required: true, message: proxy.t("contract.chargeItemMsg") }],
  652. amount: [{ required: true, message: proxy.t("contract.amountMsg") }],
  653. };
  654. const rulesTwo = {
  655. currency: [{ required: true, message: proxy.t("contract.currencyMsg") }],
  656. paymentMethod: [
  657. { required: true, message: proxy.t("contract.paymentMethodMsg") },
  658. ],
  659. advanceRatio: [
  660. { required: true, message: proxy.t("contract.advanceRatioMsg") },
  661. ],
  662. shroffAccountId: [
  663. { required: true, message: proxy.t("contract.shroffAccountIdMsg") },
  664. ],
  665. tradeMethods: [
  666. { required: true, message: proxy.t("contract.tradeMethodsMsg") },
  667. ],
  668. transportMethod: [
  669. { required: true, message: proxy.t("contract.transportMethodMsg") },
  670. ],
  671. transportRemark: [
  672. { required: true, message: proxy.t("contract.transportRemarkMsg") },
  673. ],
  674. remark: [{ required: true, message: proxy.t("contract.remarksMsg") }],
  675. };
  676. const getDict = () => {
  677. let query = {
  678. pageNum: 1,
  679. pageSize: 999,
  680. tenantId: getUserInfo().tenantId,
  681. };
  682. proxy
  683. .post("/contractTemplate/page", { pageNum: 1, pageSize: 999 })
  684. .then((res) => {
  685. formConfig[0].data = res.data.rows.map((item) => {
  686. return {
  687. ...item,
  688. label: item.templateName,
  689. value: item.id,
  690. };
  691. });
  692. });
  693. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  694. formConfig[2].data = res.data.rows.map((item) => {
  695. return {
  696. ...item,
  697. label: item.name,
  698. value: item.id,
  699. };
  700. });
  701. });
  702. // 产品
  703. proxy
  704. .post("/productInfo/page", { pageNum: 1, pageSize: 9999, definition: "1" })
  705. .then((res) => {
  706. if (res.data.rows && res.data.rows.length > 0) {
  707. formGoodsOption.btnConfig.listConfig[0].data = res.data.rows.map(
  708. (item) => {
  709. return {
  710. ...item,
  711. label: item.name,
  712. value: item.id,
  713. };
  714. }
  715. );
  716. }
  717. });
  718. // 币种
  719. proxy
  720. .post("/dictTenantData/page", { ...query, dictCode: "account_currency" })
  721. .then((res) => {
  722. if (res.data.rows && res.data.rows.length > 0) {
  723. formConfigOne[0].data = res.data.rows.map((item) => {
  724. return {
  725. label: item.dictValue,
  726. value: item.dictKey,
  727. };
  728. });
  729. }
  730. });
  731. // 付款方式
  732. proxy
  733. .post("/dictTenantData/page", {
  734. ...query,
  735. dictCode: "funds_payment_method",
  736. })
  737. .then((res) => {
  738. if (res.data.rows && res.data.rows.length > 0) {
  739. formConfigOne[2].data = res.data.rows.map((item) => {
  740. return {
  741. label: item.dictValue,
  742. value: item.dictKey,
  743. };
  744. });
  745. }
  746. });
  747. // 账户
  748. proxy
  749. .post("/accountManagement/page", { pageNum: 1, pageSize: 999 })
  750. .then((res) => {
  751. if (res.data.rows && res.data.rows.length > 0) {
  752. formConfigOne[5].data = res.data.rows.map((item) => {
  753. return {
  754. ...item,
  755. label: item.alias,
  756. value: item.id,
  757. };
  758. });
  759. }
  760. });
  761. // 贸易方式
  762. proxy
  763. .post("/dictTenantData/page", { ...query, dictCode: "trade_mode" })
  764. .then((res) => {
  765. if (res.data.rows && res.data.rows.length > 0) {
  766. formGoodsOption.btnConfig.listConfig[6].data = res.data.rows.map(
  767. (item) => {
  768. return {
  769. label: item.dictValue,
  770. value: item.dictKey,
  771. };
  772. }
  773. );
  774. }
  775. });
  776. // 运输方式
  777. proxy
  778. .post("/dictTenantData/page", { ...query, dictCode: "shipping_method" })
  779. .then((res) => {
  780. if (res.data.rows && res.data.rows.length > 0) {
  781. formConfigOne[15].data = res.data.rows.map((item) => {
  782. return {
  783. label: item.dictValue,
  784. value: item.dictKey,
  785. };
  786. });
  787. }
  788. });
  789. // if (["10", "20"].includes(route.query.processType)) {
  790. // proxy
  791. // .post("/customer/selPage", { pageNum: 1, pageSize: 50 })
  792. // .then((res) => {
  793. // formConfig[8].data = res.data.rows.map((x) => ({
  794. // ...x,
  795. // label: x.name,
  796. // value: x.id,
  797. // }));
  798. // });
  799. // }
  800. };
  801. getDict();
  802. const calculatedAmount = () => {
  803. if (
  804. formData.data.contractProductList &&
  805. formData.data.contractProductList.length > 0
  806. ) {
  807. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  808. let money = 0;
  809. if (
  810. formData.data.contractProductList[i].quantity &&
  811. formData.data.contractProductList[i].price
  812. ) {
  813. money = Number(
  814. Math.round(
  815. Number(formData.data.contractProductList[i].quantity) *
  816. Number(formData.data.contractProductList[i].price) *
  817. 10000
  818. ) / 10000
  819. );
  820. }
  821. formData.data.contractProductList[i].amount = money;
  822. }
  823. }
  824. handleChangeAmount();
  825. };
  826. const handleChangeAmount = () => {
  827. let money = 0;
  828. let amountProduct = 0;
  829. let amountProject = 0;
  830. if (
  831. formData.data.contractProductList &&
  832. formData.data.contractProductList.length > 0
  833. ) {
  834. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  835. if (formData.data.contractProductList[i].amount) {
  836. money = Number(
  837. Math.round(
  838. (Number(money) +
  839. Number(formData.data.contractProductList[i].amount)) *
  840. 10000
  841. ) / 10000
  842. );
  843. amountProduct = Number(
  844. Math.round(
  845. (Number(amountProduct) +
  846. Number(formData.data.contractProductList[i].amount)) *
  847. 10000
  848. ) / 10000
  849. );
  850. }
  851. }
  852. }
  853. if (
  854. formData.data.contractProjectList &&
  855. formData.data.contractProjectList.length > 0
  856. ) {
  857. for (let i = 0; i < formData.data.contractProjectList.length; i++) {
  858. if (formData.data.contractProjectList[i].amount) {
  859. money = Number(
  860. Math.round(
  861. (Number(money) +
  862. Number(formData.data.contractProjectList[i].amount)) *
  863. 10000
  864. ) / 10000
  865. );
  866. amountProject = Number(
  867. Math.round(
  868. (Number(amountProject) +
  869. Number(formData.data.contractProjectList[i].amount)) *
  870. 10000
  871. ) / 10000
  872. );
  873. }
  874. }
  875. }
  876. formData.data.amount = money;
  877. formData.data.amountProduct = amountProduct;
  878. formData.data.amountProject = amountProject;
  879. };
  880. const handleSubmit = async () => {
  881. const flag = await formDom1.value.validateForm().then((status) => {
  882. if (status) {
  883. active.value = 0;
  884. return false;
  885. } else {
  886. if (
  887. !(
  888. formData.data.contractProductList &&
  889. formData.data.contractProductList.length > 0
  890. )
  891. ) {
  892. active.value = 1;
  893. showFailToast(proxy.t("contract.pleaseAddProduct"));
  894. return false;
  895. }
  896. return formDom2.value.validateForm().then((status1) => {
  897. if (status1) {
  898. active.value = 1;
  899. return false;
  900. } else {
  901. return formDom4.value.validateForm().then((status2) => {
  902. if (status2) {
  903. active.value = 2;
  904. return false;
  905. } else {
  906. return formDom6.value.validateForm().then((status3) => {
  907. if (status3) {
  908. active.value = 3;
  909. return false;
  910. } else {
  911. return true;
  912. }
  913. });
  914. }
  915. });
  916. }
  917. });
  918. }
  919. });
  920. if (flag) {
  921. return formData.data;
  922. }
  923. };
  924. let status = ref(true);
  925. onMounted(() => {
  926. if (route.query && route.query.businessId) {
  927. let businessId = route.query.businessId;
  928. proxy.post("/contract/detail", { id: businessId }).then((res) => {
  929. console.log(res, "asda");
  930. res.data.countryId = res.data.buyCountryId;
  931. res.data.provinceId = res.data.buyProvinceId;
  932. res.data.cityId = res.data.buyCityId;
  933. for (const key in res.data) {
  934. formData.data[key] = res.data[key];
  935. }
  936. formData.data.sellCity =
  937. formData.data.sellCountryName +
  938. " " +
  939. formData.data.sellProvinceName +
  940. " " +
  941. formData.data.sellCityName;
  942. formData.data.countryIdName =
  943. formData.data.buyCountryName +
  944. " " +
  945. formData.data.buyProvinceName +
  946. " " +
  947. formData.data.buyCityName;
  948. if (formData.data.buyCorporationName) {
  949. proxy
  950. .post("/customer/selPage", {
  951. keyword: formData.data.buyCorporationName,
  952. })
  953. .then((res) => {
  954. formConfig[8].data = res.data.rows.map((x) => ({
  955. ...x,
  956. label: x.name,
  957. value: x.id,
  958. }));
  959. });
  960. }
  961. if (
  962. formData.data.contractProductList &&
  963. formData.data.contractProductList.length > 0
  964. ) {
  965. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  966. const e = formData.data.contractProductList[i];
  967. if (e.ehsdJson) {
  968. let obj = JSON.parse(e.ehsdJson);
  969. console.log(obj, "asda");
  970. e.packMethod = obj.packMethod;
  971. e.tradeMethods = obj.tradeMethods;
  972. }
  973. }
  974. }
  975. if (["10", "20"].includes(route.query.processType)) {
  976. formOption.readonly = true;
  977. formGoodsOption.readonly = true;
  978. formGoodsOption.btnConfig.isNeed = false;
  979. formProjectOption.readonly = true;
  980. formProjectOption.btnConfig.isNeed = false;
  981. formShipmentOption.readonly = true;
  982. }
  983. formDom1.value.formDataShowLabelOne();
  984. formDom2.value.formDataShowLabelOne();
  985. });
  986. }
  987. });
  988. watch(
  989. refProps.queryData,
  990. () => {
  991. console.log(refProps.queryData, "aa");
  992. return;
  993. if (
  994. refProps.queryData.value &&
  995. ["10", "20", "30"].includes(route.query.processType)
  996. ) {
  997. for (const key in refProps.queryData.value) {
  998. formData.data[key] = refProps.queryData.value[key];
  999. }
  1000. formDom1.value.formDataShowLabelOne();
  1001. formDom2.value.formDataListShowLabelOne();
  1002. formDom6.value.formDataShowLabelOne();
  1003. if (!formData.data.sellCity) {
  1004. let sellCity = "";
  1005. if (formData.data.sellCountryName) {
  1006. sellCity = formData.data.sellCountryName;
  1007. }
  1008. if (formData.data.sellProvinceName) {
  1009. sellCity = sellCity + " " + formData.data.sellProvinceName;
  1010. }
  1011. if (formData.data.sellCityName) {
  1012. sellCity = sellCity + " " + formData.data.sellCityName;
  1013. }
  1014. formData.data.sellCity = sellCity;
  1015. }
  1016. if (["10", "20"].includes(route.query.processType)) {
  1017. formOption.readonly = true;
  1018. formGoodsOption.readonly = true;
  1019. formGoodsOption.btnConfig.isNeed = false;
  1020. formProjectOption.readonly = true;
  1021. formProjectOption.btnConfig.isNeed = false;
  1022. formShipmentOption.readonly = true;
  1023. }
  1024. handleChangeAmount();
  1025. if (status.value) {
  1026. if (!formData.data.countryCityName) {
  1027. if (formData.data.countryId) {
  1028. let countryCityName = "";
  1029. formData.data.countryCity = formData.data.countryId;
  1030. proxy.post("/customizeArea/list", { parentId: "0" }).then((res) => {
  1031. let list = res.data.filter(
  1032. (item) => item.id == formData.data.countryId
  1033. );
  1034. if (list && list.length > 0) {
  1035. countryCityName = list[0].name;
  1036. formData.data.countryCityName = countryCityName;
  1037. }
  1038. if (formData.data.provinceId) {
  1039. formData.data.countryCity = formData.data.provinceId;
  1040. proxy
  1041. .post("/customizeArea/list", {
  1042. parentId: formData.data.countryId,
  1043. })
  1044. .then((res) => {
  1045. let list = res.data.filter(
  1046. (item) => item.id == formData.data.provinceId
  1047. );
  1048. if (list && list.length > 0) {
  1049. countryCityName = countryCityName + " " + list[0].name;
  1050. formData.data.countryCityName = countryCityName;
  1051. }
  1052. if (formData.data.cityId) {
  1053. formData.data.countryCity = formData.data.cityId;
  1054. proxy
  1055. .post("/customizeArea/list", {
  1056. parentId: formData.data.provinceId,
  1057. })
  1058. .then((res) => {
  1059. let list = res.data.filter(
  1060. (item) => item.id == formData.data.cityId
  1061. );
  1062. if (list && list.length > 0) {
  1063. countryCityName =
  1064. countryCityName + " " + list[0].name;
  1065. formData.data.countryCityName = countryCityName;
  1066. }
  1067. });
  1068. }
  1069. });
  1070. }
  1071. });
  1072. }
  1073. }
  1074. status.value = false;
  1075. }
  1076. }
  1077. },
  1078. {
  1079. deep: true,
  1080. }
  1081. );
  1082. defineExpose({
  1083. handleSubmit,
  1084. tabsChange,
  1085. });
  1086. onMounted(() => {});
  1087. </script>
  1088. <style lang="scss" scoped></style>