chenrui  2 жил өмнө
parent
commit
b4426ff6ea

+ 23 - 6
src/api/webApi.ts

@@ -1,10 +1,27 @@
-import request from '@/utils/axiosReq2'
-import { ObjTy } from '~/common'
+import request from "@/utils/axiosReq2";
+import { ObjTy } from "~/common";
 
 export function Query(params) {
   return request({
-    url: '/openApi/query',
-    method: 'post',
-    data: params
-  })
+    url: "/openApi/query",
+    method: "post",
+    data: params,
+  });
+}
+
+export async function myQuery(id, ...dataContent) {
+  const params = {
+    id,
+    dataContent,
+  };
+  try {
+    const result = await Query(params);
+    if (Number(result.code) === 0) {
+      return result.returnData.listValues;
+    } else {
+      return Promise.reject(result.message);
+    }
+  } catch (error) {
+    return Promise.reject(error);
+  }
 }

+ 11 - 20
src/views/systemSettings/queryTemplate/index.vue

@@ -10,7 +10,7 @@
       >
       <div class="app-containers">
         <DataTable
-          :tableHeader="state.list"
+          :tableHeader="tableCols"
           :tableData="tableData"
           :tableBtnGroup="tableBtnGroup"
           :tableProperty="{ rowKey: 'ID' }"
@@ -24,7 +24,7 @@
 import DataTable from "@/components/tableTemp/index.vue";
 import Minheader from "@/components/minheader/index.vue";
 import Dialog from "@/components/dialog/index.vue";
-import { Query } from "@/api/dataIntegration";
+import { Query } from "@/api/webApi";
 const router = useRouter();
 const dataId = ref<String>("4"); //请求id
 const page = ref<number>(0); //分页参数
@@ -47,23 +47,7 @@ const tableForm = reactive({
   text: "",
 }); //弹窗内容
 //列表
-const tableData = ref([
-  {
-    name: "测试",
-    china: "测试",
-    englin: "测试",
-  },
-  {
-    name: "测试",
-    china: "测试",
-    englin: "测试",
-  },
-  {
-    name: "测试",
-    china: "测试",
-    englin: "测试",
-  },
-]);
+const tableData = ref([]);
 //表头
 const state = reactive({
   list: [
@@ -143,7 +127,7 @@ const getQuery = async () => {
       needPage: ++page.value,
       dataContent: Object.values(dataContent.value),
     });
-    if (code == 0) {
+    if (code === "0") {
       if (returnData.listValues.length === 0) {
         page.value--;
         noMore.value = true;
@@ -156,6 +140,13 @@ const getQuery = async () => {
       }
       tableData.value.push(...returnData.listValues);
       tableCols.value = returnData.columnSet;
+      tableCols.value.forEach((element) => {
+        element.label = element.columnLabel;
+        element.key = element.columnName;
+        // if (element.columnName === "queryTemplate") {
+        //   element.width = "300px";
+        // }
+      });
       serviceId.value = returnData.submitID;
     } else {
       page.value--;

+ 69 - 13
src/views/systemSettings/queryTemplate/queryTemplateAdd.vue

@@ -18,13 +18,27 @@
           <el-col :span="5">
             <el-form-item label="查询模板名称" size="default">
               <el-input
-                v-model="tableForm.name"
+                v-model="tableForm.queryTemplateName"
                 placeholder="请输入查询模板名称"
               />
             </el-form-item>
           </el-col>
           <el-col :span="5">
-            <el-form-item label="查询协议" size="default">
+            <el-form-item label="数据源" prop="dataSourceID" size="default">
+              <el-select
+                v-model="tableForm.dataSourceID"
+                placeholder="请选择"
+                clearable
+              >
+                <el-option
+                  v-for="item in tableOptionser"
+                  :key="item.v"
+                  :label="item.k"
+                  :value="item.v"
+                />
+              </el-select>
+            </el-form-item>
+            <!-- <el-form-item label="查询协议" size="default">
               <el-select
                 style="width: 100%"
                 v-model="tableForm.china"
@@ -42,12 +56,12 @@
                 >
                 </el-option>
               </el-select>
-            </el-form-item>
+            </el-form-item> -->
           </el-col>
           <el-col :span="14">
             <el-form-item label="查询模板描述" size="default">
               <el-input
-                v-model="tableForm.englin"
+                v-model="tableForm.queryTemplateDescribe"
                 placeholder="请输入查询模板描述"
               />
             </el-form-item>
@@ -67,7 +81,7 @@
               <el-input
                 :autosize="{ minRows: 24, maxRows: 24 }"
                 type="textarea"
-                v-model="tableForm.three"
+                v-model="tableForm.serviceName"
                 placeholder="请输入查询语句"
               />
             </el-form-item>
@@ -80,20 +94,62 @@
 
 <script setup lang="ts">
 import Minheader from "@/components/minheader/index.vue";
+import { Query, myQuery } from "@/api/webApi";
 const router = useRouter();
 const tableOptionser = ref<Array>([]); //下拉
 const tableForm = reactive({
-  name: "",
-  china: "",
-  englin: "",
-  two: "",
-  three: "",
-  text: "",
+  queryTemplateName: "",
+  queryTemplateDescribe: "",
+  submitID: null,
+  queryTemplate: "",
+  pageRows: null,
+  serviceName: "",
+  dataSourceID: "",
 }); //内容
 //保存
-const preserForm = () => {
-  router.push({ path: "/systemSettings/queryTemplate" });
+const preserForm = async () => {
+  const params = {
+    ...tableForm,
+    submitID: tableForm.serviceID,
+  };
+  delete params.serviceID;
+  try {
+    const res = await Query({
+      serviceId: "5",
+      dataContent: JSON.stringify(params),
+    });
+    if (Number(res.code) === 0) {
+      // this.$message.success(res.message ?? "成功");
+      // this.$router.push("/systemSettings/queryTemplate");
+    } else {
+      // this.$message.error(res.message ?? "失败");
+    }
+  } catch (error) {
+    // this.$message.error("失败");
+  }
+  // router.push({ path: "/systemSettings/queryTemplate" });
+};
+const getDataSourceList = async () => {
+  const tableOptionser = await getSelectOption(13);
+  tableOptionser.value = tableOptionser.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 [];
+  }
+};
+
+onMounted(() => {
+  getDataSourceList();
+});
 </script>
 
 <style lang="scss" scoped>