Skip to content

Commit

Permalink
[feature]{widgetConfig}: 加入自定义设置错误提示语
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Aug 19, 2019
1 parent df5b2f9 commit f718229
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/components/FormDesigner/WidgetConfig.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
* @file: 表单设计器右侧配置项区域
* @copyright: NanJing Anshare Tech .Com
* @author: BoBo
* @Date: 2019-03-21 16:47:49
-->
<template>
<div v-if="show">
<el-form label-position="top">
Expand Down Expand Up @@ -489,6 +495,10 @@
size="mini"
style=" width: 240px;"
placeholder="填写正则表达式"/>
<el-input size="mini"
v-model.lazy="data.options.message"
style=" width: 240px;"
placeholder="自定义错误提示语"></el-input>
</div>
</el-form-item>
</template>
Expand Down Expand Up @@ -568,23 +578,36 @@ export default {
});
},
'data.options.dataType': function watchDataType(val) {
let message = `${this.data.name}格式不正确`;
// 如果自定义了错误提示语则赋值
if (this.data.options.message != null && this.data.options.message !== '') {
// eslint-disable-next-line prefer-destructuring
message = this.data.options.message;
}
if (!this.show) {
return false;
}
if (val) {
this.validator.type = { type: val, message: `${this.data.name}格式不正确` };
this.validator.type = { type: val, message };
} else {
this.validator.type = null;
}
this.generateRule();
return null;
},
'data.options.pattern': function watchPattern(val) {
let message = `${this.data.name}格式不正确`;
// 如果自定义了错误提示语则赋值
if (this.data.options.message != null && this.data.options.message !== '') {
// eslint-disable-next-line prefer-destructuring
message = this.data.options.message;
}
if (!this.show) {
return false;
}
if (val) {
this.validator.pattern = { pattern: val, message: `${this.data.name}格式不匹配` };
this.validator.pattern = { pattern: val, message };
} else {
this.validator.pattern = null;
}
Expand Down

0 comments on commit f718229

Please sign in to comment.