mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:59:20 +08:00
refactor(account): 公司账户管理添加账户表单优化
1. 移除登录账号字段(手机号作为唯一标识) 2. 手机号改为必填,放在第一位(密码之前) 3. 职位改为可选,默认 undefined 4. 移除头像图片ID字段 5. 更新相关 DTO 类型定义
This commit is contained in:
@@ -5,34 +5,26 @@
|
||||
export namespace AccountDTO {
|
||||
/** 创建账户参数 */
|
||||
export interface CreateAccountDTO {
|
||||
/** 登录账号 */
|
||||
loginCode: string;
|
||||
/** 密码 */
|
||||
password: string;
|
||||
/** 手机号 */
|
||||
phone: string;
|
||||
/** 真实姓名 */
|
||||
realName: string;
|
||||
/** 手机号 */
|
||||
phone?: string;
|
||||
/** 头像图片ID */
|
||||
avatarImageId?: number;
|
||||
/** 部门ID */
|
||||
departmentId: number;
|
||||
/** 岗位ID */
|
||||
positionId: number;
|
||||
positionId?: number;
|
||||
/** 备注信息 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新账户参数 */
|
||||
export interface UpdateAccountDTO {
|
||||
/** 登录账号 */
|
||||
loginCode?: string;
|
||||
/** 手机号 */
|
||||
phone?: string;
|
||||
/** 真实姓名 */
|
||||
realName?: string;
|
||||
/** 头像图片ID */
|
||||
avatarImageId?: number;
|
||||
/** 部门ID */
|
||||
departmentId?: number;
|
||||
/** 岗位ID */
|
||||
|
||||
+18
-50
@@ -60,13 +60,11 @@ interface PositionSelectOption {
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<AccountDTO.CreateAccountDTO & { status?: number }>({
|
||||
loginCode: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
avatarImageId: undefined,
|
||||
realName: '',
|
||||
departmentId: 0,
|
||||
positionId: 0,
|
||||
positionId: undefined,
|
||||
remark: '',
|
||||
status: 0,
|
||||
});
|
||||
@@ -96,13 +94,11 @@ const statusOptions = [
|
||||
// 重置表单
|
||||
function resetForm() {
|
||||
formData.value = {
|
||||
loginCode: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
avatarImageId: undefined,
|
||||
realName: '',
|
||||
departmentId: 0,
|
||||
positionId: 0,
|
||||
positionId: undefined,
|
||||
remark: '',
|
||||
status: 0,
|
||||
};
|
||||
@@ -215,7 +211,7 @@ function handleDepartmentChange(value: number[]) {
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some((item) => item.value === formData.value.positionId)
|
||||
) {
|
||||
formData.value.positionId = 0;
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,13 +224,11 @@ async function open(accountData?: AccountVO.AccountInfoVO | null) {
|
||||
|
||||
if (accountData) {
|
||||
formData.value = {
|
||||
loginCode: accountData.loginCode,
|
||||
password: '', // 编辑时密码为空
|
||||
realName: accountData.realName,
|
||||
phone: accountData.phone || '',
|
||||
avatarImageId: accountData.avatarImageId,
|
||||
realName: accountData.realName,
|
||||
departmentId: accountData.departmentId || 0,
|
||||
positionId: accountData.positionId || 0,
|
||||
positionId: accountData.positionId || undefined,
|
||||
remark: accountData.remark || '',
|
||||
status: accountData.status,
|
||||
};
|
||||
@@ -289,7 +283,7 @@ watch(
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some((item) => item.value === formData.value.positionId)
|
||||
) {
|
||||
formData.value.positionId = 0;
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -309,21 +303,14 @@ defineExpose({
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item
|
||||
label="登录账号"
|
||||
name="loginCode"
|
||||
label="手机号"
|
||||
name="phone"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入登录账号' },
|
||||
{ min: 4, max: 20, message: '登录账号长度为4-20个字符' },
|
||||
{
|
||||
pattern: /^[a-zA-Z0-9_]+$/,
|
||||
message: '登录账号只能包含字母、数字和下划线',
|
||||
},
|
||||
{ required: true, message: '请输入手机号' },
|
||||
{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号' },
|
||||
]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.loginCode"
|
||||
placeholder="请输入登录账号"
|
||||
/>
|
||||
<Input v-model:value="formData.phone" placeholder="请输入手机号" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
@@ -354,18 +341,6 @@ defineExpose({
|
||||
<Input v-model:value="formData.realName" placeholder="请输入真实姓名" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="手机号"
|
||||
name="phone"
|
||||
:rules="[{ pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号' }]"
|
||||
>
|
||||
<Input v-model:value="formData.phone" placeholder="请输入手机号" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="所属部门"
|
||||
name="departmentId"
|
||||
@@ -383,26 +358,19 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="职位"
|
||||
name="positionId"
|
||||
:rules="[{ required: true, message: '请选择职位' }]"
|
||||
>
|
||||
<Form.Item label="职位" name="positionId">
|
||||
<Select
|
||||
v-model:value="formData.positionId"
|
||||
:loading="positionOptionsLoading"
|
||||
:options="positionOptions"
|
||||
placeholder="请选择职位"
|
||||
placeholder="请选择职位(可选)"
|
||||
:disabled="positionOptionsLoading"
|
||||
allow-clear
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="头像图片ID" name="avatarImageId">
|
||||
<Input
|
||||
v-model:value="formData.avatarImageId"
|
||||
type="number"
|
||||
placeholder="请输入头像图片ID"
|
||||
/>
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="状态" name="status">
|
||||
|
||||
Reference in New Issue
Block a user