dengrui 8 meses atrás
pai
commit
878a9929cd

+ 52 - 42
src/views/device/screwdriver/components/formItem.vue

@@ -59,6 +59,8 @@
   </el-form>
 </template>
 <script setup>
+import { add } from "@/api/excel";
+
 const props = defineProps({
   propIndex: {
     type: Number,
@@ -591,6 +593,8 @@ const rules = {
 };
 const lookStatus = inject("lookStatus");
 const ruleForm = inject("ruleForm");
+const addStatus = inject("addStatus");
+
 const formData = ref({});
 const labelOption = (num) => {
   switch (num) {
@@ -696,6 +700,7 @@ const showLable = (key) => {
 const getFormData = () => {
   return JSON.stringify(formData.value);
 };
+const dialog = inject("dialog");
 const checkData = (index) => {
   return new Promise(async (resolve, reject) => {
     await formRef.value.validate((valid) => {
@@ -708,48 +713,53 @@ const checkData = (index) => {
   });
 };
 watch(
-  () => ruleForm.value,
-  () => {
-    if (JSON.stringify(ruleForm.value[`task${props.propIndex}`]) == "{}") {
-      formData.value = {
-        DDLSD1: 0,
-        DDLSD2: 1,
-        DDLSD3: 6.0,
-        DDLSD4: 60,
-        DDLSD5: 2.0,
-        DDLSD6: 4.0,
-        DDLSD7: 60,
-        DDLSD8: 0,
-        DDLSD9: 0,
-        DDLSD10: 300,
-        DDLSD11: 100,
-        DDLSD12: 15.0,
-        DDLSD13: 15.0,
-        DDLSD14: 4.5,
-        DDLSD15: 0,
-        DDLSD16: 0,
-        DDLSD17: 1,
-        DDLSD18: 0.25,
-        DDLSD19: 60,
-        DDLSD20: 5.5,
-        DDLSD21: 800,
-        DDLSD22: 6.0,
-        DDLSD23: 300,
-        DDLSD24: 0.0,
-        DDLSD25: 0,
-        DDLSD26: 0.0,
-        DDLSD27: 0,
-        DDLSD28: 8.0,
-        DDLSD29: 360,
-        DDLSD30: 0.0,
-        DDLSD31: 0,
-        DDLSD32: 0.0,
-        DDLSD33: 0,
-        DDLSD34: 0.0,
-        DDLSD35: 360,
-      };
-    } else {
-      formData.value = JSON.parse(ruleForm.value[`task${props.propIndex}`]);
+  () => dialog.visible,
+  (value) => {
+    if (value == true) {
+      if (
+        JSON.stringify(ruleForm.value[`task${props.propIndex}`]) == "{}" &&
+        addStatus.value == true
+      ) {
+        formData.value = {
+          DDLSD1: 0,
+          DDLSD2: 1,
+          DDLSD3: 6.0,
+          DDLSD4: 60,
+          DDLSD5: 2.0,
+          DDLSD6: 4.0,
+          DDLSD7: 60,
+          DDLSD8: 0,
+          DDLSD9: 0,
+          DDLSD10: 300,
+          DDLSD11: 100,
+          DDLSD12: 15.0,
+          DDLSD13: 15.0,
+          DDLSD14: 4.5,
+          DDLSD15: 0,
+          DDLSD16: 0,
+          DDLSD17: 1,
+          DDLSD18: 0.25,
+          DDLSD19: 60,
+          DDLSD20: 5.5,
+          DDLSD21: 800,
+          DDLSD22: 6.0,
+          DDLSD23: 300,
+          DDLSD24: 0.0,
+          DDLSD25: 0,
+          DDLSD26: 0.0,
+          DDLSD27: 0,
+          DDLSD28: 8.0,
+          DDLSD29: 360,
+          DDLSD30: 0.0,
+          DDLSD31: 0,
+          DDLSD32: 0.0,
+          DDLSD33: 0,
+          DDLSD34: 0.0,
+          DDLSD35: 360,
+        };
+      } else {
+        formData.value = JSON.parse(ruleForm.value[`task${props.propIndex}`]);
+      }
     }
   },
   { immediate: true, deep: true }

+ 21 - 8
src/views/device/screwdriver/index.vue

@@ -173,22 +173,32 @@ const submit = async () => {
   );
   Promise.allSettled(arrayRef.value).then(async (res) => {
     let errorArrayIndex = [];
+    let form = false;
     for (let i = 0; i < res.length; i++) {
       if (res[i].status == "rejected") {
-        errorArrayIndex.push("任务" + res[i].reason);
+        if (i == 8) {
+          form = true;
+        } else {
+          errorArrayIndex.push("任务" + res[i].reason);
+        }
       }
     }
-    if (errorArrayIndex.length > 0) {
+    if (errorArrayIndex.length > 0 || form == true) {
       //未校验成功逻辑
       let str = "请检查";
-      for (let i = 0; i < errorArrayIndex.length; i++) {
-        if (i == errorArrayIndex.length - 1) {
-          str += errorArrayIndex[i];
-        } else {
-          str += errorArrayIndex[i] + "、";
+      if (errorArrayIndex.length > 0) {
+        for (let i = 0; i < errorArrayIndex.length; i++) {
+          if (i == errorArrayIndex.length - 1) {
+            str += errorArrayIndex[i];
+          } else {
+            str += errorArrayIndex[i] + "、";
+          }
         }
       }
-      str += "等表单选项";
+      if (form == true) {
+        str += "头部表单";
+      }
+      str += "选项";
       ElMessage.error(str);
     } else {
       //校验成功逻辑
@@ -277,6 +287,7 @@ const dialog = reactive({
   title: "设备选择",
   visible: false,
 });
+provide("dialog", dialog);
 const ruleForm = ref({
   materialName: "",
   materialNo: "",
@@ -294,10 +305,12 @@ const ruleForm = ref({
 });
 provide("ruleForm", ruleForm);
 const addStatus = ref(false);
+provide("addStatus", addStatus);
 const lookStatus = ref(false);
 provide("lookStatus", lookStatus);
 const resetForm = () => {
   activeName.value = "task1";
+  formKey.value = !formKey.value;
   ruleForm.value = {
     materialName: "",
     materialNo: "",