Browse Source

🐞 fix: 修复抢课页无法获取公告的问题

Pchen. 1 month ago
parent
commit
ce28dc2bd1
1 changed files with 125 additions and 161 deletions
  1. 125 161
      src/pages/qk/taskList.vue

+ 125 - 161
src/pages/qk/taskList.vue

@@ -26,78 +26,70 @@
       </div>
       </div>
 
 
       <AppQueryFilter>
       <AppQueryFilter>
-      <a-row class="queryForm app-query-form query-row">
-        <a-col :flex="'1000px'" class="query-main">
-          <a-form :model="query" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }" label-align="left">
-            <a-row :gutter="16">
-              <a-col :span="6">
-                <a-form-item field="status" label="状态">
-                  <a-select v-model="query.status" placeholder="全部" allow-clear>
-                    <a-option value="paused">未开始</a-option>
-                    <a-option value="pending">待分配</a-option>
-                    <a-option value="assigned">已分配</a-option>
-                    <a-option value="running">抢课中</a-option>
-                    <a-option value="success">成功</a-option>
-                    <a-option value="failed">失败</a-option>
-                    <a-option value="cancelled">已取消</a-option>
-                  </a-select>
-                </a-form-item>
-              </a-col>
-              <a-col :span="6">
-                <a-form-item field="student_num" label="学号">
-                  <a-input v-model="query.student_num" placeholder="学号" allow-clear />
-                </a-form-item>
-              </a-col>
-              <a-col :span="6">
-                <a-form-item field="name" label="备注">
-                  <a-input v-model="query.name" placeholder="备注关键词" allow-clear />
-                </a-form-item>
-              </a-col>
-              <a-col :span="6">
-                <a-form-item field="batch_id" label="选课批次">
-                  <a-select v-model="query.batch_id" placeholder="全部" allow-clear allow-search>
-                    <a-option v-for="item in batchOptions" :key="item.id" :value="item.id">
-                      {{ item.name }}({{ item.jx0502zbid }})
-                    </a-option>
-                  </a-select>
-                </a-form-item>
-              </a-col>
-              <a-col :span="6">
-                <a-form-item field="course_name" label="课程名称">
-                  <a-input v-model="query.course_name" placeholder="模糊匹配课程或分组" allow-clear />
-                </a-form-item>
-              </a-col>
-            </a-row>
-          </a-form>
-        </a-col>
-        <a-divider class="query-divider" style="height: 84px" direction="vertical" />
-        <a-col :flex="1" class="app-query-actions">
-          <a-space class="query-actions-space" direction="vertical" :size="18">
-            <a-button type="primary" @click="search">
-              <template #icon><icon-search /></template>
-              搜索
-            </a-button>
-            <a-button @click="resetQuery">
-              <template #icon><icon-refresh /></template>
-              重置
-            </a-button>
-          </a-space>
-        </a-col>
-      </a-row>
+        <a-row class="queryForm app-query-form query-row">
+          <a-col :flex="'1000px'" class="query-main">
+            <a-form :model="query" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }" label-align="left">
+              <a-row :gutter="16">
+                <a-col :span="6">
+                  <a-form-item field="status" label="状态">
+                    <a-select v-model="query.status" placeholder="全部" allow-clear>
+                      <a-option value="paused">未开始</a-option>
+                      <a-option value="pending">待分配</a-option>
+                      <a-option value="assigned">已分配</a-option>
+                      <a-option value="running">抢课中</a-option>
+                      <a-option value="success">成功</a-option>
+                      <a-option value="failed">失败</a-option>
+                      <a-option value="cancelled">已取消</a-option>
+                    </a-select>
+                  </a-form-item>
+                </a-col>
+                <a-col :span="6">
+                  <a-form-item field="student_num" label="学号">
+                    <a-input v-model="query.student_num" placeholder="学号" allow-clear />
+                  </a-form-item>
+                </a-col>
+                <a-col :span="6">
+                  <a-form-item field="name" label="备注">
+                    <a-input v-model="query.name" placeholder="备注关键词" allow-clear />
+                  </a-form-item>
+                </a-col>
+                <a-col :span="6">
+                  <a-form-item field="batch_id" label="选课批次">
+                    <a-select v-model="query.batch_id" placeholder="全部" allow-clear allow-search>
+                      <a-option v-for="item in batchOptions" :key="item.id" :value="item.id">
+                        {{ item.name }}({{ item.jx0502zbid }})
+                      </a-option>
+                    </a-select>
+                  </a-form-item>
+                </a-col>
+                <a-col :span="6">
+                  <a-form-item field="course_name" label="课程名称">
+                    <a-input v-model="query.course_name" placeholder="模糊匹配课程或分组" allow-clear />
+                  </a-form-item>
+                </a-col>
+              </a-row>
+            </a-form>
+          </a-col>
+          <a-divider class="query-divider" style="height: 84px" direction="vertical" />
+          <a-col :flex="1" class="app-query-actions">
+            <a-space class="query-actions-space" direction="vertical" :size="18">
+              <a-button type="primary" @click="search">
+                <template #icon><icon-search /></template>
+                搜索
+              </a-button>
+              <a-button @click="resetQuery">
+                <template #icon><icon-refresh /></template>
+                重置
+              </a-button>
+            </a-space>
+          </a-col>
+        </a-row>
       </AppQueryFilter>
       </AppQueryFilter>
 
 
       <a-alert v-if="notice" style="margin-top: 15px;">{{ notice }}</a-alert>
       <a-alert v-if="notice" style="margin-top: 15px;">{{ notice }}</a-alert>
 
 
-      <a-table
-        row-key="id"
-        :data="data"
-        :bordered="false"
-        hoverable
-        class="table"
-        :loading="loading"
-        :scroll="{ x: 1200 }"
-        :pagination="false"
-      >
+      <a-table row-key="id" :data="data" :bordered="false" hoverable class="table" :loading="loading"
+        :scroll="{ x: 1200 }" :pagination="false">
         <template #columns>
         <template #columns>
           <a-table-column title="学号" data-index="student_num" :width="130" />
           <a-table-column title="学号" data-index="student_num" :width="130" />
           <a-table-column title="选课批次" :width="220" ellipsis tooltip>
           <a-table-column title="选课批次" :width="220" ellipsis tooltip>
@@ -132,25 +124,16 @@
           <a-table-column title="操作" :width="280" :fixed="tableFixed('right')">
           <a-table-column title="操作" :width="280" :fixed="tableFixed('right')">
             <template #cell="{ record }">
             <template #cell="{ record }">
               <a-space wrap>
               <a-space wrap>
-                <a-button
-                  v-if="canControl && canStart(record)"
-                  type="text"
-                  size="small"
-                  status="success"
-                  @click="startTask(record)"
-                >
+                <a-button v-if="canControl && canStart(record)" type="text" size="small" status="success"
+                  @click="startTask(record)">
                   开启
                   开启
                 </a-button>
                 </a-button>
-                <a-button
-                  v-if="canControl && canPause(record)"
-                  type="text"
-                  size="small"
-                  status="warning"
-                  @click="pauseTask(record)"
-                >
+                <a-button v-if="canControl && canPause(record)" type="text" size="small" status="warning"
+                  @click="pauseTask(record)">
                   暂停
                   暂停
                 </a-button>
                 </a-button>
-                <a-button v-if="canSubmit" type="text" size="small" :disabled="!canEdit(record)" @click="openModal(record)">编辑</a-button>
+                <a-button v-if="canSubmit" type="text" size="small" :disabled="!canEdit(record)"
+                  @click="openModal(record)">编辑</a-button>
                 <a-button v-if="canSubmit" type="text" size="small" @click="copyTask(record)">复制</a-button>
                 <a-button v-if="canSubmit" type="text" size="small" @click="copyTask(record)">复制</a-button>
                 <a-popconfirm v-if="canSubmit" content="确认取消该抢课任务?" @ok="cancelTask(record)">
                 <a-popconfirm v-if="canSubmit" content="确认取消该抢课任务?" @ok="cancelTask(record)">
                   <a-button type="text" status="danger" size="small" :disabled="!canCancel(record)">取消</a-button>
                   <a-button type="text" status="danger" size="small" :disabled="!canCancel(record)">取消</a-button>
@@ -167,81 +150,62 @@
       </a-table>
       </a-table>
     </a-card>
     </a-card>
 
 
-    <a-modal
-      v-model:visible="visible"
-      :title="modalTitle"
-      :width="isMobile ? '100%' : '720px'"
-      draggable
-      esc-to-close
-      :ok-loading="saving"
-      :on-before-ok="submitTask"
-    >
+    <a-modal v-model:visible="visible" :title="modalTitle" :width="isMobile ? '100%' : '720px'" draggable esc-to-close
+      :ok-loading="saving" :on-before-ok="submitTask">
       <a-spin :loading="detailLoading" style="width: 100%">
       <a-spin :loading="detailLoading" style="width: 100%">
-      <a-form :model="form" layout="vertical" class="task-form">
-        <a-form-item label="备注">
-          <a-textarea
-            v-model="form.name"
-            no-trim
-            placeholder="添加对任务的备注(非必填)"
-            :max-length="{ length: 50 }"
-            allow-clear
-            show-word-limit
-            :auto-size="{ minRows: 2, maxRows: 4 }"
-          />
-        </a-form-item>
-        <a-form-item label="选课批次" required>
-          <a-select v-model="form.batch_id" placeholder="请选择抢课批次" allow-clear allow-search>
-            <a-option v-for="item in batchOptions" :key="item.id" :value="item.id">
-              {{ item.name }}
-            </a-option>
-          </a-select>
-        </a-form-item>
-        <a-form-item label="统一身份认证账号" required>
-          <a-select
-            v-model="form.jw_account_id"
-            placeholder="请选择已验证的统一身份认证账号"
-            allow-search
-            allow-clear
-          >
-            <a-option v-for="item in jwAccounts" :key="item.id" :value="item.id">
-              {{ item.username }}({{ item.realname || '未知' }})
-            </a-option>
-          </a-select>
-          <template #extra>
-            <span v-if="jwAccounts.length === 0">
-              暂无可用账号,请先到
-              <a-link @click="$router.push({ name: 'jwAccount.accountList' })">统一身份认证</a-link>
-              添加并验证
-            </span>
-          </template>
-        </a-form-item>
-        <a-form-item label="课程名称(每行一个,精确匹配)">
-          <a-textarea v-model="form.coursesText" :auto-size="{ minRows: 3 }" placeholder="每行填写一门课程名称" />
-          <template #extra>{{ targetHint }}</template>
-        </a-form-item>
-        <a-form-item label="课程分组(体育课请在此填写项目名称)">
-          <a-textarea v-model="form.courseGroupsText" :auto-size="{ minRows: 2 }" placeholder="每行填写一个课程分组" />
-        </a-form-item>
-        <a-row :gutter="16">
-          <a-col :xs="24" :sm="12">
-            <a-form-item label="抢课间隔(ms)">
-              <a-input-number v-model="form.interval_ms" :min="minInterval" :max="10000" style="width: 100%" />
-              <template #extra>当前最低 {{ minInterval }}ms</template>
-            </a-form-item>
-          </a-col>
-          <a-col :xs="24" :sm="12">
-            <a-form-item label="启用公选课接口">
-              <a-switch v-model="form.enable_ggxxk" />
-            </a-form-item>
-          </a-col>
-          <a-col :xs="24" :sm="12">
-            <a-form-item label="登录失效后自动重新登录">
-              <a-switch v-model="form.auto_relogin" />
-              <template #extra>开启后抢课过程中会话失效将自动重新登录并继续</template>
-            </a-form-item>
-          </a-col>
-        </a-row>
-      </a-form>
+        <a-form :model="form" layout="vertical" class="task-form">
+          <a-form-item label="备注">
+            <a-textarea v-model="form.name" no-trim placeholder="添加对任务的备注(非必填)" :max-length="{ length: 50 }" allow-clear
+              show-word-limit :auto-size="{ minRows: 2, maxRows: 4 }" />
+          </a-form-item>
+          <a-form-item label="选课批次" required>
+            <a-select v-model="form.batch_id" placeholder="请选择抢课批次" allow-clear allow-search>
+              <a-option v-for="item in batchOptions" :key="item.id" :value="item.id">
+                {{ item.name }}
+              </a-option>
+            </a-select>
+          </a-form-item>
+          <a-form-item label="统一身份认证账号" required>
+            <a-select v-model="form.jw_account_id" placeholder="请选择已验证的统一身份认证账号" allow-search allow-clear>
+              <a-option v-for="item in jwAccounts" :key="item.id" :value="item.id">
+                {{ item.username }}({{ item.realname || '未知' }})
+              </a-option>
+            </a-select>
+            <template #extra>
+              <span v-if="jwAccounts.length === 0">
+                暂无可用账号,请先到
+                <a-link @click="$router.push({ name: 'jwAccount.accountList' })">统一身份认证</a-link>
+                添加并验证
+              </span>
+            </template>
+          </a-form-item>
+          <a-form-item label="课程名称(每行一个,精确匹配)">
+            <a-textarea v-model="form.coursesText" :auto-size="{ minRows: 3 }" placeholder="每行填写一门课程名称" />
+            <template #extra>{{ targetHint }}</template>
+          </a-form-item>
+          <a-form-item label="课程分组(体育课请在此填写项目名称)">
+            <a-textarea v-model="form.courseGroupsText" :auto-size="{ minRows: 2 }" placeholder="每行填写一个课程分组" />
+          </a-form-item>
+          <a-row :gutter="16">
+            <a-col :xs="24" :sm="12">
+              <a-form-item label="抢课间隔(ms)">
+                <a-input-number v-model="form.interval_ms" :min="minInterval" :max="10000" style="width: 100%" />
+                <template #extra>当前最低 {{ minInterval }}ms</template>
+              </a-form-item>
+            </a-col>
+            <a-col :xs="24" :sm="12">
+              <a-form-item label="启用公选课接口">
+                <a-switch v-model="form.enable_ggxxk" />
+              </a-form-item>
+            </a-col>
+            <a-col :xs="24" :sm="12">
+              <a-form-item label="登录失效后自动重新登录">
+                <a-switch v-model="form.auto_relogin" />
+                <template #extra>开启后抢课过程中会话失效将自动重新登录并继续</template>
+              </a-form-item>
+            </a-col>
+          </a-row>
+        </a-form>
       </a-spin>
       </a-spin>
     </a-modal>
     </a-modal>
   </div>
   </div>
@@ -260,6 +224,7 @@ import {
   splitQkLines,
   splitQkLines,
   validateQkTaskForm
   validateQkTaskForm
 } from '@/utils/qkTaskRules'
 } from '@/utils/qkTaskRules'
+import { useRoute } from 'vue-router'
 import { getNotice } from '@/utils/util'
 import { getNotice } from '@/utils/util'
 
 
 const notice = ref('')
 const notice = ref('')
@@ -270,8 +235,6 @@ const GetNotice = async () => {
   notice.value = res
   notice.value = res
 }
 }
 
 
-GetNotice()
-
 const { tableFixed, isMobile } = useResponsiveTable()
 const { tableFixed, isMobile } = useResponsiveTable()
 const canSubmit = computed(() => hasAnyPermission(QK_ASSISTANT_SUBMIT_CODES))
 const canSubmit = computed(() => hasAnyPermission(QK_ASSISTANT_SUBMIT_CODES))
 const canControl = computed(() => hasAnyPermission(QK_ASSISTANT_CONTROL_CODES))
 const canControl = computed(() => hasAnyPermission(QK_ASSISTANT_CONTROL_CODES))
@@ -436,7 +399,7 @@ const loadJwAccounts = async () => {
         form.jw_account_id = jwAccounts.value[0].id
         form.jw_account_id = jwAccounts.value[0].id
       }
       }
     }
     }
-  } catch (_) {}
+  } catch (_) { }
 }
 }
 
 
 const loadBatches = async () => {
 const loadBatches = async () => {
@@ -445,7 +408,7 @@ const loadBatches = async () => {
     if (res?.code === 0) {
     if (res?.code === 0) {
       batchOptions.value = res.data || []
       batchOptions.value = res.data || []
     }
     }
-  } catch (_) {}
+  } catch (_) { }
 }
 }
 
 
 const getList = async (silent = false) => {
 const getList = async (silent = false) => {
@@ -568,6 +531,7 @@ onMounted(() => {
   loadJwAccounts()
   loadJwAccounts()
   loadBatches()
   loadBatches()
   getList()
   getList()
+  GetNotice()
   startPolling()
   startPolling()
 })
 })