|
|
@@ -277,7 +277,7 @@ export function useGridColumns(
|
|
|
];
|
|
|
}
|
|
|
|
|
|
-// TODO @puhui999: 标准模式和内嵌模式时,主子关系一对一则生成表单schema,一对多则生成列表schema(内嵌模式时表单schema也要生成)。erp 模式时都生成
|
|
|
+## 标准模式和内嵌模式时,主子关系一对一则生成表单schema,一对多则生成列表schema(内嵌模式时表单schema也要生成)。erp 模式时都生成
|
|
|
## 特殊:主子表专属逻辑
|
|
|
#foreach ($subTable in $subTables)
|
|
|
#set ($index = $foreach.count - 1)
|
|
|
@@ -285,6 +285,7 @@ export function useGridColumns(
|
|
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
|
|
#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
|
|
|
// ==================== 子表($subTable.classComment) ====================
|
|
|
+#if ($table.templateType == 11) ## erp 情况
|
|
|
/** 新增/修改的表单 */
|
|
|
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
|
|
return [
|
|
|
@@ -402,7 +403,7 @@ export function use${subSimpleClassName}GridColumns(
|
|
|
): VxeTableGridOptions<${subSimpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
|
return [
|
|
|
#foreach($column in $subColumns)
|
|
|
- #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
|
|
+ #if ($column.listOperationResult)
|
|
|
#set ($dictType = $column.dictType)
|
|
|
#set ($javaField = $column.javaField)
|
|
|
#set ($comment = $column.columnComment)
|
|
|
@@ -410,14 +411,24 @@ export function use${subSimpleClassName}GridColumns(
|
|
|
field: '${javaField}',
|
|
|
title: '${comment}',
|
|
|
minWidth: 120,
|
|
|
- slots: { default: '${javaField}' },
|
|
|
+ #if ($column.javaType == "LocalDateTime")## 时间类型
|
|
|
+ formatter: 'formatDateTime',
|
|
|
+ #elseif("" != $dictType)## 数据字典
|
|
|
+ cellRender: {
|
|
|
+ name: 'CellDict',
|
|
|
+ props: { type: DICT_TYPE.$dictType.toUpperCase() },
|
|
|
+ },
|
|
|
+ #end
|
|
|
+ #if (${table.templateType} == 2 && $column.id == $treeNameColumn.id)## 树表特有:标记树节点列
|
|
|
+ treeNode: true,
|
|
|
+ #end
|
|
|
},
|
|
|
#end
|
|
|
#end
|
|
|
{
|
|
|
field: 'operation',
|
|
|
title: '操作',
|
|
|
- minWidth: 60,
|
|
|
+ minWidth: 200,
|
|
|
align: 'center',
|
|
|
fixed: 'right',
|
|
|
headerAlign: 'center',
|
|
|
@@ -430,13 +441,188 @@ export function use${subSimpleClassName}GridColumns(
|
|
|
},
|
|
|
name: 'CellOperation',
|
|
|
options: [
|
|
|
+ #if (${table.templateType} == 2)## 树表特有操作
|
|
|
+ {
|
|
|
+ code: 'append',
|
|
|
+ text: '新增下级',
|
|
|
+ show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:create']),
|
|
|
+ },
|
|
|
+ #end
|
|
|
+ {
|
|
|
+ code: 'edit',
|
|
|
+ show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
|
|
|
+ },
|
|
|
{
|
|
|
code: 'delete',
|
|
|
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
|
|
+ #if (${table.templateType} == 2)## 树表禁止删除带有子节点的数据
|
|
|
+ disabled: (row: ${simpleClassName}Api.${simpleClassName}) => {
|
|
|
+ return !!(row.children && row.children.length > 0);
|
|
|
+ },
|
|
|
+ #end
|
|
|
},
|
|
|
],
|
|
|
},
|
|
|
},
|
|
|
];
|
|
|
}
|
|
|
+#else
|
|
|
+ #if ($subTable.subJoinMany) ## 一对多
|
|
|
+ /** 列表的字段 */
|
|
|
+ export function use${subSimpleClassName}GridColumns(
|
|
|
+ onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
|
|
+ ): VxeTableGridOptions<${subSimpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
|
+ return [
|
|
|
+ #foreach($column in $subColumns)
|
|
|
+ #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
|
|
+ #set ($dictType = $column.dictType)
|
|
|
+ #set ($javaField = $column.javaField)
|
|
|
+ #set ($comment = $column.columnComment)
|
|
|
+ {
|
|
|
+ field: '${javaField}',
|
|
|
+ title: '${comment}',
|
|
|
+ minWidth: 120,
|
|
|
+ slots: { default: '${javaField}' },
|
|
|
+ },
|
|
|
+ #end
|
|
|
+ #end
|
|
|
+ {
|
|
|
+ field: 'operation',
|
|
|
+ title: '操作',
|
|
|
+ minWidth: 60,
|
|
|
+ align: 'center',
|
|
|
+ fixed: 'right',
|
|
|
+ headerAlign: 'center',
|
|
|
+ showOverflow: false,
|
|
|
+ cellRender: {
|
|
|
+ attrs: {
|
|
|
+ nameField: '${columns[0].javaField}',
|
|
|
+ nameTitle: '${table.classComment}',
|
|
|
+ onClick: onActionClick,
|
|
|
+ },
|
|
|
+ name: 'CellOperation',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ code: 'delete',
|
|
|
+ show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ #else
|
|
|
+ /** 新增/修改的表单 */
|
|
|
+ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ fieldName: 'id',
|
|
|
+ component: 'Input',
|
|
|
+ dependencies: {
|
|
|
+ triggerFields: [''],
|
|
|
+ show: () => false,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ #foreach($column in $subColumns)
|
|
|
+ #if ($column.createOperation || $column.updateOperation)
|
|
|
+ #if (!$column.primaryKey && ($table.templateType != 2 || ($table.templateType == 2 && $column.id != $treeParentColumn.id)))## 树表中已经添加了父ID字段,这里排除
|
|
|
+ #set ($dictType = $column.dictType)
|
|
|
+ #set ($javaType = $column.javaType)
|
|
|
+ #set ($javaField = $column.javaField)
|
|
|
+ #set ($comment = $column.columnComment)
|
|
|
+ #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
|
|
+ #set ($dictMethod = "number")
|
|
|
+ #elseif ($javaType == "String")
|
|
|
+ #set ($dictMethod = "string")
|
|
|
+ #elseif ($javaType == "Boolean")
|
|
|
+ #set ($dictMethod = "boolean")
|
|
|
+ #end
|
|
|
+ #if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
|
|
+ #else
|
|
|
+ {
|
|
|
+ fieldName: '${javaField}',
|
|
|
+ label: '${comment}',
|
|
|
+ #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
|
|
|
+ rules: 'required',
|
|
|
+ #end
|
|
|
+ #if ($column.htmlType == "input")
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入${comment}',
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "imageUpload")## 图片上传
|
|
|
+ component: 'FileUpload',
|
|
|
+ componentProps: {
|
|
|
+ fileType: 'image',
|
|
|
+ maxCount: 1,
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "fileUpload")## 文件上传
|
|
|
+ component: 'FileUpload',
|
|
|
+ componentProps: {
|
|
|
+ fileType: 'file',
|
|
|
+ maxCount: 1,
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "editor")## 文本编辑器
|
|
|
+ component: 'Editor',
|
|
|
+ #elseif($column.htmlType == "select")## 下拉框
|
|
|
+ component: 'Select',
|
|
|
+ componentProps: {
|
|
|
+ #if ("" != $dictType)## 有数据字典
|
|
|
+ options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
|
+ #else##没数据字典
|
|
|
+ options: [],
|
|
|
+ #end
|
|
|
+ placeholder: '请选择${comment}',
|
|
|
+ class: 'w-full',
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "checkbox")## 多选框
|
|
|
+ component: 'Checkbox',
|
|
|
+ componentProps: {
|
|
|
+ #if ("" != $dictType)## 有数据字典
|
|
|
+ options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
|
+ #else##没数据字典
|
|
|
+ options: [],
|
|
|
+ #end
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "radio")## 单选框
|
|
|
+ component: 'RadioGroup',
|
|
|
+ componentProps: {
|
|
|
+ #if ("" != $dictType)## 有数据字典
|
|
|
+ options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
|
+ #else##没数据字典
|
|
|
+ options: [],
|
|
|
+ #end
|
|
|
+ buttonStyle: 'solid',
|
|
|
+ optionType: 'button',
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "datetime")## 时间框
|
|
|
+ component: 'DatePicker',
|
|
|
+ componentProps: {
|
|
|
+ showTime: true,
|
|
|
+ format: 'YYYY-MM-DD HH:mm:ss',
|
|
|
+ valueFormat: 'x',
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "textarea")## 文本域
|
|
|
+ component: 'Textarea',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入${comment}',
|
|
|
+ },
|
|
|
+ #elseif($column.htmlType == "inputNumber")## 数字输入框
|
|
|
+ component: 'InputNumber',
|
|
|
+ componentProps: {
|
|
|
+ min: 0,
|
|
|
+ class: 'w-full',
|
|
|
+ controlsPosition: 'right',
|
|
|
+ placeholder: '请输入${comment}',
|
|
|
+ },
|
|
|
+ #end
|
|
|
+ },
|
|
|
+ #end
|
|
|
+ #end
|
|
|
+ #end
|
|
|
+ #end
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ #end
|
|
|
+#end
|
|
|
#end
|