Skip to content

Commit

Permalink
fix: 优化手机号区号更新为空及展示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Jiangweidong authored and BaiJiangJie committed Apr 10, 2023
1 parent cbbaf7f commit dff6824
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
26 changes: 14 additions & 12 deletions src/components/FormFields/PhoneInput.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<template>
<div>
<el-input v-model="rawValue.phone" placeholder="请输入手机号码" @change="OnInputChange">
<el-input v-model="rawValue.phone" :placeholder="$tc('users.inputPhone')" @input="OnInputChange">
<el-select
slot="prepend"
:value="rawValue.code"
style="width: 80px;"
:placeholder="$tc('common.Select')"
style="width: 90px;"
@change="OnChange"
>
<el-option
Expand Down Expand Up @@ -51,24 +52,25 @@ export default {
]
}
},
computed: {},
mounted() {
this.rawValue = this.value
if (!this.rawValue?.code) {
this.rawValue.code = '+86'
} else {
const value = `${this.rawValue.code}${this.rawValue.phone}`
this.$emit('input', value)
computed: {
fullPhone() {
if (!this.rawValue.phone) {
return ''
}
return `${this.rawValue.code} ${this.rawValue.phone}`
}
},
mounted() {
this.rawValue = this.value || { code: '+86', phone: '' }
this.$emit('input', this.fullPhone)
},
methods: {
OnChange(countryCode) {
this.rawValue.code = countryCode
this.OnInputChange()
},
OnInputChange() {
const value = `${this.rawValue.code}${this.rawValue.phone}`
this.$emit('input', value)
this.$emit('input', this.fullPhone)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,7 @@
"users": {
"Login": "Users login",
"InviteSuccess": "Invite success",
"inputPhone": "Please enter your mobile phone number",
"FileEncryptionPassword": "File encryption password",
"OrgRoles": "Org roles",
"RoleUsers": "Role users",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/langs/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,7 @@
"users": {
"Login": "ユーザー登録",
"InviteSuccess": "成功招待",
"inputPhone": "携帯電話の番号をお願いします",
"FileEncryptionPassword": "ファイル暗号化パスワード",
"RoleUsers": "承認されたユーザー",
"RoleInfo": "ロール情報",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/langs/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@
"Login": "用户登录",
"InviteSuccess": "邀请成功",
"FileEncryptionPassword": "文件加密密码",
"inputPhone": "请输入手机号码",
"RoleUsers": "授权用户",
"RoleInfo": "角色信息",
"RolePerms": "角色权限",
Expand Down
3 changes: 2 additions & 1 deletion src/views/users/User/UserDetail/UserInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export default {
{
key: this.$t('users.Phone'),
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',
Expand Down

0 comments on commit dff6824

Please sign in to comment.