b标题表达式
// 表达式
expression(titleData, config, currentFullParmas) {
let a = titleData.value; // 输入的内容
let res = titleData.value;
let reg = /\{(.*?)\}/gi;
let tmp = a.match(reg);
// 有匹配
if (tmp) {
let b = '';
let arr = [];
for (let i = 0; i < tmp.length; i++) {
b = tmp[i].replace(reg, '$1');
arr.push(tmp[i]);
}
let title = a;
if (currentFullParmas && b in currentFullParmas) {
arr.forEach(i => {
title = title.replace(new RegExp(i, 'gm'), currentFullParmas[b]);
});
res = title;
let info = config.value.chooseValue.value;
if (currentFullParmas && info in currentFullParmas) {
let isEnum = config.value.chooseValue.values.enum;
// 判断是否枚举类型
if (isEnum) {
let data = config.value.data;
if (data.length !== 0) {
data.forEach((item, index) => {
if (item.value === currentFullParmas[info]) {
res = data[index].description;
}
});
}
}
}
} else {
res = title;
}
}
return res;
},