zhaoke 2 years ago
parent
commit
dad6012893

+ 3 - 0
public/demo.js

@@ -225,6 +225,9 @@ const SERVICE_ID = {
 
   /***-----系统设置------***/
   sysProtoTabId: 1, //系统设置-协议管理-表格-增删改
+  sysServiceOutputEdit: 2, // 系统设置-服务管理-编辑服务-输出
+  sysServiceEdit: 3, //系统设置-服务管理-新增/编辑
+  sysServiceMachineEdit: 4, //系统设置-服务管理-编辑服务-部署机器-多选框
   sysServiceEdit: 3, //系统设置-服务管理-新增服务-提交/编辑服务-保存
   sysServiceEditBoxId: 4, //系统设置-服务管理-编辑服务-部署机器-多选框
   sysQueryTabId: 5, //系统设置-查询模板-表格-增删改

+ 207 - 368
src/views/systemSettings/serviceManagement/index.vue

@@ -1,11 +1,7 @@
 <template>
   <div class="serivce-home scroll-y">
     <div class="wrap">
-      <MinHeader
-        :is-auth="true"
-        :is-statuser="true"
-        @addForm="addServiceDialogShow"
-      >
+      <MinHeader :is-auth="true" :is-statuser="true" @addForm="addServiceDialogShow">
         <template #header>
           <div class="status flex-wrap">
             <div class="manageTitle">服务管理</div>
@@ -16,57 +12,19 @@
         </template>
       </MinHeader>
       <div class="app-containers">
-        <DataTable
-          :is-Status="true"
-          :table-header="tableColumns"
-          :table-data="tableData"
-          :table-btn-group="tableBtnGroup"
-          btn-group-width="310px"
-          :table-property="{ rowKey: 'ID' }"
-          @btn-click="tableButtonClickHandler"
-        />
+        <DataTable :is-Status="true" :table-header="tableColumns" :table-data="tableData" :table-btn-group="tableBtnGroup" btn-group-width="310px" :table-property="{ rowKey: 'ID' }" @btn-click="tableButtonClickHandler" />
       </div>
-      <Dialog
-        :width="serviceDialogWidth"
-        :flag="serviceDialogVisible"
-        :type="serviceDialogType"
-        :del-name="delName"
-        :msg-title="msgTitle"
-        @del-remove="delSubmitHandler"
-        @del-rest="delDialogHide"
-        @submit-form="serviceSubmitHandler"
-        @reset-form="addServiceDialogHide"
-      >
-        <el-form
-          ref="serviceFormRef"
-          class="service-form"
-          :model="serviceForm"
-          :rules="serviceFormRules"
-          label-position="right"
-          label-width="90px"
-          size="mini"
-        >
+      <Dialog :width="serviceDialogWidth" :flag="serviceDialogVisible" :type="serviceDialogType" :del-name="delName" :msg-title="msgTitle" @del-remove="delSubmitHandler" @del-rest="delDialogHide" @submit-form="serviceSubmitHandler" @reset-form="addServiceDialogHide">
+        <el-form ref="serviceFormRef" class="service-form" :model="serviceForm" :rules="serviceFormRules" label-position="right" label-width="90px" size="mini">
           <el-row :gutter="36" type="flex">
             <el-col :span="12">
               <el-form-item label="服务名称" prop="serviceName">
-                <el-input
-                  v-model="serviceForm.serviceName"
-                  placeholder="请输入服务名称"
-                  clearable
-                />
+                <el-input v-model="serviceForm.serviceName" placeholder="请输入服务名称" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item
-                label="前序输出编号"
-                label-width="120px"
-                prop="serviceOutputID"
-              >
-                <el-input
-                  v-model="serviceForm.serviceOutputID"
-                  placeholder="请输入前序输出编号"
-                  clearable
-                />
+              <el-form-item label="前序输出编号" label-width="120px" prop="serviceOutputID">
+                <el-input v-model="serviceForm.serviceOutputID" placeholder="请输入前序输出编号" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="12">
@@ -91,146 +49,66 @@
               <div class="flex">
                 <el-form-item label="数据来源" prop="dataSourceID">
                   <el-select v-model="serviceForm.dataSourceID" clearable>
-                    <el-option
-                      v-for="dataSource in selectOptionMap[
+                    <el-option v-for="dataSource in selectOptionMap[
                         queryTemplateIDMap.dataSourceName
-                      ]"
-                      :key="dataSource.dataSourceID"
-                      :value="dataSource.dataSourceID"
-                      :label="dataSource.dataSourceName"
-                    />
+                      ]" :key="dataSource.dataSourceID" :value="dataSource.dataSourceID" :label="dataSource.dataSourceName" />
                   </el-select>
                 </el-form-item>
-                <el-button
-                  type="primary"
-                  size="small"
-                  style="height: 28px; line-height: 0px"
-                  @click="addDataSourceDialogShow"
-                  >新增</el-button
-                >
+                <el-button type="primary" size="small" style="height: 28px; line-height: 0px" @click="addDataSourceDialogShow">新增</el-button>
               </div>
             </el-col>
             <el-col :span="12">
-              <el-form-item
-                label="数据来源对象"
-                label-width="120px"
-                prop="sourceObjectName"
-              >
-                <el-input
-                  v-model="serviceForm.sourceObjectName"
-                  placeholder="请输入数据来源对象名称"
-                  clearable
-                />
+              <el-form-item label="数据来源对象" label-width="120px" prop="sourceObjectName">
+                <el-input v-model="serviceForm.sourceObjectName" placeholder="请输入数据来源对象名称" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="12">
               <el-form-item label="服务描述" prop="serviceDescribe">
-                <el-input
-                  v-model="serviceForm.serviceDescribe"
-                  placeholder="请输入描述"
-                  clearable
-                />
+                <el-input v-model="serviceForm.serviceDescribe" placeholder="请输入描述" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item
-                label="生命周期ID键名"
-                prop="lifeCycleCol"
-                label-width="120px"
-              >
-                <el-input
-                  v-model="serviceForm.lifeCycleCol"
-                  placeholder="请输入生命周期ID键名"
-                  clearable
-                />
+              <el-form-item label="生命周期ID键名" prop="lifeCycleCol" label-width="120px">
+                <el-input v-model="serviceForm.lifeCycleCol" placeholder="请输入生命周期ID键名" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="24">
               <el-form-item label="取值规则" prop="computingMethod">
-                <el-input
-                  v-model="serviceForm.computingMethod"
-                  placeholder="请输入取值规则"
-                  type="textarea"
-                  :autosize="{ minRows: 4, maxRows: 4 }"
-                  resize="none"
-                  clearable
-                />
+                <el-input v-model="serviceForm.computingMethod" placeholder="请输入取值规则" type="textarea" :autosize="{ minRows: 4, maxRows: 4 }" resize="none" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="24">
               <el-form-item label="检测规则" prop="validationExpression">
-                <el-input
-                  v-model="serviceForm.validationExpression"
-                  placeholder="请输入检测规则"
-                  type="textarea"
-                  :autosize="{ minRows: 4, maxRows: 4 }"
-                  resize="none"
-                  clearable
-                />
+                <el-input v-model="serviceForm.validationExpression" placeholder="请输入检测规则" type="textarea" :autosize="{ minRows: 4, maxRows: 4 }" resize="none" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="启动时间" prop="startTime">
-                <el-date-picker
-                  v-model="serviceForm.startTime"
-                  type="datetime"
-                  format="YYYY-MM-DD HH:mm"
-                  value-format="YYYY-MM-DD HH:mm"
-                  placeholder="请选择启动时间"
-                />
+                <el-date-picker v-model="serviceForm.startTime" type="datetime" format="YYYY-MM-DD HH:mm" value-format="YYYY-MM-DD HH:mm" placeholder="请选择启动时间" />
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="停止时间" prop="stopTime">
-                <el-date-picker
-                  v-model="serviceForm.stopTime"
-                  type="datetime"
-                  format="YYYY-MM-DD HH:mm"
-                  value-format="YYYY-MM-DD HH:mm"
-                  placeholder="请选择停止时间"
-                />
+                <el-date-picker v-model="serviceForm.stopTime" type="datetime" format="YYYY-MM-DD HH:mm" value-format="YYYY-MM-DD HH:mm" placeholder="请选择停止时间" />
               </el-form-item>
             </el-col>
             <el-col :span="8">
-              <el-form-item
-                label="失败重试次数"
-                prop="retryCount"
-                label-width="100px"
-              >
-                <el-input
-                  v-model="serviceForm.retryCount"
-                  type="number"
-                  placeholder="请输入重试次数"
-                  clearable
-                />
+              <el-form-item label="失败重试次数" prop="retryCount" label-width="100px">
+                <el-input v-model="serviceForm.retryCount" type="number" placeholder="请输入重试次数" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="循环次数" prop="loopCount">
-                <el-input
-                  v-model="serviceForm.loopCount"
-                  type="number"
-                  placeholder="请输入循环次数"
-                  clearable
-                />
+                <el-input v-model="serviceForm.loopCount" type="number" placeholder="请输入循环次数" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="循环频率" prop="frequencyCount">
-                <el-input
-                  v-model="serviceForm.frequencyCount"
-                  type="number"
-                  placeholder="请输入循环频率"
-                  clearable
-                />
+                <el-input v-model="serviceForm.frequencyCount" type="number" placeholder="请输入循环频率" clearable />
               </el-form-item>
             </el-col>
             <el-col :span="8">
-              <el-form-item
-                label="循环频率单位"
-                prop="frequencyUnit"
-                label-width="100px"
-              >
+              <el-form-item label="循环频率单位" prop="frequencyUnit" label-width="100px">
                 <el-select v-model="serviceForm.frequencyUnit" clearable>
                   <el-option label="天" :value="24 * 60 * 60 * 1000" />
                   <el-option label="小时" :value="60 * 60 * 1000" />
@@ -241,75 +119,36 @@
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item
-                label="日志存储位置"
-                label-width="100px"
-                prop="logDataSourceID"
-              >
+              <el-form-item label="日志存储位置" label-width="100px" prop="logDataSourceID">
                 <el-select v-model="serviceForm.logDataSourceID">
-                  <el-option
-                    v-for="dataSource in selectOptionMap[
+                  <el-option v-for="dataSource in selectOptionMap[
                       queryTemplateIDMap.dataSourceName
-                    ]"
-                    :key="dataSource.dataSourceID"
-                    :value="dataSource.dataSourceID"
-                    :label="dataSource.dataSourceName"
-                  />
+                    ]" :key="dataSource.dataSourceID" :value="dataSource.dataSourceID" :label="dataSource.dataSourceName" />
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item
-                label="日志过滤条件"
-                label-width="100px"
-                prop="logList"
-              >
-                <el-input
-                  v-model="serviceForm.logList"
-                  placeholder="请输入日志过滤条件"
-                  clearable
-                />
+              <el-form-item label="日志过滤条件" label-width="100px" prop="logList">
+                <el-input v-model="serviceForm.logList" placeholder="请输入日志过滤条件" clearable />
               </el-form-item>
             </el-col>
           </el-row>
         </el-form>
       </Dialog>
-      <Dialog
-        type="add"
-        width="500px"
-        :flag="dataSourceDialogVisible"
-        msg-title="新增数据来源"
-        @submit-form="dataSourceSubmitHandler"
-        @reset-form="dataSourceDialogHide"
-      >
+      <Dialog type="add" width="500px" :flag="dataSourceDialogVisible" msg-title="新增数据来源" @submit-form="dataSourceSubmitHandler" @reset-form="dataSourceDialogHide">
         <el-form ref="sourceFormRef" label-width="100px" :model="sourceForm">
           <el-form-item label="数据源名称">
             <el-input v-model="sourceForm.dataSourceName" size="small" />
           </el-form-item>
           <el-form-item label="协议名称">
-            <el-select
-              size="small"
-              style="width: 100%"
-              v-model="sourceForm.protocolID"
-              placeholder="请选择活动区域"
-            >
-              <el-option
-                v-for="protocol in selectOptionMap[
+            <el-select size="small" style="width: 100%" v-model="sourceForm.protocolID" placeholder="请选择活动区域">
+              <el-option v-for="protocol in selectOptionMap[
                   queryTemplateIDMap.protocolName
-                ]"
-                :key="protocol.protocolID"
-                :label="protocol.protocolName"
-                :value="protocol.protocolID"
-              />
+                ]" :key="protocol.protocolID" :label="protocol.protocolName" :value="protocol.protocolID" />
             </el-select>
           </el-form-item>
           <el-form-item label="连接参数">
-            <el-input
-              size="small"
-              type="textarea"
-              rows="3"
-              v-model="sourceForm.connectConfig"
-            />
+            <el-input size="small" type="textarea" rows="3" v-model="sourceForm.connectConfig" />
           </el-form-item>
         </el-form>
       </Dialog>
@@ -317,40 +156,40 @@
   </div>
 </template>
 <script setup lang="ts">
-import DataTable from '@/components/tableTemp/index.vue'
-import MinHeader from '@/components/minheader/index.vue'
-import Dialog from '@/components/dialog/index.vue'
-import { ElMessage, FormInstance } from 'element-plus'
+import DataTable from "@/components/tableTemp/index.vue";
+import MinHeader from "@/components/minheader/index.vue";
+import Dialog from "@/components/dialog/index.vue";
+import { ElMessage, FormInstance } from "element-plus";
 import {
   CommonTableColumn,
   CommonQueryResult,
   SelectOption,
   SelectOptionQueryResult,
-} from '~/common'
-import request from '@/utils/axiosReq'
-import { Query, GeneralDataReception } from '@/api/webApi'
+} from "~/common";
+import request from "@/utils/axiosReq";
+import { Query, GeneralDataReception } from "@/api/webApi";
 
-const router = useRouter()
+const router = useRouter();
 
 const queryTemplateIDMap = reactive<{
-  [x: string]: number
-}>({})
+  [x: string]: number;
+}>({});
 const selectOptionMap = reactive<{
-  [id: number]: SelectOption[]
-}>({})
+  [id: number]: SelectOption[];
+}>({});
 const getSelectOptionOfColumn = (columns: CommonTableColumn[]) => {
   columns.forEach(async ({ columnName, listqueryTemplateID }) => {
     if (listqueryTemplateID !== null && !queryTemplateIDMap[columnName]) {
-      queryTemplateIDMap[columnName] = listqueryTemplateID
+      queryTemplateIDMap[columnName] = listqueryTemplateID;
       if (!selectOptionMap[listqueryTemplateID]) {
-        selectOptionMap[listqueryTemplateID] = []
+        selectOptionMap[listqueryTemplateID] = [];
         selectOptionMap[listqueryTemplateID] = await getSelectOptions(
           listqueryTemplateID
-        )
+        );
       }
     }
-  })
-}
+  });
+};
 const getSelectOptions = async (id: number) => {
   try {
     const {
@@ -360,9 +199,9 @@ const getSelectOptions = async (id: number) => {
     }: SelectOptionQueryResult = await Query({
       id,
       dataContent: [],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
     const options = listValues.map(({ k, v, setlabel, setvalue }) => ({
       k,
@@ -371,35 +210,35 @@ const getSelectOptions = async (id: number) => {
       setvalue,
       [setlabel]: k,
       [setvalue]: v,
-    }))
-    return options
+    }));
+    return options;
   } catch (error) {
-    console.error(error)
-    return []
+    console.error(error);
+    return [];
   }
-}
+};
 onMounted(async () => {
-  queryTemplateIDMap.protocolName = DATACONTENT_ID.protocolOptions
+  queryTemplateIDMap.protocolName = DATACONTENT_ID.protocolOptions;
   selectOptionMap[queryTemplateIDMap.protocolName] = await getSelectOptions(
     queryTemplateIDMap.protocolName
-  )
-})
+  );
+});
 
 // 表格
-const tableColumns = ref<CommonTableColumn[]>([])
-const tableData = ref<any[]>([])
-const page = ref(0)
-const noMore = ref(false)
-const rowTitle = ref('')
+const tableColumns = ref<CommonTableColumn[]>([]);
+const tableData = ref<any[]>([]);
+const page = ref(0);
+const noMore = ref(false);
+const rowTitle = ref("");
 onMounted(() => {
-  getTableData()
-})
+  getTableData();
+});
 const resetTable = () => {
-  page.value = 0
-  noMore.value = false
-  tableData.value = []
-  getTableData()
-}
+  page.value = 0;
+  noMore.value = false;
+  tableData.value = [];
+  getTableData();
+};
 const getTableData = async () => {
   try {
     const {
@@ -410,81 +249,81 @@ const getTableData = async () => {
       id: DATACONTENT_ID.sysServiceTable,
       dataContent: [],
       needPage: ++page.value,
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message || '失败')
+      throw new Error(message || "失败");
     }
     if (listValues.length === 0) {
-      page.value--
-      noMore.value = false
+      page.value--;
+      noMore.value = false;
     }
-    const titleColumn = columnSet.find(column => column.needShow === 1)
+    const titleColumn = columnSet.find((column) => column.needShow === 1);
     if (titleColumn) {
-      rowTitle.value = titleColumn.columnName
+      rowTitle.value = titleColumn.columnName;
     }
-    getSelectOptionOfColumn(columnSet)
-    tableColumns.value = columnSet
-    tableData.value.push(...listValues)
+    getSelectOptionOfColumn(columnSet);
+    tableColumns.value = columnSet;
+    tableData.value.push(...listValues);
   } catch (error) {
-    page.value--
-    console.error(error)
+    page.value--;
+    console.error(error);
   }
-}
+};
 const tableBtnGroup = [
   {
-    name: '查看',
-    className: 'editBtn',
+    name: "查看",
+    className: "editBtn",
     param: 1,
   },
   {
-    name: '编辑',
-    className: 'editBtn',
+    name: "编辑",
+    className: "editBtn",
     param: 2,
   },
   {
-    name: '停止',
-    className: 'editBtn',
+    name: "停止",
+    className: "editBtn",
     param: 3,
   },
   {
-    name: '删除',
-    className: 'delBtn',
+    name: "删除",
+    className: "delBtn",
     param: 4,
   },
-]
+];
 const tableButtonClickHandler = (rowIndex: number, row: any, param: number) => {
   switch (param) {
     case 1:
       router.push({
-        path: '/systemSettings/serviceTopology',
+        path: "/systemSettings/serviceTopology",
         query: {
-          serviceID: row['serviceID'],
-          serviceName: row['serviceName'],
+          serviceID: row["serviceID"],
+          serviceName: row["serviceName"],
         },
-      })
-      break
+      });
+      break;
     case 2:
       router.push({
-        path: '/systemSettings/serviceEdit',
+        path: "/systemSettings/serviceEdit",
         query: {
-          serviceID: row['serviceID'],
-          runState: row['runState'],
+          serviceID: row["serviceID"],
+          runState: row["runState"],
         },
-      })
-      break
+      });
+      break;
     case 3:
-      changeServiceState(row['serviceID'], row['runState'])
-      break
+      changeServiceState(row["serviceID"], row["runState"]);
+      break;
     case 4:
-      delID = row['serviceID']
-      delDialogShow(row)
-      break
+      delID = row["serviceID"];
+      delDialogShow(row);
+      break;
     default:
-      break
+      break;
   }
-}
+};
 const changeServiceState = async (serviceID: number, runState: string) => {
-  const operate = runState === '运行' ? 'stop' : 'start'
+  const operate = runState === "运行" ? "stop" : "start";
   try {
     const {
       code,
@@ -493,191 +332,191 @@ const changeServiceState = async (serviceID: number, runState: string) => {
     } = await Query({
       id: DATACONTENT_ID.sysServiceNodeList,
       dataContent: [serviceID],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
     if (!listValues.length) {
-      throw new Error('无部署机器')
+      throw new Error("无部署机器");
     }
     Promise.all(
-      listValues.map(node => {
+      listValues.map((node) => {
         request({
           url: `${node.serviceURL}${operate}`,
-          method: 'post',
+          method: "post",
           data: {
             serviceId: serviceID,
           },
-        })
+        });
       })
     )
       .then((results: any) => {
-        if (results.every(result => Number(result.code) === 0)) {
-          ElMessage.success('操作成功')
+        if (results.every((result) => Number(result.code) === 0)) {
+          ElMessage.success("操作成功");
         } else {
-          ElMessage.error('操作失败')
+          ElMessage.error("操作失败");
         }
       })
-      .catch(error => {
-        throw new Error(error)
-      })
+      .catch((error) => {
+        throw new Error(error);
+      });
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 
 // 新增/删除服务-弹窗
-const serviceDialogVisible = ref(false) // 弹窗开关
-const serviceDialogType = ref('') // 弹窗类型是否删除
+const serviceDialogVisible = ref(false); // 弹窗开关
+const serviceDialogType = ref(""); // 弹窗类型是否删除
 const serviceDialogWidth = computed(() =>
-  serviceDialogType.value === 'del' ? '600px' : '878px'
-)
-const delName = ref('') // 删除对象名
-let delID // 删除对象ID
-const msgTitle = ref('') // 服务弹窗-标题
-const delDialogShow = row => {
-  serviceDialogType.value = 'del'
-  msgTitle.value = '删除服务'
-  delName.value = row['serviceName']
-  serviceDialogVisible.value = true
-}
+  serviceDialogType.value === "del" ? "600px" : "878px"
+);
+const delName = ref(""); // 删除对象名
+let delID; // 删除对象ID
+const msgTitle = ref(""); // 服务弹窗-标题
+const delDialogShow = (row) => {
+  serviceDialogType.value = "del";
+  msgTitle.value = "删除服务";
+  delName.value = row["serviceName"];
+  serviceDialogVisible.value = true;
+};
 const delDialogHide = () => {
-  serviceDialogVisible.value = false
-}
+  serviceDialogVisible.value = false;
+};
 const delSubmitHandler = async () => {
   try {
-    await deleteService()
-    delDialogHide()
-    resetTable()
+    await deleteService();
+    delDialogHide();
+    resetTable();
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 const deleteService = async () => {
   try {
     const dataContent = {
       serviceID: delID,
       event: 3,
-    }
+    };
     const { code, message } = await GeneralDataReception({
-      serviceID: SERVICE_ID.sysServiceEdit,
+      serviceId: SERVICE_ID.sysServiceEdit,
       dataContent: JSON.stringify(dataContent),
-    })
+    });
     if (Number(code) === 0) {
-      ElMessage.success(message ?? '成功')
+      ElMessage.success(message ?? "成功");
     } else {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
   } catch (error) {
-    return Promise.reject(error)
+    return Promise.reject(error);
   }
-}
+};
 const addServiceDialogShow = () => {
-  serviceDialogType.value = 'add'
-  msgTitle.value = '新增服务管理'
-  serviceDialogVisible.value = true
-  console.log(queryTemplateIDMap, selectOptionMap)
-}
+  serviceDialogType.value = "add";
+  msgTitle.value = "新增服务管理";
+  serviceDialogVisible.value = true;
+  console.log(queryTemplateIDMap, selectOptionMap);
+};
 const addServiceDialogHide = () => {
-  serviceFormRef.value?.resetFields()
-  serviceDialogVisible.value = false
-}
+  serviceFormRef.value?.resetFields();
+  serviceDialogVisible.value = false;
+};
 // 新增服务-表单
-const serviceFormRef = ref<FormInstance | null>(null)
+const serviceFormRef = ref<FormInstance | null>(null);
 const serviceForm = reactive({
-  serviceName: '',
+  serviceName: "",
   serviceOutputID: null,
   serviceType: null,
   dataSourceID: null,
-  sourceObjectName: '',
-  lifeCycleCol: '',
+  sourceObjectName: "",
+  lifeCycleCol: "",
   isAsynchronous: 1,
   threads: null,
   datatype: null,
-  computingMethod: '',
-  validationExpression: '',
+  computingMethod: "",
+  validationExpression: "",
   startTime: null,
   stopTime: null,
   retryCount: null,
   loopCount: null,
   frequencyCount: null,
   frequencyUnit: null,
-  serviceDescribe: '',
+  serviceDescribe: "",
   logDataSourceID: null,
-  logList: '',
-})
+  logList: "",
+});
 const serviceFormRules = {
   serviceName: [
     {
       required: true,
-      message: '请输入服务名称',
-      trigger: ['change', 'blur'],
+      message: "请输入服务名称",
+      trigger: ["change", "blur"],
     },
   ],
-}
+};
 const serviceSubmitHandler = () => {
-  serviceFormRef.value!.validate(async valid => {
+  serviceFormRef.value!.validate(async (valid) => {
     if (valid) {
       try {
-        await createService()
-        addServiceDialogHide()
-        resetTable()
+        await createService();
+        addServiceDialogHide();
+        resetTable();
       } catch (error) {
-        console.error(error)
+        console.error(error);
       }
     }
-  })
-}
+  });
+};
 const createService = async () => {
   try {
-    Object.keys(serviceForm).forEach(key => {
+    Object.keys(serviceForm).forEach((key) => {
       if (
         ![
-          'sourceObjectName',
-          'lifeCycleCol',
-          'computingMethod',
-          'validationExpression',
-          'logList',
+          "sourceObjectName",
+          "lifeCycleCol",
+          "computingMethod",
+          "validationExpression",
+          "logList",
         ].includes(key) &&
-        serviceForm[key] === ''
+        serviceForm[key] === ""
       ) {
-        serviceForm[key] = null
+        serviceForm[key] = null;
       }
-    })
-    const dataContent = { ...serviceForm, event: 1 }
+    });
+    const dataContent = { ...serviceForm, event: 1 };
     const { code, message } = await GeneralDataReception({
-      serviceID: SERVICE_ID.sysServiceEdit,
+      serviceId: SERVICE_ID.sysServiceEdit,
       dataContent: JSON.stringify(dataContent),
-    })
+    });
     if (Number(code) === 0) {
-      ElMessage.success(message ?? '成功')
+      ElMessage.success(message ?? "成功");
     } else {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
   } catch (error) {
-    return Promise.reject(error)
+    return Promise.reject(error);
   }
-}
+};
 
 // 新增数据来源-弹窗
-const dataSourceDialogVisible = ref(false)
+const dataSourceDialogVisible = ref(false);
 const addDataSourceDialogShow = () => {
-  dataSourceDialogVisible.value = true
-}
+  dataSourceDialogVisible.value = true;
+};
 const dataSourceDialogHide = () => {
-  sourceFormRef.value?.resetFields()
-  dataSourceDialogVisible.value = false
-}
+  sourceFormRef.value?.resetFields();
+  dataSourceDialogVisible.value = false;
+};
 // 新增数据来源-表单
-const sourceFormRef = ref<FormInstance | null>(null)
+const sourceFormRef = ref<FormInstance | null>(null);
 const sourceForm = reactive({
   dataSourceName: null,
   protocolID: null,
   connectConfig: null,
-})
+});
 const dataSourceSubmitHandler = () => {
-  dataSourceDialogHide()
-}
+  dataSourceDialogHide();
+};
 </script>
 <style lang="scss" scoped>
 .app-containers {
@@ -770,7 +609,7 @@ const dataSourceSubmitHandler = () => {
     &::-webkit-inner-spin-button {
       appearance: none;
       -webkit-appearance: none !important;
-      &[type='number'] {
+      &[type="number"] {
         appearance: textfield;
         -moz-appearance: textfield !important;
       }

+ 3 - 3
src/views/systemSettings/serviceManagement/serviceEdit.vue

@@ -279,7 +279,7 @@ import AutoForm from "../components/AutoForm.vue";
 import {
   CommonTableColumn,
   SelectOptionQueryResult,
-  SelectOptionObj,
+  SelectOption,
   CommonData,
 } from "~/common";
 import { ElMessage } from "element-plus";
@@ -289,7 +289,7 @@ const queryTemplateIDMap = reactive<{
   [x: string]: number;
 }>({});
 const selectOptionMap = reactive<{
-  [id: number]: SelectOptionObj[];
+  [id: number]: SelectOption[];
 }>({});
 const getSelectOptionOfColumn = (columns: CommonTableColumn[]) => {
   columns.forEach(async ({ columnName, listqueryTemplateID }) => {
@@ -553,7 +553,7 @@ const outputSubmitHandler = async () => {
         break;
     }
     const { code, message } = await GeneralDataReception({
-      serviceId: DATACONTENT_ID.sysServiceOutTable,
+      serviceId: SERVICE_ID.sysServiceOutputEdit,
       dataContent: JSON.stringify(dataContent),
     });
     if (Number(code) === 0) {

+ 22 - 17
typings/common.d.ts

@@ -1,5 +1,7 @@
 //common type file, you can not export the type in common.d.ts
 //not export can use
+import { Ref } from 'vue'
+
 interface ObjTy {
   [propName: string]: any
 }
@@ -60,41 +62,44 @@ interface CommonTableColumn {
   columnLabel: string
   columnName: string
   dataType: string
-  listqueryTemplateID: number
-  needCount: number
-  needFilters: number
-  needGroup: number
+  listqueryTemplateID: number | null
+  needCount: number | null
+  needFilters: number | null
+  needGroup: number | null
   needSearch: number | null
-  needShow: number
-  needSort: number
+  needShow: number | null
+  needSort: number | null
   orderNumber: number | null
-  queryTemplateColumnSetID: number
-  queryTemplateID: number
+  queryTemplateColumnSetID: number | null
+  queryTemplateID: number | null
   [propName: string]: any
 }
 
-interface SelectOptionObj {
-  k: string
-  setlabel: string
-  setvalue: string
-  v: any
-}
-
 type CommonValue = string | number | null
 interface CommonData {
   [x: string]: CommonValue
 }
 
+interface SelectOption {
+  k: string
+  setlabel: string
+  setvalue: string
+  v: string
+  [x: string]: string
+}
+
 interface CommonQueryResult<T = any> {
   code?: string | number
   returnData: {
     columnSet: CommonTableColumn[]
     listValues: Array<T>
+    submitID?: number
   }
   message?: string
   needPage?: number
-  submitiD?: number
   [propName: string]: any
 }
 
-type SelectOptionQueryResult = CommonQueryResult<SelectOptionObj>
+type SelectOptionQueryResult = CommonQueryResult<SelectOption>
+
+type MaybeRef<T> = Ref<T> | T