|
@@ -1,21 +1,43 @@
|
|
<template>
|
|
<template>
|
|
<ProForm ref="formRef" :items-options="items" :model="model" :form-options="_formOptions"> </ProForm>
|
|
<ProForm ref="formRef" :items-options="items" :model="model" :form-options="_formOptions"> </ProForm>
|
|
|
|
+ <template v-if="model.tplCategory !== 'crud'">
|
|
|
|
+ <h4 class="form-header">其他信息</h4>
|
|
|
|
+ </template>
|
|
|
|
+ <ProForm ref="formRef2" :items-options="treeItemsOptions" :model="infoForm" :form-options="_formOptions"> </ProForm>
|
|
</template>
|
|
</template>
|
|
<script lang="ts" name="GenBasicInfo" setup>
|
|
<script lang="ts" name="GenBasicInfo" setup>
|
|
-import { defineProps, ref } from 'vue'
|
|
|
|
|
|
+import { defineProps, ref, computed, watch } from 'vue'
|
|
import ProForm from '@/components/ProForm/index.vue'
|
|
import ProForm from '@/components/ProForm/index.vue'
|
|
const formRef = ref<InstanceType<typeof ProForm> | null>(null)
|
|
const formRef = ref<InstanceType<typeof ProForm> | null>(null)
|
|
|
|
+const formRef2 = ref<InstanceType<typeof ProForm> | null>(null)
|
|
export interface InfoProps {
|
|
export interface InfoProps {
|
|
tables: any[] // 表格数据
|
|
tables: any[] // 表格数据
|
|
menus: any[] // 菜单
|
|
menus: any[] // 菜单
|
|
model: any // 详情数据
|
|
model: any // 详情数据
|
|
}
|
|
}
|
|
|
|
|
|
-const prop = withDefaults(defineProps<InfoProps>(), {
|
|
|
|
|
|
+const props = withDefaults(defineProps<InfoProps>(), {
|
|
tables: () => [],
|
|
tables: () => [],
|
|
menus: () => [],
|
|
menus: () => [],
|
|
model: () => null
|
|
model: () => null
|
|
})
|
|
})
|
|
|
|
+const subColumns = ref<any>([])
|
|
|
|
+const setSubTableColumns = (value: string) => {
|
|
|
|
+ props.tables.forEach((item: any) => {
|
|
|
|
+ const name = item.tableName
|
|
|
|
+ if (value === name) {
|
|
|
|
+ subColumns.value = item.columns
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+const infoForm = computed(() => props.model)
|
|
|
|
+watch(
|
|
|
|
+ () => infoForm.value.subTableName,
|
|
|
|
+ val => {
|
|
|
|
+ setSubTableColumns(val)
|
|
|
|
+ }
|
|
|
|
+)
|
|
const tplData = [
|
|
const tplData = [
|
|
{
|
|
{
|
|
label: '单表(增删改查)',
|
|
label: '单表(增删改查)',
|
|
@@ -41,8 +63,125 @@ const genTypeData = [
|
|
}
|
|
}
|
|
]
|
|
]
|
|
const _formOptions = {
|
|
const _formOptions = {
|
|
- hasFooter: false
|
|
|
|
|
|
+ hasFooter: false,
|
|
|
|
+ labelWidth: 160
|
|
|
|
+}
|
|
|
|
+let treeItemsOptions: ProForm.ItemsOptions[] = []
|
|
|
|
+const setItemsOptions = () => {
|
|
|
|
+ treeItemsOptions = [
|
|
|
|
+ {
|
|
|
|
+ label: '树编码字段',
|
|
|
|
+ prop: 'treeCode',
|
|
|
|
+ span: 12,
|
|
|
|
+ tooltip: '树显示的编码字段名, 如:dept_id',
|
|
|
|
+ rules: [{ required: true, message: '树编码字段为空', trigger: 'change' }],
|
|
|
|
+ show: () => {
|
|
|
|
+ return props.model.tplCategory === 'tree'
|
|
|
|
+ },
|
|
|
|
+ compOptions: {
|
|
|
|
+ elTagName: 'select',
|
|
|
|
+ clearable: true,
|
|
|
|
+ style: 'width: 80%',
|
|
|
|
+ enum: props.model.columns.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ label: `${item.columnName}:${item.columnComment}`,
|
|
|
|
+ value: item.columnName
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
|
|
+ placeholder: '请选择'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '树父编码字段',
|
|
|
|
+ prop: 'treeParentCode',
|
|
|
|
+ span: 12,
|
|
|
|
+ tooltip: '树显示的父编码字段名, 如:parent_Id',
|
|
|
|
+ show: () => {
|
|
|
|
+ return props.model.tplCategory === 'tree'
|
|
|
|
+ },
|
|
|
|
+ compOptions: {
|
|
|
|
+ elTagName: 'select',
|
|
|
|
+ clearable: true,
|
|
|
|
+ style: 'width: 80%',
|
|
|
|
+ enum: infoForm.value.columns.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ label: `${item.columnName}:${item.columnComment}`,
|
|
|
|
+ value: item.columnName
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
|
|
+ placeholder: '请选择'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '树名称字段',
|
|
|
|
+ prop: 'treeName',
|
|
|
|
+ span: 12,
|
|
|
|
+ tooltip: '树节点的显示名称字段名, 如:dept_name',
|
|
|
|
+ show: () => {
|
|
|
|
+ return props.model.tplCategory === 'tree'
|
|
|
|
+ },
|
|
|
|
+ compOptions: {
|
|
|
|
+ elTagName: 'select',
|
|
|
|
+ clearable: true,
|
|
|
|
+ style: 'width: 80%',
|
|
|
|
+ enum: props.model.columns.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ label: `${item.columnName}:${item.columnComment}`,
|
|
|
|
+ value: item.columnName
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
|
|
+ placeholder: '请选择'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '关联子表的表名',
|
|
|
|
+ prop: 'subTableName',
|
|
|
|
+ span: 12,
|
|
|
|
+ tooltip: '关联子表的表名, 如:sys_user',
|
|
|
|
+ show: () => {
|
|
|
|
+ return props.model.tplCategory === 'sub'
|
|
|
|
+ },
|
|
|
|
+ compOptions: {
|
|
|
|
+ elTagName: 'select',
|
|
|
|
+ clearable: true,
|
|
|
|
+ style: 'width: 80%',
|
|
|
|
+ enum: props.tables.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ label: `${item.tableName}:${item.tableComment}`,
|
|
|
|
+ value: item.tableName
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
|
|
+ placeholder: '请选择',
|
|
|
|
+ onChange: () => {
|
|
|
|
+ setItemsOptions()
|
|
|
|
+ infoForm.value.subTableFkName = ''
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '子表关联的外键名',
|
|
|
|
+ prop: 'subTableFkName',
|
|
|
|
+ span: 12,
|
|
|
|
+ tooltip: '子表关联的外键名, 如:user_id',
|
|
|
|
+ show: () => {
|
|
|
|
+ return props.model.tplCategory === 'sub'
|
|
|
|
+ },
|
|
|
|
+ compOptions: {
|
|
|
|
+ elTagName: 'select',
|
|
|
|
+ clearable: true,
|
|
|
|
+ style: 'width: 80%',
|
|
|
|
+ enum: subColumns.value.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ label: `${item.columnName}:${item.columnComment}`,
|
|
|
|
+ value: item.columnName
|
|
|
|
+ }
|
|
|
|
+ }),
|
|
|
|
+ placeholder: '请选择'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
}
|
|
}
|
|
|
|
+
|
|
let items: ProForm.ItemsOptions[] = []
|
|
let items: ProForm.ItemsOptions[] = []
|
|
const setItem = () => {
|
|
const setItem = () => {
|
|
items = [
|
|
items = [
|
|
@@ -56,13 +195,19 @@ const setItem = () => {
|
|
clearable: true,
|
|
clearable: true,
|
|
style: 'width: 80%',
|
|
style: 'width: 80%',
|
|
enum: tplData,
|
|
enum: tplData,
|
|
- placeholder: '请输入生成模板'
|
|
|
|
|
|
+ placeholder: '请输入生成模板',
|
|
|
|
+ onChange: (val: string) => {
|
|
|
|
+ if (val !== 'sub') {
|
|
|
|
+ infoForm.value.subTableName = ''
|
|
|
|
+ infoForm.value.subTableFkName = ''
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
label: '生成包路径',
|
|
label: '生成包路径',
|
|
prop: 'packageName',
|
|
prop: 'packageName',
|
|
- tooltip: '生成在哪个java包下,例如 com.taais.system',
|
|
|
|
|
|
+ tooltip: '生成在哪个java包下,例如 com.km.system',
|
|
span: 12,
|
|
span: 12,
|
|
rules: [{ required: true, message: '生成包路径不能为空', trigger: 'blur' }],
|
|
rules: [{ required: true, message: '生成包路径不能为空', trigger: 'blur' }],
|
|
compOptions: {
|
|
compOptions: {
|
|
@@ -119,7 +264,7 @@ const setItem = () => {
|
|
placeholder: '请选择上级菜单',
|
|
placeholder: '请选择上级菜单',
|
|
appendToBody: true,
|
|
appendToBody: true,
|
|
checkStrictly: true,
|
|
checkStrictly: true,
|
|
- enum: prop.menus,
|
|
|
|
|
|
+ enum: props.menus,
|
|
filterable: true,
|
|
filterable: true,
|
|
props: {
|
|
props: {
|
|
value: 'menuId',
|
|
value: 'menuId',
|
|
@@ -135,6 +280,7 @@ const setItem = () => {
|
|
span: 12,
|
|
span: 12,
|
|
compOptions: {
|
|
compOptions: {
|
|
elTagName: 'radio-group',
|
|
elTagName: 'radio-group',
|
|
|
|
+ value: '0',
|
|
enum: genTypeData,
|
|
enum: genTypeData,
|
|
clearable: true,
|
|
clearable: true,
|
|
placeholder: '请输入作者'
|
|
placeholder: '请输入作者'
|
|
@@ -143,7 +289,9 @@ const setItem = () => {
|
|
]
|
|
]
|
|
}
|
|
}
|
|
setItem()
|
|
setItem()
|
|
|
|
+setItemsOptions()
|
|
defineExpose({
|
|
defineExpose({
|
|
- formRef
|
|
|
|
|
|
+ formRef,
|
|
|
|
+ formRef2
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|