refactor: vben dict

This commit is contained in:
xingyu 2023-05-11 17:36:58 +08:00
parent 912e18857a
commit 9d68c62177

View File

@ -1,5 +1,5 @@
import { BasicColumn, FormSchema, useRender } from '@/components/Table' import { BasicColumn, FormSchema, useRender } from '@/components/Table'
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getDictOpts } from '@/utils/dict'
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
#foreach($column in $columns) #foreach($column in $columns)
@ -53,14 +53,7 @@ export const searchFormSchema: FormSchema[] = [
component: 'Select', component: 'Select',
componentProps: { componentProps: {
#if ("" != $dictType)## 设置了 dictType 数据字典的情况 #if ("" != $dictType)## 设置了 dictType 数据字典的情况
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#set ($dictMethod = "getIntDictOptions")
#elseif ($javaType == "String")
#set ($dictMethod = "getStrDictOptions")
#elseif ($javaType == "Boolean")
#set ($dictMethod = "getBoolDictOptions")
#end
options: $dictMethod(DICT_TYPE.$dictType.toUpperCase())
#else## 未设置 dictType 数据字典的情况 #else## 未设置 dictType 数据字典的情况
options: [] options: []
#end #end
@ -114,14 +107,7 @@ export const createFormSchema: FormSchema[] = [
component: 'Select', component: 'Select',
componentProps: { componentProps: {
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#set ($dictMethod = "getIntDictOptions")
#elseif ($javaType == "String")
#set ($dictMethod = "getStrDictOptions")
#elseif ($javaType == "Boolean")
#set ($dictMethod = "getBoolDictOptions")
#end
options: $dictMethod(DICT_TYPE.$dictType.toUpperCase())
#else##没数据字典 #else##没数据字典
options:[] options:[]
#end #end
@ -130,7 +116,7 @@ export const createFormSchema: FormSchema[] = [
component: 'Checkbox', component: 'Checkbox',
componentProps: { componentProps: {
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#else##没数据字典 #else##没数据字典
options:[] options:[]
#end #end
@ -139,7 +125,7 @@ export const createFormSchema: FormSchema[] = [
component: 'Radio', component: 'Radio',
componentProps: { componentProps: {
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#else##没数据字典 #else##没数据字典
options:[] options:[]
#end #end
@ -187,14 +173,7 @@ export const updateFormSchema: FormSchema[] = [
component: 'Select', component: 'Select',
componentProps: { componentProps: {
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short") options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#set ($dictMethod = "getIntDictOptions")
#elseif ($javaType == "String")
#set ($dictMethod = "getStrDictOptions")
#elseif ($javaType == "Boolean")
#set ($dictMethod = "getBoolDictOptions")
#end
options: $dictMethod(DICT_TYPE.$dictType.toUpperCase())
#else##没数据字典 #else##没数据字典
options:[] options:[]
#end #end
@ -203,7 +182,7 @@ export const updateFormSchema: FormSchema[] = [
component: 'Checkbox', component: 'Checkbox',
componentProps: { componentProps: {
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#else##没数据字典 #else##没数据字典
options:[] options:[]
#end #end
@ -212,7 +191,7 @@ export const updateFormSchema: FormSchema[] = [
component: 'Radio', component: 'Radio',
componentProps: { componentProps: {
#if ("" != $dictType)## 有数据字典 #if ("" != $dictType)## 有数据字典
options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) options: getDictOpts(DICT_TYPE.$dictType.toUpperCase())
#else##没数据字典 #else##没数据字典
options:[] options:[]
#end #end