添加Vue子表生成模板

This commit is contained in:
thinkgem
2021-12-30 23:33:11 +08:00
parent 364752f876
commit b6762cacd0
4 changed files with 407 additions and 201 deletions

View File

@@ -3,7 +3,7 @@
No deletion without permission, or be held responsible to law. --> No deletion without permission, or be held responsible to law. -->
<template> <template>
<name>vueApi</name> <name>vueApi</name>
<filePath>vue/src/api/${moduleName}/${subModuleName}</filePath> <filePath>src/api/${moduleName}/${subModuleName}</filePath>
<fileName>${className}.ts</fileName> <fileName>${className}.ts</fileName>
<content><![CDATA[ <content><![CDATA[
/** /**
@@ -26,39 +26,39 @@ export interface ${ClassName} extends ${table.isTreeEntity?'Tree':'Basic'}Model<
isExtend = false; isExtend = false;
// 生成字段属性 // 生成字段属性
for(c in table.columnList){ for(c in table.columnList){
var attrType = c.simpleAttrType; var attrType = c.simpleAttrType;
if (attrType == 'String') attrType = 'string'; if (attrType == 'String') attrType = 'string';
else if (attrType == 'Long') attrType = 'number'; else if (attrType == 'Long') attrType = 'number';
else if (attrType == 'Integer') attrType = 'number'; else if (attrType == 'Integer') attrType = 'number';
else if (attrType == 'Double') attrType = 'number'; else if (attrType == 'Double') attrType = 'number';
else if (attrType == 'BigDecimal') attrType = 'number'; else if (attrType == 'BigDecimal') attrType = 'number';
else if (attrType == 'Date') attrType = 'string'; else if (attrType == 'Date') attrType = 'string';
else attrType = 'any'; else attrType = 'any';
if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){ if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
// 如果是Extend类属性 // 如果是Extend类属性
if(table.isExtendEntity && c.isExtendColumn){ if(table.isExtendEntity && c.isExtendColumn){
if(!isExtend){ if(!isExtend){
isExtend = true; isExtend = true;
%> %>
extend?: any; // 扩展字段 extend?: any; // 扩展字段
<% <%
} }
} }
// 如果不是基类属性 // 如果不是基类属性
else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){ else if(!@StringUtils.equalsIgnoreCase(c.columnName, 'id') && !c.isSuperColumn){
// 父类对象 // 父类对象
if(table.parentExists && table.parentTableFkName == c.columnName){ if(table.parentExists && table.parentTableFkName == c.columnName){
%> %>
${c.simpleAttrName}?: ${attrType};<% if (isNotBlank(c.comments)){ %> // ${c.comments} 父类<% } %> ${c.simpleAttrName}?: ${attrType};<% if (isNotBlank(c.comments)){ %> // ${c.comments} 父类<% } %>
<% <%
// 其它字段 // 其它字段
}else{ }else{
%> %>
${c.simpleAttrName}?: ${attrType};<%if(isNotBlank(c.comments)){%> // ${c.comments}<%}%> ${c.simpleAttrName}?: ${attrType};<%if(isNotBlank(c.comments)){%> // ${c.comments}<%}%>
<% <%
} }
} }
} }
} }
%> %>
<% // 生成子表列表字段 <% // 生成子表列表字段

View File

@@ -3,7 +3,7 @@
No deletion without permission, or be held responsible to law. --> No deletion without permission, or be held responsible to law. -->
<template> <template>
<name>vueForm</name> <name>vueForm</name>
<filePath>vue/src/views/${urlPrefix}</filePath> <filePath>src/views/${urlPrefix}</filePath>
<fileName>form.vue</fileName> <fileName>form.vue</fileName>
<content><![CDATA[ <content><![CDATA[
<!-- <!--
@@ -24,7 +24,25 @@
<Icon :icon="getTitle.icon" class="pr-1 m-1" /> <Icon :icon="getTitle.icon" class="pr-1 m-1" />
<span> {{ getTitle.value }} </span> <span> {{ getTitle.value }} </span>
</template> </template>
<% if (table.childList.~size > 0){ %>
<BasicForm @register="registerForm">
<% for (child in table.childList){ %>
<template #${@StringUtils.uncap(child.className)}List>
<BasicTable
@register="register${child.className}Table"
@row-click="handle${child.className}RowClick"
/>
<% if(table.tplCategory != 'query'){ %>
<a-button class="mt-2" @click="handle${child.className}Add" v-auth="'${permissionPrefix}:edit'">
<Icon icon="ant-design:plus-circle-outlined" /> {{ t('新增') }}
</a-button>
<% } %>
</template>
<% } %>
</BasicForm>
<% }else{ %>
<BasicForm @register="registerForm" /> <BasicForm @register="registerForm" />
<% } %>
</BasicDrawer> </BasicDrawer>
</template> </template>
<script lang="ts"> <script lang="ts">
@@ -39,6 +57,9 @@
import { router } from '/@/router'; import { router } from '/@/router';
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
import { BasicForm, FormSchema, useForm } from '/@/components/Form'; import { BasicForm, FormSchema, useForm } from '/@/components/Form';
<% if (table.childList.~size > 0){ %>
import { BasicTable, useTable } from '/@/components/Table';
<% } %>
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { ${className}Save, ${className}Form<% if(table.isTreeEntity){ %>, ${className}TreeData<% } %> } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}'; import { ${className}Save, ${className}Form<% if(table.isTreeEntity){ %>, ${className}TreeData<% } %> } from '/@/api/${moduleName}${isNotEmpty(subModuleName)?'/'+subModuleName:''}/${className}';
<% <%
@@ -46,15 +67,15 @@ var userselectExists = false;
var officeselectExists = false; var officeselectExists = false;
var areaselectExists = false; var areaselectExists = false;
for(c in table.columnList){ for(c in table.columnList){
if(c.isQuery == "1" && !c.isTreeEntityColumn){ if(c.isQuery == "1" && !c.isTreeEntityColumn){
if(c.showType == 'userselect'){ if(c.showType == 'userselect'){
userselectExists = true; userselectExists = true;
}else if(c.showType == 'officeselect'){ }else if(c.showType == 'officeselect'){
officeselectExists = true; officeselectExists = true;
}else if(c.showType == 'areaselect'){ }else if(c.showType == 'areaselect'){
areaselectExists = true; areaselectExists = true;
} }
} }
} }
%> %>
<% if(userselectExists || officeselectExists) { %> <% if(userselectExists || officeselectExists) { %>
@@ -75,7 +96,7 @@ for(c in table.columnList){
}; };
const inputFormSchemas: FormSchema[] = [ const inputFormSchemas: FormSchema[] = [
<% if(table.isTreeEntity){ %> <% if(table.isTreeEntity){ %>
{ {
label: t('上级${functionNameSimple}'), label: t('上级${functionNameSimple}'),
field: 'parentCode', field: 'parentCode',
@@ -87,29 +108,29 @@ for(c in table.columnList){
}, },
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
}, },
<% } <% }
for (c in table.columnList){ for (c in table.columnList){
if (c.isEdit == '1' && c.showType != 'hidden'){ if (c.isEdit == '1' && c.showType != 'hidden'){
// 如果是树结构的字段,则自动忽略 // 如果是树结构的字段,则自动忽略
if(table.isTreeEntity && @StringUtils.inString(c.columnName, 'parent_code', if(table.isTreeEntity && @StringUtils.inString(c.columnName, 'parent_code',
'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names') 'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names')
&& c.attrName != table.treeViewCodeAttrName && c.attrName != table.treeViewCodeAttrName
&& c.attrName != table.treeViewNameAttrName){ && c.attrName != table.treeViewNameAttrName){
continue; continue;
} }
// 是否强制新行获取,生成字段界面用户设定的 // 是否强制新行获取,生成字段界面用户设定的
var isNewLine = @Global.YES.equals(c.optionMap['isNewLine']); var isNewLine = @Global.YES.equals(c.optionMap['isNewLine']);
if (isBlank(c.optionMap['isNewLine'])){ if (isBlank(c.optionMap['isNewLine'])){
if (c.showType == 'textarea'){ if (c.showType == 'textarea'){
isNewLine = true; isNewLine = true;
} }
} }
%> %>
{ {
label: t('${c.columnLabel}'), label: t('${c.columnLabel}'),
field: '${c.attrName}', field: '${c.attrName}',
<% if(c.showType == 'input' || c.showType == 'textarea'){ %> <% if(c.showType == 'input' || c.showType == 'textarea'){ %>
<% if (c.simpleAttrType == 'Integer' && c.attrName == 'treeSort'){ %> <% if (c.simpleAttrType == 'Integer' && c.attrName == 'treeSort'){ %>
helpMessage: '升序', helpMessage: '升序',
component: 'InputNumber', component: 'InputNumber',
defaultValue: '30', defaultValue: '30',
@@ -120,9 +141,9 @@ for (c in table.columnList){
componentProps: { componentProps: {
maxlength: ${c.dataLength}, maxlength: ${c.dataLength},
}, },
<% } %> <% } %>
<% }else if(c.showType == 'select' || c.showType == 'select_multiple'){ <% }else if(c.showType == 'select' || c.showType == 'select_multiple'){
var isMultiple = (c.showType == 'select_multiple'); %> var isMultiple = (c.showType == 'select_multiple'); %>
component: 'Select', component: 'Select',
componentProps: { componentProps: {
dictType: '${c.optionMap['dictType']}', dictType: '${c.optionMap['dictType']}',
@@ -137,7 +158,7 @@ for (c in table.columnList){
dictType: '${c.optionMap['dictType']}', dictType: '${c.optionMap['dictType']}',
}, },
<% }else if(c.showType == 'date' || c.showType == 'datetime'){ <% }else if(c.showType == 'date' || c.showType == 'datetime'){
var isTime = (c.showType == 'datetime'); %> var isTime = (c.showType == 'datetime'); %>
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
format: 'YYYY-MM-DD${isTime?' HH:mm':''}', format: 'YYYY-MM-DD${isTime?' HH:mm':''}',
@@ -161,6 +182,7 @@ for (c in table.columnList){
component: 'TreeSelect', component: 'TreeSelect',
componentProps: { componentProps: {
api: officeTreeData, api: officeTreeData,
canSelectParent: false,
allowClear: true, allowClear: true,
}, },
<% }else if(c.showType == 'areaselect'){ <% }else if(c.showType == 'areaselect'){
@@ -170,81 +192,82 @@ for (c in table.columnList){
component: 'TreeSelect', component: 'TreeSelect',
componentProps: { componentProps: {
api: areaTreeData, api: areaTreeData,
canSelectParent: false,
allowClear: true, allowClear: true,
}, },
<% }else{ %> <% }else{ %>
component: 'Input', component: 'Input',
<% } <% }
var fieldValid = c.optionMap['fieldValid'], fvs = [], rules = []; var fieldValid = c.optionMap['fieldValid'], fvs = [], rules = [];
if(isNotEmpty(fieldValid)){ if(isNotEmpty(fieldValid)){
var t = type.name(fieldValid); var t = type.name(fieldValid);
if (t == 'String[]' || t == 'ArrayList'){ if (t == 'String[]' || t == 'ArrayList'){
fvs = fieldValid; fvs = fieldValid;
}else if(t == 'String' && isNotBlank(fieldValid)){ }else if(t == 'String' && isNotBlank(fieldValid)){
@fvs.add(fieldValid); @fvs.add(fieldValid);
} }
} }
for(var fv in fvs){ for(var fv in fvs){
if (fv == 'email'){ if (fv == 'email'){
var s = { %>{ type: 'email', message: t('请输入邮箱地址') }<% }; var s = { %>{ type: 'email', message: t('请输入邮箱地址') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'number'){ if (fv == 'number'){
var s = { %>{ pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/, message: t('请输入一个数值') }<% }; var s = { %>{ pattern: /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/, message: t('请输入一个数值') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'integer'){ if (fv == 'integer'){
var s = { %>{ pattern: /^-?\d+$/, message: t('请输入一个整数') }<% }; var s = { %>{ pattern: /^-?\d+$/, message: t('请输入一个整数') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'digits'){ if (fv == 'digits'){
var s = { %>{ pattern: /^\d+$/, message: t('请输入一个正整数') }<% }; var s = { %>{ pattern: /^\d+$/, message: t('请输入一个正整数') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'userName'){ if (fv == 'userName'){
var s = { %>{ pattern: /^[\u0391-\uFFE5\w]+$/, message: t('请输入登录账号') }<% }; var s = { %>{ pattern: /^[\u0391-\uFFE5\w]+$/, message: t('请输入登录账号') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'realName'){ if (fv == 'realName'){
var s = { %>{ pattern: /^[\u4e00-\u9fa5]{2,30}$/, message: t('请输入真实姓名') }<% }; var s = { %>{ pattern: /^[\u4e00-\u9fa5]{2,30}$/, message: t('请输入真实姓名') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'abc'){ if (fv == 'abc'){
var s = { %>{ pattern: /^[a-zA-Z0-9_]*$/, message: t('请输入字母数字下划线') }<% }; var s = { %>{ pattern: /^[a-zA-Z0-9_]*$/, message: t('请输入字母数字下划线') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'mobile'){ if (fv == 'mobile'){
var s = { %>{ pattern: /^1[3,4,5,6,7,8,9]\d{9}$/g, message: t('请输入手机号码') }<% }; var s = { %>{ pattern: /^1[3,4,5,6,7,8,9]\d{9}$/g, message: t('请输入手机号码') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'simplePhone'){ if (fv == 'simplePhone'){
var s = { %>{ pattern: /^(\d{3,4}-?)?\d{7,9}$/g, message: t('请输入固话号码') }<% }; var s = { %>{ pattern: /^(\d{3,4}-?)?\d{7,9}$/g, message: t('请输入固话号码') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'phone'){ if (fv == 'phone'){
var s = { %>{ pattern: /(^0[1-9]{1}\d{8,10}$)|(^1[3,4,5,6,7,8,9]\d{9}$)/g, message: t('请输入固话或手机号码') }<% }; var s = { %>{ pattern: /(^0[1-9]{1}\d{8,10}$)|(^1[3,4,5,6,7,8,9]\d{9}$)/g, message: t('请输入固话或手机号码') }<% };
@rules.add(s); @rules.add(s);
} }
if (fv == 'zipCode'){ if (fv == 'zipCode'){
var s = { %>{ pattern: /^[0-9]{6}$/, message: t('请输入邮政编码') }<% }; var s = { %>{ pattern: /^[0-9]{6}$/, message: t('请输入邮政编码') }<% };
@rules.add(s); @rules.add(s);
} }
} }
if(rules.~size == 0){ if(rules.~size == 0){
if(c.isRequired == '1'){ if(c.isRequired == '1'){
%> required: true, %> required: true,
<% <%
} }
} else { %> } else { %>
rules: [<% rules: [<%
if(c.isRequired == '1'){ if(c.isRequired == '1'){
%>{ required: true }, <% %>{ required: true }, <%
} }
for (var rule in rules){ for (var rule in rules){
print(rule); print(rule);
if (ruleLP.index < rules.~size) { if (ruleLP.index < rules.~size) {
print(', '); print(', ');
} }
} %>], } %>],
<% <%
} }
@@ -254,16 +277,26 @@ for (c in table.columnList){
} }
%> %>
}, },
<% <%
} }
} }
for (child in table.childList){ %>
{
label: t('${child.comments}'),
field: '${@StringUtils.uncap(child.className)}List',
component: 'Input',
colProps: { lg: 24, md: 24 },
slot: '${@StringUtils.uncap(child.className)}List',
},
<%
}
%> %>
]; ];
<% <%
var updateSchemas = []; var updateSchemas = [];
if(table.isTreeEntity){ if(table.isTreeEntity){
var s = { var s = {
%> { %> {
field: 'parentCode', field: 'parentCode',
componentProps: { componentProps: {
api: ${className}TreeData, api: ${className}TreeData,
@@ -273,29 +306,196 @@ for (c in table.columnList){
}, },
}, },
},<% },<%
}; };
@updateSchemas.add(s); @updateSchemas.add(s);
} }
for (c in table.columnList){ for (c in table.columnList){
if (c.isPk == '1' && c.showType == 'input'){ if (c.isPk == '1' && c.showType == 'input'){
var s = { var s = {
%> { %> {
field: '${c.attrName}', field: '${c.attrName}',
componentProps: { componentProps: {
disabled: !record.value.isNewRecord, disabled: !record.value.isNewRecord,
}, },
},<% },<%
}; };
@updateSchemas.add(s); @updateSchemas.add(s);
} }
} }
%> %>
const [registerForm, { resetFields, setFieldsValue<% if(updateSchemas.~size > 0){ %>, updateSchema<% } %>, validate }] = useForm({ const [registerForm, { resetFields, setFieldsValue<% if(updateSchemas.~size > 0){ %>, updateSchema<% } %>, validate }] = useForm({
labelWidth: 120, labelWidth: 120,
schemas: inputFormSchemas, schemas: inputFormSchemas,
<% var formColNum = table.optionMap['formColNum']; %> <% var formColNum = table.optionMap['formColNum']; %>
baseColProps: { lg: ${formColNum=="1"?24:formColNum=="3"?8:12}, md: 24 }, baseColProps: { lg: ${formColNum=="1"?24:formColNum=="3"?8:12}, md: 24 },
}); });
<% for (child in table.childList){ %>
const [register${child.className}Table, ${@StringUtils.uncap(child.className)}Table] = useTable({
actionColumn: {
width: 60,
actions: (record: Recordable) => [
{
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
confirm: handle${child.className}Delete.bind(this, record),
},
auth: '${permissionPrefix}:edit',
},
],
},
rowKey: 'id',
pagination: false,
bordered: true,
size: 'small',
inset: true,
});
async function set${child.className}TableData(_res: Recordable) {
${@StringUtils.uncap(child.className)}Table.setColumns([
<%
for (c in child.columnList){
if (c.isEdit != '1' || c.isPk == '1'){
continue;
}
if(child.parentExists && child.parentTableFkName == c.columnName){
continue;
}
%>
{
title: t('${c.columnLabel}'),
dataIndex: '${c.attrName}',
<% if(c.showType == 'datetime'){ %>
width: 215,
<% }else{ %>
width: 130,
<% } %>
<% if ((isNotBlank(c.optionMap['dictType']) || @StringUtils.inString(c.attrType, 'java.util.Date', 'Integer', 'Long'))){ %>
align: 'center',
<% }else if (@StringUtils.inString(c.attrType, 'Float', 'Double')){ %>
align: 'right',
<% }else{ %>
align: 'left',
<% } %>
<% if(c.showType == 'select' || c.showType == 'select_multiple' || c.showType == 'checkbox' || c.showType == 'radio'){ %>
dictType: '${c.optionMap['dictType']}',
<% } %>
editRow: true,
<% if(c.showType == 'input' || c.showType == 'textarea'){ %>
<% if (c.simpleAttrType == 'Integer' && c.attrName == 'treeSort'){ %>
editComponent: 'InputNumber',
editDefaultValue: '30',
<% }else{ %>
editComponent: 'Input',
<% } %>
<% if (c.dataLength != '0'){ %>
editComponentProps: {
maxlength: ${c.dataLength},
},
<% } %>
<% }else if(c.showType == 'select' || c.showType == 'select_multiple' || c.showType == 'radio' || c.showType == 'checkbox'){
var isMultiple = (c.showType == 'select_multiple'); %>
editComponent: 'Select',
editComponentProps: {
dictType: '${c.optionMap['dictType']}',
allowClear: true,
<% if(isMultiple){ %>
mode: 'multiple',
<% } %>
},
<% }else if(c.showType == 'date' || c.showType == 'datetime'){
var isTime = (c.showType == 'datetime'); %>
editComponent: 'DatePicker',
editComponentProps: {
format: 'YYYY-MM-DD${isTime?' HH:mm':''}',
showTime: ${isTime?'{ format: \'HH:mm\' \}':'false'},
},
<% }else if(c.showType == 'userselect'){
if (isNotBlank(c.attrName2)){ %>
dataLabel: '${c.attrName2}',
<% } %>
editComponent: 'TreeSelect',
editComponentProps: {
api: officeTreeData,
params: { isLoadUser: true, userIdPrefix: '' },
canSelectParent: false,
allowClear: true,
},
<% }else if(c.showType == 'officeselect'){
if (isNotBlank(c.attrName2)){ %>
dataLabel: '${c.attrName2}',
<% } %>
editComponent: 'TreeSelect',
editComponentProps: {
api: officeTreeData,
canSelectParent: false,
allowClear: true,
},
<% }else if(c.showType == 'areaselect'){
if (isNotBlank(c.attrName2)){ %>
dataLabel: '${c.attrName2}',
<% } %>
editComponent: 'TreeSelect',
editComponentProps: {
api: areaTreeData,
canSelectParent: false,
allowClear: true,
},
<% }else{ %>
editComponent: 'Input',
<% } %>
editRule: ${c.isRequired == '1'},
},
<%
}
%>
]);
${@StringUtils.uncap(child.className)}Table.setTableData(record.value.${@StringUtils.uncap(child.className)}List || []);
}
function handle${child.className}RowClick(record: Recordable) {
record.onEdit?.(true, false);
}
function handle${child.className}Add() {
${@StringUtils.uncap(child.className)}Table.insertTableDataRecord({
id: new Date().getTime(),
isNewRecord: true,
editable: true,
});
}
function handle${child.className}Delete(record: Recordable) {
${@StringUtils.uncap(child.className)}Table.deleteTableDataRecord(record);
}
async function get${child.className}List() {
let ${@StringUtils.uncap(child.className)}ListValid = true;
let ${@StringUtils.uncap(child.className)}List: Recordable[] = [];
for (const record of ${@StringUtils.uncap(child.className)}Table.getDataSource()) {
if (!(await record.onEdit?.(false, true))) {
${@StringUtils.uncap(child.className)}ListValid = false;
}
${@StringUtils.uncap(child.className)}List.push({
...record,
id: !!record.isNewRecord ? '' : record.id,
});
}
for (const record of ${@StringUtils.uncap(child.className)}Table.getDelDataSource()) {
if (!!record.isNewRecord) continue;
${@StringUtils.uncap(child.className)}List.push({
...record,
status: '1',
});
}
if (!${@StringUtils.uncap(child.className)}ListValid) {
throw new Error('${@StringUtils.uncap(child.className)}List valid.');
}
return ${@StringUtils.uncap(child.className)}List;
}
<% } %>
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
resetFields(); resetFields();
@@ -309,10 +509,13 @@ for (c in table.columnList){
} }
<% } %> <% } %>
setFieldsValue(record.value); setFieldsValue(record.value);
<% for (child in table.childList){ %>
set${child.className}TableData(res);
<% } %>
<% if(updateSchemas.~size > 0){ %> <% if(updateSchemas.~size > 0){ %>
updateSchema([ updateSchema([
<% for(updateSchema in updateSchemas){ <% for(updateSchema in updateSchemas){
print(updateSchema + '\n'); print(updateSchema + '\n');
} %> } %>
]); ]);
<% } %> <% } %>
@@ -327,13 +530,16 @@ for (c in table.columnList){
isNewRecord: record.value.isNewRecord, isNewRecord: record.value.isNewRecord,
<% <%
for (c in table.columnList){ for (c in table.columnList){
if (c.isPk == '1' || c.showType == 'hidden'){ %> if (c.isPk == '1' || c.showType == 'hidden'){ %>
${c.attrName}: record.value.${c.attrName}, ${c.attrName}: record.value.${c.attrName},
<% <%
} }
} }
%> %>
}; };
<% for (child in table.childList){ %>
data.${@StringUtils.uncap(child.className)}List = await get${child.className}List();
<% } %>
// console.log('submit', params, data, record); // console.log('submit', params, data, record);
const res = await ${className}Save(params, data); const res = await ${className}Save(params, data);
showMessage(res.message); showMessage(res.message);

View File

@@ -3,7 +3,7 @@
No deletion without permission, or be held responsible to law. --> No deletion without permission, or be held responsible to law. -->
<template> <template>
<name>vueIndex</name> <name>vueIndex</name>
<filePath>vue/src/views/${urlPrefix}</filePath> <filePath>src/views/${urlPrefix}</filePath>
<fileName>index.vue</fileName> <fileName>index.vue</fileName>
<content><![CDATA[ <content><![CDATA[
<% if(table.isTreeEntity){ %> <% if(table.isTreeEntity){ %>

View File

@@ -3,7 +3,7 @@
No deletion without permission, or be held responsible to law. --> No deletion without permission, or be held responsible to law. -->
<template> <template>
<name>vueList</name> <name>vueList</name>
<filePath>vue/src/views/${urlPrefix}</filePath> <filePath>src/views/${urlPrefix}</filePath>
<fileName>list.vue</fileName> <fileName>list.vue</fileName>
<content><![CDATA[ <content><![CDATA[
<!-- <!--
@@ -19,7 +19,7 @@
<span> {{ getTitle.value }} </span> <span> {{ getTitle.value }} </span>
</template> </template>
<template #toolbar> <template #toolbar>
<% if(table.isTreeEntity){ %> <% if(table.isTreeEntity){ %>
<a-button @click="expandAll" :title="t('展开一级')"> <a-button @click="expandAll" :title="t('展开一级')">
<Icon icon="bi:chevron-double-down" /> {{ t('展开') }} <Icon icon="bi:chevron-double-down" /> {{ t('展开') }}
</a-button> </a-button>
@@ -33,14 +33,14 @@
</template> </template>
<template #firstColumn="{ record }"> <template #firstColumn="{ record }">
<% <%
var idParam = ''; var idParam = '';
for(pk in table.pkList){ for(pk in table.pkList){
idParam = idParam + pk.attrName + ': record.' + pk.attrName; idParam = idParam + pk.attrName + ': record.' + pk.attrName;
if (pkLP.index == table.pkList.~size - 1) { if (pkLP.index == table.pkList.~size - 1) {
idParam = idParam + ', '; idParam = idParam + ', ';
} }
} }
if(table.isTreeEntity){ if(table.isTreeEntity){
%> %>
<span class="cursor-pointer" @click="expandCollapse(record)"> <span class="cursor-pointer" @click="expandCollapse(record)">
( {{ record.${table.treeViewCodeAttrName} }} ) ( {{ record.${table.treeViewCodeAttrName} }} )
@@ -49,25 +49,25 @@
{{ record.${table.treeViewNameAttrName} }} {{ record.${table.treeViewNameAttrName} }}
</a> </a>
<% <%
}else{ }else{
for(c in table.columnList){ for(c in table.columnList){
if(c.isList == "1"){ if(c.isList == "1"){
// 如果是树结构的字段,则自动忽略 // 如果是树结构的字段,则自动忽略
if(table.isTreeEntity && @StringUtils.inString(c.columnName, 'parent_code', if(table.isTreeEntity && @StringUtils.inString(c.columnName, 'parent_code',
'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names') 'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names')
&& c.attrName != table.treeViewCodeAttrName && c.attrName != table.treeViewCodeAttrName
&& c.attrName != table.treeViewNameAttrName){ && c.attrName != table.treeViewNameAttrName){
continue; continue;
} }
%> %>
<a @click="handleForm({ ${idParam} })"> <a @click="handleForm({ ${idParam} })">
{{ record.${c.attrName} }} {{ record.${c.attrName} }}
</a> </a>
<% <%
break; break;
} }
} }
} }
%> %>
</template> </template>
</BasicTable> </BasicTable>
@@ -95,15 +95,15 @@ var userselectExists = false;
var officeselectExists = false; var officeselectExists = false;
var areaselectExists = false; var areaselectExists = false;
for(c in table.columnList){ for(c in table.columnList){
if(c.isQuery == "1" && !c.isTreeEntityColumn){ if(c.isQuery == "1" && !c.isTreeEntityColumn){
if(c.showType == 'userselect'){ if(c.showType == 'userselect'){
userselectExists = true; userselectExists = true;
}else if(c.showType == 'officeselect'){ }else if(c.showType == 'officeselect'){
officeselectExists = true; officeselectExists = true;
}else if(c.showType == 'areaselect'){ }else if(c.showType == 'areaselect'){
areaselectExists = true; areaselectExists = true;
} }
} }
} }
%> %>
<% if(userselectExists || officeselectExists) { %> <% if(userselectExists || officeselectExists) { %>
@@ -148,7 +148,7 @@ for(c in table.columnList){
component: 'Input', component: 'Input',
<% } %> <% } %>
<% }else if(c.showType == 'select' || c.showType == 'select_multiple'){ <% }else if(c.showType == 'select' || c.showType == 'select_multiple'){
var isMultiple = (c.showType == 'select_multiple'); %> var isMultiple = (c.showType == 'select_multiple'); %>
component: 'Select', component: 'Select',
componentProps: { componentProps: {
dictType: '${c.optionMap['dictType']}', dictType: '${c.optionMap['dictType']}',
@@ -163,7 +163,7 @@ for(c in table.columnList){
dictType: '${c.optionMap['dictType']}', dictType: '${c.optionMap['dictType']}',
}, },
<% }else if(c.showType == 'date' || c.showType == 'datetime'){ <% }else if(c.showType == 'date' || c.showType == 'datetime'){
var isTime = (c.showType == 'datetime'); %> var isTime = (c.showType == 'datetime'); %>
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
format: 'YYYY-MM-DD${isTime?' HH:mm':''}', format: 'YYYY-MM-DD${isTime?' HH:mm':''}',
@@ -214,9 +214,9 @@ for(c in table.columnList){
var firstColumn = true; var firstColumn = true;
// 生成树表的节点列 // 生成树表的节点列
if(table.isTreeEntity){ if(table.isTreeEntity){
for(c in table.columnList){ for(c in table.columnList){
if(c.attrName == table.treeViewNameAttrName){ if(c.attrName == table.treeViewNameAttrName){
%> %>
{ {
title: t('${c.columnLabel}'), title: t('${c.columnLabel}'),
dataIndex: '${c.attrName}', dataIndex: '${c.attrName}',
@@ -224,21 +224,21 @@ if(table.isTreeEntity){
align: 'left', align: 'left',
slots: { customRender: 'firstColumn' }, slots: { customRender: 'firstColumn' },
}, },
<% <%
firstColumn = false; firstColumn = false;
break; break;
} }
} }
} }
for(c in table.columnList){ for(c in table.columnList){
if(c.isList == "1"){ if(c.isList == "1"){
// 如果是树结构的字段,则自动忽略 // 如果是树结构的字段,则自动忽略
if(table.isTreeEntity && (@StringUtils.inString(c.columnName, 'parent_code', if(table.isTreeEntity && (@StringUtils.inString(c.columnName, 'parent_code',
'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names') 'parent_codes', 'tree_sorts', 'tree_leaf', 'tree_level', 'tree_names')
|| c.attrName == table.treeViewCodeAttrName || c.attrName == table.treeViewCodeAttrName
|| c.attrName == table.treeViewNameAttrName)){ || c.attrName == table.treeViewNameAttrName)){
continue; continue;
} }
%> %>
{ {
title: t('${c.columnLabel}'), title: t('${c.columnLabel}'),
@@ -271,10 +271,10 @@ for(c in table.columnList){
<% } %> <% } %>
}, },
<% <%
if(firstColumn){ if(firstColumn){
firstColumn = false; firstColumn = false;
} }
} }
} }
%> %>
]; ];
@@ -342,11 +342,11 @@ for(c in table.columnList){
const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %> }] = useTable({ const [registerTable, { reload<% if(table.isTreeEntity){ %>, expandAll, collapseAll, expandCollapse<% } %> }] = useTable({
api: ${className}ListData, api: ${className}ListData,
beforeFetch: (params) => { beforeFetch: (params) => {
<% if(table.isTreeEntity){ %> <% if(table.isTreeEntity){ %>
<% for(pk in table.pkList){ %> <% for(pk in table.pkList){ %>
params.${pk.attrName} = props.treeCode; params.${pk.attrName} = props.treeCode;
<% } %> <% } %>
<% } %> <% } %>
return params; return params;
}, },
columns: tableColumns, columns: tableColumns,