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

178 lines
3.4 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'
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
// 国际化
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
const crudSchemas = reactive<CrudSchema[]>([
{
label: t('common.index'),
field: 'id',
type: 'index',
form: {
show: false
},
detail: {
show: false
}
},
{
label: '用户账号',
field: 'username',
search: {
show: true
}
},
2022-10-26 09:44:07 +08:00
{
label: '用户密码',
field: 'password',
form: {
component: 'InputPassword'
},
detail: {
show: false
}
},
2022-07-18 19:06:37 +08:00
{
label: '用户昵称',
field: 'nickname'
},
{
label: '用户邮箱',
field: 'email'
},
{
label: '手机号码',
field: 'mobile',
search: {
show: true
}
},
{
label: '部门',
field: 'deptId',
table: {
show: false
}
},
{
label: '岗位',
field: 'postIds',
table: {
show: false
}
},
{
label: t('common.status'),
field: 'status',
dictType: DICT_TYPE.COMMON_STATUS,
search: {
show: true
}
},
{
label: '最后登录时间',
field: 'loginDate',
form: {
show: false
}
},
{
label: '最后登录IP',
field: 'loginIp',
table: {
show: false
},
form: {
show: false
}
},
{
label: t('form.remark'),
field: 'remark',
table: {
show: false
}
},
{
label: t('common.createTime'),
2022-07-21 15:07:04 +08:00
field: 'createTime',
2022-07-18 19:06:37 +08:00
table: {
show: false
},
form: {
show: false
},
detail: {
show: false
},
search: {
show: true,
component: 'DatePicker',
componentProps: {
2022-07-25 22:54:12 +08:00
type: 'datetimerange',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)],
shortcuts: [
{
text: '近一周',
value: () => {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
return [start, end]
}
},
{
text: '近一个月',
value: () => {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
return [start, end]
}
},
{
text: '近三个月',
value: () => {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
return [start, end]
}
}
]
2022-07-18 19:06:37 +08:00
}
}
},
{
field: 'action',
2022-08-01 19:03:27 +08:00
width: '400px',
2022-07-18 19:06:37 +08:00
label: t('table.action'),
form: {
show: false
},
detail: {
show: false
}
}
])
export const { allSchemas } = useCrudSchemas(crudSchemas)