Commit a65b8f63b7515553c03f32cb9072375397f6f037
1 parent
9a5d7c86
Vue3 CRUD Schema 模版,data 部分提交
Showing
1 changed file
with
54 additions
and
45 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_schema/views/data.ts.vm
| 1 | import type { CrudSchema } from '@/hooks/web/useCrudSchemas' | 1 | import type { CrudSchema } from '@/hooks/web/useCrudSchemas' |
| 2 | +import { dateFormatter } from '@/utils/formatTime' | ||
| 2 | const { t } = useI18n() // 国际化 | 3 | const { t } = useI18n() // 国际化 |
| 3 | 4 | ||
| 4 | // 表单校验 | 5 | // 表单校验 |
| @@ -21,9 +22,7 @@ const crudSchemas = reactive<CrudSchema[]>([ | @@ -21,9 +22,7 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||
| 21 | { | 22 | { |
| 22 | title: '${column.columnComment}', | 23 | title: '${column.columnComment}', |
| 23 | field: '${column.javaField}', | 24 | field: '${column.javaField}', |
| 24 | - #if (!$column.listOperationResult) | ||
| 25 | - isTable: false, | ||
| 26 | - #end | 25 | +## ========= 字典部分 ========= |
| 27 | #if ("" != $dictType)## 有数据字典 | 26 | #if ("" != $dictType)## 有数据字典 |
| 28 | dictType: DICT_TYPE.$dictType.toUpperCase(), | 27 | dictType: DICT_TYPE.$dictType.toUpperCase(), |
| 29 | #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") | 28 | #if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") |
| @@ -34,6 +33,28 @@ const crudSchemas = reactive<CrudSchema[]>([ | @@ -34,6 +33,28 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||
| 34 | dictClass: 'boolean', | 33 | dictClass: 'boolean', |
| 35 | #end | 34 | #end |
| 36 | #end | 35 | #end |
| 36 | +## ========= Table 表格部分 ========= | ||
| 37 | + #if (!$column.listOperationResult) | ||
| 38 | + isTable: false, | ||
| 39 | + #if ($column.htmlType == "datetime") | ||
| 40 | + formatter: dateFormatter, | ||
| 41 | + #end | ||
| 42 | + #end | ||
| 43 | +## ========= Search 表格部分 ========= | ||
| 44 | + #if ($column.listOperation) | ||
| 45 | + isSearch: true, | ||
| 46 | + #if ($column.htmlType == "datetime") | ||
| 47 | + search: { | ||
| 48 | + component: 'DatePicker', | ||
| 49 | + componentProps: { | ||
| 50 | + valueFormat: 'YYYY-MM-DD HH:mm:ss', | ||
| 51 | + type: 'daterange', | ||
| 52 | + defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + #end | ||
| 56 | + #end | ||
| 57 | +## ========= Form 表单部分 ========= | ||
| 37 | #if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey) | 58 | #if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey) |
| 38 | isForm: false, | 59 | isForm: false, |
| 39 | #else | 60 | #else |
| @@ -65,51 +86,39 @@ const crudSchemas = reactive<CrudSchema[]>([ | @@ -65,51 +86,39 @@ const crudSchemas = reactive<CrudSchema[]>([ | ||
| 65 | form: { | 86 | form: { |
| 66 | component: 'Radio' | 87 | component: 'Radio' |
| 67 | }, | 88 | }, |
| 89 | + #elseif($column.htmlType == "datetime")## 时间框 | ||
| 90 | + form: { | ||
| 91 | + component: 'DatePicker', | ||
| 92 | + componentProps: { | ||
| 93 | + type: 'datetime', | ||
| 94 | + valueFormat: 'x' | ||
| 95 | + } | ||
| 96 | + }, | ||
| 97 | + #elseif($column.htmlType == "textarea")## 文本框 | ||
| 98 | + form: { | ||
| 99 | + component: 'Input', | ||
| 100 | + componentProps: { | ||
| 101 | + type: 'textarea', | ||
| 102 | + rows: 4 | ||
| 103 | + }, | ||
| 104 | + colProps: { | ||
| 105 | + span: 24 | ||
| 106 | + } | ||
| 107 | + }, | ||
| 108 | + #elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框 | ||
| 109 | + form: { | ||
| 110 | + component: 'InputNumber', | ||
| 111 | + value: 0 | ||
| 112 | + }, | ||
| 68 | #end | 113 | #end |
| 69 | #end | 114 | #end |
| 70 | - #elseif(!("" != $column.dictType)) | ||
| 71 | - #if (${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime") | ||
| 72 | - form: { | ||
| 73 | - component: 'DatePicker', | ||
| 74 | - componentProps: { | ||
| 75 | - type: 'datetime', | ||
| 76 | - valueFormat: 'x' | ||
| 77 | - } | ||
| 78 | - }, | ||
| 79 | - #elseif($column.htmlType == "textarea")## 文本框 | ||
| 80 | - form: { | ||
| 81 | - component: 'Input', | ||
| 82 | - componentProps: { | ||
| 83 | - type: 'textarea', | ||
| 84 | - rows: 4 | ||
| 85 | - }, | ||
| 86 | - colProps: { | ||
| 87 | - span: 24 | ||
| 88 | - } | ||
| 89 | - }, | ||
| 90 | - #elseif(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer")## 数字类型 | ||
| 91 | - form: { | ||
| 92 | - component: 'InputNumber', | ||
| 93 | - value: 0 | ||
| 94 | - }, | ||
| 95 | - #end | ||
| 96 | - #end | ||
| 97 | - #if ($column.listOperation) | ||
| 98 | - #if($column.htmlType == "input") | ||
| 99 | - isSearch: true, | ||
| 100 | - #elseif("" != $dictType) | ||
| 101 | - isSearch: true, | ||
| 102 | - #elseif($column.htmlType == "datetime") | ||
| 103 | - formatter: 'formatDate', | ||
| 104 | - search: { | ||
| 105 | - show: true, | ||
| 106 | - itemRender: { | ||
| 107 | - name: 'XDataTimePicker' | ||
| 108 | - } | ||
| 109 | - }, | ||
| 110 | - #end | ||
| 111 | - #end | ||
| 112 | }, | 115 | }, |
| 113 | #end | 116 | #end |
| 117 | +#end | ||
| 118 | + { | ||
| 119 | + label: '操作', | ||
| 120 | + field: 'action', | ||
| 121 | + isForm: false | ||
| 122 | + } | ||
| 114 | ]) | 123 | ]) |
| 115 | export const { allSchemas } = useCrudSchemas(crudSchemas) | 124 | export const { allSchemas } = useCrudSchemas(crudSchemas) |