Browse Source

新增离线任务

ai_dev
zhouhaibin 2 months ago
parent
commit
b373bb5987
  1. 94
      src/api/documentReview/DocumentTasks/index.ts
  2. 76
      src/api/documentReview/DocumentTasks/model.ts
  3. 55
      src/views/documentReview/DocumentTasks/DocsDrawer.vue
  4. 164
      src/views/documentReview/DocumentTasks/DocumentTasks.data.ts
  5. 79
      src/views/documentReview/DocumentTasks/DocumentTasksModal.vue
  6. 2248
      src/views/documentReview/DocumentTasks/caozuomiaoshu.md
  7. 241
      src/views/documentReview/DocumentTasks/index.vue

94
src/api/documentReview/DocumentTasks/index.ts

@ -0,0 +1,94 @@
import { defHttp } from '@/utils/http/axios';
import { ID, IDS, commonExport } from '@/api/base';
import { DocumentTasksVO, DocumentTasksForm, DocumentTasksQuery } from './model';
import { ContentTypeEnum } from '@/enums/httpEnum';
/**
*
* @param params
* @returns
*/
export function DocumentTasksList(params?: DocumentTasksQuery) {
return defHttp.get<DocumentTasksVO[]>({ url: '/productManagement/DocumentTasks/list', params });
}
/**
*
* @param params
* @returns
*/
export function DocumentTasksExport(params?: DocumentTasksQuery) {
return commonExport('/productManagement/DocumentTasks/export', params ?? {});
}
/**
*
* @param id id
* @returns
*/
export function DocumentTasksInfo(id: ID) {
return defHttp.get<DocumentTasksVO>({ url: '/productManagement/DocumentTasks/' + id });
}
/**
*
* @param data
* @returns
*/
export function DocumentTasksAdd(data: DocumentTasksForm) {
return defHttp.postWithMsg<void>({ url: '/productManagement/DocumentTasks', data,timeout:1000*60*10 });
}
/**
*
* @param data
* @returns
*/
export function DocumentTasksUpdate(data: DocumentTasksForm) {
return defHttp.putWithMsg<void>({ url: '/productManagement/DocumentTasks', data });
}
/**
*
* @param id id
* @returns
*/
export function DocumentTasksRemove(id: ID | IDS) {
return defHttp.deleteWithMsg<void>({ url: '/productManagement/DocumentTasks/' + id },);
}
/**
*
*/
export function DocumentTasksStop(id: ID | IDS) {
return defHttp.putWithMsg<void>({ url: '/productManagement/DocumentTasks/stopTask/' + id });
}
// export function uploadDocument(formData) {
// return defHttp.post({
// url: '/productManagement/docAi/sse/upload',
// data: formData,
// headers: {
// 'Content-Type': ContentTypeEnum.FORM_DATA,
// },
// timeout: 10 * 60 * 1000,
// });
// }
import { UploadFileParams } from '#/axios';
import { AxiosProgressEvent } from 'axios';
/**
* @description: Upload interface
*/
export function uploadDocument(
params: UploadFileParams,
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
) {
return defHttp.uploadFile<any>(
{
// 固定url地址
url: '/productManagement/DocumentTasks/back/upload',
onUploadProgress,
timeout: 1000 * 60 * 10,
},
params,
);
}

76
src/api/documentReview/DocumentTasks/model.ts

@ -0,0 +1,76 @@
import { BaseEntity, PageQuery } from '@/api/base';
export interface DocumentTasksVO {
id: string | number;
/**
*
*/
taskName: string;
/**
*
*/
documentName: string;
/**
*
*/
estimatedCompletionTime: string;
/**
*
*/
progressStatus: string;
}
export interface DocumentTasksForm extends BaseEntity {
/**
*
*/
taskName?: string;
/**
*
*/
documentName?: string;
/**
*
*/
estimatedCompletionTime?: string;
/**
*
*/
progressStatus?: string;
}
export interface DocumentTasksQuery extends PageQuery {
/**
*
*/
taskName?: string;
/**
*
*/
documentName?: string;
/**
*
*/
estimatedCompletionTime?: string;
/**
*
*/
progressStatus?: string;
/**
*
*/
params?: any;
}

55
src/views/documentReview/DocumentTasks/DocsDrawer.vue

@ -0,0 +1,55 @@
<template>
<BasicDrawer v-bind="$attrs" title="结果详情" :width="drawerWidth" @register="registerDrawer">
<!-- <MarkdownViewer :value="value" v-if="type != 'html'" /> -->
<!-- 纯预览 -->
<MdPreview
:modelValue="value"
:theme="theme"
previewTheme="github"
codeTheme="github"
:showCodeRowNumber="true"
:previewOnly="true"
/>
<!-- <div style="width: 100%; height: 100%" v-html="value" ></div> -->
<template #footer> </template>
</BasicDrawer>
</template>
<script setup lang="ts">
import text from './caozuomiaoshu.md?raw';
// import { MarkdownViewer } from '@/components/Markdown';
import { MdPreview } from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
import { ref, onMounted } from 'vue';
import { BasicDrawer, useDrawer, useDrawerInner } from '@/components/Drawer';
import { useMaxWidthOrDefault } from '@/hooks/web/useSize';
const value = ref<string>('');
const type = ref<string>('markdown');
const MarkdownViewerkeynum = ref<number>(0);
const iframeKey = ref<number>(10);
const drawerWidth = useMaxWidthOrDefault(800);
const textvalue = ref<string>(text);
const [registerDrawer] = useDrawerInner(init);
// 'light' | 'dark'
const theme = ref('light');
onMounted(() => {});
function init(data) {
console.log('DocsDrawer', data, document.documentElement.clientHeight);
if (data) {
value.value = data.value;
type.value = data.type;
MarkdownViewerkeynum.value += 1;
iframeKey.value += 1;
if (type.value == 'def') {
console.log(textvalue.value);
value.value = textvalue.value;
}
}
}
</script>
<style scoped>
iframe {
width: 100%;
}
</style>

164
src/views/documentReview/DocumentTasks/DocumentTasks.data.ts

@ -0,0 +1,164 @@
import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { getDictOptions } from '@/utils/dict';
import { useRender } from '@/hooks/component/useRender';
import { uploadDocument } from '@/api/documentReview/DocumentTasks';
import { useUserStore } from '@/store/modules/user';
import { RoleEnum } from '@/enums/roleEnum';
const { roleList } = useUserStore();
export const formSchemas: FormSchema[] = [
{
label: '任务名称',
field: 'taskNameList',
component: 'Select',
componentProps: {
options: getDictOptions('document_task'),
mode: 'multiple',
},
},
{
label: '文档名称',
field: 'documentName',
component: 'Input',
},
// {
// label: '预计时间',
// field: 'estimatedCompletionTime',
// component: 'DatePicker',
// componentProps: {
// showTime: true,
// format: 'YYYY-MM-DD HH:mm:ss',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// },
// },
{
label: '状态',
field: 'progressStatus',
component: 'Select',
componentProps: {
options: getDictOptions('document_task_status'),
},
},
];
const { renderDict } = useRender();
export const columns: BasicColumn[] = [
{
title: '任务名称',
dataIndex: 'taskName',
customRender: ({ value }) => renderDict(value, 'document_task'),
},
{
title: '文档名称',
dataIndex: 'documentName',
},
{
title: '模型所属区域',
dataIndex: 'taskRegion',
customRender: ({ value }) => renderDict(value, 'model_region'),
},
{
title: '模型所属行业',
dataIndex: 'taskIndustry',
customRender: ({ value }) => renderDict(value, 'model_industry'),
},
{
title: '上传时间',
dataIndex: 'createTime',
},
{
title: '提交人',
dataIndex: 'createUser',
auth: 'documentReview:DocumentTasks:tableShow',
},
{
title: '任务耗时',
dataIndex: 'taskDuration',
},
{
title: '状态',
dataIndex: 'progressStatus',
customRender: ({ value }) => renderDict(value, 'document_task_status'),
},
];
export const modalSchemas: FormSchema[] = [
{
label: '模型所属区域',
field: 'taskRegion',
required: true,
component: 'Select',
// componentProps: {
// options: taskRegionPermission(),
// defaultValue:"normal",
// },
componentProps: () => {
const isSuperAdmin = roleList.includes(RoleEnum.SUPER_ADMIN);
let options = getDictOptions('model_region');
if (!isSuperAdmin) {
// 如果不是超级管理员,移除 label 带有 '#' 的项
options = options.filter((option) => !option.label.includes('#'));
}
return {
options: options,
defaultValue: 'normal',
};
},
},
{
label: '模型所属行业',
field: 'taskIndustry',
required: true,
component: 'Select',
componentProps: {
options: getDictOptions('model_industry'),
defaultValue: 'normal',
},
},
{
label: '任务名称',
field: 'taskNameList',
required: true,
component: 'Select',
componentProps: {
options: getDictOptions('document_task'),
mode: 'multiple',
},
},
{
label: '文档名称',
field: 'ossId',
required: true,
component: 'Upload',
componentProps: {
accept: ['.docx', '.doc', '.wps'],
maxSize: 500,
multiple: false,
resultField: 'ossId',
api: uploadDocument,
beforeUploadPrompt:"严禁在本互联网非涉密平台处理、传输国家秘密。请再次确认您上传的文件资料不涉及国家秘密。"
},
},
// {
// label: '预计时间',
// field: 'estimatedCompletionTime',
// required: true,
// component: 'DatePicker',
// componentProps: {
// showTime: true,
// format: 'YYYY-MM-DD HH:mm:ss',
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// },
// },
// {
// label: '状态',
// field: 'progressStatus',
// required: true,
// component: 'Select',
// componentProps: {
// options: getDictOptions('document_task_status')
// },
// },
];

79
src/views/documentReview/DocumentTasks/DocumentTasksModal.vue

@ -0,0 +1,79 @@
<template>
<PageWrapper dense>
<BasicModal
v-bind="$attrs"
:title="title"
@register="registerInnerModal"
@ok="handleSubmit"
@cancel="resetForm"
>
<BasicForm @register="registerForm" />
</BasicModal>
</PageWrapper>
</template>
<script setup lang="ts">
import { PageWrapper } from '@/components/Page';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { computed, ref, unref } from 'vue';
import {
DocumentTasksInfo,
DocumentTasksAdd,
DocumentTasksUpdate,
} from '@/api/documentReview/DocumentTasks';
import { ModelUserPromptssettingInfoByUserId } from '@/api/modelConfiguration/ModelUserPromptssetting/index';
import { modalSchemas } from './DocumentTasks.data';
defineOptions({ name: 'DocumentTasksModal' });
const emit = defineEmits(['register', 'reload']);
const isUpdate = ref<boolean>(false);
const title = computed<string>(() => {
return isUpdate.value ? '编辑文档任务' : '新增文档任务';
});
const [registerInnerModal, { modalLoading, closeModal }] = useModalInner(
async (data: { record?: Recordable; update: boolean }) => {
modalLoading(true);
const settings = await ModelUserPromptssettingInfoByUserId();
await setFieldsValue(settings);
//
// const { record, update } = data;
// isUpdate.value = update;
// if (update && record) {
// const ret = await DocumentTasksInfo(record.id);
// await setFieldsValue(ret);
// }
modalLoading(false);
},
);
const [registerForm, { setFieldsValue, resetForm, validate }] = useForm({
labelWidth: 100,
showActionButtonGroup: false,
baseColProps: { span: 24 },
schemas: modalSchemas,
});
async function handleSubmit() {
try {
modalLoading(true);
const data = await validate();
data['ossId'] = data['ossId'][0];
if (unref(isUpdate)) {
await DocumentTasksUpdate(data);
} else {
await DocumentTasksAdd(data);
}
emit('reload');
closeModal();
await resetForm();
} catch (e) {
} finally {
modalLoading(false);
}
}
</script>
<style scoped></style>

2248
src/views/documentReview/DocumentTasks/caozuomiaoshu.md

File diff suppressed because it is too large

241
src/views/documentReview/DocumentTasks/index.vue

@ -0,0 +1,241 @@
<template>
<PageWrapper dense>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button id="how-to-edit" class="font-bold" type="link" @click="openDrawer(true,{ value: '', type: 'def' })"
>👉如何新增任务?
</a-button>
<!-- <a-button
@click="downloadExcel(DocumentTasksExport, '文档任务数据', getForm().getFieldsValue())"
v-auth="'productManagement:DocumentTasks:export'"
>导出</a-button
>
<a-button
type="primary"
danger
@click="multipleRemove(DocumentTasksRemove)"
:disabled="!selected"
v-auth="'productManagement:DocumentTasks:remove'"
>删除</a-button
> -->
<a-button type="primary" @click="handleAdd">新增</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
stopButtonPropagation
:actions="[
{
label: '详情',
icon: IconEnum.EDIT,
type: 'primary',
ghost: true,
ifShow: () => {
if (
record.progressStatus != 'PENDING' &&
record.progressStatus != 'STARTED' &&
record.progressStatus != 'REVOKED'
) {
return true;
} else {
return false;
}
},
onClick: handleDetail.bind(null, record),
},
{
label: '终止任务',
icon: IconEnum.DELETE,
type: 'primary',
danger: true,
ghost: true,
ifShow: () => {
if (record.progressStatus == 'PENDING') {
return true;
} else {
return false;
}
},
popConfirm: {
placement: 'left',
title: '是否终止当前任务?',
confirm: handleStop.bind(null, record),
},
},
]"
/>
</template>
</template>
<!-- <template #headerTop>
<div class="container mx-auto mt-4 mb-4 h-20">
<div class="grid grid-cols-3 gap-3 h-full">
<div class="bg-[#1890FF] opacity-100 h-full">
<div class="grid grid-cols-4 gap-1 h-full">
<div class="col-span-3 mt-4 ml-4 text-white">每日文档数</div>
<div
class="col-span-1 flex justify-center items-center text-white text-4xl font-bold"
>{{ documentData?.dailyDocumentCount }}</div
>
</div>
</div>
<div class="bg-[#1890FF] opacity-100 h-full">
<div class="grid grid-cols-4 gap-1 h-full">
<div class="col-span-3 mt-4 ml-4 text-white">当日剩余文档数</div>
<div
class="col-span-1 flex justify-center items-center text-white text-4xl font-bold"
>{{ documentData?.remainingTasksToday }}</div
>
</div>
</div>
<div class="bg-[#1890FF] opacity-100 h-full">
<div class="grid grid-cols-4 gap-1 h-full">
<div class="col-span-3 mt-4 ml-4 text-white">优先级</div>
<div
class="col-span-1 flex justify-center items-center text-white text-4xl font-bold"
>{{ documentData?.priority }}</div
>
</div>
</div>
</div>
</div>
</template> -->
</BasicTable>
<DocumentTasksModal @register="registerModal" @reload="reload" />
<DocsDrawer @register="registerDrawer" />
</PageWrapper>
</template>
<script setup lang="ts">
import { PageWrapper } from '@/components/Page';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import {
DocumentTasksList,
DocumentTasksExport,
DocumentTasksRemove,
DocumentTasksStop,
} from '@/api/documentReview/DocumentTasks';
import { getTasksPermissionsByUserId } from '@/api/taskPermissions/DocumentTasksPermissions';
import { DocumentTaskResultsInfoByTaskId } from '@/api/documentReview/DocumentTaskResults';
import { useModal } from '@/components/Modal';
import DocumentTasksModal from './DocumentTasksModal.vue';
import { formSchemas, columns } from './DocumentTasks.data';
import { IconEnum } from '@/enums/appEnum';
import { useDrawer } from '@/components/Drawer';
import DocsDrawer from '@/views/documentReview/DocumentTasks/DocsDrawer.vue';
import { onMounted, ref } from 'vue';
import { DocumentTasksPermissionsVO } from '@/api/taskPermissions/DocumentTasksPermissions/model';
defineOptions({ name: 'DocumentTasks' });
const documentData = ref<DocumentTasksPermissionsVO>();
const [registerDrawer, { openDrawer }] = useDrawer();
const [registerTable, { reload, multipleRemove, selected, getForm }] = useTable({
rowSelection: {
type: 'checkbox',
},
title: '文档任务列表',
api: DocumentTasksList,
showIndexColumn: false,
rowKey: 'id',
useSearchForm: true,
formConfig: {
schemas: formSchemas,
baseColProps: {
xs: 24,
sm: 24,
md: 24,
lg: 6,
},
},
columns: columns,
actionColumn: {
width: 200,
title: '操作',
key: 'action',
fixed: 'right',
},
});
// 便
const timer = ref<any>(null);
//loading 便
const loading = ref(false);
//使countdown autoRefreshTime
const countdown = ref(0);
// 6 6
const autoRefreshTime = ref(30);
const [registerModal, { openModal }] = useModal();
onMounted(async () => {
documentData.value = await getTasksPermissionsByUserId();
timer.value = window.setInterval(() => {
//loading
if (!loading.value) {
//countdown +1
if (countdown.value < autoRefreshTime.value) {
countdown.value = countdown.value + 1;
// refresh()
if (countdown.value === autoRefreshTime.value) {
countdown.value =0
reload()
}
}
}
}, 1000);
});
const cleanHtml = (content) => {
// DOCTYPEhtml
content = content.replace(/<!DOCTYPE[^>]*>/i, '')
content = content.replace(/<html[^>]*>/i, '')
content = content.replace(/<\/html>/i, '')
// head
content = content.replace(/<head>[\s\S]*?<\/head>/i, '')
// body
content = content.replace(/<body[^>]*>/i, '')
content = content.replace(/<\/body>/i, '')
return content.trim()
}
async function handleDetail(record: Recordable) {
try {
let res = await DocumentTaskResultsInfoByTaskId(record.id);
if (record.taskName == 'schemEvaluation') {
// res.result=generateTable(JSON.parse(res.result as string))
const updatedHtmlText = res.result?.replace(
/文件名称:\S+/g,
`文件名称:${record.documentName}`,
);
openDrawer(true, { value: cleanHtml(updatedHtmlText), type: 'markdown' });
}else if(record.taskName =="checkDocumentError"){
openDrawer(true, { value: res.result, type: 'markdown' });
}
else {
openDrawer(true, { value: res.result, type: 'markdown' });
}
console.log('res', res);
} catch (ex) {
openDrawer(true, { value: '加载失败,请刷新页面', type: 'markdown' });
}
//record.id
}
async function handleStop(record: Recordable) {
await DocumentTasksStop(record.id);
await reload();
}
function handleAdd() {
openModal(true, { update: false });
}
async function handleDelete(record: Recordable) {
await DocumentTasksRemove([record.id]);
await reload();
}
</script>
<style scoped></style>
Loading…
Cancel
Save