Kaynağa Gözat

临时提交

panlinlin 1 yıl önce
ebeveyn
işleme
e285257f24

+ 9 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java

@@ -1,6 +1,7 @@
 package com.genersoft.iot.vmp.gb28181.service.impl;
 
 import com.genersoft.iot.vmp.common.CivilCodePo;
+import com.genersoft.iot.vmp.conf.exception.ControllerException;
 import com.genersoft.iot.vmp.gb28181.bean.Region;
 import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
 import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
@@ -9,9 +10,11 @@ import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
 import com.genersoft.iot.vmp.gb28181.service.IRegionService;
 import com.genersoft.iot.vmp.utils.CivilCodeUtil;
 import com.genersoft.iot.vmp.utils.DateUtil;
+import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
@@ -45,7 +48,12 @@ public class RegionServiceImpl implements IRegionService {
         }
         region.setCreateTime(DateUtil.getNow());
         region.setUpdateTime(DateUtil.getNow());
-        regionMapper.add(region);
+        try {
+            regionMapper.add(region);
+        }catch (DuplicateKeyException e){
+            throw new ControllerException(ErrorCode.ERROR100.getCode(), "此行政区划已存在");
+        }
+
     }
 
     @Override

+ 1 - 1
web_src/src/components/common/RegionTree.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="DeviceTree">
-    <div class="page-header" style="margin-bottom: 1rem">
+    <div class="page-header" style="margin-bottom: 1rem;">
       <div class="page-title">行政区划</div>
       <div class="page-header-btn">
         <div style="display: inline;">

+ 19 - 4
web_src/src/components/region.vue

@@ -20,7 +20,7 @@
                 <el-option label="在线" value="true"></el-option>
                 <el-option label="离线" value="false"></el-option>
               </el-select>
-              <el-button size="medium" type="primary" @click="add()">
+              <el-button size="mini" type="primary" @click="add()">
                 添加
               </el-button>
             </div>
@@ -28,7 +28,7 @@
         </div>
         <el-table ref="channelListTable" :data="channelList" :height="winHeight" style="width: 100%"
                   header-row-class-name="table-header" @selection-change="handleSelectionChange">
-          <el-table-column type="selection" width="55">
+          <el-table-column type="selection" width="55" :selectable="selectable">
           </el-table-column>
           <el-table-column prop="gbName" label="名称" min-width="180">
           </el-table-column>
@@ -92,7 +92,8 @@ export default {
       total: 0,
       loading: false,
       loadSnap: {},
-      regionId: ""
+      regionId: "",
+      multipleSelection: []
     };
   },
 
@@ -138,12 +139,26 @@ export default {
       });
     },
     handleSelectionChange: function (val){
-      console.log(val)
+      this.multipleSelection = val;
+    },
+    selectable: function (row, rowIndex) {
+      if (row.civilCode) {
+        return false
+      }else {
+        return true
+      }
     },
     add: function (row) {
       if (!this.regionId) {
         this.$message.info("请选择左侧行政区划节点")
       }
+      console.log(this.regionId)
+      console.log(this.multipleSelection)
+      let channels = []
+      for (let i = 0; i < this.multipleSelection.length; i++) {
+        channels.push(this.multipleSelection[i].gbId)
+      }
+      console.log(channels)
 
     },
     remove: function (row) {