表单校验几个细节问题

master
Chopper 2021-10-19 14:20:20 +08:00
parent 7cbd2b698c
commit 31d9859f10
6 changed files with 42 additions and 23 deletions

View File

@ -62,10 +62,14 @@ export const TEL = /0\d{2,3}-\d{7,8}/
// 正整数 // 正整数
export const INTEGER = { export const INTEGER = {
pattern: /^[0-9]\d{0,10}|0$/, pattern: /^[0-9]\d{0,10}|0$/,
message:'请输入正整数' message:'请输入正整数'
}
// 正整数
export const NUMBER = {
pattern: /^(\-|\+)?\d{0,10}$/,
message:'请输入数字'
} }
export const VARCHAR5 = { export const VARCHAR5 = {
pattern:/^.{1,5}$/, pattern:/^.{1,5}$/,
message:'长度应该限制在1-5个字符' message:'长度应该限制在1-5个字符'

View File

@ -35,7 +35,7 @@
:width="500" :width="500"
> >
<Form ref="form" :model="form" :label-width="100" :rules="formValidate"> <Form ref="form" :model="form" :label-width="100" :rules="formValidate">
<FormItem label="自定义分词" prop="sn"> <FormItem label="自定义分词" prop="name">
<Input v-model="form.name" clearable style="width: 100%" /> <Input v-model="form.name" clearable style="width: 100%" />
</FormItem> </FormItem>
</Form> </Form>
@ -56,6 +56,8 @@ import {
insertCustomWords, insertCustomWords,
updateCustomWords updateCustomWords
} from "@/api/index"; } from "@/api/index";
import { regular } from "@/utils";
export default { export default {
name: "customWords", name: "customWords",
data() { data() {
@ -79,11 +81,8 @@ export default {
// //
formValidate: { formValidate: {
name: [ name: [
{ regular.REQUIRED,
required: true, regular.VARCHAR20
message: "请输入自定义分词",
trigger: "blur",
},
], ],
}, },
submitLoading: false, // submitLoading: false, //

View File

@ -20,11 +20,12 @@
</Card> </Card>
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500"> <Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500">
<Form ref="form" :model="form" :label-width="100" > <Form ref="form" :model="form" :label-width="100"
<FormItem label="热词" prop="name"> :rules="formValidate">
<FormItem label="热词" prop="keywords">
<Input v-model="form.keywords" clearable style="width: 100%" /> <Input v-model="form.keywords" clearable style="width: 100%" />
</FormItem> </FormItem>
<FormItem label="分数" prop="name"> <FormItem label="分数" prop="point">
<Input v-model="form.point" clearable style="width: 100%" /> <Input v-model="form.point" clearable style="width: 100%" />
</FormItem> </FormItem>
</Form> </Form>
@ -39,6 +40,7 @@
<script> <script>
import { getHotWords, setHotWords } from "@/api/index"; import { getHotWords, setHotWords } from "@/api/index";
import { regular } from "@/utils";
export default { export default {
name: "hotWords", name: "hotWords",
components: {}, components: {},
@ -53,6 +55,18 @@ export default {
point: 0, point: 0,
}, },
data: [], // data: [], //
//
formValidate: {
keywords:[
regular.REQUIRED,
regular.VARCHAR20,
],
point:[
regular.REQUIRED,
regular.NUMBER
]
},
}; };
}, },
methods: { methods: {
@ -94,7 +108,6 @@ export default {
this.form.keywords = ""; this.form.keywords = "";
} }
this.form.point = 1; this.form.point = 1;
this.$refs.form.resetFields();
this.modalVisible = true; this.modalVisible = true;
}, },
}, },

View File

@ -14,7 +14,7 @@
<p slot="title">账单详细</p> <p slot="title">账单详细</p>
<div class="tips-status"> <div class="tips-status">
<span>商品状态</span> <span>账单状态</span>
<span class="theme_color">{{bill.billStatus | unixSellerBillStatus}}</span> <span class="theme_color">{{bill.billStatus | unixSellerBillStatus}}</span>
<Button <Button
v-if="bill.billStatus == 'CHECK'" v-if="bill.billStatus == 'CHECK'"

View File

@ -141,6 +141,7 @@
v-model="messageSendForm.content" v-model="messageSendForm.content"
:rows="4" :rows="4"
type="textarea" type="textarea"
maxlength="200"
style="max-height:60vh;overflow:auto;width: 70%" style="max-height:60vh;overflow:auto;width: 70%"
/> />
</FormItem> </FormItem>
@ -288,7 +289,7 @@
import * as API_Other from "@/api/other.js"; import * as API_Other from "@/api/other.js";
import * as API_Shop from "@/api/shops.js"; import * as API_Shop from "@/api/shops.js";
import userList from "@/views/member/list/index"; import userList from "@/views/member/list/index";
import { regular } from "@/utils";
export default { export default {
name: "noticeMessageTemplate", name: "noticeMessageTemplate",
components: { components: {
@ -316,10 +317,12 @@
}, },
messageFormValidate: { messageFormValidate: {
title: [ title: [
{required: true, message: '请输入消息标题', trigger: 'blur'}, regular.REQUIRED,
regular.VARCHAR20
], ],
content: [ content: [
{required: true, message: '请输入消息内容', trigger: 'blur'}, regular.REQUIRED,
regular.VARCHAR255
], ],
}, },
// //

View File

@ -14,7 +14,7 @@
<p slot="title">账单详细</p> <p slot="title">账单详细</p>
<div class="tips-status"> <div class="tips-status">
<span>商品状态</span> <span>账单状态</span>
<span class="theme_color">{{ <span class="theme_color">{{
bill.billStatus | unixSellerBillStatus bill.billStatus | unixSellerBillStatus