PriceSheet.vue 28 KB

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