修复 代码生成信息 反显问题

This commit is contained in:
吕金泽 2022-06-08 22:06:49 +08:00
parent 476760a9b5
commit 00dad13df3
5 changed files with 24 additions and 17 deletions

View File

@ -5,7 +5,7 @@
"groupId" : "f2538e0f370a4cabab0ae920f5e77ae7", "groupId" : "f2538e0f370a4cabab0ae920f5e77ae7",
"name" : "执行生成", "name" : "执行生成",
"createTime" : null, "createTime" : null,
"updateTime" : 1653992145291, "updateTime" : 1654682481038,
"lock" : null, "lock" : null,
"createBy" : null, "createBy" : null,
"updateBy" : null, "updateBy" : null,
@ -324,12 +324,12 @@ columns.forEach(it => {
} }
} }
}) })
datasource = datasource || ''
var commonField = db[datasource].select(""" var commonField = db[datasource].select("""
SELECT SELECT
column_name column_name
FROM FROM
information_schema.COLUMNS information_schema.COLUMNS
WHERE WHERE
table_name = #{tableName} AND column_name IN ( 'is_del', 'create_by', 'create_date', 'update_by', 'update_date' ) AND table_schema = DATABASE() table_name = #{tableName} AND column_name IN ( 'is_del', 'create_by', 'create_date', 'update_by', 'update_date' ) AND table_schema = DATABASE()
""") """)
@ -406,4 +406,4 @@ componentInfo.setPath("/list")
componentInfo.setScript(componentScript) componentInfo.setScript(componentScript)
MagicResourceService.saveFile(componentInfo) MagicResourceService.saveFile(componentInfo)
return 1 return 1

View File

@ -5,7 +5,7 @@
"groupId" : "f2538e0f370a4cabab0ae920f5e77ae7", "groupId" : "f2538e0f370a4cabab0ae920f5e77ae7",
"name" : "查出所有表", "name" : "查出所有表",
"createTime" : null, "createTime" : null,
"updateTime" : 1653990626738, "updateTime" : 1654682333737,
"lock" : null, "lock" : null,
"createBy" : null, "createBy" : null,
"updateBy" : null, "updateBy" : null,
@ -130,6 +130,6 @@
} }
} }
================================ ================================
return db[datasource].select(""" return db[datasource || ''].select("""
select table_name, table_comment from information_schema.tables where table_schema = database() select table_name, table_comment from information_schema.tables where table_schema = database()
""").map(it => { label: it.tableName + `(${it.tableComment})`, value: it.tableName }) """).map(it => { label: it.tableName + `(${it.tableComment})`, value: it.tableName })

View File

@ -5,7 +5,7 @@
"groupId" : "f2538e0f370a4cabab0ae920f5e77ae7", "groupId" : "f2538e0f370a4cabab0ae920f5e77ae7",
"name" : "根据表名查出所有列", "name" : "根据表名查出所有列",
"createTime" : null, "createTime" : null,
"updateTime" : 1653991292310, "updateTime" : 1654682348773,
"lock" : null, "lock" : null,
"createBy" : null, "createBy" : null,
"updateBy" : null, "updateBy" : null,
@ -191,7 +191,7 @@
} }
================================ ================================
return { return {
columns: db[datasource].select(""" columns: db[datasource || ''].select("""
SELECT SELECT
column_name, column_name,
column_comment, column_comment,

View File

@ -1,6 +1,6 @@
<template> <template>
<el-form ref="dataForm" :model="genInfo" :rules="genInfoRules" label-position="right" label-width="120px"> <el-form ref="dataForm" :model="genInfo" :rules="genInfoRules" label-position="right" label-width="120px">
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName">
<el-tab-pane label="表信息" name="basic"> <el-tab-pane label="表信息" name="basic">
<el-row :gutter="24"> <el-row :gutter="24">
<el-col :span="8"> <el-col :span="8">
@ -151,11 +151,6 @@ import {reactive, ref, watch, getCurrentInstance, onMounted, nextTick} from 'vue
}) })
} }
watch(() => genInfo.value.datasource, () => {
datasourceChange()
genInfo.value.tableName = ''
})
function formInitClearValidate(){ function formInitClearValidate(){
genInfo.value.tableComment = '' genInfo.value.tableComment = ''
genInfo.value.info.moduleName = ''; genInfo.value.info.moduleName = '';
@ -170,6 +165,13 @@ import {reactive, ref, watch, getCurrentInstance, onMounted, nextTick} from 'vue
},1) },1)
} }
function watchDatasource(){
watch(() => genInfo.value.datasource, () => {
datasourceChange()
genInfo.value.tableName = ''
})
}
function watchTableName(){ function watchTableName(){
datasourceChange() datasourceChange()
watch(() => genInfo.value.tableName, (value) => { watch(() => genInfo.value.tableName, (value) => {
@ -199,6 +201,11 @@ import {reactive, ref, watch, getCurrentInstance, onMounted, nextTick} from 'vue
}) })
} }
function watchInfo(){
watchTableName()
watchDatasource()
}
const activeName = ref('basic') const activeName = ref('basic')
const formData = reactive({ const formData = reactive({
groupName: '' groupName: ''
@ -399,10 +406,10 @@ import {reactive, ref, watch, getCurrentInstance, onMounted, nextTick} from 'vue
formData.info = JSON.parse(formData.info) formData.info = JSON.parse(formData.info)
formData.columns = JSON.parse(formData.columns) formData.columns = JSON.parse(formData.columns)
genInfo.value = formData genInfo.value = formData
watchTableName() watchInfo()
}) })
} }
defineExpose({ save, getDetail, watchTableName }) defineExpose({ save, getDetail, watchInfo })
</script> </script>

View File

@ -20,7 +20,7 @@
permission: 'code:gen:save', permission: 'code:gen:save',
click: () => { click: () => {
formDialog.value.show() formDialog.value.show()
nextTick(() => magicForm.value.watchTableName()) nextTick(() => magicForm.value.watchInfo())
} }
}], }],
table: { table: {