|
@@ -0,0 +1,163 @@
|
|
|
+<template>
|
|
|
+ <div class="registration-query flex flex-col h-full">
|
|
|
+ <SearchForm :fields="fields" :params="params"></SearchForm>
|
|
|
+ <div class="flex-1 page-wrap">
|
|
|
+ <t-table
|
|
|
+ size="small"
|
|
|
+ row-key="id"
|
|
|
+ :columns="columns"
|
|
|
+ :data="tableData"
|
|
|
+ bordered
|
|
|
+ :pagination="{
|
|
|
+ defaultCurrent: 1,
|
|
|
+ defaultPageSize: 10,
|
|
|
+ onChange,
|
|
|
+ total: pagination.total,
|
|
|
+ current: pagination.pageNumber,
|
|
|
+ }"
|
|
|
+ v-loading="tableLoading"
|
|
|
+ >
|
|
|
+ <template #create-time="{ col, row }">
|
|
|
+ {{ timestampFilter(row[col.colKey]) }}
|
|
|
+ </template>
|
|
|
+ <template #operate="{ col, row }">
|
|
|
+ <div class="table-operations">
|
|
|
+ <t-link
|
|
|
+ v-if="row.hasReportFile"
|
|
|
+ theme="primary"
|
|
|
+ hover="color"
|
|
|
+ @click="handleDownload(row, 'REPORT_FILE')"
|
|
|
+ >
|
|
|
+ 导出日志
|
|
|
+ </t-link>
|
|
|
+ <t-link
|
|
|
+ v-if="row.hasResultFile"
|
|
|
+ theme="primary"
|
|
|
+ hover="color"
|
|
|
+ @click="handleDownload(row, 'EXPORT_FILE')"
|
|
|
+ >
|
|
|
+ 下载文件
|
|
|
+ </t-link>
|
|
|
+ <!-- <t-link
|
|
|
+ v-if="row.hasImportFile"
|
|
|
+ theme="primary"
|
|
|
+ hover="color"
|
|
|
+ @click="handleDownload(row, 'IMPORT_FILE')"
|
|
|
+ >
|
|
|
+ 下载导入文件
|
|
|
+ </t-link> -->
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </t-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="TaskManage">
|
|
|
+import { ref, reactive } from 'vue';
|
|
|
+import { MessagePlugin } from 'tdesign-vue-next';
|
|
|
+import useFetchTable from '@/hooks/useFetchTable';
|
|
|
+
|
|
|
+import { taskQueryApi } from '@/api/system';
|
|
|
+import { getAttachmentFile } from '@/api/user';
|
|
|
+import { dictToOptionList, downloadByUrl } from '@/utils/tool';
|
|
|
+import {
|
|
|
+ DATA_TASK_STATUS,
|
|
|
+ DATA_TASK_RESULT,
|
|
|
+ DATA_TASK_TYPE,
|
|
|
+} from '@/config/constants';
|
|
|
+import { timestampFilter } from '@/utils/filter';
|
|
|
+
|
|
|
+const fields = ref([
|
|
|
+ {
|
|
|
+ prop: 'type',
|
|
|
+ label: '任务类型',
|
|
|
+ type: 'select',
|
|
|
+ labelWidth: 100,
|
|
|
+ colSpan: 5,
|
|
|
+ options: dictToOptionList(DATA_TASK_TYPE),
|
|
|
+ attrs: {
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'status',
|
|
|
+ label: '任务状态',
|
|
|
+ type: 'select',
|
|
|
+ labelWidth: 100,
|
|
|
+ colSpan: 5,
|
|
|
+ options: dictToOptionList(DATA_TASK_STATUS),
|
|
|
+ attrs: {
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'result',
|
|
|
+ label: '任务结果',
|
|
|
+ type: 'select',
|
|
|
+ labelWidth: 100,
|
|
|
+ colSpan: 5,
|
|
|
+ options: dictToOptionList(DATA_TASK_RESULT),
|
|
|
+ attrs: {
|
|
|
+ clearable: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'buttons',
|
|
|
+ colSpan: 2,
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ type: 'button',
|
|
|
+ text: '查询',
|
|
|
+ onClick: () => {
|
|
|
+ search();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+]);
|
|
|
+const params = reactive({
|
|
|
+ status: '',
|
|
|
+ type: '',
|
|
|
+ result: '',
|
|
|
+});
|
|
|
+
|
|
|
+const columns = [
|
|
|
+ { colKey: 'type', title: '任务类型' },
|
|
|
+ { colKey: 'status', title: '任务状态', width: 100 },
|
|
|
+ { colKey: 'result', title: '任务结果', width: 80 },
|
|
|
+ { colKey: 'createName', title: '创建人', width: 120 },
|
|
|
+ { colKey: 'createTime', title: '创建时间', cell: 'create-time', width: 170 },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ colKey: 'operate',
|
|
|
+ fixed: 'right',
|
|
|
+ width: 160,
|
|
|
+ align: 'center',
|
|
|
+ cell: 'operate',
|
|
|
+ },
|
|
|
+];
|
|
|
+const {
|
|
|
+ loading: tableLoading,
|
|
|
+ pagination,
|
|
|
+ tableData,
|
|
|
+ search,
|
|
|
+ onChange,
|
|
|
+} = useFetchTable(taskQueryApi, {
|
|
|
+ params,
|
|
|
+});
|
|
|
+
|
|
|
+async function handleDownload(row, type) {
|
|
|
+ const res = await getAttachmentFile(row.id, type).catch(() => {});
|
|
|
+ if (!res) return;
|
|
|
+
|
|
|
+ const url = res.url;
|
|
|
+ if (url.endsWith('.txt')) {
|
|
|
+ window.open(url);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ downloadByUrl(url);
|
|
|
+ MessagePlugin.success('文件下载成功!');
|
|
|
+}
|
|
|
+</script>
|