浏览代码

测试执行页面相关接口。

jiaxiaoqiang 3 月之前
父节点
当前提交
eaf148c750

+ 1 - 0
.nvmrc

@@ -0,0 +1 @@
+v18.18.0

+ 44 - 1
src/api/project/excute.ts

@@ -2,10 +2,53 @@ import request from "@/utils/request";
 import { AxiosPromise } from "axios";
 
 // 查询测试类型
-export function searhTestType(data: object): AxiosPromise {
+export function searhTestType(data?: object): AxiosPromise {
   return request({
     url: "/api/v1/test/engrExecute/selectTestType",
     method: "post",
     data: {},
   });
 }
+
+// 测试仪器配置列表查询
+export function searchTestMachineConfig(engineeringId: string): AxiosPromise {
+  return request({
+    url: "/api/v1/test/engrInstrumentConfig/list",
+    method: "post",
+    data: {
+      engineeringIdList: [engineeringId, 0],
+      instrumentProperty: 2,
+      pageSize: 100,
+    },
+  });
+}
+
+// 查询执行工程项目关联的全局数据
+export function searchExcutingGlobalData(
+  engineeringId: string,
+  itemIds: string[]
+): AxiosPromise {
+  return request({
+    url: "/api/v1/test/engrProject/selectInvolveGlobalData",
+    method: "post",
+    data: {
+      engineeringId: engineeringId,
+      projectIdList: itemIds,
+    },
+  });
+}
+
+// 查询执行工程项目关联的仪器配置
+export function searchExcutingInstrumentConfig(
+  engineeringId: string,
+  itemIds: string[]
+): AxiosPromise {
+  return request({
+    url: "/api/v1/test/engrProject/selectInvolveInstrConfig",
+    method: "post",
+    data: {
+      engineeringId: engineeringId,
+      projectIdList: itemIds,
+    },
+  });
+}

+ 2 - 0
src/store/modules/common.ts

@@ -17,6 +17,8 @@ export const useCommonStore = defineStore("commonStore", {
 
     currentProjectId: "", //在首页点击某一项的配置工程的时候使用
     currentTestItemId: "", //选择的测试项目
+
+    currentExecutionId: "", // 当前在测试执行的工程id
   }),
   persist: true,
 });

+ 7 - 1
src/views/main/components/menu.vue

@@ -1,7 +1,8 @@
 <script setup lang="ts">
 import { useCommonStoreHook } from "@/store";
 
-const { currentMenu, currentProjectId } = toRefs(useCommonStoreHook());
+const { currentMenu, currentProjectId, currentExecutionId } =
+  toRefs(useCommonStoreHook());
 
 interface MenuItem {
   name: string;
@@ -51,6 +52,11 @@ const handleMenuClick = (menu: MenuItem) => {
       return;
     }
 
+    if (menu.route === "/main/run-test" && !currentExecutionId.value) {
+      ElMessage.warning("请先在首页执行工程");
+      return;
+    }
+
     currentMenu.value = menu;
     router.push(menu.route);
   }

+ 20 - 3
src/views/modules/home/home.vue

@@ -114,7 +114,7 @@
             <span @click="gotoConfigProject(item)">
               <svg-icon icon-class="homeIcon4" />
             </span>
-            <span>
+            <span @click="gotoExecuteTest(item)">
               <svg-icon icon-class="homeIcon1" />
             </span>
           </div>
@@ -154,8 +154,13 @@ import {
 } from "@/api/project";
 
 import { useCommonStoreHook } from "@/store";
-const { currentProjectId, currentMenu, pageSize, currentTestItemId } =
-  toRefs(useCommonStoreHook());
+const {
+  currentProjectId,
+  currentMenu,
+  pageSize,
+  currentTestItemId,
+  currentExecutionId,
+} = toRefs(useCommonStoreHook());
 
 const checkAll = ref(false);
 const isIndeterminate = ref(true);
@@ -290,6 +295,18 @@ const gotoConfigProject = (project) => {
   };
   router.push("/main/project-config");
 };
+
+// 去到测试执行页面
+const gotoExecuteTest = (project) => {
+  currentExecutionId.value = project.id;
+
+  currentMenu.value = {
+    name: "测试执行",
+    icon: "run-test",
+    route: "/main/run-test",
+  };
+  router.push("/main/run-test");
+};
 </script>
 
 <style scoped lang="scss">

+ 1 - 0
src/views/modules/project-config/configs/properites.ts

@@ -33,6 +33,7 @@ export interface InforPropertyModel {
   bindValue?: string; //这个是el-form 会绑定的值
   bindCode?: string; //  //编号
   bindLabel?: string; //这个是el-mention 会绑定的值 然后将id给 bindCode
+  bingObjJson?: string; // 这个是el-metntion 会绑定的整个对象的值
 }
 
 interface HJNodeData2 {

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

@@ -163,12 +163,14 @@ const handleSearch = (_: string, prefix: string) => {
               @select="
                 (opt) => {
                   property.bindCode = opt.code;
+                  property.bingObjJson = JSON.stringify(opt);
                 }
               "
               @blur="
                 () => {
                   if (property.bindLabel === '') {
                     property.bindCode = '';
+                    property.bingObjJson = '';
                   }
                 }
               "

+ 1 - 1
src/views/modules/report-template/report-template.vue

@@ -19,7 +19,7 @@ const onExportTemplate = () => {
 
 const onSaveTemplate = () => {
   const res = excelRef.value.getExcelData();
-  console.log("onSaveTemplate", res);
+  console.log("onSaveTemplate", res, "传给后端要转json");
 };
 </script>
 

+ 109 - 17
src/views/modules/runTest/run-test.vue

@@ -2,6 +2,17 @@
 import { ref } from "vue";
 import titHeader from "./components/tit-header.vue";
 
+import { useCommonStoreHook } from "@/store";
+import { getTestProjectList } from "@/api/project";
+import { CheckboxValueType } from "element-plus";
+import {
+  searchExcutingInstrumentConfig,
+  searchTestMachineConfig,
+  searhTestType,
+} from "@/api/project/excute";
+
+const { currentExecutionId } = toRefs(useCommonStoreHook());
+
 interface VersionItem {
   instrumentType: string;
   configName: string;
@@ -12,10 +23,75 @@ const formLabelAlign = ref<VersionItem>({
   instrumentType: "",
   configName: "",
   configIp: "",
+  zhongduan: "",
 });
 
 const drawer = ref(false);
-const checkList = ref(["Value selected and disabled", "Value A"]);
+
+onMounted(() => {
+  getTestProjectTopList();
+  getAllTestTypes();
+  getExcutingMachines();
+});
+
+const topProAllList = ref<any[]>([]);
+const topProSelectedList = ref<any[]>([]);
+const checkAll = ref(false);
+const isIndeterminate = ref(true);
+
+const handleCheckAllChange = (val: CheckboxValueType) => {
+  topProSelectedList.value = val
+    ? topProAllList.value.map((item) => item.id)
+    : [];
+  isIndeterminate.value = false;
+};
+const handletopProSelectedListChange = (value: CheckboxValueType[]) => {
+  const checkedCount = value.length;
+  checkAll.value = checkedCount === topProAllList.value.length;
+  isIndeterminate.value =
+    checkedCount > 0 && checkedCount < topProAllList.value.length;
+};
+// 获取顶部测试项目
+const getTestProjectTopList = () => {
+  getTestProjectList({ engineeringId: currentExecutionId.value }).then(
+    (result) => {
+      topProAllList.value = result.data;
+      topProSelectedList.value = result.data.map((item) => item.id); // 默认选中全部
+    }
+  );
+};
+
+// 顶部展示的项目 是弹窗选中的项目
+const topOnShowProList = computed(() => {
+  return topProAllList.value.filter((item) =>
+    topProSelectedList.value.includes(item.id)
+  );
+});
+
+// 下面左边第一列
+const allTestTypes = ref<any[]>([]);
+const getAllTestTypes = () => {
+  searhTestType().then((result) => {
+    allTestTypes.value = result.data;
+  });
+};
+
+// 下边第二列
+const excutingMachinesList = ref<any[]>([]); // 所有执行终端
+const getExcutingMachines = () => {
+  searchTestMachineConfig(currentExecutionId.value).then((result) => {
+    excutingMachinesList.value = result.data;
+  });
+};
+
+const testingMachines = ref<any[]>([]); // 所有routeData里面的测试仪器
+const getExcutingGlobalMachines = async () => {
+  let res = await searchExcutingInstrumentConfig(
+    currentExecutionId.value,
+    topProSelectedList.value
+  );
+  testingMachines.value = res.data;
+};
 </script>
 
 <template>
@@ -28,8 +104,8 @@ const checkList = ref(["Value selected and disabled", "Value A"]);
         <el-scrollbar height="100%">
           <div class="test-list">
             <div
-              v-for="item in 50"
-              :key="item"
+              v-for="item in topOnShowProList"
+              :key="item.id"
               class="test-list-item"
               :class="item === 2 ? 'active' : ''"
             >
@@ -47,7 +123,7 @@ const checkList = ref(["Value selected and disabled", "Value A"]);
                   <svg-icon icon-class="chacha" class="svg svg-error" />
                   <svg-icon icon-class="Frame" class="svg svg-progress" />
                 </div>
-                <div class="name">增益测试</div>
+                <div class="name">{{ item.projectName }}</div>
               </div>
             </div>
           </div>
@@ -71,10 +147,10 @@ const checkList = ref(["Value selected and disabled", "Value A"]);
                 placeholder="选择测试类型"
               >
                 <el-option
-                  v-for="item in 3"
-                  key="item.value"
-                  label="item.label"
-                  value="item.value"
+                  v-for="item in allTestTypes"
+                  :key="item.dictValue"
+                  :label="item.dictLabel"
+                  :value="item.dictValue"
                 />
               </el-select>
             </el-form-item>
@@ -96,14 +172,14 @@ const checkList = ref(["Value selected and disabled", "Value A"]);
               <div class="select-div">
                 <el-select
                   class="select-item"
-                  v-model="formLabelAlign.configName"
+                  v-model="formLabelAlign.zhongduan"
                   placeholder="选择执行终端"
                 >
                   <el-option
-                    v-for="item in 3"
-                    key="item.value"
-                    label="item.label"
-                    value="item.value"
+                    v-for="item in excutingMachinesList"
+                    :key="item.id"
+                    :label="item.configName"
+                    :value="item.id"
                   />
                 </el-select>
                 <el-button class="test-min-btn" type="primary">
@@ -202,11 +278,26 @@ const checkList = ref(["Value selected and disabled", "Value A"]);
         <div class="test-drawer-header">选择测试项</div>
       </template>
       <template #default>
+        <el-checkbox
+          v-model="checkAll"
+          :indeterminate="isIndeterminate"
+          @change="handleCheckAllChange"
+        >
+          全选
+        </el-checkbox>
         <el-scrollbar>
-          <el-checkbox-group v-model="checkList" class="drawer-list">
-            <div v-for="item in 20" :key="item" class="drawer-list-item">
-              <el-checkbox label="" value="Value A" />
-              <span>增益测试</span>
+          <el-checkbox-group
+            v-model="topProSelectedList"
+            @change="handletopProSelectedListChange"
+            class="drawer-list"
+          >
+            <div
+              v-for="item in topProAllList"
+              :key="item.id"
+              class="drawer-list-item"
+            >
+              <el-checkbox label="" :value="item.id" />
+              <span>{{ item.projectName }}</span>
             </div>
           </el-checkbox-group>
         </el-scrollbar>
@@ -298,6 +389,7 @@ $color-progress: #3cbaff;
     }
     .test-list {
       display: flex;
+      justify-content: center;
       height: 100%;
     }
     .test-list-item {