"use strict";(self["webpackChunkscui"]=self["webpackChunkscui"]||[]).push([[5267],{93088:function(e,l,r){r.r(l),r.d(l,{default:function(){return p}});var a=r(66252);const u=(0,a.Uk)("验证所有字段"),m=(0,a.Uk)("Reset"),o=(0,a.Uk)("验证所有字段"),t=(0,a.Uk)("Reset");function d(e,l,r,d,s,n){const i=(0,a.up)("el-input"),f=(0,a.up)("el-form-item"),p=(0,a.up)("el-button"),c=(0,a.up)("el-form"),g=(0,a.up)("el-card"),h=(0,a.up)("el-alert"),W=(0,a.up)("el-main");return(0,a.wg)(),(0,a.j4)(W,null,{default:(0,a.w5)((()=>[(0,a.Wm)(g,{shadow:"never",header:"async-validator内置"},{default:(0,a.w5)((()=>[(0,a.Wm)(c,{ref:"form",model:s.form,rules:s.rules,"label-width":"100px","status-icon":""},{default:(0,a.w5)((()=>[(0,a.Wm)(f,{label:"必填",prop:"required"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.required,"onUpdate:modelValue":l[0]||(l[0]=e=>s.form.required=e)},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"长度",prop:"length"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.length,"onUpdate:modelValue":l[1]||(l[1]=e=>s.form.length=e),placeholder:"长度需为3位"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"类型",prop:"type"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.type,"onUpdate:modelValue":l[2]||(l[2]=e=>s.form.type=e),placeholder:"类型可为string number boolean array date url email等"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"范围",prop:"range"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.range,"onUpdate:modelValue":l[3]||(l[3]=e=>s.form.range=e),placeholder:"请填写范围在3至5位"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"枚举",prop:"enum"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.enum,"onUpdate:modelValue":l[4]||(l[4]=e=>s.form.enum=e),placeholder:"请填写admin，user，guest其一"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"自定义",prop:"custom"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.custom,"onUpdate:modelValue":l[5]||(l[5]=e=>s.form.custom=e),placeholder:"请填写数字1"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"异步验证",prop:"async"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form.async,"onUpdate:modelValue":l[6]||(l[6]=e=>s.form.async=e),placeholder:"请输入SCUI最新版本号,form开启status-icon后 可以查看右侧状态"},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,null,{default:(0,a.w5)((()=>[(0,a.Wm)(p,{type:"primary",onClick:n.submit},{default:(0,a.w5)((()=>[u])),_:1},8,["onClick"]),(0,a.Wm)(p,{onClick:l[7]||(l[7]=e=>n.resetForm("form"))},{default:(0,a.w5)((()=>[m])),_:1})])),_:1})])),_:1},8,["model","rules"])])),_:1}),(0,a.Wm)(g,{shadow:"never",header:"自定义",style:{"margin-top":"15px"}},{default:(0,a.w5)((()=>[(0,a.Wm)(c,{ref:"form2",model:s.form2,rules:s.rules2,"label-width":"100px","status-icon":""},{default:(0,a.w5)((()=>[(0,a.Wm)(f,{label:"手机号码",prop:"phone"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form2.phone,"onUpdate:modelValue":l[8]||(l[8]=e=>s.form2.phone=e)},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,{label:"车牌号码",prop:"cars"},{default:(0,a.w5)((()=>[(0,a.Wm)(i,{modelValue:s.form2.cars,"onUpdate:modelValue":l[9]||(l[9]=e=>s.form2.cars=e)},null,8,["modelValue"])])),_:1}),(0,a.Wm)(f,null,{default:(0,a.w5)((()=>[(0,a.Wm)(p,{type:"primary",onClick:n.submit2},{default:(0,a.w5)((()=>[o])),_:1},8,["onClick"]),(0,a.Wm)(p,{onClick:l[10]||(l[10]=e=>n.resetForm("form2"))},{default:(0,a.w5)((()=>[t])),_:1})])),_:1})])),_:1},8,["model","rules"]),(0,a.Wm)(h,{title:"自定义验证可在 @/utils/verificate.js 中不断扩展业务需要的验证. 记得要 import 进来",type:"success"})])),_:1})])),_:1})}var s=r(62921),n={name:"verificate",data(){return{form:{},rules:{required:[{required:!0,message:"请填写"}],length:[{required:!0,len:3,message:"长度需为3位"}],type:[{required:!0,type:"email",message:"类型需为email"}],range:[{required:!0,min:3,max:5,message:"范围在3至5位"}],enum:[{required:!0,type:"enum",enum:["admin","user","guest"],message:"请填写admin，user，guest其一"}],custom:[{required:!0,validator:(e,l)=>"1"===l,message:"请填写数字1",trigger:"blur"}],async:[{required:!0,validator:(e,l,r)=>{this.$API.demo.ver.get({value:l}).then((e=>{if(e.data!=l)return r(new Error("请输入SCUI最新版本号："+e.data));r()}))},trigger:"blur"}]},form2:{},rules2:{phone:[{required:!0,message:"请输入姓名"},{validator:s.verifyPhone,trigger:"blur"}],cars:[{required:!0,validator:s.verifyCars,trigger:"blur"}]}}},mounted(){},methods:{submit(){this.$refs.form.validate((async e=>{if(!e)return!1;this.$message.success("全部验证通过")}))},submit2(){this.$refs.form2.validate((async e=>{if(!e)return!1;this.$message.success("全部验证通过")}))},resetForm(e){this.$refs[e].resetFields()}}},i=r(83744);const f=(0,i.Z)(n,[["render",d]]);var p=f}}]);