diff --git a/ry-xinli-admin/src/main/resources/application-druid.yml b/ry-xinli-admin/src/main/resources/application-druid.yml index 2127354c..4cd2e570 100644 --- a/ry-xinli-admin/src/main/resources/application-druid.yml +++ b/ry-xinli-admin/src/main/resources/application-druid.yml @@ -1,61 +1,61 @@ # 数据源配置 spring: - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: - url: jdbc:mysql://127.0.0.1:3306/ry_xinli?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true - username: ry_xinli - password: ZLZBcfGtsWJe5r4z - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 10 - # 最小连接池数量 - minIdle: 20 - # 最大连接池数量 - maxActive: 100 - # 配置获取连接等待超时的时间(减少到20秒,快速失败) - maxWait: 20000 - # 配置连接超时时间 - connectTimeout: 10000 - # 配置网络超时时间 - socketTimeout: 30000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问(生产环境必须配置!) - allow: 127.0.0.1,192.168.0.0/16 - url-pattern: /druid/* - # 控制台管理用户名和密码(重要:生产环境必须修改) - login-username: ddnai_admin - login-password: Ddnai@2025#Druid - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: + url: jdbc:mysql://1.15.149.240:3306/ry_xinli?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true + username: ry_xinli + password: ZLZBcfGtsWJe5r4z + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问(生产环境必须配置!) + allow: 127.0.0.1,192.168.0.0/16 + url-pattern: /druid/* + # 控制台管理用户名和密码(重要:生产环境必须修改) + login-username: ddnai_admin + login-password: Ddnai@2025#Druid + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true diff --git a/xinli-ui/src/views/psychology/permission/index.vue b/xinli-ui/src/views/psychology/permission/index.vue index 13dc458e..f214590c 100644 --- a/xinli-ui/src/views/psychology/permission/index.vue +++ b/xinli-ui/src/views/psychology/permission/index.vue @@ -102,39 +102,50 @@ /> - + - - - - +
+ + + + + + + + + + +
- - - - + @focus="showUserSelectDialog = true"> + 选择 +
- 提示:可输入姓名或账号搜索,支持多选。留空表示所有用户。 + 提示:留空表示所有用户。点击"选择"按钮可按信息编号、姓名、监区筛选用户。
@@ -170,6 +181,71 @@ 取 消
+ + + + + + + + + + + + + + + + + + 搜索 + 重置 + + + + + + + + + + + + + + + @@ -179,6 +255,8 @@ import { listScale } from "@/api/psychology/scale"; import { allocatedUserList } from "@/api/system/role"; import { listRole } from "@/api/system/role"; import { getUser } from "@/api/system/user"; +import { listProfile } from "@/api/psychology/profile"; +import { deptTreeSelect } from "@/api/system/user"; export default { name: "PsyScalePermission", @@ -200,6 +278,8 @@ export default { permissionList: [], // 量表列表 scaleList: [], + // 量表搜索关键词 + scaleSearchKeyword: "", // 用户列表(用于下拉框显示) userOptions: [], // 用户搜索加载状态 @@ -210,6 +290,24 @@ export default { title: "", // 是否显示弹出层 open: false, + // 是否显示用户选择对话框 + showUserSelectDialog: false, + // 用户选择相关 + userSelectList: [], + userSelectTotal: 0, + userSelectLoading: false, + selectedUserIds: [], + // 部门选项 + deptOptions: [], + // 用户查询参数 + userQueryParams: { + pageNum: 1, + pageSize: 10, + infoNumber: undefined, + userName: undefined, + deptId: undefined, + status: '0' + }, // 查询参数 queryParams: { pageNum: 1, @@ -231,10 +329,60 @@ export default { } }; }, + computed: { + // 过滤后的量表列表 + filteredScaleList() { + if (!this.scaleSearchKeyword) { + return this.scaleList; + } + const keyword = this.scaleSearchKeyword.toLowerCase(); + return this.scaleList.filter(scale => { + const scaleName = (scale.scaleName || '').toLowerCase(); + const scaleCode = (scale.scaleCode || '').toLowerCase(); + return scaleName.includes(keyword) || scaleCode.includes(keyword); + }); + }, + // 选中用户的显示文本 + selectedUserDisplay() { + const userIds = this.form.userIds || []; + if (userIds.length === 0) { + return ""; + } else if (userIds.length === 1) { + const user = this.userOptions.find(u => u.userId === userIds[0]); + return user ? (user.nickName ? `${user.nickName}(${user.userName})` : user.userName) : ""; + } else { + return `已选择 ${userIds.length} 个用户`; + } + } + }, + watch: { + // 监听用户选择对话框打开 + showUserSelectDialog(val) { + if (val) { + // 打开对话框时加载用户列表 + this.resetUserQuery(); + this.selectedUserIds = [...(this.form.userIds || [])]; + this.getUserSelectList().then(() => { + // 确保已选中的用户被选中 + this.$nextTick(() => { + if (this.form.userIds && this.form.userIds.length > 0 && this.$refs.userTable) { + this.form.userIds.forEach(userId => { + const row = this.userSelectList.find(u => u.userId === userId); + if (row) { + this.$refs.userTable.toggleRowSelection(row, true); + } + }); + } + }); + }); + } + } + }, created() { this.getList(); this.loadScales(); this.loadUsers(); + this.loadDeptTree(); }, methods: { /** 查询权限列表 */ @@ -345,6 +493,88 @@ export default { console.error("获取学员角色ID失败:", error); }); }, + /** 加载部门树 */ + loadDeptTree() { + deptTreeSelect().then(response => { + this.deptOptions = response.data || []; + }); + }, + /** 量表行点击 */ + handleScaleRowClick(row) { + this.form.scaleId = row.scaleId; + }, + /** 量表选择改变 */ + handleScaleChange(scale) { + this.form.scaleId = scale.scaleId; + }, + /** 获取用户选择列表 */ + getUserSelectList() { + this.userSelectLoading = true; + // 使用用户档案接口查询,支持信息编号、姓名、监区筛选 + const query = { + pageNum: this.userQueryParams.pageNum, + pageSize: this.userQueryParams.pageSize, + infoNumber: this.userQueryParams.infoNumber, + userName: this.userQueryParams.userName, + deptId: this.userQueryParams.deptId, + status: this.userQueryParams.status + }; + return listProfile(query).then(response => { + this.userSelectList = (response.rows || []).map(profile => ({ + userId: profile.userId, + infoNumber: profile.infoNumber, + userName: profile.userName, + userAccount: profile.infoNumber, // 使用信息编号作为账号显示 + deptName: profile.deptName, + status: profile.status || '0' + })); + this.userSelectTotal = response.total || 0; + this.userSelectLoading = false; + return response; + }).catch(() => { + this.userSelectLoading = false; + return Promise.reject(); + }); + }, + /** 用户查询 */ + handleUserQuery() { + this.userQueryParams.pageNum = 1; + this.getUserSelectList(); + }, + /** 重置用户查询 */ + resetUserQuery() { + this.resetForm("userQueryForm"); + this.userQueryParams = { + pageNum: 1, + pageSize: 10, + infoNumber: undefined, + userName: undefined, + deptId: undefined, + status: '0' + }; + this.handleUserQuery(); + }, + /** 用户选择改变 */ + handleUserSelectionChange(selection) { + this.selectedUserIds = selection.map(item => item.userId); + }, + /** 确认用户选择 */ + handleConfirmUserSelect() { + // 更新 form.userIds + this.form.userIds = [...this.selectedUserIds]; + // 确保选中的用户在 userOptions 中 + this.selectedUserIds.forEach(userId => { + const user = this.userSelectList.find(u => u.userId === userId); + if (user && !this.userOptions.find(u => u.userId === userId)) { + this.userOptions.push({ + userId: user.userId, + userName: user.userAccount || user.userName, + nickName: user.userName + }); + } + }); + this.showUserSelectDialog = false; + }, /** 搜索用户(远程搜索) */ searchUsers(keyword) { if (!this.studentRoleId) { @@ -545,6 +775,8 @@ export default { _permissionIds: undefined, // 存储所有相关的权限ID(用于编辑时删除) _groupKey: undefined // 分组key }; + this.scaleSearchKeyword = ""; + this.selectedUserIds = []; this.resetForm("form"); }, /** 搜索按钮操作 */ @@ -574,6 +806,7 @@ export default { /** 新增按钮操作 */ handleAdd() { this.reset(); + this.scaleSearchKeyword = ""; // 确保 userOptions 有初始数据 if (this.userOptions.length === 0) { this.searchUsers(""); @@ -584,6 +817,7 @@ export default { /** 修改按钮操作 */ handleUpdate(row) { this.reset(); + this.scaleSearchKeyword = ""; // 汇总后的记录包含多个权限ID,需要加载所有相关的权限记录 const permissionIds = row.permissionIds || (row.permissionId ? [row.permissionId] : []);