|
@@ -0,0 +1,216 @@
|
|
|
+<template>
|
|
|
+ <div class="part-box is-filter">
|
|
|
+ <a-space class="filter-line" :size="12" wrap>
|
|
|
+ <SelectTask
|
|
|
+ v-model="searchModel.taskId"
|
|
|
+ placeholder="请选择"
|
|
|
+ allow-clear
|
|
|
+ prefix
|
|
|
+ />
|
|
|
+ <SelectTeaching
|
|
|
+ v-model="searchModel.teachingId"
|
|
|
+ placeholder="请选择"
|
|
|
+ allow-clear
|
|
|
+ prefix-str="所约教学点"
|
|
|
+ :task-id="searchModel.taskId"
|
|
|
+ @get-options="getTeachOptions"
|
|
|
+ />
|
|
|
+ <SelectAgent
|
|
|
+ v-model="searchModel.examSiteId"
|
|
|
+ placeholder="请选择"
|
|
|
+ allow-clear
|
|
|
+ prefix
|
|
|
+ cascade
|
|
|
+ :teaching-id="searchModel.teachingId"
|
|
|
+ />
|
|
|
+ <SelectRoom
|
|
|
+ v-model="searchModel.examRoomId"
|
|
|
+ placeholder="请选择"
|
|
|
+ allow-clear
|
|
|
+ prefix
|
|
|
+ cascade
|
|
|
+ :exam-site-id="searchModel.examSiteId"
|
|
|
+ />
|
|
|
+ <a-button type="primary" @click="search">查询</a-button>
|
|
|
+ </a-space>
|
|
|
+ </div>
|
|
|
+ <div class="part-box">
|
|
|
+ <a-space
|
|
|
+ v-if="searchModel.examRoomId && searchModel.taskId && tableData.length"
|
|
|
+ class="part-action"
|
|
|
+ :size="12"
|
|
|
+ >
|
|
|
+ <a-button type="primary" @click="save">保存</a-button>
|
|
|
+ <span style="color: #ff9a2e">时段关联最小单位是考场</span>
|
|
|
+ </a-space>
|
|
|
+ <a-table
|
|
|
+ :key="tableKey"
|
|
|
+ class="page-table"
|
|
|
+ :columns="columns"
|
|
|
+ :data="tableData"
|
|
|
+ :pagination="false"
|
|
|
+ :scroll="{ x: 1200 }"
|
|
|
+ :bordered="false"
|
|
|
+ :loading="saveLoading || tableLoading"
|
|
|
+ >
|
|
|
+ <template #dateStr="{ record }"> {{ record.dateStr }} </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 }"
|
|
|
+ :key="head"
|
|
|
+ >
|
|
|
+ <a-switch
|
|
|
+ v-if="
|
|
|
+ record.timePeriodList?.find((item:any) => item.timePeriodStr == head)
|
|
|
+ "
|
|
|
+ :default-checked="
|
|
|
+ record.timePeriodList?.find((item) => item.timePeriodStr == head)
|
|
|
+ .enable
|
|
|
+ "
|
|
|
+ :disabled="
|
|
|
+ !record.timePeriodList?.find((item) => item.timePeriodStr == head)
|
|
|
+ .editable
|
|
|
+ "
|
|
|
+ @change="(bool:string | number | boolean)=>{
|
|
|
+ switchChange(rowIndex,head,bool as boolean)
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <template #checked> 开启 </template>
|
|
|
+ <template #unchecked> 关闭 </template>
|
|
|
+ </a-switch></template
|
|
|
+ >
|
|
|
+ </a-table>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+ import { reactive, ref, computed, onMounted, watch } from 'vue';
|
|
|
+ import { Message, TableColumnData } from '@arco-design/web-vue';
|
|
|
+ import {
|
|
|
+ getTimeSliceList,
|
|
|
+ getRoomDateAndTimeList,
|
|
|
+ saveScheduling,
|
|
|
+ toggleSelfYYStatus,
|
|
|
+ } from '@/api/order';
|
|
|
+ import { TaskItem, OrderPeriodSetItem } from '@/api/types/order';
|
|
|
+ import useTable from '@/hooks/table';
|
|
|
+ import { timestampFilter } from '@/utils/filter';
|
|
|
+ import { modalConfirm } from '@/utils/arco';
|
|
|
+ import { useAppStore, useUserStore } from '@/store';
|
|
|
+
|
|
|
+ defineOptions({
|
|
|
+ name: 'RoomSchedulingSet',
|
|
|
+ });
|
|
|
+ const userStore = useUserStore();
|
|
|
+ const tableLoading = ref(false);
|
|
|
+
|
|
|
+ const tableKey = ref(`${Date.now()}`);
|
|
|
+ const appStore = useAppStore();
|
|
|
+ appStore.setInfo({ breadcrumbs: ['考试预约管理', '考场排版设置'] });
|
|
|
+
|
|
|
+ const searchModel = reactive({
|
|
|
+ taskId: null,
|
|
|
+ examSiteId: null,
|
|
|
+ teachingId: null,
|
|
|
+ examRoomId: null,
|
|
|
+ });
|
|
|
+ const sliceTimeArr = ref([] as string[]);
|
|
|
+
|
|
|
+ const columns = computed<TableColumnData[]>(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: '日期/时段',
|
|
|
+ dateIndex: 'dateStr',
|
|
|
+ slotName: 'dateStr',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '批量操作',
|
|
|
+ slotName: 'batch',
|
|
|
+ minWidth: 100,
|
|
|
+ },
|
|
|
+ ...sliceTimeArr.value.map((head: string) => {
|
|
|
+ return {
|
|
|
+ title: head,
|
|
|
+ minWidth: 100,
|
|
|
+ slotName: head,
|
|
|
+ // render: (record: any, column: any, rowIndex: any) => {
|
|
|
+ // return <span>2</span>;
|
|
|
+ // },
|
|
|
+ };
|
|
|
+ }),
|
|
|
+ ];
|
|
|
+ });
|
|
|
+
|
|
|
+ const tableData = ref<OrderPeriodSetItem[]>([]);
|
|
|
+ const getTimeSilce = async () => {
|
|
|
+ const res = await getTimeSliceList({ taskId: searchModel.taskId });
|
|
|
+ sliceTimeArr.value = res || [];
|
|
|
+ };
|
|
|
+ // onMounted(() => {});
|
|
|
+ const search = async () => {
|
|
|
+ if (!searchModel.examRoomId) {
|
|
|
+ Message.error(`请选择考场`);
|
|
|
+ tableData.value = [];
|
|
|
+ tableKey.value = `${Date.now()}`;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await getTimeSilce();
|
|
|
+ tableLoading.value = true;
|
|
|
+ const res = getRoomDateAndTimeList({
|
|
|
+ examSiteId: searchModel.examSiteId || null,
|
|
|
+ }).catch(() => null);
|
|
|
+ tableLoading.value = false;
|
|
|
+
|
|
|
+ if (!res) return;
|
|
|
+ tableData.value = (res || []).map((item: OrderPeriodSetItem) => {
|
|
|
+ item.batchStatus = item.timePeriodList.some((v) => v.enable);
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ tableKey.value = `${Date.now()}`;
|
|
|
+ };
|
|
|
+
|
|
|
+ const switchChange = (rowIndex: number, head: string, bool: boolean) => {
|
|
|
+ // console.log(rowIndex, head, bool);
|
|
|
+ const row = tableData.value[rowIndex];
|
|
|
+ const timePeriodItem = row.timePeriodList.find(
|
|
|
+ (item) => item.timePeriodStr === head
|
|
|
+ );
|
|
|
+ if (!timePeriodItem) return;
|
|
|
+ timePeriodItem.enable = bool;
|
|
|
+ row.batchStatus = row.timePeriodList.some((v) => v.enable);
|
|
|
+ tableKey.value = `${Date.now()}`;
|
|
|
+ };
|
|
|
+
|
|
|
+ const switchBatchChange = (rowIndex: number, bool: boolean) => {
|
|
|
+ const row = tableData.value[rowIndex];
|
|
|
+ row.batchStatus = bool;
|
|
|
+ row.timePeriodList.forEach((item) => {
|
|
|
+ item.enable = bool;
|
|
|
+ });
|
|
|
+ tableKey.value = `${Date.now()}`;
|
|
|
+ };
|
|
|
+
|
|
|
+ const saveLoading = ref(false);
|
|
|
+ const save = async () => {
|
|
|
+ saveLoading.value = true;
|
|
|
+ const data = tableData.value.map((item) => item.timePeriodList).flat();
|
|
|
+ const res = await saveScheduling(data, searchModel.examSiteId).catch(
|
|
|
+ () => false
|
|
|
+ );
|
|
|
+ saveLoading.value = false;
|
|
|
+ if (!res) return;
|
|
|
+ Message.success('保存成功!');
|
|
|
+ search();
|
|
|
+ };
|
|
|
+</script>
|