Browse Source

feat(all): update

Hu Cheng 1 year ago
parent
commit
d45e56c153

+ 3 - 2
src/api/modules/TaskData.js

@@ -1,5 +1,6 @@
 import service from '@/utils/axios';
 import { baseURL4 } from '@/constant';
+import { baseURL1 } from '../../constant';
 
 // 任务数据 设备列表
 export const getTaskDataClassList = (data) => {
@@ -15,7 +16,7 @@ export const getTaskDataClassList = (data) => {
 export const checkTaskData = (data) => {
   return service.request({
     method: 'POST',
-    url: '/api/TaskData/Check',
+    url: '/TaskData/Check',
     data,
     baseURL: baseURL4,
   });
@@ -27,7 +28,7 @@ export const extractTaskData = (data) => {
     method: 'POST',
     url: '/TaskData/Extract_TaskData',
     data,
-    baseURL: baseURL4,
+    baseURL: baseURL1,
   });
 };
 

+ 0 - 7
src/router/index.js

@@ -2,7 +2,6 @@ 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),
@@ -59,7 +58,6 @@ const router = createRouter({
 
 // 全局前置路由守卫
 router.beforeEach((to, from, next) => {
-  loadingBar.start();
   const token = getToken();
   if (to.path === '/login') {
     if (!token) {
@@ -76,9 +74,4 @@ router.beforeEach((to, from, next) => {
   }
 });
 
-// 全局后置路由守卫
-router.afterEach(() => {
-  loadingBar.finish();
-});
-
 export default router;

+ 10 - 3
src/utils/axios.js

@@ -1,14 +1,17 @@
 import axios from 'axios';
 import { getToken } from '@/utils/storage/sessionToken';
 import { TOKEN } from '@/constant';
-import { loadingBar, message } from '@/plugin/naive-ui';
+import { createDiscreteApi } from 'naive-ui';
+import router from '../router';
+
+const { message, loadingBar } = createDiscreteApi(['message', 'loadingBar']);
 
 // 显示消息
 const showError = (res) => {
   if (res.Code === 201) {
     message.error('登录过期,请重新登录');
     window.sessionStorage.clear();
-    window.location.reload();
+    router.replace('/login');
   } else if (res.Code !== 200 && res.Code !== 600 && res.Code !== 601) {
     message.error(res.Msg);
   }
@@ -33,7 +36,11 @@ service.interceptors.request.use(
         formData.append(TOKEN, token);
       }
       Object.entries(config.data).forEach(([key, value]) => {
-        formData.append(key, value);
+        if (value === null || value === undefined) {
+          formData.append(key, '');
+        } else {
+          formData.append(key, value);
+        }
       });
       config.data = formData;
     } else {

+ 76 - 57
src/views/data/edit/ImportPlatform.vue

@@ -39,55 +39,55 @@
         </n-form>
         <template #action>
           <div class="flex justify-end">
-            <n-button type="primary" @click="getData">查询</n-button>
+            <n-button type="primary" @click="getDataList">查询</n-button>
+          </div>
+        </template>
+      </n-card>
+      <n-card title="数据总量">
+        <template #header-extra>
+          <n-spin :show="spinShow">
+            <n-progress
+              type="dashboard"
+              gap-position="bottom"
+              :percentage="100"
+            >
+              <span class="text-center font-bold"
+                >{{ percentage }}/{{ total }}</span
+              >
+            </n-progress>
+          </n-spin>
+        </template>
+        <n-descriptions bordered class="mt-auto">
+          <n-descriptions-item label="SN">
+            {{ formValue.T_sn }}
+          </n-descriptions-item>
+          <n-descriptions-item label="探头编号">
+            {{ formValue.T_id }}
+          </n-descriptions-item>
+        </n-descriptions>
+        <template #action>
+          <div class="flex justify-end">
+            <n-popconfirm @positive-click="handleImport">
+              <template #trigger>
+                <n-button type="primary">导入</n-button>
+              </template>
+              是否确认导入?
+            </n-popconfirm>
           </div>
         </template>
       </n-card>
-      <n-spin :show="show">
-        <n-card class="h-full" title="导入后的参数">
-          <template #header-extra>
-            <n-statistic label="数据总量" :value="data.Num" />
-          </template>
-          <n-descriptions bordered class="mt-auto">
-            <n-descriptions-item label="SN">
-              {{ formValue.T_sn }}
-            </n-descriptions-item>
-            <n-descriptions-item label="探头编号">
-              {{ formValue.T_id }}
-            </n-descriptions-item>
-          </n-descriptions>
-          <template #action>
-            <div class="flex justify-end">
-              <n-popconfirm @positive-click="handleImport">
-                <template #trigger>
-                  <n-button type="primary">导入</n-button>
-                </template>
-                是否确认导入?
-              </n-popconfirm>
-            </div>
-          </template>
-        </n-card>
-      </n-spin>
     </n-space>
   </n-modal>
-  <n-modal
-    v-model:show="showModal1"
-    :show-icon="false"
-    preset="dialog"
-    title="进度"
-  >
-    <n-progress type="circle" :percentage="20">
-      <span style="text-align: center">20% 很小</span>
-    </n-progress>
-  </n-modal>
 </template>
 
 <script setup>
 import { getV3DataList, addTaskData } from '@/api';
-import { NStatistic, useMessage } from 'naive-ui';
+import { useMessage } from 'naive-ui';
 
 const message = useMessage();
 
+const notification = useNotification();
+
 const props = defineProps({
   task: {
     required: true,
@@ -97,13 +97,15 @@ const props = defineProps({
 
 // 是否展示 Modal
 const showModal = ref(false);
-const showModal1 = ref(false);
 
-//
-const show = ref(false);
+// 是否展示 Spinner
+const spinShow = ref(false);
 
 //
-const data = ref({});
+const dataList = ref([]);
+
+// 总数
+const total = ref(0);
 
 // 表单数据
 const formValue = reactive({
@@ -115,6 +117,9 @@ const formValue = reactive({
   page_z: 9999,
 });
 
+// 当前完成数
+const percentage = ref(0);
+
 // 显示导入
 const showImportModal = () => {
   showModal.value = true;
@@ -122,20 +127,24 @@ const showImportModal = () => {
   formValue.Time_end = null;
   formValue.T_sn = null;
   formValue.T_id = null;
+  total.value = 0;
+  percentage.value = 0;
 };
 
-//
-const handleImport = () => {
-  if (data.value.Data) {
-    data.value.Data.forEach((item) => {
-      return addTask(item);
-    });
-    showModal1.value = true;
-  } else {
-    message.info('无数据');
+// 批量导入
+const handleImport = async () => {
+  if (dataList.value.length === 0) {
+    return message.info('无数据');
   }
+  dataList.value.forEach(async (item) => {
+    const code = await addTask(item);
+    if (code !== 200) {
+      return false;
+    }
+  });
 };
 
+// 导入任务
 const addTask = async (item) => {
   const { data: res } = await addTaskData({
     T_task_id: props.task.T_task_id,
@@ -145,15 +154,23 @@ const addTask = async (item) => {
     T_rh: item.T_rh,
     T_time: item.T_time,
   });
-  if (res.Code !== 200) {
-    return false;
+  if (res.Code === 200) {
+    percentage.value += 1;
+    if (percentage.value === total.value) {
+      notification.success({
+        title: res.Msg,
+        duration: 2500,
+        keepAliveOnHover: true,
+      });
+    }
   }
+  return res.Code;
 };
 
-//
-const getData = async () => {
+// 查询数据
+const getDataList = async () => {
   try {
-    show.value = true;
+    spinShow.value = true;
     const { data: res } = await getV3DataList({
       Time_start: formValue.Time_start + '',
       Time_end: formValue.Time_end + '',
@@ -161,10 +178,12 @@ const getData = async () => {
       page: 1,
       page_z: 9999,
     });
-    show.value = false;
-    data.value = res.Data || {};
+    dataList.value = res.Data.Data || [];
+    total.value = res.Data.Num || 0;
   } catch (e) {
     console.log(e);
+  } finally {
+    spinShow.value = false;
   }
 };
 </script>

+ 35 - 32
src/views/data/edit/index.vue

@@ -224,38 +224,41 @@ const handleTabChange = (value) => {
 
 //
 const handleSet = (data) => {
-  chart1.value.chart.yAxis[0].addPlotLine({
-    color: 'red',
-    width: 2,
-    value: data.tTop,
-    label: {
-      text: `上限(${data.tTop})`,
-    },
-  });
-  chart1.value.chart.yAxis[0].addPlotLine({
-    color: 'red',
-    width: 2,
-    value: data.tBottom,
-    label: {
-      text: `下限(${data.tBottom})`,
-    },
-  });
-  chart2.value.chart.yAxis[0].addPlotLine({
-    color: 'red',
-    width: 2,
-    value: data.hTop,
-    label: {
-      text: `上限(${data.hTop})`,
-    },
-  });
-  chart2.value.chart.yAxis[0].addPlotLine({
-    color: 'red',
-    width: 2,
-    value: data.hBottom,
-    label: {
-      text: `下限(${data.hBottom})`,
-    },
-  });
+  if (tabChart.value === '温度') {
+    chart1.value.chart.yAxis[0].addPlotLine({
+      color: 'red',
+      width: 2,
+      value: data.tTop,
+      label: {
+        text: `上限(${data.tTop})`,
+      },
+    });
+    chart1.value.chart.yAxis[0].addPlotLine({
+      color: 'red',
+      width: 2,
+      value: data.tBottom,
+      label: {
+        text: `下限(${data.tBottom})`,
+      },
+    });
+  } else {
+    chart2.value.chart.yAxis[0].addPlotLine({
+      color: 'red',
+      width: 2,
+      value: data.hTop,
+      label: {
+        text: `上限(${data.hTop})`,
+      },
+    });
+    chart2.value.chart.yAxis[0].addPlotLine({
+      color: 'red',
+      width: 2,
+      value: data.hBottom,
+      label: {
+        text: `下限(${data.hBottom})`,
+      },
+    });
+  }
 };
 
 const checked = ref(false);

+ 3 - 7
src/views/data/source/index.vue

@@ -151,8 +151,8 @@ const extractTask = async () => {
   try {
     const { data: res } = await extractTaskData({
       T_task_id: queryData.T_task_id,
-      Time_start: queryData.Time_start !== null ? queryData.Time_start : '',
-      Time_end: queryData.Time_end !== null ? queryData.Time_end : '',
+      Time_start: queryData.Time_start,
+      Time_end: queryData.Time_end,
     });
     if (res.Code === 200) {
       notification.info({
@@ -172,11 +172,7 @@ const extractTask = async () => {
 // 获取列表
 const getDataList = async () => {
   try {
-    const { data: res } = await getTaskDataList({
-      ...queryData,
-      Time_start: queryData.Time_start !== null ? queryData.Time_start : '',
-      Time_end: queryData.Time_end !== null ? queryData.Time_end : '',
-    });
+    const { data: res } = await getTaskDataList(queryData);
     pagination.itemCount = res.Data.Num;
     if (!res.Data.List) {
       showModal.value = true;

+ 3 - 3
src/views/report/audit/TabFour.vue

@@ -94,10 +94,10 @@ const extractTask = async () => {
     loading.value = true;
     const { data: res } = await extractTaskData({
       T_task_id: queryData.T_task_id,
-      Time_start: queryData.Time_start + '',
-      Time_end: queryData.Time_end + '',
+      Time_start: queryData.Time_start,
+      Time_end: queryData.Time_end,
     });
-    dataList.value = res.Data.List || [];
+    dataList.value = res.Data || [];
   } catch (error) {
     console.log(error);
   } finally {

+ 56 - 38
src/views/report/create/index.vue

@@ -17,7 +17,7 @@
       </template>
     </n-page-header>
     <n-scrollbar :style="{ maxHeight: `${height - 150}px` }" trigger="none">
-      <n-form label-width="auto" size="large" show-require-mark>
+      <n-form label-width="auto" size="large">
         <n-grid :cols="12" :x-gap="12">
           <n-form-item-gi
             v-for="(item, index) of formValue.formList"
@@ -99,45 +99,60 @@
     </n-scrollbar>
   </div>
   <n-modal
+    style="width: 30%"
     v-model:show="modal.showModal"
     :show-icon="false"
     preset="dialog"
     :mask-closable="false"
     :title="modal.title"
-    @close="handleClose"
+    @close="onCloseModal"
   >
-    <n-scrollbar style="max-height: 200px" trigger="none" ref="scrollbarRef">
-      <n-upload
-        list-type="image-card"
-        :default-upload="false"
-        :max="1"
-        @change="handleChange"
-        v-if="modal.title === '上传验证'"
-      >
-        上传文件
-      </n-upload>
-      <n-alert
-        :title="keyInfo.Msg"
-        :type="
-          keyInfo.Code === 600
-            ? 'info'
-            : keyInfo.Code === 601
-            ? 'success'
-            : 'error'
-        "
-        v-else
-      >
-        <div>进度:{{ keyInfo.Schedule }}%</div>
-        <n-list class="bg-transparent">
-          <n-list-item :key="index" v-for="(item, index) of items">
-            <template #prefix>
-              {{ items.length - index }}
-            </template>
-            {{ item }}
-          </n-list-item>
-        </n-list>
-      </n-alert>
-    </n-scrollbar>
+    <n-upload
+      class="w-full"
+      list-type="image-card"
+      :default-upload="false"
+      :max="1"
+      @change="handleChange"
+      v-if="modal.title === '上传验证'"
+    >
+      上传文件
+    </n-upload>
+    <template v-else>
+      <n-card embedded :bordered="false">
+        <template #header>
+          <div class="flex justify-center">
+            <n-progress
+              :status="
+                keyInfo.Code === 600
+                  ? 'default'
+                  : keyInfo.Code === 601
+                  ? 'success'
+                  : 'error'
+              "
+              type="dashboard"
+              gap-position="bottom"
+              :percentage="keyInfo.Schedule"
+            />
+          </div>
+        </template>
+        <n-scrollbar
+          style="max-height: 300px"
+          trigger="none"
+          ref="scrollbarRef"
+        >
+          <n-space vertical>
+            <div
+              class="flex items-center"
+              v-for="(item, index) of items"
+              :key="index"
+            >
+              <n-badge class="mr-5" type="info" :value="index + 1" />
+              <span>{{ item }}</span>
+            </div>
+          </n-space>
+        </n-scrollbar>
+      </n-card>
+    </template>
     <template #action>
       <n-space v-if="modal.title === '上传验证'">
         <n-button @click="modal.showModal = false">取消</n-button>
@@ -322,9 +337,7 @@ let timer = 0;
 const keyInfo = ref({});
 const items = computed(() => {
   return keyInfo.value.Item
-    ? keyInfo.value.Item.split('\n')
-        .filter((item) => item)
-        .reverse()
+    ? keyInfo.value.Item.split('\n').filter((item) => item)
     : [];
 });
 
@@ -340,11 +353,16 @@ const generateKeyInfo = async (key) => {
   } else {
     clearTimeout(timer);
   }
+  scrollbarRef.value.scrollTo({
+    top: 9999,
+    behavior: 'smooth',
+  });
   keyInfo.value = res;
 };
 
 // 关闭对话框时触发
-const handleClose = () => {
+const onCloseModal = () => {
+  keyInfo.value = {};
   clearTimeout(timer);
 };
 

+ 54 - 38
src/views/scheme/index.vue

@@ -17,7 +17,7 @@
       </template>
     </n-page-header>
     <n-scrollbar :style="{ maxHeight: `${height - 150}px` }" trigger="none">
-      <n-form label-width="auto" size="large" show-require-mark>
+      <n-form label-width="auto" size="large">
         <n-grid :cols="12" :x-gap="12">
           <n-form-item-gi
             v-for="(item, index) of formValue.formList"
@@ -102,41 +102,52 @@
     v-model:show="modal.showModal"
     :show-icon="false"
     preset="dialog"
-    @close="handleClose"
     :title="modal.title"
+    @close="onCloseModal"
   >
-    <n-scrollbar style="max-height: 400px" trigger="none" ref="scroll">
-      <n-upload
-        list-type="image-card"
-        :default-upload="false"
-        :max="1"
-        @change="handleChange"
-        v-if="modal.title === '上传验证'"
-      >
-        上传文件
-      </n-upload>
-      <n-alert
-        :title="keyInfo.Msg"
-        :type="
-          keyInfo.Code === 600
-            ? 'info'
-            : keyInfo.Code === 601
-            ? 'success'
-            : 'error'
-        "
-        v-else
-      >
-        <div>进度:{{ keyInfo.Schedule }}%</div>
-        <n-list class="bg-transparent">
-          <n-list-item :key="index" v-for="(item, index) of items">
-            <template #prefix>
-              {{ items.length - index }}
-            </template>
-            {{ item }}
-          </n-list-item>
-        </n-list>
-      </n-alert>
-    </n-scrollbar>
+    <n-upload
+      list-type="image-card"
+      :default-upload="false"
+      :max="1"
+      @change="handleChange"
+      v-if="modal.title === '上传验证'"
+    >
+      上传文件
+    </n-upload>
+    <template v-else>
+      <n-card embedded :bordered="false">
+        <template #header>
+          <div class="flex justify-center">
+            <n-progress
+              :status="
+                keyInfo.Code === 600
+                  ? 'default'
+                  : keyInfo.Code === 601
+                  ? 'success'
+                  : 'error'
+              "
+              type="dashboard"
+              gap-position="bottom"
+              :percentage="keyInfo.Schedule"
+            />
+          </div>
+        </template>
+        <n-scrollbar
+          style="max-height: 300px"
+          trigger="none"
+          ref="scrollbarRef"
+        >
+          <div
+            class="flex items-center"
+            v-for="(item, index) of items"
+            :key="index"
+          >
+            <n-badge class="mr-5" type="info" :value="index + 1" />
+            <span>{{ item }}</span>
+          </div>
+        </n-scrollbar>
+      </n-card>
+    </template>
     <template #action>
       <n-space v-if="modal.title === '上传验证'">
         <n-button @click="modal.showModal = false">取消</n-button>
@@ -174,6 +185,8 @@ const { height } = useWindowSize();
 
 const message = useMessage();
 
+const scrollbarRef = ref(null);
+
 const task = window.sessionStorage.getItem('task')
   ? JSON.parse(window.sessionStorage.getItem('task'))
   : {};
@@ -333,9 +346,7 @@ let timer = 0;
 const keyInfo = ref({});
 const items = computed(() => {
   return keyInfo.value.Item
-    ? keyInfo.value.Item.split('\n')
-        .filter((item) => item)
-        .reverse()
+    ? keyInfo.value.Item.split('\n').filter((item) => item)
     : [];
 });
 // 验证报告生成 获取生成结果
@@ -350,11 +361,16 @@ const generateKeyInfo = async (key) => {
   } else {
     clearTimeout(timer);
   }
+  scrollbarRef.value.scrollTo({
+    top: 9999,
+    behavior: 'smooth',
+  });
   keyInfo.value = res;
 };
 
 // 关闭对话框时触发
-const handleClose = () => {
+const onCloseModal = () => {
+  keyInfo.value = {};
   clearTimeout(timer);
 };
 

+ 7 - 7
vite.config.js

@@ -10,13 +10,13 @@ import WindiCSS from 'vite-plugin-windicss';
 export default defineConfig({
   server: {
     cors: true,
-    proxy: {
-      '/api': {
-        target: 'http://coldverifylocal.coldbaozhida.com',
-        changeOrigin: true,
-        rewrite: (path) => path.replace(/^\/api/, ''),
-      },
-    },
+    // proxy: {
+    //   '/api2': {
+    //     target: 'http://coldverifylocal.coldbaozhida.com',
+    //     changeOrigin: true,
+    //     rewrite: (path) => path.replace(/^\/api2/, ''),
+    //   },
+    // },
   },
   base: './',
   resolve: {