chenrui  1 рік тому
батько
коміт
f6ff765554

+ 267 - 271
src/views/systemSettings/serviceManagement/serviceEdit.vue

@@ -64,8 +64,8 @@
               <el-date-picker
                 v-model="serviceForm.hasStartTime"
                 type="datetime"
-                format="yyyy-MM-dd HH:mm"
-                value-format="yyyy-MM-dd HH:mm"
+                format="YYYY-MM-DD HH:mm"
+                value-format="YYYY-MM-DD HH:mm"
                 placeholder="请选择启动时间"
               />
             </el-form-item>
@@ -75,8 +75,8 @@
               <el-date-picker
                 v-model="serviceForm.hasEndTime"
                 type="datetime"
-                format="yyyy-MM-dd HH:mm"
-                value-format="yyyy-MM-dd HH:mm"
+                format="YYYY-MM-DD HH:mm"
+                value-format="YYYY-MM-DD HH:mm"
                 placeholder="请选择停止时间"
               />
             </el-form-item>
@@ -161,8 +161,8 @@
               <el-date-picker
                 v-model="serviceForm.startTime"
                 type="datetime"
-                format="yyyy-MM-dd HH:mm"
-                value-format="yyyy-MM-dd HH:mm"
+                format="YYYY-MM-DD HH:mm"
+                value-format="YYYY-MM-DD HH:mm"
                 placeholder="请选择启动时间"
               />
             </el-form-item>
@@ -172,8 +172,8 @@
               <el-date-picker
                 v-model="serviceForm.stopTime"
                 type="datetime"
-                format="yyyy-MM-dd HH:mm"
-                value-format="yyyy-MM-dd HH:mm"
+                format="YYYY-MM-DD HH:mm"
+                value-format="YYYY-MM-DD HH:mm"
                 placeholder="请选择停止时间"
               />
             </el-form-item>
@@ -561,52 +561,48 @@
 </template>
 
 <script setup lang="ts">
-import Minheader from '@/components/minheader/index.vue'
-import DataTable from '@/components/tableTemp/index.vue'
-import Dialog from '@/components/dialog/index.vue'
-import AutoForm from '../components/AutoForm.vue'
+import Minheader from "@/components/minheader/index.vue";
+import DataTable from "@/components/tableTemp/index.vue";
+import Dialog from "@/components/dialog/index.vue";
+import AutoForm from "../components/AutoForm.vue";
 import {
   CommonTableColumn,
   SelectOptionQueryResult,
   SelectOption,
   CommonData,
-} from '~/common'
-import { ElMessage } from 'element-plus'
-import { Query, GeneralDataReception } from '@/api/webApi'
+} from "~/common";
+import { ElMessage } from "element-plus";
+import { Query, GeneralDataReception } from "@/api/webApi";
 
 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 {
-      code,
-      returnData,
-      message,
-    }: SelectOptionQueryResult = await Query({
+    const { code, returnData, message }: SelectOptionQueryResult = await Query({
       id,
       dataContent: [],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
-    const listValues = returnData.listValues || returnData
+    const listValues = returnData.listValues || returnData;
     const options = listValues.map(({ k, v, setlabel, setvalue }) => ({
       k,
       v,
@@ -614,32 +610,32 @@ const getSelectOptions = async (id: number) => {
       setvalue,
       [setlabel]: k,
       [setvalue]: v,
-    }))
-    return options
+    }));
+    return options;
   } catch (error) {
-    console.error(error)
-    return []
+    console.error(error);
+    return [];
   }
-}
+};
 
-const route = useRoute()
-const serviceID = Number(route.query.serviceID)
+const route = useRoute();
+const serviceID = Number(route.query.serviceID);
 const serviceState = computed(() =>
-  route.query.runState === '运行' ? '进行中' : '停止'
-) //状态
+  route.query.runState === "运行" ? "进行中" : "停止"
+); //状态
 const serviceForm = reactive({
-  serviceName: '',
+  serviceName: "",
   serviceOutputID: null,
   serviceType: null,
-  sourceObjectName: '',
-  lifeCycleCol: '',
-  serviceDescribe: '',
+  sourceObjectName: "",
+  lifeCycleCol: "",
+  serviceDescribe: "",
   threads: null,
   isAsynchronous: 1,
   datatype: null,
   dataSourceID: null,
-  computingMethod: '',
-  validationExpression: '',
+  computingMethod: "",
+  validationExpression: "",
   startTime: null,
   stopTime: null,
   retryCount: null,
@@ -647,12 +643,12 @@ const serviceForm = reactive({
   frequencyCount: null,
   frequencyUnit: null,
   logDataSourceID: null,
-  logList: '',
+  logList: "",
   logDataSourceName: null,
   dataSourceName: null,
   hasStartTime: null,
   hasEndTime: null,
-})
+});
 const getServiceDetail = async () => {
   try {
     const {
@@ -662,64 +658,64 @@ const getServiceDetail = async () => {
     } = await Query({
       id: DATACONTENT_ID.sysServiceDetail,
       dataContent: [serviceID],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
     if (!listValues.length) {
-      throw new Error('未查询到服务信息')
+      throw new Error("未查询到服务信息");
     }
     Object.entries(listValues[0]).forEach(([key, value]) => {
-      serviceForm[key] = value
-    })
+      serviceForm[key] = value;
+    });
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 onMounted(() => {
-  getServiceDetail()
-})
+  getServiceDetail();
+});
 const serviceSubmitHandler = async () => {
   try {
     const dataContent = {
       serviceID,
       ...serviceForm,
       event: 2,
-    }
-    Object.keys(dataContent).forEach(key => {
+    };
+    Object.keys(dataContent).forEach((key) => {
       if (
         ![
-          'serviceName',
-          'sourceObjectName',
-          'lifeCycleCol',
-          'serviceDescribe',
-          'computingMethod',
-          'validationExpression',
-          'logList',
+          "serviceName",
+          "sourceObjectName",
+          "lifeCycleCol",
+          "serviceDescribe",
+          "computingMethod",
+          "validationExpression",
+          "logList",
         ].includes(key) &&
-        dataContent[key] === ''
+        dataContent[key] === ""
       ) {
-        dataContent[key] = null
+        dataContent[key] = null;
       }
-    })
+    });
     const { code, message } = await GeneralDataReception({
       serviceId: SERVICE_ID.sysServiceEdit,
       dataContent: JSON.stringify(dataContent),
-      btnAuth: 'service_editor_button',
-    })
+      btnAuth: "service_editor_button",
+    });
     if (Number(code) === 0) {
-      ElMessage.success(message ?? '成功')
+      ElMessage.success(message ?? "成功");
     } else {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 
 // 输出-表格
-const outputTableColumns = ref<CommonTableColumn[]>([])
-const outputTableData = ref<CommonData[]>([])
+const outputTableColumns = ref<CommonTableColumn[]>([]);
+const outputTableData = ref<CommonData[]>([]);
 const getOutputTable = async () => {
   try {
     const {
@@ -729,34 +725,34 @@ const getOutputTable = async () => {
     } = await Query({
       id: DATACONTENT_ID.sysServiceOutTable,
       dataContent: [serviceID],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
-    getSelectOptionOfColumn(columnSet)
-    outputTableColumns.value = columnSet
-    outputTableData.value = listValues
+    getSelectOptionOfColumn(columnSet);
+    outputTableColumns.value = columnSet;
+    outputTableData.value = listValues;
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 onMounted(() => {
-  getOutputTable()
-})
+  getOutputTable();
+});
 const outputTableButtonGroup = [
   {
-    name: '编辑',
-    className: 'editBtn',
+    name: "编辑",
+    className: "editBtn",
     param: 1,
-    is: 'service_edit_output_location_button',
+    is: "service_edit_output_location_button",
   },
   {
-    name: '删除',
-    className: 'delBtn',
+    name: "删除",
+    className: "delBtn",
     param: 2,
-    is: 'service_delete_output_location_button',
+    is: "service_delete_output_location_button",
   },
-]
+];
 const outputTableButtonClickHandler = (
   rowIndex: number,
   row: CommonData,
@@ -764,193 +760,193 @@ const outputTableButtonClickHandler = (
 ) => {
   switch (param) {
     case 1:
-      outputDialogShow(2, row)
-      break
+      outputDialogShow(2, row);
+      break;
     case 2:
-      outputDialogShow(3, row)
-      break
+      outputDialogShow(3, row);
+      break;
     default:
-      break
+      break;
   }
-}
+};
 
 // 输出-新增/编辑
-const outputDialogVisible = ref(false)
-const outputDialogType = ref('')
-const outputDialogTitle = ref('')
-const serviceOutputID = ref<string | number>()
+const outputDialogVisible = ref(false);
+const outputDialogType = ref("");
+const outputDialogTitle = ref("");
+const serviceOutputID = ref<string | number>();
 const outputDialogShow = (operate: number = 1, row: CommonData) => {
   switch (operate) {
     case 1:
-      outputDialogType.value = 'add'
-      outputDialogTitle.value = '新增输出'
-      break
+      outputDialogType.value = "add";
+      outputDialogTitle.value = "新增输出";
+      break;
     case 2:
-      outputDialogType.value = 'edit'
-      outputDialogTitle.value = '编辑输出'
+      outputDialogType.value = "edit";
+      outputDialogTitle.value = "编辑输出";
       Object.entries(row).forEach(([key, value]) => {
-        outputForm[key] = value
+        outputForm[key] = value;
         const column = outputTableColumns.value.find(
-          column => column.columnName === key
-        )
-        if (typeof column?.listqueryTemplateID === 'number') {
-          const selectOptions = selectOptionMap[column.listqueryTemplateID]
-          const option = selectOptions.find(option => option.k === value)
+          (column) => column.columnName === key
+        );
+        if (typeof column?.listqueryTemplateID === "number") {
+          const selectOptions = selectOptionMap[column.listqueryTemplateID];
+          const option = selectOptions.find((option) => option.k === value);
           if (option) {
-            outputForm[option.setvalue] = option.v
+            outputForm[option.setvalue] = option.v;
           }
         }
-      })
-      break
+      });
+      break;
     case 3:
-      outputDialogType.value = 'del'
-      outputDialogTitle.value = '删除输出'
-      break
+      outputDialogType.value = "del";
+      outputDialogTitle.value = "删除输出";
+      break;
     default:
-      break
+      break;
   }
-  serviceOutputID.value = (row && row['serviceOutputID']) ?? ''
-  outputDialogVisible.value = true
-}
+  serviceOutputID.value = (row && row["serviceOutputID"]) ?? "";
+  outputDialogVisible.value = true;
+};
 const outputDialogHide = () => {
-  outputDialogVisible.value = false
-  Object.keys(outputForm).forEach(key => {
-    outputForm[key] = null
-  })
-}
-const outputForm = reactive<CommonData>({})
+  outputDialogVisible.value = false;
+  Object.keys(outputForm).forEach((key) => {
+    outputForm[key] = null;
+  });
+};
+const outputForm = reactive<CommonData>({});
 const outputSubmitHandler = async () => {
   try {
     const dataContent = {
       serviceID,
-    }
+    };
     switch (outputDialogType.value) {
-      case 'add':
+      case "add":
         Object.assign(dataContent, {
           event: 1,
           ...outputForm,
-        })
-        break
-      case 'edit':
+        });
+        break;
+      case "edit":
         Object.assign(dataContent, {
           event: 2,
           serviceOutputID: serviceOutputID.value,
           ...outputForm,
-        })
-        break
-      case 'delete':
+        });
+        break;
+      case "delete":
         Object.assign(dataContent, {
           event: 3,
           serviceOutputID: serviceOutputID.value,
-        })
-        break
+        });
+        break;
       default:
-        break
+        break;
     }
     const { code, message } = await GeneralDataReception({
       serviceId: SERVICE_ID.sysServiceOutputEdit,
       dataContent: JSON.stringify(dataContent),
-    })
+    });
     if (Number(code) === 0) {
-      ElMessage.success(message ?? '成功')
-      outputDialogHide()
+      ElMessage.success(message ?? "成功");
+      outputDialogHide();
     } else {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 
 // 日志弹框
-const logDialogVisible = ref(false)
+const logDialogVisible = ref(false);
 const logDialogShow = () => {
-  logDialogVisible.value = true
-  getToday()
-  getLogTableData()
-}
+  logDialogVisible.value = true;
+  getToday();
+  getLogTableData();
+};
 const logDialogHide = () => {
-  logDialogVisible.value = false
-}
-const logStartTime = ref('')
-const logEndTime = ref('')
+  logDialogVisible.value = false;
+};
+const logStartTime = ref("");
+const logEndTime = ref("");
 const getToday = () => {
   function numberFormat(number) {
-    const string = '0' + number
-    return string.slice(-2)
+    const string = "0" + number;
+    return string.slice(-2);
   }
-  const now = new Date()
-  const year = now.getFullYear()
-  const month = now.getMonth() + 1
-  const date = now.getDate()
-  const today = `${year}-${numberFormat(month)}-${numberFormat(date)}`
-  logStartTime.value = `${today} 00:00:00`
-  logEndTime.value = `${today} 23:59:59`
-}
+  const now = new Date();
+  const year = now.getFullYear();
+  const month = now.getMonth() + 1;
+  const date = now.getDate();
+  const today = `${year}-${numberFormat(month)}-${numberFormat(date)}`;
+  logStartTime.value = `${today} 00:00:00`;
+  logEndTime.value = `${today} 23:59:59`;
+};
 const logTimeChangeHandler = () => {
   if (!logStartTime.value || !logEndTime.value) {
-    return
+    return;
   }
-  const startTime = new Date(logStartTime.value).getTime()
-  const endTime = new Date(logEndTime.value).getTime()
+  const startTime = new Date(logStartTime.value).getTime();
+  const endTime = new Date(logEndTime.value).getTime();
   if (startTime > endTime) {
-    ElMessage.error('开始时间不能大于结束时间')
-    logEndTime.value = ''
-    return
+    ElMessage.error("开始时间不能大于结束时间");
+    logEndTime.value = "";
+    return;
   }
   if (startTime < endTime - (3 * 24 * 60 * 60 - 1) * 1000) {
-    ElMessage.error('间隔时间不能大于三天')
-    logEndTime.value = ''
-    return
+    ElMessage.error("间隔时间不能大于三天");
+    logEndTime.value = "";
+    return;
   }
-  resetLogTable()
-  getLogTableData()
-}
-const logSearchText = ref('')
+  resetLogTable();
+  getLogTableData();
+};
+const logSearchText = ref("");
 const logSearchHandler = () => {
-  getLogTableData()
-}
+  getLogTableData();
+};
 const logSearchClearHandler = () => {
-  getLogTableData()
-}
+  getLogTableData();
+};
 
-const logTableData = ref<CommonData[]>([])
-const logTableLoading = ref(false)
+const logTableData = ref<CommonData[]>([]);
+const logTableLoading = ref(false);
 const resetLogTable = () => {
-  logTableData.value = []
-}
+  logTableData.value = [];
+};
 const getLogTableData = async () => {
   try {
-    logTableLoading.value = true
+    logTableLoading.value = true;
     const {
       code,
       returnData: { listValues },
     } = await Query({
       id: DATACONTENT_ID.sysServiceTopologyTable,
       dataContent: [serviceID, logStartTime.value, logEndTime.value],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error('获取数据失败')
+      throw new Error("获取数据失败");
     }
-    logTableData.value = listValues
-    logTableLoading.value = false
+    logTableData.value = listValues;
+    logTableLoading.value = false;
   } catch (error) {
-    console.error(error)
-    logTableLoading.value = false
+    console.error(error);
+    logTableLoading.value = false;
   }
-}
+};
 
 // 选择插槽
-const slotDialogVisible = ref(false)
+const slotDialogVisible = ref(false);
 const slotDialogShow = () => {
-  getSlotTable()
-  slotDialogVisible.value = true
-}
+  getSlotTable();
+  slotDialogVisible.value = true;
+};
 const slotDialogHide = () => {
-  slotDialogVisible.value = false
-}
-const slotTableColumns = ref<CommonTableColumn[]>([])
-const slotTableData = ref<CommonData[]>([])
+  slotDialogVisible.value = false;
+};
+const slotTableColumns = ref<CommonTableColumn[]>([]);
+const slotTableData = ref<CommonData[]>([]);
 const getSlotTable = async () => {
   try {
     const {
@@ -960,31 +956,31 @@ const getSlotTable = async () => {
     } = await Query({
       id: DATACONTENT_ID.sysServiceNodeList,
       dataContent: [serviceID],
-    })
+    });
     if (Number(code) !== 0) {
-      throw new Error(message ?? '失败')
+      throw new Error(message ?? "失败");
     }
-    getSelectOptionOfColumn(columnSet)
-    slotTableColumns.value = columnSet
-    slotTableData.value = listValues
+    getSelectOptionOfColumn(columnSet);
+    slotTableColumns.value = columnSet;
+    slotTableData.value = listValues;
   } catch (error) {
-    console.error(error)
+    console.error(error);
   }
-}
+};
 const slotTableButtonGroups = [
   {
-    name: '编辑',
-    className: 'editBtn',
+    name: "编辑",
+    className: "editBtn",
     param: 1,
-    is: 'machine_editing_button'
+    is: "machine_editing_button",
   },
   {
-    name: '删除',
-    className: 'delBtn',
+    name: "删除",
+    className: "delBtn",
     param: 2,
-    is: 'machine_deletion_button'
+    is: "machine_deletion_button",
   },
-]
+];
 const slotTableButtonClickHandler = (
   rowIndex: number,
   row: CommonData,
@@ -992,92 +988,92 @@ const slotTableButtonClickHandler = (
 ) => {
   switch (param) {
     case 1:
-      editSlotDialogShow(2, row)
-      break
+      editSlotDialogShow(2, row);
+      break;
     case 2:
-      editSlotDialogShow(3, row)
-      break
+      editSlotDialogShow(3, row);
+      break;
     default:
-      break
+      break;
   }
-}
+};
 const slotSelectHandler = (selection, row) => {
-  console.log(selection, row)
-}
+  console.log(selection, row);
+};
 const slotSubmitHandler = () => {
-  slotDialogHide()
-}
+  slotDialogHide();
+};
 
 // 插槽-新增/编辑
-const editSlotDialogType = ref('')
-const editSlotDialogTitle = ref('')
-const deployNodeName = ref('')
-const editSlotDialogVisible = ref(false)
+const editSlotDialogType = ref("");
+const editSlotDialogTitle = ref("");
+const deployNodeName = ref("");
+const editSlotDialogVisible = ref(false);
 const editSlotDialogShow = (operate: number = 1, row: CommonData) => {
   switch (operate) {
     case 1:
-      editSlotDialogType.value = 'add'
-      editSlotDialogTitle.value = '新增插槽'
-      break
+      editSlotDialogType.value = "add";
+      editSlotDialogTitle.value = "新增插槽";
+      break;
     case 2:
-      editSlotDialogType.value = 'edit'
-      editSlotDialogTitle.value = '编辑插槽'
+      editSlotDialogType.value = "edit";
+      editSlotDialogTitle.value = "编辑插槽";
       Object.entries(row).forEach(([key, value]) => {
-        slotForm[key] = value
+        slotForm[key] = value;
         const column = slotTableColumns.value.find(
-          column => column.columnName === key
-        )
-        if (typeof column?.listqueryTemplateID === 'number') {
-          const selectOptions = selectOptionMap[column.listqueryTemplateID]
-          const option = selectOptions.find(option => option.k === value)
+          (column) => column.columnName === key
+        );
+        if (typeof column?.listqueryTemplateID === "number") {
+          const selectOptions = selectOptionMap[column.listqueryTemplateID];
+          const option = selectOptions.find((option) => option.k === value);
           if (option) {
-            slotForm[option.setvalue] = option.v
+            slotForm[option.setvalue] = option.v;
           }
         }
-      })
-      break
+      });
+      break;
     case 3:
-      editSlotDialogType.value = 'del'
-      editSlotDialogTitle.value = '删除插槽'
-      break
+      editSlotDialogType.value = "del";
+      editSlotDialogTitle.value = "删除插槽";
+      break;
     default:
-      break
+      break;
   }
-  deployNodeName.value = (row && (row['deployNodeName'] as string)) ?? ''
-  editSlotDialogVisible.value = true
-}
+  deployNodeName.value = (row && (row["deployNodeName"] as string)) ?? "";
+  editSlotDialogVisible.value = true;
+};
 const editSlotDialogHide = () => {
-  editSlotDialogVisible.value = false
-  Object.keys(slotForm).forEach(key => {
-    slotForm[key] = null
-  })
-}
-const slotForm = reactive<CommonData>({})
+  editSlotDialogVisible.value = false;
+  Object.keys(slotForm).forEach((key) => {
+    slotForm[key] = null;
+  });
+};
+const slotForm = reactive<CommonData>({});
 const editSlotSubmitHandler = () => {
-  editSlotDialogHide()
-}
+  editSlotDialogHide();
+};
 
 //复制
-const logCopy = index => {
-  const ele = document.getElementById('logId' + index)
-  const val = ele!.innerText
+const logCopy = (index) => {
+  const ele = document.getElementById("logId" + index);
+  const val = ele!.innerText;
   try {
-    const input = document.createElement('input')
+    const input = document.createElement("input");
     //将input的值设置为需要复制的内容
-    input.value = val
+    input.value = val;
     //添加input标签
-    document.body.appendChild(input)
+    document.body.appendChild(input);
     //选中input标签
-    input.select()
+    input.select();
     //执行复制
-    document.execCommand('copy')
+    document.execCommand("copy");
     //移除input标签
-    document.body.removeChild(input)
+    document.body.removeChild(input);
     // this.$message.success("复制成功");
   } catch (e) {
     // this.$message.error("复制失败");
   }
-}
+};
 </script>
 
 <style lang="scss" scoped>

+ 4 - 1
src/views/systemSettings/sourceTube/index.vue

@@ -51,7 +51,7 @@
                 <el-form-item label="协议名称" size="default">
                   <el-select
                     style="width: 100%"
-                    v-model="tableForm.protocolName"
+                    v-model="tableForm.protocolID"
                     class="input-shadow"
                     filterable
                     default-first-option
@@ -173,6 +173,9 @@ const resetForm = () => {
 // };
 //编辑-删除
 const btnClick = (row, index, param) => {
+  if (param === 1) {
+    debugger;
+  }
   if (param === 2) {
     msgTitle.value = "编辑数据源";
     flag.value = true;