Переглянути джерело

重点区域,按部门检索

lyq 1 рік тому
батько
коміт
2bc965500e

+ 16 - 2
data-ui/src/views/data/generalbusiness/importarea/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
+    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" @submit.native.prevent>
       <!--<el-form-item label="创建人姓名" prop="createName">
         <el-input
           v-model="queryParams.createName"
@@ -67,6 +67,15 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item prop="deptId">
+        <template slot="label">
+          <span @click="changeQueryType" v-if="queryParams.deptName == 0">本级及下级</span>
+          <span @click="changeQueryType" v-if="queryParams.deptName == 1">只查询本级</span>
+        </template>
+        <treeselect v-model="queryParams.deptId" :options="deptOptions" multiple:false :show-count="true"
+                    placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'" style="width: 240px"/>
+        <el-input v-model="queryParams.deptName" v-if="false"/>
+      </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -360,7 +369,7 @@
           updateName: null,
           deptStatus: null,
           deptId: null,
-          deptName: null,
+          deptName: 0,
           latitude: null,
           longitude: null,
           areaName: null,
@@ -528,6 +537,7 @@
       },
       /** 重置按钮操作 */
       resetQuery() {
+        this.queryParams.deptName = 0;
         this.resetForm("queryForm");
         this.handleQuery();
       },
@@ -590,6 +600,10 @@
         this.download('sooka-sponest-center-data/importarea/export', {
           ...this.queryParams
         }, `重点区域_${new Date().getTime()}.xlsx`)
+      },
+      // 点击按钮修改是否只查询本级部门用户
+      changeQueryType() {
+        this.queryParams.deptName = this.queryParams.deptName == 0 ? 1 : 0;
       }
     }
   };

+ 8 - 2
src/main/resources/mapper/generalbusiness/CenterdataTForestImportareaMapper.xml

@@ -51,8 +51,14 @@
             <if test="updateName != null  and updateName != ''">and update_name like concat('%', #{updateName}, '%')
             </if>
             <if test="deptStatus != null  and deptStatus != ''">and dept_status = #{deptStatus}</if>
-            <if test="deptId != null ">and dept_id = #{deptId}</if>
-            <if test="deptName != null  and deptName != ''">and dept_name like concat('%', #{deptName}, '%')</if>
+            <if test="deptId != null">
+                <choose>
+                    <when test="deptName != null and deptName == 0">
+                        and FIND_IN_SET( #{deptId}, CONCAT( d.ancestors, ",", d.dept_id) )
+                    </when>
+                    <otherwise>and d.dept_id = #{deptId}</otherwise>
+                </choose>
+            </if>
             <if test="latitude != null  and latitude != ''">and latitude = #{latitude}</if>
             <if test="areaType != null  and areaType != ''">and area_type = #{areaType}</if>
             <if test="longitude != null  and longitude != ''">and longitude = #{longitude}</if>