fix: 优化手机号区号更新为空及展示问题

This commit is contained in:
jiangweidong
2023-04-10 17:08:00 +08:00
committed by Jiangjie.Bai
parent cbbaf7f7ca
commit dff6824ddc
5 changed files with 19 additions and 13 deletions

View File

@@ -1,10 +1,11 @@
<template> <template>
<div> <div>
<el-input v-model="rawValue.phone" placeholder="请输入手机号码" @change="OnInputChange"> <el-input v-model="rawValue.phone" :placeholder="$tc('users.inputPhone')" @input="OnInputChange">
<el-select <el-select
slot="prepend" slot="prepend"
:value="rawValue.code" :value="rawValue.code"
style="width: 80px;" :placeholder="$tc('common.Select')"
style="width: 90px;"
@change="OnChange" @change="OnChange"
> >
<el-option <el-option
@@ -51,24 +52,25 @@ export default {
] ]
} }
}, },
computed: {}, computed: {
mounted() { fullPhone() {
this.rawValue = this.value if (!this.rawValue.phone) {
if (!this.rawValue?.code) { return ''
this.rawValue.code = '+86' }
} else { return `${this.rawValue.code} ${this.rawValue.phone}`
const value = `${this.rawValue.code}${this.rawValue.phone}`
this.$emit('input', value)
} }
}, },
mounted() {
this.rawValue = this.value || { code: '+86', phone: '' }
this.$emit('input', this.fullPhone)
},
methods: { methods: {
OnChange(countryCode) { OnChange(countryCode) {
this.rawValue.code = countryCode this.rawValue.code = countryCode
this.OnInputChange() this.OnInputChange()
}, },
OnInputChange() { OnInputChange() {
const value = `${this.rawValue.code}${this.rawValue.phone}` this.$emit('input', this.fullPhone)
this.$emit('input', value)
} }
} }
} }

View File

@@ -1685,6 +1685,7 @@
"users": { "users": {
"Login": "Users login", "Login": "Users login",
"InviteSuccess": "Invite success", "InviteSuccess": "Invite success",
"inputPhone": "Please enter your mobile phone number",
"FileEncryptionPassword": "File encryption password", "FileEncryptionPassword": "File encryption password",
"OrgRoles": "Org roles", "OrgRoles": "Org roles",
"RoleUsers": "Role users", "RoleUsers": "Role users",

View File

@@ -1673,6 +1673,7 @@
"users": { "users": {
"Login": "ユーザー登録", "Login": "ユーザー登録",
"InviteSuccess": "成功招待", "InviteSuccess": "成功招待",
"inputPhone": "携帯電話の番号をお願いします",
"FileEncryptionPassword": "ファイル暗号化パスワード", "FileEncryptionPassword": "ファイル暗号化パスワード",
"RoleUsers": "承認されたユーザー", "RoleUsers": "承認されたユーザー",
"RoleInfo": "ロール情報", "RoleInfo": "ロール情報",

View File

@@ -1676,6 +1676,7 @@
"Login": "用户登录", "Login": "用户登录",
"InviteSuccess": "邀请成功", "InviteSuccess": "邀请成功",
"FileEncryptionPassword": "文件加密密码", "FileEncryptionPassword": "文件加密密码",
"inputPhone": "请输入手机号码",
"RoleUsers": "授权用户", "RoleUsers": "授权用户",
"RoleInfo": "角色信息", "RoleInfo": "角色信息",
"RolePerms": "角色权限", "RolePerms": "角色权限",

View File

@@ -180,7 +180,8 @@ export default {
{ {
key: this.$t('users.Phone'), key: this.$t('users.Phone'),
formatter: () => { formatter: () => {
return <div>{this.object.phone.phone}</div> const phoneObj = this.object.phone
return <div>{phoneObj?.code} {phoneObj?.phone}</div>
} }
}, },
'wecom_id', 'dingtalk_id', 'feishu_id', 'wecom_id', 'dingtalk_id', 'feishu_id',