This commit is contained in:
2025-09-11 14:12:22 +08:00
parent 35ebacc326
commit 36bd470611
3 changed files with 60 additions and 55 deletions

View File

@@ -6,7 +6,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://127.0.0.1:3306/managersystem?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://127.0.0.1:n3306/managersystem?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: Wxit11335577
# 从库数据源

View File

@@ -34,8 +34,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.project_name
from biz_module m
left join biz_project p on m.project_id = p.project_id
left join sys_user u1 on u1.user_id = CAST(m.assignee AS UNSIGNED)
left join sys_user u2 on u2.user_name = m.assignee
left join sys_user u1 on (m.assignee REGEXP '^[0-9]+$') and u1.user_id = CAST(m.assignee AS UNSIGNED)
left join sys_user u2 on (NOT (m.assignee REGEXP '^[0-9]+$')) and u2.user_name = m.assignee
</sql>
<select id="selectBizModuleList" parameterType="BizModule" resultMap="BizModuleResult">
@@ -44,7 +44,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="projectId != null "> and m.project_id = #{projectId}</if>
<if test="moduleName != null and moduleName != ''"> and m.module_name like concat('%', #{moduleName}, '%')</if>
<if test="status != null and status != ''"> and m.status = #{status}</if>
<if test="assignee != null and assignee != ''"> and m.assignee = #{assignee}</if>
<if test="assignee != null and assignee != ''">
and (
m.assignee = #{assignee}
or exists (
select 1 from sys_user su
where (
(#{assignee} REGEXP '^[0-9]+$' and su.user_id = CAST(#{assignee} AS UNSIGNED))
or su.user_name = #{assignee}
)
and (su.user_name = m.assignee or CAST(m.assignee AS CHAR) = CAST(su.user_id AS CHAR))
)
)
</if>
<if test="assignTime != null "> and m.assign_time = #{assignTime}</if>
<if test="finishTime != null "> and m.finish_time = #{finishTime}</if>
and m.del_flag = '0'
@@ -75,7 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBizModuleByModuleId" parameterType="Long" resultMap="BizModuleResult">
<include refid="selectBizModuleVo"/>
where module_id = #{moduleId}
where m.module_id = #{moduleId}
limit 1
</select>
<insert id="insertBizModule" parameterType="BizModule" useGeneratedKeys="true" keyProperty="moduleId">
@@ -157,8 +170,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.project_name
from biz_module m
left join biz_project p on m.project_id = p.project_id
left join sys_user u1 on u1.user_id = CAST(m.assignee AS UNSIGNED)
left join sys_user u2 on u2.user_name = m.assignee
left join sys_user u1 on (m.assignee REGEXP '^[0-9]+$') and u1.user_id = CAST(m.assignee AS UNSIGNED)
left join sys_user u2 on (NOT (m.assignee REGEXP '^[0-9]+$')) and u2.user_name = m.assignee
where m.designated_user = #{userId} and m.del_flag = '0'
order by m.create_time desc
</select>

View File

@@ -248,49 +248,49 @@ export default {
methods: {
async initProjects() {
try {
let options = []
// 并行获取:管理员可见项目 + 我参与的模块聚合项目,取并集,避免有时显示有时不显示
const tasks = []
if (this.isProjectAdmin) {
// 管理员/项目管理员:读取全部可管理项目
const { rows } = await listProject({ pageNum: 1, pageSize: 9999 })
options = rows || []
} else if (this.isNormalUser) {
// 普通用户:从“我的模块”汇总所属项目
const { rows } = await getMyModules({ pageNum: 1, pageSize: 9999 })
const map = new Map()
;(rows || []).forEach(m => {
if (m.projectId && m.projectName && !map.has(m.projectId)) {
map.set(m.projectId, { projectId: m.projectId, projectName: m.projectName })
}
})
options = Array.from(map.values())
tasks.push(listProject({ pageNum: 1, pageSize: 9999 }))
} else {
// 也许用户具备项目管理员角色但权限范围有限,这里仍保留 getMyModules 以保证兜底
tasks.push(Promise.resolve({ rows: [] }))
}
// 兼容:若管理员接口无数据,则回退到“我的模块”聚合
if ((!options || options.length === 0)) {
const { rows } = await getMyModules({ pageNum: 1, pageSize: 9999 })
const map = new Map()
;(rows || []).forEach(m => {
if (m.projectId && m.projectName && !map.has(m.projectId)) {
map.set(m.projectId, { projectId: m.projectId, projectName: m.projectName })
}
})
options = Array.from(map.values())
}
// 如果路由带有项目上下文,但下拉没有,补入一项,避免空列表
if ((this.currentContext.projectId && this.currentContext.projectName) && !options.some(p => String(p.projectId) === String(this.currentContext.projectId))) {
options.unshift({ projectId: this.currentContext.projectId, projectName: this.currentContext.projectName })
}
this.projectOptions = options
tasks.push(getMyModules({ pageNum: 1, pageSize: 9999 }))
// 预选项目(优先使用路由上下文),并联动加载模块下拉
if (!this.upload.meta.projectId) {
if (this.currentContext.projectId) {
this.upload.meta.projectId = this.currentContext.projectId
} else if (this.projectOptions && this.projectOptions.length > 0) {
this.upload.meta.projectId = this.projectOptions[0].projectId
}
const [projRes, myModRes] = await Promise.all(tasks)
const map = new Map()
// 管理员项目
if (projRes && Array.isArray(projRes.rows)) {
projRes.rows.forEach(p => {
if (p.projectId && !map.has(p.projectId)) {
map.set(p.projectId, { projectId: p.projectId, projectName: p.projectName || (`项目#${p.projectId}`) })
}
})
}
// 我参与的模块所在项目
if (myModRes && Array.isArray(myModRes.rows)) {
myModRes.rows.forEach(m => {
if (m.projectId && !map.has(m.projectId)) {
map.set(m.projectId, { projectId: m.projectId, projectName: m.projectName || (`项目#${m.projectId}`) })
}
})
}
// 路由上下文一定补入
if (this.currentContext.projectId && !map.has(this.currentContext.projectId)) {
map.set(this.currentContext.projectId, { projectId: this.currentContext.projectId, projectName: this.currentContext.projectName || (`项目#${this.currentContext.projectId}`) })
}
this.projectOptions = Array.from(map.values())
// 如果之前没选过,按上下文预选
if (!this.upload.meta.projectId && this.currentContext.projectId) {
this.upload.meta.projectId = this.currentContext.projectId
}
if (this.upload.meta.projectId) {
await this.handleProjectChange(this.upload.meta.projectId)
} else {
this.moduleOptions = []
this.upload.meta.moduleId = null
}
} catch (e) {
this.projectOptions = []
@@ -400,10 +400,8 @@ export default {
} else {
this.uploadTitle = "上传文档";
}
// 确保项目选项已加载再设置默认值避免首次显示为纯ID
if (!this.projectOptions || this.projectOptions.length === 0) {
await this.initProjects()
}
// 每次打开均刷新一次项目集合,避免角色/指派变更导致的偶发不显示
await this.initProjects()
// 预选:优先使用路由上下文;否则选第一项
if (this.currentContext.projectId) {
this.upload.meta.projectId = this.currentContext.projectId
@@ -411,13 +409,7 @@ export default {
// 默认不选任何项目避免显示成固定ID
this.upload.meta.projectId = null
}
if (this.upload.meta.projectId) {
await this.handleProjectChange(this.upload.meta.projectId)
} else {
// 无默认项目时清空模块下拉
this.moduleOptions = []
this.upload.meta.moduleId = null
}
// initProjects 内已处理联动
this.uploadOpen = true;
},
/** 下载按钮操作 */