web-vue2
Version:
web ui for vue2
81 lines (80 loc) • 2.67 kB
JavaScript
const i18nRegex = /^[\[]((\w|\d|[.%_-])+)[\]]$/;
/**
* 已正式加入框架体系应用
* marked by deleteelf 20210819
*/
export default {
methods: {
adapterUrl(url) {
if(url) {
if (this.$d.isExternal(url))
return url;
else {
if (url.indexOf("/") == 0)
return this.$store.state.api.axios.baseURL + url;
else
return this.$store.state.api.axios.baseURL + "/" + url;
}
}
return "";
},hasRichText(text){
return /^[<][-\w]+([ ].*)*[>].*[<][/][-\w]+[>]$/.test(text);
},$_i18n(text){
if (i18nRegex.test(text)) {
return this.$i18n.t(i18nRegex.exec(text)[1]);
}
return text;
},placeholderAdapter(item) {
if (!this.form||!this.form.readonly) {
switch (item.type) {
case "text":
case "editor":
case "textarea":
return this.$_i18n(item.remark) || (this.checkDisable(item) ?
this.$_i18n(item.name) + this.$t("form.system_build") :
this.$t("form.write") + this.$_i18n(item.name));
break;
case "select":
case "dropdownchecklist":
case "selectTree":
return this.$t("form.select");
case "autocomplete":
case "autocomplete_remote":
return this.$t("form.autocomplete");
default:
return this.$_i18n(item.remark);
}
} else {
return "";
}
},checkDisable(item) {
if (this.options&&this.options.params&&this.options.params.readonly) {
return true;
}else if(item.disable===true) {//业务干预 //某些情况下,需要由代码业务逻辑来控制禁用
return true;
}else if(item.readonly===true){//业务干预 //某些情况下,需要由代码业务逻辑来控制只读
return true;
} else if(item.modReadonly!=null||item.addReadonly!=null){
if (this.options.params.id) {
return item.modReadonly;
} else {
return item.addReadonly;
}
}
return false;
},setControlTitle(item) {
switch (item.type) {
case "text":
case "editor":
case "textarea":
return this.$_i18n(item.remark) || (this.checkDisable(item) ?
"" : this.$t("form.write") + this.$_i18n(item.name));
break;
default:
return this.$_i18n(item.remark) || (this.checkDisable(item) ?
"" : this.$t("form.select") + this.$_i18n(item.name));
break;
}
}
}
}