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

106 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-07-18 19:06:37 +08:00
import { reactive } from 'vue'
import { required } from '@/utils/formRules'
import { useI18n } from '@/hooks/web/useI18n'
import { DICT_TYPE } from '@/utils/dict'
2022-11-15 23:44:08 +08:00
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
2022-07-18 19:06:37 +08:00
// 国际化
const { t } = useI18n()
// 表单校验
export const rules = reactive({
username: [required],
2022-07-20 13:04:37 +08:00
nickname: [required],
email: [required],
status: [required],
mobile: [
{
pattern:
/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/,
trigger: 'blur',
message: '请输入正确的手机号码'
}
]
2022-07-18 19:06:37 +08:00
})
// crudSchemas
2022-11-15 23:44:08 +08:00
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: 'seq',
action: true,
actionWidth: '400px',
columns: [
{
title: '用户账号',
field: 'username',
isSearch: true
2022-10-26 09:44:07 +08:00
},
2022-11-15 23:44:08 +08:00
{
title: '用户密码',
field: 'password',
2022-11-15 23:46:27 +08:00
isDetail: false,
isTable: false,
2022-11-15 23:44:08 +08:00
form: {
component: 'InputPassword'
2022-11-15 23:46:27 +08:00
}
2022-07-18 19:06:37 +08:00
},
2022-11-15 23:44:08 +08:00
{
title: '用户昵称',
field: 'nickname'
2022-07-18 19:06:37 +08:00
},
2022-11-15 23:44:08 +08:00
{
title: '用户邮箱',
field: 'email'
2022-07-18 19:06:37 +08:00
},
2022-11-15 23:44:08 +08:00
{
title: '手机号码',
field: 'mobile',
isSearch: true
2022-07-18 19:06:37 +08:00
},
2022-11-15 23:44:08 +08:00
{
title: '部门',
field: 'deptId',
2022-11-17 00:22:38 +08:00
isTable: false
2022-07-18 19:06:37 +08:00
},
2022-11-15 23:44:08 +08:00
{
title: '岗位',
field: 'postIds',
isTable: false
},
{
title: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
2022-11-16 23:15:14 +08:00
dictData: 'number',
2022-11-15 23:44:08 +08:00
isSearch: true
},
{
title: '最后登录时间',
field: 'loginDate',
isForm: false
},
{
title: '最后登录IP',
field: 'loginIp',
isTable: false,
isForm: false
},
{
title: t('form.remark'),
field: 'remark',
isTable: false
},
{
title: t('common.createTime'),
field: 'createTime',
formatter: 'formatDate',
isTable: false,
isForm: false,
search: {
show: true,
itemRender: {
name: 'XDataTimePicker'
}
}
2022-07-18 19:06:37 +08:00
}
2022-11-15 23:44:08 +08:00
]
})
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)