Hu Cheng %!s(int64=2) %!d(string=hai) anos
pai
achega
a3a99730d1

+ 1 - 1
src/api/modules/TaskData.js

@@ -71,7 +71,7 @@ export const editTaskData = (data) => {
   });
 };
 
-// 任务数据(编辑
+// 任务数据(删除
 export const deleteTaskData = (data) => {
   return service.request({
     method: 'POST',

+ 0 - 56
src/plugin/highcharts.js

@@ -4,62 +4,6 @@ import boostInit from 'highcharts/modules/boost';
 import exportingInit from 'highcharts/modules/exporting';
 import exportDataInit from 'highcharts/modules/export-data';
 
-Highcharts.setOptions({
-  lang: {
-    contextButtonTitle: '图表导出菜单',
-    decimalPoint: '.',
-    downloadJPEG: '下载JPEG图片',
-    downloadPDF: '下载PDF文件',
-    downloadPNG: '下载PNG文件',
-    downloadSVG: '下载SVG文件',
-    drillUpText: '返回 {series.name}',
-    loading: '加载中',
-    months: [
-      '一月',
-      '二月',
-      '三月',
-      '四月',
-      '五月',
-      '六月',
-      '七月',
-      '八月',
-      '九月',
-      '十月',
-      '十一月',
-      '十二月',
-    ],
-    noData: '没有数据',
-    numericSymbols: ['千', '兆', 'G', 'T', 'P', 'E'],
-    printChart: '打印图表',
-    resetZoom: '恢复缩放',
-    resetZoomTitle: '恢复图表',
-    shortMonths: [
-      'Jan',
-      'Feb',
-      'Mar',
-      'Apr',
-      'May',
-      'Jun',
-      'Jul',
-      'Aug',
-      'Sep',
-      'Oct',
-      'Nov',
-      'Dec',
-    ],
-    thousandsSep: ',',
-    weekdays: [
-      '星期一',
-      '星期二',
-      '星期三',
-      '星期四',
-      '星期五',
-      '星期六',
-      '星期天',
-    ],
-  },
-});
-
 stockInit(Highcharts);
 boostInit(Highcharts);
 exportingInit(Highcharts);

+ 29 - 29
src/router/index.js

@@ -1,57 +1,57 @@
-import { createRouter, createWebHashHistory } from "vue-router";
-import LayoutView from "../layout/index.vue";
-import LoginView from "../login/index.vue";
-import { getToken } from "@/utils/storage/sessionToken";
-import { loadingBar } from "@/plugin/naive-ui";
+import { createRouter, createWebHashHistory } from 'vue-router';
+import LayoutView from '../layout/index.vue';
+import LoginView from '../login/index.vue';
+import { getToken } from '@/utils/storage/sessionToken';
+import { loadingBar } from '@/plugin/naive-ui';
 
 const router = createRouter({
   history: createWebHashHistory(import.meta.env.BASE_URL),
   routes: [
     {
-      path: "/",
+      path: '/',
       component: LayoutView,
-      redirect: "/project",
+      redirect: '/project',
       children: [
         {
-          path: "/project",
-          component: () => import("@/views/project/index.vue"),
+          path: '/project',
+          component: () => import('@/views/project/index.vue'),
         },
         {
-          path: "/certificate",
-          component: () => import("@/views/certificate/index.vue"),
+          path: '/certificate',
+          component: () => import('@/views/certificate/index.vue'),
         },
         {
-          path: "/scheme",
-          component: () => import("@/views/scheme/index.vue"),
+          path: '/scheme',
+          component: () => import('@/views/scheme/index.vue'),
         },
         {
-          path: "/equipment",
-          component: () => import("@/views/equipment/index.vue"),
+          path: '/equipment',
+          component: () => import('@/views/equipment/index.vue'),
         },
         {
-          path: "/data_source",
-          component: () => import("@/views/data/source/index.vue"),
+          path: '/data_source',
+          component: () => import('@/views/data/source/index.vue'),
         },
         {
-          path: "/data_edit",
-          component: () => import("@/views/data/edit/index.vue"),
+          path: '/data_edit',
+          component: () => import('@/views/data/edit/index.vue'),
         },
         {
-          path: "/data_checkout",
-          component: () => import("@/views/data/checkout/index.vue"),
+          path: '/data_checkout',
+          component: () => import('@/views/data/checkout/index.vue'),
         },
         {
-          path: "/report_create",
-          component: () => import("@/views/report/create/index.vue"),
+          path: '/report_create',
+          component: () => import('@/views/report/create/index.vue'),
         },
         {
-          path: "/report_audit",
-          component: () => import("@/views/report/audit/index.vue"),
+          path: '/report_audit',
+          component: () => import('@/views/report/audit/index.vue'),
         },
       ],
     },
     {
-      path: "/login",
+      path: '/login',
       component: LoginView,
     },
   ],
@@ -61,15 +61,15 @@ const router = createRouter({
 router.beforeEach((to, from, next) => {
   loadingBar.start();
   const token = getToken();
-  if (to.path === "/login") {
+  if (to.path === '/login') {
     if (!token) {
       next();
     } else {
-      next("/");
+      next('/');
     }
   } else {
     if (!token) {
-      next("/login");
+      next('/login');
     } else {
       next();
     }

+ 4 - 7
src/utils/axios.js

@@ -2,18 +2,15 @@ import axios from 'axios';
 import { getToken } from '@/utils/storage/sessionToken';
 import { TOKEN } from '@/constant';
 import { loadingBar, message } from '@/plugin/naive-ui';
-import { useRouter } from 'vue-router';
-
-const router = useRouter();
 
 // 显示消息
 const showError = (res) => {
-  if (res.Code !== 200) {
-    message.error(res.Msg);
-  } else if (res.Code === 201) {
+  if (res.Code === 201) {
     message.error('登录过期,请重新登录');
     window.sessionStorage.clear();
-    router.replace('/login');
+    window.location.reload();
+  } else if (res.Code !== 200) {
+    message.error(res.Msg);
   }
 };
 

+ 5 - 0
src/views/data/edit/HumidityChart.vue

@@ -0,0 +1,5 @@
+<template></template>
+
+<script setup></script>
+
+<style scoped></style>

+ 0 - 1
src/views/data/edit/ImportPlatform.vue

@@ -118,7 +118,6 @@ const showImportModal = () => {
 
 //
 const handleImport = () => {
-  console.log(data.value.Data);
   if (data.value.Data) {
     data.value.Data.forEach((item, index) => {
       const code = addTask(item);

+ 77 - 0
src/views/data/edit/TemperatureChart.vue

@@ -0,0 +1,77 @@
+<template>
+  <Chart
+    :style="{ minHeight: `${minHeight}px` }"
+    ref="chart"
+    constructor-type="stockChart"
+    :options="options"
+  ></Chart>
+</template>
+
+<script setup>
+import { Chart } from 'highcharts-vue';
+
+defineProps({
+  minHeight: {
+    type: Number,
+    default: 0,
+  },
+  dataList: {
+    type: Array,
+    default: () => [],
+  },
+});
+
+// 图表配置
+const options = {
+  xAxis: {
+    labels: {
+      format: '{value:%Y-%m-%d %H:%M:%S}',
+    },
+  },
+
+  yAxis: {
+    // labels: {
+    //   format: `{text}℃`,
+    // },
+    plotLines: [],
+  },
+
+  legend: {
+    enabled: true,
+  },
+
+  accessibility: {
+    enabled: false,
+  },
+
+  chart: {
+    zoomType: 'xy',
+  },
+
+  boost: {
+    useGPUTranslations: true,
+    seriesThreshold: 5,
+  },
+
+  title: {
+    text: '车载冷藏箱',
+  },
+
+  subtitle: {
+    align: 'left',
+    text: '车载冷藏箱',
+  },
+
+  tooltip: {
+    valueDecimals: 2,
+  },
+
+  series: [],
+
+  scrollbar: {
+    enabled: false,
+  },
+};
+</script>
+
+<style scoped></style>

+ 59 - 47
src/views/data/edit/index.vue

@@ -7,7 +7,11 @@
       <n-card>
         <n-list>
           <template #header>
-            <n-checkbox label="全选" @update:checked="handleCheckAll" />
+            <n-checkbox
+              v-model:checked="checkValueAll"
+              label="全选"
+              @update:checked="handleCheckAll"
+            />
           </template>
           <n-scrollbar
             :style="{ maxHeight: `${height - 260}px` }"
@@ -168,8 +172,8 @@ const task = window.sessionStorage.getItem('task')
 const chart1 = ref(null);
 const chart2 = ref(null);
 
-const chartData1 = ref([]);
-const chartData2 = ref([]);
+// const chartData1 = ref([]);
+// const chartData2 = ref([]);
 
 // Modal 数据源
 const modal = reactive({
@@ -209,10 +213,12 @@ const checkValues = ref([]);
 // tab
 const tabChart = ref('温度');
 
+const checkValueAll = ref(false);
+
 const handleTabChange = (value) => {
-  if (value === '温度') {
-  } else {
-  }
+  console.log(value);
+  checkValues.value = [];
+  checkValueAll.value = false;
 };
 
 //
@@ -262,8 +268,8 @@ const handleSet = (data) => {
 };
 
 // 全选
-const handleCheckAll = (checked) => {
-  if (checked) {
+const handleCheckAll = () => {
+  if (checkValueAll.value) {
     checkValues.value = classList.value.map((item) => item.T_id);
     checkValues.value.forEach(async (item) => {
       queryData.T_id = item;
@@ -274,56 +280,62 @@ const handleCheckAll = (checked) => {
       const data2 = dataList.value
         .map((item) => [new Date(item.T_time).getTime(), item.T_rh])
         .sort((a, b) => a[0] - b[0]);
-      chart1.value.chart.addSeries({
-        id: item,
-        name: item,
-        data: data1,
-        lineWidth: 1,
-        cursor: 'pointer',
-        events: {
-          click(e) {
-            modal.title = '温度';
-            modal.showModal = true;
-            formValue.T_t = e.point.y;
-            queryData.T_id = e.point.series.name;
-            getDataList();
-            dataInfo.value = dataList.value[e.point.index];
+      if (tabChart.value === '温度') {
+        chart1.value.chart.addSeries({
+          id: item,
+          name: item,
+          data: data1,
+          lineWidth: 1,
+          cursor: 'pointer',
+          events: {
+            click(e) {
+              modal.title = '温度';
+              modal.showModal = true;
+              formValue.T_t = e.point.y;
+              queryData.T_id = e.point.series.name;
+              getDataList();
+              dataInfo.value = dataList.value[e.point.index];
+            },
           },
-        },
-      });
-      chart2.value.chart.addSeries({
-        id: item,
-        name: item,
-        data: data2,
-        lineWidth: 1,
-        cursor: 'pointer',
-        events: {
-          click(e) {
-            modal.title = '湿度';
-            modal.showModal = true;
-            formValue.T_rh = e.point.y;
-            queryData.T_id = e.point.series.name;
-            getDataList();
-            dataInfo.value = dataList.value[e.point.index];
+        });
+      } else {
+        chart2.value.chart.addSeries({
+          id: item,
+          name: item,
+          data: data2,
+          lineWidth: 1,
+          cursor: 'pointer',
+          events: {
+            click(e) {
+              modal.title = '湿度';
+              modal.showModal = true;
+              formValue.T_rh = e.point.y;
+              queryData.T_id = e.point.series.name;
+              getDataList();
+              dataInfo.value = dataList.value[e.point.index];
+            },
           },
-        },
-      });
+        });
+      }
     });
   } else {
     const arr = checkValues.value;
-    arr.forEach(async (item) => {
-      chart1.value.chart.get(item).remove();
-    });
-    arr.forEach(async (item) => {
-      chart2.value.chart.get(item).remove();
-    });
+    if (tabChart.value === '温度') {
+      arr.forEach(async (item) => {
+        chart1.value.chart.get(item).remove();
+      });
+    } else {
+      arr.forEach(async (item) => {
+        chart2.value.chart.get(item).remove();
+      });
+    }
     checkValues.value = [];
   }
 };
 
 // 选项组的值改变时的回调
 const onUpdateValues = async (values, meta) => {
-  const classInfo = values.find((item) => item.T_id === meta.value);
+  const classInfo = classList.value.find((item) => item.T_id === meta.value);
   queryData.T_id = classInfo.T_id;
   queryData.T_sn = classInfo.T_sn;
   await getDataList();

+ 25 - 19
src/views/equipment/index.vue

@@ -19,7 +19,6 @@
       remote
       :columns="columns"
       :data="data"
-      :pagination="pagination"
       :bordered="false"
       flex-height
       class="flex-1"
@@ -53,7 +52,13 @@
         </n-form-item>
       </template>
       <n-form-item label="备注" path="T_remark">
-        <n-select v-model:value="formValue.T_remark" :options="remarkOptions" />
+        <n-space vertical class="w-full">
+          <n-select
+            :options="remarkOptions"
+            @update:value="(value) => (formValue.T_remark = value)"
+          />
+          <n-input v-model:value="formValue.T_remark" type="textarea" />
+        </n-space>
       </n-form-item>
     </n-form>
   </n-modal>
@@ -162,16 +167,16 @@ const columns = [
 const data = ref([]);
 
 // 分页数据源
-const pagination = reactive({
-  page: queryData.page,
-  pageSize: queryData.page_z,
-  itemCount: 0,
-  onChange: (page) => {
-    pagination.page = page;
-    queryData.page = page;
-    getDataList();
-  },
-});
+// const pagination = reactive({
+//   page: queryData.page,
+//   pageSize: queryData.page_z,
+//   itemCount: 0,
+//   onChange: (page) => {
+//     pagination.page = page;
+//     queryData.page = page;
+//     getDataList();
+//   },
+// });
 
 // 模态框数据源
 const modal = reactive({
@@ -184,6 +189,7 @@ const formValue = reactive({
   T_snid: '',
   T_id: 0,
   T_remark: '',
+  remark: '',
 });
 
 // 输入框点击清空按钮时触发
@@ -198,8 +204,9 @@ const submitCallback = () => {
     const arr = formValue.T_snid.split('\n');
     arr.forEach((item) => {
       const [T_sn, T_id] = item.split('-');
-      addDeviceClass(T_sn, T_id, formValue.T_remark);
+      addDeviceClass(T_sn, T_id);
     });
+    getDataList();
   } else {
     editDeviceClass();
   }
@@ -254,17 +261,17 @@ const editDeviceClass = async () => {
   }
 };
 
-// 添加
-const addDeviceClass = async (T_sn, T_id, T_remark) => {
+// 批量导入
+const addDeviceClass = async (T_sn, T_id) => {
   try {
     const { data: res } = await addDeviceClassList({
       T_class: queryData.T_class,
       T_sn,
       T_id,
-      T_remark,
+      T_remark: formValue.T_remark,
     });
-    if (res.Code === 200) {
-      getDataList();
+    if (res.Code !== 200) {
+      return false;
     }
   } catch (e) {
     console.log(e);
@@ -275,7 +282,6 @@ const addDeviceClass = async (T_sn, T_id, T_remark) => {
 const getDataList = async () => {
   try {
     const { data: res } = await getDeviceClassListList(queryData);
-    pagination.itemCount = res.Data.Num;
     data.value = res.Data.List || [];
   } catch (e) {
     console.log(e);

+ 11 - 7
src/views/project/index.vue

@@ -12,7 +12,7 @@
 
 <script setup>
 import { h } from 'vue';
-import { NButton, NSpace, NCard, NTag, NIcon, NTooltip } from 'naive-ui';
+import { NButton, NSpace, NCard, NTag, NIcon, NPopover } from 'naive-ui';
 import { getTaskList } from '@/api';
 import { ArrowRightOutlined as ArrowRightIcon } from '@vicons/antd';
 
@@ -29,11 +29,15 @@ const queryData = reactive({
 // 任务列表
 const data = ref([]);
 
-const renderTooltip = (trigger, content) => {
-  return h(NTooltip, null, {
-    trigger: () => trigger,
-    default: () => h(NSpace, null, { default: () => content }),
-  });
+const renderPopover = (trigger, content) => {
+  return h(
+    NPopover,
+    { trigger: 'hover' },
+    {
+      trigger: () => trigger,
+      default: () => h(NSpace, null, { default: () => content }),
+    }
+  );
 };
 
 // 需要展示的列
@@ -55,7 +59,7 @@ const columns = [
   },
   {
     title() {
-      return renderTooltip(
+      return renderPopover(
         '流程(?)',
         [0, 1, 2, 3].map((item) =>
           h(

+ 37 - 19
src/views/report/audit/TabThree.vue

@@ -5,11 +5,11 @@
         <template #header>
           <h2>校准证书</h2>
         </template>
-        <n-scrollbar :style="{ maxHeight: `${height - 450}px`, paddingRight: '20px' }" trigger="none">
-          <template
-            v-for="item of dataList"
-            :key="item"
-          >
+        <n-scrollbar
+          :style="{ maxHeight: `${height - 450}px`, paddingRight: '20px' }"
+          trigger="none"
+        >
+          <template v-for="item of dataList" :key="item">
             <n-list-item>
               <template #suffix>
                 <n-button type="primary" @click="handleView(item)"
@@ -21,7 +21,7 @@
                 :bordered="false"
                 :content-style="{ padding: '5px', textAlign: 'center' }"
               >
-                {{ item.slice(item.lastIndexOf("-") + 1) }}
+                {{ item.T_id }}
               </n-card>
             </n-list-item>
           </template>
@@ -44,11 +44,12 @@
 </template>
 
 <script setup>
-import VuePdfEmbed from "vue-pdf-embed";
-import { PrinterOutlined as PrinterIcon } from "@vicons/antd";
+import VuePdfEmbed from 'vue-pdf-embed';
+import { PrinterOutlined as PrinterIcon } from '@vicons/antd';
+import { getDeviceClassListList } from '@/api';
 
 const props = defineProps({
-  taskInfo: {
+  task: {
     required: true,
     default: {},
   },
@@ -58,25 +59,42 @@ const props = defineProps({
   },
 });
 
-//
-const source = ref("");
+// 查询参数
+const queryData = reactive({
+  T_sn: '',
+  T_class: props.task.T_class,
+});
 
-//
-const handleView = (row) => {
-  source.value = row.slice(0, row.lastIndexOf("-"));
-};
+// pdf源
+const source = ref('');
 
-//
-const dataList = computed(() => {
-  return props.taskInfo.T_pdf3.split("|").filter((item) => item);
-});
+// 列表
+const dataList = ref([]);
 
+// pdf组件ref
 const pdfRef = ref(null);
 
+// 查看
+const handleView = (row) => {
+  source.value = row.T_pdf;
+};
+
 // 打印pdf
 const onPrint = () => {
   pdfRef.value.print();
 };
+
+// 获取列表
+const getDataList = async () => {
+  try {
+    const { data: res } = await getDeviceClassListList(queryData);
+    dataList.value = res.Data.List || [];
+  } catch (e) {
+    console.log(e);
+  }
+};
+
+getDataList();
 </script>
 
 <style lang="scss" scoped></style>

+ 13 - 13
src/views/report/audit/index.vue

@@ -43,7 +43,7 @@
         </n-scrollbar>
       </n-tab-pane>
       <n-tab-pane class="h-full flex flex-col gap-y-3" name="3" tab="校准证书">
-        <TabThree :taskInfo="taskInfo" :height="height" />
+        <TabThree :task="task" :height="height" />
       </n-tab-pane>
       <n-tab-pane class="h-full flex flex-col gap-y-3" name="4" tab="验证数据">
         <TabFour :task="task" />
@@ -53,12 +53,12 @@
 </template>
 
 <script setup>
-import VuePdfEmbed from "vue-pdf-embed";
-import { getTask, updateTaskData } from "@/api";
-import { PrinterOutlined as PrinterIcon } from "@vicons/antd";
-import TabThree from "./TabThree.vue";
-import TabFour from "./TabFour.vue";
-import { useWindowSize } from "@vueuse/core";
+import VuePdfEmbed from 'vue-pdf-embed';
+import { getTask, updateTaskData } from '@/api';
+import { PrinterOutlined as PrinterIcon } from '@vicons/antd';
+import TabThree from './TabThree.vue';
+import TabFour from './TabFour.vue';
+import { useWindowSize } from '@vueuse/core';
 
 const { height } = useWindowSize();
 
@@ -66,8 +66,8 @@ const dialog = useDialog();
 
 const message = useMessage();
 
-const task = window.sessionStorage.getItem("task")
-  ? JSON.parse(window.sessionStorage.getItem("task"))
+const task = window.sessionStorage.getItem('task')
+  ? JSON.parse(window.sessionStorage.getItem('task'))
   : {};
 
 const pdfRef = ref(null);
@@ -83,10 +83,10 @@ const onPrint = () => {
 //
 const handleCheck = () => {
   dialog.info({
-    title: "审核",
-    content: "请仔细检查报告内容、报告证书、报告数据都是否有误?",
-    positiveText: "确定都没有问题",
-    negativeText: "取消",
+    title: '审核',
+    content: '请仔细检查报告内容、报告证书、报告数据都是否有误?',
+    positiveText: '确定都没有问题',
+    negativeText: '取消',
     maskClosable: false,
     onPositiveClick: updateTask,
   });

+ 77 - 87
src/views/report/create/index.vue

@@ -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>

+ 72 - 87
src/views/scheme/index.vue

@@ -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" :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 { NButton } from 'naive-ui';
 import { useWindowSize } from '@vueuse/core';
+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 pdf1 = ref('');
 
-// CAD索引
-const cadIndex = ref(0);
-
 // 查询数据
 const queryData = reactive({
   T_source: 1,
@@ -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}`
   );
@@ -339,24 +377,6 @@ const editTaskInfo = async () => {
 };
 
 /**
- * 显示生成报告
- * @returns {Promise<void>}
- */
-const showCreateDialog = () => {
-  dialog.info({
-    title: '提示',
-    content: '确认生成报告?',
-    positiveText: '确定',
-    negativeText: '取消',
-    onPositiveClick: () => {
-      putTemplateData();
-    },
-  });
-};
-
-const reportKey = ref('');
-
-/**
  * 生成报告
  * @returns {Promise<void>}
  */
@@ -367,50 +387,32 @@ const generateSchemeInfo = 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}%`,
-      duration: 3000,
-      keepAliveOnHover: true,
-    });
-  } else if (res.Code === 201) {
-    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) {
+  } else {
     clearTimeout(timer);
-    notification.error({
-      title: res.Msg,
-      description: `进度:${res.Schedule}%`,
-      content: items.map((item, index) =>
-        h('p', {}, { default: () => `${index + 1} ${item}` })
-      ),
-    });
   }
 };
 
@@ -460,6 +462,8 @@ const putTemplateData = async () => {
         }
         obj[i.T_name] = i.T_value;
       }
+      modal.title = '生成报告';
+      modal.showModal = true;
       generateSchemeInfo(obj);
     }
   } catch (e) {
@@ -510,25 +514,6 @@ onBeforeUnmount(() => {
 
 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`;
-    }
-  });
-});
 </script>
 
 <style scoped></style>