Vue3+antDesignVue實(shí)現(xiàn)表單校驗(yàn)的方法
一
<a-form
ref="form"
:model="form"
:rules="rules"
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 18 }, sm: { span: 24 } }"
>
<!-- <a-form-item label='創(chuàng)建人:' name='createdBy'>-->
<!-- <a-input-number v-model:value='form.createdBy' placeholder='請(qǐng)輸入創(chuàng)建人' allow-clear autocomplete='off' style="width: 100%" />-->
<!-- </a-form-item>-->
<a-form-item label="項(xiàng)目編號(hào):" name="projectCode">
<a-input v-model:value="form.projectCode" placeholder="請(qǐng)輸入項(xiàng)目編號(hào)" style="width: 50%" allow-clear autocomplete="off" />
</a-form-item>
<a-form-item label="項(xiàng)目名稱:" name="projectName">
<a-input v-model:value="form.projectName" placeholder="請(qǐng)輸入項(xiàng)目名稱" style="width: 50%" allow-clear autocomplete="off" />
</a-form-item>
<a-form-item label="項(xiàng)目承擔(dān)單位:" name="company">
<a-input v-model:value="form.company" placeholder="請(qǐng)輸入項(xiàng)目承擔(dān)單位" style="width: 50%" allow-clear autocomplete="off" />
</a-form-item>
<a-form-item label="項(xiàng)目目的和意義:" name="purpose">
<a-textarea v-model:value="form.purpose" placeholder="請(qǐng)輸入項(xiàng)目目的和意義" style="width: 50%" allow-clear autocomplete="off" />
</a-form-item>
<a-form-item label="技術(shù)水平:" name="level">
<a-select
ref="select"
v-model:value="form.level"
style="width: 40%"
placeholder="請(qǐng)選擇技術(shù)水平"
@focus="focus"
@change="handleChange"
>
<a-select-option value="國(guó)際先進(jìn)">國(guó)際先進(jìn)</a-select-option>
<a-select-option value="國(guó)際領(lǐng)先">國(guó)際領(lǐng)先</a-select-option>
<a-select-option value="國(guó)內(nèi)先進(jìn)">國(guó)內(nèi)先進(jìn)</a-select-option>
<a-select-option value="國(guó)內(nèi)領(lǐng)先">國(guó)內(nèi)領(lǐng)先</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="項(xiàng)目類型:" name="projectType">
<a-select
ref="select"
v-model:value="form.projectType"
placeholder="請(qǐng)選擇項(xiàng)目類型"
style="width: 40%"
@focus="focus"
@change="handleChange"
>
<a-select-option value="產(chǎn)學(xué)研合作">產(chǎn)學(xué)研合作</a-select-option>
<a-select-option value="自主研發(fā)">自主研發(fā)</a-select-option>
<a-select-option value="其他">其他</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="項(xiàng)目主要內(nèi)容:" name="content">
<a-textarea v-model:value="form.content" placeholder="請(qǐng)輸入項(xiàng)目主要內(nèi)容" style="width: 50%" allow-clear autocomplete="off" />
</a-form-item>
<a-form-item label="項(xiàng)目前期準(zhǔn)備工作、調(diào)研計(jì)劃:" name="plan">
<a-textarea
v-model:value="form.plan"
placeholder="請(qǐng)輸入項(xiàng)目前期準(zhǔn)備工作、調(diào)研計(jì)劃"
style="width: 50%"
allow-clear
autocomplete="off"
/>
</a-form-item>
<a-form-item label="項(xiàng)目預(yù)計(jì)科技投入總額:" name="investment">
<a-input-number
v-model:value="form.investment"
placeholder="請(qǐng)輸入項(xiàng)目預(yù)計(jì)科技投入總額"
style="width: 50%"
allow-clear
autocomplete="off"
addon-before="RMB"
addon-after="萬(wàn)元"
/>
</a-form-item>
<a-form-item label="前期準(zhǔn)備工作進(jìn)展、項(xiàng)目調(diào)研進(jìn)展:" name="progress">
<a-textarea
v-model:value="form.progress"
placeholder="請(qǐng)輸入前期準(zhǔn)備工作進(jìn)展、項(xiàng)目調(diào)研進(jìn)展"
style="width: 50%"
allow-clear
autocomplete="off"
/>
</a-form-item>
<a-form-item label="已累計(jì)投入總額:" name="spent">
<a-input-number
v-model:value="form.spent"
placeholder="請(qǐng)輸入已累計(jì)投入總額"
style="width: 50%"
allow-clear
autocomplete="off"
addon-before="RMB"
addon-after="萬(wàn)元"
/>
</a-form-item>
<a-form-item label="項(xiàng)目調(diào)研報(bào)告(或總結(jié)):" name="report">
<a-upload
name="file"
ref="uploadRef"
class="upload-list"
v-model:file-list="fileList"
:multiple="false"
:action="FileUploadUrl"
:headers="headers"
:before-upload="beforeUpload"
:custom-request="customRequest"
@change="handleChange"
@remove="handleRemove"
>
<a-button v-if="fileList.length < 1">
<template #icon>
<CloudUploadOutlined />
</template>
<span>選擇文件</span>
</a-button>
</a-upload>
</a-form-item>
</a-form>二
data() {
return {
fileList: [],
// 表單數(shù)據(jù)
form: Object.assign({}, this.data),
// 表單驗(yàn)證規(guī)則
rules: {
createdBy: [{ required: true, message: '請(qǐng)輸入創(chuàng)建人', type: 'number', trigger: 'blur' }],
projectName: [{ required: true, message: '請(qǐng)輸入項(xiàng)目名稱', type: 'string', trigger: 'blur' }],
company: [{ required: true, message: '請(qǐng)輸入項(xiàng)目承擔(dān)單位', type: 'string', trigger: 'blur' }],
purpose: [{ required: true, message: '請(qǐng)輸入項(xiàng)目目的和意義', type: 'string', trigger: 'blur' }],
level: [{ required: true, message: '請(qǐng)輸入技術(shù)水平', type: 'string', trigger: 'blur' }],
projectType: [{ required: true, message: '請(qǐng)輸入項(xiàng)目類型', type: 'string', trigger: 'blur' }],
content: [{ required: true, message: '請(qǐng)輸入項(xiàng)目主要內(nèi)容', type: 'string', trigger: 'blur' }],
plan: [{ required: true, message: '請(qǐng)輸入項(xiàng)目前期準(zhǔn)備工作、調(diào)研計(jì)劃', type: 'string', trigger: 'blur' }],
investment: [{ required: true, message: '請(qǐng)輸入項(xiàng)目預(yù)計(jì)科技投入總額', type: 'number', trigger: 'blur' }],
postTime: [{ required: true, message: '請(qǐng)輸入', type: 'string', trigger: 'blur' }],
status: [{ required: true, message: '請(qǐng)輸入', type: 'string', trigger: 'blur' }],
progress: [{ required: true, message: '請(qǐng)輸入前期準(zhǔn)備工作進(jìn)展、項(xiàng)目調(diào)研進(jìn)展', type: 'string', trigger: 'blur' }],
report: [{ required: true, message: '請(qǐng)輸入項(xiàng)目調(diào)研報(bào)告(或總結(jié))', type: 'change', trigger: 'blur' }],
projectCode: [{ required: true, message: '請(qǐng)輸入項(xiàng)目編號(hào)', type: 'string', trigger: 'blur' }],
spent: [{ required: true, message: '請(qǐng)輸入已累計(jì)投入總額', type: 'number', trigger: 'blur' }]
},
// 提交狀態(tài)
loading: false,
headers: {
Authorization: getToken()
},
// 是否是修改
isUpdate: false
};
},到此這篇關(guān)于Vue3+antDesignVue實(shí)現(xiàn)表單校驗(yàn)的方法的文章就介紹到這了,更多相關(guān)Vue3 antDesignVue表單校驗(yàn)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue組件和iframe頁(yè)面的相互傳參問(wèn)題及解決
這篇文章主要介紹了vue組件和iframe頁(yè)面的相互傳參問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-05-05
vue中解決chrome瀏覽器自動(dòng)播放音頻和MP3語(yǔ)音打包到線上的實(shí)現(xiàn)方法
這篇文章主要介紹了vue中解決chrome瀏覽器自動(dòng)播放音頻和MP3語(yǔ)音打包到線上的實(shí)現(xiàn)方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10
vite分目錄打包及去掉默認(rèn)的.gz?文件的操作方法
Vite在默認(rèn)配置下會(huì)將資源打包至assets文件夾并添加哈希值,不同于Webpack的多文件夾存放方式,Vite只對(duì)public文件夾不進(jìn)行打包處理,而Webpack不打包public和static文件夾,本文介紹vite分目錄打包及去掉默認(rèn)的.gz?文件的操作方法,感興趣的朋友一起看看吧2024-09-09
vuex vue簡(jiǎn)單使用知識(shí)點(diǎn)總結(jié)
在本篇文章里小編給大家整理了關(guān)于vuex vue簡(jiǎn)單使用知識(shí)點(diǎn)總結(jié),有需要的朋友們可以參考下。2019-08-08
vue和webpack打包項(xiàng)目相對(duì)路徑修改的方法
這篇文章主要介紹了vue和webpack打包項(xiàng)目相對(duì)路徑修改的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-06-06
element中el-table中的el-input校驗(yàn)的實(shí)現(xiàn)
本文主要介紹了element中el-table中的el-input校驗(yàn)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08

