Browse Source

Merge branch 'master' of http://120.26.64.82:3000/BFFE/SZYGM1.0

zhaoke 2 years ago
parent
commit
463fe725eb

+ 1 - 0
public/demo.js

@@ -64,6 +64,7 @@ const DATACONTENT_ID = {
   sysServiceWarnId: 18030, //预警报警场景(按照ID)
   sysServiceStrategyId: 18033, //预警报警策略(按照ID)
   sysSourceId: 13, //系统设置-数据源-id
+  sysQueryEditId: 24, //系统设置-查询模板-编辑-根据id获取服务
   sysServiceTopTable: 31, //系统设置-服务管理-服务拓扑-查看日志
   messageQueryTabId: 1803442, //系统设置-消息查询-表格-id
 };

+ 8 - 0
src/router/routes/routes-file-four.ts

@@ -80,6 +80,14 @@ const HomeRoutes = {
       component: () =>
         import("@/views/systemSettings/queryTemplate/queryTemplateAdd.vue"),
     },
+    {
+      path: "/systemSettings/queryTemplateEdit",
+      name: "QueryTemplateEdit",
+      hidden: true,
+      meta: { title: "编辑查询模板", elSvgIcon: "Fold", icon: "table" },
+      component: () =>
+        import("@/views/systemSettings/queryTemplate/queryTemplateEdit.vue"),
+    },
     {
       path: "/systemSettings/queryTemplateColumn",
       name: "QueryTemplateColumn",

+ 6 - 1
src/views/systemSettings/queryTemplate/index.vue

@@ -116,7 +116,12 @@ const resetForm = () => {
 //编辑-删除
 const btnClick = (row, index, param) => {
   if (param === 2) {
-    router.push({ path: "/systemSettings/queryTemplateAdd" });
+    router.push({
+      path: "/systemSettings/queryTemplateEdit",
+      query: {
+        queryTemplateID: index.queryTemplateID,
+      },
+    });
   } else if (param === 3) {
     msgTitle.value = "删除查询模板";
     flag.value = true;

+ 2 - 0
src/views/systemSettings/queryTemplate/queryTemplateAdd.vue

@@ -101,6 +101,8 @@ const serviceList = ref<Array>([]); //下拉
 const ruleForm = reactive({
   queryTemplateName: "",
   queryTemplateDescribe: "",
+  serviceName: "",
+  dataSourceID: "",
   submitID: null,
   queryTemplate: "",
   pageRows: null,

+ 193 - 0
src/views/systemSettings/queryTemplate/queryTemplateEdit.vue

@@ -0,0 +1,193 @@
+<template>
+  <div class="airportInfo scroll-y">
+    <Minheader
+      :is-statuser="true"
+      :is-Preser="true"
+      :is-Measure="true"
+      @preserForm="preserForm"
+    >
+      <template #header>
+        <div class="status flex-wrap">
+          <div class="manageTitle">编辑查询模板</div>
+        </div>
+      </template></Minheader
+    >
+    <div class="app-container">
+      <el-form :model="ruleForm">
+        <el-row :gutter="24">
+          <el-col :span="6">
+            <el-form-item label="查询模板名称" size="default">
+              <el-input
+                v-model="ruleForm.queryTemplateName"
+                placeholder="请输入查询模板名称"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="数据源" prop="dataSourceID" size="default">
+              <el-select
+                v-model="ruleForm.dataSourceID"
+                placeholder="请选择"
+                clearable
+              >
+                <el-option
+                  v-for="item in dataSourceList"
+                  :key="item.dataSourceID"
+                  :label="item.dataSourceName"
+                  :value="item.dataSourceID"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="服务名称" prop="submitID" size="default">
+              <el-select
+                v-model="ruleForm.submitID"
+                placeholder="请选择"
+                clearable
+              >
+                <el-option
+                  v-for="item in serviceList"
+                  :key="item.submitID"
+                  :label="item.serviceName"
+                  :value="item.submitID"
+                />
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="每页显示" prop="pageRows" size="default">
+              <el-input
+                v-model="ruleForm.pageRows"
+                size="medium"
+                placeholder="请输入每页显示行数"
+                type="number"
+                clearable
+              />
+            </el-form-item>
+          </el-col>
+          <el-col>
+            <el-form-item label="查询模板描述" size="default">
+              <el-input
+                v-model="ruleForm.queryTemplateDescribe"
+                placeholder="请输入查询模板描述"
+              />
+            </el-form-item>
+          </el-col>
+          <el-col>
+            <el-form-item label="查询语句" size="default">
+              <el-input
+                :autosize="{ minRows: 24, maxRows: 24 }"
+                type="textarea"
+                v-model="ruleForm.serviceName"
+                placeholder="请输入查询语句"
+              />
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+  </div>
+</template>
+
+<script setup lang="ts">
+import Minheader from "@/components/minheader/index.vue";
+import { Query, myQuery, GeneralDataReception } from "@/api/webApi";
+import { ElMessage } from "element-plus";
+const router = useRouter();
+const route = useRoute();
+const asShOW = ref<boolean>(false);
+const dataSourceList = ref<Array>([]); //下拉
+const serviceList = ref<Array>([]); //下拉
+const queryTemplateID = ref<String>("");
+const ruleForm = reactive({
+  queryTemplateName: "",
+  queryTemplateDescribe: "",
+  serviceName: "",
+  dataSourceID: "",
+  submitID: null,
+  queryTemplate: "",
+  pageRows: null,
+  event: 2,
+}); //内容
+queryTemplateID.value = route.query.queryTemplateID;
+//保存
+const preserForm = async () => {
+  const params = {
+    ...ruleForm,
+    submitID: ruleForm.serviceID,
+  };
+  delete params.serviceID;
+  try {
+    const res = await GeneralDataReception({
+      serviceId: SERVICE_ID.sysQueryTabId,
+      dataContent: JSON.stringify(params),
+    });
+    if (Number(res.code) === 0) {
+      ElMessage.success(`成功`);
+      router.push({ path: "/systemSettings/queryTemplate" });
+      // this.$message.success(res.message ?? "成功");
+      // this.$router.push("/systemSettings/queryTemplate");
+    } else {
+      ElMessage.error(`失败`);
+      // this.$message.error(res.message ?? "失败");
+    }
+  } catch (error) {
+    ElMessage.error(`失败`);
+  }
+  // router.push({ path: "/systemSettings/queryTemplate" });
+};
+const getDataSourceList = async () => {
+  const dataSourceLists = await getSelectOption(13);
+  dataSourceList.value = dataSourceLists.map((item) => {
+    item[item.setlabel] = item.k;
+    item[item.setvalue] = item.v;
+    return item;
+  });
+};
+const getSelectOption = async (ID) => {
+  try {
+    const listValues = await myQuery(ID);
+    return listValues;
+  } catch (error) {
+    // this.$message.error(error)
+    return [];
+  }
+};
+const queryServiceList = async (ID) => {
+  const serviceLists = await getSelectOption(DATACONTENT_ID.sysServiceTabId);
+  serviceList.value = serviceLists.map((item) => {
+    item[item.setlabel] = item.k;
+    item[item.setvalue] = item.v;
+    return item;
+  });
+};
+const queryQueryTemplateByID = async (queryTemplateID) => {
+  try {
+    const templateInfo = await myQuery(
+      DATACONTENT_ID.sysQueryEditId,
+      queryTemplateID.value
+    );
+    Object.entries(templateInfo[0]).forEach(([key, value]) => {
+      ruleForm[key] = value;
+    });
+  } catch (error) {
+    // this.$message.error(error)
+  }
+};
+getDataSourceList();
+queryServiceList();
+queryQueryTemplateByID(queryTemplateID);
+</script>
+
+<style lang="scss" scoped>
+.airportInfo {
+  padding: 24px;
+  height: 100%;
+  background: #ffffff;
+  border-radius: 4px;
+}
+::v-deep .el-form-item__label {
+  width: 110px;
+}
+</style>