刘浩男 1 рік тому
батько
коміт
bbdd31539a

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

@@ -1,7 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px"
-             @submit.native.prevent>
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" @submit.native.prevent>
       <el-form-item label="项目名称" prop="projectName">
         <el-input
           v-model="queryParams.projectName"
@@ -31,6 +30,15 @@
           ></el-option>
         </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>
@@ -718,6 +726,7 @@ export default {
         latitude: null,
         cameraSystem: null,
         deptId: null,
+        deptName: 0,
         introduction: null,
         parkLongitude: null,
         parkLatitude: null,
@@ -1031,9 +1040,14 @@ export default {
     },
     /** 重置按钮操作 */
     resetQuery() {
+      this.queryParams.deptName = 0;
       this.resetForm("queryForm");
       this.handleQuery();
     },
+    // 点击按钮修改是否只查询本级部门用户
+    changeQueryType() {
+      this.queryParams.deptName = this.queryParams.deptName === 0 ? 1 : 0;
+    },
     resetHistoryQuery() {
       this.resetForm("historyForm");
       this.handleHistoryQuery();

+ 8 - 1
src/main/resources/mapper/generalbusiness/CenterdataTKeyProjectsMapper.xml

@@ -81,7 +81,14 @@
             <if test="longitude != null  and longitude != ''">and longitude = #{longitude}</if>
             <if test="latitude != null  and latitude != ''">and latitude = #{latitude}</if>
             <if test="cameraSystem != null  and cameraSystem != ''">and camera_system = #{cameraSystem}</if>
-            <if test="deptId != null  and deptId != ''">and dept_id = #{deptId}</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="introduction != null  and introduction != ''">and introduction = #{introduction}</if>
             <if test="territoriality != null  and territoriality != ''">and territoriality = #{territoriality}</if>
             <if test="park != null  and park != ''">and park = #{park}</if>