Parcourir la source

fix:修复用户管理中不支持用户名搜索的问题

yangyi il y a 4 mois
Parent
commit
6d291b5fed
1 fichiers modifiés avec 12 ajouts et 2 suppressions
  1. 12 2
      src/view/admin/UserManage.vue

+ 12 - 2
src/view/admin/UserManage.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 import { getUserManagement } from '../../api/endpoints/user-management'
-import type { User } from '../../api/models'
+import type { ListUsersParams, User } from '../../api/models'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import { RefreshRight, Search } from '@element-plus/icons-vue'
 import { ref, reactive } from 'vue'
@@ -15,11 +15,17 @@ const pagination = reactive({
 })
 
 const statusFilter = ref('')
+const usernameFilter = ref('')
 
 const fetchData = async () => {
   loading.value = true
   try {
-    const res = await getUserManagement().listUsers({ pageNum: pagination.pageNum, pageSize: pagination.pageSize })
+    const params: ListUsersParams = {
+      pageNum: pagination.pageNum,
+      pageSize: pagination.pageSize,
+    }
+    if (usernameFilter.value) params.username = usernameFilter.value
+    const res = await getUserManagement().listUsers(params)
     if (res.code === 200) {
       tableData.value = res.data?.list ?? []
       pagination.total = res.data?.total ?? 0
@@ -39,6 +45,7 @@ const handleSearch = () => {
 
 const handleReset = () => {
   statusFilter.value = ''
+  usernameFilter.value = ''
   handleSearch()
 }
 
@@ -102,6 +109,9 @@ fetchData()
     <!-- 搜索区域 -->
     <el-card class="search-card" shadow="never">
       <el-form inline>
+        <el-form-item label="用户名">
+          <el-input v-model="usernameFilter" placeholder="用户名搜索" clearable style="width: 180px" @change="handleSearch" />
+        </el-form-item>
         <el-form-item label="状态">
           <el-select v-model="statusFilter" placeholder="全部" clearable style="width: 120px" @change="handleSearch">
             <el-option label="正常" value="NORMAL" />