6
0

2 Коммитууд d6460937e7 ... 55264bb09e

Эзэн SHA1 Мессеж Огноо
  lin.liu 55264bb09e 网格员设置 2 долоо хоног өмнө
  lin.liu 888238fb53 网格员设置 2 долоо хоног өмнө
16 өөрчлөгдсөн 472 нэмэгдсэн , 72 устгасан
  1. 42 7
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/controller/GridInfoController.java
  2. 8 8
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/domain/GridPersonPO.java
  3. 11 0
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridinfo/ReqSetListPerson.java
  4. 13 0
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridinfo/SetListPersonItem.java
  5. 0 4
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridperson/ReqCreateGridPerson.java
  6. 0 4
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridperson/ReqModifyGridPerson.java
  7. 20 6
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/mapper/impl/GridPersonMapperImpl.java
  8. 56 1
      secure-producting-business/src/main/java/com/customs/cq/datacenter/business/service/GridInfoService.java
  9. 13 0
      secure-producting-host/src/main/java/com/customs/cq/datacenter/host/web/controller/system/SysDeptController.java
  10. 12 0
      secure-producting-system/src/main/java/com/customs/cq/datacenter/system/entity/response/dept/ResListUser4Department.java
  11. 10 1
      secure-producting-system/src/main/java/com/customs/cq/datacenter/system/service/ISysDeptService.java
  12. 34 0
      secure-producting-system/src/main/java/com/customs/cq/datacenter/system/service/impl/SysDeptServiceImpl.java
  13. 17 0
      secure-producting-vue/src/api/grid/GridIndex.js
  14. 8 0
      secure-producting-vue/src/api/system/dept.js
  15. 223 37
      secure-producting-vue/src/views/grid/GridIndex.vue
  16. 5 4
      sql/20240814.sql

+ 42 - 7
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/controller/GridInfoController.java

@@ -22,21 +22,24 @@
 */
 package com.customs.cq.datacenter.business.controller;
 
+import com.customs.cq.datacenter.business.domain.vo.GridInfoVO;
+import com.customs.cq.datacenter.business.domain.vo.GridPersonVO;
+import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqCreateGridInfo;
+import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqModifyGridInfo;
+import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqSetListPerson;
+import com.customs.cq.datacenter.business.entity.search.SearchGridInfo;
+import com.customs.cq.datacenter.business.service.GridInfoService;
 import com.customs.cq.datacenter.common.ExecutedResult;
 import com.customs.cq.datacenter.common.PagerResult;
+import com.customs.cq.datacenter.common.core.controller.BasicController;
+import com.customs.cq.datacenter.common.model.ReqListId;
 import com.customs.cq.datacenter.common.utils.ParameterUtil;
 import com.customs.cq.datacenter.common.validator.ParameterValidateResult;
 import com.customs.cq.datacenter.common.validator.ParameterValidator;
-import com.customs.cq.datacenter.common.core.controller.BasicController;
-import com.customs.cq.datacenter.common.model.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
 import java.util.List;
-import com.customs.cq.datacenter.business.service.GridInfoService;
-import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqCreateGridInfo;
-import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqModifyGridInfo;
-import com.customs.cq.datacenter.business.entity.search.SearchGridInfo;
-import com.customs.cq.datacenter.business.domain.vo.GridInfoVO;
 
 /**
  * 1020.网格信息
@@ -125,4 +128,36 @@ public class GridInfoController extends BasicController {
     public ExecutedResult<PagerResult<GridInfoVO>> search(@RequestBody SearchGridInfo request) {
         return this.service.search(request);
     }
+
+    /**
+     * 设置网格员
+     * @author lin.liu
+     */
+    @PostMapping(value = "setListPerson")
+    public ExecutedResult<String> setListPerson(@RequestBody ReqSetListPerson request) {
+        //#region 参数验证
+        ParameterValidator validator = new ParameterValidator()
+                // 必须大于0
+                .addGreater(ParameterUtil.named("网格id"), request.getId(), 0L)
+                // 非空
+                //.addNotNullOrEmpty(ParameterUtil.named("名称"), request.getName())
+                // 限制最大长度
+                //.addLengthMax(ParameterUtil.named("名称"), request.getName(), Constants.LENGTH_MAX50)
+                ;
+        ParameterValidateResult result = validator.validate();
+        if (result.getIsFiled()) {
+            return failed(result.getErrorMsg());
+        }
+        //#endregion
+        return this.service.setListPerson(request);
+    }
+
+    /**
+     * 获取网格员
+     * @author lin.liu
+     */
+    @GetMapping(value = "getListPerson/{id}")
+    public ExecutedResult<List<GridPersonVO>> getListPerson(@PathVariable Long id) {
+        return this.service.getListPerson(id);
+    }
 }

+ 8 - 8
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/domain/GridPersonPO.java

@@ -57,10 +57,15 @@ public class GridPersonPO {
 	@TableField(value = "GRID_ID")
 	private Long gridId;
 	/**
-	 * 姓名
+	 * 用户guid
 	 */
-	@TableField(value = "REAL_NAME")
-	private String realName;
+	@TableField(value = "USER_GUID")
+	private String userGuid;
+	/**
+	 * 用户名称
+	 */
+	@TableField(value = "USER_NAME")
+	private String userName;
 	/**
 	 * 联系方式
 	 */
@@ -71,11 +76,6 @@ public class GridPersonPO {
 	 */
 	@TableField(value = "IS_ADMIN")
 	private Integer isAdmin;
-	/**
-	 * 是否联络员
-	 */
-	@TableField(value = "IS_LIAISON")
-	private Integer isLiaison;
 	/**
 	 * 状态 EState
 	 */

+ 11 - 0
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridinfo/ReqSetListPerson.java

@@ -0,0 +1,11 @@
+package com.customs.cq.datacenter.business.entity.request.gridinfo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ReqSetListPerson {
+    private Long id;
+    private List<SetListPersonItem> listUser;
+}

+ 13 - 0
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridinfo/SetListPersonItem.java

@@ -0,0 +1,13 @@
+package com.customs.cq.datacenter.business.entity.request.gridinfo;
+
+import lombok.Data;
+
+@Data
+public class SetListPersonItem {
+    private String userGuid;
+    private String realName;
+    private Integer isAdmin;
+    private Long deptId;
+    private String deptGuid;
+    private String deptName;
+}

+ 0 - 4
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridperson/ReqCreateGridPerson.java

@@ -56,8 +56,4 @@ public class ReqCreateGridPerson {
 	 * 是否网格管理员
 	 */
 	private Integer isAdmin;
-	/**
-	 * 是否联络员
-	 */
-	private Integer isLiaison;
 }

+ 0 - 4
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/entity/request/gridperson/ReqModifyGridPerson.java

@@ -60,10 +60,6 @@ public class ReqModifyGridPerson {
 	 * 是否网格管理员
 	 */
 	private Integer isAdmin;
-	/**
-	 * 是否联络员
-	 */
-	private Integer isLiaison;
 	/**
 	 * 状态 EState
 	 */

+ 20 - 6
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/mapper/impl/GridPersonMapperImpl.java

@@ -3,17 +3,19 @@ package com.customs.cq.datacenter.business.mapper.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.customs.cq.datacenter.business.domain.GridPersonPO;
+import com.customs.cq.datacenter.business.entity.search.SearchGridPerson;
+import com.customs.cq.datacenter.business.mapper.GridPersonMapper;
+import com.customs.cq.datacenter.common.core.mapper.BasicMapper;
 import com.customs.cq.datacenter.common.enums.EOrderBy;
 import com.customs.cq.datacenter.common.enums.EYesOrNo;
-import com.customs.cq.datacenter.common.utils.ListUtil;
-import com.customs.cq.datacenter.common.utils.NumericUtil;
-import com.customs.cq.datacenter.common.core.mapper.BasicMapper;
 import com.customs.cq.datacenter.common.model.OrderByDTO;
 import com.customs.cq.datacenter.common.model.SearchBasicDTO;
+import com.customs.cq.datacenter.common.utils.ListUtil;
+import com.customs.cq.datacenter.common.utils.NumericUtil;
 import org.springframework.stereotype.Repository;
-import com.customs.cq.datacenter.business.entity.search.SearchGridPerson;
-import com.customs.cq.datacenter.business.domain.GridPersonPO;
-import com.customs.cq.datacenter.business.mapper.GridPersonMapper;
+
+import java.util.List;
 
 /**
  * 网格人员
@@ -97,4 +99,16 @@ public class GridPersonMapperImpl extends BasicMapper<GridPersonPO> {
         }
         return mapper.selectPage(new Page<>(search.getPage(), search.getLimit()), queryWrapper);
     }
+
+    public void remove4Grid(Long gridId) {
+        LambdaQueryWrapper<GridPersonPO> where = super.getQuery();
+        where.eq(GridPersonPO::getGridId, gridId);
+        mapper.delete(where);
+    }
+
+    public List<GridPersonPO> list4Grid(Long gridId) {
+        LambdaQueryWrapper<GridPersonPO> where = super.getQuery();
+        where.eq(GridPersonPO::getGridId, gridId);
+        return mapper.selectList(where);
+    }
 }

+ 56 - 1
secure-producting-business/src/main/java/com/customs/cq/datacenter/business/service/GridInfoService.java

@@ -26,13 +26,17 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.customs.cq.datacenter.business.domain.DangerCategoryPO;
 import com.customs.cq.datacenter.business.domain.GridCategoryPO;
 import com.customs.cq.datacenter.business.domain.GridInfoPO;
+import com.customs.cq.datacenter.business.domain.GridPersonPO;
 import com.customs.cq.datacenter.business.domain.vo.GridInfoVO;
+import com.customs.cq.datacenter.business.domain.vo.GridPersonVO;
 import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqCreateGridInfo;
 import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqModifyGridInfo;
+import com.customs.cq.datacenter.business.entity.request.gridinfo.ReqSetListPerson;
 import com.customs.cq.datacenter.business.entity.search.SearchGridInfo;
 import com.customs.cq.datacenter.business.mapper.impl.DangerCategoryMapperImpl;
 import com.customs.cq.datacenter.business.mapper.impl.GridCategoryMapperImpl;
 import com.customs.cq.datacenter.business.mapper.impl.GridInfoMapperImpl;
+import com.customs.cq.datacenter.business.mapper.impl.GridPersonMapperImpl;
 import com.customs.cq.datacenter.common.ExecutedResult;
 import com.customs.cq.datacenter.common.PagerResult;
 import com.customs.cq.datacenter.common.core.domain.entity.SysDept;
@@ -45,7 +49,6 @@ import com.customs.cq.datacenter.common.model.NameValueDto;
 import com.customs.cq.datacenter.common.model.Tuple;
 import com.customs.cq.datacenter.common.utils.*;
 import com.customs.cq.datacenter.system.service.ISysDeptService;
-import com.customs.cq.datacenter.system.service.impl.SysDeptServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -65,6 +68,8 @@ public class GridInfoService extends BasicService {
     private GridCategoryMapperImpl gridCategoryMapper;
     @Autowired
     private DangerCategoryMapperImpl dangerCategoryMapper;
+    @Autowired
+    private GridPersonMapperImpl gridPersonMapper;
 
 
     @Autowired
@@ -310,4 +315,54 @@ public class GridInfoService extends BasicService {
         }
         return ExecutedResult.success(exists);
     }
+
+    // 设置网格员
+    public ExecutedResult<String> setListPerson(ReqSetListPerson request) {
+        // 验证记录是否存在
+        ExecutedResult<GridInfoPO> checkExists = this.check4Id(request.getId());
+        if (checkExists.isFailed()) {
+            return ExecutedResult.failed(checkExists.getMsg());
+        }
+        // 删除已有网格员
+        gridPersonMapper.remove4Grid(request.getId());
+        // 添加新的网格员
+        if (ListUtil.isNullOrEmpty(request.getListUser())) {
+            return ExecutedResult.success();
+        }
+        Long now = LocalDateTimeUtil.nowTimeStamp();
+        // 创建人信息
+        LoginUser loginUser = LoginHelper.getLoginUser();
+        List<GridPersonPO> list = request.getListUser().stream()
+                .map(c -> {
+                    GridPersonPO item = new GridPersonPO();
+                    item.setDepartment(c.getDeptGuid());
+                    item.setDepartmentName(c.getDeptName());
+                    item.setGridId(request.getId());
+                    item.setUserGuid(c.getUserGuid());
+                    item.setUserName(c.getRealName());
+                    item.setContactInfo("");
+                    item.setIsAdmin(c.getIsAdmin());
+                    item.setStatus(EState.NORMAL.getValue());
+                    item.setCreateTime(now);
+                    if (Objects.nonNull(loginUser)) {
+                        item.setCreateBy(loginUser.getUserId().toString());
+                        item.setCreateByName(loginUser.getUsername());
+                    }
+                    return item;
+                })
+                .collect(Collectors.toList());
+        boolean setPerson = gridPersonMapper.insert(list);
+        if (setPerson) {
+            return ExecutedResult.success();
+        }
+        return ExecutedResult.failed("设置网格员失败。");
+    }
+
+    public ExecutedResult<List<GridPersonVO>> getListPerson(Long gridId) {
+        List<GridPersonPO> list = gridPersonMapper.list4Grid(gridId);
+        if (ListUtil.isNullOrEmpty(list)) {
+            return ExecutedResult.success(new ArrayList<>());
+        }
+        return ExecutedResult.success(CopierUtil.mapTo(list, GridPersonVO.class));
+    }
 }

+ 13 - 0
secure-producting-host/src/main/java/com/customs/cq/datacenter/host/web/controller/system/SysDeptController.java

@@ -2,13 +2,16 @@ package com.customs.cq.datacenter.host.web.controller.system;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.convert.Convert;
+import com.customs.cq.datacenter.common.ExecutedResult;
 import com.customs.cq.datacenter.common.annotation.Log;
 import com.customs.cq.datacenter.common.constant.UserConstants;
 import com.customs.cq.datacenter.common.core.controller.BaseController;
 import com.customs.cq.datacenter.common.core.domain.R;
 import com.customs.cq.datacenter.common.core.domain.entity.SysDept;
 import com.customs.cq.datacenter.common.enums.BusinessType;
+import com.customs.cq.datacenter.common.model.NameValueDto;
 import com.customs.cq.datacenter.common.utils.StringUtils;
+import com.customs.cq.datacenter.system.entity.response.dept.ResListUser4Department;
 import com.customs.cq.datacenter.system.service.ISysDeptService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.validation.annotation.Validated;
@@ -117,4 +120,14 @@ public class SysDeptController extends BaseController {
         deptService.checkDeptDataScope(deptId);
         return toAjax(deptService.deleteDeptById(deptId));
     }
+
+    /**
+     * 获取指定部门下的所有人员
+     * @param deptId 部门id
+     */
+    @SaCheckPermission("system:dept:query")
+    @GetMapping(value = "listUser4Department/{deptId}")
+    public ExecutedResult<List<ResListUser4Department>> listUser4Department(@PathVariable Long deptId) {
+        return deptService.listUser4Department(deptId);
+    }
 }

+ 12 - 0
secure-producting-system/src/main/java/com/customs/cq/datacenter/system/entity/response/dept/ResListUser4Department.java

@@ -0,0 +1,12 @@
+package com.customs.cq.datacenter.system.entity.response.dept;
+
+import lombok.Data;
+
+@Data
+public class ResListUser4Department {
+    private String guid;
+    private String name;
+    private Long deptId;
+    private String deptGuid;
+    private String deptName;
+}

+ 10 - 1
secure-producting-system/src/main/java/com/customs/cq/datacenter/system/service/ISysDeptService.java

@@ -1,7 +1,10 @@
 package com.customs.cq.datacenter.system.service;
 
 import cn.hutool.core.lang.tree.Tree;
+import com.customs.cq.datacenter.common.ExecutedResult;
 import com.customs.cq.datacenter.common.core.domain.entity.SysDept;
+import com.customs.cq.datacenter.common.model.NameValueDto;
+import com.customs.cq.datacenter.system.entity.response.dept.ResListUser4Department;
 
 import java.util.List;
 
@@ -125,5 +128,11 @@ public interface ISysDeptService {
      * 批量获取部门
      * @param listDept 部门id列表
      */
-    public List<SysDept> getList(List<Long> listDept);
+    List<SysDept> getList(List<Long> listDept);
+
+    /**
+     * 获取指定部门下的所有人员
+     * @param deptId 部门id
+     */
+    ExecutedResult<List<ResListUser4Department>> listUser4Department(Long deptId);
 }

+ 34 - 0
secure-producting-system/src/main/java/com/customs/cq/datacenter/system/service/impl/SysDeptServiceImpl.java

@@ -1,13 +1,18 @@
 package com.customs.cq.datacenter.system.service.impl;
 
+import cn.gov.customs.casp.sdk.h4a.entity.OrganizationChildren;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.lang.tree.Tree;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.customs.cq.datacenter.common.ExecutedResult;
 import com.customs.cq.datacenter.common.enums.EYesOrNo;
+import com.customs.cq.datacenter.common.model.NameValueDto;
 import com.customs.cq.datacenter.common.utils.StringUtil;
+import com.customs.cq.datacenter.system.entity.response.dept.ResListUser4Department;
+import com.customs.cq.datacenter.system.h4a.H4AReaderHelper;
 import com.customs.cq.datacenter.system.mapper.SysDeptMapper;
 import com.customs.cq.datacenter.common.constant.CacheNames;
 import com.customs.cq.datacenter.common.constant.UserConstants;
@@ -345,4 +350,33 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
     public List<SysDept> getList(List<Long> listDept) {
         return baseMapper.selectBatchIds(listDept);
     }
+
+    /**
+     * 获取指定部门下的所有人员
+     * @param deptId 部门id
+     */
+    public ExecutedResult<List<ResListUser4Department>> listUser4Department(Long deptId) {
+        SysDept dept = baseMapper.selectById(deptId);
+        if (Objects.isNull(dept)) {
+            return ExecutedResult.failed("部门不存在." + deptId);
+        }
+        OrganizationChildren[] list = null;
+        try {
+            list = H4AReaderHelper.getUsersInOrg(dept.getGuid());
+        } catch (Exception e) {
+            return ExecutedResult.failed("从h4a获取人员信息失败." + e.getMessage());
+        }
+        if (Objects.isNull(list)) {
+            return ExecutedResult.success(new ArrayList<>());
+        }
+        return ExecutedResult.success(Arrays.stream(list).map(c -> {
+            ResListUser4Department item = new ResListUser4Department();
+            item.setDeptId(dept.getDeptId());
+            item.setDeptGuid(dept.getGuid());
+            item.setDeptName(dept.getDeptName());
+            item.setGuid(c.getUser_guid());
+            item.setName(c.getDisplay_name());
+            return item;
+        }).collect(Collectors.toList()));
+    }
 }

+ 17 - 0
secure-producting-vue/src/api/grid/GridIndex.js

@@ -34,3 +34,20 @@ export function modify(data) {
     data: data
   })
 }
+
+// 设置网格员
+export function setListPerson(data) {
+  return request({
+    url: '/gridInfo/setListPerson',
+    method: 'post',
+    data: data
+  })
+}
+
+// 获取网格员
+export function getListPerson(id) {
+  return request({
+    url: '/gridInfo/getListPerson/' + id,
+    method: 'get'
+  })
+}

+ 8 - 0
secure-producting-vue/src/api/system/dept.js

@@ -49,4 +49,12 @@ export function delDept(deptId) {
     url: '/system/dept/' + deptId,
     method: 'delete'
   })
+}
+
+// 获取指定部门下的所有人员
+export function listUser4Department(deptId) {
+  return request({
+    url: '/system/dept/listUser4Department/' + deptId,
+    method: 'get'
+  })
 }

+ 223 - 37
secure-producting-vue/src/views/grid/GridIndex.vue

@@ -137,11 +137,11 @@
           <el-table-column label="隐患分类" align="center" prop="dangerCategoryTxt" />
           <el-table-column label="创建时间" align="center" prop="createTimeView" />
           <el-table-column label="数据创建人" align="center" prop="createByName" />
-          <el-table-column label="操作" align="center" width="150" fixed="right" class-name="small-padding fixed-width">
+          <el-table-column label="操作" align="center" width="235" fixed="right" class-name="small-padding fixed-width">
             <template #default="scope">
               <el-button
                 link
-                type="primary"
+                type="info"
                 @click="handleDetail(scope.row)"
               >详情</el-button>
               <el-button
@@ -150,6 +150,12 @@
                 icon="Edit"
                 @click="handleUpdate(scope.row)"
               >修改</el-button>
+              <el-button
+                link
+                type="warning"
+                icon="User"
+                @click="onSetUser(scope.row)"
+              >设置网格员</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -222,7 +228,7 @@
       <template #footer>
         <div class="dialog-footer">
           <el-button
-            :loading="createLoading"
+            :loading="loadingCreate"
             type="primary"
             @click="submitCreate"
             >确 定</el-button>
@@ -294,9 +300,9 @@
         <div class="dialog-footer">
           <el-button
             v-if="isDetail === false"
-            :loading="modifyLoading"
+            :loading="loadingSetUser"
             type="primary"
-            @click="submitModify"
+            @click="submitSetUser"
             >确 定</el-button
           >
           <el-button @click="cancelModify">{{ cancelModifyTxt }}</el-button>
@@ -304,14 +310,100 @@
         </div>
       </template>
     </el-dialog>
+
+
+    
+    <!-- 设置网格员对话框 -->
+    <el-dialog
+      :title="title"
+      v-model="dialogOpenSetUser"
+      width="750px"
+      append-to-body
+    >
+      <el-form
+        ref="formSetUserRef"
+        :model="formSetUser"
+        label-width="100px"
+      >
+        <el-form-item label="部门人员" prop="listUser">
+          <el-tree-select
+            :loading="loadingSetUserDeptListUser"
+            v-model="setUserDeptId"
+            :data="deptOptions"
+            @change="onSetUserDeptChange"
+            :props="{checkStrictly:true,value:'id',label:'label'}"
+            check-strictly
+            :render-after-expand="false"
+          />
+          <el-select
+            v-if="setUserDeptId"
+            v-model="setUserDeptListSelect"
+            placeholder="请选择"
+            style="width:120px;margin-left:10px;"
+            @change="onSetUserChange"
+          >
+            <el-option
+              v-for="item in setUserDeptListUser"
+              :key="item.guid"
+              :label="item.name"
+              :value="item.guid"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="已设置网格员" prop="listUser">
+          <span v-for="item in formSetUser.listUser" :key="item.userGuid" class="grid-user-container">
+            <div class="grid-user" :title="item.userealNamerName">{{item.realName}}</div>
+            <span class="grid-user-content">              
+              <el-tooltip
+                class="box-item"
+                effect="dark"
+                content="删除"
+                placement="top"
+              >
+                <span class="grid-user-close" @click="onRemoveUser(item.userGuid)">x</span>
+              </el-tooltip>
+              <el-tooltip
+                class="box-item"
+                effect="dark"
+                content="点击设置网格管理员"
+                placement="top"
+              >
+                <span :class="'grid-user-type' + (item.isAdmin===1 ? ' grid-user-admin' : ' grid-user-user')" @click="onChangeIsAdmin(item.userGuid)">{{item.isAdmin===1 ? '管' : '员'}}</span>
+              </el-tooltip>
+            </span>
+          </span>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button
+            :loading="loadingSetUser"
+            type="primary"
+            @click="submitSetUser"
+            >确 定</el-button>
+          <el-button @click="cancelSetUser">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
+<style scoped>
+  .grid-user-container{display:flex;line-height:25px;margin-right:10px;}
+  .grid-user{text-align:center;border:1px solid #53a7ff;color:#000;border-right:none;width:70px;height:25px;overflow:hidden;text-overflow:ellipsis;word-wrap:break-word;white-space:nowrap;font-size:12px;line-height:25px;border-top-left-radius:5px;border-bottom-left-radius:5px;}
+  .grid-user-content{min-width:35px;}
+  .grid-user-type{position:absolute;height:25px;width:35px;font-size:11px;padding:0 5px 0 10px;border-top-right-radius:5px;border-bottom-right-radius:5px;color:#fff;cursor:pointer;}
+  .grid-user-close{height:10px;line-height:10px;position:absolute;top:4px;margin-left:25px;z-index:999;color:#fff;cursor:pointer;}
+  .grid-user-admin{background-color:orangered;}
+  .grid-user-user{background-color:#53a7ff;}
+</style>
+
 <script setup name="GridIndex">
 import { listAllGridCategory } from "@/api/grid/GridCategory";
 import { listAllDangerCategory } from "@/api/danger/DangerCategory";
-import { detail, modify, create, search } from "@/api/grid/GridIndex";
+import { detail, modify, create, search, setListPerson, getListPerson } from "@/api/grid/GridIndex";
 import { deptTreeSelect } from "@/api/system/user";
+import { listUser4Department } from "@/api/system/dept";
 
 const { proxy } = getCurrentInstance();
 
@@ -319,22 +411,6 @@ const deptOptions = ref(undefined);
 const gridCategoryList = ref([]);
 const dangerCategoryList = ref([]);
 const dataList = ref([]);
-
-const createLoading = ref(false);
-const dialogOpenCreate = ref(false);
-
-const modifyLoading = ref(false);
-const dialogOpenModify = ref(false);
-
-const total = ref(0);
-const dateRangeCreateTime = ref([]);
-const ids = ref([]);
-const single = ref(true);
-const multiple = ref(true);
-const title = ref("");
-const cancelModifyTxt = ref("取 消");
-const isDetail = ref(false);
-
 const queryParams = ref({
   page: 1,
   limit: 10,
@@ -347,6 +423,8 @@ const queryParams = ref({
   listDangerCategory: [],
 });
 
+const loadingCreate = ref(false);
+const dialogOpenCreate = ref(false);
 const formCreate = ref({});
 const rulesCreate = ref({
   gridName: [
@@ -366,6 +444,8 @@ const rulesCreate = ref({
   gridPersonDuty: [{ max: 500, message: "网格员职责字符长度不能超过500", trigger: "blur" }],
 });
 
+const loadingModify = ref(false);
+const dialogOpenModify = ref(false);
 const formModify = ref({});
 const rulesModify = ref({
   gridName: [
@@ -386,6 +466,27 @@ const rulesModify = ref({
   status: [{ required: true, message: "状态", trigger: "blur" }],
 });
 
+const loadingSetUser = ref(false);
+const dialogOpenSetUser = ref(false);
+const formSetUser = ref({
+  id: 0,
+  deptId: undefined,
+  listUser: []
+});
+const setUserDeptId = ref(undefined);
+const loadingSetUserDeptListUser = ref(false);
+const setUserDeptListUser = ref([]);
+const setUserDeptListSelect = ref([]);
+
+const total = ref(0);
+const dateRangeCreateTime = ref([]);
+const ids = ref([]);
+const single = ref(true);
+const multiple = ref(true);
+const title = ref("");
+const cancelModifyTxt = ref("取 消");
+const isDetail = ref(false);
+
 
 
 /** 查询列表 */
@@ -453,7 +554,7 @@ function handleAdd() {
 function submitCreate() {
   proxy.$refs["formCrateRef"].validate((valid) => {
     if (valid) {
-      createLoading.value = true;
+      loadingCreate.value = true;
 
       create(formCreate.value)
         .then((response) => {
@@ -462,7 +563,7 @@ function submitCreate() {
           getList();
         })
         .finally(() => {
-          createLoading.value = false;
+          loadingCreate.value = false;
         });
     }
   });
@@ -489,12 +590,12 @@ function resetModify() {
 }
 /** 详情按钮 */
 function handleDetail(row) {
-  modifyLoading.value = true;
+  loadingModify.value = true;
   resetModify();
   const id = row.id || ids.value[0];
   detail(id).then((response) => {
     isDetail.value = true;
-    modifyLoading.value = false;
+    loadingModify.value = false;
 
     formModify.value = response.data;
 
@@ -510,12 +611,12 @@ function changeModify() {
 }
 /** 修改按钮 */
 function handleUpdate(row) {
-  modifyLoading.value = true;
+  loadingModify.value = true;
   resetModify();
   const id = row.id || ids.value[0];
   detail(id).then((response) => {
     isDetail.value = false;
-    modifyLoading.value = false;
+    loadingModify.value = false;
 
     formModify.value = response.data;
 
@@ -528,23 +629,94 @@ function handleUpdate(row) {
 function submitModify() {
   proxy.$refs["formModifyRef"].validate((valid) => {
     if (valid) {
-      modifyLoading.value = true;
+      loadingModify.value = true;
 
       modify(formModify.value)
-        .then((response) => {
-          proxy.$modal.msgSuccess("修改成功");
-          dialogOpenModify.value = false;
-          getList();
-        })
-        .finally(() => {
-          modifyLoading.value = false;
-        });
+      .then((response) => {
+        proxy.$modal.msgSuccess("修改成功");
+        dialogOpenModify.value = false;
+        getList();
+      })
+      .finally(() => {
+        loadingModify.value = false;
+      });
     }
   });
 }
 
 
 
+/** 设置网格员按钮 */
+function onSetUser(row) {
+  dialogOpenSetUser.value = true;
+  formSetUser.value = {
+    id: row.id,
+    deptId: undefined,
+    listUser: [
+    ]
+  };
+
+  // 获取现有网格员列表
+  getListPerson(row.id)
+  .then((response) => {
+    formSetUser.value.listUser = response.data;
+  })
+  .finally(() => {
+    loadingSetUser.value = false;
+  });
+}
+/** 设置网格员提交 */
+function submitSetUser() {
+    loadingSetUser.value = true;
+
+    setListPerson(formSetUser.value)
+    .then((response) => {
+      proxy.$modal.msgSuccess("设置成功");
+      dialogOpenSetUser.value = false;
+      getList();
+    })
+    .finally(() => {
+      loadingSetUser.value = false;
+    });
+}
+/** 设置网格员取消 */
+function cancelSetUser() {
+  dialogOpenSetUser.value = false;
+}
+/** 设置网格员,部门选择变化 */
+function onSetUserDeptChange(value) {
+  loadingSetUserDeptListUser.value = true;
+    loadingSetUser.value = true;
+
+  listUser4Department(value)
+  .then((response) => {    
+    setUserDeptListUser.value = response.data;
+  })
+  .finally(() => {
+    loadingSetUserDeptListUser.value = false;
+    loadingSetUser.value = false;
+  });
+}
+/** 设置网格员,人员选择变化 */
+function onSetUserChange(value) {
+  console.log('listUser: ' + JSON.stringify(formSetUser.value.listUser));
+  if (formSetUser.value.listUser.filter(c => c.userGuid === value).length > 0) {
+    return;
+  }
+  console.log('allUser: ' + JSON.stringify(setUserDeptListUser.value));
+  let findList = setUserDeptListUser.value.filter(c => c.guid === value);
+  formSetUser.value.listUser.push({
+    userGuid: value,
+    realName: findList[0].name,
+    isAdmin: 0,
+    deptId: findList[0].deptId,
+    deptGuid: findList[0].deptGuid,
+    deptName: findList[0].deptName,
+  });
+}
+
+
+
 /** 查询部门下拉树结构 */
 function getDeptTree() {
   deptTreeSelect().then(response => {
@@ -563,6 +735,20 @@ function initListDangerCategory() {
     dangerCategoryList.value = response.data;
   });
 }
+function onChangeIsAdmin(guid) {
+  let findList = formSetUser.value.listUser.filter(c => c.userGuid === guid);
+  if (!findList || findList == null || findList.length == 0) {
+    return;
+  }
+  findList[0].isAdmin = (findList[0].isAdmin === 1 ? 0 : 1);
+}
+function onRemoveUser(guid) {  
+  let findList = formSetUser.value.listUser.filter(c => c.userGuid === guid);
+  if (!findList || findList == null || findList.length == 0) {
+    return;
+  }
+  formSetUser.value.listUser = formSetUser.value.listUser.filter(c => c.userGuid != guid);
+}
 
 
 

+ 5 - 4
sql/20240814.sql

@@ -150,10 +150,10 @@ CREATE TABLE "SECURE_PRODUCTING"."SP_GRID_PERSON"(
   "DEPARTMENT" VARCHAR(50) NOT NULL DEFAULT '',
   "DEPARTMENT_NAME" VARCHAR(200) NOT NULL DEFAULT '',
   "GRID_ID" BIGINT NOT NULL DEFAULT 0,
-  "REAL_NAME" VARCHAR(50) NOT NULL DEFAULT '',
+  "USER_GUID" VARCHAR(50) NOT NULL DEFAULT '',
+  "USER_NAME" VARCHAR(50) NOT NULL DEFAULT '',
   "CONTACT_INFO" VARCHAR(50) NOT NULL DEFAULT '',
   "IS_ADMIN" TINYINT NOT NULL DEFAULT 0,
-  "IS_LIAISON" TINYINT NOT NULL DEFAULT 0,
   "STATUS" TINYINT NOT NULL DEFAULT 0,
   "CREATE_TIME" BIGINT NOT NULL DEFAULT 0,
   "UPDATE_TIME" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(),
@@ -168,6 +168,7 @@ CREATE TABLE "SECURE_PRODUCTING"."SP_GRID_PERSON"(
 -- 索引
 CREATE INDEX IDX_SP_GRID_PERSON_DEPARTMENT ON "SECURE_PRODUCTING"."SP_GRID_PERSON"("DEPARTMENT");
 CREATE INDEX IDX_SP_GRID_PERSON_GRID_ID ON "SECURE_PRODUCTING"."SP_GRID_PERSON"("GRID_ID");
+CREATE INDEX IDX_SP_GRID_PERSON_USER_GUID ON "SECURE_PRODUCTING"."SP_GRID_PERSON"("USER_GUID");
 CREATE INDEX IDX_SP_GRID_PERSON_STATUS ON "SECURE_PRODUCTING"."SP_GRID_PERSON"("STATUS");
 CREATE INDEX IDX_SP_GRID_PERSON_CREATE_TIME ON "SECURE_PRODUCTING"."SP_GRID_PERSON"("CREATE_TIME");
 -- 触发器:自动赋值最后修改时间
@@ -183,10 +184,10 @@ COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."ID" IS '主键';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."DEPARTMENT" IS '所属部门';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."DEPARTMENT_NAME" IS '部门名称';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."GRID_ID" IS '所属网格';
-COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."REAL_NAME" IS '姓名';
+COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."USER_GUID" IS '用户guid';
+COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."USER_NAME" IS '用户名称';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."CONTACT_INFO" IS '联系方式';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."IS_ADMIN" IS '是否网格管理员';
-COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."IS_LIAISON" IS '是否联络员';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."STATUS" IS '状态 EState';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."CREATE_TIME" IS '数据创建时间';
 COMMENT ON COLUMN "SECURE_PRODUCTING". "SP_GRID_PERSON"."UPDATE_TIME" IS '最后更新时间';