Contract.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  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="proxy.t('contract.commodityInformation')" />
  6. <van-tab :title="proxy.t('contract.otherCharges')" />
  7. <van-tab :title="proxy.t('contract.deliveryInformation')" />
  8. <van-tab :title="proxy.t('contract.shipmentPlan')" />
  9. <div class="common-process-card" v-show="active == 0">
  10. <div class="common-title">{{ proxy.t("contract.transactionInformation") }}</div>
  11. <testForm v-model="formData.data" :formOption="formOption" :formConfig="formConfig" :rules="rules" ref="formDom1"> </testForm>
  12. </div>
  13. <div class="common-process-card" v-show="active == 1">
  14. <div class="common-title">{{ proxy.t("contract.commodityInformation") }}</div>
  15. <testForm v-model="formData.data" :formOption="formGoodsOption" :formConfig="formEmptyConfig" :rules="rules" ref="formDom2"> </testForm>
  16. <testForm v-model="formData.data" :formOption="formOption" :formConfig="formAmountProductConfig" :rules="rules" ref="formDom3"> </testForm>
  17. </div>
  18. <div class="common-process-card" v-show="active == 2">
  19. <div class="common-title">{{ proxy.t("contract.otherCharges") }}</div>
  20. <testForm v-model="formData.data" :formOption="formProjectOption" :formConfig="formEmptyConfig" :rules="rules" ref="formDom4"> </testForm>
  21. <testForm v-model="formData.data" :formOption="formOption" :formConfig="formAmountProjectConfig" :rules="rules" ref="formDom5"> </testForm>
  22. </div>
  23. <div class="common-process-card" v-show="active == 3">
  24. <div class="common-title">{{ proxy.t("contract.deliveryInformation") }}</div>
  25. <testForm v-model="formData.data" :formOption="formOption" :formConfig="formDeliveryConfig" :rules="rulesTwo" ref="formDom6"> </testForm>
  26. </div>
  27. <div class="common-process-card" v-show="active == 4">
  28. <div class="common-title">{{ proxy.t("contract.shipmentPlan") }}</div>
  29. <testForm v-model="formData.data" :formOption="formShipmentOption" :formConfig="formEmptyConfig" :rules="rulesTwo" ref="formDom7"> </testForm>
  30. </div>
  31. </van-tabs>
  32. </div>
  33. </template>
  34. <script setup>
  35. import { ref, getCurrentInstance, onMounted, defineProps, defineExpose, watch, reactive, toRefs } from "vue";
  36. import { useRoute } from "vue-router";
  37. import testForm from "@/components/testForm/index.vue";
  38. import { getUserInfo } from "@/utils/auth";
  39. import { showFailToast } from "vant";
  40. // 接收父组件的传值
  41. const props = defineProps({
  42. queryData: Object,
  43. });
  44. const refProps = toRefs(props);
  45. const proxy = getCurrentInstance().proxy;
  46. const route = useRoute();
  47. const active = ref(0);
  48. const tabsChange = () => {
  49. active.value ++
  50. }
  51. const formData = reactive({
  52. data: {
  53. contractType: "1",
  54. contractProductList: [],
  55. contractProjectList: [],
  56. contractShipmentList: [],
  57. },
  58. });
  59. const formDom1 = ref(null);
  60. const formDom2 = ref(null);
  61. const formDom3 = ref(null);
  62. const formDom4 = ref(null);
  63. const formDom5 = ref(null);
  64. const formDom6 = ref(null);
  65. const formDom7 = ref(null);
  66. const formOption = reactive({
  67. readonly: false,
  68. disabled: false,
  69. labelAlign: "top",
  70. scroll: true,
  71. labelWidth: "62pk",
  72. hiddenSubmitBtn: true,
  73. });
  74. const formConfig = reactive([
  75. {
  76. type: "picker",
  77. label: proxy.t("contract.contractType"),
  78. prop: "contractType",
  79. itemType: "onePicker",
  80. showPicker: false,
  81. fieldNames: {
  82. text: "label",
  83. value: "value",
  84. },
  85. data: [],
  86. },
  87. {
  88. type: "picker",
  89. label: proxy.t("contract.contractTemplateId"),
  90. prop: "contractTemplateId",
  91. itemType: "onePicker",
  92. showPicker: false,
  93. fieldNames: {
  94. text: "label",
  95. value: "value",
  96. },
  97. data: [],
  98. changeFn: (val, data) => {
  99. proxy.formChange(val, data, formData);
  100. formData.data.sellCorporationId = "";
  101. formData.data.sellCountryName = "";
  102. formData.data.sellProvinceName = "";
  103. formData.data.sellCityName = "";
  104. formData.data.sellAddress = "";
  105. formData.data.sellContactName = "";
  106. formData.data.sellContactNumber = "";
  107. if (val.selectedValues[0]) {
  108. proxy.post("/contractTemplate/detail", { id: val.selectedValues[0] }).then((res) => {
  109. formData.data.sellCorporationId = res.data.corporationId;
  110. if (res.data.corporationId) {
  111. proxy.post("/corporation/detail", { id: res.data.corporationId }).then((detailCorporation) => {
  112. let sellCity = "";
  113. if (detailCorporation.data.countryEnStr) {
  114. formData.data.sellCountryName = detailCorporation.data.countryEnStr;
  115. sellCity = detailCorporation.data.countryEnStr;
  116. }
  117. if (detailCorporation.data.provinceEnStr) {
  118. formData.data.sellProvinceName = detailCorporation.data.provinceEnStr;
  119. sellCity = sellCity + " " + detailCorporation.data.provinceEnStr;
  120. }
  121. if (detailCorporation.data.cityEnStr) {
  122. formData.data.sellCityName = detailCorporation.data.cityEnStr;
  123. sellCity = sellCity + " " + detailCorporation.data.cityEnStr;
  124. }
  125. if (detailCorporation.data.addressEn) {
  126. formData.data.sellAddress = detailCorporation.data.addressEn;
  127. }
  128. formData.data.sellCity = sellCity;
  129. formDom1.value.formDataShowLabelOne();
  130. });
  131. }
  132. formData.data.sellContactName = res.data.contactName;
  133. formData.data.sellContactNumber = res.data.contactNumber;
  134. formDom1.value.formDataShowLabelOne();
  135. });
  136. }
  137. data.showPicker = false;
  138. },
  139. },
  140. {
  141. type: "title",
  142. title: proxy.t("contract.sellerInformation"),
  143. },
  144. {
  145. type: "picker",
  146. label: proxy.t("contract.sellCorporationId"),
  147. prop: "sellCorporationId",
  148. itemType: "onePicker",
  149. showPicker: false,
  150. fieldNames: {
  151. text: "label",
  152. value: "value",
  153. },
  154. data: [],
  155. readonly: true,
  156. },
  157. {
  158. type: "input",
  159. label: proxy.t("contract.cityText"),
  160. prop: "sellCity",
  161. itemType: "text",
  162. readonly: true,
  163. },
  164. {
  165. type: "input",
  166. label: proxy.t("contract.address"),
  167. prop: "sellAddress",
  168. itemType: "textarea",
  169. },
  170. {
  171. type: "input",
  172. label: proxy.t("contract.contactName"),
  173. prop: "sellContactName",
  174. itemType: "text",
  175. },
  176. {
  177. type: "input",
  178. label: proxy.t("contract.contactNumber"),
  179. prop: "sellContactNumber",
  180. itemType: "text",
  181. },
  182. {
  183. type: "title",
  184. title: proxy.t("contract.buyerInformation"),
  185. },
  186. {
  187. type: "picker",
  188. label: proxy.t("contract.buyCorporationId"),
  189. prop: "buyCorporationId",
  190. itemType: "onePicker",
  191. showPicker: false,
  192. fieldNames: {
  193. text: "label",
  194. value: "value",
  195. },
  196. data: [],
  197. changeFn: (val, data) => {
  198. proxy.formChange(val, data, formData);
  199. formData.data.buyContactName = "";
  200. formData.data.buyContactNumber = "";
  201. if (val.selectedValues[0]) {
  202. proxy.post("/customer/detail", { id: val.selectedValues[0] }).then((res) => {
  203. if (res.data.customerUserList && res.data.customerUserList.length > 0) {
  204. formData.data.buyContactName = res.data.customerUserList[0].name;
  205. if (res.data.customerUserList[0].contactJson) {
  206. let contactJson = JSON.parse(res.data.customerUserList[0].contactJson);
  207. if (contactJson && contactJson.length > 0) {
  208. formData.data.buyContactNumber = contactJson[0].contactNo;
  209. }
  210. }
  211. }
  212. let countryCityName = "";
  213. if (res.data.countryName) {
  214. countryCityName = res.data.countryName;
  215. if (res.data.provinceName) {
  216. countryCityName = countryCityName + " " + res.data.provinceName;
  217. if (res.data.cityName) {
  218. countryCityName = countryCityName + " " + res.data.cityName;
  219. }
  220. }
  221. }
  222. formData.data.countryCityName = countryCityName;
  223. if (res.data.cityId) {
  224. formData.data.countryCity = res.data.cityId;
  225. } else if (res.data.provinceId) {
  226. formData.data.countryCity = res.data.provinceId;
  227. } else if (res.data.countryId) {
  228. formData.data.countryCity = res.data.countryId;
  229. } else {
  230. formData.data.countryCity = "";
  231. }
  232. formData.data.countryId = res.data.countryId;
  233. formData.data.provinceId = res.data.provinceId;
  234. formData.data.cityId = res.data.cityId;
  235. formData.data.buyPostalCode = res.data.zipCode;
  236. formData.data.buyAddress = res.data.address;
  237. });
  238. } else {
  239. formData.data.countryId = "";
  240. formData.data.provinceId = "";
  241. formData.data.cityId = "";
  242. formData.data.buyPostalCode = "";
  243. formData.data.buyAddress = "";
  244. }
  245. data.showPicker = false;
  246. },
  247. },
  248. {
  249. type: "cascader",
  250. label: proxy.t("contract.cityText"),
  251. prop: "countryCity",
  252. itemType: "city",
  253. showPicker: false,
  254. },
  255. {
  256. type: "input",
  257. label: proxy.t("contract.address"),
  258. prop: "buyAddress",
  259. itemType: "textarea",
  260. },
  261. {
  262. type: "input",
  263. label: proxy.t("contract.postalCode"),
  264. prop: "buyPostalCode",
  265. itemType: "text",
  266. },
  267. {
  268. type: "input",
  269. label: proxy.t("contract.contactName"),
  270. prop: "buyContactName",
  271. itemType: "text",
  272. },
  273. {
  274. type: "input",
  275. label: proxy.t("contract.contactNumber"),
  276. prop: "buyContactNumber",
  277. itemType: "text",
  278. },
  279. ]);
  280. const formGoodsOption = reactive({
  281. readonly: false,
  282. disabled: false,
  283. labelAlign: "top",
  284. scroll: true,
  285. labelWidth: "62pk",
  286. hiddenSubmitBtn: true,
  287. btnConfig: {
  288. isNeed: true,
  289. prop: "contractProductList",
  290. plain: true,
  291. listTitle: proxy.t("contract.commodityInformation"),
  292. listConfig: [
  293. {
  294. type: "picker",
  295. label: proxy.t("contract.productId"),
  296. prop: "productId",
  297. itemType: "onePicker",
  298. showPicker: false,
  299. readonly: false,
  300. fieldNames: {
  301. text: "label",
  302. value: "value",
  303. },
  304. data: [],
  305. changeFn: (val, data, index, indexTwo, propName) => {
  306. let selectList = formData.data[propName].filter((item, itemIndex) => item[data.prop] === val.selectedValues[0] && itemIndex !== index);
  307. if (selectList && selectList.length > 0) {
  308. return showFailToast(proxy.t("contract.productRepeat"));
  309. }
  310. formData.data[propName][index][data.prop] = val.selectedValues[0];
  311. formData.data.contractShipmentList[index][data.prop] = val.selectedValues[0];
  312. let list = data.data.filter((item) => item[data.fieldNames.value] == val.selectedValues[0]);
  313. if (list && list.length > 0) {
  314. formData.data[propName][index][data.prop + "Name"] = list[0][data.fieldNames.text];
  315. let name = list[0].name;
  316. if (list[0].standardJson) {
  317. let standardJson = JSON.parse(list[0].standardJson);
  318. if (standardJson && standardJson.englishName) {
  319. name = standardJson.englishName;
  320. }
  321. }
  322. formData.data[propName][index].productName = name;
  323. formData.data[propName][index].productModel = list[0].spec;
  324. formData.data.contractShipmentList[index].productName = name;
  325. } else {
  326. formData.data[propName][index][data.prop + "Name"] = "";
  327. }
  328. formData.data[propName][index].quantity = null;
  329. formData.data[propName][index].price = null;
  330. formData.data[propName][index].amount = null;
  331. formData.data[propName][index].remark = null;
  332. formData.data.contractShipmentList[index].shipmentTime = null;
  333. formData.data.contractShipmentList[index].quantity = null;
  334. formData.data.contractShipmentList[index].remark = null;
  335. data.showPicker = false;
  336. },
  337. },
  338. {
  339. type: "input",
  340. label: proxy.t("contract.productName"),
  341. prop: "productName",
  342. itemType: "text",
  343. },
  344. {
  345. type: "input",
  346. label: proxy.t("contract.productModel"),
  347. prop: "productModel",
  348. itemType: "text",
  349. },
  350. {
  351. type: "input",
  352. label: proxy.t("contract.quantity"),
  353. prop: "quantity",
  354. itemType: "number",
  355. changeFn: () => {
  356. calculatedAmount();
  357. },
  358. },
  359. {
  360. type: "input",
  361. label: proxy.t("contract.price"),
  362. prop: "price",
  363. itemType: "number",
  364. changeFn: () => {
  365. calculatedAmount();
  366. },
  367. },
  368. ],
  369. clickFn: () => {
  370. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  371. formData.data.contractProductList.push({
  372. productId: null,
  373. productName: null,
  374. productModel: null,
  375. quantity: null,
  376. price: null,
  377. amount: null,
  378. remark: null,
  379. });
  380. formData.data.contractShipmentList.push({
  381. productId: null,
  382. productName: null,
  383. shipmentTime: null,
  384. quantity: null,
  385. remark: null,
  386. });
  387. } else {
  388. formData.data.contractProductList = [
  389. {
  390. productId: null,
  391. productName: null,
  392. productModel: null,
  393. quantity: null,
  394. price: null,
  395. amount: null,
  396. remark: null,
  397. },
  398. ];
  399. formData.data.contractShipmentList = [
  400. {
  401. productId: null,
  402. productName: null,
  403. shipmentTime: null,
  404. quantity: null,
  405. remark: null,
  406. },
  407. ];
  408. }
  409. },
  410. deleteFn: (index) => {
  411. formData.data.contractProductList.splice(index, 1);
  412. formData.data.contractShipmentList.splice(index, 1);
  413. handleChangeAmount();
  414. },
  415. },
  416. });
  417. const formEmptyConfig = reactive([]);
  418. const formAmountProductConfig = reactive([
  419. {
  420. type: "input",
  421. label: proxy.t("contract.amountProduct"),
  422. prop: "amountProduct",
  423. itemType: "text",
  424. readonly: true,
  425. placeholder: proxy.t("contract.amountProductPlaceholder"),
  426. },
  427. ]);
  428. const formAmountProjectConfig = reactive([
  429. {
  430. type: "input",
  431. label: proxy.t("contract.amountProject"),
  432. prop: "amountProject",
  433. itemType: "text",
  434. readonly: true,
  435. placeholder: proxy.t("contract.amountProjectPlaceholder"),
  436. },
  437. ]);
  438. const formProjectOption = reactive({
  439. readonly: false,
  440. disabled: false,
  441. labelAlign: "top",
  442. scroll: true,
  443. labelWidth: "62pk",
  444. hiddenSubmitBtn: true,
  445. btnConfig: {
  446. isNeed: true,
  447. prop: "contractProjectList",
  448. plain: true,
  449. listTitle: proxy.t("contract.chargeItem"),
  450. listConfig: [
  451. {
  452. type: "input",
  453. label: proxy.t("contract.chargeItem"),
  454. prop: "payName",
  455. itemType: "text",
  456. },
  457. {
  458. type: "input",
  459. label: proxy.t("contract.amount"),
  460. prop: "amount",
  461. itemType: "number",
  462. changeFn: () => {
  463. handleChangeAmount();
  464. },
  465. },
  466. {
  467. type: "input",
  468. label: proxy.t("contract.remark"),
  469. prop: "remark",
  470. itemType: "textarea",
  471. },
  472. ],
  473. clickFn: () => {
  474. if (formData.data.contractProjectList && formData.data.contractProjectList.length > 0) {
  475. formData.data.contractProjectList.push({
  476. payName: null,
  477. amount: null,
  478. remark: null,
  479. });
  480. } else {
  481. formData.data.contractProjectList = [
  482. {
  483. payName: null,
  484. amount: null,
  485. remark: null,
  486. },
  487. ];
  488. }
  489. },
  490. deleteFn: (index) => {
  491. formData.data.contractProjectList.splice(index, 1);
  492. handleChangeAmount();
  493. },
  494. },
  495. });
  496. const formDeliveryConfig = reactive([
  497. {
  498. type: "title",
  499. title: proxy.t("contract.collectionInformation"),
  500. },
  501. {
  502. type: "picker",
  503. label: proxy.t("contract.currency"),
  504. prop: "currency",
  505. itemType: "onePicker",
  506. showPicker: false,
  507. fieldNames: {
  508. text: "label",
  509. value: "value",
  510. },
  511. data: [],
  512. },
  513. {
  514. type: "input",
  515. label: proxy.t("contract.amountAll"),
  516. prop: "amount",
  517. itemType: "text",
  518. readonly: true,
  519. placeholder: proxy.t("contract.amountAllPlaceholder"),
  520. },
  521. {
  522. type: "picker",
  523. label: proxy.t("contract.paymentMethod"),
  524. prop: "paymentMethod",
  525. itemType: "onePicker",
  526. showPicker: false,
  527. fieldNames: {
  528. text: "label",
  529. value: "value",
  530. },
  531. data: [],
  532. },
  533. {
  534. type: "input",
  535. label: proxy.t("contract.advanceRatio"),
  536. prop: "advanceRatio",
  537. itemType: "number",
  538. inputFn: (val) => {
  539. if (val) {
  540. if (val > 100) {
  541. formData.data.advanceRatio = 100;
  542. } else if (val < 0) {
  543. formData.data.advanceRatio = 0;
  544. }
  545. }
  546. },
  547. },
  548. {
  549. type: "picker",
  550. label: proxy.t("contract.shroffAccountId"),
  551. prop: "shroffAccountId",
  552. itemType: "onePicker",
  553. showPicker: false,
  554. fieldNames: {
  555. text: "label",
  556. value: "value",
  557. },
  558. data: [],
  559. },
  560. {
  561. type: "title",
  562. title: proxy.t("contract.deliveryInformation"),
  563. },
  564. {
  565. type: "picker",
  566. label: proxy.t("contract.tradeMethods"),
  567. prop: "tradeMethods",
  568. itemType: "onePicker",
  569. showPicker: false,
  570. fieldNames: {
  571. text: "label",
  572. value: "value",
  573. },
  574. data: [],
  575. },
  576. {
  577. type: "picker",
  578. label: proxy.t("contract.transportMethod"),
  579. prop: "transportMethod",
  580. itemType: "onePicker",
  581. showPicker: false,
  582. fieldNames: {
  583. text: "label",
  584. value: "value",
  585. },
  586. data: [],
  587. },
  588. {
  589. type: "input",
  590. label: proxy.t("contract.transportRemark"),
  591. prop: "transportRemark",
  592. itemType: "text",
  593. },
  594. {
  595. type: "input",
  596. label: proxy.t("contract.remarks"),
  597. prop: "remark",
  598. itemType: "textarea",
  599. },
  600. {
  601. type: "input",
  602. label: proxy.t("contract.warranty"),
  603. prop: "warranty",
  604. itemType: "digit",
  605. },
  606. {
  607. type: "input",
  608. label: proxy.t("contract.deliveryTime"),
  609. prop: "deliveryTime",
  610. itemType: "digit",
  611. },
  612. ]);
  613. const formShipmentOption = reactive({
  614. readonly: false,
  615. disabled: false,
  616. labelAlign: "top",
  617. scroll: true,
  618. labelWidth: "62pk",
  619. hiddenSubmitBtn: true,
  620. btnConfig: {
  621. isNeed: false,
  622. prop: "contractShipmentList",
  623. plain: true,
  624. listTitle: proxy.t("contract.commodity"),
  625. listConfig: [
  626. {
  627. type: "input",
  628. label: proxy.t("contract.productName"),
  629. prop: "productName",
  630. itemType: "text",
  631. readonly: true,
  632. placeholder: proxy.t("contract.productNamePlaceholder"),
  633. },
  634. {
  635. type: "picker",
  636. label: proxy.t("contract.shipmentTime"),
  637. prop: "shipmentTime",
  638. itemType: "datePicker",
  639. showPicker: false,
  640. split: "-",
  641. columnsType: ["year", "month", "day"],
  642. },
  643. {
  644. type: "input",
  645. label: proxy.t("contract.quantityShipment"),
  646. prop: "quantity",
  647. itemType: "number",
  648. },
  649. ],
  650. },
  651. });
  652. const rules = {
  653. contractType: [{ required: true, message: proxy.t("contract.contractTypeMsg") }],
  654. contractTemplateId: [{ required: true, message: proxy.t("contract.contractTemplateIdMsg") }],
  655. sellCorporationId: [{ required: true, message: proxy.t("contract.sellCorporationIdMsg") }],
  656. buyCorporationId: [{ required: true, message: proxy.t("contract.buyCorporationIdMsg") }],
  657. sellCity: [{ required: true, message: proxy.t("contract.cityMsg") }],
  658. countryCity: [{ required: true, message: proxy.t("contract.cityMsg") }],
  659. sellAddress: [{ required: true, message: proxy.t("contract.addressMsg") }],
  660. buyAddress: [{ required: true, message: proxy.t("contract.addressMsg") }],
  661. sellContactName: [{ required: true, message: proxy.t("contract.contactNameMsg") }],
  662. sellContactNumber: [{ required: true, message: proxy.t("contract.contactNumberMsg") }],
  663. // buyPostalCode: [{ required: true, message: proxy.t("contract.postalCodeMsg") }],
  664. buyContactName: [{ required: true, message: proxy.t("contract.contactNameMsg") }],
  665. buyContactNumber: [{ required: true, message: proxy.t("contract.contactNumberMsg") }],
  666. productId: [{ required: true, message: proxy.t("contract.productIdMsg") }],
  667. productName: [{ required: true, message: proxy.t("contract.productNameMsg") }],
  668. productModel: [{ required: true, message: proxy.t("contract.productModelMsg") }],
  669. quantity: [{ required: true, message: proxy.t("contract.quantityMsg") }],
  670. price: [{ required: true, message: proxy.t("contract.priceMsg") }],
  671. payName: [{ required: true, message: proxy.t("contract.chargeItemMsg") }],
  672. amount: [{ required: true, message: proxy.t("contract.amountMsg") }],
  673. };
  674. const rulesTwo = {
  675. currency: [{ required: true, message: proxy.t("contract.currencyMsg") }],
  676. paymentMethod: [{ required: true, message: proxy.t("contract.paymentMethodMsg") }],
  677. advanceRatio: [{ required: true, message: proxy.t("contract.advanceRatioMsg") }],
  678. shroffAccountId: [{ required: true, message: proxy.t("contract.shroffAccountIdMsg") }],
  679. tradeMethods: [{ required: true, message: proxy.t("contract.tradeMethodsMsg") }],
  680. transportMethod: [{ required: true, message: proxy.t("contract.transportMethodMsg") }],
  681. transportRemark: [{ required: true, message: proxy.t("contract.transportRemarkMsg") }],
  682. remark: [{ required: true, message: proxy.t("contract.remarksMsg") }],
  683. };
  684. const getDict = () => {
  685. let query = {
  686. pageNum: 1,
  687. pageSize: 999,
  688. tenantId: getUserInfo().tenantId,
  689. };
  690. proxy.post("/dictTenantData/page", { ...query, dictCode: "contract_type" }).then((res) => {
  691. if (res.data.rows && res.data.rows.length > 0) {
  692. formConfig[0].data = res.data.rows.map((item) => {
  693. return {
  694. label: item.dictValue,
  695. value: item.dictKey,
  696. };
  697. });
  698. }
  699. });
  700. proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  701. if (res.data.rows && res.data.rows.length > 0) {
  702. formConfig[1].data = res.data.rows.map((item) => {
  703. return {
  704. ...item,
  705. label: item.templateName,
  706. value: item.id,
  707. };
  708. });
  709. }
  710. });
  711. proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  712. if (res.data.rows && res.data.rows.length > 0) {
  713. formConfig[3].data = res.data.rows.map((item) => {
  714. return {
  715. ...item,
  716. label: item.name,
  717. value: item.id,
  718. };
  719. });
  720. }
  721. });
  722. proxy.post("/customer/privateSeaPage", { pageNum: 1, pageSize: 999 }).then((res) => {
  723. if (res.data.rows && res.data.rows.length > 0) {
  724. formConfig[9].data = res.data.rows.map((item) => {
  725. return {
  726. ...item,
  727. label: item.name,
  728. value: item.id,
  729. };
  730. });
  731. }
  732. });
  733. proxy.post("/productInfo/page", { pageNum: 1, pageSize: 9999, definition: "1" }).then((res) => {
  734. if (res.data.rows && res.data.rows.length > 0) {
  735. formGoodsOption.btnConfig.listConfig[0].data = res.data.rows.map((item) => {
  736. return {
  737. ...item,
  738. label: item.name,
  739. value: item.id,
  740. };
  741. });
  742. }
  743. });
  744. proxy.post("/dictTenantData/page", { ...query, dictCode: "account_currency" }).then((res) => {
  745. if (res.data.rows && res.data.rows.length > 0) {
  746. formDeliveryConfig[1].data = res.data.rows.map((item) => {
  747. return {
  748. label: item.dictValue,
  749. value: item.dictKey,
  750. };
  751. });
  752. }
  753. });
  754. proxy.post("/dictTenantData/page", { ...query, dictCode: "funds_payment_method" }).then((res) => {
  755. if (res.data.rows && res.data.rows.length > 0) {
  756. formDeliveryConfig[3].data = res.data.rows.map((item) => {
  757. return {
  758. label: item.dictValue,
  759. value: item.dictKey,
  760. };
  761. });
  762. }
  763. });
  764. proxy.post("/accountManagement/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  765. if (res.data.rows && res.data.rows.length > 0) {
  766. formDeliveryConfig[5].data = res.data.rows.map((item) => {
  767. return {
  768. ...item,
  769. label: item.alias,
  770. value: item.id,
  771. };
  772. });
  773. }
  774. });
  775. proxy.post("/dictTenantData/page", { ...query, dictCode: "trade_mode" }).then((res) => {
  776. if (res.data.rows && res.data.rows.length > 0) {
  777. formDeliveryConfig[7].data = res.data.rows.map((item) => {
  778. return {
  779. label: item.dictValue,
  780. value: item.dictKey,
  781. };
  782. });
  783. }
  784. });
  785. proxy.post("/dictTenantData/page", { ...query, dictCode: "shipping_method" }).then((res) => {
  786. if (res.data.rows && res.data.rows.length > 0) {
  787. formDeliveryConfig[8].data = res.data.rows.map((item) => {
  788. return {
  789. label: item.dictValue,
  790. value: item.dictKey,
  791. };
  792. });
  793. }
  794. });
  795. };
  796. getDict();
  797. const calculatedAmount = () => {
  798. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  799. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  800. let money = 0;
  801. if (formData.data.contractProductList[i].quantity && formData.data.contractProductList[i].price) {
  802. money = Number(Math.round(Number(formData.data.contractProductList[i].quantity) * Number(formData.data.contractProductList[i].price) * 10000) / 10000);
  803. }
  804. formData.data.contractProductList[i].amount = money;
  805. }
  806. }
  807. handleChangeAmount();
  808. };
  809. const handleChangeAmount = () => {
  810. let money = 0;
  811. let amountProduct = 0;
  812. let amountProject = 0;
  813. if (formData.data.contractProductList && formData.data.contractProductList.length > 0) {
  814. for (let i = 0; i < formData.data.contractProductList.length; i++) {
  815. if (formData.data.contractProductList[i].amount) {
  816. money = Number(Math.round((Number(money) + Number(formData.data.contractProductList[i].amount)) * 10000) / 10000);
  817. amountProduct = Number(Math.round((Number(amountProduct) + Number(formData.data.contractProductList[i].amount)) * 10000) / 10000);
  818. }
  819. }
  820. }
  821. if (formData.data.contractProjectList && formData.data.contractProjectList.length > 0) {
  822. for (let i = 0; i < formData.data.contractProjectList.length; i++) {
  823. if (formData.data.contractProjectList[i].amount) {
  824. money = Number(Math.round((Number(money) + Number(formData.data.contractProjectList[i].amount)) * 10000) / 10000);
  825. amountProduct = Number(Math.round((Number(amountProduct) + Number(formData.data.contractProjectList[i].amount)) * 10000) / 10000);
  826. }
  827. }
  828. }
  829. formData.data.amount = money;
  830. formData.data.amountProduct = amountProduct;
  831. formData.data.amountProject = amountProject;
  832. };
  833. const handleSubmit = async () => {
  834. const flag = await formDom1.value.validateForm().then((status) => {
  835. if (status) {
  836. active.value = 0;
  837. return false;
  838. } else {
  839. if (!(formData.data.contractProductList && formData.data.contractProductList.length > 0)) {
  840. active.value = 1;
  841. showFailToast(proxy.t("contract.pleaseAddProduct"));
  842. return false;
  843. }
  844. return formDom2.value.validateForm().then((status1) => {
  845. if (status1) {
  846. active.value = 1;
  847. return false;
  848. } else {
  849. return formDom4.value.validateForm().then((status2) => {
  850. if (status2) {
  851. active.value = 2;
  852. return false;
  853. } else {
  854. return formDom6.value.validateForm().then((status3) => {
  855. if (status3) {
  856. active.value = 3;
  857. return false;
  858. } else {
  859. return true;
  860. }
  861. });
  862. }
  863. });
  864. }
  865. });
  866. }
  867. });
  868. if (flag) {
  869. return formData.data;
  870. }
  871. };
  872. watch(
  873. refProps.queryData,
  874. () => {
  875. if (refProps.queryData.value && ["10", "20", "30"].includes(route.query.processType)) {
  876. for (const key in refProps.queryData.value) {
  877. formData.data[key] = refProps.queryData.value[key];
  878. }
  879. formDom1.value.formDataShowLabelOne();
  880. formDom2.value.formDataListShowLabelOne();
  881. formDom6.value.formDataShowLabelOne();
  882. if (["10", "20"].includes(route.query.processType)) {
  883. formOption.readonly = true;
  884. formGoodsOption.readonly = true;
  885. formGoodsOption.btnConfig.isNeed = false;
  886. formProjectOption.readonly = true;
  887. formProjectOption.btnConfig.isNeed = false;
  888. formShipmentOption.readonly = true;
  889. }
  890. }
  891. },
  892. {
  893. deep: true,
  894. }
  895. );
  896. defineExpose({
  897. handleSubmit,
  898. });
  899. onMounted(() => {});
  900. </script>
  901. <style lang="scss" scoped></style>