fix: 代码生成器

This commit is contained in:
xingyu 2022-10-14 17:52:04 +08:00
parent ff938a9e30
commit aa983a6fa9
14 changed files with 30 additions and 19 deletions

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElDropdown, ElDropdownMenu, ElDropdownItem } from 'element-plus' import { ElDropdown, ElDropdownMenu, ElDropdownItem } from 'element-plus'
import { PropType, ref } from 'vue' import { PropType, ref, defineEmits } from 'vue'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import type { RouteLocationNormalizedLoaded } from 'vue-router' import type { RouteLocationNormalizedLoaded } from 'vue-router'

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, computed, watch, onMounted, unref, toRef, PropType } from 'vue' import { reactive, computed, watch, onMounted, unref, toRef, PropType, defineEmits } from 'vue'
import { isNumber } from '@/utils/is' import { isNumber } from '@/utils/is'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'

View File

@ -24,7 +24,7 @@ import {
ElRadioButton, ElRadioButton,
ElMessage ElMessage
} from 'element-plus' } from 'element-plus'
import { ref, computed, onMounted, reactive, watch, PropType } from 'vue' import { ref, computed, onMounted, reactive, watch, PropType, defineEmits } from 'vue'
interface shortcutsType { interface shortcutsType {
text: string text: string
value: string value: string

View File

@ -4,6 +4,7 @@ import networkError from '@/assets/svgs/500.svg'
import noPermission from '@/assets/svgs/403.svg' import noPermission from '@/assets/svgs/403.svg'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { defineEmits } from 'vue'
interface ErrorMap { interface ErrorMap {
url: string url: string

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import { ref, computed, CSSProperties, toRef, watch } from 'vue' import { ref, computed, CSSProperties, toRef, watch, defineEmits } from 'vue'
import { import {
ElInput, ElInput,
ElPopover, ElPopover,

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { PropType } from 'vue' import { PropType, defineEmits } from 'vue'
import { Highlight } from '@/components/Highlight' import { Highlight } from '@/components/Highlight'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, unref, computed, watch } from 'vue' import { ref, unref, computed, watch, defineEmits } from 'vue'
import { ElInput } from 'element-plus' import { ElInput } from 'element-plus'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { useConfigGlobal } from '@/hooks/web/useConfigGlobal' import { useConfigGlobal } from '@/hooks/web/useConfigGlobal'

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { PropType, nextTick, ref, watch, computed, unref } from 'vue' import { PropType, nextTick, ref, watch, computed, unref, defineEmits } from 'vue'
import QRCode from 'qrcode' import QRCode from 'qrcode'
import { QRCodeRenderersOptions } from 'qrcode' import { QRCodeRenderersOptions } from 'qrcode'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { Form } from '@/components/Form' import { Form } from '@/components/Form'
import { PropType, computed, unref, ref } from 'vue' import { PropType, computed, unref, ref, defineEmits } from 'vue'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { ElButton } from 'element-plus' import { ElButton } from 'element-plus'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { PropType, watch, unref, ref } from 'vue' import { PropType, watch, unref, ref, defineEmits } from 'vue'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'

View File

@ -26,6 +26,10 @@ const activeName = ref('cloum')
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>() const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>()
const genInfoRef = ref<ComponentRef<typeof GenInfoForm>>() const genInfoRef = ref<ComponentRef<typeof GenInfoForm>>()
const cloumInfoRef = ref(null) const cloumInfoRef = ref(null)
const parentMenuId = ref<number>()
const menu = (id: number) => {
parentMenuId.value = id
}
const submitForm = async () => { const submitForm = async () => {
const basicInfo = unref(basicInfoRef) const basicInfo = unref(basicInfoRef)
const genInfo = unref(genInfoRef) const genInfo = unref(genInfoRef)
@ -38,6 +42,11 @@ const submitForm = async () => {
table: Object.assign({}, basicInfoData, genInfoData), table: Object.assign({}, basicInfoData, genInfoData),
columns: cloumCurrentRow.value columns: cloumCurrentRow.value
} }
if (parentMenuId.value) {
genInfoData.parentMenuId = parentMenuId.value
} else {
genInfoData.parentMenuId = 0
}
await updateCodegenTableApi(genTable) await updateCodegenTableApi(genTable)
ElMessage.success(t('common.updateSuccess')) ElMessage.success(t('common.updateSuccess'))
push('/infra/codegen') push('/infra/codegen')
@ -57,7 +66,7 @@ onMounted(() => {
<CloumInfoForm ref="cloumInfoRef" :info="cloumCurrentRow" /> <CloumInfoForm ref="cloumInfoRef" :info="cloumCurrentRow" />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo"> <el-tab-pane label="生成信息" name="genInfo">
<GenInfoForm ref="genInfoRef" :genInfo="tableCurrentRow" /> <GenInfoForm ref="genInfoRef" :genInfo="tableCurrentRow" @menu="menu" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<template #right> <template #right>

View File

@ -15,7 +15,8 @@ const props = defineProps({
default: () => null default: () => null
} }
}) })
const defaultProps = { const menuProps = {
checkStrictly: true,
children: 'children', children: 'children',
label: 'name', label: 'name',
value: 'id' value: 'id'
@ -31,7 +32,6 @@ const rules = reactive({
}) })
const templateTypeOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE) const templateTypeOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE)
const sceneOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE) const sceneOptions = getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE)
const parentMenuId = ref()
const treeRef = ref<InstanceType<typeof ElTreeSelect>>() const treeRef = ref<InstanceType<typeof ElTreeSelect>>()
const menuOptions = ref<any>([]) // const menuOptions = ref<any>([]) //
const getTree = async () => { const getTree = async () => {
@ -112,9 +112,13 @@ const schema = reactive<FormSchema[]>([
const { register, methods, elFormRef } = useForm({ const { register, methods, elFormRef } = useForm({
schema schema
}) })
const parentMenuId = ref<number>()
//
const emit = defineEmits(['menu'])
const handleNodeClick = () => { const handleNodeClick = () => {
console.log(parentMenuId.value) emit('menu', parentMenuId.value)
} }
// ========== ========== // ========== ==========
onMounted(async () => { onMounted(async () => {
await getTree() await getTree()
@ -143,10 +147,9 @@ defineExpose({
v-model="parentMenuId" v-model="parentMenuId"
ref="treeRef" ref="treeRef"
node-key="id" node-key="id"
check-on-click-node :props="menuProps"
expand-on-click-node="false"
:props="defaultProps"
:data="menuOptions" :data="menuOptions"
check-strictly
@node-click="handleNodeClick" @node-click="handleNodeClick"
/> />
</template> </template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from 'vue' import { reactive, ref, defineEmits } from 'vue'
import { getSchemaTableListApi, createCodegenListApi } from '@/api/infra/codegen' import { getSchemaTableListApi, createCodegenListApi } from '@/api/infra/codegen'
import { import {
ElMessage, ElMessage,

View File

@ -150,7 +150,6 @@ onMounted(async () => {
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" /> <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
</template> </template>
<template #packageId="{ row }"> <template #packageId="{ row }">
<!-- <DictTag :type="DICT_TYPE.SYSTEM_TENANT_PACKAGE_ID" :value="row.packageId" />-->
<el-tag v-if="row.packageId === 0" type="danger">系统租户</el-tag> <el-tag v-if="row.packageId === 0" type="danger">系统租户</el-tag>
<el-tag v-else type="success"> {{ getPackageName(row.packageId) }} </el-tag> <el-tag v-else type="success"> {{ getPackageName(row.packageId) }} </el-tag>
</template> </template>
@ -161,7 +160,6 @@ onMounted(async () => {
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<!-- <el-button type="text" v-hasPermi="['system:tenant:update']" @click="handleUpdate(row)">-->
<el-button <el-button
link link
type="primary" type="primary"