|
@@ -4,7 +4,12 @@
|
|
|
<template #title> 报告生成 </template>
|
|
|
<template #extra>
|
|
|
<n-space>
|
|
|
- <n-button type="primary" @click="showCreateDialog">生成报告</n-button>
|
|
|
+ <n-popconfirm @positive-click="putTemplateData">
|
|
|
+ <template #trigger>
|
|
|
+ <n-button type="primary">生成报告</n-button>
|
|
|
+ </template>
|
|
|
+ 确认生成报告?
|
|
|
+ </n-popconfirm>
|
|
|
<n-button type="primary" @click="showUploadModal">上传验证</n-button>
|
|
|
</n-space>
|
|
|
</template>
|
|
@@ -149,7 +154,10 @@
|
|
|
</n-form-item>
|
|
|
<n-form-item :label="item.T_name" v-else-if="item.T_label === 11">
|
|
|
<n-image class="mr-5" width="100" v-model:src="item.T_value" />
|
|
|
- <n-button @click="handleEdit(item, index)">编辑</n-button>
|
|
|
+ <n-space>
|
|
|
+ <n-button @click="() => handleEdit(item)">编辑</n-button>
|
|
|
+ <n-button @click="() => handleRefresh(index)">刷新</n-button>
|
|
|
+ </n-space>
|
|
|
<n-popover trigger="hover">
|
|
|
<template #trigger>
|
|
|
<n-icon size="24" class="ml-3">
|
|
@@ -167,14 +175,43 @@
|
|
|
v-model:show="modal.showModal"
|
|
|
:show-icon="false"
|
|
|
preset="dialog"
|
|
|
- title="上传验证实施方案"
|
|
|
- positive-text="确认"
|
|
|
- negative-text="取消"
|
|
|
- @positive-click="editTaskInfo"
|
|
|
+ :title="modal.title"
|
|
|
>
|
|
|
- <n-upload :default-upload="false" :max="1" @change="handleChange">
|
|
|
+ <n-upload
|
|
|
+ :default-upload="false"
|
|
|
+ :max="1"
|
|
|
+ @change="handleChange"
|
|
|
+ v-if="modal.title === '上传验证'"
|
|
|
+ >
|
|
|
<n-button> 上传文件 </n-button>
|
|
|
</n-upload>
|
|
|
+ <n-alert
|
|
|
+ :title="keyInfo.Msg"
|
|
|
+ :type="code === 200 ? 'info' : code === 201 ? 'success' : 'error'"
|
|
|
+ v-else
|
|
|
+ >
|
|
|
+ <div>进度:{{ keyInfo.Schedule }}%</div>
|
|
|
+ <n-list>
|
|
|
+ <n-list-item :key="index" v-for="(item, index) of items">
|
|
|
+ <template #prefix>
|
|
|
+ {{ index }}
|
|
|
+ </template>
|
|
|
+ {{ item }}
|
|
|
+ </n-list-item>
|
|
|
+ </n-list>
|
|
|
+ </n-alert>
|
|
|
+ <template #action>
|
|
|
+ <n-space v-if="modal.title === '上传验证'">
|
|
|
+ <n-button @click="modal.showModal = false">取消</n-button>
|
|
|
+ <n-button type="primary" @click="editTaskInfo">确认</n-button>
|
|
|
+ </n-space>
|
|
|
+ <n-button
|
|
|
+ v-else
|
|
|
+ :disabled="code !== 201"
|
|
|
+ @click="window.location.href = keyInfo.Data"
|
|
|
+ >下载文件</n-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
</n-modal>
|
|
|
</template>
|
|
|
|
|
@@ -193,15 +230,12 @@ import { getFileToken } from '@/common';
|
|
|
import { InformationCircleOutline } from '@vicons/ionicons5';
|
|
|
import { useWindowSize } from '@vueuse/core';
|
|
|
import { NButton } from 'naive-ui';
|
|
|
+import { onBeforeUnmount } from 'vue';
|
|
|
|
|
|
const { height } = useWindowSize();
|
|
|
|
|
|
const message = useMessage();
|
|
|
|
|
|
-const dialog = useDialog();
|
|
|
-
|
|
|
-const notification = useNotification();
|
|
|
-
|
|
|
const task = window.sessionStorage.getItem('task')
|
|
|
? JSON.parse(window.sessionStorage.getItem('task'))
|
|
|
: {};
|
|
@@ -209,9 +243,6 @@ const task = window.sessionStorage.getItem('task')
|
|
|
// 获取表项中收集到的值的对象
|
|
|
const pdf2 = ref('');
|
|
|
|
|
|
-// CAD索引
|
|
|
-const cadIndex = ref(0);
|
|
|
-
|
|
|
// 查询数据
|
|
|
const queryData = reactive({
|
|
|
T_source: 2,
|
|
@@ -228,11 +259,18 @@ const templateList = ref([]);
|
|
|
// 模态框数据源
|
|
|
const modal = reactive({
|
|
|
showModal: false,
|
|
|
+ title: '',
|
|
|
});
|
|
|
|
|
|
+// 刷新CAD
|
|
|
+const handleRefresh = (index) => {
|
|
|
+ templateList.value[
|
|
|
+ index
|
|
|
+ ].T_value = `http://coldverifylocal.coldbaozhida.com/CAD/download?type=upload&filename=${queryData.T_task_id}_${queryData.T_VerifyTemplate_id}_${templateList.value[index].T_id}.png`;
|
|
|
+};
|
|
|
+
|
|
|
// CAD编辑
|
|
|
-const handleEdit = (row, index) => {
|
|
|
- cadIndex.value = index;
|
|
|
+const handleEdit = (row) => {
|
|
|
window.open(
|
|
|
`http://coldverifylocal.coldbaozhida.com/CAD/?task_id=${queryData.T_task_id}&vt_id=${queryData.T_VerifyTemplate_id}&key_id=${row.T_id}`
|
|
|
);
|
|
@@ -326,21 +364,6 @@ const editTaskInfo = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-//
|
|
|
-const showCreateDialog = async () => {
|
|
|
- dialog.info({
|
|
|
- title: '提示',
|
|
|
- content: '确认生成报告?',
|
|
|
- positiveText: '确定',
|
|
|
- negativeText: '取消',
|
|
|
- onPositiveClick: () => {
|
|
|
- putTemplateData();
|
|
|
- },
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
-const reportKey = ref('');
|
|
|
-
|
|
|
/**
|
|
|
* 生成报告
|
|
|
* @returns {Promise<void>}
|
|
@@ -352,51 +375,33 @@ const generateReportInfo = async (obj) => {
|
|
|
...obj,
|
|
|
});
|
|
|
if (res.Code === 200) {
|
|
|
- reportKey.value = res.Data;
|
|
|
- generateKeyInfo();
|
|
|
+ generateKeyInfo(res.Data);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let timer = 0;
|
|
|
-const generateKeyInfo = async () => {
|
|
|
+const keyInfo = ref({});
|
|
|
+const code = ref(0);
|
|
|
+const items = computed(() => {
|
|
|
+ if (keyInfo.value.Item) {
|
|
|
+ return keyInfo.value.Item.split('\n').filter((item) => item);
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const generateKeyInfo = async (key) => {
|
|
|
const { data: res } = await generateKey({
|
|
|
- key: reportKey.value,
|
|
|
+ key,
|
|
|
});
|
|
|
- const items = res.Item.split('\n').filter((item) => item);
|
|
|
+ keyInfo.value = res;
|
|
|
+ code.value = res.Code;
|
|
|
if (res.Code === 200) {
|
|
|
timer = setTimeout(() => {
|
|
|
- generateKeyInfo();
|
|
|
+ generateKeyInfo(key);
|
|
|
}, 3000);
|
|
|
- notification.warning({
|
|
|
- title: res.Msg,
|
|
|
- description: `进度:${res.Schedule}%`,
|
|
|
- content: res.Msg,
|
|
|
- duration: 3000,
|
|
|
- keepAliveOnHover: true,
|
|
|
- });
|
|
|
- } else if (res.Code === 201) {
|
|
|
+ } else {
|
|
|
clearTimeout(timer);
|
|
|
- notification.success({
|
|
|
- title: res.Msg,
|
|
|
- description: `进度:${res.Schedule}%`,
|
|
|
- content: items.map((item, index) =>
|
|
|
- h('p', {}, { default: () => `${index + 1} ${item}` })
|
|
|
- ),
|
|
|
- meta: h(
|
|
|
- NButton,
|
|
|
- { onclick: () => (window.location.href = res.Data) },
|
|
|
- { default: () => '下载文件' }
|
|
|
- ),
|
|
|
- });
|
|
|
- } else if (res.Code === 202) {
|
|
|
- clearTimeout(timer);
|
|
|
- notification.error({
|
|
|
- title: res.Msg,
|
|
|
- description: `进度:${res.Schedule}%`,
|
|
|
- content: items.map((item, index) =>
|
|
|
- h('p', {}, { default: () => `${index + 1} ${item}` })
|
|
|
- ),
|
|
|
- });
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -436,7 +441,6 @@ const putTemplateData = async () => {
|
|
|
VerifyTemplateMapData,
|
|
|
});
|
|
|
if (res.Code === 200) {
|
|
|
- message.success(res.Msg);
|
|
|
const arr = toRaw(templateList.value);
|
|
|
const obj = {};
|
|
|
for (let i of arr) {
|
|
@@ -445,6 +449,8 @@ const putTemplateData = async () => {
|
|
|
}
|
|
|
obj[i.T_name] = i.T_value;
|
|
|
}
|
|
|
+ modal.title = '生成报告';
|
|
|
+ modal.showModal = true;
|
|
|
generateReportInfo(obj);
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -483,28 +489,12 @@ const getTemplateList = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ clearTimeout(timer);
|
|
|
+});
|
|
|
+
|
|
|
getClassList();
|
|
|
getTemplateList();
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- window.document.addEventListener('visibilitychange', () => {
|
|
|
- if (document.visibilityState === 'hidden') {
|
|
|
- // 离开当前tab标签
|
|
|
- console.log('离开当前tab标签');
|
|
|
- } else {
|
|
|
- // 回到当前tab标签
|
|
|
- console.log('回到当前tab标签');
|
|
|
- templateList.value[
|
|
|
- cadIndex.value
|
|
|
- ].T_value = `http://coldverifylocal.coldbaozhida.com/CAD/download?type=upload&filename=${
|
|
|
- queryData.T_task_id
|
|
|
- }_${queryData.T_VerifyTemplate_id}_${
|
|
|
- templateList.value[cadIndex.value].T_id
|
|
|
- }.png`;
|
|
|
- console.log(templateList.value[cadIndex.value].T_value);
|
|
|
- }
|
|
|
- });
|
|
|
-});
|
|
|
</script>
|
|
|
|
|
|
<style scoped></style>
|