diff --git a/modules/core/src/main/resources/templates/modules/gen/config.xml b/modules/core/src/main/resources/templates/modules/gen/config.xml
index 6db14e27..58e7b68c 100644
--- a/modules/core/src/main/resources/templates/modules/gen/config.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/config.xml
@@ -23,6 +23,7 @@
vue/vueImport.xml
category-ref:dao
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
@@ -33,12 +34,14 @@
vue/vueIndex.xml
vue/vueImport.xml
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
category-ref:crud_only_vue
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
@@ -49,6 +52,7 @@
vue/vueIndex.xml
vue/vueImport.xml
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
@@ -64,6 +68,7 @@
vue/vueSelect.xml
category-ref:dao
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
@@ -93,6 +98,7 @@
vue/vueImport.xml
category-ref:dao_cloud
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
@@ -108,6 +114,7 @@
vue/vueSelect.xml
category-ref:dao_cloud
+ vue/vueApiChild.xml
vue/vueFormChildList.xml
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueApi.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueApi.xml
index 155d4dad..1b702bcb 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueApi.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueApi.xml
@@ -20,6 +20,10 @@ import { BasicModel, Page, TreeDataModel } from '@jeesite/core/api/model/baseMod
<% }else{ %>
import { BasicModel, Page } from '@jeesite/core/api/model/baseModel';
<% } %>
+<% // 生成子表列表字段
+for(child in table.childList){ %>
+import { ${child.className} } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${@StringUtils.uncap(child.classNameSimple)}';
+<% } %>
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
import { UploadApiResult } from '@jeesite/core/api/sys/upload';
import { UploadFileParams } from '@jeesite/types/axios';
@@ -59,12 +63,12 @@ for(c in table.columnList){
// 父类对象
if(table.parentExists && table.parentTableFkName == c.columnName){
%>
- ${c.simpleAttrName}?: ${attrType};<% if (isNotBlank(c.comments)){ %> // ${c.comments} 父类<% } %>
+ ${c.simpleAttrName}${c.isRequired == '1' ? '' : '?'}: ${ParentClassName};<% if (isNotBlank(c.comments)){ %> // ${c.comments} 父类<% } %>
<%
// 其它字段
}else{
%>
- ${c.simpleAttrName}?: ${attrType};<%if(isNotBlank(c.comments)){%> // ${c.comments}<%}%>
+ ${c.simpleAttrName}${c.isRequired == '1' ? '' : '?'}: ${attrType};<%if(isNotBlank(c.comments)){%> // ${c.comments}<%}%>
<%
}
}
@@ -73,7 +77,7 @@ for(c in table.columnList){
%>
<% // 生成子表列表字段
for(child in table.childList){ %>
- ${@StringUtils.uncap(child.classNameSimple)}List?: any[]; // 子表列表
+ ${@StringUtils.uncap(child.classNameSimple)}List?: ${child.className}[]; // 子表列表
<% } %>
}
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueApiChild.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueApiChild.xml
new file mode 100644
index 00000000..dd7bf8aa
--- /dev/null
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueApiChild.xml
@@ -0,0 +1,65 @@
+
+
+
+ vueApi
+ ${frontDir}/packages${modulePath}/api${modulePath}${subModulePath}
+ ${@StringUtils.uncap(table.classNameSimple)}.ts
+
+import { TreeModel } from '@jeesite/core/api/model/baseModel';
+<% }else{ %>
+import { BasicModel } from '@jeesite/core/api/model/baseModel';
+<% } %>
+import { ${ParentClassName} } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${funName}';
+
+export interface ${ClassName} extends ${table.isTreeEntity?'Tree':'Basic'}Model<${ClassName}> {
+<%
+isExtend = false;
+// 生成字段属性
+for(c in table.columnList){
+ var attrType = c.simpleAttrType;
+ if (attrType == 'String') attrType = 'string';
+ else if (attrType == 'Long') attrType = 'number';
+ else if (attrType == 'Integer') attrType = 'number';
+ else if (attrType == 'Double') attrType = 'number';
+ else if (attrType == 'BigDecimal') attrType = 'number';
+ else if (attrType == 'Date') attrType = 'string';
+ else attrType = 'any';
+ if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
+ // 如果是Extend类属性
+ if(table.isExtendEntity && c.isExtendColumn){
+ if(!isExtend){
+ isExtend = true;
+%>
+ extend?: any; // 扩展字段
+<%
+ }
+ }
+ // 如果不是基类属性
+ else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
+ // 父类对象
+ if(table.parentExists && table.parentTableFkName == c.columnName){
+%>
+ ${c.simpleAttrName}${c.isRequired == '1' ? '' : '?'}: ${ParentClassName};<% if (isNotBlank(c.comments)){ %> // ${c.comments} 父类<% } %>
+<%
+ // 其它字段
+ }else{
+%>
+ ${c.simpleAttrName}${c.isRequired == '1' ? '' : '?'}: ${attrType};<%if(isNotBlank(c.comments)){%> // ${c.comments}<%}%>
+<%
+ }
+ }
+ }
+}
+%>
+}
+<% %>
+]]>
+
+
\ No newline at end of file
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueForm.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueForm.xml
index 8aeaa61a..3cc2b0ed 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueForm.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueForm.xml
@@ -117,7 +117,7 @@
value: record.value.isNewRecord ? t('新增${functionNameSimple}') : t('编辑${functionNameSimple}'),
}));
- const inputFormSchemas: FormSchema[] = [
+ const inputFormSchemas: FormSchema<${ClassName}>[] = [
<% if(table.isTreeEntity){ %>
{
label: t('上级${functionNameSimple}'),
@@ -428,7 +428,7 @@ for (c in table.columnList){
}
}
%>
- const [registerForm, { resetFields, setFieldsValue<% if(updateSchemas.~size > 0){ %>, updateSchema<% } %>, validate }] = useForm({
+ const [registerForm, { resetFields, setFieldsValue<% if(updateSchemas.~size > 0){ %>, updateSchema<% } %>, validate }] = useForm<${ClassName}>({
labelWidth: 120,
schemas: inputFormSchemas,
<% var formColNum = table.optionMap['formColNum']; %>
@@ -447,7 +447,7 @@ for (c in table.columnList){
record.value.parentName = data.parentName;
}
<% } %>
- setFieldsValue(record.value);
+ await setFieldsValue(record.value);
<% for (child in table.childList){ %>
form${@StringUtils.cap(child.classNameSimple)}ListRef.value?.setTableData(record.value);
<% } %>
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueFormChildList.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueFormChildList.xml
index 1206b66b..f4372770 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueFormChildList.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueFormChildList.xml
@@ -27,6 +27,7 @@
import { Icon } from '@jeesite/core/components/Icon';
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
import { ${ParentClassName} } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${parentClassName}';
+ import { ${ClassName} } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${className}';
<%
var userselectExists = false;
var officeselectExists = false;
@@ -59,7 +60,7 @@
const { t } = useI18n('${moduleName}${subModuleNameDot}.${funName}');
const record = ref<${ParentClassName}>({} as ${ParentClassName});
- const tableColumns: BasicColumn[] = [
+ const tableColumns: BasicColumn<${ClassName}>[] = [
<%
for (c in table.columnList){
if (c.isEdit != '1' || c.isPk == '1'){
@@ -166,11 +167,11 @@ for (c in table.columnList){
<% } %>
];
- const [registerTable, tableAction] = useTable({
+ const [registerTable, tableAction] = useTable<${ClassName}>({
columns: tableColumns,
actionColumn: {
width: 60,
- actions: (record: Recordable) => [
+ actions: (record: ${ClassName}) => [
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueFormRoute.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueFormRoute.xml
index 5d122f73..a868af7a 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueFormRoute.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueFormRoute.xml
@@ -136,7 +136,7 @@ for(c in table.columnList){
setTitle(record.value.isNewRecord ? t('新增${functionNameSimple}') : t('编辑${functionNameSimple}'));
};
- const inputFormSchemas: FormSchema[] = [
+ const inputFormSchemas: FormSchema<${ClassName}>[] = [
<% if(table.isTreeEntity){ %>
{
label: t('上级${functionNameSimple}'),
@@ -368,7 +368,7 @@ for (c in table.columnList){
<%
for (child in table.childList){ %>
- const input${child.className}FormSchemas: FormSchema[] = [
+ const input${child.className}FormSchemas: FormSchema<${ClassName}>[] = [
{
field: '${@StringUtils.uncap(child.classNameSimple)}List',
component: 'Input',
@@ -381,7 +381,7 @@ for (c in table.columnList){
if(false && toBoolean(table.optionMap['isBpmForm'])){
%>
- const inputBpmFormSchemas: FormSchema[] = [
+ const inputBpmFormSchemas: FormSchema<${ClassName}>[] = [
{
label: t('审批意见'),
field: 'bpm.comment',
@@ -459,7 +459,7 @@ for (c in table.columnList){
}
}
%>
- const [registerForm, formAction] = useForm({
+ const [registerForm, formAction] = useForm<${ClassName}>({
labelWidth: 120,
schemas: inputFormSchemas,
<% var formColNum = table.optionMap['formColNum']; %>
@@ -467,16 +467,16 @@ for (c in table.columnList){
});
<% for (child in table.childList){ %>
- const [register${child.className}Form, ${@StringUtils.uncap(child.className)}Form] = useForm({
+ const [register${child.className}Form, ${@StringUtils.uncap(child.className)}Form] = useForm<${ClassName}>({
labelWidth: 120,
schemas: input${child.className}FormSchemas,
baseColProps: { md: 24, lg: 24 },
});
- const [register${child.className}Table, ${@StringUtils.uncap(child.classNameSimple)}Table] = useTable({
+ const [register${child.className}Table, ${@StringUtils.uncap(child.classNameSimple)}Table] = useTable<${ClassName}>({
actionColumn: {
width: 60,
- actions: (record: Recordable) => [
+ actions: (record: ${ClassName}) => [
{
icon: 'i-ant-design:delete-outlined',
color: 'error',
@@ -687,7 +687,7 @@ for (c in table.columnList){
record.value.parentName = data.parentName;
}
<% } %>
- setFieldsValue(record.value);
+ await setFieldsValue(record.value);
<% for (child in table.childList){ %>
set${child.className}TableData(res);
<% } %>
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueImport.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueImport.xml
index bac6af12..7481309c 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueImport.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueImport.xml
@@ -22,12 +22,7 @@
:minHeight="120"
:width="400"
>
-
+
{{ t('选择文件') }}
{{ uploadInfo }}
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml
index ee1f370f..de45a812 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueList.xml
@@ -193,7 +193,7 @@ if(table.isTreeEntity){
const loading = ref(false);
<% } %>
- const searchForm: FormProps = {
+ const searchForm: FormProps<${ClassName}> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
@@ -287,7 +287,7 @@ if(table.isTreeEntity){
<% } %>
};
- const tableColumns: BasicColumn[] = [
+ const tableColumns: BasicColumn<${ClassName}>[] = [
<%
var firstColumn = true;
// 生成树表的节点列
@@ -357,9 +357,9 @@ for(c in table.columnList){
%>
];
- const actionColumn: BasicColumn = {
+ const actionColumn: BasicColumn<${ClassName}> = {
width: 160,
- actions: (record: Recordable) => [
+ actions: (record: ${ClassName}) => [
{
icon: 'i-clarity:note-edit-line',
title: t('编辑${functionNameSimple}'),
@@ -427,7 +427,7 @@ for(c in table.columnList){
],
};
- const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %>, getForm }] = useTable({
+ const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %>, getForm }] = useTable<${ClassName}>({
api: ${className}ListData,
beforeFetch: (params) => {
<% if(table.isTreeEntity){ %>
@@ -466,7 +466,11 @@ for(c in table.columnList){
if (!isEmpty(props.treeCodes)) {
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
await getForm().setFieldsValue({
+ <% if (@StringUtils.contains(table.optionMap['leftTreeRightTableFk'], '.')) { %>
'${table.optionMap['leftTreeRightTableFk']}': props.treeCodes[0],
+ <% } else { %>
+ ${table.optionMap['leftTreeRightTableFk']}: props.treeCodes[0],
+ <% } %>
});
<% } %>
await reload();
diff --git a/modules/core/src/main/resources/templates/modules/gen/vue/vueSelect.xml b/modules/core/src/main/resources/templates/modules/gen/vue/vueSelect.xml
index cfb0b894..340989e9 100644
--- a/modules/core/src/main/resources/templates/modules/gen/vue/vueSelect.xml
+++ b/modules/core/src/main/resources/templates/modules/gen/vue/vueSelect.xml
@@ -44,7 +44,7 @@ const modalProps = {
title: t('${functionNameSimple}选择'),
};
-const searchForm: FormProps = {
+const searchForm: FormProps<${ClassName}> = {
baseColProps: { md: 8, lg: 6 },
labelWidth: 90,
schemas: [
@@ -130,7 +130,7 @@ const searchForm: FormProps = {
],
};
-const tableColumns: BasicColumn[] = [
+const tableColumns: BasicColumn<${ClassName}>[] = [
<%
var firstColumn = true;
// 生成树表的节点列