diff --git a/src/assets/styles/variables.module.scss b/src/assets/styles/variables.module.scss index 92fc34d..5e5b119 100644 --- a/src/assets/styles/variables.module.scss +++ b/src/assets/styles/variables.module.scss @@ -98,7 +98,7 @@ $--color-warning: #e6a23c; $--color-danger: #f56c6c; $--color-info: #909399; -$base-sidebar-width: 200px; +$base-sidebar-width: 250px; // the :export directive is the magic sauce for webpack // https://www.bluematador.com/blog/how-to-share-variables-between-js-and-sass diff --git a/src/views/boardGenerate/dataSourceList.vue b/src/views/boardGenerate/dataSourceList.vue index ac31038..41ef139 100644 --- a/src/views/boardGenerate/dataSourceList.vue +++ b/src/views/boardGenerate/dataSourceList.vue @@ -28,27 +28,16 @@ 修改 - 删除 + 删除 - + @@ -95,8 +84,7 @@ - + 删除 @@ -135,8 +123,7 @@ 添加字段 - + 查找 @@ -144,7 +131,7 @@ @@ -162,12 +149,8 @@ - + @@ -191,13 +174,7 @@ - + @@ -253,8 +230,7 @@ 添加字段 - + 查找 @@ -262,7 +238,7 @@ @@ -299,7 +275,7 @@ const selectForm = ref({ pageSize: 10 }); const total = ref(0); -const tableData = ref([{}]); +const tableData = ref([]); const constructionDataForm = ref({ designDataFieldList: [] }); const constructionDataFormVisible = ref(false); const addSQLFormVisible = ref(false); @@ -394,6 +370,7 @@ const createSQL = () => { fieldTwo: addSQLForm.value.SQL, fieldThree: addSQLForm.value.isPage }; + delete params.SQL; if (addSQLForm.value.dataSourceId) { editDataSourceApi(params).then(() => { @@ -517,7 +494,6 @@ const findTier = () => { (paramsTableData.value || []).forEach((item) => { params[item.name] = item.test; }); - (options.isD ? request : axios.request)({ method: constructionDataForm.value.requestMethod, url: constructionDataForm.value.requestUrl, @@ -567,13 +543,41 @@ const findTier = () => { }); } }); +}; +const formulaFun = (formula) => { + let data = formula.replace(/\$\{\s*([^}]+?)\s*\}/g, (_, key) => { + let infos = key.split(','); + if (infos.length === 1) { + if (addSQLForm.value.testList.find(e => e.fieldOne === infos[0])) { + return addSQLForm.value.testList.find(e => e.fieldOne === infos[0])?.fieldTwo || ''; + } else { + addSQLForm.value.testList.push({ + fieldOne: infos[0], + fieldTwo: '' + }); + return ''; + } + } + if (infos.length === 2) { + if (addSQLForm.value.testList.find(e => e.fieldOne === infos[1])) { + return `AND ${infos[0]} = ${addSQLForm.value.testList.find(e => e.fieldOne === infos[1])?.fieldTwo || ''}`; + } else { + addSQLForm.value.testList.push({ + fieldOne: infos[1], + fieldTwo: '' + }); + return ''; + } + } + }); + return data; }; const sqlFindTier = () => { addSQLForm.value.designDataFieldList = []; if (addSQLForm.value.isPage) { querySql1({ - sql: addSQLForm.value.SQL.replace(/\n/g, ' '), + sql: formulaFun(addSQLForm.value.SQL.replace(/\n/g, ' ')), linkId: addSQLForm.value.db, pageSize: 10, pageNum: 1 @@ -598,7 +602,7 @@ const sqlFindTier = () => { }); }); } else { - querySql(addSQLForm.value.SQL, addSQLForm.value.db).then((res) => { + querySql(formulaFun(addSQLForm.value.SQL.replace(/\n/g, ' ')), addSQLForm.value.db).then((res) => { let data = res; if (data?.data) { Object.keys(data.data?.[0]).forEach(key => { diff --git a/src/views/boardGenerate/index.vue b/src/views/boardGenerate/index.vue index 82e3968..4bc696e 100644 --- a/src/views/boardGenerate/index.vue +++ b/src/views/boardGenerate/index.vue @@ -145,6 +145,14 @@ 文字 + + + + + 按钮 + @@ -329,6 +337,10 @@ + + + @@ -888,6 +900,7 @@ import DataNode from './nodes/data/dataNode.vue'; import CustomDataNode from './nodes/data/customDataNode.vue'; import MapNode from './nodes/form/mapNode.vue'; import InputNode from './nodes/form/inputNode.vue'; +import ButtonNode from './nodes/form/buttonNode.vue'; import TimeNode from './nodes/form/timeNode.vue'; import TextNode from './nodes/form/textNode.vue'; import ImgNode from './nodes/form/imgNode.vue'; diff --git a/src/views/boardGenerate/index1.vue b/src/views/boardGenerate/index1.vue index cc239a7..7302904 100644 --- a/src/views/boardGenerate/index1.vue +++ b/src/views/boardGenerate/index1.vue @@ -233,6 +233,18 @@ 文字 + + + + + + + + 按钮 + handleResizeStop(e, inputNodeProps)" /> + + handleResizeStop(e, buttonNodeProps)" /> + + handleResizeStop(e, selectNodeProps)" /> @@ -1071,8 +1088,8 @@ @@ -1193,6 +1210,23 @@ + + + + + + @@ -1552,6 +1586,7 @@ import DigitalFlopNode from '@/views/boardGenerate/nodes/form/digitalFlopNode.vu import NightingaleRoseDiagramNode from '@/views/boardGenerate/nodes/board/nightingaleRoseDiagramNode.vue'; import IconNode from '@/views/boardGenerate/nodes/form/iconNode.vue'; import InputNode from '@/views/boardGenerate/nodes/form/inputNode.vue'; +import ButtonNode from '@/views/boardGenerate/nodes/form/buttonNode.vue'; import SelectNode from '@/views/boardGenerate/nodes/form/selectNode.vue'; import TimeNode from '@/views/boardGenerate/nodes/form/timeNode.vue'; diff --git a/src/views/boardGenerate/nodes/data/customDataNode.vue b/src/views/boardGenerate/nodes/data/customDataNode.vue index 75ef171..8327ad7 100644 --- a/src/views/boardGenerate/nodes/data/customDataNode.vue +++ b/src/views/boardGenerate/nodes/data/customDataNode.vue @@ -7,7 +7,7 @@ {{ props.data.customData.name }} @@ -97,16 +97,19 @@ const formulaFun = (formula) => { let data = formula.replace(/\$\{\s*([^}]+?)\s*\}/g, (_, key) => { let infos = key.split(','); if (infos.length === 1) { - return props.inputData[infos[0]] || ''; + return props.inputData[infos[0]] || '%%'; } if (infos.length === 2) { - return `AND ${infos[0]} = ${props.inputData[infos[1]]}`; + return `AND ${infos[0]} = ${props.inputData[infos[1]] || '%%'}`; } }); return data; }; +let timestamp = Date.now(); const getOutputData = () => { - + if (Date.now() < timestamp + 900) { + return; + } let params = props.inputData; (Object.keys(props.inputData) || []).forEach((item) => { params[item.name] = props.inputData[item.name]; @@ -163,23 +166,13 @@ const getOutputData = () => { isErr.value = true; }); } - - 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; - }); } }; - onMounted(() => { - getOutputData(); + setTimeout(() => { + getOutputData(); + }, 1000); + }); @@ -189,9 +182,9 @@ watch(() => JSON.parse(JSON.stringify([props.inputData])), (obj1, obj2) => { } }, { deep: true, immediate: true }); -let interval = setInterval(() => { +let interval = props.data.options?.timeout === -1 ? null : setInterval(() => { getOutputData(); -}, Math.max(props.data.options?.timeout || 5 * 1000, 1000)); +}, Math.max((props.data.options?.timeout || 5) * 1000, 1000)); onBeforeUnmount(() => { clearInterval(interval); diff --git a/src/views/boardGenerate/nodes/form/buttonNode.vue b/src/views/boardGenerate/nodes/form/buttonNode.vue new file mode 100644 index 0000000..b6708a3 --- /dev/null +++ b/src/views/boardGenerate/nodes/form/buttonNode.vue @@ -0,0 +1,130 @@ + + + + + + + $emit('resize', e)" color="#fff" + v-if="!props.isView && !props.isHideHandle && props.selected" @resize="resize" /> + + + {{ props.data.options.text }} + + + + + + + + diff --git a/src/views/boardGenerate/nodes/form/mapNode.vue b/src/views/boardGenerate/nodes/form/mapNode.vue index 2c12072..0fa036c 100644 --- a/src/views/boardGenerate/nodes/form/mapNode.vue +++ b/src/views/boardGenerate/nodes/form/mapNode.vue @@ -5,7 +5,8 @@ - 数据映射 diff --git a/src/views/boardGenerate/tool.js b/src/views/boardGenerate/tool.js index ceb58b4..515b588 100644 --- a/src/views/boardGenerate/tool.js +++ b/src/views/boardGenerate/tool.js @@ -295,15 +295,17 @@ const getOption = (e) => { } else if (e === 'customBoard') { return { title: '', yNames: [] }; } else if (e === 'data') { - return { timeout: 5000 }; + return { timeout: 5 }; } else if (e === 'staticData') { return { defaultInputArea: '', field: 'input', defaultDataType: '' }; } else if (e === 'customData') { - return { timeout: 5000 }; + return { timeout: 5 }; } else if (e === 'map') { return { dataMap: [] }; } else if (e === 'inputNode') { return { field: 'input', defaultInput: '' }; + } else if (e === 'buttonNode') { + return { backgroundColor: '#409EFF', color: '#fff', text: '按钮', sendType: ['ok'] }; } else if (e === 'selectNode') { return { field: 'select', defaultInput: '', labelField: 'label', valueField: 'value' }; } else if (e === 'time') { @@ -361,6 +363,8 @@ const getNodeSize = (e) => { return { width: 150, height: 50 }; } else if (e === 'inputNode') { return { width: 100, height: 30 }; + } else if (e === 'buttonNode') { + return { width: 100, height: 30 }; } else if (e === 'staticData') { return { width: 100, height: 60 }; } else if (e === 'text') { diff --git a/src/views/boardGenerate/view.vue b/src/views/boardGenerate/view.vue index c649f47..500dbfc 100644 --- a/src/views/boardGenerate/view.vue +++ b/src/views/boardGenerate/view.vue @@ -53,6 +53,10 @@ + + + @@ -163,6 +167,7 @@ import BarNode from './nodes/board/barNode.vue'; import BackgroundBarNode from './nodes/board/backgroundBarNode.vue'; import MultiBarsNode from './nodes/board/multiBarsNode.vue'; import InputNode from './nodes/form/inputNode.vue'; +import ButtonNode from './nodes/form/buttonNode.vue'; import SelectNode from './nodes/form/selectNode.vue'; import MapNode from './nodes/form/mapNode.vue'; import CustomBoardNode from './nodes/board/customBoardNode.vue';