Przeglądaj źródła

小区单位根据所选区划查询

roose 2 lat temu
rodzic
commit
6ef6ad6f1b

+ 0 - 24
ruoyi-modules/znyl-resource/src/main/java/com/ruoyi/resource/controller/ZnylKhzhController.java

@@ -5,8 +5,6 @@ import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.core.utils.SecurityUtils;
-import com.ruoyi.system.api.RemoteDeptJlService;
-import com.ruoyi.system.api.domain.SysDeptJl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -22,7 +20,6 @@ import com.ruoyi.common.security.annotation.PreAuthorize;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
 import com.ruoyi.resource.domain.ZnylKhzh;
 import com.ruoyi.resource.service.IZnylKhzhService;
 import com.ruoyi.common.core.web.controller.BaseController;
@@ -43,28 +40,7 @@ public class ZnylKhzhController extends BaseController
 {
     @Autowired
     private IZnylKhzhService znylKhzhService;
-    @Autowired
-    private RemoteDeptJlService remoteDeptJlService;
 
-    /**
-     * 区划
-     * @return
-     */
-    @GetMapping("/getDeptList")
-    public AjaxResult getDeptList()
-    {
-        SysDeptJl sysDeptJl = new SysDeptJl();
-        Long userId = SecurityUtils.getUserId();
-        if (userId != 1) {
-            if (null != SecurityUtils.getUsername()){
-                ZnylKhzh khzh = znylKhzhService.selectByAccountno(SecurityUtils.getUsername());
-                sysDeptJl = remoteDeptJlService.selectSysDeptJlByCode(khzh.getRegioncode());
-            }
-        }
-//        List<SysDeptJl> list = remoteDeptJlService.getDeptList(sysDeptJl.getId());
-        sysDeptJl = remoteDeptJlService.selectSysDeptJlById(sysDeptJl.getId());
-        return AjaxResult.success(sysDeptJl);
-    }
 
     /**
      * 查询客户账号列表

+ 53 - 2
ruoyi-modules/znyl-resource/src/main/java/com/ruoyi/resource/controller/ZnylXqdwController.java

@@ -1,7 +1,9 @@
 package com.ruoyi.resource.controller;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.io.IOException;
+import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.core.utils.SecurityUtils;
@@ -9,6 +11,8 @@ import com.ruoyi.resource.domain.ZnylKhzh;
 import com.ruoyi.resource.domain.ZnylYgry;
 import com.ruoyi.resource.service.IZnylKhzhService;
 import com.ruoyi.resource.service.IZnylYgryService;
+import com.ruoyi.system.api.RemoteDeptJlService;
+import com.ruoyi.system.api.domain.SysDeptJl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -24,7 +28,6 @@ import com.ruoyi.common.security.annotation.PreAuthorize;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
 import com.ruoyi.resource.domain.ZnylXqdw;
 import com.ruoyi.resource.service.IZnylXqdwService;
 import com.ruoyi.common.core.web.controller.BaseController;
@@ -52,6 +55,8 @@ public class ZnylXqdwController extends BaseController
     @Autowired
     private IZnylYgryService znylYgryService;
 
+    @Autowired
+    private RemoteDeptJlService remoteDeptJlService;
     /**
      * 查询智能养老_小区单位信息列表
      */
@@ -78,13 +83,59 @@ public class ZnylXqdwController extends BaseController
     }
 
     @ApiOperation(value = "查询小区单位信息列表")
-//    @PreAuthorize(hasPermi = "resource:xqdw:getXqdwList")
     @GetMapping("/getXqdwList")
     public AjaxResult getXqdwList(ZnylXqdw znylXqdw)
     {
+        if(null != znylXqdw.getRegioncode()){
+            SysDeptJl sysDeptJl = remoteDeptJlService.selectSysDeptJlByCode(znylXqdw.getRegioncode());
+            String level = String.valueOf(sysDeptJl.getLevel());
+            if (level.equals("1")) { //查全部
+                znylXqdw.setRegioncode("");
+            } else if (level.equals("2")) { // 所有下级区划
+                List<SysDeptJl> childDept = remoteDeptJlService.getDeptList(sysDeptJl.getId());
+                List<String> deptIdsList = new ArrayList<>();
+                for (int i = 0; childDept.size() > i; i++) {
+                    deptIdsList.add(childDept.get(i).getCode());
+                }
+                Map<String,Object> map = znylXqdw.getParams();
+                map.put("orgCodes",deptIdsList);
+                znylXqdw.setRegioncode("");
+                znylXqdw.setParams(map);
+            }
+        }
         return AjaxResult.success(znylXqdwService.selectZnylXqdwList(znylXqdw));
     }
 
+    /**
+     * 区划
+     * @return
+     */
+    @GetMapping("/getDeptListByCode")
+    public AjaxResult getDeptListByCode()
+    {
+        List<SysDeptJl> list = new ArrayList<>();
+        Long userId = SecurityUtils.getUserId();
+        if (userId != 1) {
+            String code = "";
+            ZnylYgry ygry = znylYgryService.selectByAccountno(SecurityUtils.getUsername());
+            if (null != ygry) {
+                code = ygry.getRegioncode();
+            } else {
+                ZnylKhzh khzh = znylKhzhService.selectByAccountno(SecurityUtils.getUsername());
+                code = khzh.getRegioncode();
+            }
+            SysDeptJl sysDeptJl = remoteDeptJlService.selectSysDeptJlByCode(code);
+//            List<SysDeptJl> list = remoteDeptJlService.getDeptList(sysDeptJl.getId());
+            list = remoteDeptJlService.getDeptList(sysDeptJl.getId());
+//            list.add(sysDeptJl);
+            return AjaxResult.success(list);
+        } else {
+            list = remoteDeptJlService.getDeptList(null);
+            return AjaxResult.success(list);
+        }
+
+    }
+
     /**
      * 导出智能养老_小区单位信息列表
      */

+ 5 - 0
ruoyi-modules/znyl-resource/src/main/resources/mapper/resource/ZnylXqdwMapper.xml

@@ -41,6 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateUnit != null "> and update_unit = #{updateUnit}</if>
             <if test="updateUnitName != null  and updateUnitName != ''"> and update_unit_name like concat('%', #{updateUnitName}, '%')</if>
             <if test="state != null "> and state = #{state}</if>
+            <if test="params.orgCodes != null  and params.orgCodes != ''"> and regioncode in
+                <foreach item="item" collection="params.orgCodes" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
         </where>
     </select>
     

+ 0 - 7
ruoyi-ui/src/api/resource/khzh.js

@@ -8,13 +8,6 @@ export function listKhzh(query) {
     params: query
   })
 }
-// 区划
-export function getDeptList() {
-  return request({
-    url: '/resource/khzh/getDeptList',
-    method: 'get'
-  })
-}
 
 // 查询客户账号详细
 export function getKhzh(id) {

+ 8 - 0
ruoyi-ui/src/api/resource/xqdw.js

@@ -15,6 +15,14 @@ export function getXqdws(query) {
     params: query
   })
 }
+
+// 区划
+export function getDeptList() {
+  return request({
+    url: '/resource/xqdw/getDeptListByCode',
+    method: 'get'
+  })
+}
 // 查询智能养老_小区单位信息详细
 export function getXqdw(id) {
   return request({

+ 1 - 1
ruoyi-ui/src/components/RegionCascaderSelect/index.vue

@@ -3,7 +3,7 @@
   <el-cascader v-if="show" ref="cascader" v-model="cascaderValue" :props="props" v-bind="options" @change="handleChange"></el-cascader>
 </template>
 <script>
-import { getDeptList } from "@/api/resource/khzh";
+import { getDeptList } from "@/api/resource/xqdw";
 
 import { CountryDeptList } from "@/api/system/jlDept";
 export default {

+ 22 - 15
ruoyi-ui/src/views/resource/jhdx/index.vue

@@ -162,7 +162,7 @@
           <RegionCascaderSelect v-model="form.regioncode"></RegionCascaderSelect>
         </el-form-item>
         <el-form-item label="小区单位" prop="communityid">
-          <el-select v-model="form.communityid" placeholder="请选择小区单位">
+          <el-select v-model="form.communityid" placeholder="请选择小区单位" @click.native="getXqdwList()">
             <el-option
               v-for="community in communityOptions"
               :key="community.id+''"
@@ -534,7 +534,7 @@ export default {
   },
   created() {
     this.getList();
-    this.getXqdwList();
+    // this.getXqdwList();
     this.getKindList();
     this.getDicts("znyl_status").then(response => {
       this.statusOptions = response.data;
@@ -574,9 +574,24 @@ export default {
       });
     },
     getXqdwList() {
-      getXqdws().then(response => {
-        this.communityOptions = response.data;
-      });
+      if(null != this.form.regioncode){
+        console.log(this.form.regioncode);
+        // 获取最后级的行政区划code
+        let xzqh='';
+        if(Array.isArray(this.form.regioncode)){
+          xzqh=this.form.regioncode[this.form.regioncode.length - 1]
+        }else{
+          let data=JSON.parse(this.form.regioncode);
+          xzqh=data[data.length - 1];
+        }
+        console.log("getXqdwList",xzqh);
+        getXqdws({regioncode:xzqh}).then(response => {
+          this.communityOptions = response.data;
+        });
+      } else {
+        alert("请选择所属区划!")
+      }
+
     },
     getKindList() {
       getYjqds().then(response => {
@@ -629,16 +644,8 @@ export default {
     },
     yjzcreset() {
       this.yjzcform = {
-//        id: null,
-//        regpersonid: null,
-//        regperson: null,
-//        regpersontype: null,
-//        regdatetime: null,
         devicenum: null,
-        productid: null,
-//        wardid: null,
-//        accountid: null,
-//        datastate: null
+        productid: null
       };
       this.resetForm("form");
     },
@@ -867,7 +874,7 @@ export default {
       }).then(function() {
         return delYjzcxx(ids);
       }).then(() => {
-        this.getList();
+        this.getYjzcList(this.wardid);
         this.msgSuccess("删除成功");
       })
     },