data.ts.vm 3.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
import { BasicColumn, FormSchema, useRender } from '@/components/Table'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'

export const columns: BasicColumn[] = [
#foreach($column in $columns)
#if ($column.listOperationResult)
  #set ($dictType=$column.dictType)
  #set ($javaField = $column.javaField)
  #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  #set ($comment=$column.columnComment)
#if ($column.javaType == "LocalDateTime")## 时间类型
  {
    title: '${comment}',
    dataIndex: '${javaField}',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    }
  },
#elseif("" != $column.dictType)## 数据字典
  {
    title: '${comment}',
    dataIndex: '${javaField}',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.$dictType.toUpperCase())
    }
  },
#else
  {
    title: '${comment}',
    dataIndex: '${javaField}',
    width: 160
  },
#end
#end
#end
]

export const searchFormSchema: FormSchema[] = [
#foreach($column in $columns)
#if ($column.listOperation)
  #set ($dictType=$column.dictType)
  #set ($javaField = $column.javaField)
  #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  #set ($comment=$column.columnComment)
  {
    label: '${comment}',
    field: '${javaField}',
  #if ($column.htmlType == "input")
    component: 'Input',
  #elseif ($column.htmlType == "select" || $column.htmlType == "radio")
    component: 'Select',
    componentProps: {
      #if ("" != $dictType)## 设置了 dictType 数据字典的情况
        options: getIntDictOptions(DICT_TYPE.$dictType.toUpperCase())
      #else## 未设置 dictType 数据字典的情况
        options: []
      #end
    },
  #elseif($column.htmlType == "datetime")
    component: 'RangePicker',
    #end
    colProps: { span: 8 }
  },
#end
#end
]

export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input'
  },
#foreach($column in $columns)
#if ($column.createOperation || $column.updateOperation)
  #set ($dictType = $column.dictType)
  #set ($javaField = $column.javaField)
  #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
  #set ($comment = $column.columnComment)
#if (!$column.primaryKey)## 忽略主键,不用在表单里
  {
    label: '${comment}',
    field: '${javaField}',
  #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
    required: true,
    #end
  #if ($column.htmlType == "input")
    component: 'Input'
  #elseif($column.htmlType == "imageUpload")## 图片上传
    component: 'Upload'
  #elseif($column.htmlType == "fileUpload")## 文件上传
    component: 'Upload'
  #elseif($column.htmlType == "editor")## 文本编辑器
    component: 'InputTextArea'
  #elseif($column.htmlType == "select")## 下拉框
    component: 'Select',
    componentProps: {
      #if ("" != $dictType)## 有数据字典
        options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
      #else##没数据字典
        options:[]
      #end
    }
  #elseif($column.htmlType == "checkbox")## 多选框
    component: 'Checkbox',
    componentProps: {
      #if ("" != $dictType)## 有数据字典
        options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
      #else##没数据字典
        options:[]
      #end
    }
  #elseif($column.htmlType == "radio")## 单选框
    component: 'Radio',
    componentProps: {
      #if ("" != $dictType)## 有数据字典
        options: getIntDictOptions(DICT_TYPE.COMMON_STATUS)
      #else##没数据字典
        options:[]
      #end
    }
  #elseif($column.htmlType == "datetime")## 时间框
    component: 'DatePicker'
  #elseif($column.htmlType == "textarea")## 文本域
    component: 'InputTextArea'
  #end
  },
#end
#end
#end
]