支持管理账号手机号选填
This commit is contained in:
@@ -75,7 +75,7 @@ export interface ListUsersParams {
|
||||
export interface CreateUserRequest {
|
||||
account: string
|
||||
nickname: string
|
||||
phone: string
|
||||
phone?: string
|
||||
contactPhone?: string
|
||||
birthday?: string
|
||||
wechatId?: string
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
<a-form-item label="手机号" name="phone">
|
||||
<a-input
|
||||
v-model:value="formState.phone"
|
||||
placeholder="请输入手机号"
|
||||
placeholder="选填,填写后保持唯一"
|
||||
:maxlength="11"
|
||||
inputmode="numeric"
|
||||
autocomplete="off"
|
||||
@@ -256,9 +256,8 @@
|
||||
<a-form-item
|
||||
label="微信号"
|
||||
name="wechatId"
|
||||
:required="[2, 3].includes(Number(formState.type))"
|
||||
>
|
||||
<a-input v-model:value="formState.wechatId" placeholder="店长和美甲师必填" />
|
||||
<a-input v-model:value="formState.wechatId" placeholder="选填,未填时使用登录账号兜底" />
|
||||
</a-form-item>
|
||||
<a-form-item label="微信二维码" name="wechatQrCode">
|
||||
<div class="wechat-qr-field">
|
||||
@@ -932,7 +931,7 @@ const handleWechatQrUpload: UploadProps['customRequest'] = async (options) => {
|
||||
const validatePhoneUniqueness = async (value: string) => {
|
||||
const normalized = value?.trim()
|
||||
if (!normalized) {
|
||||
throw new Error('请输入手机号')
|
||||
return
|
||||
}
|
||||
if (!PHONE_REGEX.test(normalized)) {
|
||||
throw new Error('请输入正确的 11 位手机号')
|
||||
@@ -1075,7 +1074,6 @@ const formRules = {
|
||||
],
|
||||
nickname: [{ required: true, message: '请输入昵称', trigger: 'blur' }],
|
||||
phone: [
|
||||
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
||||
{
|
||||
validator: async (_rule: unknown, value: string) => {
|
||||
await validatePhoneUniqueness(value)
|
||||
@@ -1084,15 +1082,6 @@ const formRules = {
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
wechatId: [{
|
||||
validator: async (_rule: unknown, value: string) => {
|
||||
if ([2, 3].includes(Number(formState.type)) && !value?.trim()) {
|
||||
return Promise.reject('店长和美甲师必须填写微信号')
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
trigger: ['blur', 'change']
|
||||
}],
|
||||
password: [{
|
||||
validator: async (_rule: unknown, value: string) => {
|
||||
validateOptionalPasswordStrength(value)
|
||||
@@ -1379,7 +1368,7 @@ const buildDraftPayload = () => ({
|
||||
account: formState.account,
|
||||
nickname: formState.nickname,
|
||||
phone: formState.phone,
|
||||
contactPhone: formState.phone,
|
||||
contactPhone: formState.contactPhone,
|
||||
birthday: formState.birthday,
|
||||
wechatId: formState.wechatId,
|
||||
wechatQrCode: formState.wechatQrCode,
|
||||
@@ -1445,8 +1434,8 @@ const showEditModal = (record: any) => {
|
||||
Object.assign(formState, {
|
||||
account: record.account,
|
||||
nickname: record.nickname,
|
||||
phone: record.phone || record.contactPhone || '',
|
||||
contactPhone: record.phone || record.contactPhone || '',
|
||||
phone: record.phone || '',
|
||||
contactPhone: record.contactPhone || '',
|
||||
birthday: record.birthday || '',
|
||||
wechatId: record.wechatId || '',
|
||||
wechatQrCode: record.wechatQrCode || '',
|
||||
@@ -1534,7 +1523,7 @@ const handleModalOk = async () => {
|
||||
account: formState.account.trim(),
|
||||
nickname: formState.nickname.trim(),
|
||||
phone: primaryPhone,
|
||||
contactPhone: primaryPhone,
|
||||
contactPhone: primaryPhone || undefined,
|
||||
birthday: formState.birthday || undefined,
|
||||
wechatId: formState.wechatId.trim(),
|
||||
wechatQrCode: formState.wechatQrCode,
|
||||
|
||||
@@ -50,7 +50,8 @@ describe('admin modal and user form behavior', () => {
|
||||
expect(userFormModal).not.toContain('formState.contactPhone')
|
||||
expect(usersView).toContain('const primaryPhone = formState.phone.trim()')
|
||||
expect(usersView).toContain('phone: primaryPhone')
|
||||
expect(usersView).toContain('contactPhone: primaryPhone')
|
||||
expect(usersView).toContain('contactPhone: primaryPhone || undefined')
|
||||
expect(usersView).toContain('选填,填写后保持唯一')
|
||||
})
|
||||
|
||||
it('uses a polished date picker and visible required markers for conditional user fields', () => {
|
||||
@@ -64,7 +65,8 @@ describe('admin modal and user form behavior', () => {
|
||||
expect(userFormModal).toContain('value-format="YYYY-MM-DD"')
|
||||
expect(userFormModal).toContain('class="user-date-picker"')
|
||||
expect(usersView).toContain('.user-date-picker')
|
||||
expect(wechatIdField).toContain(':required="[2, 3].includes(Number(formState.type))"')
|
||||
expect(wechatIdField).not.toContain(':required="[2, 3].includes(Number(formState.type))"')
|
||||
expect(wechatIdField).toContain('选填,未填时使用登录账号兜底')
|
||||
expect(shopIdsField).toContain(':required="Number(formState.type) !== 4"')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user