Browse Source

fix: 代码生成器

xingyu 2 years ago
parent
commit
aa983a6fa9

+ 1 - 1
yudao-ui-admin-vue3/src/components/ContextMenu/src/ContextMenu.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 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 { useDesign } from '@/hooks/web/useDesign'
 import type { RouteLocationNormalizedLoaded } from 'vue-router'

+ 1 - 1
yudao-ui-admin-vue3/src/components/CountTo/src/CountTo.vue

@@ -1,5 +1,5 @@
 <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 { propTypes } from '@/utils/propTypes'
 import { useDesign } from '@/hooks/web/useDesign'

+ 1 - 1
yudao-ui-admin-vue3/src/components/Crontab/src/Crontab.vue

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

+ 1 - 0
yudao-ui-admin-vue3/src/components/Error/src/Error.vue

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

+ 1 - 1
yudao-ui-admin-vue3/src/components/Icon/src/IconSelect.vue

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

+ 1 - 1
yudao-ui-admin-vue3/src/components/Infotip/src/Infotip.vue

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

+ 1 - 1
yudao-ui-admin-vue3/src/components/InputPassword/src/InputPassword.vue

@@ -1,5 +1,5 @@
 <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 { propTypes } from '@/utils/propTypes'
 import { useConfigGlobal } from '@/hooks/web/useConfigGlobal'

+ 1 - 1
yudao-ui-admin-vue3/src/components/Qrcode/src/Qrcode.vue

@@ -1,5 +1,5 @@
 <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 { QRCodeRenderersOptions } from 'qrcode'
 import { cloneDeep } from 'lodash-es'

+ 1 - 1
yudao-ui-admin-vue3/src/components/Search/src/Search.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 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 { ElButton } from 'element-plus'
 import { useI18n } from '@/hooks/web/useI18n'

+ 1 - 1
yudao-ui-admin-vue3/src/components/Setting/src/components/ColorRadioPicker.vue

@@ -1,5 +1,5 @@
 <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 { useDesign } from '@/hooks/web/useDesign'
 

+ 10 - 1
yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue

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

+ 9 - 6
yudao-ui-admin-vue3/src/views/infra/codegen/components/GenInfoForm.vue

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

+ 1 - 1
yudao-ui-admin-vue3/src/views/infra/codegen/components/ImportTable.vue

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

+ 0 - 2
yudao-ui-admin-vue3/src/views/system/tenant/index.vue

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