瀏覽代碼

本周没事了

East 4 年之前
父節點
當前提交
31322ec09a

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

@@ -382,6 +382,10 @@ export default {
           })
         }).then(result => {
           if (result.data.code === 0) {
+            // 新增pageIndex的修正
+            this.totalPage++
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
             this.resetForm();
             this.visible = false;
             this.$message({

+ 4 - 0
src/views/modules/basicdata/bpighouse.vue

@@ -383,6 +383,10 @@ export default {
           }),
         }).then((result) => {
           if (result.data.code === 0) {
+            // 新增pageIndex的修正
+            this.totalPage++
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
             this.resetForm();
             this.visible = false;
             this.$message({

+ 7 - 3
src/views/modules/basicdata/branch.vue

@@ -251,6 +251,7 @@ export default {
       // 显示牧场新增 or 修改面板
       this.visible = true
       if (row) {
+        console.log(row);
         let location = row.location
         let arr = location.split(",")
         this.form.selectedOptions = []
@@ -359,7 +360,7 @@ export default {
             })
           } else {
             if (result.data.code === 600) {
-              let msg = result.data.msg.split(' ')
+              let msg = result.data.msg.split('-')
               this.$message({
                 message: `牧场名称 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
                 type: "error",
@@ -398,6 +399,10 @@ export default {
           })
         }).then(result => {
           if (result.data.code === 0) {
+            // 新增pageIndex的修正
+            this.totalPage++
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
             this.resetForm();
             this.visible = false;
             this.$message({
@@ -407,8 +412,7 @@ export default {
             })
           } else {
             if (result.data.code === 600) {
-              // this.$message.error('牧场名称 ' + result.data.msg)
-              let msg = result.data.msg.split(' ')
+              let msg = result.data.msg.split('-')
               this.$message({
                 message: `牧场名称 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
                 type: "error",

+ 5 - 1
src/views/modules/basicdata/bunit.vue

@@ -265,10 +265,10 @@ export default {
       // 显示牧场新增 or 修改面板
       this.visible = true
       if (row) {
-        this.form.id = row.id
         for (let key of Object.keys(this.form)) {
           this.form[key] = row[key]
         }
+        this.form.id = row.id
       }
     },
     // 选择n个牧场
@@ -340,6 +340,10 @@ export default {
           })
         }).then(result => {
           if (result.data.code === 0) {
+            // 新增pageIndex的修正
+            this.totalPage++
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
             this.resetForm();
             this.visible = false;
             this.$message({

+ 29 - 1
src/views/modules/pigbasic/pbbasic.vue

@@ -652,7 +652,19 @@ export default {
               duration: 1000
             })
           } else {
-            // TODO: 年猪耳边重复
+            // TODO: 年猪耳标重复
+            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
+              // })
+              this.$message.error(result.data.msg);
+              return
+            }
             this.$message.error('修改年猪信息失败');
           }
         })
@@ -687,6 +699,10 @@ export default {
           })
         }).then(result => {
           if (result.data.code === 0) {
+            // 新增pageIndex的修正
+            this.totalPage++
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
             this.resetForm()
             this.visible = false;
             this.$message({
@@ -696,6 +712,18 @@ export default {
             })
           } else {
             // TODO: 年猪耳标重复
+            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
+              // })
+              this.$message.error(result.data.msg);
+              return
+            }
             this.$message.error('添加年猪失败');
           }
         })

+ 86 - 81
src/views/modules/pigfarm/pfperson.vue

@@ -229,7 +229,10 @@ export default {
       // 显示谱系新增 or 修改面板
       this.visible = true
       if (row) {
-        this.form = row
+        for (let key of Object.keys(this.form)) {
+          this.form[key] = row[key]
+        }
+        this.form.id = row.id
       }
     },
     // 选择n个养殖员
@@ -280,92 +283,80 @@ export default {
     formSubmit () {
       if (this.form.id) {
         // 修改
-        if (this.confirmInput()) {
-          // 检查入场时间、离开场时间
-          if (!this.confirmJobStatus()) {
-            return
-          }
-          // 进行修改操作
-          this.$http({
-            url: this.$http.adornUrl('/management/employee/update'),
-            method: 'post',
-            data: this.$http.adornData({
-              id: this.form.id,
-              position: this.form.position,
-              approachTime: this.form.approachTime,
-              departureTime: this.form.departureTime,
-              jobStatus: this.form.jobStatus
-            })
-          }).then(result => {
-            if (result.data.code === 0) {
-              this.resetForm();
-              this.visible = false;
-              this.$message({
-                message: '成功修改养殖员信息',
-                type: 'success',
-                duration: 1000
-              })
-            } else {
-              this.$message.error('修改养殖员信息失败');
-            }
-          })
-        } else {
-          // 请输入完整
-          this.$confirm(`请输入完整`, '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }).then(() => {
-            return
-          }).catch(() => {})
+        if (!this.confirmComplete()) {
+          return
         }
-      } else {
-        // 新增
-        if (this.confirmInput(1)) {
-          // 检查入场时间、立场时间、当前在岗
-          if (!this.confirmJobStatus()) {
-            return
-          }
-          // 进行新增操作
-          this.$http({
-            url: this.$http.adornUrl('/management/employee/save'),
-            method: 'post',
-            data: this.$http.adornData({
-              name: this.form.name,
-              position: this.form.position,
-              approachTime: this.form.approachTime,
-              departureTime: this.form.departureTime,
-              jobStatus: this.form.jobStatus
-            })
-          }).then(result => {
-            if (result.data.code === 0) {
-              this.resetForm();
-              this.visible = false;
-              this.$message({
-                message: '成功添加养殖员信息',
-                type: 'success',
-                duration: 1000
-              })
-              // TODO: 新增的pageIndex修正
-            } else {
-              this.$message.error('添加养殖员信息失败');
-            }
+        // 检查入场时间、离开场时间
+        if (!this.confirmJobStatus()) {
+          return
+        }
+        // 进行修改操作
+        this.$http({
+          url: this.$http.adornUrl('/management/employee/update'),
+          method: 'post',
+          data: this.$http.adornData({
+            id: this.form.id,
+            position: this.form.position,
+            approachTime: this.form.approachTime,
+            departureTime: this.form.departureTime,
+            jobStatus: this.form.jobStatus
           })
-        } else {
-          // 请输入完整
-          this.$confirm(`请输入完整`, '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }).then(() => {
-            return
-          }).catch(() => {})
+        }).then(result => {
+          if (result.data.code === 0) {
+            this.resetForm();
+            this.visible = false;
+            this.$message({
+              message: '成功修改养殖员信息',
+              type: 'success',
+              duration: 1000
+            })
+          } else {
+            this.$message.error('修改养殖员信息失败');
+          }
+        })
+      } else {
+        /** 新增 */
+        // 输入是否完整
+        if (!this.confirmComplete(1)) {
+          return
+        }
+        // 检查入场时间、立场时间、当前在岗
+        if (!this.confirmJobStatus()) {
+          return
         }
+        // 进行新增操作
+        this.$http({
+          url: this.$http.adornUrl('/management/employee/save'),
+          method: 'post',
+          data: this.$http.adornData({
+            name: this.form.name,
+            position: this.form.position,
+            approachTime: this.form.approachTime,
+            departureTime: this.form.departureTime,
+            jobStatus: this.form.jobStatus
+          })
+        }).then(result => {
+          if (result.data.code === 0) {
+            // 新增pageIndex的修正
+            this.totalPage++
+            let pages = Math.ceil(this.totalPage / this.pageSize)
+            this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
+            this.resetForm();
+            this.visible = false;
+            this.$message({
+              message: '成功添加养殖员信息',
+              type: 'success',
+              duration: 1000
+            })
+          } else {
+            this.$message.error('添加养殖员信息失败');
+          }
+        })
       }
     },
     // 判断新增/修改时是否输入完整
-    confirmInput (val) {
-      val && (delete this.form.id, delete this.form.deleted, delete this.form.gmtCreate, delete this.form.gmtModified)
+    validComplete (val) {
+      val && (delete this.form.id)
       for (let i in this.form) {
         if (!this.form[i].toString()) {
           return false
@@ -373,6 +364,20 @@ export default {
       }
       return true
     },
+    // 如不完整,则提示
+    confirmComplete (val) {
+      if (this.validComplete(val)) {
+        return true
+      }
+      this.$confirm(`请输入完整`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        console.log('输入不完整');
+      }).catch(() => {})
+      return false
+    },
     // 清空form
     resetForm () {
       for (let i in this.form) {