Merge pull request 'fix : 修复通讯录手机号码校验' (#74) from dd into master

Reviewed-on: http://git.feashow.cn/feashow/SmartOpsWeb/pulls/74
This commit is contained in:
2024-09-16 03:22:31 +00:00

View File

@@ -1,10 +1,13 @@
<template> <template>
<div class="address-book">
<fvSearchForm :searchConfig="searchConfig" @search="search"></fvSearchForm> <fvSearchForm :searchConfig="searchConfig" @search="search"></fvSearchForm>
<fvTable ref="tableIns" :tableConfig="tableConfig" @headBtnClick="headBtnClick" <fvTable ref="tableIns" :tableConfig="tableConfig" @headBtnClick="headBtnClick"
@selectionChange="selectionChange"></fvTable> @selectionChange="selectionChange"></fvTable>
<fvFormDialog ref="formDialogRef" :title="dialogTitle" :dialogType="dialogType" <fvFormDialog ref="formDialogRef" :title="dialogTitle" :dialogType="dialogType"
:form-schema="formSchema" :form-rules="formRules" @dialogCancel="handleCancel" :form-schema="formSchema" :form-rules="formRules" @dialogCancel="handleCancel"
@dialogSubmit="handleSubmit"></fvFormDialog> @dialogSubmit="handleSubmit"></fvFormDialog>
</div>
</template> </template>
<script setup lang="jsx"> <script setup lang="jsx">
@@ -19,6 +22,23 @@ const delBtnDisabled = ref(true)
const contactIds = ref(""); const contactIds = ref("");
const dialogTitle = ref(""); const dialogTitle = ref("");
const dialogType = ref(""); const dialogType = ref("");
// 手机号验证
const checkPhone = (rule, value, callback) => {
const phoneReg = /^1[3|4|5|6|7|8][0-9]{9}$/
setTimeout(() => {
if (!Number.isInteger(+value)) {
callback(new Error('请输入数字值'))
} else {
if (phoneReg.test(value)) {
callback()
} else {
callback(new Error('手机号码格式不正确'))
}
}
}, 100)
};
const formRules = reactive({ const formRules = reactive({
siteName: [ siteName: [
{required: true, message: "请输入电站", trigger: ["change", "blur"]} {required: true, message: "请输入电站", trigger: ["change", "blur"]}
@@ -30,7 +50,8 @@ const formRules = reactive({
{required: true, message: "请输入姓名", trigger: ["change", "blur"]} {required: true, message: "请输入姓名", trigger: ["change", "blur"]}
], ],
phone: [ phone: [
{required: true, message: "请输入手机号", trigger: ["change", "blur"]} {required: true, message: "请输入手机号", trigger: ["change", "blur"]},
{ validator: checkPhone, trigger: ["change", "blur"]},
] ]
}); });
const formSchema = computed(() => { const formSchema = computed(() => {
@@ -76,13 +97,14 @@ const formSchema = computed(() => {
{ {
label: '手机号', label: '手机号',
prop: 'phone', prop: 'phone',
component: 'el-input', component: 'el-input-number',
colProps: { colProps: {
span: 24 span: 24
}, },
props: { props: {
placeholder: '请输入手机号', placeholder: '请输入手机号',
clearable: true, clearable: true,
controls:false
}, },
}, },
{ {
@@ -287,8 +309,6 @@ const deleteContactMethod = (contactsId) => {
}) })
} }
const handleMoreDelete = () => { const handleMoreDelete = () => {
console.info("🚀 ~method:contactIds -----", contactIds.value)
if(contactIds.value){ if(contactIds.value){
ElMessageBox.confirm(`确认删除选择的通讯录吗?`, '系统提示', { ElMessageBox.confirm(`确认删除选择的通讯录吗?`, '系统提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
@@ -300,7 +320,6 @@ const handleMoreDelete = () => {
}else{ }else{
ElMessage.warning("请选择要删除的通讯录") ElMessage.warning("请选择要删除的通讯录")
} }
} }
const handleSingleDelete = (row) => { const handleSingleDelete = (row) => {
ElMessageBox.confirm(`确认删除姓名为${row.name}的通讯录吗?`, '系统提示', { ElMessageBox.confirm(`确认删除姓名为${row.name}的通讯录吗?`, '系统提示', {
@@ -340,7 +359,14 @@ const handleSubmit = async (formInstance) => {
} }
} }
</script> </script>
<style lang="scss">
.address-book{
<style scoped> .el-input-number {
width: 100% !important;
.el-input__inner{
text-align: left;
}
}
}
</style> </style>