Browse Source

执行和配置页面启用路由作为参数。全局配置完善。ts除去any报错。

jiaxiaoqiang 4 months ago
parent
commit
fa6c76954b

+ 4 - 2
src/router/index.ts

@@ -32,7 +32,8 @@ export const constantRoutes: RouteRecordRaw[] = [
         component: () => import("@/views/modules/home/home.vue"),
       },
       {
-        path: "run-test",
+        path: "run-test/:engineerId",
+        name: "RunTestPage",
         component: () => import("@/views/modules/runTest/run-test.vue"),
       },
       {
@@ -41,7 +42,8 @@ export const constantRoutes: RouteRecordRaw[] = [
           import("@/views/modules/data-manager/data-manager.vue"),
       },
       {
-        path: "project-config",
+        path: "project-config/:engineerId",
+        name: "ProjectConfig",
         component: () =>
           import("@/views/modules/project-config/project-config.vue"),
       },

+ 1 - 5
src/store/modules/common.ts

@@ -8,11 +8,7 @@ export const useCommonStore = defineStore("commonStore", {
     tableType: 1,
     tableTitle: "",
     //   菜单切换
-    currentMenu: {
-      name: "首页",
-      icon: "home",
-      route: "/main/home",
-    },
+    currentMenuIndex: 0, // 当前选中的菜单索引
     pageSize: 9, // 首页每页显示的条数
 
     currentProjectId: "", //在首页点击某一项的配置工程的时候使用

+ 33 - 13
src/views/main/components/menu.vue

@@ -1,13 +1,14 @@
 <script setup lang="ts">
 import { useCommonStoreHook } from "@/store";
 
-const { currentMenu, currentProjectId, currentExecutionId } =
+const { currentMenuIndex, currentProjectId, currentExecutionId } =
   toRefs(useCommonStoreHook());
 
 interface MenuItem {
   name: string;
   icon: string;
   route: string;
+  index: number;
 }
 
 const menus = ref<MenuItem[]>([
@@ -15,50 +16,69 @@ const menus = ref<MenuItem[]>([
     name: "首页",
     icon: "home",
     route: "/main/home",
+    index: 0,
   },
   {
     name: "测试执行",
     icon: "run-test",
     route: "/main/run-test",
+    index: 1,
   },
   {
     name: "数据管理",
     icon: "data-manager",
     route: "/main/data-manager",
+    index: 2,
   },
   {
     name: "工程配置",
     icon: "project-config",
     route: "/main/project-config",
+    index: 3,
   },
   {
     name: "报告模版",
     icon: "report-template",
     route: "/main/report-template",
+    index: 4,
   },
   {
     name: "人员管理",
     icon: "person-manager",
     route: "/main/person-manager",
+    index: 5,
   },
 ]);
 
 const router = useRouter();
 const handleMenuClick = (menu: MenuItem) => {
-  if (menu.route != currentMenu.value.route) {
+  if (menu.index != currentMenuIndex.value) {
     // 如果工程配置没有值,就不跳转,并提示   && !currentProjectId.value
-    if (menu.route === "/main/project-config" && !currentProjectId.value) {
-      ElMessage.warning("请先在首页选择工程");
-      return;
-    }
+    if (menu.index === 3) {
+      if (!currentProjectId.value) {
+        ElMessage.warning("请先在首页选择工程");
+        return;
+      }
+      router.push({
+        name: "ProjectConfig",
+        params: { engineerId: currentProjectId.value },
+      });
+    } else if (menu.index === 1) {
+      if (!currentExecutionId.value) {
+        ElMessage.warning("请先在首页执行工程");
+        return;
+      }
+      router.push({
+        name: "RunTestPage",
+        params: { engineerId: currentExecutionId.value },
+      });
+    } else {
+      // 其他菜单都可以跳转
 
-    if (menu.route === "/main/run-test" && !currentExecutionId.value) {
-      ElMessage.warning("请先在首页执行工程");
-      return;
+      router.push(menu.route);
     }
 
-    currentMenu.value = menu;
-    router.push(menu.route);
+    currentMenuIndex.value = menu.index;
   }
 };
 </script>
@@ -77,12 +97,12 @@ const handleMenuClick = (menu: MenuItem) => {
         :icon-class="menu.icon"
         size="24"
         :style="{
-          color: menu.route === currentMenu.route ? 'white' : '#AFB9D0',
+          color: menu.index === currentMenuIndex ? 'white' : '#AFB9D0',
         }"
       />
       <div
         class="name"
-        :class="[menu.route === currentMenu.route ? 'selected' : 'normal']"
+        :class="[menu.index === currentMenuIndex ? 'selected' : 'normal']"
       >
         {{ menu.name }}
       </div>

+ 1 - 1
src/views/modules/global-config/components/ConfigAdd.vue

@@ -43,7 +43,7 @@
         >
           <el-select
             v-model="formLabelAlign.instrumentType"
-            placeholder="Select"
+            placeholder="请选择仪器类型"
             size="large"
           >
             <el-option

+ 1 - 1
src/views/modules/global-config/components/engrInstrumentConfig.vue

@@ -120,7 +120,7 @@ const configHandleDelete = (index: number, row: any) => {
         <el-table-column label="配置地址" prop="configIp" />
         <el-table-column label="配置名称" prop="configName" />
         <el-table-column label="仪器编码" prop="instrumentCode" />
-        <el-table-column label="仪器类型" prop="instrumentType" />
+        <el-table-column label="仪器类型" prop="typeLabel" />
         <el-table-column label="操作" prop="操作" fixed="right">
           <template #default="scope">
             <el-button

+ 15 - 9
src/views/modules/global-config/components/globalDataAdd.vue

@@ -27,14 +27,14 @@
         >
           <el-input v-model="formLabelAlign.dataItemName" />
         </el-form-item>
-        <el-form-item
-          label="测试工程id	"
-          :label-position="itemLabelPosition"
-          type="number"
-          prop="engineeringId"
-        >
-          <el-input v-model="formLabelAlign.engineeringId" />
-        </el-form-item>
+        <!--        <el-form-item-->
+        <!--          label="测试工程id	"-->
+        <!--          :label-position="itemLabelPosition"-->
+        <!--          type="number"-->
+        <!--          prop="engineeringId"-->
+        <!--        >-->
+        <!--          <el-input v-model="formLabelAlign.engineeringId" />-->
+        <!--        </el-form-item>-->
         <el-form-item
           label="设定值	"
           :label-position="itemLabelPosition"
@@ -61,6 +61,8 @@ const dialogVisible = ref(false);
 
 import type { FormItemProps, FormProps } from "element-plus";
 
+const route = useRoute();
+
 const labelPosition = ref<FormProps["labelPosition"]>("right");
 const itemLabelPosition = ref<FormItemProps["labelPosition"]>("");
 
@@ -85,7 +87,11 @@ const formLabelAlign = ref<VersionItem>({
 const emit = defineEmits(["save"]);
 
 const saveFun = () => {
-  emit("save", formLabelAlign.value, flag.value);
+  emit(
+    "save",
+    { ...formLabelAlign.value, engineeringId: route.params.engineerId },
+    flag.value
+  );
 };
 
 const ruleFormRef = ref();

+ 8 - 15
src/views/modules/home/home.vue

@@ -165,7 +165,7 @@ import {
 import { useCommonStoreHook } from "@/store";
 const {
   currentProjectId,
-  currentMenu,
+  currentMenuIndex,
   pageSize,
   currentTestItemId,
   currentExecutionId,
@@ -173,8 +173,8 @@ const {
 
 const checkAll = ref(false);
 const isIndeterminate = ref(true);
-const checkedCities = ref([]);
-const typeList = ref([]);
+const checkedCities = ref<any[]>([]);
+const typeList = ref<any[]>([]);
 // 获取所有的工程类型
 const getEngineeringTypeList = () => {
   getProjectTypeCount().then((res) => {
@@ -297,24 +297,17 @@ const gotoConfigProject = (project) => {
   currentProjectId.value = project.id;
   currentTestItemId.value = ""; // 要清空数据,不然进入配置页面会导致数据错误
 
-  currentMenu.value = {
-    name: "工程配置",
-    icon: "project-config",
-    route: "/main/project-config",
-  };
-  router.push("/main/project-config");
+  currentMenuIndex.value = 3;
+  router.push({ name: "ProjectConfig", params: { engineerId: project.id } });
 };
 
 // 去到测试执行页面
 const gotoExecuteTest = (project) => {
   currentExecutionId.value = project.id;
 
-  currentMenu.value = {
-    name: "测试执行",
-    icon: "run-test",
-    route: "/main/run-test",
-  };
-  router.push("/main/run-test");
+  currentMenuIndex.value = 1;
+
+  router.push({ name: "RunTestPage", params: { engineerId: project.id } });
 };
 </script>
 

+ 11 - 5
src/views/modules/project-config/com/project-message.vue

@@ -5,22 +5,24 @@ import TitleHeader from "@/views/modules/project-config/com/titleHeader.vue";
 import { delTestModule } from "@/api/project";
 import { useCommonStoreHook } from "@/store";
 import { getProjectById, getTestProjectList } from "@/api/project/index";
-const { currentProjectId, currentTestItemId } = toRefs(useCommonStoreHook());
+const { currentTestItemId } = toRefs(useCommonStoreHook());
 
 const emits = defineEmits(["onClickItem"]);
 
 const router = useRouter();
+const route = useRoute();
+
 const goGlobalConfig = () => {
   router.push({
     name: "GlobalConfig",
-    params: { engineerId: currentProjectId.value },
+    params: { engineerId: route?.params?.engineerId },
   });
 };
 
 // 当前正在配置的项目信息
 const currentProject = ref();
 onMounted(() => {
-  getProjectById(currentProjectId.value).then((res) => {
+  getProjectById(route?.params?.engineerId).then((res) => {
     currentProject.value = res.data;
     toGetTestProjectList();
   });
@@ -49,12 +51,16 @@ const clickTestProjectItem = (item) => {
 const moduleDialogRef = ref();
 //新增测试项目
 const addProject = () => {
-  moduleDialogRef.value.openDialog(false, null, currentProjectId.value);
+  moduleDialogRef.value.openDialog(false, null, route?.params?.engineerId);
 };
 //修改测试项目
 const editProject = () => {
   clickItem &&
-    moduleDialogRef.value.openDialog(true, clickItem, currentProjectId.value);
+    moduleDialogRef.value.openDialog(
+      true,
+      clickItem,
+      route?.params?.engineerId
+    );
 };
 //删除测试项目
 const confirmEvent = () => {

+ 4 - 2
src/views/modules/project-config/project-config.vue

@@ -20,7 +20,9 @@ import {
 
 import { useCommonStoreHook } from "@/store";
 
-const { currentTestItemId, currentProjectId } = toRefs(useCommonStoreHook());
+const { currentTestItemId } = toRefs(useCommonStoreHook());
+
+const route = useRoute();
 
 const flowRef = ref<HJFlowInstance>();
 const nodes = ref<HJNodeData[]>([]);
@@ -87,7 +89,7 @@ onMounted(async () => {
     getFlowData();
   }
 
-  let res = await getProjectGlobalConfig(currentProjectId.value);
+  let res = await getProjectGlobalConfig(route?.params?.engineerId as string);
   configData.value = res.data;
 });
 

+ 9 - 6
src/views/modules/runTest/run-test.vue

@@ -11,12 +11,13 @@ import {
   searhTestType,
 } from "@/api/project/excute";
 
-const { currentExecutionId } = toRefs(useCommonStoreHook());
+const route = useRoute();
 
 interface VersionItem {
   instrumentType: string;
   configName: string;
   configIp: string;
+  zhongduan: string;
 }
 
 const formLabelAlign = ref<VersionItem>({
@@ -53,7 +54,7 @@ const handletopProSelectedListChange = (value: CheckboxValueType[]) => {
 };
 // 获取顶部测试项目
 const getTestProjectTopList = () => {
-  getTestProjectList({ engineeringId: currentExecutionId.value }).then(
+  getTestProjectList({ engineeringId: route?.params?.engineerId }).then(
     (result) => {
       topProAllList.value = result.data;
       topProSelectedList.value = result.data.map((item) => item.id); // 默认选中全部
@@ -79,15 +80,17 @@ const getAllTestTypes = () => {
 // 下边第二列
 const excutingMachinesList = ref<any[]>([]); // 所有执行终端
 const getExcutingMachines = () => {
-  searchTestMachineConfig(currentExecutionId.value).then((result) => {
-    excutingMachinesList.value = result.data;
-  });
+  searchTestMachineConfig(route?.params?.engineerId as string).then(
+    (result) => {
+      excutingMachinesList.value = result.data;
+    }
+  );
 };
 
 const testingMachines = ref<any[]>([]); // 所有routeData里面的测试仪器
 const getExcutingGlobalMachines = async () => {
   let res = await searchExcutingInstrumentConfig(
-    currentExecutionId.value,
+    route?.params?.engineerId as string,
     topProSelectedList.value
   );
   testingMachines.value = res.data;

+ 1 - 1
tsconfig.json

@@ -12,7 +12,7 @@
     "lib": ["esnext", "dom"],
     "baseUrl": ".",
     "allowJs": true,
-    "noImplicitAny": true,
+    "noImplicitAny": false,
     "paths": {
       "@/*": ["src/*"]
     },