Sfoglia il codice sorgente

更新 货种选择

wzh 3 anni fa
parent
commit
f381292008
2 ha cambiato i file con 31 aggiunte e 28 eliminazioni
  1. 1 2
      src/components/RemoteSelect.vue
  2. 30 26
      src/views/cargoManage/cargoList.vue

+ 1 - 2
src/components/RemoteSelect.vue

@@ -45,8 +45,7 @@ export default {
       default: false,
     },
     value: {
-      type: Array,
-      default: [],
+      type: [Array, Object, String],
     },
   },
 

+ 30 - 26
src/views/cargoManage/cargoList.vue

@@ -132,7 +132,7 @@ let form = ref(null);
 let visable = ref(false);
 let ruleForm = ref({
   cargo: "",
-  proxyIds: [],
+  proxyIds: "",
 });
 function resetForm() {
   visable.value = false;
@@ -180,32 +180,36 @@ function pageChange(e) {
   getCargoList();
 }
 async function addCargo() {
-  let { cargo, proxyIds, cargoId } = ruleForm.value;
-  let arr = [];
-  for (let i of proxyIds) {
-    arr.push(i.key);
-  }
-  let postData = {};
-  if (cargoId) {
-    postData = { cargoId };
-  }
-  let res = await api[cargoId ? "updateCargo" : "addCargo"]({
-    ...postData,
-    cargo,
-    proxyIds: arr.join(","),
+  form.value.validate(async (valid) => {
+    if (valid) {
+      let { cargo, proxyIds, cargoId } = ruleForm.value;
+      let arr = [];
+      for (let i of proxyIds) {
+        arr.push(i.key);
+      }
+      let postData = {};
+      if (cargoId) {
+        postData = { cargoId };
+      }
+      let res = await api[cargoId ? "updateCargo" : "addCargo"]({
+        ...postData,
+        cargo,
+        proxyIds: arr.join(","),
+      });
+      if (res.data.status == 0) {
+        ElNotification({
+          title: "成功",
+          duration: 1500,
+          message: res.data.msg,
+          type: "success",
+        });
+        resetForm();
+        getCargoList();
+      } else {
+        console.log(res);
+      }
+    }
   });
-  if (res.data.status == 0) {
-    ElNotification({
-      title: "成功",
-      duration: 1500,
-      message: res.data.msg,
-      type: "success",
-    });
-    resetForm();
-    getCargoList();
-  } else {
-    console.log(res);
-  }
 }
 
 async function changeStatus(status, cargoId) {