Forráskód Böngészése

feat(update): update

HuCheng 2 éve
szülő
commit
e75645303b

+ 2 - 2
.env.development

@@ -1,2 +1,2 @@
-VITE_API_BASE_URL = "http://coldverifylocal.coldbaozhida.com/api"
-VITE_API_BASE_URL_ONLINE = "https://coldverify.coldbaozhida.com/api"
+VITE_API_BASE_URL = "https://coldverify.coldbaozhida.com/api"
+VITE_API_LOCAL_BASE_URL = "http://coldverifylocal.coldbaozhida.com/api"

+ 2 - 2
.env.production

@@ -1,2 +1,2 @@
-VITE_API_BASE_URL = "http://coldverifylocal.coldbaozhida.com/api"
-VITE_API_BASE_URL_ONLINE = "https://coldverify.coldbaozhida.com/api"
+VITE_API_BASE_URL = "https://coldverify.coldbaozhida.com/api"
+VITE_API_LOCAL_BASE_URL = "http://coldverifylocal.coldbaozhida.com/api"

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8">
     <link rel="icon" href="/favicon.ico">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Vite App</title>
+    <title>冷链验证报告生成系统</title>
   </head>
   <body>
     <div id="app"></div>

+ 6 - 14
src/api/index.js

@@ -28,29 +28,21 @@ export const getTaskData = (data) => {
   });
 };
 
-// 任务管理(添加)
-export const addTaskData = (data) => {
-  return service.request({
-    method: "POST",
-    url: "/Task/Add",
-    data,
-  });
-};
 
-// 任务管理(编辑
-export const editTaskData = (data) => {
+// 设备管理(列表)
+export const getDeviceClassData = (data) => {
   return service.request({
     method: "POST",
-    url: "/Task/Up",
+    url: "/DeviceClassList/List",
     data,
   });
 };
 
-// 任务管理(删除
-export const deleteTaskData = (data) => {
+// 设备管理(添加
+export const addDeviceClassData = (data) => {
   return service.request({
     method: "POST",
-    url: "/Task/Del",
+    url: "/DeviceClassList/Add",
     data,
   });
 };

+ 6 - 4
src/layout/index.vue

@@ -9,7 +9,7 @@
       :collapsed-width="0"
       show-trigger="bar"
       :native-scrollbar="false"
-      class="h-full shadow"
+      class="shadow"
     >
       <h2 class="text-center leading-[64px]">冷链验证报告生成系统</h2>
       <MenuComponent />
@@ -23,11 +23,13 @@
         </n-space>
       </n-layout-header>
       <n-layout-content
-        style="height: calc(100vh - 64px)"
-        content-style="padding: 24px; height: 100%; background-color: #f5f7f9"
+        content-style="padding: 24px; background-color: #f5f7f9"
         :native-scrollbar="false"
       >
-        <n-card :bordered="false" class="h-full">
+        <n-card
+          :bordered="false"
+          style="height: calc(100vh - 112px); min-height: 600px"
+        >
           <RouterView />
         </n-card>
       </n-layout-content>

+ 1 - 1
src/login/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div
-    class="absolute top-0 right-0 bottom-0 left-0 bg-[#f5f7f9] flex justify-center items-center"
+    class="absolute top-0 right-0 bottom-0 left-0 bg-[#f5f7f9] flex justify-center items-center overflow-auto"
   >
     <n-card class="w-[500px] shadow rounded-lg" :bordered="false">
       <template #header>

+ 2 - 1
src/router/index.js

@@ -16,7 +16,8 @@ const router = createRouter({
           component: () => import("@/views/project/index.vue"),
         },
         {
-          path: "/equipment",
+          path: "/equipment/:taskId",
+          props: true,
           component: () => import("@/views/project/equipment/index.vue"),
         },
         {

+ 1 - 1
src/utils/axios.js

@@ -6,7 +6,7 @@ import { createDiscreteApi } from "naive-ui";
 const { message } = createDiscreteApi(["message"]);
 
 const service = axios.create({
-  baseURL: import.meta.env.VITE_API_BASE_URL_ONLINE,
+  baseURL: import.meta.env.VITE_API_BASE_URL,
   timeout: 8000,
 });
 

+ 110 - 63
src/views/project/equipment/index.vue

@@ -7,7 +7,7 @@
       </n-input-group>
       <n-space>
         <n-button type="primary">批量导入</n-button>
-        <n-button type="primary" @click="handleAdd">新增</n-button>
+        <n-button type="primary" @click="handleAdd">添加</n-button>
       </n-space>
     </n-space>
     <n-data-table
@@ -27,23 +27,17 @@
     @positive-click="submitCallback"
   >
     <n-form
-      :model="form"
+      ref="formRef"
+      :model="formValue"
       label-placement="left"
       label-width="auto"
-      require-mark-placement="right-hanging"
+      :rules="rules"
     >
-      <n-form-item label="项目名称" path="inputValue">
-        <n-input v-model:value="form.inputValue" />
+      <n-form-item label="SN" path="T_sn">
+        <n-input v-model:value="formValue.T_sn" />
       </n-form-item>
-      <n-form-item label="描述" path="textareaValue">
-        <n-input
-          v-model:value="form.textareaValue"
-          type="textarea"
-          :autosize="{
-            minRows: 3,
-            maxRows: 5,
-          }"
-        />
+      <n-form-item label="ID" path="T_id">
+        <n-input v-model:value="formValue.T_id" />
       </n-form-item>
     </n-form>
   </n-modal>
@@ -52,74 +46,127 @@
 <script setup>
 import { h } from "vue";
 import { NButton, NSpace } from "naive-ui";
+import { getDeviceClassData, addDeviceClassData } from "@/api";
 
-const createColumns = () => {
-  return [
-    {
-      title: "项目名称",
-      key: "no",
-    },
-    {
-      title: "描述",
-      key: "title",
-    },
-    {
-      title: "时间",
-      key: "length",
-    },
-    {
-      title: "操作",
-      key: "actions",
-      render() {
-        return h(
-          NSpace,
-          {},
-          {
-            default: () =>
-              ["删除"].map((item) =>
-                h(
-                  NButton,
-                  {
-                    type: "error",
-                    size: "small",
-                    onClick: () => {},
-                  },
-                  { default: () => item }
-                )
-              ),
-          }
-        );
-      },
-    },
-  ];
+const message = useMessage();
+
+const props = defineProps({
+  taskId: String,
+});
+
+const formRef = ref(null);
+
+// 验证表项的规则
+const rules = {
+  T_sn: { required: true, message: "不能为空", trigger: "blur" },
+  T_id: { required: true, message: "不能为空", trigger: "blur" },
 };
 
-const data = [
-  { no: 3, title: "Wonderwall", length: "4:18" },
-  { no: 4, title: "Don't Look Back in Anger", length: "4:48" },
-  { no: 12, title: "Champagne Supernova", length: "7:27" },
+// 查询参数
+const queryData = reactive({
+  T_sn: "",
+});
+
+// 需要展示的列
+const columns = [
+  {
+    title: "#",
+    key: "key",
+    render: (_, index) => {
+      return `${index + 1}`;
+    },
+  },
+  {
+    title: "设备序列号",
+    key: "T_sn",
+  },
+  {
+    title: "操作",
+    key: "actions",
+    render() {
+      return h(
+        NSpace,
+        {},
+        {
+          default: () =>
+            ["删除"].map((item) =>
+              h(
+                NButton,
+                {
+                  type: "error",
+                  size: "small",
+                  onClick: () => {},
+                },
+                { default: () => item }
+              )
+            ),
+        }
+      );
+    },
+  },
 ];
 
-const columns = createColumns({});
+// 设备列表
+const data = ref([]);
+
 const pagination = ref(false);
 
+// 模态框数据源
 const modal = reactive({
   title: "",
   showModal: false,
 });
 
 const submitCallback = () => {
-  console.log("确定");
+  if (modal.title === "添加") {
+    addDeviceClass();
+  }
 };
 const handleAdd = () => {
+  modal.title = "添加";
   modal.showModal = true;
-  modal.title = "新增";
 };
 
-const form = reactive({
-  inputValue: "",
-  textareaValue: "",
+// 获取表项中收集到的值的对象
+const formValue = reactive({
+  T_sn: null,
+  T_id: null,
 });
+
+// 添加
+const addDeviceClass = () => {
+  formRef.value.validate(async (errors) => {
+    if (!errors) {
+      try {
+        const { data: res } = await addDeviceClassData({
+          T_class: props.taskId,
+          T_sn: formValue.T_sn,
+          T_id: formValue.T_id,
+        });
+        message.success(res.Msg);
+        getDeviceClassList();
+      } finally {
+        formRef.value.restoreValidation();
+        Object.keys(formValue).forEach((key) => (formValue[key] = ""));
+      }
+    } else {
+      modal.showModal = true;
+      message.error("验证失败,请填写完整信息");
+    }
+  });
+};
+
+// 设备管理(列表)
+const getDeviceClassList = async () => {
+  const { data: res } = await getDeviceClassData({
+    T_class: props.taskId,
+    T_sn: queryData.T_sn,
+  });
+  pagination.itemCount = res.Data.Num;
+  data.value = res.Data.List;
+};
+
+getDeviceClassList();
 </script>
 
 <style scoped></style>

+ 20 - 2
src/views/project/index.vue

@@ -72,6 +72,8 @@ import { h } from "vue";
 import { NButton, NSpace } from "naive-ui";
 import { getTaskData, getUserData } from "@/api";
 
+const router = useRouter();
+
 const formRef = ref(null);
 
 // 验证表项的规则
@@ -144,7 +146,7 @@ const columns = [
   {
     title: "操作",
     key: "actions",
-    render() {
+    render(row) {
       return h(
         NSpace,
         {},
@@ -164,7 +166,23 @@ const columns = [
                 {
                   type: "primary",
                   size: "small",
-                  onClick: () => {},
+                  onClick: () => {
+                    if (item === "设备管理") {
+                      router.push(`/equipment/${row.Id}`);
+                    } else if (item === "数据来源") {
+                      router.push("/data_source");
+                    } else if (item === "数据编辑") {
+                      router.push("/data_source");
+                    } else if (item === "数据校验") {
+                      router.push("/data_source");
+                    } else if (item === "报告生成") {
+                      router.push("/data_source");
+                    } else if (item === "报告编辑") {
+                      router.push("/data_source");
+                    } else {
+                      router.push("/data_source");
+                    }
+                  },
                 },
                 { default: () => item }
               )

+ 1 - 3
vite.config.js

@@ -8,9 +8,7 @@ import WindiCSS from "vite-plugin-windicss";
 
 // https://vitejs.dev/config/
 export default defineConfig({
-  server: {
-    open: true
-  },
+  base: "",
   plugins: [
     vue(),
     WindiCSS(),