فهرست منبع

加机停机状态改第一个关闭

Shan9312 1 سال پیش
والد
کامیت
1be2085b19
1فایلهای تغییر یافته به همراه86 افزوده شده و 41 حذف شده
  1. 86 41
      src/views/formulationPlan/recipeTemplate/index.vue

+ 86 - 41
src/views/formulationPlan/recipeTemplate/index.vue

@@ -1635,6 +1635,14 @@ export default {
       MessageBox.confirm('是否确认删除此信息?', {
         confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
       }).then(() => {
+        console.log(this.table2.list.length)
+        const tabelList= JSON.parse(JSON.stringify(this.table2.list));
+        const List =this.sortObjectsById(tabelList);
+        if(List && List.length>=2 && List[0].id == row.id && List[1].shutdown == 1){
+            this.$message({ type: 'error', message: '需要把后面排序:第一个的‘加料前停机’改为关掉', duration: 3000 })
+            return false;
+          }
+
         const url = 'authdata/feedtemplet/del'
         const data = {
           ftId:row.id,
@@ -2463,26 +2471,26 @@ export default {
         userId: Cookies.get('employeid')
       }}
       const url = 'authdata/ftdetail/edit'
-      const data = this.requestParam
-      postJson(url, data).then(response => {
-        if (response.msg !== 'fail') {
-          this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
-          this.getList2()
-          this.getList3()
-        } else {
-          this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
+      const data = this.requestParam;
+      const tabelList= JSON.parse(JSON.stringify(this.table2.list));
+      const List =this.sortObjectsById(tabelList);
+      if(List && List.length>0 && List[0].shutdown == 1){
+        this.$message({ type: 'error', message: '顺序第一个词料,需要把‘加料前停机’改为关掉', duration: 3000 })
+        return false;
+              //   this.$confirm('第一个词料,需要把‘加料前停机’改为关掉, 是否继续?', '提示', {
+              //   confirmButtonText: '确定',
+              //   cancelButtonText: '取消',
+              //   type: 'warning'
+              // }).then(() => {
+              //   data.data[1].parammaps.shutdown = 0;
+              //   console.log(data,'传的数据---hss');
+              //   this.postTableDate(url,data)
+              // }).catch(() => {
+              //   return false;
+              // });
         }
-      })
-      // ExecDataByConfig(this.requestParam).then(response => {
-      //   console.log('新增保存发送参数', this.requestParam)
-      //   if (response.msg !== 'fail') {
-      //     this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
-      //     this.getList2()
-      //     this.getList3()
-      //   } else {
-      //     this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
-      //   }
-      // })
+        this.postTableDate(url,data)
+
     },
     createCancel2(row) {
       console.log('点击了详情新增取消')
@@ -2575,6 +2583,7 @@ export default {
           this.table2.temp.deviation = row.deviation
           this.table2.temp.shutdown = row.shutdown
           this.table2.temp.id = row.id
+
           console.log('this.table2.updateList', this.table2.updateList)
           console.log('temp', this.table2.temp)
           // var status = ''
@@ -2695,28 +2704,52 @@ export default {
             userId: Cookies.get('employeid')
           }}
           const url = 'authdata/ftdetail/edit'
-          const data = this.requestParam
-          postJson(url, data).then(response => {
-            if (response.msg !== 'fail') {
-              this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
-              this.getList2()
-              this.getList3()
-              this.dropState = false
-            } else {
-              this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
+          const data = this.requestParam;
+          // TODO: 如果排序为1 或者当前数组中只有当前一个新增的值  只能默认当前加料前停机为0
+          // 当用户修改顺序时,把列表进行判断,如果是第一个值,若当前加料前停机状态为开启,则提示用户
+          // 当前加料前停机状态为开,需要关闭才能排序,否就不操作,确认则发给后端
+          const tabelList= JSON.parse(JSON.stringify(this.table2.list));
+          console.log(tabelList,'获取当前数据--hssss')
+          const List =this.sortObjectsById(tabelList);
+          // console.log(tabelList,'排序--hssss');
+          if(List && List.length>0 && List[0].shutdown == 1){
+            this.$message({ type: 'error', message: '顺序第一个词料,需要把‘加料前停机’改为关掉', duration: 3000 })
+            return false;
+              //   this.$confirm('第一个词料,需要把‘加料前停机’改为关掉, 是否继续?', '提示', {
+              //   confirmButtonText: '确定',
+              //   cancelButtonText: '取消',
+              //   type: 'warning'
+              // }).then(() => {
+              //   // debugger
+              //   data.data[1].parammaps.shutdown = 0;
+              //   console.log(data,'传的数据---hss');
+              //   this.postTableDate(url,data)
+              // }).catch(() => {
+              //   return false;
+              // });
             }
-          })
-          // ExecDataByConfig(this.requestParam).then(response => {
-          //   console.log('新增保存发送参数', this.requestParam)
-          //   if (response.msg !== 'fail') {
-          //     this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
-          //     this.getList2()
-          //     this.getList3()
-          //     this.dropState = false
-          //   } else {
-          //     this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
-          //   }
-          // })
+             this.postTableDate(url,data)
+
+
+        },
+        //  发送数据‘
+        postTableDate(url,data){
+          postJson(url, data).then(response => {
+                              if (response.msg !== 'fail') {
+                                this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
+                                this.getList2()
+                                this.getList3()
+                                this.dropState = false
+                              } else {
+                                this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
+                              }
+                })
+
+
+        },
+        // 排序
+        sortObjectsById(arr) {
+            return arr.sort((a, b) => a.sort - b.sort);
         },
     updateCancel2(row) {
       console.log('点击了详情编辑取消')
@@ -2740,7 +2773,17 @@ export default {
       MessageBox.confirm('是否确认删除此信息?', {
         confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
       }).then(() => {
-        console.log(this.table2.list.length)
+        const tabelList= JSON.parse(JSON.stringify(this.table2.list));
+        const List =this.sortObjectsById(tabelList);
+        console.log(List,'哈哈哈哈哈')
+        // 若数组只有一个,无需判断.大于等于2个以上则需要判断状态
+        // 若删除第一个,则判断下一个是否是关掉状态,
+        // 若删除第n个,无需判断第一个状态值
+        if(List && List.length>=2 && List[0].id == row.id && List[1].shutdown == 1){
+            this.$message({ type: 'error', message: '需要把后面排序:第一个的‘加料前停机’改为关掉', duration: 3000 })
+            return false;
+          }
+
         let dateTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
         if (this.table2.list.length > 1) {
           this.requestParam.common = { 'returnmap': '0' }
@@ -2858,6 +2901,8 @@ export default {
           confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
         }).then(() => {
           console.log(this.table2.list.length - this.selectList2.length)
+          // 多选的话,则需要把 选中的数组 从tablelist去除,剩余数据 如果有数据,则排序第一个的数据.
+          // 需要判断第一个的状态,如果是开启,则需要让用户修改关闭; TODO:
           let dateTime = parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')
           if (this.table2.list.length - this.selectList2.length > 0) {
             this.requestParam.common = { 'returnmap': '0' }