cz 1 éve
szülő
commit
31c3b457c1

+ 305 - 33
src/views/processApproval/components/EhsdContract.vue

@@ -102,6 +102,9 @@ const active = ref(0);
 const tabsChange = () => {
   active.value++;
 };
+const innerMethod = ref([]);
+const outsideMethod = ref([]);
+
 const formData = reactive({
   data: {
     contractProductList: [],
@@ -136,7 +139,57 @@ const formConfig = reactive([
       value: "value",
     },
     data: [],
-    changeFn: (val, data) => {},
+    changeFn: (val, data) => {
+      proxy.formChange(val, data, formData);
+      formData.data.sellCorporationId = "";
+      formData.data.sellCountryName = "";
+      formData.data.sellProvinceName = "";
+      formData.data.sellCityName = "";
+      formData.data.sellAddress = "";
+      formData.data.sellContactName = "";
+      formData.data.sellContactNumber = "";
+      if (val.selectedValues[0]) {
+        proxy
+          .post("/contractTemplate/detail", { id: val.selectedValues[0] })
+          .then((res) => {
+            formData.data.sellCorporationId = res.data.corporationId;
+            if (res.data.corporationId) {
+              proxy
+                .post("/corporation/detail", { id: res.data.corporationId })
+                .then((detailCorporation) => {
+                  let sellCity = "";
+                  if (detailCorporation.data.countryEnStr) {
+                    formData.data.sellCountryName =
+                      detailCorporation.data.countryEnStr;
+                    sellCity = detailCorporation.data.countryEnStr;
+                  }
+                  if (detailCorporation.data.provinceEnStr) {
+                    formData.data.sellProvinceName =
+                      detailCorporation.data.provinceEnStr;
+                    sellCity =
+                      sellCity + " " + detailCorporation.data.provinceEnStr;
+                  }
+                  if (detailCorporation.data.cityEnStr) {
+                    formData.data.sellCityName =
+                      detailCorporation.data.cityEnStr;
+                    sellCity =
+                      sellCity + " " + detailCorporation.data.cityEnStr;
+                  }
+                  if (detailCorporation.data.addressEn) {
+                    formData.data.sellAddress =
+                      detailCorporation.data.addressEn;
+                  }
+                  formData.data.sellCity = sellCity;
+                  formDom1.value.formDataShowLabelOne();
+                });
+            }
+            formData.data.sellContactName = res.data.contactName;
+            formData.data.sellContactNumber = res.data.contactNumber;
+            formDom1.value.formDataShowLabelOne();
+          });
+      }
+      data.showPicker = false;
+    },
   },
   {
     type: "title",
@@ -153,14 +206,14 @@ const formConfig = reactive([
       value: "value",
     },
     data: [],
-    readonly: true,
+    readonly: false,
   },
   {
     type: "input",
     label: proxy.t("contract.cityText"),
     prop: "sellCity",
     itemType: "text",
-    readonly: true,
+    readonly: false,
   },
   {
     type: "input",
@@ -195,12 +248,80 @@ const formConfig = reactive([
       value: "value",
     },
     data: [],
-    changeFn: (val, data) => {},
+    changeFn: (val, data) => {
+      proxy.formChange(val, data, formData);
+      formData.data.buyContactName = "";
+      formData.data.buyContactNumber = "";
+      if (val.selectedValues[0]) {
+        proxy
+          .post("/customer/detail", { id: val.selectedValues[0] })
+          .then((res) => {
+            // 回填联系人
+            if (
+              res.data.customerUserList &&
+              res.data.customerUserList.length > 0
+            ) {
+              formData.data.buyContactName = res.data.customerUserList[0].name;
+              if (res.data.customerUserList[0].contactJson) {
+                let contactJson = JSON.parse(
+                  res.data.customerUserList[0].contactJson
+                );
+                if (contactJson && contactJson.length > 0) {
+                  formData.data.buyContactNumber = contactJson[0].contactNo;
+                }
+              }
+            }
+            // 回填客户的账户信息
+            formData.data.beneficiaryName = res.data.beneficiaryName;
+            formData.data.beneficiaryBank = res.data.beneficiaryBank;
+            formData.data.beneficiaryBankAddress =
+              res.data.beneficiaryBankAddress;
+            formData.data.beneficiaryAccountNumber =
+              res.data.beneficiaryAccountNumber;
+
+            formData.data.swiftCode = res.data.swiftCode;
+            formData.data.beneficiaryAddress = res.data.beneficiaryAddress;
+            let countryCityName = "";
+            if (res.data.countryName) {
+              countryCityName = res.data.countryName;
+              if (res.data.provinceName) {
+                countryCityName = countryCityName + " " + res.data.provinceName;
+                if (res.data.cityName) {
+                  countryCityName = countryCityName + " " + res.data.cityName;
+                }
+              }
+            }
+
+            formData.data.countryCityName = countryCityName;
+            if (res.data.cityId) {
+              formData.data.countryCity = res.data.cityId;
+            } else if (res.data.provinceId) {
+              formData.data.countryCity = res.data.provinceId;
+            } else if (res.data.countryId) {
+              formData.data.countryCity = res.data.countryId;
+            } else {
+              formData.data.countryCity = "";
+            }
+            formData.data.countryId = res.data.countryId;
+            formData.data.provinceId = res.data.provinceId;
+            formData.data.cityId = res.data.cityId;
+            formData.data.buyPostalCode = res.data.zipCode;
+            formData.data.buyAddress = res.data.address;
+          });
+      } else {
+        formData.data.countryId = "";
+        formData.data.provinceId = "";
+        formData.data.cityId = "";
+        formData.data.buyPostalCode = "";
+        formData.data.buyAddress = "";
+      }
+      data.showPicker = false;
+    },
   },
   {
     type: "cascader",
     label: proxy.t("contract.cityText"),
-    prop: "countryId",
+    prop: "countryCity",
     itemType: "city",
     showPicker: false,
   },
@@ -241,14 +362,14 @@ const formConfigOne = reactive([
       value: "value",
     },
     data: [],
-    readonly: true,
+    readonly: false,
   },
   {
     type: "input",
     label: "汇率",
     prop: "rate",
     itemType: "number",
-    readonly: true,
+    readonly: false,
   },
   {
     type: "picker",
@@ -261,14 +382,14 @@ const formConfigOne = reactive([
       value: "value",
     },
     data: [],
-    readonly: true,
+    readonly: false,
   },
   {
     type: "input",
     label: "预付比例",
     prop: "advanceRatio",
     itemType: "number",
-    readonly: true,
+    readonly: false,
   },
   {
     type: "input",
@@ -287,7 +408,21 @@ const formConfigOne = reactive([
       value: "value",
     },
     data: [],
-    readonly: true,
+    readonly: false,
+    changeFn: (val, data) => {
+      proxy.formChange(val, data, formData);
+      const current = data.data.find((x) => x.value === val.selectedValues[0]);
+      if (current) {
+        formData.data.beneficiaryName = current.beneficiaryName;
+        formData.data.beneficiaryBank = current.beneficiaryBank;
+        formData.data.beneficiaryBankAddress = current.beneficiaryBankAddress;
+        formData.data.beneficiaryAccountNumber =
+          current.beneficiaryAccountNumber;
+        formData.data.swiftCode = current.swiftCode;
+        formData.data.beneficiaryAddress = current.beneficiaryAddress;
+      }
+      data.showPicker = false;
+    },
   },
   {
     type: "input",
@@ -334,7 +469,7 @@ const formConfigOne = reactive([
     label: "报价有效期 (天)",
     prop: "effective",
     itemType: "number",
-    readonly: true,
+    readonly: false,
   },
   {
     type: "picker",
@@ -356,7 +491,7 @@ const formConfigOne = reactive([
       value: "value",
     },
     data: [],
-    readonly: true,
+    readonly: false,
   },
   {
     type: "input",
@@ -379,10 +514,81 @@ const formGoodsOption = reactive({
     listTitle: "商品信息",
     listConfig: [
       {
-        type: "input",
+        type: "picker",
         label: "商品中文名",
-        prop: "productCnName",
-        itemType: "text",
+        prop: "productId",
+        itemType: "onePicker",
+        showPicker: false,
+        readonly: false,
+        fieldNames: {
+          text: "label",
+          value: "value",
+        },
+        data: [],
+        changeFn: (val, data, index, indexTwo, propName) => {
+          let selectList = formData.data[propName].filter(
+            (item, itemIndex) =>
+              item[data.prop] === val.selectedValues[0] && itemIndex !== index
+          );
+          if (selectList && selectList.length > 0) {
+            return showFailToast(proxy.t("contract.productRepeat"));
+          }
+          formData.data[propName][index][data.prop] = val.selectedValues[0];
+          formData.data.contractShipmentList[index][data.prop] =
+            val.selectedValues[0];
+          let list = data.data.filter(
+            (item) => item[data.fieldNames.value] == val.selectedValues[0]
+          );
+          if (list && list.length > 0) {
+            formData.data[propName][index][data.prop + "Name"] =
+              list[0][data.fieldNames.text];
+            if (list[0].ehsdJson) {
+              let ehsdJson = JSON.parse(list[0].ehsdJson);
+              if (ehsdJson) {
+                formData.data[propName][index].productName =
+                  ehsdJson.nameEnglish || "";
+                formData.data.contractShipmentList[index].productName =
+                  ehsdJson.nameEnglish || list[0][data.fieldNames.text];
+                formData.data.contractShipmentList[index].productCode =
+                  list[0].code;
+                formData.data[propName][index].productModel =
+                  ehsdJson.productLong +
+                  "*" +
+                  ehsdJson.productWide +
+                  "*" +
+                  ehsdJson.productHigh;
+                // 包装方式
+                let str = "";
+                let strOne = "";
+                if (ehsdJson.innerPackMethod) {
+                  let innerPackMethodArr = ehsdJson.innerPackMethod.split(",");
+                  innerPackMethodArr = innerPackMethodArr.map((x) =>
+                    proxy.dictValueLabel(x, innerMethod.value)
+                  );
+                  str += innerPackMethodArr.join(",");
+                }
+                if (ehsdJson.outerPackMethod) {
+                  let outerPackMethodArr = ehsdJson.outerPackMethod.split(",");
+                  outerPackMethodArr = outerPackMethodArr.map((x) =>
+                    proxy.dictValueLabel(x, outsideMethod.value)
+                  );
+                  strOne += outerPackMethodArr.join(",");
+                }
+                formData.data[propName][index].packMethod = str + "," + strOne;
+              }
+            }
+          } else {
+            formData.data[propName][index][data.prop + "Name"] = "";
+          }
+          formData.data[propName][index].quantity = null;
+          formData.data[propName][index].price = null;
+          formData.data[propName][index].amount = null;
+          formData.data[propName][index].remark = null;
+          formData.data.contractShipmentList[index].shipmentTime = null;
+          formData.data.contractShipmentList[index].quantity = null;
+          formData.data.contractShipmentList[index].remark = null;
+          data.showPicker = false;
+        },
       },
       {
         type: "input",
@@ -407,18 +613,18 @@ const formGoodsOption = reactive({
         label: "数量",
         prop: "quantity",
         itemType: "number",
-        // changeFn: () => {
-        //   calculatedAmount();
-        // },
+        changeFn: () => {
+          calculatedAmount();
+        },
       },
       {
         type: "input",
         label: "单价",
         prop: "price",
         itemType: "number",
-        // changeFn: () => {
-        //   calculatedAmount();
-        // },
+        changeFn: () => {
+          calculatedAmount();
+        },
       },
       {
         type: "picker",
@@ -431,16 +637,16 @@ const formGoodsOption = reactive({
           value: "value",
         },
         data: [],
-        readonly: true,
+        readonly: false,
       },
       {
         type: "input",
         label: "金额",
         prop: "amount",
         itemType: "number",
-        // changeFn: () => {
-        //   calculatedAmount();
-        // },
+        changeFn: () => {
+          calculatedAmount();
+        },
       },
     ],
     clickFn: () => {
@@ -460,6 +666,7 @@ const formGoodsOption = reactive({
         formData.data.contractShipmentList.push({
           productId: null,
           productName: null,
+          productCode: null,
           shipmentTime: null,
           quantity: null,
           remark: null,
@@ -480,6 +687,7 @@ const formGoodsOption = reactive({
           {
             productId: null,
             productName: null,
+            productCode: null,
             shipmentTime: null,
             quantity: null,
             remark: null,
@@ -696,6 +904,7 @@ const getDict = () => {
         };
       });
     });
+  // 卖方
   proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
     formConfig[2].data = res.data.rows.map((item) => {
       return {
@@ -705,9 +914,26 @@ const getDict = () => {
       };
     });
   });
+  // 买方
+  proxy
+    .post("/customer/selPage", {
+      pageNum: 1,
+      pageSize: 999,
+    })
+    .then((res) => {
+      formConfig[8].data = res.data.rows.map((x) => ({
+        ...x,
+        label: x.name,
+        value: x.id,
+      }));
+    });
   // 产品
   proxy
-    .post("/productInfo/page", { pageNum: 1, pageSize: 9999, definition: "1" })
+    .post("productInfo/getConditionProductList", {
+      pageNum: 1,
+      pageSize: 9999,
+      definition: "1",
+    })
     .then((res) => {
       if (res.data.rows && res.data.rows.length > 0) {
         formGoodsOption.btnConfig.listConfig[0].data = res.data.rows.map(
@@ -721,6 +947,39 @@ const getDict = () => {
         );
       }
     });
+  // 包装方式
+  proxy
+    .post("/dictTenantData/page", {
+      ...query,
+      dictCode: "inner_packaging_method_ehsd",
+    })
+    .then((res) => {
+      if (res.data.rows && res.data.rows.length > 0) {
+        innerMethod.value = res.data.rows.map((item) => {
+          return {
+            label: item.dictValue,
+            value: item.dictKey,
+          };
+        });
+      }
+    });
+  // 包装方式
+  proxy
+    .post("/dictTenantData/page", {
+      ...query,
+      dictCode: "outside_packaging_method_ehsd",
+    })
+    .then((res) => {
+      if (res.data.rows && res.data.rows.length > 0) {
+        outsideMethod.value = res.data.rows.map((item) => {
+          return {
+            label: item.dictValue,
+            value: item.dictKey,
+          };
+        });
+      }
+    });
+
   // 币种
   proxy
     .post("/dictTenantData/page", { ...query, dictCode: "account_currency" })
@@ -924,6 +1183,18 @@ const handleSubmit = async () => {
     }
   });
   if (flag) {
+    formData.data.contractProductList = formData.data.contractProductList.map(
+      (item) => {
+        let ehsdJson = JSON.stringify({
+          packMethod: item.packMethod,
+          tradeMethods: item.tradeMethods,
+        });
+        return {
+          ...item,
+          ehsdJson: ehsdJson,
+        };
+      }
+    );
     return formData.data;
   }
 };
@@ -932,8 +1203,6 @@ onMounted(() => {
   if (route.query && route.query.businessId) {
     let businessId = route.query.businessId;
     proxy.post("/contract/detail", { id: businessId }).then((res) => {
-      console.log(res, "asda");
-
       res.data.countryId = res.data.buyCountryId;
       res.data.provinceId = res.data.buyProvinceId;
       res.data.cityId = res.data.buyCityId;
@@ -946,12 +1215,13 @@ onMounted(() => {
         formData.data.sellProvinceName +
         " " +
         formData.data.sellCityName;
-      formData.data.countryIdName =
+      formData.data.countryCityName =
         formData.data.buyCountryName +
         " " +
         formData.data.buyProvinceName +
         " " +
         formData.data.buyCityName;
+
       if (formData.data.buyCorporationName) {
         proxy
           .post("/customer/selPage", {
@@ -965,21 +1235,21 @@ onMounted(() => {
             }));
           });
       }
+
       if (
         formData.data.contractProductList &&
         formData.data.contractProductList.length > 0
       ) {
         for (let i = 0; i < formData.data.contractProductList.length; i++) {
           const e = formData.data.contractProductList[i];
-
           if (e.ehsdJson) {
             let obj = JSON.parse(e.ehsdJson);
-            console.log(obj, "asda");
             e.packMethod = obj.packMethod;
             e.tradeMethods = obj.tradeMethods;
           }
         }
       }
+
       if (["10", "20"].includes(route.query.processType)) {
         formOption.readonly = true;
         formGoodsOption.readonly = true;
@@ -988,8 +1258,10 @@ onMounted(() => {
         formProjectOption.btnConfig.isNeed = false;
         formShipmentOption.readonly = true;
       }
-      formDom1.value.formDataShowLabelOne();
-      formDom2.value.formDataShowLabelOne();
+      setTimeout(() => {
+        formDom1.value.formDataShowLabelOne();
+        formDom2.value.formDataShowLabelOne();
+      }, 200);
     });
   }
 });

+ 1 - 1
src/views/salesContract/contract/index.vue

@@ -7,7 +7,7 @@
     @click-right="onClickRight"
   >
     <template #right>
-      <!-- {{ $t("common.add") }} -->
+      {{ $t("common.add") }}
     </template>
   </van-nav-bar>
   <van-search