feat: 修正标签属性名错误导致的模拟类型渲染问题

pull/144/head
klaokai 2023-04-29 16:04:48 +08:00
parent 756fc1038c
commit 7c2955e327
2 changed files with 65 additions and 14 deletions

View File

@ -1,5 +1,40 @@
<template>
<Dialog v-model="dialogVisible" title="代码预览" width="80%">
<el-space>
<el-alert effect="dark" title="请注意看使用说明" type="success" />
<el-text type="primary" size="large"> 不模拟 </el-text>
<el-text
>即默认规则,这个字段会在“insert”语句那里被忽略掉,一般第一次进来配置的时候都是这个。
</el-text>
<el-text type="primary" size="large"> 递增 </el-text>
<el-text
>设定一个数字,从这个数字开始比如“3”,那么生成的递增规则的数字为“3、4、5……”。
(选做?)如果是主键,那么会自动跳过数据库已经存在的主键,比如“3”,生成三个数据“3、4、5”,但由于数据库已经有4,那么跳过4,生成“3、5、6”。
</el-text>
<el-text type="primary" size="large"> 随机 </el-text>
<el-text
>随机做好了一定的随机规则,现在有STRING("字符串"), NAME("人名"), CITY("城市"),
URL("网址"), EMAIL("邮箱"), IP("IP"), INTEGER("整数"), DECIMAL("小数"),
UNIVERSITY("大学"), DATE("日期"), TIMESTAMP("时间戳"), PHONE("手机号")。
这些规则可能还会有更细的划分,比如可以自定连续日期,但有可能考虑到这些规则的加入不仅程序会更加复杂,用户也得细心设置这些规则才能生成正确的数据,像这种细分的东西,用户还是自己自己实现规则搞定。
</el-text>
<el-text type="primary" size="large"> 固定 </el-text>
<el-text>文本,填什么就是什么,直接加入到“insert”语句。</el-text>
<el-text type="primary" size="large"> 规则 </el-text>
<el-text
>通过正则表达式生成随机数据,使用的是com.mifmif.common.regex.Generex,语法地址在这(
<el-icon>
<Bell />
</el-icon>
)。
</el-text>
<el-text type="primary" size="large"> 词库 </el-text>
<el-text
>通过curl命令实现,参数填 curl
命令之后的参数(不包含curl命令),你的系统一定要支持curl命令才能使用。 对面的响应格式为
["a1","b1"……] 即可
</el-text>
</el-space>
<div class="common-layout">
<el-container v-if="active == 1">
<el-header>请配置模拟类型、模拟参数以及模拟参数默认值</el-header>
@ -9,7 +44,7 @@
<el-footer>
<div class="slider-demo-block">
<span class="demonstration">数据生成量</span>
<el-slider v-model="queryParams.num" :step="10" show-stops />
<el-slider v-model="queryParams.num" max="1000" show-stops show-input />
</div>
</el-footer>
</el-container>
@ -22,11 +57,11 @@
</div>
</div>
</el-main>
<el-footer
><el-button class="float-right" text type="primary" @click="copy()">
<el-footer>
<el-button class="float-right" text type="primary" @click="copy()">
{{ t('common.copy') }}
</el-button></el-footer
>
</el-button>
</el-footer>
</el-container>
</div>
<el-steps :active="active" finish-status="success">

View File

@ -24,9 +24,9 @@
<el-select v-model="scope.row.mockType" clearable filterable placeholder="请选择">
<el-option
v-for="dict in dictOptions"
:key="dict.label"
:label="dict.label"
:key="dict.type"
:value="dict.type"
:label="dict.lable"
/>
</el-select>
</template>
@ -34,11 +34,13 @@
<el-table-column label="模拟参数" min-width="10%">
<template #default="scope">
<el-select
v-if="scope.row.mockType == 4"
v-if="scope.row.mockType === 4"
v-model="scope.row.mockParams"
clearable
filterable
placeholder="请选择"
remote
:loading="loading"
:remote-method="(val) => getMockParmOptions(val, scope.row.mockType)"
>
<el-option v-for="dict in mockParamOptions" :key="dict" :label="dict" :value="dict" />
</el-select>
@ -69,12 +71,27 @@ const tableHeight = document.documentElement.scrollHeight - 350 + 'px'
/** 查询模拟类型下拉列表 */
const dictOptions = ref<CodegenApi.CodegenMockTypeRespVO[]>([])
const getDictOptions = async () => {
dictOptions.value = await CodegenApi.fakeDataMockTypeList()
loading.value = true
try {
dictOptions.value = await CodegenApi.fakeDataMockTypeList()
} finally {
loading.value = false
}
}
const mockParamOptions = ref<string[]>([]) // 用户组列表
const getMockParmOptions = async () => {
mockParamOptions.value = await CodegenApi.getMockParamsByMockType(4)
//查询模拟参数
const loading = ref(false)
const mockParamOptions = ref<string[]>([])
const getMockParmOptions = async (val, type: number) => {
if (type == undefined) {
return
}
loading.value = true
try {
mockParamOptions.value = await CodegenApi.getMockParamsByMockType(type)
} finally {
loading.value = false
}
}
watch(
@ -91,6 +108,5 @@ watch(
onMounted(async () => {
await getDictOptions()
await getMockParmOptions()
})
</script>