ysy 1 سال پیش
والد
کامیت
9b10ffdcbf
1فایلهای تغییر یافته به همراه41 افزوده شده و 42 حذف شده
  1. 41 42
      src/views/material/BOMmanage/detailsPop.vue

+ 41 - 42
src/views/material/BOMmanage/detailsPop.vue

@@ -133,7 +133,12 @@
               提交发布
             </el-button>
 
-            <el-button type="primary" size="mini" @click="handleSave"   v-if="currentNodeData.status != 1">
+            <el-button
+              type="primary"
+              size="mini"
+              @click="handleSave"
+              v-if="currentNodeData.status != 1"
+            >
               保存
             </el-button>
           </div>
@@ -199,7 +204,7 @@
               >
                 <el-option
                   v-for="item in versList"
-                  :label="'V' +item.versions + '.0'"
+                  :label="'V' + item.versions + '.0'"
                   :value="item.versions"
                   :key="item.id"
                 >
@@ -435,7 +440,6 @@
 
         if (Object.prototype.hasOwnProperty.call(row, 'bomType')) {
           this.currentNodeData.bomType = row.bomType;
-
         }
         this.drawer = true;
         this.getTreeData();
@@ -466,11 +470,10 @@
         this.getVersion();
       },
 
-
       async getTreeData() {
         try {
           this.treeLoading = true;
-          
+
           const res = await getBomTreeList({
             categoryId: this.searchObj.categoryId,
             versions: this.searchObj.versions,
@@ -508,7 +511,7 @@
         if (id) {
           getBomGetById(id).then((res) => {
             this.currentNodeData = res.data;
-            this.searchObj.versions =  this.currentNodeData.versions
+            this.searchObj.versions = this.currentNodeData.versions;
             this.$forceUpdate();
           });
         } else {
@@ -559,10 +562,17 @@
           .finally(() => {});
       },
 
-      transformation(tt) {
+      async transformation(tt) {
         if (this.currentNodeData.status != 1) {
           return this.$message.warning('只有已发布版本才可以转换');
         }
+
+        let _type = tt == 'P' ? 1 : tt == 'M' ? 2 : tt == 'A' ? 3 : 4;
+        if (!this.isEdit) {
+          let isHas = await this.hasVersionFn(_type);
+          if (!isHas) return;
+        }
+
         this.loadingInstance = this.$loading({
           lock: true,
           text: '转换中...',
@@ -586,8 +596,6 @@
             this.loadingInstance.close();
             this.$message.success('转换成功');
 
- 
-             let _type = tt == 'P' ? 1 : tt == 'M' ? 2 : tt == 'A' ? 3 : 4;
             this.currentNodeData.bomType = _type;
             this.getTreeData();
             this.getVersion();
@@ -595,7 +603,6 @@
         });
       },
 
-
       handleAdd() {
         this.baseInfoShow = true;
       },
@@ -615,12 +622,9 @@
       handleSave() {
         this.$message.success('保存成功');
         this.handleClose();
-
-      
       },
 
       handSubmit() {
-       
         if (this.clientEnvironmentId == 4) {
           this.isSubmit = true;
         } else {
@@ -631,11 +635,10 @@
           })
             .then(() => {
               bomSubmit({ businessId: this.currentNodeData.id }).then((res) => {
-                if(res.code == 0) {
+                if (res.code == 0) {
                   this.$message.success('发布成功');
                   this.getTreeData();
                 }
-  
               });
             })
             .catch(() => {});
@@ -667,35 +670,31 @@
         }
       },
 
-      async hasVersionFn() {
-         return new Promise((resolve) => {
-        let param = {
-          categoryId: this.searchObj.categoryId,
-          bomType: this.currentNodeData.bomType
-        };
-        hasNewVersion(param).then((res) => {
-           if(res.data == 1) {
-                this.$confirm('已经草稿版本存在,是否覆盖?', '提示', {
-                  confirmButtonText: '覆盖',
-                  cancelButtonText: '取消',
-                  type: 'warning'
+      async hasVersionFn(bomType) {
+        return new Promise((resolve) => {
+          let param = {
+            categoryId: this.searchObj.categoryId,
+            bomType: bomType
+          };
+          hasNewVersion(param).then((res) => {
+            if (res.data == 1) {
+              this.$confirm('已经草稿版本存在,是否覆盖?', '提示', {
+                confirmButtonText: '覆盖',
+                cancelButtonText: '取消',
+                type: 'warning'
+              })
+                .then(() => {
+                  resolve(true);
                 })
-                  .then(() => {
-                    resolve(false);
-                  })
-                  .catch(() => {
-                    resolve(true);
-                  });
-
-
-           } else {
-            resolve(true);
-           }
-
-   
+                .catch(() => {
+                  resolve(false);
+                });
+            } else {
+              resolve(true);
+            }
+          });
         });
-      });
-      },
+      }
     }
   };
 </script>