|
@@ -11,7 +11,7 @@
|
11
|
11
|
<el-input v-model="ruleForm.remark" placeholder="备注"/>
|
12
|
12
|
</el-form-item>
|
13
|
13
|
<el-form-item>
|
14
|
|
- <el-button type="primary" @click="operateAdd()">添加</el-button>
|
|
14
|
+ <el-button type="primary" @click="operateAdd('ruleForm')">添加</el-button>
|
15
|
15
|
</el-form-item>
|
16
|
16
|
</el-form>
|
17
|
17
|
</div>
|
|
@@ -40,8 +40,7 @@ export default {
|
40
|
40
|
{ required: true, message: '请输入名称', trigger: 'blur' }
|
41
|
41
|
],
|
42
|
42
|
tel: [
|
43
|
|
- { required: true, message: '请输入手机号', trigger: 'blur' },
|
44
|
|
- { min: 6, max: 11, required: true, message: '请输入11位手机号、400号码或类似025123456固话号码', trigger: 'blur' }
|
|
43
|
+ {required: true, min: 6, max: 11, required: true, message: '请输入11位手机号、400号码或类似025123456固话号码', trigger: 'blur' }
|
45
|
44
|
],
|
46
|
45
|
remark: [
|
47
|
46
|
{ required: false, message: '请输入备注', trigger: 'blur' }
|
|
@@ -52,8 +51,11 @@ export default {
|
52
|
51
|
mounted() {
|
53
|
52
|
},
|
54
|
53
|
methods: {
|
55
|
|
- operateAdd() {
|
56
|
|
- this.$store.dispatch('OperateAdd', this.ruleForm).then((res) => {
|
|
54
|
+ operateAdd(formName) {
|
|
55
|
+
|
|
56
|
+ this.$refs[formName].validate((valid) => {
|
|
57
|
+ if (valid) {
|
|
58
|
+ this.$store.dispatch('OperateAdd', this.ruleForm).then((res) => {
|
57
|
59
|
if (res.code === '0') {
|
58
|
60
|
this.$message({
|
59
|
61
|
message: '操作成功',
|
|
@@ -66,8 +68,22 @@ export default {
|
66
|
68
|
}).catch(() => {
|
67
|
69
|
console.log('error OperateAdd')
|
68
|
70
|
})
|
|
71
|
+ } else {
|
|
72
|
+ console.log('error submit!!');
|
|
73
|
+ return false;
|
|
74
|
+ }
|
|
75
|
+ });
|
|
76
|
+ },
|
|
77
|
+ resetForm(formName) {
|
|
78
|
+ this.$refs[formName].resetFields();
|
|
79
|
+ }
|
69
|
80
|
}
|
70
|
|
- }
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
71
|
87
|
}
|
72
|
88
|
</script>
|
73
|
89
|
|