diff --git a/package.json b/package.json index 5f08f3a..a4c6477 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "@unocss/preset-icons": "0.58.6", "@unocss/preset-uno": "0.58.6", "@vitejs/plugin-vue": "5.0.4", - "@vue/compiler-sfc": "3.4.23", + "@vue/compiler-sfc": "3.4.34", "autoprefixer": "10.4.18", "eslint": "8.57.0", "eslint-config-prettier": "9.1.0", @@ -116,5 +116,13 @@ "vitest": "1.5.0", "vue-eslint-parser": "9.4.2", "vue-tsc": "2.0.13" + }, + "overrides": { + "vue": "3.4.34", + "@vue/compiler-core": "3.4.34", + "@vue/runtime-dom": "3.4.34", + "@vue/runtime-core": "3.4.34", + "@vue/reactivity": "3.4.34", + "@vue/shared": "3.4.34" } } diff --git a/src/utils/request.ts b/src/utils/request.ts index ba2e479..5e10619 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -51,8 +51,7 @@ service.interceptors.request.use( (config: InternalAxiosRequestConfig) => { // 请求地址处理,兼容使用模块化,wms分为wms1\2\3多个微服务端口 - config.url = config.url.replaceAll('/wms/',getUrl()) - console.log(config.url); + config.url = config.url.replaceAll('/wms/', getUrl()); // 对应国际化资源文件后缀 @@ -111,6 +110,12 @@ service.interceptors.request.use( if (config.data instanceof FormData) { delete config.headers['Content-Type']; } + if (config.headers?.bodyType === 'raw') { + if (typeof config.data === 'object') { + config.data = JSON.stringify(config.data); + } + config.headers['Content-Type'] = 'text/plain'; + } return config; }, (error: any) => { diff --git a/src/views/boardGenerate/api/dataSource.js b/src/views/boardGenerate/api/dataSource.js index bc68a60..b431546 100644 --- a/src/views/boardGenerate/api/dataSource.js +++ b/src/views/boardGenerate/api/dataSource.js @@ -27,3 +27,11 @@ export const editDataSourceApi = (data) => { url: '/system/designDataSource', method: 'PUT', data }); }; + + +// 测试sql连接 +export const querySql = (data, db) => { + return request({ + url: '/system/databaseLink/querySql/' + db, method: 'post', data, headers: { bodyType: 'raw' } + }); +}; diff --git a/src/views/boardGenerate/dataSourceList.vue b/src/views/boardGenerate/dataSourceList.vue index 36325fe..94c09a7 100644 --- a/src/views/boardGenerate/dataSourceList.vue +++ b/src/views/boardGenerate/dataSourceList.vue @@ -153,10 +153,13 @@ + + + - - {{ i }} - - - - - - - - - - {{ addSQLForm.table }} - - {{ i.columnName - }} - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 添加字段 + + + 查找 + @@ -216,7 +254,7 @@ import axios from 'axios'; import request from '@/utils/request'; import { options } from './tool.js'; -import { addDataSourceApi, delDataSourceApi, editDataSourceApi, getDataSourceList } from './api/dataSource'; +import { addDataSourceApi, delDataSourceApi, editDataSourceApi, getDataSourceList, querySql } from './api/dataSource'; import { ElMessage, ElMessageBox } from 'element-plus'; import { getDatabaseLink, getFieldList, listDatabaseLink } from '@/views/boardGenerate/api/db'; @@ -278,7 +316,9 @@ const constructionData = () => { }; const addSQL = () => { addSQLFormVisible.value = true; - addSQLForm.value = {}; + addSQLForm.value = { + designDataFieldList: [] + }; getDbList(); }; const getDbList = () => { @@ -300,9 +340,33 @@ const addSQLInput = (data) => { addSQLForm.value.SQL = (addSQLForm.value.SQL || '') + `${data} `; }; +const testSql = () => { + querySql(addSQLForm.value.SQL, addSQLForm.value.db).then((res) => { + console.log(res); + }); +}; + const createSQL = () => { - let params = JSON.parse(JSON.stringify(addSQLForm.value)); - params.activeFlag = '1'; + let params = { + ...addSQLForm.value, + dataSourceName: addSQLForm.value.dataSourceName, + activeFlag: '1', + responseType: '2', + designDataFieldList: addSQLForm.value.designDataFieldList.map(e => { + return { + fieldType: '2', + activeFlag: '1', + dataSourceId: addSQLForm.value.dataSourceId, + fieldOne: e.fieldOne, + fieldTwo: e.fieldTwo + }; + }), + requestUrl: 'system/databaseLink/querySql', + requestMethod: 'querySql', + fieldOne: addSQLForm.value.db, + fieldTwo: addSQLForm.value.SQL + }; + if (addSQLForm.value.dataSourceId) { editDataSourceApi(params).then(() => { addSQLFormVisible.value = false; @@ -339,8 +403,20 @@ const delData = () => { }; const editDataSource = (e) => { console.log(e); - constructionDataFormVisible.value = true; - constructionDataForm.value = e; + if (e.responseType === '1' || !e.responseType) { + constructionDataFormVisible.value = true; + constructionDataForm.value = e; + } + if (e.responseType === '2') { + addSQLFormVisible.value = true; + addSQLForm.value = { + ...e, + db: parseFloat(e.fieldOne), + SQL: e.fieldTwo + }; + + getDbList(); + } }; const delDataSource = (e) => { ElMessageBox.confirm( @@ -374,6 +450,7 @@ const createData = () => { } let params = JSON.parse(JSON.stringify(constructionDataForm.value)); params.activeFlag = '1'; + params.responseType = '1'; params.designDataFieldList = params.designDataFieldList.map(e => { return { fieldType: '2', @@ -420,7 +497,6 @@ const findTier = () => { data: constructionDataForm.value.requestMethod === 'post' ? params : '' }).then(res => { let data = (options.isD ? res : res.data); - console.log(data); if (data?.data) { Object.keys(data.data?.[0]).forEach(key => { constructionDataForm.value.designDataFieldList.push({ @@ -429,6 +505,11 @@ const findTier = () => { fieldTwo: `data,map%${key}` }); }); + constructionDataForm.value.designDataFieldList.push({ + fieldOne: 'data', + remark: '', + fieldTwo: `data` + }); } else if (data?.rows) { console.log(data?.rows); Object.keys(data.rows?.[0]).forEach(key => { @@ -438,6 +519,11 @@ const findTier = () => { fieldTwo: `rows,map%${key}` }); }); + constructionDataForm.value.designDataFieldList.push({ + fieldOne: 'rows', + remark: '', + fieldTwo: `rows` + }); } else { let exclude = ['code']; Object.keys(data).forEach(key => { @@ -454,6 +540,55 @@ 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 => { + 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) { + console.log(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 () => { await queryList(); diff --git a/src/views/boardGenerate/index1.vue b/src/views/boardGenerate/index1.vue index b11163e..8c5b065 100644 --- a/src/views/boardGenerate/index1.vue +++ b/src/views/boardGenerate/index1.vue @@ -422,153 +422,185 @@
- + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + +
@@ -891,10 +923,10 @@ - + - + @@ -1472,19 +1504,8 @@ import imgImg from './images/imgImg.png'; import textImg from './images/textImg.png'; import FlowRuler from './FlowRuler.vue'; -import { - ArrowDown, - View, - DocumentChecked, - Close, - Plus, - Setting, - StarFilled, - Delete, - Unlock, - Lock -} from '@element-plus/icons-vue'; import * as icon from '@element-plus/icons-vue'; +import { ArrowDown, Close, Delete, DocumentChecked, Lock, Plus, Setting, Unlock, View } from '@element-plus/icons-vue'; import { MarkerType, useVueFlow, VueFlow } from '@vue-flow/core'; import tool, { options } from '@/views/boardGenerate/tool.js'; import { v4 as uuidv4 } from 'uuid'; @@ -1533,6 +1554,17 @@ const headers = ref(globalHeaders()); const { onDragStart, onDrop, onDragOver } = tool(); const router = useRouter(); +const isSnapToGrid = ref(true); +const toggleSnapToGrid = (e) => { + if (e.key === 'Alt') { + isSnapToGrid.value = false; + } +}; +const keyup = () => { + isSnapToGrid.value = true; +}; +window.addEventListener('keydown', toggleSnapToGrid); +window.addEventListener('keyup', keyup); const { addEdges, updateNode, @@ -1540,6 +1572,22 @@ const { addNodes } = useVueFlow(); +const gridSize = 200; + +const handleResizeStop = (event, node) => { + if (event.altKey) return; + + const snappedWidth = Math.round(node.width / gridSize) * gridSize; + const snappedHeight = Math.round(node.height / gridSize) * gridSize; + + updateNode(node.id, { + style: { + width: `${snappedWidth}px`, + height: `${snappedHeight}px` + } + }); +}; + onMounted(async () => { icons.value = Object.keys(icon); loading.value = true; @@ -1553,7 +1601,10 @@ onMounted(async () => { name: e.dataSourceName, url: e.requestUrl, method: e.requestMethod, - outputData: e.designDataFieldList + outputData: e.designDataFieldList, + type: e.responseType, + db: e.fieldOne, + SQL: e.fieldTwo }; }); }) @@ -1679,10 +1730,8 @@ const logEvent = async (eventname, event) => { nodeAttrForm.value = event.node.data.options; nodeDataForm.value = event.node; customDataForm.value = event.node.data.customData; - console.log(nodeDataForm.value); break; case 'nodeDrag': - console.log(event.nodes); if (event.nodes.length === 1) { nodeAttrForm.value = event.node.data.options; nodeDataForm.value = event.node; @@ -1694,7 +1743,6 @@ const logEvent = async (eventname, event) => { } break; case 'contextmenu': - console.log('contextmenu', event); } }; const resize = (e, id) => { @@ -1757,23 +1805,39 @@ const save = () => { } } }); - return { - activeFlag: '1', - pageConfigId: boardData.value.pageConfigId, - pagePointId: e.id, - pagePointName: e.name, - fieldOne: index, - fieldTwo: e.draggable, - width: e.dimensions.width, - height: e.dimensions.height, - posX: e.position.x, - posY: e.position.y, - pointType: e.type, - dataContent: JSON.stringify(data) - }; + if (e.type === 'area') { + return { + activeFlag: '1', + pageConfigId: boardData.value.pageConfigId, + pagePointId: e.id, + pagePointName: e.name, + fieldOne: index, + fieldTwo: e.draggable, + width: e.dimensions.width || '', + height: e.dimensions.height || '', + posX: e.position.x, + posY: e.position.y, + pointType: e.type, + dataContent: JSON.stringify(data) + }; + } else { + return { + activeFlag: '1', + pageConfigId: boardData.value.pageConfigId, + pagePointId: e.id, + pagePointName: e.name, + fieldOne: index, + fieldTwo: e.draggable, + width: e.dimensions.width || '', + height: e.dimensions.height || '', + posX: e.position.x, + posY: e.position.y, + pointType: e.type, + dataContent: JSON.stringify(data) + }; + } }), designPageEdgesList: edges.value.map(e => { - console.log(e); return { activeFlag: '1', pageConfigId: boardData.value.pageConfigId, @@ -1898,15 +1962,16 @@ const pitchOnNode = (e) => { }; const cellClick = (e) => { + let option = (nodeAttrForm.value.tableCellOptions || []).find(v => v.index === e.$index && v.cellIndex === e.cellIndex) || {}; + console.log(e); cellOption.value = { ...(nodeAttrForm.value.tableOptions?.[e.cellIndex] || {}), $index: e.$index, - $cellIndex: e.cellIndex - + $cellIndex: e.cellIndex, + formula: option.formula, + type: option.type }; - console.log(e); cellOptionsVisible.value = true; - console.log(cellOption.value); }; const cellTypeChange = (value) => { @@ -1926,11 +1991,9 @@ const cellTypeChange = (value) => { } else { nodeAttrForm.value.tableCellOptions[index].type = value; } - console.log(nodeAttrForm.value); }; const cellFormulaChange = (value) => { - console.log(value); if (!nodeAttrForm.value.tableCellOptions) { nodeAttrForm.value.tableCellOptions = []; } @@ -1947,12 +2010,14 @@ const cellFormulaChange = (value) => { } else { nodeAttrForm.value.tableCellOptions[index].formula = value; } - console.log(nodeAttrForm.value); }; const formulaFun = (row, formula) => { let data = formula.replace(/\$\{\s*([^}]+?)\s*\}/g, (_, key) => { + if (key === 'tableData') { + return key; + } if (`${row[key]}`?.trim() !== '' && !isNaN(row[key])) { return row[key] || 0; } else { @@ -1961,7 +2026,8 @@ const formulaFun = (row, formula) => { }); let res = 0; try { - res = eval(data); + const fun = new Function('tableData', `return ${data}`); + res = fun((getInputData(nodeDataForm.value.id) || {}).tableData); } catch (err) { res = 0; } @@ -2100,6 +2166,16 @@ const setText = (value, row, formula) => { height: calc(100vh - var(--boardGenerateTopHeight)); overflow: auto; + + /deep/ .vue-flow__resize-control { + background-color: #409EFF !important; + border: 1px solid white; + + .handle { + background-color: #409EFF !important; + } + } + } .right { diff --git a/src/views/boardGenerate/nodes/board/annularNode.vue b/src/views/boardGenerate/nodes/board/annularNode.vue index e820e87..8384a20 100644 --- a/src/views/boardGenerate/nodes/board/annularNode.vue +++ b/src/views/boardGenerate/nodes/board/annularNode.vue @@ -1,7 +1,7 @@