Explorar o código

fix: bug啊bug

刘洋 hai 7 meses
pai
achega
1288f61909

+ 1 - 1
src/constants/enumerate.ts

@@ -13,7 +13,7 @@ export const ABLE_TYPE = {
 // 角色
 export const ROLE_TYPE = {
   ADMIN: '学校管理员',
-  EXAM_TEACHER: '教学点管理员',
+  TEACHING: '教学点管理员',
 };
 
 export const TASK_STATUS = {

+ 1 - 1
src/store/modules/user/index.ts

@@ -26,7 +26,7 @@ const useUserStore = defineStore('user', {
       return state.role === 'ADMIN';
     },
     isExamTeacher(state: UserState): boolean {
-      return state.role === 'EXAM_TEACHER';
+      return state.role === 'TEACHING';
     },
   },
 

+ 40 - 10
src/views/order/reservation-set/index.vue

@@ -27,7 +27,7 @@
   </div>
   <div class="part-box">
     <a-space
-      v-if="searchModel.examSiteId && searchModel.taskId"
+      v-if="searchModel.examSiteId && searchModel.taskId && tableData.length"
       class="part-action"
       :size="12"
     >
@@ -35,7 +35,7 @@
       <span style="color: #ff9a2e">时段关联最小单位是考点</span>
     </a-space>
     <div
-      v-if="searchModel.examSiteId && searchModel.taskId"
+      v-if="searchModel.examSiteId && searchModel.taskId && !userStore.isAdmin"
       class="part-action"
       :size="12"
       style="display: flex; align-items: center"
@@ -51,16 +51,27 @@
       >
     </div>
     <a-table
+      :key="tableKey"
       class="page-table"
       :columns="columns"
       :data="tableData"
       :pagination="false"
       :scroll="{ x: 1200 }"
       :bordered="false"
-      :loading="saveLoading"
+      :loading="saveLoading || tableLoading"
     >
       <template #dateStr="{ record }"> {{ record.dateStr }} </template>
-      <!-- <template #batch="{ record }"> <a-switch /></template> -->
+      <template #batch="{ record, rowIndex }">
+        <a-switch
+          :default-checked="record.batchStatus"
+          @change="(bool:string | number | boolean)=>{
+            switchBatchChange(rowIndex,bool as boolean)
+          }"
+        >
+          <template #checked> 开启 </template>
+          <template #unchecked> 关闭 </template>
+        </a-switch></template
+      >
       <template
         v-for="head in sliceTimeArr"
         #[head]="{ record, rowIndex }"
@@ -98,12 +109,15 @@
   import useTable from '@/hooks/table';
   import { timestampFilter } from '@/utils/filter';
   import { modalConfirm } from '@/utils/arco';
-  import { useAppStore } from '@/store';
+  import { useAppStore, useUserStore } from '@/store';
 
   defineOptions({
     name: 'ReservationSet',
   });
+  const userStore = useUserStore();
+  const tableLoading = ref(false);
 
+  const tableKey = ref(`${Date.now()}`);
   const appStore = useAppStore();
   appStore.setInfo({ breadcrumbs: ['考试预约管理', '考点预约设置'] });
 
@@ -156,14 +170,22 @@
     if (!searchModel.taskId) {
       Message.error('请选择任务');
       tableData.value = [];
+      tableKey.value = `${Date.now()}`;
       return;
     }
     getTimeSilce();
-    getDateAndTimeList({ examSiteId: searchModel.examSiteId || null }).then(
-      (res) => {
-        tableData.value = res || [];
-      }
-    );
+    tableLoading.value = true;
+    getDateAndTimeList({ examSiteId: searchModel.examSiteId || null })
+      .then((res: any) => {
+        tableData.value = (res || []).map((item: any) => {
+          item.batchStatus = false;
+          return item;
+        });
+        tableKey.value = `${Date.now()}`;
+      })
+      .finally(() => {
+        tableLoading.value = false;
+      });
   };
   // watch(
   //   () => searchModel.examSiteId,
@@ -179,6 +201,14 @@
     ).enable = bool;
   };
 
+  const switchBatchChange = (rowIndex: number, bool: boolean) => {
+    tableData.value[rowIndex].batchStatus = bool;
+    tableData.value[rowIndex].timePeriodList.forEach((item: any) => {
+      item.enable = bool;
+    });
+    tableKey.value = `${Date.now()}`;
+  };
+
   const saveLoading = ref(false);
   const save = () => {
     saveLoading.value = true;