1
0

feat(web): 使用vite重新组织前端代码

This commit is contained in:
2024-11-19 17:52:34 +08:00
parent 7ccc602406
commit 9a01d74d78
138 changed files with 1141 additions and 443 deletions

View File

@@ -0,0 +1,38 @@
import {horizontalFormOptions, apiPost} from '../constants.js'
import {confirmPasswordFormItem, passwordFormItem} from "./dialog-user-item.js";
export function userChangePasswordDialog() {
return {
actionType: 'dialog',
dialog: {
title: '修改密码',
actions: [
{
type: 'reset',
label: '清空',
},
{
type: 'submit',
label: '修改',
level: 'primary',
}
],
body: {
type: 'form',
api: apiPost('${base}/user_management/change_password'),
...horizontalFormOptions(),
body: [
{
type: 'input-password',
name: 'oldPassword',
label: '旧密码',
placeholder: '请输入旧密码',
required: true,
},
passwordFormItem('newPassword', '新密码'),
confirmPasswordFormItem('confirmNewPassword', 'newPassword', '新密码'),
]
}
}
}
}

View File

@@ -0,0 +1,61 @@
import {apiGet, horizontalFormOptions, mappingField, userRoleMapping, userStateMapping} from "../constants.js";
export function userCheckDialog() {
return {
actionType: 'dialog',
dialog: {
title: '用户注册',
actions: [
{
type: 'action',
label: '同意',
level: 'primary',
actionType: 'ajax',
api: apiGet('${base}/user_management/enable/${username}'),
confirmTitle: '审核通过',
confirmText: '确认通过账号为${username}通过审核吗?审核通过后将无法撤销。',
reload: '9200849e-a8e9-4752-b4fc-ae52dc46a205',
},
],
body: {
type: 'form',
initApi: apiGet('${base}/user_management/detail/${username}'),
...horizontalFormOptions(),
static: true,
body: [
{
type: 'input-email',
name: 'username',
label: '邮箱',
},
{
type: 'control',
name: 'role',
label: '角色',
body: [
mappingField('role', userRoleMapping),
]
},
{
type: 'control',
name: 'state',
label: '账号状态',
body: [
mappingField('state', userStateMapping)
]
},
{
type: 'input-datetime',
name: 'createTime',
label: '创建时间',
},
{
type: 'input-datetime',
name: 'updateTime',
label: '更新时间',
},
]
}
}
}
}

View File

@@ -0,0 +1,49 @@
export function emailFormItem(name) {
return {
type: 'input-email',
name: name,
label: '邮箱',
placeholder: '请输入邮箱',
required: true,
clearable: true,
clearValueOnEmpty: true,
validateApi: '${base}/user/exists_username/${username}',
}
}
export function passwordFormItem(name, label = '密码') {
return {
type: 'input-password',
name: name,
label: label,
placeholder: `请输入${label}`,
required: true,
clearable: true,
clearValueOnEmpty: true,
validations: {
matchRegexp:
/^(?=.*\d)(?!.*(\d)\1{2})(?!.*(012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210))(?=.*[a-zA-Z])(?=.*[^\da-zA-Z\s]).{8,16}$/,
},
validationErrors: {
matchRegexp:
`${label}至少包含字母、数字、特殊字符8-16位并且不能连续出现3个大小连续或相同的数字`,
},
}
}
export function confirmPasswordFormItem(name, target, label = '密码') {
return {
type: 'input-password',
name: name,
label: `确认${label}`,
placeholder: `请再次输入${label}`,
required: true,
clearable: true,
validations: {
equalsField: target,
},
validationErrors: {
equalsField: `两次输入${label}不一致`,
},
}
}

View File

@@ -0,0 +1,89 @@
import {apiPost, horizontalFormOptions} from '../constants.js'
import {confirmPasswordFormItem, emailFormItem, passwordFormItem} from "./dialog-user-item.js";
export function userRegisterDialog() {
return {
actionType: 'dialog',
dialog: {
title: '用户注册',
actions: [
{
type: 'reset',
label: '清空',
},
{
type: 'submit',
label: '注册',
level: 'primary',
},
],
body: {
type: 'form',
api: apiPost('${base}/user/register'),
...horizontalFormOptions(),
body: [
emailFormItem('username'),
passwordFormItem('password'),
confirmPasswordFormItem('confirm-password', 'password'),
{
type: 'radios',
name: 'role',
label: '角色',
required: true,
selectFirst: true,
options: [
{ label: '数据提供方', value: 'PROVIDER' },
{ label: '数据使用方', value: 'CUSTOMER' },
{ label: '审查监管方', value: 'CHECKER' },
],
},
],
},
},
}
}
export function userAdministratorRegisterDialog() {
return {
actionType: 'dialog',
dialog: {
title: '用户注册',
actions: [
{
type: 'reset',
label: '清空',
},
{
type: 'submit',
label: '注册',
level: 'primary',
},
],
body: {
type: 'form',
api: apiPost('${base}/user_management/register'),
...horizontalFormOptions(),
body: [
emailFormItem('username'),
passwordFormItem('password'),
confirmPasswordFormItem('confirm-password', 'password'),
{
type: 'radios',
name: 'role',
label: '角色',
required: true,
selectFirst: true,
inline: false,
columnsCount: 2,
options: [
{ label: '数据提供方', value: 'PROVIDER' },
{ label: '数据使用方', value: 'CUSTOMER' },
{ label: '审查监管方', value: 'CHECKER' },
{ label: '系统管理员', value: 'ADMINISTRATOR' },
],
},
],
},
},
}
}