East пре 4 година
родитељ
комит
2741decca5

+ 25 - 0
src/views/modules/basicdata/bperiod.vue

@@ -305,6 +305,11 @@ export default {
               type: 'success',
               duration: 1000
             })
+            // pageIndex修正
+            this.totalPage -= this.selectionDataList.length
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+            this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
           } else {
             this.$message.error('删除栏期失败');
           }
@@ -343,6 +348,16 @@ export default {
               duration: 1000
             })
           } else {
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split('-')
+              this.$message({
+                message: `栏期编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
             this.$message.error('修改栏期信息失败');
           }
         })
@@ -375,6 +390,16 @@ export default {
               duration: 1000
             })
           } else {
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split('-')
+              this.$message({
+                message: `栏期编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
             this.$message.error('添加失败');
           }
         })

+ 73 - 34
src/views/modules/basicdata/bpighouse.vue

@@ -270,41 +270,46 @@ export default {
         cancelButtonText: "取消",
         type: "warning",
       })
-        .then(() => {
-          // 删除操作
-          if (id) {
-            this.selectionDataList.push(id);
-          }
-          if (this.selectionDataList.length <= 0) {
-            return;
+      .then(() => {
+        // 删除操作
+        if (id) {
+          this.selectionDataList.push(id);
+        }
+        if (this.selectionDataList.length <= 0) {
+          return;
+        }
+        this.$http({
+          url: this.$http.adornUrl("/management/pigsty/delete"),
+          method: "post",
+          data: this.$http.adornData(this.selectionDataList, false),
+        }).then((result) => {
+          console.log(result);
+          if (result.data.code === 0) {
+            this.$message({
+              message: "成功删除猪舍",
+              type: "success",
+              duration: 1000,
+            })
+            // pageIndex修正
+            this.totalPage -= this.selectionDataList.length
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+            this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
+          } else {
+            // this.$message.error('删除失败:' + result.data.msg)
+            this.$confirm(result.data.msg, '删除失败', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }).then(() => {
+              console.log('猪舍编号输入不合法')
+            }).catch(() => {})
           }
-          this.$http({
-            url: this.$http.adornUrl("/management/pigsty/delete"),
-            method: "post",
-            data: this.$http.adornData(this.selectionDataList, false),
-          }).then((result) => {
-            console.log(result);
-            if (result.data.code === 0) {
-              this.$message({
-                message: "成功删除猪舍",
-                type: "success",
-                duration: 1000,
-              });
-            } else {
-              // this.$message.error('删除失败:' + result.data.msg)
-              this.$confirm(result.data.msg, '删除失败', {
-                confirmButtonText: '确定',
-                cancelButtonText: '取消',
-                type: 'warning'
-              }).then(() => {
-                console.log('猪舍编号输入不合法')
-              }).catch(() => {})
-            }
-            this.resetForm();
-            this.selectionDataList = [];
-          });
-        })
-        .catch(() => {});
+          this.resetForm();
+          this.selectionDataList = [];
+        });
+      })
+      .catch(() => {});
     },
     formSubmit() {
       if (this.form.id) {
@@ -337,6 +342,23 @@ export default {
               duration: 1000,
             })
           } else {
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split('-')
+              let pasture = ''
+              for (let item of this.pastureList) {
+                if (this.form.pastureId === item.id) {
+                  pasture = item.name
+                  break
+                }
+              }
+              this.$message({
+                message: `${pasture}中猪舍编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
             this.$message.error("修改猪舍信息失败");
           }
         })
@@ -369,6 +391,23 @@ export default {
               duration: 1000,
             });
           } else {
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split('-')
+              let pasture = ''
+              for (let item of this.pastureList) {
+                if (this.form.pastureId === item.id) {
+                  pasture = item.name
+                  break
+                }
+              }
+              this.$message({
+                message: `${pasture}中猪舍编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
             this.$message.error("添加猪舍失败");
           }
         })

+ 28 - 2
src/views/modules/basicdata/branch.vue

@@ -301,6 +301,11 @@ export default {
               type: 'success',
               duration: 1000
             })
+            // pageIndex修正
+            this.totalPage -= this.selectionDataList.length
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+            this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
           } else {
             this.$confirm(result.data.msg, '删除失败', {
               confirmButtonText: '确定',
@@ -353,7 +358,17 @@ export default {
               duration: 1000
             })
           } else {
-            this.$message.error('修改牧场信息失败');
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split(' ')
+              this.$message({
+                message: `牧场名称 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
+            this.$message.error(result.data.msg);
           }
         })
       } else {
@@ -391,7 +406,18 @@ export default {
               duration: 1000
             })
           } else {
-            this.$message.error('添加牧场失败');
+            if (result.data.code === 600) {
+              // this.$message.error('牧场名称 ' + result.data.msg)
+              let msg = result.data.msg.split(' ')
+              this.$message({
+                message: `牧场名称 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
+            this.$message.error(result.data.msg)
           }
         })
       }

+ 25 - 0
src/views/modules/basicdata/bunit.vue

@@ -305,6 +305,11 @@ export default {
               type: 'success',
               duration: 1000
             })
+            // pageIndex修正
+            this.totalPage -= this.selectionDataList.length
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+            this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
           } else {
             this.$message.error('删除单元失败');
           }
@@ -343,6 +348,16 @@ export default {
               duration: 1000
             })
           } else {
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split('-')
+              this.$message({
+                message: `单元编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
             this.$message.error('修改单元信息失败');
           }
         })
@@ -375,6 +390,16 @@ export default {
               duration: 1000
             })
           } else {
+            if (result.data.code === 600) {
+              let msg = result.data.msg.split('-')
+              this.$message({
+                message: `单元编号 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+                type: "error",
+                duration: 1000,
+                dangerouslyUseHTMLString: true
+              })
+              return
+            }
             this.$message.error('添加失败');
           }
         })

+ 7 - 0
src/views/modules/pigbasic/pbbasic.vue

@@ -598,6 +598,11 @@ export default {
               type: 'success',
               duration: 1000
             })
+            // pageIndex修正
+            this.totalPage -= this.selectionDataList.length
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+            this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
           } else {
             this.$message.error('删除年猪失败');
           }
@@ -647,6 +652,7 @@ export default {
               duration: 1000
             })
           } else {
+            // TODO: 年猪耳边重复
             this.$message.error('修改年猪信息失败');
           }
         })
@@ -689,6 +695,7 @@ export default {
               duration: 1000
             })
           } else {
+            // TODO: 年猪耳标重复
             this.$message.error('添加年猪失败');
           }
         })

+ 6 - 0
src/views/modules/pigfarm/pfperson.vue

@@ -264,6 +264,11 @@ export default {
               type: 'success',
               duration: 1000
             })
+            // pageIndex修正
+            this.totalPage -= this.selectionDataList.length
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+            this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
           } else {
             this.$message.error('删除养殖员信息失败');
           }
@@ -341,6 +346,7 @@ export default {
                 type: 'success',
                 duration: 1000
               })
+              // TODO: 新增的pageIndex修正
             } else {
               this.$message.error('添加养殖员信息失败');
             }