Преглед изворни кода

逆变器编号重复BUG修改

xusl пре 8 месеци
родитељ
комит
b76eab6b38

+ 54 - 24
ipp-ap/src/views/idp/control/inverterinfo/index.vue

@@ -104,15 +104,6 @@ export default {
     checkequipmentNo(rule, value, callback) {
       if (value == '') {
         callback(new Error('请输入设备编号'))
-      } else {
-        var s6 = this.tableData
-        for (let i = 0; i < s6.length; i++) {
-          if (this.modId != s6[i].id) {
-            if ((value == s6[i].equipmentNo)) {
-              callback(new Error('设备编号不能重复'))
-            }
-          }
-        }
       }
       callback()
     },
@@ -134,6 +125,9 @@ export default {
       this.tableLoading = true
       getStation().then(response => {
         this.stationList = response.data.data
+        if (this.stationList.length>0){
+          this.stationCode = this.stationList[0].value
+        }
         this.tableLoading = false
       })
       this.dataQuery()
@@ -152,7 +146,6 @@ export default {
         this.tableLoading = false
       })
     },
-
     rowDel: function (row, index) {
       this.$confirm('是否确认删除名称为 ' + row.name + ' 的逆变器', '提示', {
         confirmButtonText: '确定',
@@ -166,22 +159,59 @@ export default {
       })
     },
     handleUpdate: function (row, index, done, loading) {
-      putObj(row).then(data => {
-        this.$message.success('修改成功')
-        done()
-        this.dataQuery()
-      }).catch(() => {
-        loading();
-      });
+      var queryParams = {
+        stationCode:row.stationCode,
+        equipmentNo:row.equipmentNo
+      }
+      this.$axios.get('/inverterinfo/findExistEquipmentNo',{params: queryParams}).then((res) => {
+        let resData = res.data.data;
+        if (resData.length>0){
+          if (resData[0].id !=row.id){
+            this.$message.warning('设备编号已存在')
+            loading();
+          }
+          else{
+            putObj(row).then(data => {
+              this.$message.success('修改成功')
+              done()
+              this.dataQuery()
+            }).catch(() => {
+              loading();
+            });
+          }
+        }
+        else{
+          putObj(row).then(data => {
+            this.$message.success('修改成功')
+            done()
+            this.dataQuery()
+          }).catch(() => {
+            loading();
+          });
+        }
+      })
     },
     handleSave: function (row, done, loading) {
-      addObj(row).then(data => {
-        this.$message.success('添加成功')
-        done()
-        this.dataQuery()
-      }).catch(() => {
-        loading();
-      });
+      var queryParams = {
+        stationCode:row.stationCode,
+        equipmentNo:row.equipmentNo
+      }
+      this.$axios.get('/inverterinfo/findExistEquipmentNo',{params: queryParams}).then((res) => {
+        let resData = res.data.data;
+        if (resData.length>0){
+          this.$message.warning('设备编号已存在')
+          loading();
+        }
+        else{
+          addObj(row).then(data => {
+            this.$message.success('添加成功')
+            done()
+            this.dataQuery()
+          }).catch(() => {
+            loading();
+          });
+        }
+      })
     },
     sizeChange(pageSize) {
       this.page.pageSize = pageSize

+ 17 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/InverterInfoController.java

@@ -1,8 +1,10 @@
 package com.jiayue.ipp.idp.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jiayue.ipp.common.data.entity.InverterInfo;
+import com.jiayue.ipp.common.data.entity.WindTurbineInfo;
 import com.jiayue.ipp.idp.service.InverterInfoService;
 import com.jiayue.ipp.idp.util.R;
 import io.swagger.annotations.Api;
@@ -140,4 +142,19 @@ public class InverterInfoController {
         }
         return R.ok(list);
     }
+
+    /**
+     * 查找设备编号是否存在
+     *
+     * @param stationCode
+     * @return
+     */
+    @GetMapping("/findExistEquipmentNo")
+    public R findExistEquipmentNo(String stationCode,String equipmentNo) {
+        QueryWrapper<InverterInfo> wrapper = new QueryWrapper<>();
+        wrapper.eq("station_code", stationCode);
+        wrapper.eq("equipment_no", equipmentNo);
+        List<InverterInfo> inverterInfoList = inverterInfoService.list(wrapper);
+        return R.ok(inverterInfoList);
+    }
 }