|
|
|
@ -184,6 +184,37 @@
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item
|
|
|
|
|
label="语法类型"
|
|
|
|
|
prop="syntaxType"
|
|
|
|
|
>
|
|
|
|
|
<el-radio-group
|
|
|
|
|
v-model="dataForm.syntaxType"
|
|
|
|
|
class="bs-el-radio-group"
|
|
|
|
|
>
|
|
|
|
|
<el-radio label="normal">
|
|
|
|
|
普通
|
|
|
|
|
</el-radio>
|
|
|
|
|
<el-radio label="mybatis">
|
|
|
|
|
Mybatis
|
|
|
|
|
</el-radio>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
<el-tooltip
|
|
|
|
|
class="item"
|
|
|
|
|
effect="light"
|
|
|
|
|
content="Mybatis类型可使用动态标签来处理sql,如if、choose、where,具体用法可参考示例"
|
|
|
|
|
placement="top"
|
|
|
|
|
>
|
|
|
|
|
<i
|
|
|
|
|
class="el-icon-warning-outline"
|
|
|
|
|
style="color: #E3C98C;margin-left: 16px;font-size:14px"
|
|
|
|
|
/>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item
|
|
|
|
|
label="标签"
|
|
|
|
@ -209,10 +240,35 @@
|
|
|
|
|
:options="cOptions"
|
|
|
|
|
style="margin-top: 2px"
|
|
|
|
|
/>
|
|
|
|
|
<div class="bs-codemirror-bottom-text">
|
|
|
|
|
<div class="bs-codemirror-bottom-text" v-if="dataForm.syntaxType === 'mybatis'">
|
|
|
|
|
示例:
|
|
|
|
|
<strong><br>
|
|
|
|
|
1、常规使用
|
|
|
|
|
<el-tooltip
|
|
|
|
|
class="item"
|
|
|
|
|
effect="dark"
|
|
|
|
|
content="${参数名称}会将参数值直接填充到sql中,#{参数名称}会将参数值进行转义(比如字符串类型会添加'')后填充到sql中"
|
|
|
|
|
placement="top-start"
|
|
|
|
|
><i class="el-icon-question" />
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
select * from table where table_field = <span style="color: #CC7832;">${参数名称}</span> ( 或 <span style="color: #CC7832;">#{参数名称}</span> )<br>
|
|
|
|
|
2、条件判断
|
|
|
|
|
<el-tooltip
|
|
|
|
|
class="item"
|
|
|
|
|
effect="dark"
|
|
|
|
|
content="支持Mybatis的所有动态标签,如if、choose、where等,具体用法请参考Mybatis官方文档"
|
|
|
|
|
placement="top-start"
|
|
|
|
|
><i class="el-icon-question" />
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
select * from table where 1=1 <span style="color: #2F67A7;"><if test="参数名称 != null and 参数名称 !=''"></span> and table_field = <span
|
|
|
|
|
style="color: #CC7832;"
|
|
|
|
|
>${参数名称}</span> <span style="color: #2F67A7;"></if></span>
|
|
|
|
|
</strong>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="bs-codemirror-bottom-text" v-else>
|
|
|
|
|
示例:
|
|
|
|
|
<strong><br>
|
|
|
|
|
1、常规使用 select * from table where table_field = <span style="color: red;">${参数名称}</span><br>
|
|
|
|
|
1、常规使用 select * from table where table_field = <span style="color: #CC7832;">${参数名称}</span><br>
|
|
|
|
|
2、标签使用
|
|
|
|
|
<el-tooltip
|
|
|
|
|
class="item"
|
|
|
|
@ -221,9 +277,9 @@
|
|
|
|
|
placement="top-start"
|
|
|
|
|
><i class="el-icon-question" />
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
select * from table where 1=1 <span style="color: blue;"><参数名称></span> and table_field = <span
|
|
|
|
|
style="color: red;"
|
|
|
|
|
>${参数名称}</span> <span style="color: blue;"></参数名称></span>
|
|
|
|
|
select * from table where 1=1 <span style="color: #2F67A7;"><参数名称></span> and table_field = <span
|
|
|
|
|
style="color: #CC7832;"
|
|
|
|
|
>${参数名称}</span> <span style="color: #2F67A7;"></参数名称></span>
|
|
|
|
|
</strong>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -857,7 +913,8 @@ export default {
|
|
|
|
|
fieldDesc: {},
|
|
|
|
|
fieldList: [],
|
|
|
|
|
script: '',
|
|
|
|
|
cacheCoherence: null
|
|
|
|
|
cacheCoherence: null,
|
|
|
|
|
syntaxType: 'normal'
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
|
|
|
@ -980,6 +1037,7 @@ export default {
|
|
|
|
|
this.dataForm.fieldDesc = res.config.fieldDesc
|
|
|
|
|
this.dataForm.fieldList = res.config.fieldList
|
|
|
|
|
this.dataForm.cacheCoherence = res.config.cacheCoherence
|
|
|
|
|
this.dataForm.syntaxType = res.config.syntaxType ? res.config.syntaxType : 'normal'
|
|
|
|
|
// 使用传入的数据集名称 ?
|
|
|
|
|
this.dataForm.name = this.datasetName
|
|
|
|
|
this.paramsListCopy = cloneDeep(this.dataForm.paramsList)
|
|
|
|
@ -1161,7 +1219,8 @@ export default {
|
|
|
|
|
sqlProcess: this.dataForm.sqlProcess,
|
|
|
|
|
paramsList: this.dataForm.paramsList,
|
|
|
|
|
fieldList: this.dataForm.fieldList,
|
|
|
|
|
fieldDesc: this.dataForm.fieldDesc
|
|
|
|
|
fieldDesc: this.dataForm.fieldDesc,
|
|
|
|
|
syntaxType: this.dataForm.syntaxType,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
datasetSave(datasetParams).then(res => {
|
|
|
|
@ -1184,8 +1243,13 @@ export default {
|
|
|
|
|
*/
|
|
|
|
|
buildParamsAndRun () {
|
|
|
|
|
this.isTest = true
|
|
|
|
|
// 匹配 ${}
|
|
|
|
|
const reg = /\${(.*?)}/g
|
|
|
|
|
const paramNames = [...new Set([...this.dataForm.sqlProcess.matchAll(reg)].map(item => item[1]))]
|
|
|
|
|
let paramNames = [...new Set([...this.dataForm.sqlProcess.matchAll(reg)].map(item => item[1]))]
|
|
|
|
|
// 匹配 #{}
|
|
|
|
|
const reg2 = /#{(.*?)}/g
|
|
|
|
|
const paramNames2 = [...new Set([...this.dataForm.sqlProcess.matchAll(reg2)].map(item => item[1]))]
|
|
|
|
|
paramNames.push(...paramNames2)
|
|
|
|
|
const names = this.dataForm.paramsList.map(item => item.name)
|
|
|
|
|
const params = []
|
|
|
|
|
paramNames.forEach(name => {
|
|
|
|
@ -1243,6 +1307,7 @@ export default {
|
|
|
|
|
script: this.dataForm.sqlProcess,
|
|
|
|
|
params: this.dataForm.paramsList,
|
|
|
|
|
dataSetType: 'custom',
|
|
|
|
|
syntaxType: this.dataForm.syntaxType,
|
|
|
|
|
size: this.size,
|
|
|
|
|
current: this.current
|
|
|
|
|
}
|
|
|
|
@ -1285,7 +1350,7 @@ export default {
|
|
|
|
|
const checkList = this.structurePreviewList.filter(item => item.fieldName === param.name)
|
|
|
|
|
if (checkList.length) {
|
|
|
|
|
paramsNameCheck = true
|
|
|
|
|
param.name = ''
|
|
|
|
|
// param.name = ''
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (paramsNameCheck) {
|
|
|
|
|