ShiShiYiBan/yudao-ui-admin-vue3/src/views/system/dict/dict.data.ts

109 lines
2.4 KiB
TypeScript
Raw Normal View History

2022-07-18 19:06:37 +08:00
import { reactive } from 'vue'
import { DICT_TYPE } from '@/utils/dict'
import { required } from '@/utils/formRules'
import { useI18n } from '@/hooks/web/useI18n'
2022-11-22 14:34:21 +08:00
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
2022-07-18 19:06:37 +08:00
// 国际化
const { t } = useI18n()
// 表单校验
export const dictDataRules = reactive({
2023-01-16 17:54:20 +08:00
label: [required],
value: [required],
sort: [required]
2022-07-18 19:06:37 +08:00
})
// crudSchemas
2022-11-22 14:34:21 +08:00
export const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: null,
2022-11-22 14:34:21 +08:00
action: true,
actionWidth: '140px',
2022-11-28 16:50:53 +08:00
searchSpan: 12,
2022-11-22 14:34:21 +08:00
columns: [
{
title: '字典类型',
field: 'dictType',
isTable: false,
isForm: false
2022-07-18 19:06:37 +08:00
},
2022-11-22 14:34:21 +08:00
{
title: '数据标签',
field: 'label',
isSearch: true
2022-08-02 11:15:40 +08:00
},
2022-11-22 14:34:21 +08:00
{
title: '数据键值',
field: 'value'
2022-07-18 19:06:37 +08:00
},
2023-01-16 18:04:58 +08:00
// {
// title: '标签类型',
// field: 'colorType',
// form: {
// component: 'Select',
// componentProps: {
// options: [
// {
// label: 'default',
// value: ''
// },
// {
// label: 'success',
// value: 'success'
// },
// {
// label: 'info',
// value: 'info'
// },
// {
// label: 'warning',
// value: 'warning'
// },
// {
// label: 'danger',
// value: 'danger'
// }
// ]
// }
// },
// isTable: false
// },
2022-11-22 14:34:21 +08:00
{
2023-01-16 17:54:20 +08:00
title: '颜色',
2022-11-22 14:34:21 +08:00
field: 'cssClass',
2023-01-16 17:54:20 +08:00
isTable: false,
form: {
2023-01-16 18:04:58 +08:00
component: 'ColorPicker',
componentProps: {
predefine: ['#ffffff', '#409eff', '#67c23a', '#e6a23c', '#f56c6c', '#909399', '#c71585']
}
2023-01-16 17:54:20 +08:00
}
2022-11-22 14:34:21 +08:00
},
{
title: '显示排序',
field: 'sort',
isTable: false
},
{
title: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
dictClass: 'number'
2022-07-18 19:06:37 +08:00
},
2022-11-22 14:34:21 +08:00
{
title: t('form.remark'),
field: 'remark',
form: {
component: 'Input',
componentProps: {
type: 'textarea',
rows: 4
},
colProps: {
span: 24
}
},
isTable: false
2022-07-18 19:06:37 +08:00
}
2022-11-22 14:34:21 +08:00
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)