Ver Fonte

兼容格式问题

zhuyiyi há 6 meses atrás
pai
commit
cb982796a7
1 ficheiros alterados com 40 adições e 23 exclusões
  1. 40 23
      src/views/info.vue

+ 40 - 23
src/views/info.vue

@@ -36,7 +36,9 @@
           </el-form-item>
         </template>
       </template>
-      <el-button type="primary" @click="saveData" :disabled="isSubmit">确认</el-button>
+      <el-button type="primary" @click="saveData" :disabled="isSubmit"
+        >确认</el-button
+      >
       <el-button type="primary" @click="handleDownload(loaderData)"
         >下载全部文件</el-button
       >
@@ -156,27 +158,39 @@ async function getData() {
           FormJson: json_info,
         };
       }
+      let fromdata = true;
+      CeErpOrderFormData.value.content = CeErpOrderFormData.value.content.replace(/\n/g, ' ')
       if (CeErpOrderFormData.value && CeErpOrderFormData.value.content) {
         console.log(
           "🚀 ~ getData ~ CeErpOrderFormData.value.content:",
           CeErpOrderFormData.value.content
         );
-        CeErpOrderFormData.value = {
-          content: JSON.parse(CeErpOrderFormData.value.content),
-          id: CeErpOrderFormData.value.ID,
-          tid: CeErpOrderFormData.value.tid,
-        };
-        CeErpOrderFormData.value?.content.map((item) => {
-          if (
-            item.type == "upload" &&
-            item.content &&
-            typeof item.content == "string"
-          ) {
-            item.content?.split(",")?.map((e) => {
-              loaderData.value.push(baseUrl + e);
-            });
-          }
-        });
+        try {
+          CeErpOrderFormData.value = {
+            content: JSON.parse(CeErpOrderFormData.value.content),
+            id: CeErpOrderFormData.value.ID,
+            tid: CeErpOrderFormData.value.tid,
+          };
+
+          CeErpOrderFormData.value?.content.map((item) => {
+            if (
+              item.type == "upload" &&
+              item.content &&
+              typeof item.content == "string"
+            ) {
+              item.content?.split(",")?.map((e) => {
+                loaderData.value.push(baseUrl + e);
+              });
+            }
+          });
+        } catch (error) {
+          console.error("getData ~ error:", error);
+          fromdata = false;
+          ElMessage({
+            message: "数据解析错误",
+            type: "error",
+          });
+        }
       }
       product.FormJson = json_info;
       if (product && product.FormJson != "") {
@@ -188,13 +202,16 @@ async function getData() {
           } else {
             item.content = "";
           }
-          if (CeErpOrderFormData.value && CeErpOrderFormData.value.content) {
-            CeErpOrderFormData.value.content.map((e) => {
-              if (e.title === item.title && e.type === item.type) {
-                item.content = e.content;
-              }
-            });
+          if (fromdata) {
+            if (CeErpOrderFormData.value && CeErpOrderFormData.value.content) {
+              CeErpOrderFormData.value.content.map((e) => {
+                if (e.title === item.title && e.type === item.type) {
+                  item.content = e.content;
+                }
+              });
+            }
           }
+
           if (item.title == "手机号") {
             need = false;
           }