修改bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 2m45s

This commit is contained in:
sexygoat
2026-04-09 15:32:20 +08:00
parent 4656d403c2
commit b171e7cc03
3 changed files with 34 additions and 21 deletions

View File

@@ -125,6 +125,8 @@
clearable
size="small"
style="width: 180px"
@input="handleRoleSearch"
@clear="handleRoleSearch('')"
/>
</div>
<div class="panel-body">
@@ -555,9 +557,16 @@
})
// 加载所有角色列表
const loadAllRoles = async () => {
const loadAllRoles = async (keyword: string = '') => {
try {
const res = await RoleService.getRoles({ page: 1, pageSize: 100 })
const params: any = {
page: 1,
pageSize: keyword ? 100 : 20 // 搜索时加载更多默认20条
}
if (keyword) {
params.role_name = keyword
}
const res = await RoleService.getRoles(params)
if (res.code === 0) {
allRoles.value = res.data.items || []
}
@@ -607,12 +616,24 @@
roles = roles.filter((role) => role.role_type === 1)
}
// 根据搜索关键词过滤
if (!leftRoleFilter.value) return roles
const keyword = leftRoleFilter.value.toLowerCase()
return roles.filter((role) => role.role_name.toLowerCase().includes(keyword))
return roles
})
// 搜索防抖定时器
let roleSearchTimer: any = null
// 远程搜索角色
const handleRoleSearch = (keyword: string) => {
// 清除之前的定时器
if (roleSearchTimer) {
clearTimeout(roleSearchTimer)
}
// 设置新的定时器500ms 后执行搜索
roleSearchTimer = setTimeout(async () => {
await loadAllRoles(keyword)
}, 500)
}
// 计算属性:过滤后的已分配角色
const filteredAssignedRoles = computed(() => {
const assignedRolesList = allRoles.value.filter((role) => selectedRoles.value.includes(role.ID))
@@ -674,18 +695,16 @@
// 移除单个角色
const removeSingleRole = async (roleId: number) => {
try {
// 从已分配列表中移除该角色
const newRoles = selectedRoles.value.filter((id) => id !== roleId)
await AccountService.assignRolesToAccount(currentAccountId.value, newRoles)
await AccountService.removeRoleFromAccount(currentAccountId.value, roleId)
selectedRoles.value = newRoles
// 从本地已分配列表中移除该角色
selectedRoles.value = selectedRoles.value.filter((id) => id !== roleId)
ElMessage.success('角色移除成功')
// 刷新列表以更新角色显示
await getAccountList()
} catch (error) {
console.error('移除角色失败:', error)
ElMessage.error('角色移除失败')
}
}

View File

@@ -670,7 +670,6 @@
await getTableData()
} catch (error) {
console.error('移除角色失败:', error)
ElMessage.error('角色移除失败')
}
}

View File

@@ -152,12 +152,11 @@
</ElSelect>
</ElFormItem>
</ElCol>
<!-- 只有流量重置周期为每月时才显示套餐周期类型 -->
<ElCol :span="12" v-if="form.data_reset_cycle === 'monthly'">
<ElCol :span="12">
<ElFormItem label="套餐周期类型" prop="calendar_type">
<ElSelect
v-model="form.calendar_type"
placeholder="请选择套餐周期类型"
placeholder="请选择套餐周期类型(可选)"
style="width: 100%"
clearable
>
@@ -815,10 +814,6 @@
watch(
() => form.data_reset_cycle,
(cycle) => {
// 不是每月时清空套餐周期类型
if (cycle !== 'monthly') {
form.calendar_type = undefined
}
// 不是每日且calendar_type不是按天时清空套餐天数
if (cycle !== 'daily' && form.calendar_type !== 'by_day') {
form.duration_days = undefined
@@ -1101,8 +1096,8 @@
if (form.data_reset_cycle) {
data.data_reset_cycle = form.data_reset_cycle
}
// 只有流量重置周期为 monthly 时,才传递 calendar_type
if (form.data_reset_cycle === 'monthly' && form.calendar_type) {
// calendar_type 是可选字段,有值就传递
if (form.calendar_type) {
data.calendar_type = form.calendar_type
}
// 当流量重置周期为每日,或套餐周期类型为按天时,传递套餐天数