Browse Source

判断模板保存前后是否相同

Luolei 6 years ago
parent
commit
aca9d8f6b1
1 changed files with 8 additions and 16 deletions
  1. 8 16
      src/components/Operation/index.jsx

+ 8 - 16
src/components/Operation/index.jsx

@@ -172,14 +172,15 @@ class Operation extends Component {
     let jsonStr = getAllDataStringList(baseList);
     let whichSign = baseList.typeConfig.typeConfig;
     let tmpLis = baseList.tabTemplate.items;
-    if (whichSign == 0) {
-      for(let i = 0;i <tmpLis.length;i++){
-        let dataStr = tmpLis[i].dataJson;
-        if(dataStr == JSON.stringify(jsonData)){
-          Notify.info('该模板已保存');
-          return false;
-        }
+    for(let i = 0;i <tmpLis.length;i++){
+      let dataStr = tmpLis[i].preview;
+      let jsStr = tmpLis[i].dataJson;
+      if(JSON.stringify(JSON.parse(dataStr)) == JSON.stringify(jsonStr) && jsStr == JSON.stringify(jsonData)){
+        Notify.info('该模板已保存');
+        return false;
       }
+    }
+    if (whichSign == 0) {
       if (
         JSON.stringify(jsonData.advice) == '{}' &&
         (jsonData.chief.length < 1 && jsonStr.chief == '[]') &&
@@ -197,15 +198,6 @@ class Operation extends Component {
         return true;
       }
     } else if(whichSign == 1) {
-      for(let i = 0;i <tmpLis.length;i++){
-        let dataStr = tmpLis[i].preview;
-        let jsStr = tmpLis[i].dataJson;
-        console.log(dataStr == JSON.stringify(jsonStr))
-        if(JSON.stringify(JSON.parse(dataStr)) == JSON.stringify(jsonStr) && jsStr == JSON.stringify(jsonData)){
-          Notify.info('该模板已保存');
-          return false;
-        }
-      }
       if (JSON.stringify(jsonData.advice) == '{}' && 
           jsonStr.chief == '[]' && 
           jsonStr.present == '[]' &&