Skip to content

Commit

Permalink
管理员员工和医生电话号码编辑优化
Browse files Browse the repository at this point in the history
  • Loading branch information
shiguangbiyi committed Sep 2, 2023
1 parent ac96abb commit e4a930c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/管理员界面/mytabledoctor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<el-input v-model="editedDoctor.name"></el-input>
</el-form-item>
<el-form-item label="电话">
<el-input v-model="editedDoctor.phone"></el-input>
<el-input v-model="editedDoctor.phone" @input="handleeditPhoneInput"></el-input>
</el-form-item>
<el-form-item label="工作时间">
<!-- <el-input v-model="editedDoctor.workingHours"></el-input> -->
Expand Down Expand Up @@ -118,6 +118,16 @@ const newDoctor = ref<Doctor>({
salary: '',
});
const handleeditPhoneInput = () => {
// 获取输入框的值并移除所有非数字字符
const digitsOnly = editedDoctor.value.phone.replace(/\D/g, "");
// 在第4个和第9个位置插入空格
const formattedValue = insertSpaces(digitsOnly, [3, 7]);
editedDoctor.value.phone = formattedValue;
};
const handlePhoneInput = () => {
// 获取输入框的值并移除所有非数字字符
const digitsOnly = newDoctor.value.phone.replace(/\D/g, "");
Expand Down
12 changes: 11 additions & 1 deletion src/components/管理员界面/mytableemployee.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<el-input v-model="editedEmployee.name"></el-input>
</el-form-item>
<el-form-item label="电话">
<el-input v-model="editedEmployee.phone"></el-input>
<el-input v-model="editedEmployee.phone" @input="handleeditPhoneInput"></el-input>
</el-form-item>
<el-form-item label="职责">
<!-- <el-input v-model="editedEmployee.responsibility"></el-input> -->
Expand Down Expand Up @@ -172,6 +172,16 @@ const options = [
},
]
const handleeditPhoneInput = () => {
// 获取输入框的值并移除所有非数字字符
const digitsOnly = editedEmployee.value.phone.replace(/\D/g, "");
// 在第4个和第9个位置插入空格
const formattedValue = insertSpaces(digitsOnly, [3, 7]);
editedEmployee.value.phone = formattedValue; // 更新 editedEmployee.value.phone
};
const handlePhoneInput = () => {
// 获取输入框的值并移除所有非数字字符
const digitsOnly = newEmployee.value.phone.replace(/\D/g, "");
Expand Down

0 comments on commit e4a930c

Please sign in to comment.