From 83e708d36a3f1c294170da571c99586729bd0493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E7=AC=99=E6=AD=8C?= <2277317060@qq.com> Date: Fri, 29 Aug 2025 11:08:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=A5=E8=A1=A8=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.ts | 4 +- src/views/boardGenerate/api/dataSource.js | 7 ++ src/views/boardGenerate/dataSourceList.vue | 104 ++++++++++++------ src/views/boardGenerate/index1.vue | 3 +- .../nodes/data/customDataNode.vue | 37 ++++++- src/views/boardGenerate/view.vue | 13 ++- 6 files changed, 124 insertions(+), 44 deletions(-) diff --git a/src/utils/request.ts b/src/utils/request.ts index 5e10619..1b4fff0 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -174,10 +174,10 @@ service.interceptors.response.use( } return Promise.reject('无效的会话,或者会话已过期,请重新登录。'); } else if (code === HttpStatus.SERVER_ERROR) { - ElMessage({ message: msg, type: 'error' }); + // ElMessage({ message: msg, type: 'error' }); return Promise.reject(new Error(msg)); } else if (code === HttpStatus.WARN) { - ElMessage({ message: msg, type: 'warning' }); + // ElMessage({ message: msg, type: 'warning' }); return Promise.reject(new Error(msg)); } else if (code !== HttpStatus.SUCCESS) { ElNotification.error({ title: msg }); diff --git a/src/views/boardGenerate/api/dataSource.js b/src/views/boardGenerate/api/dataSource.js index b431546..ee83419 100644 --- a/src/views/boardGenerate/api/dataSource.js +++ b/src/views/boardGenerate/api/dataSource.js @@ -35,3 +35,10 @@ export const querySql = (data, db) => { url: '/system/databaseLink/querySql/' + db, method: 'post', data, headers: { bodyType: 'raw' } }); }; + +// 测试sql连接 +export const querySql1 = (data, db) => { + return request({ + url: '/system/databaseLink/queryPageSql', method: 'post', data + }); +}; diff --git a/src/views/boardGenerate/dataSourceList.vue b/src/views/boardGenerate/dataSourceList.vue index 94c09a7..238cabf 100644 --- a/src/views/boardGenerate/dataSourceList.vue +++ b/src/views/boardGenerate/dataSourceList.vue @@ -170,6 +170,9 @@ /> + + + { requestUrl: 'system/databaseLink/querySql', requestMethod: 'querySql', fieldOne: addSQLForm.value.db, - fieldTwo: addSQLForm.value.SQL + fieldTwo: addSQLForm.value.SQL, + fieldThree: addSQLForm.value.isPage }; if (addSQLForm.value.dataSourceId) { @@ -412,7 +423,8 @@ const editDataSource = (e) => { addSQLForm.value = { ...e, db: parseFloat(e.fieldOne), - SQL: e.fieldTwo + SQL: e.fieldTwo, + isPage: e.fieldThree === 'true' }; getDbList(); @@ -543,51 +555,73 @@ const findTier = () => { }; const sqlFindTier = () => { addSQLForm.value.designDataFieldList = []; - - querySql(addSQLForm.value.SQL, addSQLForm.value.db).then((res) => { - let data = res; - if (data?.data) { - Object.keys(data.data?.[0]).forEach(key => { + if (addSQLForm.value.isPage) { + querySql1({ sql: addSQLForm.value.SQL, linkId: addSQLForm.value.db, pageSize: 10, pageNum: 1 }).then((res) => { + let data = res.data || {}; + Object.keys(data.rows?.[0]).forEach(key => { addSQLForm.value.designDataFieldList.push({ fieldOne: key, remark: comparisonTable[key], - fieldTwo: `data,map%${key}` + fieldTwo: `data,rows,map%${key}` }); }); addSQLForm.value.designDataFieldList.push({ fieldOne: 'data', remark: '', - fieldTwo: `data` - }); - } else if (data?.rows) { - console.log(data?.rows); - Object.keys(data.rows?.[0]).forEach(key => { - addSQLForm.value.designDataFieldList.push({ - fieldOne: key, - remark: comparisonTable[key], - fieldTwo: `rows,map%${key}` - }); + fieldTwo: `data,rows` }); addSQLForm.value.designDataFieldList.push({ - fieldOne: 'rows', + fieldOne: 'total', remark: '', - fieldTwo: `rows` + fieldTwo: `data,total` }); - } else { - let exclude = ['code']; - Object.keys(data).forEach(key => { - if (!exclude.includes(key.toLowerCase())) { - if (typeof data[key] === 'string' || typeof data[key] === 'string') { - addSQLForm.value.designDataFieldList.push({ - fieldOne: key, - remark: comparisonTable[key], - fieldTwo: `${key}` - }); + }); + } else { + querySql(addSQLForm.value.SQL, addSQLForm.value.db).then((res) => { + let data = res; + if (data?.data) { + Object.keys(data.data?.[0]).forEach(key => { + addSQLForm.value.designDataFieldList.push({ + fieldOne: key, + remark: comparisonTable[key], + fieldTwo: `data,map%${key}` + }); + }); + addSQLForm.value.designDataFieldList.push({ + fieldOne: 'data', + remark: '', + fieldTwo: `data` + }); + } else if (data?.rows) { + Object.keys(data.rows?.[0]).forEach(key => { + addSQLForm.value.designDataFieldList.push({ + fieldOne: key, + remark: comparisonTable[key], + fieldTwo: `rows,map%${key}` + }); + }); + addSQLForm.value.designDataFieldList.push({ + fieldOne: 'rows', + remark: '', + fieldTwo: `rows` + }); + } else { + let exclude = ['code']; + Object.keys(data).forEach(key => { + if (!exclude.includes(key.toLowerCase())) { + if (typeof data[key] === 'string' || typeof data[key] === 'string') { + addSQLForm.value.designDataFieldList.push({ + fieldOne: key, + remark: comparisonTable[key], + fieldTwo: `${key}` + }); + } } - } - }); - } - }); + }); + } + }); + } + }; onMounted(async () => { diff --git a/src/views/boardGenerate/index1.vue b/src/views/boardGenerate/index1.vue index 70987c5..cc239a7 100644 --- a/src/views/boardGenerate/index1.vue +++ b/src/views/boardGenerate/index1.vue @@ -1623,7 +1623,8 @@ onMounted(async () => { outputData: e.designDataFieldList, type: e.responseType, db: e.fieldOne, - SQL: e.fieldTwo + SQL: e.fieldTwo, + isPage: e.fieldThree === 'true' }; }); }) diff --git a/src/views/boardGenerate/nodes/data/customDataNode.vue b/src/views/boardGenerate/nodes/data/customDataNode.vue index b99c29e..55323a3 100644 --- a/src/views/boardGenerate/nodes/data/customDataNode.vue +++ b/src/views/boardGenerate/nodes/data/customDataNode.vue @@ -25,7 +25,7 @@ import { Handle, Position } from '@vue-flow/core'; import request from '@/utils/request'; import axios from 'axios'; import { options } from '../../tool.js'; -import { querySql } from '@/views/boardGenerate/api/dataSource.js'; +import { querySql, querySql1 } from '@/views/boardGenerate/api/dataSource.js'; const isErr = ref(false); const props = defineProps({ @@ -129,9 +129,42 @@ const getOutputData = () => { }); } if (props.data.customData.type === '2') { + if (props.data.customData.isPage) { + + querySql1({ + sql: formulaFun(props.data.customData.SQL), + linkId: props.data.customData.db, + pageSize: props.inputData.pageSize, + pageNum: props.inputData.pageNum + }).then((res) => { + isErr.value = false; + let data = res; + let output = {}; + console.log(output); + console.log(props.data.customData.outputData); + props.data.customData.outputData.forEach(item => { + output[item.fieldOne] = parseData(data, item.fieldTwo); + }); + props.data.outputData = output; + console.log(output); + }).catch(e => { + isErr.value = true; + }); + } else { + querySql(formulaFun(props.data.customData.SQL), props.data.customData.db).then((res) => { + isErr.value = false; + let data = res; + let output = {}; + props.data.customData.outputData.forEach(item => { + output[item.fieldOne] = parseData(data, item.fieldTwo); + }); + props.data.outputData = output; + }).catch(e => { + isErr.value = true; + }); + } querySql(formulaFun(props.data.customData.SQL), props.data.customData.db).then((res) => { - console.log(res); isErr.value = false; let data = res; let output = {}; diff --git a/src/views/boardGenerate/view.vue b/src/views/boardGenerate/view.vue index e2b89d1..c649f47 100644 --- a/src/views/boardGenerate/view.vue +++ b/src/views/boardGenerate/view.vue @@ -1,5 +1,6 @@