Browse Source

feat: update

Hu Cheng 2 years ago
parent
commit
0ffb95d8e8

+ 1 - 1
.env.production

@@ -1,3 +1,3 @@
 VITE_API_BASE_URL="https://coldverify.coldbaozhida.com/api"
-VITE_API_LOCAL_BASE_URL="http://192.168.1.23:6400"
+VITE_API_LOCAL_BASE_URL="http://192.168.11.23:6400"
 VITE_API_COLD_BASE_URL="https://cold.coldbaozhida.com/api"

+ 12 - 2
src/views/data/checkout/index.vue

@@ -5,6 +5,7 @@
     </n-page-header>
     <n-data-table
       remote
+      :loading="loading"
       :columns="columns"
       :data="dataList"
       :bordered="false"
@@ -75,10 +76,19 @@ const columns = [
 // 列表
 const dataList = ref([]);
 
+// 表格数据是否加载完成
+const loading = ref(false);
+
 // 获取列表
 const getDataList = async () => {
-  const { data: res } = await checkTaskData(queryData);
-  dataList.value = res.Data ? res.Data : [];
+  try {
+    loading.value = true;
+    const { data: res } = await checkTaskData(queryData);
+    loading.value = false;
+    dataList.value = res.Data ? res.Data : [];
+  } catch (e) {
+    console.log(e);
+  }
 };
 
 getDataList();

+ 7 - 0
src/views/data/edit/index.vue

@@ -128,6 +128,9 @@ import SetVue from "./SetVue.vue";
 import ExportVue from "./ExportVue.vue";
 import TemplateForm from "./TemplateForm.vue";
 import { useWindowSize } from "@vueuse/core";
+import { useNow, useDateFormat } from "@vueuse/core";
+
+const formatted = useDateFormat(useNow(), "YYYY-MM-DD HH:mm:ss");
 
 const notification = useNotification();
 
@@ -487,13 +490,17 @@ getClassList();
 
 if (task.T_collection_state === 0) {
   notification.info({
+    closable: false,
     title: "未完成",
+    meta: `当前时间:${formatted.value}`,
     duration: 2500,
     keepAliveOnHover: true,
   });
 } else if (task.T_collection_state === 2) {
   notification.info({
+    closable: false,
     title: "采集中",
+    meta: `当前时间:${formatted.value}`,
     duration: 2500,
     keepAliveOnHover: true,
   });

+ 35 - 15
src/views/data/source/index.vue

@@ -35,11 +35,10 @@
   </div>
   <n-modal
     v-model:show="showModal"
-    :mask-closable="false"
     :show-icon="false"
+    :mask-closable="false"
     :closable="false"
     preset="dialog"
-    title="自定义时间"
   >
     <n-form
       label-width="auto"
@@ -65,20 +64,22 @@
           class="w-full"
         />
       </n-form-item>
-      <n-form-item>
-        <n-button type="primary" block @click="handleSearch">搜索</n-button>
-      </n-form-item>
+      <n-button type="primary" block @click="handleSearch">搜索</n-button>
     </n-form>
   </n-modal>
 </template>
 
 <script setup>
-import { NSpace } from "naive-ui";
+import { NSpace, NButton } from "naive-ui";
 import { extractTaskData, getTaskDataList } from "@/api";
-import { message } from "@/plugin/naive-ui";
+import { useNow, useDateFormat } from "@vueuse/core";
+
+const formatted = useDateFormat(useNow(), "YYYY-MM-DD HH:mm:ss");
 
 const dialog = useDialog();
 
+const notification = useNotification();
+
 const task = window.sessionStorage.getItem("task")
   ? JSON.parse(window.sessionStorage.getItem("task"))
   : {};
@@ -91,7 +92,7 @@ const queryData = reactive({
   Time_start: null,
   Time_end: null,
   page: 1,
-  page_z: 10,
+  page_z: 20,
 });
 
 // 列表
@@ -129,14 +130,14 @@ const pagination = reactive({
   },
 });
 
-// modal数据源
+//
 const showModal = ref(false);
 
 //
 const handleSearch = () => {
-  showModal.value = false;
   queryData.T_id = "";
   queryData.T_sn = "";
+  showModal.value = false;
   extractTask();
 };
 
@@ -148,7 +149,7 @@ const handleReset = () => {
     positiveText: "确认",
     negativeText: "取消",
     onPositiveClick: () => {
-      extractTask();
+      showModal.value = true;
     },
   });
 };
@@ -162,7 +163,13 @@ const extractTask = async () => {
       Time_end: queryData.Time_end !== null ? queryData.Time_end : "",
     });
     if (res.Code === 200) {
-      message.success(res.Msg);
+      notification.info({
+        title: "数据采集完成",
+        description: `${queryData.Time_start} 至 ${queryData.Time_end}`,
+        meta: `当前时间:${formatted.value}`,
+        duration: 2500,
+        keepAliveOnHover: true,
+      });
       getDataList();
     }
   } catch (e) {
@@ -180,11 +187,16 @@ const getDataList = async () => {
     });
     pagination.itemCount = res.Data.Num;
     if (!res.Data.List) {
-      message.info("数据为空");
-      queryData.Time_start = null;
-      queryData.Time_end = null;
       showModal.value = true;
+      notification.info({
+        title: "数据为空!",
+        description: `${queryData.Time_start} 至 ${queryData.Time_end}`,
+        meta: `当前时间:${formatted.value}`,
+        duration: 2500,
+        keepAliveOnHover: true,
+      });
     } else {
+      showModal.value = false;
       taskList.value = res.Data.List;
     }
   } catch (e) {
@@ -192,6 +204,14 @@ const getDataList = async () => {
   }
 };
 
+let timer = setInterval(() => {
+  getDataList();
+}, 10000);
+
+onBeforeUnmount(() => {
+  clearInterval(timer);
+});
+
 getDataList();
 </script>
 

+ 8 - 0
src/views/project/index.vue

@@ -258,6 +258,14 @@ const getDataList = async () => {
 };
 
 getDataList();
+
+let timer = setInterval(() => {
+  getDataList();
+}, 30000);
+
+onBeforeUnmount(() => {
+  clearInterval(timer);
+});
 </script>
 
 <style scoped></style>

+ 16 - 13
vite.config.js

@@ -8,17 +8,22 @@ import WindiCSS from "vite-plugin-windicss";
 
 // https://vitejs.dev/config/
 export default defineConfig({
-  server: {
-    host: true,
-    proxy: {
-      "/Api": {
-        target: "https://cold.coldbaozhida.com/api",
-        changeOrigin: true,
-        rewrite: (path) => path.replace(/^\/Api/, ""),
-      },
+  // server: {
+  //   host: true,
+  //   proxy: {
+  //     "/Api": {
+  //       target: "https://cold.coldbaozhida.com/api",
+  //       changeOrigin: true,
+  //       rewrite: (path) => path.replace(/^\/Api/, ""),
+  //     },
+  //   },
+  // },
+  base: "./",
+  resolve: {
+    alias: {
+      "@": fileURLToPath(new URL("./src", import.meta.url)),
     },
   },
-  base: "./",
   plugins: [
     vue(),
     WindiCSS(),
@@ -43,9 +48,7 @@ export default defineConfig({
       resolvers: [NaiveUiResolver()],
     }),
   ],
-  resolve: {
-    alias: {
-      "@": fileURLToPath(new URL("./src", import.meta.url)),
-    },
+  build: {
+    chunkSizeWarningLimit: 2000,
   },
 });