perf: 优化表单校验和查询参数

This commit is contained in:
xingyu
2022-08-02 10:19:02 +08:00
parent fa79f4226e
commit 93a97cd526
23 changed files with 161 additions and 34 deletions

View File

@ -1,5 +1,19 @@
import { required } from '@/utils/formRules'
import { reactive } from 'vue'
// 表单校验
export const rules = reactive({
name: [required],
sort: [required],
email: [required],
phone: [
{
pattern:
/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/,
trigger: 'blur',
message: '请输入正确的手机号码'
}
]
})
export const modelSchema = reactive<FormSchema[]>([
{

View File

@ -5,7 +5,7 @@ import { handleTree } from '@/utils/tree'
import { onMounted, ref, unref, watch } from 'vue'
import * as DeptApi from '@/api/system/dept'
import { Form, FormExpose } from '@/components/Form'
import { modelSchema } from './dept.data'
import { modelSchema, rules } from './dept.data'
import { DeptVO } from '@/api/system/dept/types'
import { useMessage } from '@/hooks/web/useMessage'
import { getListSimpleUsersApi } from '@/api/system/user'
@ -159,7 +159,7 @@ onMounted(async () => {
</div>
<div v-if="showForm">
<!-- 操作工具栏 -->
<Form :schema="modelSchema" ref="formRef">
<Form ref="formRef" :schema="modelSchema" :rules="rules">
<template #parentId>
<el-tree-select
node-key="id"