Selaa lähdekoodia

feat: 接口调试

zhangjie 1 kuukausi sitten
vanhempi
commit
4f9b0b5757

+ 22 - 0
src/api/order.ts

@@ -203,6 +203,28 @@ export function toggleSelfYYStatus(params: any) {
   return axios.post('/api/admin/teaching/selfApplyEnable', {}, { params });
 }
 
+// 管理开始关闭自主预约
+// 查询状态
+export function adminSwitchReservationStatus() {
+  return axios.post(
+    '/api/admin/time/period/exam/site/switch/find',
+    {},
+    {
+      params: {
+        propKey: 'APPLY_SWITCH',
+      },
+    }
+  );
+}
+// 修改状态
+export function adminSwitchReservation(status: boolean) {
+  return axios.post(
+    '/api/admin/time/period/exam/site/switch/enable',
+    {},
+    { params: { status } }
+  );
+}
+
 // 考场排版设置
 // 预约时段设置列表
 export function getRoomDateAndTimeList(

+ 3 - 0
src/assets/style/base.less

@@ -267,3 +267,6 @@
 .ml-10 {
   margin-left: 10px;
 }
+.mb-10 {
+  margin-bottom: 10px;
+}

+ 1 - 1
src/router/routes/modules/order.ts

@@ -32,7 +32,7 @@ const routes: AppRouteRecordRaw = {
       name: 'RoomSchedulingSet',
       component: () => import('@/views/order/room-scheduling-set/index.vue'),
       meta: {
-        title: '考点预约设置',
+        title: '考场排班设置',
         requiresAuth: true,
       },
     },

+ 71 - 15
src/views/order/reservation-set/index.vue

@@ -27,14 +27,32 @@
     </a-space>
   </div>
   <div class="part-box">
-    <a-space
-      v-if="searchModel.examSiteId && searchModel.taskId && tableData.length"
-      class="part-action"
-      :size="12"
-    >
-      <a-button type="primary" @click="save">保存</a-button>
-      <span style="color: #ff9a2e">时段关联最小单位是考点</span>
-    </a-space>
+    <div class="box-justify mb-10">
+      <div>
+        <a-space
+          v-if="
+            searchModel.examSiteId && searchModel.taskId && tableData.length
+          "
+          :size="12"
+        >
+          <a-button type="primary" @click="save">保存</a-button>
+          <span style="color: #ff9a2e">时段关联最小单位是考点</span>
+        </a-space>
+      </div>
+      <div>
+        <a-space v-if="userStore.isAdmin">
+          <span>自主预约:</span>
+          <a-switch
+            v-model="timeExamPeriodEnable"
+            @change="timeExamPeriodEnableChange"
+          >
+            <template #checked> 开启 </template>
+            <template #unchecked> 关闭 </template>
+          </a-switch>
+        </a-space>
+      </div>
+    </div>
+
     <!-- <div
       v-if="searchModel.examSiteId && searchModel.taskId && !userStore.isAdmin"
       class="part-action"
@@ -71,8 +89,8 @@
         >
           <template #checked> 开启 </template>
           <template #unchecked> 关闭 </template>
-        </a-switch></template
-      >
+        </a-switch>
+      </template>
       <template
         v-for="head in sliceTimeArr"
         #[head]="{ record, rowIndex }"
@@ -105,6 +123,8 @@
     getDateAndTimeList,
     saveReservation,
     toggleSelfYYStatus,
+    adminSwitchReservationStatus,
+    adminSwitchReservation,
   } from '@/api/order';
   import { TaskItem } from '@/api/types/order';
   import useTable from '@/hooks/table';
@@ -123,9 +143,9 @@
   appStore.setInfo({ breadcrumbs: ['考试预约管理', '考点预约设置'] });
 
   const searchModel = reactive({
-    taskId: '',
-    examSiteId: '',
-    teachingId: '',
+    taskId: null,
+    examSiteId: null,
+    teachingId: null,
   });
   const sliceTimeArr = ref([]);
 
@@ -162,11 +182,11 @@
   const tableData = ref<any>([]);
   const getTimeSilce = () => {
     getTimeSliceList({ taskId: searchModel.taskId }).then((res: any) => {
-      console.log('times', res);
+      // console.log('times', res);
       sliceTimeArr.value = res || [];
     });
   };
-  onMounted(() => {});
+
   const search = () => {
     if (
       !searchModel.taskId ||
@@ -267,4 +287,40 @@
       Message.success('设置成功');
     });
   };
+
+  // timeExamPeriodEnable set;
+  const timeExamPeriodEnable = ref<boolean>(false);
+  async function timeExamPeriodEnableStatus() {
+    const res = await adminSwitchReservationStatus();
+    timeExamPeriodEnable.value = Boolean(res);
+  }
+
+  async function timeExamPeriodEnableChange() {
+    if (!userStore.isAdmin) return;
+
+    const action = timeExamPeriodEnable.value ? '开启' : '关闭';
+    const confirmRes = await modalConfirm(
+      '提示',
+      `确定要${action}自助预约吗?`
+    ).catch(() => false);
+    if (confirmRes !== 'confirm') {
+      timeExamPeriodEnable.value = !timeExamPeriodEnable.value;
+      return;
+    }
+
+    const res = await adminSwitchReservation(timeExamPeriodEnable.value).catch(
+      () => {
+        timeExamPeriodEnable.value = !timeExamPeriodEnable.value;
+        return false;
+      }
+    );
+    if (!res) return;
+    Message.success('操作成功!');
+  }
+
+  onMounted(() => {
+    if (userStore.isAdmin) {
+      timeExamPeriodEnableStatus();
+    }
+  });
 </script>

+ 7 - 5
src/views/order/room-scheduling-set/index.vue

@@ -13,7 +13,6 @@
         allow-clear
         prefix-str="所约教学点"
         :task-id="searchModel.taskId"
-        @get-options="getTeachOptions"
       />
       <SelectAgent
         v-model="searchModel.examSiteId"
@@ -57,6 +56,7 @@
       <template #batch="{ record, rowIndex }">
         <a-switch
           :default-checked="record.batchStatus"
+          :disabled="!record.timePeriodList?.some((item) => item.editable)"
           @change="(bool:string | number | boolean)=>{
             switchBatchChange(rowIndex,bool as boolean)
           }"
@@ -167,9 +167,9 @@
     }
     await getTimeSilce();
     tableLoading.value = true;
-    const res = getRoomDateAndTimeList({
-      examSiteId: searchModel.examSiteId || null,
-    }).catch(() => null);
+    const res = await getRoomDateAndTimeList(searchModel.examRoomId).catch(
+      () => null
+    );
     tableLoading.value = false;
 
     if (!res) return;
@@ -196,7 +196,9 @@
     const row = tableData.value[rowIndex];
     row.batchStatus = bool;
     row.timePeriodList.forEach((item) => {
-      item.enable = bool;
+      if (item.editable) {
+        item.enable = bool;
+      }
     });
     tableKey.value = `${Date.now()}`;
   };