diff --git a/src/resources/plugins/TsSheet/form/component/formtextarea.vue b/src/resources/plugins/TsSheet/form/component/formtextarea.vue
index 2da251c41a58f75293f9a57c16bd53449c2ece86..8894c317e8b7afab63c94e706ec1277b976375e8 100644
--- a/src/resources/plugins/TsSheet/form/component/formtextarea.vue
+++ b/src/resources/plugins/TsSheet/form/component/formtextarea.vue
@@ -9,7 +9,7 @@
:value="actualValue"
:readonly="readonly"
:disabled="disabled"
- :validateList="validateList"
+ :validateList="actualValidateList"
:readonlyTextIsHighlight="readonlyTextIsHighlight"
@on-blur="
val => {
@@ -48,6 +48,21 @@ export default {
beforeDestroy() {},
destroyed() {},
methods: {
+ validConfig() {
+ const errorList = this.validDataForAllItem();
+ if (!this.$utils.isEmpty(this.config.regex) && this.$utils.isEmpty(this.config.regexMessage)) {
+ errorList.push({ field: 'regexMessage', error: this.$t('form.placeholder.pleaseinput', {'target': this.$t('message.framework.validtip')}) });
+ }
+ return errorList;
+ },
+ isValidRegex(regexString) { //判断正则表达式是否合法
+ try {
+ new RegExp(regexString);
+ return true;
+ } catch (error) {
+ return false;
+ }
+ }
},
filter: {},
computed: {
@@ -60,6 +75,28 @@ export default {
}
}
return null;
+ },
+ actualValidateList() {
+ let validateList = this.validateList || [];
+ if (!this.$utils.isEmpty(this.config)) {
+ if (this.config.validate) {
+ validateList.push(this.config.validate);
+ }
+ if (!this.$utils.isEmpty(this.config.regex) && this.isValidRegex(this.config.regex)) {
+ let findRegex = validateList.find(item => item.name === 'regex');
+ if (findRegex) {
+ this.$set(findRegex, 'pattern', this.config.regex);
+ this.$set(findRegex, 'message', this.config.regexMessage);
+ } else {
+ validateList.push({
+ name: 'regex',
+ pattern: this.config.regex,
+ message: this.config.regexMessage
+ });
+ }
+ }
+ }
+ return validateList;
}
},
watch: {}
diff --git a/src/resources/plugins/TsSheet/form/config/formtextarea-conf.vue b/src/resources/plugins/TsSheet/form/config/formtextarea-conf.vue
index f8adf877f295995db6e596c4c97ab15336a78ae1..d25b266b3219fb1213489f63e94d2309295262a4 100644
--- a/src/resources/plugins/TsSheet/form/config/formtextarea-conf.vue
+++ b/src/resources/plugins/TsSheet/form/config/formtextarea-conf.vue
@@ -20,6 +20,34 @@
}"
>
+
+ {
+ setConfig('regex', val);
+ }"
+ >
+
+
+
+ {
+ setConfig('regexMessage', val);
+ }"
+ >
+
+