Quellcode durchsuchen

fead:科室管理

lsw vor 9 Monaten
Ursprung
Commit
4bbb1dfdfc

+ 1 - 1
admin-ui/src/views/monitor/online/index.vue

@@ -14,7 +14,7 @@
         </template>
       </el-table-column>
       <el-table-column label="账号" align="center" prop="userName" :show-overflow-tooltip="true" />
-      <el-table-column label="部门" align="center" prop="deptName" />
+      <el-table-column label="科室" align="center" prop="deptName" />
       <el-table-column label="主机" align="center" prop="ipaddr" :show-overflow-tooltip="true" />
       <el-table-column label="登录地点" align="center" prop="loginLocation" :show-overflow-tooltip="true" />
       <el-table-column label="浏览器" align="center" prop="browser" />

+ 112 - 0
admin-ui/src/views/system/dept/edit.vue

@@ -0,0 +1,112 @@
+<template>
+  <div class="cmain">
+    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+      <el-form-item label="上级科室" prop="parentId" v-if="form.parentId !== 0">
+        <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级科室" />
+      </el-form-item>
+      <el-form-item label="科室名称" prop="deptName"><el-input v-model="form.deptName" placeholder="请输入科室名称" /></el-form-item>
+      <div v-if="form.parentId != 0 && form.ancestors.length == 3">
+        <el-form-item label="科室介绍" prop="brief">
+          <editor v-model="form.brief" placeholder="请输入"></editor>
+        </el-form-item>
+      </div>
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="显示排序" prop="orderNum"><el-input-number v-model="form.orderNum" controls-position="right" :min="0" /></el-form-item>
+        </el-col>
+        <el-col :span="8">
+          <el-form-item label="科室状态">
+            <el-radio-group v-model="form.status">
+              <el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <div class="mfooter">
+      <el-button type="primary" @click="submitForm">确 定</el-button>
+      <el-button @click="$layer.close(layerid)">取 消</el-button>
+    </div>
+  </div>
+</template>
+
+<script>
+import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from '@/api/system/dept';
+import Treeselect from '@riophae/vue-treeselect';
+import '@riophae/vue-treeselect/dist/vue-treeselect.css';
+export default {
+  dicts: ['sys_normal_disable'],
+  components: { Treeselect },
+  data() {
+    return {
+      form: { ancestors: [], brief: '', status: '0' },
+      deptOptions: [],
+      rules: {
+        parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
+        deptName: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
+        brief: [{ required: true, message: '科室介绍不能为空', trigger: 'blur' }],
+        orderNum: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }]
+      }
+    };
+  },
+  mounted() {
+    if (this.param.id) {
+      getDept(this.param.id).then((response) => {
+        this.form = response.data;
+        this.form.ancestors = this.form.ancestors.split(',') || [];
+        listDeptExcludeChild(this.param.id).then((response) => {
+          this.deptOptions = this.handleTree(response.data, 'deptId');
+          if (this.deptOptions.length == 0) {
+            const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] };
+            this.deptOptions.push(noResultsOptions);
+          }
+        });
+      });
+    } else {
+      listDept().then((response) => {
+        this.deptOptions = this.handleTree(response.data, 'deptId');
+      });
+      this.form.parentId = this.param.parentId;
+      this.form.ancestors = this.param.ancestors;
+      this.form.ancestors.push(1);
+      console.log('asd:' + this.form.ancestors);
+      console.log('asd:' + this.form.parentId);
+      this.$forceUpdate();
+    }
+  },
+  methods: {
+    /** 转换部门数据结构 */
+    normalizer(node) {
+      if (node.children && !node.children.length) {
+        delete node.children;
+      }
+      return {
+        id: node.deptId,
+        label: node.deptName,
+        children: node.children
+      };
+    },
+    submitForm: function () {
+      this.$refs['form'].validate((valid) => {
+        if (valid) {
+          let data = JSON.parse(JSON.stringify(this.form));
+          data.ancestors = data.ancestors.toString();
+          if (this.form.deptId != undefined) {
+            updateDept(data).then((response) => {
+              this.$modal.msgSuccess('修改成功');
+              this.$layer.close(this.layerid);
+              this.$parent.getList();
+            });
+          } else {
+            addDept(data).then((response) => {
+              this.$modal.msgSuccess('新增成功');
+              this.$layer.close(this.layerid);
+              this.$parent.getList();
+            });
+          }
+        }
+      });
+    }
+  }
+};
+</script>

+ 32 - 48
admin-ui/src/views/system/dept/index.vue

@@ -1,41 +1,32 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" >
-      <el-form-item label="部门名称" prop="deptName">
+    <el-form :model="queryParams" ref="queryForm" :inline="true">
+      <el-form-item label="科室名称" prop="deptName">
         <el-input v-model="queryParams.deptName" placeholder="请输入部门名称" clearable @keyup.enter.native="handleQuery" class="se" />
       </el-form-item>
-      <el-form-item label="状态" prop="status">
-        <el-select v-model="queryParams.status" placeholder="部门状态" clearable>
+      <el-form-item label="科室状态" prop="status">
+        <el-select v-model="queryParams.status" placeholder="科室状态" clearable class="se">
           <el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
         </el-select>
       </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
+        <el-button type="info" icon="el-icon-sort" @click="toggleExpandAll">展开/折叠</el-button>
       </el-form-item>
     </el-form>
-
-    <el-row :gutter="10" class="mb8">
-      <el-col :span="1.5"><el-button type="info" icon="el-icon-sort" @click="toggleExpandAll">展开/折叠</el-button></el-col>
-    </el-row>
-
     <el-table v-if="refreshTable" :data="deptList" row-key="deptId" :default-expand-all="isExpandAll" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
-      <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
-      <el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
-      <el-table-column prop="status" label="状态" width="100">
+      <el-table-column prop="deptName" label="科室名称"/>
+      <el-table-column prop="orderNum" label="科室排序" align="center" width="200"/>
+      <el-table-column prop="status" label="科室状态" align="center" width="100">
         <template slot-scope="scope">
           <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status" />
         </template>
       </el-table-column>
-      <el-table-column label="创建时间" align="center" prop="createTime" width="200">
-        <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.createTime) }}</span>
-        </template>
-      </el-table-column>
-      <el-table-column label="操作" align="center">
+      <el-table-column label="操作" align="center" width="220">
         <template slot-scope="scope">
           <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']">修改</el-button>
-          <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']">新增</el-button>
+          <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']" v-if="scope.row.ancestors.length < 3">新增</el-button>
           <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']">删除</el-button>
         </template>
       </el-table-column>
@@ -45,12 +36,15 @@
     </el-table>
 
     <!-- 添加或修改部门对话框 -->
-    <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="600px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" v-if="open" :close-on-click-modal="false" width="60%" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="上级科室" prop="parentId" v-if="form.parentId !== 0">
           <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级科室" />
         </el-form-item>
         <el-form-item label="科室名称" prop="deptName"><el-input v-model="form.deptName" placeholder="请输入科室名称" /></el-form-item>
+        <el-form-item label="科室介绍" prop="brief" v-if="open && form.parentId != 0 && form.ancestors.length == 3">
+          <editor v-model="form.brief" placeholder="请输入"></editor>
+        </el-form-item>
         <el-form-item label="显示排序" prop="orderNum"><el-input-number v-model="form.orderNum" controls-position="right" :min="0" /></el-form-item>
         <el-form-item label="科室状态">
           <el-radio-group v-model="form.status">
@@ -70,7 +64,7 @@
 import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from '@/api/system/dept';
 import Treeselect from '@riophae/vue-treeselect';
 import '@riophae/vue-treeselect/dist/vue-treeselect.css';
-
+import edit from './edit';
 export default {
   name: 'Dept',
   dicts: ['sys_normal_disable'],
@@ -102,21 +96,8 @@ export default {
       rules: {
         parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
         deptName: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
-        orderNum: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }],
-        email: [
-          {
-            type: 'email',
-            message: '请输入正确的邮箱地址',
-            trigger: ['blur', 'change']
-          }
-        ],
-        phone: [
-          {
-            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
-            message: '请输入正确的手机号码',
-            trigger: 'blur'
-          }
-        ]
+        brief: [{ required: true, message: '科室介绍不能为空', trigger: 'blur' }],
+        orderNum: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }]
       }
     };
   },
@@ -127,6 +108,13 @@ export default {
     /** 查询部门列表 */
     getList() {
       listDept(this.queryParams).then((response) => {
+        response.data.forEach((item) => {
+          if (item.ancestors) {
+            item.ancestors = item.ancestors.split(',');
+          } else {
+            item.ancestors = [];
+          }
+        });
         this.deptList = this.handleTree(response.data, 'deptId');
       });
     },
@@ -171,15 +159,7 @@ export default {
     },
     /** 新增按钮操作 */
     handleAdd(row) {
-      this.reset();
-      if (row != undefined) {
-        this.form.parentId = row.deptId;
-      }
-      this.open = true;
-      this.title = '添加科室';
-      listDept().then((response) => {
-        this.deptOptions = this.handleTree(response.data, 'deptId');
-      });
+      this.iframe({ obj: edit, param: { parentId: row.deptId, ancestors: row.ancestors }, title: '新增科室', width: '55%', height: '75%' });
     },
     /** 展开/折叠操作 */
     toggleExpandAll() {
@@ -191,11 +171,13 @@ export default {
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-      this.reset();
+      this.iframe({ obj: edit, param: { id: row.deptId }, title: '编辑科室', width: '55%', height: '75%' });
+      /*      this.reset();
       this.open = true;
       this.title = '修改科室';
       getDept(row.deptId).then((response) => {
         this.form = response.data;
+        this.form.ancestors = this.form.ancestors.split(',') || [];
         listDeptExcludeChild(row.deptId).then((response) => {
           this.deptOptions = this.handleTree(response.data, 'deptId');
           if (this.deptOptions.length == 0) {
@@ -203,14 +185,16 @@ export default {
             this.deptOptions.push(noResultsOptions);
           }
         });
-      });
+      }); */
     },
     /** 提交按钮 */
     submitForm: function () {
       this.$refs['form'].validate((valid) => {
         if (valid) {
           if (this.form.deptId != undefined) {
-            updateDept(this.form).then((response) => {
+            let data = JSON.parse(JSON.stringify(this.form));
+            data.ancestors = data.ancestors.toString();
+            updateDept(data).then((response) => {
               this.$modal.msgSuccess('修改成功');
               this.open = false;
               this.getList();

+ 3 - 3
admin-ui/src/views/system/user/index.vue

@@ -51,13 +51,13 @@
 					</el-col>
 					<el-col :span="1.5"><el-button type="info" icon="el-icon-upload2" @click="handleImport" v-hasPermi="['system:user:import']">导入</el-button></el-col>
 					<el-col :span="1.5"><el-button type="warning" icon="el-icon-download" @click="handleExport" v-hasPermi="['system:user:export']">导出</el-button></el-col>
-					
+
 				</el-row>
 				<el-table border :data="userList" @selection-change="handleSelectionChange" height="calc(100vh - 273px)">
 					<el-table-column type="selection" align="center" width="50" />
 					<el-table-column label="账号" align="center" key="userName" prop="userName" :show-overflow-tooltip="true" width="110" />
 					<el-table-column label="姓名" align="center" key="nickName" prop="nickName" :show-overflow-tooltip="true" width="110" />
-					<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" :show-overflow-tooltip="true" />
+					<el-table-column label="科室" align="center" key="deptName" prop="dept.deptName" :show-overflow-tooltip="true" />
 					<el-table-column label="手机号" align="center" key="phonenumber" prop="phonenumber" width="120" />
 					<el-table-column label="状态" align="center" key="status" width="100">
 						<template slot-scope="scope">
@@ -141,7 +141,7 @@
 						</el-form-item>
 					</el-col>
 					<el-col :span="12">
-						<el-form-item label="部门" prop="deptId">
+						<el-form-item label="科室" prop="deptId">
 							<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属部门" />
 						</el-form-item>
 					</el-col>

+ 9 - 4
app/common/common.scss

@@ -74,13 +74,14 @@
 	}
 	.left {
 		position: fixed;
-		width: 25%;
+		width: 33%;
 		overflow-y: auto;
 		z-index: 2;
 		height: 95%;
 		.item {
 			padding: 13px 8px 13px 8px;
 			font-size: 14px;
+			text-align: center;
 			&.active {
 				background-color: white;
 				color: $main-color;
@@ -90,11 +91,15 @@
 	.right {
 		position: fixed;
 		height: 100%;
-		width: 80%;
+		width: 67%;
 		overflow-y: auto;
-		left: 25%;
+		left: 33%;
 		z-index: 1;
 		background-color: white;
+		.contents{
+			padding: 10px 10px 50px 10px;
+			font-size: 14px;
+		}
 		.list {
 			padding: 10px 10px 85px 10px;
 			.item {
@@ -165,4 +170,4 @@
 	.a {
 		color: blue;
 	}
-}
+}

+ 7 - 0
app/pages.json

@@ -77,6 +77,13 @@
 			{
 				"navigationBarTitleText" : "我的回访"
 			}
+		},
+		{
+			"path" : "pages/department/index",
+			"style" : 
+			{
+				"navigationBarTitleText" : "科室介绍"
+			}
 		}
 	],
 	"tabBar": {

+ 55 - 0
app/pages/department/index.vue

@@ -0,0 +1,55 @@
+<template>
+	<view class="msilde">
+		<view class="left">
+			<u-collapse accordion @open="current = -1">
+				<u-collapse-item :title="d.deptName" name="Docs guide" v-for="(d, index) in list" :key="d.deptName">
+					<view :class="{ active: index == current }" v-for="(i, index) in d.children" :key="i.deptName" class="item" @click="selected(i, index)">{{ i.deptName }}</view>
+				</u-collapse-item>
+			</u-collapse>
+		</view>
+		<view class="right">
+			<view class="contents">
+				<u-divider :text="item.deptName + '介绍'" v-if="item.deptName"></u-divider>
+				<image src="https://omo-oss-image.thefastimg.com/portal-saas/new2022102818501904409/cms/image/29a676ec-abc2-48fe-8657-ce8f05f8ceb2.jpg" mode="widthFix" style="width: 100%;height: 150px;" v-else></image>
+				<u-parse :content="item.brief"></u-parse>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+export default {
+	data() {
+		return {
+			item: {},
+			current: -1,
+			list: []
+		};
+	},
+	onLoad(e) {
+		this.getData();
+	},
+	methods: {
+		getData() {
+			this.http.request({
+				url: '/app/department/list',
+				success: (res) => {
+					this.list = res.data.data;
+				}
+			});
+		},
+		selected(item, index) {
+			this.current = index;
+			this.http.request({
+				url: '/app/department/detail/' + item.deptId,
+				success: (res) => {
+					this.item = res.data.data;
+					this.item.brief = res.data.data.brief.replace(new RegExp('/profile/upload/', 'g'), this.http.ip + '/profile/upload/');
+				}
+			});
+		}
+	}
+};
+</script>
+
+<style lang="scss"></style>

+ 1 - 1
app/pages/index/index.vue

@@ -10,7 +10,7 @@
 					</view>
 				</view>
 			</view>
-			<view class="item" @click="go()">
+			<view class="item" @click="go('/pages/department/index')">
 				<view class="out">
 					<view class="int">
 						<view class="icon" style="color: rgb(72, 154, 253)">&#xe752;</view>

+ 1 - 3
app/uni_modules/uview-ui/components/u-collapse-item/u-collapse-item.vue

@@ -15,7 +15,7 @@
 			<!-- #ifndef MP-WEIXIN -->
 			<!-- 微信小程序不支持,因为微信中不支持 <slot name="title" slot="title" />的写法 -->
 			<template slot="title">
-				<slot name="title"></slot>
+				<text style="font-size: 14px;font-weight: bold;text-align: center;">{{title}}</text>
 			</template>
 			<template slot="icon">
 				<slot name="icon"></slot>
@@ -209,13 +209,11 @@
 	@import "../../libs/css/components.scss";
 
 	.u-collapse-item {
-        cursor: pointer;
 		&__content {
 			overflow: hidden;
 			height: 0;
 
 			&__text {
-				padding: 12px 15px;
 				color: $u-content-color;
 				font-size: 14px;
 				line-height: 18px;

+ 23 - 30
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java

@@ -1,19 +1,5 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.List;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.controller.BaseController;
@@ -22,9 +8,16 @@ import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.service.ISysDeptService;
+import org.apache.commons.lang3.ArrayUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
- * 部门信息
+ * 科室信息
  *
  * @author ruoyi
  */
@@ -35,7 +28,7 @@ public class SysDeptController extends BaseController {
     private ISysDeptService deptService;
 
     /**
-     * 获取部门列表
+     * 获取科室列表
      */
     @PreAuthorize("@ss.hasPermi('system:dept:list')")
     @GetMapping("/list")
@@ -45,7 +38,7 @@ public class SysDeptController extends BaseController {
     }
 
     /**
-     * 查询部门列表(排除节点)
+     * 查询科室列表(排除节点)
      */
     @PreAuthorize("@ss.hasPermi('system:dept:list')")
     @GetMapping("/list/exclude/{deptId}")
@@ -56,7 +49,7 @@ public class SysDeptController extends BaseController {
     }
 
     /**
-     * 根据部门编号获取详细信息
+     * 根据科室编号获取详细信息
      */
     @PreAuthorize("@ss.hasPermi('system:dept:query')")
     @GetMapping(value = "/{deptId}")
@@ -66,51 +59,51 @@ public class SysDeptController extends BaseController {
     }
 
     /**
-     * 新增部门
+     * 新增科室
      */
     @PreAuthorize("@ss.hasPermi('system:dept:add')")
-    @Log(title = "部门管理", businessType = BusinessType.INSERT)
+    @Log(title = "科室管理", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@Validated @RequestBody SysDept dept) {
         if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
-            return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
+            return AjaxResult.error("新增科室'" + dept.getDeptName() + "'失败,科室名称已存在");
         }
         dept.setCreateBy(getUsername());
         return toAjax(deptService.insertDept(dept));
     }
 
     /**
-     * 修改部门
+     * 修改科室
      */
     @PreAuthorize("@ss.hasPermi('system:dept:edit')")
-    @Log(title = "部门管理", businessType = BusinessType.UPDATE)
+    @Log(title = "科室管理", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@Validated @RequestBody SysDept dept) {
         Long deptId = dept.getDeptId();
         deptService.checkDeptDataScope(deptId);
         if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) {
-            return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
+            return AjaxResult.error("修改科室'" + dept.getDeptName() + "'失败,科室名称已存在");
         } else if (dept.getParentId().equals(deptId)) {
-            return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
+            return AjaxResult.error("修改科室'" + dept.getDeptName() + "'失败,上级科室不能是自己");
         } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
-            return AjaxResult.error("该部门包含未停用的子部门!");
+            return AjaxResult.error("该科室包含未停用的子科室!");
         }
         dept.setUpdateBy(getUsername());
         return toAjax(deptService.updateDept(dept));
     }
 
     /**
-     * 删除部门
+     * 删除科室
      */
     @PreAuthorize("@ss.hasPermi('system:dept:remove')")
-    @Log(title = "部门管理", businessType = BusinessType.DELETE)
+    @Log(title = "科室管理", businessType = BusinessType.DELETE)
     @DeleteMapping("/{deptId}")
     public AjaxResult remove(@PathVariable Long deptId) {
         if (deptService.hasChildByDeptId(deptId)) {
-            return AjaxResult.error("存在下级部门,不允许删除");
+            return AjaxResult.error("存在下级科室,不允许删除");
         }
         if (deptService.checkDeptExistUser(deptId)) {
-            return AjaxResult.error("部门存在用户,不允许删除");
+            return AjaxResult.error("科室存在用户,不允许删除");
         }
         deptService.checkDeptDataScope(deptId);
         return toAjax(deptService.deleteDeptById(deptId));

+ 34 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/Api_DepartmentController.java

@@ -0,0 +1,34 @@
+package com.ruoyi.web.work.api;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.service.ISysDeptService;
+import com.ruoyi.web.work.api.config.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 科室介绍
+ *
+ * @author lsw
+ * @date 2024-07-11
+ */
+@RestController
+@RequestMapping("/app/department")
+public class Api_DepartmentController extends BaseController {
+
+    @Autowired
+    private ISysDeptService deptService;
+
+    @GetMapping("/list")
+    public AjaxResult list() {
+        return deptService.treeList();
+    }
+
+    @GetMapping(value = "/detail/{id}")
+    public AjaxResult detail(@PathVariable("id") Long id) {
+        return AjaxResult.success(deptService.getById(id));
+    }
+}

+ 1 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/api/config/InterceptorConfig.java

@@ -23,6 +23,7 @@ public class InterceptorConfig implements WebMvcConfigurer {
         registration.excludePathPatterns("/app/user/login"); //排除
         registration.excludePathPatterns("/app/home/**"); //排除
         registration.excludePathPatterns("/app/knowledge/**"); //排除
+        registration.excludePathPatterns("/app/department/**"); //排除
         registration.excludePathPatterns("/app/common/type/*"); //排除
         registration.excludePathPatterns("/app/common/introduction/*"); //排除
     }

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/FollowRecord.java

@@ -51,7 +51,7 @@ public class FollowRecord{
     @TableField(fill = FieldFill.INSERT)
     private Long userId;
 
-    @ApiModelProperty(value = "部门ID")
+    @ApiModelProperty(value = "科室ID")
     @TableField(fill = FieldFill.INSERT)
     private Long deptId;
 

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/FollowTemplate.java

@@ -50,7 +50,7 @@ public class FollowTemplate extends BaseData {
     @TableField(fill = FieldFill.INSERT)
     private Long userId;
 
-    @ApiModelProperty(value = "部门ID")
+    @ApiModelProperty(value = "科室ID")
     @TableField(fill = FieldFill.INSERT)
     private Long deptId;
 

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -153,6 +153,6 @@ xss:
   # 过滤开关
   enabled: true
   # 排除链接(多个用逗号分隔)
-  excludes: /system/notice
+  excludes: /system/notice,/system/dept
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*

+ 43 - 40
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java

@@ -1,114 +1,117 @@
 package com.ruoyi.common.core.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonFormat;
 
 /**
  * Entity基类
  *
  * @author ruoyi
  */
-public class BaseEntity implements Serializable
-{
+public class BaseEntity implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /** 搜索值 */
+    /**
+     * 搜索值
+     */
+    @TableField(exist = false)
     private String searchValue;
 
-    /** 创建者 */
+    /**
+     * 创建者
+     */
     private String createBy;
 
-    /** 创建时间 */
+    /**
+     * 创建时间
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
-    /** 更新者 */
+    /**
+     * 更新者
+     */
     private String updateBy;
 
-    /** 更新时间 */
+    /**
+     * 更新时间
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
 
-    /** 备注 */
+    /**
+     * 备注
+     */
+    @TableField(exist = false)
     private String remark;
 
-    /** 请求参数 */
+    /**
+     * 请求参数
+     */
+    @TableField(exist = false)
     private Map<String, Object> params;
 
-    public String getSearchValue()
-    {
+    public String getSearchValue() {
         return searchValue;
     }
 
-    public void setSearchValue(String searchValue)
-    {
+    public void setSearchValue(String searchValue) {
         this.searchValue = searchValue;
     }
 
-    public String getCreateBy()
-    {
+    public String getCreateBy() {
         return createBy;
     }
 
-    public void setCreateBy(String createBy)
-    {
+    public void setCreateBy(String createBy) {
         this.createBy = createBy;
     }
 
-    public Date getCreateTime()
-    {
+    public Date getCreateTime() {
         return createTime;
     }
 
-    public void setCreateTime(Date createTime)
-    {
+    public void setCreateTime(Date createTime) {
         this.createTime = createTime;
     }
 
-    public String getUpdateBy()
-    {
+    public String getUpdateBy() {
         return updateBy;
     }
 
-    public void setUpdateBy(String updateBy)
-    {
+    public void setUpdateBy(String updateBy) {
         this.updateBy = updateBy;
     }
 
-    public Date getUpdateTime()
-    {
+    public Date getUpdateTime() {
         return updateTime;
     }
 
-    public void setUpdateTime(Date updateTime)
-    {
+    public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
 
-    public String getRemark()
-    {
+    public String getRemark() {
         return remark;
     }
 
-    public void setRemark(String remark)
-    {
+    public void setRemark(String remark) {
         this.remark = remark;
     }
 
-    public Map<String, Object> getParams()
-    {
-        if (params == null)
-        {
+    public Map<String, Object> getParams() {
+        if (params == null) {
             params = new HashMap<>();
         }
         return params;
     }
 
-    public void setParams(Map<String, Object> params)
-    {
+    public void setParams(Map<String, Object> params) {
         this.params = params;
     }
 }

+ 206 - 159
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java

@@ -1,203 +1,250 @@
 package com.ruoyi.common.core.domain.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
-import javax.validation.constraints.Email;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * 部门表 sys_dept
  *
  * @author ruoyi
  */
+@Data
+@TableName(value = "sys_dept")
+@Accessors(chain = true)
 public class SysDept extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 部门ID
-     */
+    @TableId
     private Long deptId;
 
-    /**
-     * 父部门ID
-     */
+    @Excel(name = "父部门id")
     private Long parentId;
 
-    /**
-     * 祖级列表
-     */
+    @Excel(name = "祖级列表")
     private String ancestors;
 
-    /**
-     * 部门名称
-     */
+    @Excel(name = "部门名称")
     private String deptName;
 
-    /**
-     * 显示顺序
-     */
+    @Excel(name = "显示顺序")
     private Integer orderNum;
 
-    /**
-     * 负责人
-     */
+    @Excel(name = "科室简介")
+    private String brief;
+
+    @Excel(name = "负责人")
     private String leader;
 
-    /**
-     * 联系电话
-     */
+    @Excel(name = "联系电话")
     private String phone;
 
-    /**
-     * 邮箱
-     */
+    @Excel(name = "邮箱")
     private String email;
 
-    /**
-     * 部门状态:0正常,1停用
-     */
+    @Excel(name = "部门状态:0=正常,1=停用")
     private String status;
 
-    /**
-     * 删除标志(0代表存在 2代表删除)
-     */
     private String delFlag;
 
+    @Excel(name = "医疗机构ID")
+    private String orgCode;
+
+    @Excel(name = "科室代码")
+    private String deptCode;
+
+    @Excel(name = "拼音码")
+    private String py;
+
+    @Excel(name = "五笔码")
+    private String wb;
+
+    @Excel(name = "助记码")
+    private String inputCode;
+
+    @Excel(name = "一级科室代码")
+    private String deptCodeOne;
+
+    @Excel(name = "一级科室名称")
+    private String deptNameOne;
+
+    @Excel(name = "二级科室代码")
+    private String deptCodeTwo;
+
+    @Excel(name = "二级科室名称")
+    private String deptNameTwo;
+
+    @Excel(name = "医保科室代码")
+    private String medDeptCode;
+
+    @Excel(name = "医保科室名称")
+    private String medDeptName;
+
+    @Excel(name = "核算科室代码")
+    private String accountDeptCode;
+
+    @Excel(name = "核算科室名称")
+    private String accountDeptName;
+
+    @Excel(name = "科室类别代码")
+    private Long deptTypeCode;
+
+    @Excel(name = "科室地址")
+    private String deptAddr;
+
+    @Excel(name = "押金警示线")
+    private BigDecimal depositWarLine;
+
+    @Excel(name = "门急诊标志:1:门诊,2:急诊,3:家床,4:住院")
+    private String erSign;
+
+    @Excel(name = "专科标志:0:否,1:是")
+    private String specialtySign;
+
+    @Excel(name = "儿科标志:0:否,1:是")
+    private String childSign;
+
+    @Excel(name = "供应室标志:0:否,1:是")
+    private String rupplyRoomSign;
+
+    @Excel(name = "中医科室标志:0:否,1:是")
+    private String chineseMedSign;
+
+    @Excel(name = "医技确费欠费控制标志:0:否,1:是")
+    private String oweCtrlSign;
+
+    @Excel(name = "科室标志:0:否,1:是")
+    private String deptSign;
+
+    @Excel(name = "限号数")
+    private Integer limitNo;
+
+    @Excel(name = "主任医师数")
+    private Integer chiefDoctNo;
+
+    @Excel(name = "住院医师数")
+    private Integer resiDoctNo;
+
+    @Excel(name = "主治医师数")
+    private Integer atndDoctNo;
+
+    @Excel(name = "护士数")
+    private Integer nursNo;
+
+    @Excel(name = "考核床位数")
+    private Integer assessedBedsNo;
+
+    @Excel(name = "押金停药线")
+    private BigDecimal depositBndonLine;
+
+    @Excel(name = "使作中医病历标志:0:不使用,1:使用")
+    private String tcmEmrSign;
+
+    @Excel(name = "科室中护士站的IP")
+    private String nurseStationIp;
+
+    @Excel(name = "核定床位数")
+    private Integer authorizeBeds;
+
+    @Excel(name = "核定家床数")
+    private Integer authorizeHomeBeds;
+
+    @Excel(name = "确认科室标志:0:不是确认科室,1:是确认科室")
+    private String confirmDeptSign;
+
+    @Excel(name = "提交科室代码")
+    private String submitDeptCode;
+
+    @Excel(name = "提交科室名称")
+    private String submitDeptName;
+
+    @Excel(name = "自助挂号标志:0:不可以自助挂号,1:可以自助挂号")
+    private String selfRegisterSign;
+
+    @Excel(name = "药房标志:0:不是药房,1:是药房")
+    private String pharmSign;
+
+    @Excel(name = "专病标志:0:非专病,1:专病")
+    private String specDiseaseSign;
+
+    @Excel(name = "医生登录的科室及诊间的IP地址")
+    private String deptIp;
+
+    @Excel(name = "对应科室代码")
+    private String correspondingDeptCode;
+
+    @Excel(name = "对应科室名称")
+    private String correspondingDeptName;
+
+    @Excel(name = "使用全科医生站标志:0:不使用,1:使用")
+    private String generPracStationSign;
+
+    @Excel(name = "分诊号序前缀")
+    private String triagePrefix;
+
+    @Excel(name = "科室使用阿里健康:0:不使用,1:使用")
+    private String aljkSign;
+
+    @Excel(name = "科室地理位置")
+    private String deptLocation;
+
+    @Excel(name = "科室地理位置2")
+    private String deptLocation2;
+
+    @Excel(name = "科室地理位置3")
+    private String deptLocation3;
+
+    @Excel(name = "科室地理位置4")
+    private String deptLocation4;
+
+    @Excel(name = "专病专家标志:0:否,1:是")
+    private String specialistSign;
+
+    @Excel(name = "预约标志:0:不预约,1:预约")
+    private String apntSign;
+
+    @Excel(name = "备注")
+    private String memo;
+
+    @Excel(name = "有效开始日期时间")
+    private String validStartDTime;
+
+    @Excel(name = "有效结束日期时间")
+    private String validEndDTime;
+
+    @Excel(name = "有效标志:0:无效,1:有效")
+    private String activeSign;
+
+    @Excel(name = "版本号")
+    private String verNo;
+
+    @Excel(name = "科室排序序号")
+    private String orderno;
+
+    @Excel(name = "押金停药线")
+    private String yjbj;
+
+    @Excel(name = "转诊描述")
+    private String zzms;
+
     /**
      * 父部门名称
      */
+    @TableField(exist = false)
     private String parentName;
 
     /**
      * 子部门
      */
+    @TableField(exist = false)
     private List<SysDept> children = new ArrayList<SysDept>();
 
-    public Long getDeptId() {
-        return deptId;
-    }
-
-    public void setDeptId(Long deptId) {
-        this.deptId = deptId;
-    }
-
-    public Long getParentId() {
-        return parentId;
-    }
-
-    public void setParentId(Long parentId) {
-        this.parentId = parentId;
-    }
-
-    public String getAncestors() {
-        return ancestors;
-    }
-
-    public void setAncestors(String ancestors) {
-        this.ancestors = ancestors;
-    }
-
-    @NotBlank(message = "部门名称不能为空")
-    @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
-    public String getDeptName() {
-        return deptName;
-    }
-
-    public void setDeptName(String deptName) {
-        this.deptName = deptName;
-    }
-
-    @NotNull(message = "显示顺序不能为空")
-    public Integer getOrderNum() {
-        return orderNum;
-    }
-
-    public void setOrderNum(Integer orderNum) {
-        this.orderNum = orderNum;
-    }
-
-    public String getLeader() {
-        return leader;
-    }
-
-    public void setLeader(String leader) {
-        this.leader = leader;
-    }
-
-    @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
-    public String getPhone() {
-        return phone;
-    }
-
-    public void setPhone(String phone) {
-        this.phone = phone;
-    }
-
-    @Email(message = "邮箱格式不正确")
-    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
-    public String getEmail() {
-        return email;
-    }
-
-    public void setEmail(String email) {
-        this.email = email;
-    }
-
-    public String getStatus() {
-        return status;
-    }
-
-    public void setStatus(String status) {
-        this.status = status;
-    }
-
-    public String getDelFlag() {
-        return delFlag;
-    }
-
-    public void setDelFlag(String delFlag) {
-        this.delFlag = delFlag;
-    }
-
-    public String getParentName() {
-        return parentName;
-    }
-
-    public void setParentName(String parentName) {
-        this.parentName = parentName;
-    }
-
-    public List<SysDept> getChildren() {
-        return children;
-    }
-
-    public void setChildren(List<SysDept> children) {
-        this.children = children;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
-                .append("deptId", getDeptId())
-                .append("parentId", getParentId())
-                .append("ancestors", getAncestors())
-                .append("deptName", getDeptName())
-                .append("orderNum", getOrderNum())
-                .append("leader", getLeader())
-                .append("phone", getPhone())
-                .append("email", getEmail())
-                .append("status", getStatus())
-                .append("delFlag", getDelFlag())
-                .append("createBy", getCreateBy())
-                .append("createTime", getCreateTime())
-                .append("updateBy", getUpdateBy())
-                .append("updateTime", getUpdateTime())
-                .toString();
-    }
 }

+ 25 - 19
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java

@@ -1,19 +1,22 @@
 package com.ruoyi.system.mapper;
 
-import java.util.List;
-import org.apache.ibatis.annotations.Param;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.common.core.domain.entity.SysDept;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * 部门管理 数据层
- * 
+ *
  * @author ruoyi
  */
-public interface SysDeptMapper
-{
+public interface SysDeptMapper extends BaseMapper<SysDept> {
     /**
      * 查询部门管理数据
-     * 
+     *
      * @param dept 部门信息
      * @return 部门信息集合
      */
@@ -21,8 +24,8 @@ public interface SysDeptMapper
 
     /**
      * 根据角色ID查询部门树信息
-     * 
-     * @param roleId 角色ID
+     *
+     * @param roleId            角色ID
      * @param deptCheckStrictly 部门树选择项是否关联显示
      * @return 选中部门列表
      */
@@ -30,7 +33,7 @@ public interface SysDeptMapper
 
     /**
      * 根据部门ID查询信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门信息
      */
@@ -38,7 +41,7 @@ public interface SysDeptMapper
 
     /**
      * 根据ID查询所有子部门
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门列表
      */
@@ -46,7 +49,7 @@ public interface SysDeptMapper
 
     /**
      * 根据ID查询所有子部门(正常状态)
-     * 
+     *
      * @param deptId 部门ID
      * @return 子部门数
      */
@@ -54,7 +57,7 @@ public interface SysDeptMapper
 
     /**
      * 是否存在子节点
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -62,7 +65,7 @@ public interface SysDeptMapper
 
     /**
      * 查询部门是否存在用户
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -70,7 +73,7 @@ public interface SysDeptMapper
 
     /**
      * 校验部门名称是否唯一
-     * 
+     *
      * @param deptName 部门名称
      * @param parentId 父部门ID
      * @return 结果
@@ -79,7 +82,7 @@ public interface SysDeptMapper
 
     /**
      * 新增部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -87,7 +90,7 @@ public interface SysDeptMapper
 
     /**
      * 修改部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -95,14 +98,14 @@ public interface SysDeptMapper
 
     /**
      * 修改所在部门正常状态
-     * 
+     *
      * @param deptIds 部门ID组
      */
     public void updateDeptStatusNormal(Long[] deptIds);
 
     /**
      * 修改子元素关系
-     * 
+     *
      * @param depts 子元素
      * @return 结果
      */
@@ -110,9 +113,12 @@ public interface SysDeptMapper
 
     /**
      * 删除部门管理信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
     public int deleteDeptById(Long deptId);
+
+    @Select("SELECT dept_id AS deptId, dept_name AS deptName, parent_id AS parentId FROM sys_dept WHERE status ='0' ORDER BY order_num ASC")
+    List<Map<String, Object>> treeList();
 }

+ 36 - 32
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java

@@ -1,124 +1,128 @@
 package com.ruoyi.system.service;
 
-import java.util.List;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.TreeSelect;
 import com.ruoyi.common.core.domain.entity.SysDept;
 
+import java.util.List;
+
 /**
  * 部门管理 服务层
- * 
+ *
  * @author ruoyi
  */
-public interface ISysDeptService
-{
+public interface ISysDeptService extends IService<SysDept> {
     /**
      * 查询部门管理数据
-     * 
+     *
      * @param dept 部门信息
      * @return 部门信息集合
      */
-    public List<SysDept> selectDeptList(SysDept dept);
+     List<SysDept> selectDeptList(SysDept dept);
 
     /**
      * 查询部门树结构信息
-     * 
+     *
      * @param dept 部门信息
      * @return 部门树信息集合
      */
-    public List<TreeSelect> selectDeptTreeList(SysDept dept);
+     List<TreeSelect> selectDeptTreeList(SysDept dept);
+
+     AjaxResult treeList();
 
     /**
      * 构建前端所需要树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 树结构列表
      */
-    public List<SysDept> buildDeptTree(List<SysDept> depts);
+     List<SysDept> buildDeptTree(List<SysDept> depts);
 
     /**
      * 构建前端所需要下拉树结构
-     * 
+     *
      * @param depts 部门列表
      * @return 下拉树结构列表
      */
-    public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
+     List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
 
     /**
      * 根据角色ID查询部门树信息
-     * 
+     *
      * @param roleId 角色ID
      * @return 选中部门列表
      */
-    public List<Long> selectDeptListByRoleId(Long roleId);
+     List<Long> selectDeptListByRoleId(Long roleId);
 
     /**
      * 根据部门ID查询信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门信息
      */
-    public SysDept selectDeptById(Long deptId);
+     SysDept selectDeptById(Long deptId);
 
     /**
      * 根据ID查询所有子部门(正常状态)
-     * 
+     *
      * @param deptId 部门ID
      * @return 子部门数
      */
-    public int selectNormalChildrenDeptById(Long deptId);
+     int selectNormalChildrenDeptById(Long deptId);
 
     /**
      * 是否存在部门子节点
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
-    public boolean hasChildByDeptId(Long deptId);
+     boolean hasChildByDeptId(Long deptId);
 
     /**
      * 查询部门是否存在用户
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果 true 存在 false 不存在
      */
-    public boolean checkDeptExistUser(Long deptId);
+     boolean checkDeptExistUser(Long deptId);
 
     /**
      * 校验部门名称是否唯一
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
-    public String checkDeptNameUnique(SysDept dept);
+     String checkDeptNameUnique(SysDept dept);
 
     /**
      * 校验部门是否有数据权限
-     * 
+     *
      * @param deptId 部门id
      */
-    public void checkDeptDataScope(Long deptId);
+     void checkDeptDataScope(Long deptId);
 
     /**
      * 新增保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
-    public int insertDept(SysDept dept);
+    boolean insertDept(SysDept dept);
 
     /**
      * 修改保存部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
-    public int updateDept(SysDept dept);
+     boolean updateDept(SysDept dept);
 
     /**
      * 删除部门管理信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
-    public int deleteDeptById(Long deptId);
+     int deleteDeptById(Long deptId);
 }

+ 29 - 15
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -1,14 +1,9 @@
 package com.ruoyi.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.constant.UserConstants;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.TreeSelect;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysRole;
@@ -21,6 +16,14 @@ import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.system.mapper.SysDeptMapper;
 import com.ruoyi.system.mapper.SysRoleMapper;
 import com.ruoyi.system.service.ISysDeptService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 部门管理 服务实现
@@ -28,7 +31,7 @@ import com.ruoyi.system.service.ISysDeptService;
  * @author ruoyi
  */
 @Service
-public class SysDeptServiceImpl implements ISysDeptService {
+public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {
     @Autowired
     private SysDeptMapper deptMapper;
 
@@ -59,6 +62,19 @@ public class SysDeptServiceImpl implements ISysDeptService {
         return buildDeptTreeSelect(depts);
     }
 
+    @Override
+    public AjaxResult treeList() {
+        List<Map<String, Object>> all = deptMapper.treeList();
+        List<Map<String, Object>> list = all.stream().filter(r -> r.get("parentId").toString().equals("100")).collect(Collectors.toList());
+        for (Map record : list) {
+            List<Map<String, Object>> children = all.stream().filter(r -> r.get("parentId").toString().equals(record.get("deptId").toString())).collect(Collectors.toList());
+            if (children.size() > 0) {
+                record.put("children", children);
+            }
+        }
+        return AjaxResult.success(list);
+    }
+
     /**
      * 构建前端所需要树结构
      *
@@ -195,14 +211,14 @@ public class SysDeptServiceImpl implements ISysDeptService {
      * @return 结果
      */
     @Override
-    public int insertDept(SysDept dept) {
+    public boolean insertDept(SysDept dept) {
         SysDept info = deptMapper.selectDeptById(dept.getParentId());
         // 如果父节点不为正常状态,则不允许新增子节点
         if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
             throw new ServiceException("部门停用,不允许新增");
         }
         dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
-        return deptMapper.insertDept(dept);
+        return save(dept);
     }
 
     /**
@@ -212,7 +228,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
      * @return 结果
      */
     @Override
-    public int updateDept(SysDept dept) {
+    public boolean updateDept(SysDept dept) {
         SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
         SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
         if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
@@ -221,13 +237,11 @@ public class SysDeptServiceImpl implements ISysDeptService {
             dept.setAncestors(newAncestors);
             updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
         }
-        int result = deptMapper.updateDept(dept);
-        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
-                && !StringUtils.equals("0", dept.getAncestors())) {
+        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) && !StringUtils.equals("0", dept.getAncestors())) {
             // 如果该部门是启用状态,则启用该部门的所有上级部门
             updateParentDeptStatusNormal(dept);
         }
-        return result;
+        return updateById(dept);
     }
 
     /**

+ 2 - 1
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="createTime" column="create_time" />
 		<result property="updateBy"   column="update_by"   />
 		<result property="updateTime" column="update_time" />
+		<result property="brief"      column="brief" />
 	</resultMap>
 	
 	<sql id="selectDeptVo">
@@ -59,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	</select>
     
     <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
-		select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
+		select d.dept_id,d.brief,d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
 			(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
 		from sys_dept d
 		where d.dept_id = #{deptId}