Browse Source

feat: 完成

刘洋 8 months ago
parent
commit
2132c89945

+ 13 - 0
src/api/order.ts

@@ -132,6 +132,12 @@ export function orderRecordTemplate(): Promise<AxiosResponse<Blob>> {
   );
 }
 
+export function orderDetailExport(data: any): Promise<AxiosResponse<Blob>> {
+  return axios.post('/api/admin/apply/detail/export', data, {
+    responseType: 'blob',
+  });
+}
+
 // 预约名单详情分页
 export function orderRecordPrintTimeListPage(): Promise<
   OrderRecordPrintTimeItem[]
@@ -200,3 +206,10 @@ export function ableUser(params: any): any {
 export function resetUserPwd(params: any): any {
   return axios.post('/api/admin/user/reset/password', {}, { params });
 }
+export function getMyTasks(data: any): any {
+  return axios.post('/api/admin/async/task/page', data);
+}
+
+export function getTaskTypes(): any {
+  return axios.post('/api/admin/async/task/type/list');
+}

+ 2 - 2
src/hooks/table.ts

@@ -1,4 +1,4 @@
-import { ref } from 'vue';
+import { ref, isRef } from 'vue';
 import { PageResult } from '@/api/types/common';
 
 export default function useTable<T extends Record<string, any>>(
@@ -13,7 +13,7 @@ export default function useTable<T extends Record<string, any>>(
 
   async function getList() {
     const datas = {
-      ...searchModel,
+      ...(isRef(searchModel || {}) ? searchModel.value : searchModel),
       pageNumber: pageNumber.value,
       pageSize: pageSize.value,
     };

+ 9 - 0
src/router/routes/modules/order.ts

@@ -63,6 +63,15 @@ const routes: AppRouteRecordRaw = {
         requiresAuth: true,
       },
     },
+    {
+      path: 'my-task',
+      name: 'MyTask',
+      component: () => import('@/views/order/my-task/index.vue'),
+      meta: {
+        title: '我的任务',
+        requiresAuth: true,
+      },
+    },
   ],
 };
 

+ 10 - 0
src/store/modules/app/menuData.ts

@@ -126,4 +126,14 @@ export const menus = [
     enable: true,
     roles: ['ADMIN'],
   },
+  {
+    id: 19,
+    name: '我的任务',
+    url: 'MyTask',
+    type: 'MENU',
+    parentId: 17,
+    sequence: 1,
+    enable: true,
+    roles: ['ADMIN', 'TEACHING'],
+  },
 ];

+ 123 - 0
src/views/order/my-task/index.vue

@@ -0,0 +1,123 @@
+<template>
+  <!-- <div class="part-box is-filter">
+    <a-space class="filter-line" :size="12" wrap> -->
+  <!-- <a-select
+        v-model="searchModel.type"
+        :allow-clear="true"
+        :options="taskList"
+        popup-container="body"
+      >
+        <template #prefix>任务类型</template>
+      </a-select> -->
+  <!-- <a-select
+        v-model="searchModel.status"
+        :allow-clear="true"
+        :options="[
+          { value: 'SUCCESS', label: '成功' },
+          { value: 'ERROR', label: '失败' },
+        ]"
+        popup-container="body"
+      >
+        <template #prefix>任务状态</template>
+      </a-select> -->
+  <!-- <a-button type="primary" @click="toPage(1)">查询</a-button> -->
+  <!-- </a-space>
+  </div> -->
+  <div class="part-box">
+    <a-table
+      class="page-table"
+      :columns="columns"
+      :data="dataList"
+      :pagination="false"
+      :scroll="{ x: 1200 }"
+      :bordered="false"
+    >
+      <template #type="{ record }">{{ taskTypeEnum[record.type] }}</template>
+      <template #status="{ record }">{{
+        taskStatusEnum[record.status]
+      }}</template>
+      <template #result="{ record }">{{
+        taskResultEnum[record.result]
+      }}</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 { getMyTasks, getTaskTypes } from '@/api/order';
+  import { TaskItem } from '@/api/types/order';
+  import useTable from '@/hooks/table';
+  import { useAppStore } from '@/store';
+  import { modalConfirm } from '@/utils/arco';
+
+  defineOptions({
+    name: 'MyTask',
+  });
+
+  const taskList = ref([]);
+  const taskTypeEnum = reactive<any>({});
+  const taskStatusEnum = reactive<any>({
+    INIT: '初始化',
+    RUNNING: '进行中',
+    FINISH: '已完成',
+  });
+  const taskResultEnum = reactive<any>({
+    SUCCESS: '成功',
+    ERROR: '失败',
+  });
+  onMounted(() => {
+    getTaskTypes().then((res: any) => {
+      taskList.value = (res || []).map((item: any) => ({
+        label: item.name,
+        value: item.type,
+      }));
+      taskList.value.forEach((item: any) => {
+        taskTypeEnum[item.value] = item.label;
+      });
+    });
+  });
+  const appStore = useAppStore();
+  appStore.setInfo({ breadcrumbs: ['系统设置', '我的任务'] });
+
+  const searchModel = reactive({
+    type: '',
+    // status: '',
+  });
+  const computedModel = computed(() => {
+    return { type: searchModel.type ? searchModel.type : null };
+  });
+  const columns = computed<TableColumnData[]>(() => {
+    return [
+      {
+        title: '任务类型',
+        dataIndex: 'type',
+        slotName: 'type',
+      },
+      {
+        title: '任务状态',
+        dataIndex: 'status',
+        slotName: 'status',
+      },
+      {
+        title: '任务结果',
+        dataIndex: 'result',
+        slotName: 'result',
+      },
+      {
+        title: '创建人',
+        dataIndex: 'operator',
+      },
+      {
+        title: '创建时间',
+        dataIndex: 'operator',
+      },
+    ];
+  });
+  const { dataList, pagination, toPage, getList } = useTable<any>(
+    getMyTasks,
+    computedModel,
+    true
+  );
+</script>

+ 14 - 0
src/views/order/order-record-manage/index.vue

@@ -45,6 +45,9 @@
       </a-input>
 
       <a-button type="primary" @click="toPage(1)">查询</a-button>
+      <a-button type="primary" status="success" @click="exportTable"
+        >导出</a-button
+      >
     </a-space>
   </div>
   <div class="part-box">
@@ -127,6 +130,7 @@
     orderRecordAutoAssign,
     orderRecordListPage,
     orderRecordTemplate,
+    orderDetailExport,
   } from '@/api/order';
   import { OrderRecordItem, OrderRecordListFilter } from '@/api/types/order';
   import useTable from '@/hooks/table';
@@ -300,4 +304,14 @@
     Message.success('操作成功!');
     getList();
   }
+
+  const exportTable = async () => {
+    const res = await downloadByApi(() =>
+      orderDetailExport({ teachingId: searchModel.teachingId })
+    ).catch((e) => {
+      Message.error(e || '导出失败,请重新尝试!');
+    });
+    if (!res) return;
+    Message.success('导出成功!');
+  };
 </script>