feat: enhance user search functionality with additional filters for active status and source

--bug=1059690 --user=王孝刚 【用户管理】筛选项加上:状态、用户来源 https://www.tapd.cn/62980211/s/1744107
This commit is contained in:
wxg0103 2025-07-29 14:52:17 +08:00
parent 53f83d3292
commit fbef7232da

View File

@ -19,6 +19,14 @@
<el-option :label="$t('views.login.loginForm.username.label')" value="username"/> <el-option :label="$t('views.login.loginForm.username.label')" value="username"/>
<el-option :label="$t('views.userManage.userForm.nick_name.label')" value="nick_name"/> <el-option :label="$t('views.userManage.userForm.nick_name.label')" value="nick_name"/>
<el-option :label="$t('views.login.loginForm.email.label')" value="email"/> <el-option :label="$t('views.login.loginForm.email.label')" value="email"/>
<el-option
:label="$t('common.status.label')"
value="is_active"
/>
<el-option
:label="$t('views.userManage.source.label')"
value="source"
/>
</el-select> </el-select>
<el-input <el-input
v-if="search_type === 'username'" v-if="search_type === 'username'"
@ -44,6 +52,63 @@
clearable clearable
:placeholder="$t('common.inputPlaceholder')" :placeholder="$t('common.inputPlaceholder')"
/> />
<el-select
v-else-if="search_type === 'is_active'"
v-model="search_form.is_active"
@change="getList"
style="width: 220px"
>
<el-option
:label="$t('common.status.enabled')"
:value="true"
/>
<el-option
:label="$t('common.status.disabled')"
:value="false"
/>
</el-select>
<el-select
v-else-if="search_type === 'source'"
v-model="search_form.source"
@change="getList"
style="width: 220px"
clearable
:placeholder="$t('common.inputPlaceholder')"
>
<el-option
:label="$t('views.userManage.source.local')"
value="LOCAL"
/>
<el-option
label="CAS"
value="CAS"
/>
<el-option
label="LDAP"
value="LDAP"
/>
<el-option
label="OIDC"
value="OIDC"
/>
<el-option
label="OAuth2"
value="OAuth2"
/>
<el-option
:label="$t('views.userManage.source.wecom')"
value="wecom"
/>
<el-option
:label="$t('views.userManage.source.lark')"
value="lark"
/>
<el-option
:label="$t('views.userManage.source.dingtalk')"
value="dingtalk"
/>
</el-select>
</div> </div>
</div> </div>
<app-table <app-table
@ -207,7 +272,9 @@
:title="$t('common.delete')" :title="$t('common.delete')"
v-if="hasPermission([RoleConst.ADMIN, PermissionConst.USER_DELETE], 'OR')" v-if="hasPermission([RoleConst.ADMIN, PermissionConst.USER_DELETE], 'OR')"
> >
<el-icon><Delete /></el-icon> <el-icon>
<Delete/>
</el-icon>
</el-button> </el-button>
</el-tooltip> </el-tooltip>
</template> </template>
@ -238,10 +305,14 @@ const search_form = ref<{
username: string username: string
nick_name?: string nick_name?: string
email?: string email?: string
is_active?: boolean | null
source?: string | null
}>({ }>({
username: '', username: '',
nick_name: '', nick_name: '',
email: '', email: '',
is_active: true,
source: '',
}) })
const UserDrawerRef = ref() const UserDrawerRef = ref()
@ -257,7 +328,7 @@ const paginationConfig = reactive({
const userTableData = ref<any[]>([]) const userTableData = ref<any[]>([])
const search_type_change = () => { const search_type_change = () => {
search_form.value = { username: '', nick_name: '', email: '' } search_form.value = {username: '', nick_name: '', email: '', is_active: null}
} }
function handleSizeChange() { function handleSizeChange() {
@ -267,9 +338,9 @@ function handleSizeChange() {
function getList() { function getList() {
const params: any = {} const params: any = {}
if (search_form.value[search_type.value as keyof typeof search_form.value]) { const searchValue = search_form.value[search_type.value as keyof typeof search_form.value];
params[search_type.value] = if (searchValue !== undefined && searchValue !== null && searchValue !== '') {
search_form.value[search_type.value as keyof typeof search_form.value] params[search_type.value] = searchValue;
} }
return userManageApi.getUserManage(paginationConfig, params, loading).then((res) => { return userManageApi.getUserManage(paginationConfig, params, loading).then((res) => {
userTableData.value = res.data.records.map((item: any) => ({ userTableData.value = res.data.records.map((item: any) => ({
@ -329,7 +400,8 @@ function deleteUserManage(row: any) {
getList() getList()
}) })
}) })
.catch(() => {}) .catch(() => {
})
} }
function editPwdUser(row: any) { function editPwdUser(row: any) {