Просмотр исходного кода

首页,工程配置,全局配置页面修改

jiaxiaoqiang 4 месяцев назад
Родитель
Сommit
32493ff748

+ 2 - 2
.env.development

@@ -11,8 +11,8 @@ VITE_APP_BASE_API = '/dev-api'
 
 # 开发接口地址
 
-VITE_APP_API_URL = 'http://192.168.1.43:7205/'
-# VITE_APP_API_URL = 'http://192.168.1.4:18000/'
+# VITE_APP_API_URL = 'http://192.168.1.43:7205/'
+ VITE_APP_API_URL = 'http://192.168.1.4:18000/'
 
 # 是否启用 Mock 服务
 VITE_MOCK_DEV_SERVER = false

+ 53 - 20
src/api/config/index.ts

@@ -18,21 +18,6 @@ export function instrumentConfigPage(queryParams?: object): AxiosPromise<any> {
 }
 
 /**
- * 发送全局数据分页查询请求
- *
- * @param queryParams - 查询参数对象,可选
- * @returns AxiosPromise<any> - 返回一个 AxiosPromise 对象,包含请求的响应数据
- */
-//测试全局数据分页查询
-export function globalDataPage(queryParams?: object): AxiosPromise<any> {
-  return request({
-    url: "/api/v1/globalData/page",
-    method: "post",
-    data: queryParams,
-  });
-}
-
-/**
  * 更新仪器配置
  *
  * @param queryParams - 可选的查询参数对象,包含要更新的配置数据。
@@ -74,6 +59,21 @@ export function configDel(queryParams?: object): AxiosPromise<any> {
   });
 }
 
+
+/**
+ * 发送全局数据分页查询请求
+ *
+ * @param queryParams - 查询参数对象,可选
+ * @returns AxiosPromise<any> - 返回一个 AxiosPromise 对象,包含请求的响应数据
+ */
+//测试全局数据分页查询
+export function globalDataPage(queryParams?: object): AxiosPromise<any> {
+  return request({
+    url: "/api/v1/test/engrGlobalData/page",
+    method: "post",
+    data: queryParams,
+  });
+}
 /**
  * 向全局数据新增接口发送请求
  *
@@ -83,23 +83,56 @@ export function configDel(queryParams?: object): AxiosPromise<any> {
 //全局数据新增
 export function globalDataAdd(queryParams?: object): AxiosPromise<any> {
   return request({
-    url: "/api/v1/globalData/add",
+    url: "/api/v1/test/engrGlobalData/add",//api/v1/test/engrGlobalData/add
     method: "post",
     data: queryParams,
   });
 }
-
 export function globalDataDel(queryParams?: object): AxiosPromise<any> {
   return request({
-    url: "/api/v1/globalData/del",
+    url: "/api/v1/test/engrGlobalData/del",
     method: "post",
     data: queryParams,
   });
 }
-
 export function globalDataUpdate(queryParams?: object): AxiosPromise<any> {
   return request({
-    url: "/api/v1/globalData/update",
+    url: "/api/v1/test/engrGlobalData/update",
+    method: "post",
+    data: queryParams,
+  });
+}
+
+//查询仪器类型
+export function selectInstrumentType(queryParams?: object): AxiosPromise<any> {
+  return request({
+    url: "/api/v1/test/engrInstrumentConfig/selectInstrumentType",
+    method: "post",
+    data: queryParams,
+  });
+}
+
+//新增测试仪器配置
+export function engrInstrumentConfigAdd(queryParams?: object): AxiosPromise<any> {
+  return request({
+    url: "/api/v1/test/engrInstrumentConfig/add",
+    method: "post",
+    data: queryParams,
+  });
+}
+
+//更新测试仪器配置
+export function engrInstrumentConfigUpdate(queryParams?: object): AxiosPromise<any> {
+  return request({
+    url: "/api/v1/test/engrInstrumentConfig/update",
+    method: "post",
+    data: queryParams,
+  });
+}
+//删除测试仪器配置
+export function engrInstrumentConfigDel(queryParams?: object): AxiosPromise<any> {
+  return request({
+    url: "/api/v1/test/engrInstrumentConfig/del",
     method: "post",
     data: queryParams,
   });

+ 18 - 0
src/api/project/index.ts

@@ -101,3 +101,21 @@ export function getProjectGlobalConfig(engineeringId: string): AxiosPromise {
     data: { engineeringId: engineeringId },
   });
 }
+
+// 新增 测试模块 
+export function addTestModule(data: object): AxiosPromise {
+  return request({
+    url: "/api/v1/test/engrProject/add",
+    method: "post",
+    data: data,
+  });
+}
+
+//删除测试模块
+export function delTestModule(data: object): AxiosPromise {
+  return request({
+    url: "/api/v1/test/engrProject/del",
+    method: "post",
+    data: data,
+  });
+}

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

@@ -1,6 +1,10 @@
 <template>
   <div class="add">
-    <el-dialog v-model="dialogVisible" title="新建测试工程" width="500">
+    <el-dialog
+      v-model="dialogVisible"
+      :title="tabName + (logType === 'add' ? '新增' : '修改')"
+      width="500"
+    >
       <el-form
         :label-position="labelPosition"
         label-width="auto"
@@ -9,25 +13,46 @@
         ref="ruleFormRef"
       >
         <el-form-item
-          label="所需仪器类型"
+          label="配置地址"
           :label-position="itemLabelPosition"
-          prop="instrumentType"
+          prop="configIp"
         >
-          <el-input v-model="formLabelAlign.instrumentType" />
+          <el-input v-model="formLabelAlign.configIp" />
         </el-form-item>
+
         <el-form-item
-          label="名称"
+          label="配置名称"
           :label-position="itemLabelPosition"
           prop="configName"
         >
           <el-input v-model="formLabelAlign.configName" />
         </el-form-item>
+
         <el-form-item
-          label="仪器地址"
+          label="仪器编码	"
           :label-position="itemLabelPosition"
-          prop="configIp"
+          prop="instrumentCode"
         >
-          <el-input v-model="formLabelAlign.configIp" />
+          <el-input v-model="formLabelAlign.instrumentCode" />
+        </el-form-item>
+
+        <el-form-item
+          label="仪器类型		"
+          :label-position="itemLabelPosition"
+          prop="instrumentType"
+        >
+          <el-select
+            v-model="formLabelAlign.instrumentType"
+            placeholder="Select"
+            size="large"
+          >
+            <el-option
+              v-for="item in options"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            />
+          </el-select>
         </el-form-item>
       </el-form>
 
@@ -43,6 +68,7 @@
 
 <script lang="ts" setup>
 import { reactive, ref, watch } from "vue";
+import { selectInstrumentType } from "@/api/config";
 
 const dialogVisible = ref(false);
 
@@ -55,12 +81,22 @@ interface VersionItem {
   instrumentType: string;
   configName: string;
   configIp: string;
+  instrumentProperty: number;
+  instrumentCode: string;
 }
+//configIp	配置地址		true
+//configName	配置名称		true
+//engineeringId	测试工程id		false
+//instrumentCode	仪器编码		true
+//instrumentProperty	仪器属性(1工程仪器 2执行仪器)		true
+//instrumentType	仪器类型
 
 const formLabelAlign = ref<VersionItem>({
   instrumentType: "",
   configName: "",
   configIp: "",
+  instrumentProperty: 1,
+  instrumentCode: "",
 });
 
 const emit = defineEmits(["save"]);
@@ -69,9 +105,14 @@ const saveFun = () => {
   emit("save", formLabelAlign.value, flag.value);
 };
 
+const props = defineProps(["tabName"]);
+
 const ruleFormRef = ref();
 const flag = ref("");
+//show弹框
+const logType = ref("");
 const showDialog = (type: string, data: any) => {
+  logType.value = type;
   dialogVisible.value = true;
   ruleFormRef.value && ruleFormRef.value.resetFields();
   flag.value = type;
@@ -84,6 +125,31 @@ defineExpose({
   showDialog,
   hiddenDialog,
 });
+const options = ref([{}]);
+
+onMounted?.(() => {
+  //查询仪器类型,可以初始化查询,也可以在 showDialog 弹框显示的时候查询
+  selectInstrumentType({}).then((res) => {
+    options.value = [
+      {
+        value: "Option1",
+        label: "Option1",
+      },
+      {
+        value: "Option2",
+        label: "Option2",
+      },
+      {
+        value: "Option3",
+        label: "Option3",
+      },
+      {
+        value: "Option4",
+        label: "Option4",
+      },
+    ];
+  });
+});
 </script>
 <style scoped lang="scss">
 // .add {

+ 154 - 0
src/views/modules/global-config/components/engrGlobalData.vue

@@ -0,0 +1,154 @@
+<script lang="ts" setup>
+import globalDataAddView from "@/views/modules/global-config/components/globalDataAdd.vue";
+
+import {
+  globalDataPage,
+  globalDataAdd,
+  globalDataDel,
+  globalDataUpdate,
+} from "@/api/config";
+import { computed, ref } from "vue";
+const globalChildRef = ref();
+
+//全局列表请求参数
+const globalParams = ref({
+  orders: [
+    {
+      column: "",
+      isAsc: true,
+    },
+  ],
+  pageNo: 1,
+  pageSize: 10,
+});
+//分页
+const globalHandleChange = (currentPage: number, pageSize: number) => {
+  console.log(currentPage);
+  globalParams.value.pageNo = currentPage;
+  getglobalData();
+};
+
+//全局数据数组
+const globalDataList = ref([]);
+//全局数据数据total
+const globalDataTotal = ref(1);
+//请求数据 全局数据
+const getglobalData = () => {
+  globalDataPage(globalParams.value).then((res) => {
+    console.log(res);
+    globalDataList.value = res.data.records;
+    globalDataTotal.value = res.data.totalCount;
+  });
+};
+
+const globalHandleEdit = (index: number, row: any) => {
+  globalChildRef.value && globalChildRef.value.showDialog("change", row);
+};
+
+const addglobalFun = () => {
+  globalChildRef.value && globalChildRef.value.showDialog("add", {});
+};
+
+const globalSaveFun = (data: any, flag: string) => {
+  if (flag === "add") {
+    globalDataAdd(data).then((res) => {
+      globalChildRef.value && globalChildRef.value.hiddenDialog(); //关闭弹框
+      getglobalData(); //重新请求数据
+    });
+  } else {
+    globalDataUpdate(data).then((res) => {
+      globalChildRef.value && globalChildRef.value.hiddenDialog(); //关闭弹框
+      getglobalData(); //重新请求数据
+    });
+  }
+};
+
+const globalHandledel = (index: number, row: any) => {
+  globalDataDel({ id: row.id }).then((res) => {
+    getglobalData(); //重新请求数据
+  });
+};
+
+onMounted?.(() => {
+  getglobalData(); //重新请求数据
+});
+</script>
+
+<template>
+  <div class="global-config-pane">
+    <div class="btns">
+      <el-button type="primary" @click="addglobalFun">
+        <span class="add">+</span>
+        新增
+      </el-button>
+    </div>
+
+    <div>
+      <el-table :data="globalDataList" style="width: 100%">
+        <el-table-column label="序号" type="index" width="80" />
+
+        <el-table-column label="数据项编码" prop="dataItemCode" />
+        <el-table-column label="数据项名称" prop="dataItemName" />
+        <el-table-column label="测试工程id" prop="engineeringId" />
+        <el-table-column label="设定值" prop="setValue" />
+        <el-table-column label="操作" prop="操作" fixed="right">
+          <template #default="scope">
+            <el-button
+              text
+              size="small"
+              type="primary"
+              @click="globalHandledel(scope.$index, scope.row)"
+            >
+              删除
+            </el-button>
+            <el-button
+              text
+              size="small"
+              type="primary"
+              @click="globalHandleEdit(scope.$index, scope.row)"
+            >
+              修改
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        class="content-pag"
+        background
+        layout="prev, pager, next"
+        :page-size="10"
+        :total="globalDataTotal"
+        @change="globalHandleChange"
+      />
+    </div>
+  </div>
+
+  <globalDataAddView ref="globalChildRef" @save="globalSaveFun" />
+</template>
+
+<style scoped lang="scss">
+.add {
+  width: 12px;
+  height: 12px;
+  line-height: 12px;
+  border-radius: 12px;
+  text-align: center;
+  background-color: #fff;
+  color: #3b7cff;
+  margin-right: 10px;
+  vertical-align: middle;
+}
+.global-config-pane {
+  padding: 0 20px;
+  .btns {
+    text-align: right;
+    margin-bottom: 12px;
+  }
+}
+.content-pag {
+  float: right;
+  margin-right: 20px;
+  margin-top: 20px;
+  padding-bottom: 30px;
+}
+</style>

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

@@ -0,0 +1,187 @@
+<script lang="ts" setup>
+import { computed, ref, watch, defineProps } from "vue";
+import {
+  instrumentConfigPage,
+  engrInstrumentConfigUpdate,
+  engrInstrumentConfigAdd,
+  engrInstrumentConfigDel,
+} from "@/api/config";
+import { useCommonStoreHook } from "@/store";
+const { currentProjectId, currentTestItemId } = toRefs(useCommonStoreHook());
+import configAddVue from "@/views/modules/global-config/components/ConfigAdd.vue";
+
+//配置列表请求参数
+const configParams = ref({
+  // engineeringId: "", //测试工程id
+  // instrumentCode: currentProjectId.value, //	仪器编码		false
+  instrumentProperty: "", //	仪器属性(1工程仪器 2执行仪器)
+  orders: [
+    {
+      column: "",
+      isAsc: true,
+    },
+  ],
+  pageNo: 1,
+  pageSize: 10,
+});
+//分页
+const configHandleChange = (currentPage: number, pageSize: number) => {
+  console.log(currentPage);
+  configParams.value.pageNo = currentPage;
+  getInstrumentConfig();
+  // console.log(pageSize);
+};
+
+//测试仪器配置数组
+const instrumentConfigList = ref([]);
+//数据total
+const instrumentConfigTotal = ref(1);
+//请求数据
+const getInstrumentConfig = () => {
+  instrumentConfigPage(configParams.value).then((res) => {
+    console.log(res);
+    instrumentConfigList.value = res.data.records;
+    instrumentConfigTotal.value = res.data.totalCount;
+  });
+};
+
+const props = defineProps(["property", "tabName"]);
+
+watch(
+  () => props.property,
+  (newVal) => {
+    // console.log(newVal);
+    configParams.value.instrumentProperty = newVal; //	仪器属性(1工程仪器 2执行仪器)
+    getInstrumentConfig();
+  },
+  { immediate: true }
+);
+
+const configChildRef = ref();
+
+const configHandleEdit = (index: number, row: any) => {
+  configChildRef.value && configChildRef.value.showDialog("change", row);
+};
+
+const addConfigFun = () => {
+  configChildRef.value && configChildRef.value.showDialog("add", {});
+};
+
+/**
+//新增或修改仪器配置
+ *
+ * @param {any} data - 要保存的仪器配置数据
+ * @param {string} flag - 操作标识,"add" 表示新增,其他值表示修改
+ *
+ * 根据 flag 的值调用相应的 API 进行新增或修改操作,
+ * 操作完成后关闭弹框并重新请求仪器配置数据。
+ */
+const configSaveFun = (data: any, flag: string) => {
+  data.instrumentProperty = configParams.value.instrumentProperty; //	仪器属性(1工程仪器 2执行仪器)
+
+  if (flag === "add") {
+    engrInstrumentConfigAdd(data).then((res) => {
+      configChildRef.value && configChildRef.value.hiddenDialog(); //关闭弹框
+      getInstrumentConfig(); //重新请求数据
+    });
+  } else {
+    engrInstrumentConfigUpdate(data).then((res) => {
+      configChildRef.value && configChildRef.value.hiddenDialog(); //关闭弹框
+      getInstrumentConfig(); //重新请求数据
+    });
+  }
+};
+
+/**
+ * 处理删除配置项的函数
+ * @param {number} index - 配置项在列表中的索引
+ * @param {any} row - 当前配置项的数据对象
+ *
+ * 此函数调用 configDel 方法删除指定的配置项,并在成功后重新请求配置数据。
+ */
+const configHandleDelete = (index: number, row: any) => {
+  engrInstrumentConfigDel({ id: row.id }).then((res) => {
+    getInstrumentConfig(); //重新请求数据
+  });
+};
+</script>
+<template>
+  <div class="global-config-pane">
+    <div class="btns">
+      <el-button type="primary" @click="addConfigFun">
+        <span class="add">+</span>
+        新增
+      </el-button>
+    </div>
+
+    <div>
+      <el-table :data="instrumentConfigList" style="width: 100%">
+        <el-table-column label="序号" type="index" width="80" />
+        <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="操作" fixed="right">
+          <template #default="scope">
+            <el-button
+              text
+              size="small"
+              type="primary"
+              @click="configHandleDelete(scope.$index, scope.row)"
+            >
+              删除
+            </el-button>
+            <el-button
+              text
+              size="small"
+              type="primary"
+              @click="configHandleEdit(scope.$index, scope.row)"
+            >
+              修改
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination
+        class="content-pag"
+        background
+        layout="prev, pager, next"
+        :page-size="10"
+        :total="instrumentConfigTotal"
+        @change="configHandleChange"
+      />
+    </div>
+  </div>
+
+  <configAddVue
+    ref="configChildRef"
+    @save="configSaveFun"
+    :tabName="tabName"
+  ></configAddVue>
+</template>
+<style scoped lang="scss">
+.add {
+  width: 12px;
+  height: 12px;
+  line-height: 12px;
+  border-radius: 12px;
+  text-align: center;
+  background-color: #fff;
+  color: #3b7cff;
+  margin-right: 10px;
+  vertical-align: middle;
+}
+.global-config-pane {
+  padding: 0 20px;
+  .btns {
+    text-align: right;
+    margin-bottom: 12px;
+  }
+}
+.content-pag {
+  float: right;
+  margin-right: 20px;
+  margin-top: 20px;
+  padding-bottom: 30px;
+}
+</style>

+ 33 - 3
src/views/modules/global-config/components/globalDataAdd.vue

@@ -1,6 +1,10 @@
 <template>
   <div class="add">
-    <el-dialog v-model="dialogVisible" title="新建测试工程" width="500">
+    <el-dialog
+      v-model="dialogVisible"
+      :title="'全局数据' + (logType === 'add' ? '新增' : '修改')"
+      width="500"
+    >
       <el-form
         :label-position="labelPosition"
         label-width="auto"
@@ -9,14 +13,30 @@
         ref="ruleFormRef"
       >
         <el-form-item
+          label="数据项编码	"
+          :label-position="itemLabelPosition"
+          prop="dataItemCode"
+        >
+          <el-input v-model="formLabelAlign.dataItemCode" />
+        </el-form-item>
+
+        <el-form-item
           label="数据项名称	"
           :label-position="itemLabelPosition"
-          prop="dataItemName"
+          prop="dataItemCode"
         >
           <el-input v-model="formLabelAlign.dataItemName" />
         </el-form-item>
         <el-form-item
-          label="名称"
+          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"
           prop="setValue"
         >
@@ -47,11 +67,19 @@ const itemLabelPosition = ref<FormItemProps["labelPosition"]>("");
 interface VersionItem {
   dataItemName: string;
   setValue: string;
+  dataItemCode: string;
+  engineeringId: number;
 }
 
+// dataItemCode	数据项编码
+// dataItemName	数据项名称
+// engineeringId	测试工程id
+// setValue 设定值
 const formLabelAlign = ref<VersionItem>({
   dataItemName: "",
   setValue: "",
+  dataItemCode: "",
+  engineeringId: 0,
 });
 
 const emit = defineEmits(["save"]);
@@ -62,7 +90,9 @@ const saveFun = () => {
 
 const ruleFormRef = ref();
 const flag = ref("");
+const logType = ref("");
 const showDialog = (type: string, data: any) => {
+  logType.value = type;
   dialogVisible.value = true;
   ruleFormRef.value && ruleFormRef.value.resetFields();
   flag.value = type;

+ 24 - 263
src/views/modules/global-config/global-config.vue

@@ -1,18 +1,8 @@
 <script lang="ts" setup>
 import { computed, ref } from "vue";
 import type { TabsPaneContext } from "element-plus";
-import {
-  instrumentConfigPage,
-  globalDataPage,
-  configUpdate,
-  configAdd,
-  configDel,
-  globalDataAdd,
-  globalDataDel,
-  globalDataUpdate,
-} from "@/api/config";
-import configAddVue from "./components/ConfigAdd.vue";
-import globalAddVue from "./components/globalDataAdd.vue";
+import engrInstrumentConfig from "@/views/modules/global-config/components/engrInstrumentConfig.vue";
+import engrGlobalData from "@/views/modules/global-config/components/engrGlobalData.vue";
 import SecondHeader from "@/views/modules/conmon/SecondHeader.vue";
 
 const route = useRoute();
@@ -22,150 +12,7 @@ const handleClick = (tab: TabsPaneContext, event: Event) => {
   // console.log(tab, event);
 };
 
-//配置列表请求参数
-const configParams = ref({
-  orders: [
-    {
-      column: "",
-      isAsc: true,
-    },
-  ],
-  pageNo: 1,
-  pageSize: 10,
-});
-//分页
-const configHandleChange = (currentPage: number, pageSize: number) => {
-  console.log(currentPage);
-  configParams.value.pageNo = currentPage;
-  getInstrumentConfig();
-  // console.log(pageSize);
-};
-
-//测试仪器配置数组
-const instrumentConfigList = ref([]);
-//数据total
-const instrumentConfigTotal = ref(1);
-//请求数据
-const getInstrumentConfig = () => {
-  instrumentConfigPage(configParams.value).then((res) => {
-    console.log(res);
-    instrumentConfigList.value = res.data.records;
-    instrumentConfigTotal.value = res.data.totalCount;
-  });
-};
-
-//全局列表请求参数
-const globalParams = ref({
-  orders: [
-    {
-      column: "",
-      isAsc: true,
-    },
-  ],
-  pageNo: 1,
-  pageSize: 10,
-});
-//分页
-const globalHandleChange = (currentPage: number, pageSize: number) => {
-  console.log(currentPage);
-  globalParams.value.pageNo = currentPage;
-  getglobalData();
-};
-
-//全局数据数组
-const globalDataList = ref([]);
-//全局数据数据total
-const globalDataTotal = ref(1);
-//请求数据 全局数据
-const getglobalData = () => {
-  globalDataPage(globalParams.value).then((res) => {
-    console.log(res);
-    globalDataList.value = res.data.records;
-    globalDataTotal.value = res.data.totalCount;
-  });
-};
-
-onMounted?.(() => {
-  getInstrumentConfig();
-  getglobalData();
-  console.log("当前页面的engineerid", route.params.engineerId);
-});
-
-const configChildRef = ref();
-const configHandleEdit = (index: number, row: any) => {
-  configChildRef.value && configChildRef.value.showDialog("change", row);
-};
-
-const addConfigFun = () => {
-  configChildRef.value && configChildRef.value.showDialog("add", {});
-};
-
-/**
-//新增或修改仪器配置
- *
- * @param {any} data - 要保存的仪器配置数据
- * @param {string} flag - 操作标识,"add" 表示新增,其他值表示修改
- *
- * 根据 flag 的值调用相应的 API 进行新增或修改操作,
- * 操作完成后关闭弹框并重新请求仪器配置数据。
- */
-const configSaveFun = (data: any, flag: string) => {
-  if (flag === "add") {
-    configAdd(data).then((res) => {
-      configChildRef.value && configChildRef.value.hiddenDialog(); //关闭弹框
-      getInstrumentConfig(); //重新请求数据
-    });
-  } else {
-    configUpdate(data).then((res) => {
-      configChildRef.value && configChildRef.value.hiddenDialog(); //关闭弹框
-      getInstrumentConfig(); //重新请求数据
-    });
-  }
-};
-
-/**
- * 处理删除配置项的函数
- * @param {number} index - 配置项在列表中的索引
- * @param {any} row - 当前配置项的数据对象
- *
- * 此函数调用 configDel 方法删除指定的配置项,并在成功后重新请求配置数据。
- */
-const configHandleDelete = (index: number, row: any) => {
-  configDel({ id: row.id }).then((res) => {
-    getInstrumentConfig(); //重新请求数据
-  });
-};
-
 // =======================
-const globalChildRef = ref();
-
-const globalHandleEdit = (index: number, row: any) => {
-  globalChildRef.value && globalChildRef.value.showDialog("change", row);
-};
-
-const addglobalFun = () => {
-  globalChildRef.value && globalChildRef.value.showDialog("add", {});
-};
-
-const globalSaveFun = (data: any, flag: string) => {
-  if (flag === "add") {
-    globalDataAdd(data).then((res) => {
-      globalChildRef.value && globalChildRef.value.hiddenDialog(); //关闭弹框
-      getglobalData(); //重新请求数据
-    });
-  } else {
-    globalDataUpdate(data).then((res) => {
-      globalChildRef.value && globalChildRef.value.hiddenDialog(); //关闭弹框
-      getglobalData(); //重新请求数据
-    });
-  }
-};
-
-const globalHandledel = (index: number, row: any) => {
-  globalDataDel({ id: row.id }).then((res) => {
-    getglobalData(); //重新请求数据
-  });
-};
 </script>
 
 <template>
@@ -173,106 +20,20 @@ const globalHandledel = (index: number, row: any) => {
     <SecondHeader>全局配置</SecondHeader>
     <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
       <el-tab-pane label="仪器配置" name="仪器配置">
-        <div class="global-config-pane">
-          <div class="btns">
-            <el-button type="primary" @click="addConfigFun">
-              <span class="add">+</span>
-              新增
-            </el-button>
-          </div>
-
-          <div>
-            <el-table :data="instrumentConfigList" style="width: 100%">
-              <el-table-column label="序号" type="index" width="80" />
-              <el-table-column label="所需仪器类型" prop="instrumentType" />
-              <el-table-column label="名称" prop="configName" />
-              <el-table-column label="仪器地址" prop="configIp" />
-              <el-table-column label="操作" prop="操作" fixed="right">
-                <template #default="scope">
-                  <el-button
-                    text
-                    size="small"
-                    type="primary"
-                    @click="configHandleDelete(scope.$index, scope.row)"
-                  >
-                    删除
-                  </el-button>
-                  <el-button
-                    text
-                    size="small"
-                    type="primary"
-                    @click="configHandleEdit(scope.$index, scope.row)"
-                  >
-                    修改
-                  </el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-            <el-pagination
-              class="content-pag"
-              background
-              layout="prev, pager, next"
-              :page-size="10"
-              :total="instrumentConfigTotal"
-              @change="configHandleChange"
-            />
-          </div>
-        </div>
+        <engrInstrumentConfig :property="1" tabName="仪器配置" />
       </el-tab-pane>
       <el-tab-pane label="全局数据" name="全局数据">
-        <div class="global-config-pane">
-          <div class="btns">
-            <el-button type="primary" @click="addglobalFun">
-              <span class="add">+</span>
-              新增
-            </el-button>
-          </div>
-
-          <div>
-            <el-table :data="globalDataList" style="width: 100%">
-              <el-table-column label="序号" type="index" width="80" />
-              <el-table-column label="数据项名称" prop="dataItemName" />
-              <el-table-column label="设定值" prop="setValue" />
-              <el-table-column label="操作" prop="操作" fixed="right">
-                <template #default="scope">
-                  <el-button
-                    text
-                    size="small"
-                    type="primary"
-                    @click="globalHandledel(scope.$index, scope.row)"
-                  >
-                    删除
-                  </el-button>
-                  <el-button
-                    text
-                    size="small"
-                    type="primary"
-                    @click="globalHandleEdit(scope.$index, scope.row)"
-                  >
-                    修改
-                  </el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-            <el-pagination
-              class="content-pag"
-              background
-              layout="prev, pager, next"
-              :page-size="10"
-              :total="globalDataTotal"
-              @change="globalHandleChange"
-            />
-          </div>
-        </div>
+        <engrGlobalData />
+      </el-tab-pane>
+      <el-tab-pane label="执行终端" name="执行终端">
+        <engrInstrumentConfig :property="2" tabName="执行终端" />
+        <!-- 跟仪器配置一样只是 instrumentProperty 仪器属性(1工程仪器 2执行仪器)
+        仪器类型是字典要选择 -->
       </el-tab-pane>
-      <el-tab-pane label="执行终端" name="执行终端"
-        >跟仪器配置一样只是 instrumentProperty 仪器属性(1工程仪器 2执行仪器)
-        仪器类型是字典要选择</el-tab-pane
-      >
     </el-tabs>
 
-    <configAddVue ref="configChildRef" @save="configSaveFun"></configAddVue>
-    <globalAddVue ref="globalChildRef" @save="globalSaveFun"></globalAddVue>
+    <!-- <configAddVue ref="configChildRef" @save="configSaveFun"></configAddVue> -->
+    <!-- <globalAddVue ref="globalChildRef" @save="globalSaveFun"></globalAddVue> -->
   </div>
 </template>
 
@@ -286,13 +47,6 @@ const globalHandledel = (index: number, row: any) => {
       padding: 0 20px;
     }
   }
-  .global-config-pane {
-    padding: 0 20px;
-    .btns {
-      text-align: right;
-      margin-bottom: 12px;
-    }
-  }
   .add {
     width: 12px;
     height: 12px;
@@ -304,11 +58,18 @@ const globalHandledel = (index: number, row: any) => {
     margin-right: 10px;
     vertical-align: middle;
   }
-  .content-pag {
-    float: right;
-    margin-right: 20px;
-    margin-top: 20px;
-    padding-bottom: 30px;
-  }
+  // .global-config-pane {
+  //   padding: 0 20px;
+  //   .btns {
+  //     text-align: right;
+  //     margin-bottom: 12px;
+  //   }
+  // }
+  // .content-pag {
+  //   float: right;
+  //   margin-right: 20px;
+  //   margin-top: 20px;
+  //   padding-bottom: 30px;
+  // }
 }
 </style>

+ 101 - 86
src/views/modules/home/home.vue

@@ -15,23 +15,25 @@
         <div class="box-text">工程类型</div>
       </div>
       <div class="head-box-group">
-        <el-checkbox-group
-          v-model="checkedCities"
-          @change="handleCheckedCitiesChange"
-        >
-          <div
-            class="head-box-item"
-            :class="[
-              checkedCities.includes(type.engineeringType) ? 'active' : '',
-            ]"
-            v-for="type in typeList"
-            :key="type.engineeringType"
+        <el-scrollbar>
+          <el-checkbox-group
+            v-model="checkedCities"
+            @change="handleCheckedCitiesChange"
           >
-            <el-checkbox label="" :value="type.engineeringType"></el-checkbox>
-            <div class="name">{{ type.engineeringType }}</div>
-            <div class="num">{{ type.typeCount }}</div>
-          </div>
-        </el-checkbox-group>
+            <div
+              class="head-box-item"
+              :class="[
+                checkedCities.includes(type.engineeringType) ? 'active' : '',
+              ]"
+              v-for="type in typeList"
+              :key="type.engineeringType"
+            >
+              <el-checkbox label="" :value="type.engineeringType"></el-checkbox>
+              <div class="name">{{ type.engineeringType }}</div>
+              <div class="num">{{ type.typeCount }}</div>
+            </div>
+          </el-checkbox-group>
+        </el-scrollbar>
       </div>
     </div>
     <div class="content-body">
@@ -52,74 +54,81 @@
           <!--          </el-button>-->
         </div>
       </div>
-
-      <div class="content-list">
-        <div
-          v-for="(item, index) in engineeringList"
-          :key="index"
-          class="content-list-item"
-        >
-          <div class="list-item-flex">
-            <div class="list-itme-tit">{{ item.engineeringProductName }}</div>
-            <div class="list-item-switch">
-              <span class="item-gray">发布</span
-              ><el-switch
-                v-model="item.publishStatus"
-                @change="changeProjectStatus(item)"
-              />
-            </div>
-          </div>
-          <div class="list-item-flex">
-            <div>
-              <span class="item-gray">工程类型:</span
-              >{{ item.engineeringType }}
-            </div>
-            <div>
-              <span class="item-gray">版本:</span>{{ item.engineeringVersion }}
-            </div>
-          </div>
-          <div class="list-item-flex">
-            <div>
-              <span class="item-gray">开发人员:</span>{{ item.creator }}
-            </div>
-            <div>
-              <span class="item-gray">更新时间:</span>{{ item.updated }}
-            </div>
-          </div>
-          <div class="list-item-btns">
-            <span @click="toEdit(item)">
-              <svg-icon icon-class="homeIcon2" />
-            </span>
-            <el-popconfirm
-              width="220"
-              :icon="InfoFilled"
-              icon-color="#626AEF"
-              title="确认要删除这个工程吗?"
-              @cancel="onDelCancel"
-              @confirm="deleteConfirm(item)"
+      <div class="content-scrollbar">
+        <el-scrollbar>
+          <div class="content-list">
+            <div
+              v-for="(item, index) in engineeringList"
+              :key="index"
+              class="content-list-item"
             >
-              <template #reference>
+              <div class="list-item-flex">
+                <div class="list-itme-tit">
+                  {{ item.engineeringProductName }}
+                </div>
+                <div class="list-item-switch">
+                  <span class="item-gray">发布</span
+                  ><el-switch
+                    v-model="item.publishStatus"
+                    @change="changeProjectStatus(item)"
+                  />
+                </div>
+              </div>
+              <div class="list-item-flex">
+                <div>
+                  <span class="item-gray">工程类型:</span
+                  >{{ item.engineeringType }}
+                </div>
+                <div>
+                  <span class="item-gray">版本:</span
+                  >{{ item.engineeringVersion }}
+                </div>
+              </div>
+              <div class="list-item-flex">
+                <div>
+                  <span class="item-gray">开发人员:</span>{{ item.creator }}
+                </div>
+                <div>
+                  <span class="item-gray">更新时间:</span>{{ item.updated }}
+                </div>
+              </div>
+              <div class="list-item-btns">
+                <span @click="toEdit(item)">
+                  <svg-icon icon-class="homeIcon2" />
+                </span>
+                <el-popconfirm
+                  width="220"
+                  :icon="InfoFilled"
+                  icon-color="#626AEF"
+                  title="确认要删除这个工程吗?"
+                  @cancel="onDelCancel"
+                  @confirm="deleteConfirm(item)"
+                >
+                  <template #reference>
+                    <span>
+                      <svg-icon icon-class="homeIcon3" />
+                    </span>
+                  </template>
+                  <template #actions="{ confirm, cancel }">
+                    <el-button size="small" @click="cancel">取消</el-button>
+                    <el-button type="danger" size="small" @click="confirm">
+                      确认删除
+                    </el-button>
+                  </template>
+                </el-popconfirm>
+
+                <span @click="gotoConfigProject(item)">
+                  <svg-icon icon-class="homeIcon4" />
+                </span>
                 <span>
-                  <svg-icon icon-class="homeIcon3" />
+                  <svg-icon icon-class="homeIcon1" />
                 </span>
-              </template>
-              <template #actions="{ confirm, cancel }">
-                <el-button size="small" @click="cancel">取消</el-button>
-                <el-button type="danger" size="small" @click="confirm">
-                  确认删除
-                </el-button>
-              </template>
-            </el-popconfirm>
-
-            <span @click="gotoConfigProject(item)">
-              <svg-icon icon-class="homeIcon4" />
-            </span>
-            <span>
-              <svg-icon icon-class="homeIcon1" />
-            </span>
+              </div>
+            </div>
           </div>
-        </div>
+        </el-scrollbar>
       </div>
+
       <el-pagination
         class="content-pag"
         background
@@ -299,14 +308,15 @@ const gotoConfigProject = (project) => {
 
   .content-head {
     color: var(--hj-white-1);
-    display: flex;
+    // display: flex;
     height: 100px;
     background: $hj-white-1;
     // width: 100%;
     // overflow: hidden;
-    min-width: 0;
+    // min-width: 0;
 
     .head-box-all {
+      display: inline-block;
       padding: 6px;
       box-sizing: border-box;
       border-radius: 4px 0 0 4px;
@@ -329,13 +339,16 @@ const gotoConfigProject = (project) => {
     }
 
     .head-box-group {
-      flex: 1;
+      display: inline-block;
+      width: calc(100% - 100px);
+
+      // flex: 1;
 
       .el-checkbox-group {
-        height: 100%;
+        // height: 100%;
         width: 100%;
-        overflow-x: auto;
-        overflow-y: hidden;
+        // overflow-x: auto;
+        // overflow-y: hidden;
         white-space: nowrap;
         display: flex;
         align-content: center;
@@ -433,7 +446,9 @@ const gotoConfigProject = (project) => {
       }
     }
   }
-
+  .content-scrollbar {
+    height: calc(100vh - 325px);
+  }
   .content-list {
     width: 100%;
     display: grid;

+ 42 - 6
src/views/modules/project-config/com/project-message.vue

@@ -1,7 +1,8 @@
 <script setup>
 import { propertyData } from "../configs/properites";
+import moduleDialog from "@/views//modules/project-config/components/test-module-dialog.vue";
 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());
@@ -35,14 +36,37 @@ const toGetTestProjectList = () => {
     testProjectList.value = res.data ?? [];
   });
 };
+
+let clickItem = null;
 // 当点击了项目
 const clickTestProjectItem = (item) => {
   let data = JSON.parse(JSON.stringify(item));
-
+  clickItem = data;
   currentTestItemId.value = item.id;
-
   emits("onClickItem", data);
 };
+
+const moduleDialogRef = ref();
+//新增测试项目
+const addProject = () => {
+  moduleDialogRef.value.openDialog(false, null, currentProjectId.value);
+};
+//修改测试项目
+const editProject = () => {
+  clickItem &&
+    moduleDialogRef.value.openDialog(true, clickItem, currentProjectId.value);
+};
+//删除测试项目
+const confirmEvent = () => {
+  if (currentTestItemId.value) {
+    delTestModule({
+      id: currentTestItemId.value,
+    }).then((res) => {
+      currentTestItemId.value = "";
+      toGetTestProjectList(); //重新获取
+    });
+  }
+};
 </script>
 
 <template>
@@ -77,9 +101,19 @@ const clickTestProjectItem = (item) => {
     <div class="project-test-btn">
       <div class="name">测试项目</div>
       <div class="btn">
-        <span>-</span>
-        <span>+</span>
-        <span class="edit">
+        <el-popconfirm
+          width="220"
+          confirm-button-text="确认"
+          cancel-button-text="取消"
+          title="是否删除"
+          @confirm="confirmEvent"
+        >
+          <template #reference>
+            <span>-</span>
+          </template>
+        </el-popconfirm>
+        <span @click="addProject">+</span>
+        <span class="edit" @click="editProject">
           <svg-icon icon-class="homeIcon2" />
         </span>
       </div>
@@ -101,6 +135,8 @@ const clickTestProjectItem = (item) => {
       </el-scrollbar>
     </div>
   </div>
+
+  <moduleDialog ref="moduleDialogRef" @saveFinish="toGetTestProjectList" />
 </template>
 
 <style scoped lang="scss">

+ 127 - 0
src/views/modules/project-config/components/test-module-dialog.vue

@@ -0,0 +1,127 @@
+<template>
+  <div class="add">
+    <el-dialog
+      v-model="dialogVisible"
+      :title="isEdit1 ? '修改测试工程' : '新建测试工程'"
+      width="500"
+      :close-on-click-modal="false"
+      @closed="handleClose"
+    >
+      <el-form
+        :label-position="labelPosition"
+        label-width="auto"
+        ref="formRef"
+        :rules="rules"
+        v-model:model="formLabelAlign"
+        style="max-width: 600px"
+      >
+        <el-form-item
+          label="项目名称"
+          :label-position="itemLabelPosition"
+          prop="projectName"
+        >
+          <el-input v-model="formLabelAlign.projectName" />
+        </el-form-item>
+
+        <el-form-item
+          label="路线详情"
+          :label-position="itemLabelPosition"
+          prop="routeData"
+        >
+          <el-input v-model="formLabelAlign.routeData" />
+        </el-form-item>
+      </el-form>
+
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="handleClose">取消</el-button>
+          <el-button type="primary" @click="submitForm(formRef)">
+            保存
+          </el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script lang="ts" setup>
+import { reactive, ref, watch } from "vue";
+
+const dialogVisible = ref(false);
+
+import type { FormItemProps, FormProps, FormRules } from "element-plus";
+// import { addProject, updateProject } from "@/api/project";
+import { addTestModule, updateTestModule } from "@/api/project";
+
+const labelPosition = ref<FormProps["labelPosition"]>("right");
+const itemLabelPosition = ref<FormItemProps["labelPosition"]>("");
+
+interface VersionItem {
+  engineeringId: string;
+  projectName: string;
+  routeData: string;
+}
+
+const formRef = ref<FormProps>();
+
+const formLabelAlign = ref<VersionItem>({
+  engineeringId: "",
+  projectName: "",
+  routeData: "",
+});
+const rules = reactive({
+  projectName: [
+    { required: true, message: "请输入 项目名称", trigger: "blur" },
+  ],
+});
+
+const emit = defineEmits(["saveFinish"]);
+const handleClose = (done: () => void) => {
+  formRef.value && formRef.value.resetFields();
+  dialogVisible.value = false;
+};
+
+const submitForm = async (formEl) => {
+  if (!formEl) return;
+  await formEl.validate(async (valid, fields) => {
+    if (valid) {
+      if (isEdit1) {
+        updateTestModule(formLabelAlign.value);
+      } else {
+        await addTestModule(formLabelAlign.value);
+      }
+      emit("saveFinish");
+      handleClose();
+    } else {
+      console.log("error submit!", fields);
+    }
+  });
+};
+
+let isEdit1 = false;
+const openDialog = (
+  isEdit: boolean,
+  row: VersionItem,
+  currentProjectId: string
+) => {
+  dialogVisible.value = true;
+  console.log(currentProjectId);
+
+  isEdit1 = isEdit;
+  if (isEdit) {
+    formLabelAlign.value = row;
+  }
+  formLabelAlign.value.engineeringId = currentProjectId;
+};
+
+defineExpose({ openDialog });
+</script>
+<style scoped lang="scss">
+// .add {
+//   // position: fixed;
+//   // width: 100%;
+//   // height: 100%;
+//   // z-index: 10;
+//   // background-color: #000;
+// }
+</style>