소스 검색

feat: test 用户管理

zhangjie 2 일 전
부모
커밋
83b17ba05f

+ 4 - 4
src/api/user.ts

@@ -25,7 +25,7 @@ export function login(data: LoginData): Promise<UserItem> {
 
 // 修改密码
 export function updatePwd(datas: UpdatePasswordParam): Promise<boolean> {
-  return axios.post('/api/user/password/modify', {}, { params: datas });
+  return axios.post('/api/user/password/modify', datas);
 }
 
 // 退出登录
@@ -35,11 +35,11 @@ export function userLogout() {
 
 // 选择考试
 export function switchExam(examId: number): Promise<boolean> {
-  return axios.post('/api/admin/sys/select/exam', {}, { params: { examId } });
+  return axios.post('/api/admin/sys/select/exam', { examId });
 }
 // 选做分组
 export function switchGroup(groupId: number): Promise<boolean> {
-  return axios.post('/api/admin/sys/select/group', {}, { params: { groupId } });
+  return axios.post('/api/admin/sys/select/group', { groupId });
 }
 
 // 首次登录修改用户信息
@@ -58,7 +58,7 @@ export function systemVersion(): Promise<SystemInfo> {
 export function userListPage(
   params: UserListPageParam
 ): Promise<UserListPageRes> {
-  return axios.post('/api/admin/user/query', { params });
+  return axios.post('/api/admin/user/query', params);
 }
 // 获取指定用户
 export function getUser(id: number): Promise<UserItem> {

+ 6 - 0
src/assets/style/element-custom.scss

@@ -32,6 +32,8 @@
     border: 1px solid var(--el-border-color-lighter);
     line-height: 30px;
     border-radius: 6px;
+    margin: 0 4px;
+    min-width: 32px;
 
     &.is-active {
       color: var(--color-primary);
@@ -254,6 +256,10 @@
     font-weight: 400;
   }
 }
+.el-button--large {
+  padding: 5px 19px;
+  font-size: 16px;
+}
 .el-button--primary {
   background: linear-gradient(180deg, #00a6fc 0%, #0072ff 100%);
 }

+ 1 - 0
src/assets/style/var.scss

@@ -46,6 +46,7 @@
 
   // element
   --el-color-primary: var(--color-primary);
+  --el-color-success: var(--color-success);
   --el-border-color-lighter: var(--color-border-light);
 
   .el-table {

+ 0 - 4
src/layout/default-layout.vue

@@ -116,7 +116,6 @@
   import { computed, onMounted, ref, watch } from 'vue';
   import { useRoute, useRouter } from 'vue-router';
   import { useAppStore, useUserStore } from '@/store';
-  import { ElMessageBox } from 'element-plus';
   import { modalConfirm } from '@/utils/ui';
 
   import ResetPwdDialog from '@/views/login/components/ResetPwdDialog.vue';
@@ -203,9 +202,6 @@
   }
 
   onMounted(() => {
-    // TODO:开发设置
-    appStore.fetchLocalMenu();
-
     initData();
   });
 

+ 2 - 0
src/router/guard/permission.ts

@@ -15,6 +15,8 @@ export default function setupUserLoginInfoGuard(router: Router) {
     const appStore = useAppStore();
     if (!appStore.appMenus.length) {
       const useStore = useUserStore();
+      // TODO:测试
+      appStore.fetchLocalMenu();
       // await appStore.fetchServerMenu(useStore.role);
       console.log(useStore.role);
     }

+ 1 - 1
src/utils/filter.ts

@@ -36,6 +36,6 @@ export const dictFilter = {
 };
 
 // 时间戳过滤器
-export function timestampFilter(val: number | null): string {
+export function timestampFilter(val: number | null | undefined): string {
   return val ? formatDate('YYYY-MM-DD HH:mm:ss', new Date(val)) : DEFAULT_LABEL;
 }

+ 3 - 3
src/utils/ui.ts

@@ -1,13 +1,13 @@
 import { ElMessageBox } from 'element-plus';
 
 export async function modalConfirm(
-  title: string,
-  content: string
+  content: string,
+  title: string
 ): Promise<string> {
   return ElMessageBox.confirm(content, title, {
     confirmButtonText: '确定',
     cancelButtonText: '取消',
-    type: 'error',
+    type: 'warning',
     autofocus: false, // 根据需要调整
     closeOnClickModal: false, // maskClosable
     closeOnPressEscape: false, // escToClose

+ 1 - 6
src/views/admin/role-manage/RoleManage.vue

@@ -35,12 +35,7 @@
       <el-table-column prop="updateName" label="更新人" width="120" />
       <el-table-column label="操作" width="120" fixed="right">
         <template #default="scope">
-          <el-button
-            size="small"
-            type="primary"
-            link
-            @click="onEdit(scope.row)"
-          >
+          <el-button type="primary" link @click="onEdit(scope.row)">
             编辑
           </el-button>
         </template>

+ 4 - 4
src/views/admin/school-manage/SchoolManage.vue

@@ -38,16 +38,16 @@
       <el-table-column prop="city" label="城市" />
       <el-table-column label="操作" width="240">
         <template #default="scope">
-          <el-button size="small" link @click="onEdit(scope.row)">
+          <el-button type="primary" link @click="onEdit(scope.row)">
             修改
           </el-button>
-          <el-button size="small" link @click="onEditAdmin(scope.row)">
+          <el-button type="primary" link @click="onEditAdmin(scope.row)">
             编辑管理员
           </el-button>
-          <el-button size="small" link @click="onEditRoleAuth(scope.row)">
+          <el-button type="primary" link @click="onEditRoleAuth(scope.row)">
             角色权限
           </el-button>
-          <el-button size="small" link @click="onSplitCourse(scope.row)">
+          <el-button type="primary" link @click="onSplitCourse(scope.row)">
             科目拆分
           </el-button>
         </template>

+ 1 - 2
src/views/exam/components/IssuePaperTypeDialog.vue

@@ -35,7 +35,7 @@
           <template #default="scope">
             <el-button
               v-if="scope.row.custom"
-              size="small"
+              type="primary"
               link
               @click="onEdit(scope.row)"
             >
@@ -43,7 +43,6 @@
             </el-button>
             <el-button
               v-if="scope.row.custom"
-              size="small"
               link
               type="danger"
               @click="onDelete(scope.row)"

+ 1 - 2
src/views/exam/components/RejectTypeDialog.vue

@@ -35,7 +35,7 @@
           <template #default="scope">
             <el-button
               v-if="scope.row.custom"
-              size="small"
+              type="primary"
               link
               @click="onEdit(scope.row)"
             >
@@ -43,7 +43,6 @@
             </el-button>
             <el-button
               v-if="scope.row.custom"
-              size="small"
               link
               type="danger"
               @click="onDelete(scope.row)"

+ 2 - 12
src/views/issue-paper/IssuePaper.vue

@@ -89,20 +89,10 @@
       />
       <el-table-column label="操作" width="120" fixed="right">
         <template #default="scope">
-          <el-button
-            type="primary"
-            link
-            size="small"
-            @click="viewDetail(scope.row)"
-          >
+          <el-button type="primary" link @click="viewDetail(scope.row)">
             试卷详情
           </el-button>
-          <el-button
-            type="primary"
-            link
-            size="small"
-            @click="resetSingle(scope.row)"
-          >
+          <el-button type="primary" link @click="resetSingle(scope.row)">
             重置
           </el-button>
         </template>

+ 19 - 6
src/views/login/SwitchExam.vue

@@ -43,7 +43,9 @@
   import type { FormInstance, FormRules } from 'element-plus';
   import { useAppStore } from '@/store';
   import { ExamItem } from '@/api/types/exam';
+  import { switchExam } from '@/api/user';
   import { DEFAULT_ROUTE_NAME } from '@/router/constants';
+  import useLoading from '@/hooks/loading';
 
   const appStore = useAppStore();
   const router = useRouter();
@@ -69,15 +71,26 @@
   };
 
   // 确认按钮点击事件
+  const { loading, setLoading } = useLoading();
   const submit = async () => {
-    const valid = await formRef.value?.validate().catch(() => false);
-    if (!valid) return;
+    if (loading.value) return;
+    try {
+      const valid = await formRef.value?.validate().catch(() => false);
+      if (!valid) return;
 
-    appStore.setInfo({ curExam: selectExam.value });
+      setLoading(true);
 
-    router.push({
-      name: DEFAULT_ROUTE_NAME,
-    });
+      await switchExam(formData.examId);
+      appStore.setInfo({ curExam: selectExam.value });
+
+      router.push({
+        name: DEFAULT_ROUTE_NAME,
+      });
+    } catch (error) {
+      console.error(error);
+    } finally {
+      setLoading(false);
+    }
   };
 
   // 回退按钮点击事件

+ 2 - 1
src/views/login/components/UserInfoDialog.vue

@@ -27,7 +27,7 @@
           {{ userInfo.lastLoginIp || '-' }}
         </el-descriptions-item>
         <el-descriptions-item label="最后登录时间">
-          {{ userInfo.lastLoginTime || '-' }}
+          {{ timestampFilter(userInfo.lastLoginTime) }}
         </el-descriptions-item>
       </el-descriptions>
     </div>
@@ -43,6 +43,7 @@
   import useModal from '@/hooks/modal';
   import { getUser } from '@/api/user';
   import type { UserItem } from '@/api/types/user';
+  import { timestampFilter } from '@/utils/filter';
 
   defineOptions({
     name: 'UserInfoDialog',

+ 1 - 6
src/views/mark/ArbitrationManage.vue

@@ -92,12 +92,7 @@
       </el-table-column>
       <el-table-column label="操作" width="120" fixed="right">
         <template #default="scope">
-          <el-button
-            type="primary"
-            size="small"
-            link
-            @click="onHandle(scope.row)"
-          >
+          <el-button type="primary" link @click="onHandle(scope.row)">
             处理
           </el-button>
         </template>

+ 2 - 16
src/views/mark/GroupManage.vue

@@ -73,25 +73,14 @@
       <el-table-column prop="status" label="状态" width="80" />
       <el-table-column label="操作" width="120" fixed="right">
         <template #default="scope">
-          <el-button
-            type="primary"
-            size="small"
-            link
-            @click="onView(scope.row)"
-          >
+          <el-button type="primary" link @click="onView(scope.row)">
             预览
           </el-button>
-          <el-button
-            type="primary"
-            size="small"
-            link
-            @click="onEdit(scope.row)"
-          >
+          <el-button type="primary" link @click="onEdit(scope.row)">
             修改
           </el-button>
           <el-button
             type="primary"
-            size="small"
             link
             :disabled="startMarkLoading"
             @click="onStartMark(scope.row)"
@@ -100,7 +89,6 @@
           </el-button>
           <el-button
             type="danger"
-            size="small"
             link
             :disabled="releaseLoading"
             @click="onRelease(scope.row)"
@@ -108,7 +96,6 @@
           >
           <el-button
             type="danger"
-            size="small"
             link
             :disabled="closeLoading"
             @click="onClose(scope.row)"
@@ -116,7 +103,6 @@
           >
           <el-button
             type="danger"
-            size="small"
             link
             :disabled="deleteLoading"
             @click="onDelete(scope.row)"

+ 6 - 28
src/views/mark/MarkerManage.vue

@@ -95,8 +95,7 @@
         <template #default="scope">
           <el-button
             v-if="scope.row.status === 'disabled'"
-            type="success"
-            size="small"
+            type="primary"
             link
             @click="onEnable(scope.row, true)"
           >
@@ -104,43 +103,22 @@
           </el-button>
           <el-button
             v-if="scope.row.status === 'enabled'"
-            type="warning"
-            size="small"
+            type="danger"
             link
             @click="onEnable(scope.row, false)"
           >
             禁用
           </el-button>
-          <el-button
-            type="danger"
-            size="small"
-            link
-            @click="onUnbind(scope.row)"
-          >
+          <el-button type="danger" link @click="onUnbind(scope.row)">
             解绑
           </el-button>
-          <el-button
-            type="primary"
-            size="small"
-            link
-            @click="onSetTaskCount(scope.row)"
-          >
+          <el-button type="primary" link @click="onSetTaskCount(scope.row)">
             设置评卷数
           </el-button>
-          <el-button
-            type="info"
-            size="small"
-            link
-            @click="onRecycle(scope.row)"
-          >
+          <el-button type="primary" link @click="onRecycle(scope.row)">
             回收
           </el-button>
-          <el-button
-            type="warning"
-            size="small"
-            link
-            @click="onResetPassword(scope.row)"
-          >
+          <el-button type="warning" link @click="onResetPassword(scope.row)">
             重置密码
           </el-button>
         </template>

+ 1 - 7
src/views/mark/TaskManage.vue

@@ -182,18 +182,12 @@
       </el-table-column>
       <el-table-column label="操作" width="120" fixed="right">
         <template #default="scope">
-          <el-button
-            type="primary"
-            size="small"
-            link
-            @click="onView(scope.row)"
-          >
+          <el-button type="primary" link @click="onView(scope.row)">
             查看
           </el-button>
           <el-button
             v-if="scope.row.status === 'completed'"
             type="danger"
-            size="small"
             link
             @click="onReject(scope.row)"
           >

+ 1 - 6
src/views/mark/TrialManage.vue

@@ -83,12 +83,7 @@
       />
       <el-table-column label="操作" width="120" fixed="right">
         <template #default="scope">
-          <el-button
-            type="primary"
-            size="small"
-            link
-            @click="onView(scope.row)"
-          >
+          <el-button type="primary" link @click="onView(scope.row)">
             查看
           </el-button>
         </template>

+ 3 - 3
src/views/review/AllReview.vue

@@ -247,13 +247,13 @@
       />
       <el-table-column label="操作" width="100" fixed="right">
         <template #default="scope">
-          <el-button size="small" link @click="onTrackView(scope.row)">
+          <el-button type="primary" link @click="onTrackView(scope.row)">
             轨迹图
           </el-button>
-          <el-button size="small" link @click="onCancelReview(scope.row)">
+          <el-button type="primary" link @click="onCancelReview(scope.row)">
             取消复核
           </el-button>
-          <el-button size="small" link @click="onReview(scope.row)">
+          <el-button type="primary" link @click="onReview(scope.row)">
             进入复核
           </el-button>
         </template>

+ 1 - 1
src/views/scan/SignPaperStats.vue

@@ -40,7 +40,7 @@
       <el-table-column prop="picCount" label="图片数量" sortable />
       <el-table-column label="操作" width="100" fixed="right">
         <template #default="scope">
-          <el-button size="small" link @click="onView(scope.row)">
+          <el-button type="primary" link @click="onView(scope.row)">
             查看
           </el-button>
         </template>

+ 1 - 6
src/views/score/ScoreQuery.vue

@@ -198,12 +198,7 @@
       <el-table-column prop="examRoom" label="考场" min-width="100" />
       <el-table-column label="操作" width="100" fixed="right">
         <template #default="scope">
-          <el-button
-            type="primary"
-            link
-            size="small"
-            @click="viewDetail(scope.row)"
-          >
+          <el-button type="primary" link @click="viewDetail(scope.row)">
             查看
           </el-button>
         </template>

+ 1 - 7
src/views/student/StudentManage.vue

@@ -346,17 +346,11 @@
       />
       <el-table-column label="操作" width="120" fixed="right">
         <template v-if="userStore.isSchoolAdmin" #default="scope">
-          <el-button
-            size="small"
-            type="primary"
-            link
-            @click="onEdit(scope.row)"
-          >
+          <el-button type="primary" link @click="onEdit(scope.row)">
             修改
           </el-button>
           <el-button
             v-if="!appStore.isMultiExam"
-            size="small"
             type="danger"
             link
             @click="onDelete(row)"

+ 1 - 4
src/views/subject/PaperStructEdit.vue

@@ -98,12 +98,9 @@
       </el-table-column>
       <el-table-column label="操作" width="100" fixed="right">
         <template #default="{ row }">
-          <el-button size="small" type="primary" link @click="onEdit(row)">
-            编辑
-          </el-button>
+          <el-button type="primary" link @click="onEdit(row)"> 编辑 </el-button>
           <el-button
             v-if="!row.groupNumber"
-            size="small"
             type="danger"
             link
             @click="onDelete(row)"

+ 2 - 10
src/views/subject/SubjectManage.vue

@@ -174,11 +174,8 @@
       </el-table-column>
       <el-table-column label="操作" width="200">
         <template #default="{ row }">
-          <el-button size="small" type="primary" link @click="onEdit(row)">
-            编辑
-          </el-button>
+          <el-button type="primary" link @click="onEdit(row)"> 编辑 </el-button>
           <el-button
-            size="small"
             type="primary"
             :disabled="loading"
             link
@@ -186,12 +183,7 @@
           >
             分析计算
           </el-button>
-          <el-button
-            size="small"
-            type="primary"
-            link
-            @click="onSetOptional(row)"
-          >
+          <el-button type="primary" link @click="onSetOptional(row)">
             设置选做题
           </el-button>
         </template>

+ 2 - 2
src/views/subject/components/OptionalRuleDialog.vue

@@ -34,10 +34,10 @@
 
       <el-table-column label="操作" width="120">
         <template #default="{ row }">
-          <el-button type="primary" size="small" @click="editRule(row)">
+          <el-button type="primary" link @click="editRule(row)">
             编辑
           </el-button>
-          <el-button type="danger" size="small" @click="deleteRule(row)">
+          <el-button type="danger" link @click="deleteRule(row)">
             删除
           </el-button>
         </template>

+ 8 - 18
src/views/user/UserManage.vue

@@ -133,14 +133,8 @@
       </el-table-column>
       <el-table-column label="操作" width="140">
         <template #default="{ row }">
-          <el-button size="small" type="primary" link @click="onEdit(row)"
-            >编辑</el-button
-          >
-          <el-button
-            size="small"
-            type="danger"
-            link
-            @click="onResetPassword(row)"
+          <el-button type="primary" link @click="onEdit(row)">编辑</el-button>
+          <el-button type="danger" link @click="onResetPassword(row)"
             >重置密码</el-button
           >
         </template>
@@ -189,7 +183,7 @@
 </template>
 
 <script setup lang="ts">
-  import { reactive, ref, onMounted, computed } from 'vue';
+  import { reactive, ref, computed } from 'vue';
   import { ElMessage } from 'element-plus';
   import { CaretBottom } from '@element-plus/icons-vue';
   import { userListPage, resetUserPassword, enableUser } from '@/api/user';
@@ -223,7 +217,7 @@
     toPage,
     pageSizeChange,
     handleSelectionChange,
-  } = useTable<UserItem>(userListPage, searchModel);
+  } = useTable<UserItem>(userListPage, searchModel, true);
 
   const modifyUserRef = ref<InstanceType<typeof ModifyUser> | null>(null);
   const batchCreateUserDialogRef = ref<InstanceType<
@@ -308,8 +302,8 @@
 
   // 批量启用、禁用
   const onBatchEnable = async (enabled: boolean) => {
-    if (canBatchAction.value) {
-      ElMessage.warning('请至少选择一个用户');
+    if (!canBatchAction.value) {
+      ElMessage.error('请至少选择一个用户');
       return;
     }
     const action = enabled ? '启用' : '禁用';
@@ -334,8 +328,8 @@
 
   // 批量重置密码
   const onBatchResetPassword = async () => {
-    if (canBatchAction.value) {
-      ElMessage.warning('请至少选择一个用户');
+    if (!canBatchAction.value) {
+      ElMessage.error('请至少选择一个用户');
       return;
     }
     const confirm = await modalConfirm(
@@ -355,8 +349,4 @@
       console.error('操作失败:', error);
     }
   };
-
-  onMounted(() => {
-    // getList();
-  });
 </script>