|
@@ -1,349 +0,0 @@
|
|
|
-import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
|
|
|
|
|
-import type { VbenFormSchema } from '#/adapter/form';
|
|
|
|
|
-import type { OnActionClickFn } from '#/adapter/vxe-table';
|
|
|
|
|
-import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
|
|
|
-
|
|
|
|
|
-import { z } from '#/adapter/form';
|
|
|
|
|
-#if(${table.templateType} == 2)## 树表需要导入这些
|
|
|
|
|
-import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
|
|
|
-import { handleTree } from '#/utils/tree';
|
|
|
|
|
-#end
|
|
|
|
|
-import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
|
|
|
|
-import { getRangePickerDefaultProps } from '#/utils/date';
|
|
|
|
|
-import { useAccess } from '@vben/access';
|
|
|
|
|
-
|
|
|
|
|
-const { hasAccessByCodes } = useAccess();
|
|
|
|
|
-
|
|
|
|
|
-/** 列表的搜索表单 */
|
|
|
|
|
-export function useGridFormSchema(): VbenFormSchema[] {
|
|
|
|
|
- return [
|
|
|
|
|
-#foreach($column in $columns)
|
|
|
|
|
-#if ($column.listOperation)
|
|
|
|
|
- #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
|
|
|
|
|
- {
|
|
|
|
|
- fieldName: '${javaField}',
|
|
|
|
|
- label: '${comment}',
|
|
|
|
|
- #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor")
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- placeholder: '请输入${comment}',
|
|
|
|
|
- },
|
|
|
|
|
- #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
|
|
|
|
- component: 'Select',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- #if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
|
|
|
|
- options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
|
|
|
- #else## 未设置 dictType 数据字典的情况
|
|
|
|
|
- options: [],
|
|
|
|
|
- #end
|
|
|
|
|
- placeholder: '请选择${comment}',
|
|
|
|
|
- },
|
|
|
|
|
- #elseif($column.htmlType == "datetime")
|
|
|
|
|
- component: 'RangePicker',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- ...getRangePickerDefaultProps(),
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- },
|
|
|
|
|
-#end
|
|
|
|
|
-#end
|
|
|
|
|
- ];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/** 列表的字段 */
|
|
|
|
|
-export function useGridColumns(
|
|
|
|
|
- onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>,
|
|
|
|
|
-): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
|
|
|
|
|
- return [
|
|
|
|
|
-#if ($table.templateType == 12) ## 内嵌情况
|
|
|
|
|
- { type: 'expand', width: 80, slots: { content: 'expand_content' } },
|
|
|
|
|
-#end
|
|
|
|
|
-#foreach($column in $columns)
|
|
|
|
|
-#if ($column.listOperationResult)
|
|
|
|
|
- #set ($dictType = $column.dictType)
|
|
|
|
|
- #set ($javaField = $column.javaField)
|
|
|
|
|
- #set ($comment = $column.columnComment)
|
|
|
|
|
- {
|
|
|
|
|
- field: '${javaField}',
|
|
|
|
|
- title: '${comment}',
|
|
|
|
|
- minWidth: 120,
|
|
|
|
|
- #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: 200,
|
|
|
|
|
- align: 'center',
|
|
|
|
|
- fixed: 'right',
|
|
|
|
|
- headerAlign: 'center',
|
|
|
|
|
- showOverflow: false,
|
|
|
|
|
- cellRender: {
|
|
|
|
|
- attrs: {
|
|
|
|
|
- nameField: '${columns[0].javaField}',
|
|
|
|
|
- nameTitle: '${table.classComment}',
|
|
|
|
|
- onClick: onActionClick,
|
|
|
|
|
- },
|
|
|
|
|
- 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
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- ];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-## 标准模式和内嵌模式时,主子关系一对一则生成表单schema,一对多则生成列表schema(内嵌模式时表单schema也要生成)。erp 模式时都生成
|
|
|
|
|
-## 特殊:主子表专属逻辑
|
|
|
|
|
-#foreach ($subTable in $subTables)
|
|
|
|
|
- #set ($index = $foreach.count - 1)
|
|
|
|
|
- #set ($subColumns = $subColumnsList.get($index))##当前字段数组
|
|
|
|
|
- #set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
|
|
|
|
- #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
|
|
|
|
|
- #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
|
|
|
|
-// ==================== 子表($subTable.classComment) ====================
|
|
|
|
|
-
|
|
|
|
|
-#if ($table.templateType == 11) ## erp 情况
|
|
|
|
|
-/** 列表的搜索表单 */
|
|
|
|
|
-export function use${subSimpleClassName}GridFormSchema(): VbenFormSchema[] {
|
|
|
|
|
- return [
|
|
|
|
|
- #foreach($column in $subColumns)
|
|
|
|
|
- #if ($column.listOperation)
|
|
|
|
|
- #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
|
|
|
|
|
- {
|
|
|
|
|
- fieldName: '${javaField}',
|
|
|
|
|
- label: '${comment}',
|
|
|
|
|
- #if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor")
|
|
|
|
|
- component: 'Input',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- placeholder: '请输入${comment}',
|
|
|
|
|
- },
|
|
|
|
|
- #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
|
|
|
|
- component: 'Select',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- #if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
|
|
|
|
- options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
|
|
|
- #else## 未设置 dictType 数据字典的情况
|
|
|
|
|
- options: [],
|
|
|
|
|
- #end
|
|
|
|
|
- placeholder: '请选择${comment}',
|
|
|
|
|
- },
|
|
|
|
|
- #elseif($column.htmlType == "datetime")
|
|
|
|
|
- component: 'RangePicker',
|
|
|
|
|
- componentProps: {
|
|
|
|
|
- ...getRangePickerDefaultProps(),
|
|
|
|
|
- allowClear: true,
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- #end
|
|
|
|
|
- ];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/** 列表的字段 */
|
|
|
|
|
-export function use${subSimpleClassName}GridColumns(
|
|
|
|
|
- onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
|
|
|
|
-): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
|
|
|
- return [
|
|
|
|
|
- #foreach($column in $subColumns)
|
|
|
|
|
- #if ($column.listOperationResult)
|
|
|
|
|
- #set ($dictType = $column.dictType)
|
|
|
|
|
- #set ($javaField = $column.javaField)
|
|
|
|
|
- #set ($comment = $column.columnComment)
|
|
|
|
|
- {
|
|
|
|
|
- field: '${javaField}',
|
|
|
|
|
- title: '${comment}',
|
|
|
|
|
- minWidth: 120,
|
|
|
|
|
- #if ($column.javaType == "LocalDateTime")## 时间类型
|
|
|
|
|
- formatter: 'formatDateTime',
|
|
|
|
|
- #elseif("" != $dictType)## 数据字典
|
|
|
|
|
- cellRender: {
|
|
|
|
|
- name: 'CellDict',
|
|
|
|
|
- props: { type: DICT_TYPE.$dictType.toUpperCase() },
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- #end
|
|
|
|
|
- {
|
|
|
|
|
- field: 'operation',
|
|
|
|
|
- title: '操作',
|
|
|
|
|
- minWidth: 200,
|
|
|
|
|
- align: 'center',
|
|
|
|
|
- fixed: 'right',
|
|
|
|
|
- headerAlign: 'center',
|
|
|
|
|
- showOverflow: false,
|
|
|
|
|
- cellRender: {
|
|
|
|
|
- attrs: {
|
|
|
|
|
- nameField: '${columns[0].javaField}',
|
|
|
|
|
- nameTitle: '${subTable.classComment}',
|
|
|
|
|
- onClick: onActionClick,
|
|
|
|
|
- },
|
|
|
|
|
- name: 'CellOperation',
|
|
|
|
|
- options: [
|
|
|
|
|
- {
|
|
|
|
|
- code: 'edit',
|
|
|
|
|
- show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- code: 'delete',
|
|
|
|
|
- show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- ];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#else
|
|
|
|
|
- #if ($subTable.subJoinMany) ## 一对多
|
|
|
|
|
- /** 新增/修改列表的字段 */
|
|
|
|
|
- export function use${subSimpleClassName}GridEditColumns(
|
|
|
|
|
- onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
|
|
|
|
- ): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
|
|
|
- return [
|
|
|
|
|
- #foreach($column in $subColumns)
|
|
|
|
|
- #if ($column.createOperation || $column.updateOperation)
|
|
|
|
|
- #if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
|
|
|
|
- #set ($dictType = $column.dictType)
|
|
|
|
|
- #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
|
|
|
|
|
- {
|
|
|
|
|
- field: '${javaField}',
|
|
|
|
|
- title: '${comment}',
|
|
|
|
|
- minWidth: 120,
|
|
|
|
|
- slots: { default: '${javaField}' },
|
|
|
|
|
- #if ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio")
|
|
|
|
|
- #if ("" != $dictType)## 有数据字典
|
|
|
|
|
- params: {
|
|
|
|
|
- options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
|
|
|
- },
|
|
|
|
|
- #else
|
|
|
|
|
- params: {
|
|
|
|
|
- options: [],
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- #end
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- #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']),
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
- #end
|
|
|
|
|
- #if ($table.templateType == 12) ## 内嵌情况
|
|
|
|
|
- /** 列表的字段 */
|
|
|
|
|
- export function use${subSimpleClassName}GridColumns(): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
|
|
|
- return [
|
|
|
|
|
- #foreach($column in $subColumns)
|
|
|
|
|
- #if ($column.listOperationResult)
|
|
|
|
|
- #set ($dictType = $column.dictType)
|
|
|
|
|
- #set ($javaField = $column.javaField)
|
|
|
|
|
- #set ($comment = $column.columnComment)
|
|
|
|
|
- {
|
|
|
|
|
- field: '${javaField}',
|
|
|
|
|
- title: '${comment}',
|
|
|
|
|
- minWidth: 120,
|
|
|
|
|
- #if ($column.javaType == "LocalDateTime")## 时间类型
|
|
|
|
|
- formatter: 'formatDateTime',
|
|
|
|
|
- #elseif("" != $dictType)## 数据字典
|
|
|
|
|
- cellRender: {
|
|
|
|
|
- name: 'CellDict',
|
|
|
|
|
- props: { type: DICT_TYPE.$dictType.toUpperCase() },
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- },
|
|
|
|
|
- #end
|
|
|
|
|
- #end
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- #end
|
|
|
|
|
-#end
|
|
|
|
|
-#end
|
|
|