商品模块代码继续完善,表单校验等

This commit is contained in:
Chopper
2021-09-22 15:32:47 +08:00
parent 2932c7f35d
commit 20042786aa
6 changed files with 52 additions and 25 deletions

View File

@@ -57,6 +57,9 @@ import {
updateGoodsUnit,
delGoodsUnit
} from "@/api/index";
import {regular} from "@/utils";
export default {
name: "goods-unit",
data() {
@@ -79,12 +82,9 @@ export default {
// 表单验证规则
formValidate: {
name: [
{
required: true,
message: "请输入计量单位",
trigger: "blur",
},
],
regular.REQUIRED,
regular.VARCHAR5
]
},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据

View File

@@ -56,7 +56,8 @@
:mask-closable="false"
:width="500"
>
<Form ref="form" :model="form" :label-width="100">
<Form ref="form" :model="form" :label-width="100"
:rules="formValidate">
<FormItem label="规格名称" prop="specName">
<Input v-model="form.specName" maxlength="30" clearable style="width: 100%"/>
</FormItem>
@@ -92,6 +93,7 @@ import {
delSpec
} from "@/api/goods";
import {regular} from "@/utils";
export default {
name: "spec",
components: {},
@@ -108,6 +110,17 @@ export default {
sort: "createTime", // 默认排序字段
order: "asc", // 默认排序方式
},
// 表单验证规则
formValidate: {
specName: [
regular.REQUIRED,
regular.VARCHAR20
],
specValue: [
regular.REQUIRED,
regular.VARCHAR255
],
},
form: {
// 添加或编辑表单对象初始化数据
specName: "",
@@ -280,6 +293,7 @@ export default {
this.modalType = 0;
this.modalTitle = "添加";
this.$refs.form.resetFields();
this.specValue = '';
delete this.form.id;
this.modalVisible = true;
},