增加子表类型生成;表格组件和表单组件,完善泛型支持;
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
<template>vue/vueImport.xml</template>
|
||||
<childTable>
|
||||
<template>category-ref:dao</template>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
@@ -33,12 +34,14 @@
|
||||
<template>vue/vueIndex.xml</template>
|
||||
<template>vue/vueImport.xml</template>
|
||||
<childTable>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
<category value="crud_only_vue_modal" label="单表/主子表 (增删改查,弹窗表单) 仅vue ">
|
||||
<template>category-ref:crud_only_vue</template>
|
||||
<childTable>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
@@ -49,6 +52,7 @@
|
||||
<template>vue/vueIndex.xml</template>
|
||||
<template>vue/vueImport.xml</template>
|
||||
<childTable>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
@@ -64,6 +68,7 @@
|
||||
<template>vue/vueSelect.xml</template>
|
||||
<childTable>
|
||||
<template>category-ref:dao</template>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
@@ -93,6 +98,7 @@
|
||||
<template>vue/vueImport.xml</template>
|
||||
<childTable>
|
||||
<template>category-ref:dao_cloud</template>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
@@ -108,6 +114,7 @@
|
||||
<template>vue/vueSelect.xml</template>
|
||||
<childTable>
|
||||
<template>category-ref:dao_cloud</template>
|
||||
<template>vue/vueApiChild.xml</template>
|
||||
<template>vue/vueFormChildList.xml</template>
|
||||
</childTable>
|
||||
</category>
|
||||
@@ -282,9 +289,9 @@
|
||||
<template>module_cloud/web/db/erm.xml</template>
|
||||
<template>module_cloud/web/src/main/java/package.xml</template>
|
||||
<template>module_cloud/web/src/main/java/startClass.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/bootstrap.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/bootstrap-elk.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/bootstrap-prod.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/application.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/application-elk.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/application-prod.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/logback-spring.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/logback-spring-elk.xml</template>
|
||||
<template>module_cloud/web/src/main/resources/config/logback-spring-prod.xml</template>
|
||||
|
||||
@@ -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}[]; // 子表列表
|
||||
<% } %>
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
No deletion without permission, or be held responsible to law. -->
|
||||
<template>
|
||||
<name>vueApi</name>
|
||||
<filePath>${frontDir}/packages${modulePath}/api${modulePath}${subModulePath}</filePath>
|
||||
<fileName>${@StringUtils.uncap(table.classNameSimple)}.ts</fileName>
|
||||
<content><![CDATA[
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
* No deletion without permission, or be held responsible to law.
|
||||
* @author ${functionAuthor}
|
||||
*/
|
||||
<% if(table.isTreeEntity){ %>
|
||||
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}<%}%>
|
||||
<%
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
}
|
||||
<% %>
|
||||
]]>
|
||||
</content>
|
||||
</template>
|
||||
@@ -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);
|
||||
<% } %>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
<% } %>
|
||||
|
||||
@@ -22,12 +22,7 @@
|
||||
:minHeight="120"
|
||||
:width="400"
|
||||
>
|
||||
<Upload
|
||||
accept=".xls,.xlsx"
|
||||
:file-list="fileList"
|
||||
:before-upload="beforeUpload"
|
||||
@remove="handleRemove"
|
||||
>
|
||||
<Upload accept=".xls,.xlsx" :file-list="fileList" :before-upload="beforeUpload" @remove="handleRemove">
|
||||
<a-button> <Icon icon="ant-design:upload-outlined" /> {{ t('选择文件') }} </a-button>
|
||||
<span class="ml-4">{{ uploadInfo }}</span>
|
||||
</Upload>
|
||||
|
||||
@@ -94,7 +94,7 @@ if(table.isTreeEntity){
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="${compNamePrefix}List">
|
||||
import { unref<% if(toBoolean(table.optionMap['isImportExport'])){ %>, ref<% } %><% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>, watch<% }
|
||||
import { onMounted<% if(toBoolean(table.optionMap['isImportExport'])){ %>, ref<% } %>, unref<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])){ %>, watch<% }
|
||||
%><% if(table.isTreeEntity){ %>, nextTick<% } %> } from 'vue';
|
||||
<% if(@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||
import { useEmitter } from '@jeesite/core/store/modules/user';
|
||||
@@ -111,6 +111,7 @@ if(table.isTreeEntity){
|
||||
import { router } from '@jeesite/core/router';
|
||||
import { Icon } from '@jeesite/core/components/Icon';
|
||||
import { BasicTable, BasicColumn, useTable } from '@jeesite/core/components/Table';
|
||||
import { ${ClassName}, ${className}List } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${funName}';
|
||||
import { ${className}Delete, ${className}ListData } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${funName}';
|
||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||
import { ${className}Disable, ${className}Enable } from '@jeesite/${moduleMinus}/api${modulePath}${subModulePath}/${funName}';
|
||||
@@ -179,6 +180,7 @@ if(table.isTreeEntity){
|
||||
const { t } = useI18n('${moduleName}${subModuleNameDot}.${funName}');
|
||||
const { showMessage } = useMessage();
|
||||
const { meta } = unref(router.currentRoute);
|
||||
const record = ref<${ClassName}>({} as ${ClassName});
|
||||
|
||||
const getTitle = {
|
||||
icon: meta.icon || 'i-ant-design:book-outlined',
|
||||
@@ -191,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: [
|
||||
@@ -285,7 +287,7 @@ if(table.isTreeEntity){
|
||||
<% } %>
|
||||
};
|
||||
|
||||
const tableColumns: BasicColumn[] = [
|
||||
const tableColumns: BasicColumn<${ClassName}>[] = [
|
||||
<%
|
||||
var firstColumn = true;
|
||||
// 生成树表的节点列
|
||||
@@ -355,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}'),
|
||||
@@ -425,9 +427,7 @@ for(c in table.columnList){
|
||||
],
|
||||
};
|
||||
|
||||
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %><%
|
||||
if (table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableFk'])
|
||||
|| toBoolean(table.optionMap['isImportExport'])){ %>, getForm<% } %> }] = useTable({
|
||||
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %>, getForm }] = useTable<${ClassName}>({
|
||||
api: ${className}ListData,
|
||||
beforeFetch: (params) => {
|
||||
<% if(table.isTreeEntity){ %>
|
||||
@@ -449,6 +449,12 @@ for(c in table.columnList){
|
||||
canResize: true,
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const res = await ${className}List();
|
||||
record.value = (res.${className} || {}) as ${ClassName};
|
||||
await getForm().setFieldsValue(record.value);
|
||||
});
|
||||
|
||||
<% if(!@StringUtils.contains(table.tplCategory, '_route')) { %>
|
||||
const [register${modalOrDrawer}, { open${modalOrDrawer} }] = use${modalOrDrawer}();
|
||||
<% } %>
|
||||
@@ -460,10 +466,14 @@ 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],
|
||||
<% } %>
|
||||
});
|
||||
<% } %>
|
||||
reload();
|
||||
await reload();
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -511,14 +521,14 @@ for(c in table.columnList){
|
||||
const params = { ${idParam} };
|
||||
const res = await ${className}Disable(params);
|
||||
showMessage(res.message);
|
||||
handleSuccess(record);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
|
||||
async function handleEnable(record: Recordable) {
|
||||
const params = { ${idParam} };
|
||||
const res = await ${className}Enable(params);
|
||||
showMessage(res.message);
|
||||
handleSuccess(record);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
<% } %>
|
||||
|
||||
@@ -526,11 +536,11 @@ for(c in table.columnList){
|
||||
const params = { ${idParam} };
|
||||
const res = await ${className}Delete(params);
|
||||
showMessage(res.message);
|
||||
handleSuccess(record);
|
||||
await handleSuccess(record);
|
||||
}
|
||||
|
||||
function handleSuccess(record: Recordable) {
|
||||
reload({ record });
|
||||
async function handleSuccess(record: Recordable) {
|
||||
await reload({ record });
|
||||
}
|
||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||
|
||||
|
||||
@@ -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;
|
||||
// 生成树表的节点列
|
||||
|
||||
Reference in New Issue
Block a user