|
|
@@ -30,15 +30,15 @@ function converter(data) {
|
|
|
|
|
|
function titleConfig(title) {
|
|
|
return {
|
|
|
- title: title,
|
|
|
+ title: replaceSpecTag(title),
|
|
|
fontSize: getFontSize()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function formConfig(model) {
|
|
|
- let { type, header, config, layout } = model;
|
|
|
- let { fontSize, fieldstyle, valuestyle, columns, data } = config;
|
|
|
- data = data.map((d) => {
|
|
|
+ let { type, config, layout } = model;
|
|
|
+ let { fontSize, header, fieldStyle, valueStyle, columns, data } = config;
|
|
|
+ data = data ? data.map((d) => {
|
|
|
d.field = {
|
|
|
text: d.field.text,
|
|
|
style: parseStyleStr(d.field.style)
|
|
|
@@ -47,15 +47,16 @@ function formConfig(model) {
|
|
|
text: d.value.text,
|
|
|
style: parseStyleStr(d.value.style)
|
|
|
};
|
|
|
+ d.render = renderFunction(d.render);
|
|
|
return d;
|
|
|
- });
|
|
|
+ }) : [];
|
|
|
let c = {
|
|
|
type: 'form',
|
|
|
config: {
|
|
|
fontSize: fontSize || getFontSize(),
|
|
|
- header: header,
|
|
|
- fieldStyle: parseStyleStr(fieldstyle),
|
|
|
- valueStyle: parseStyleStr(valuestyle),
|
|
|
+ header: renderFunction(header),
|
|
|
+ fieldStyle: parseStyleStr(fieldStyle),
|
|
|
+ valueStyle: parseStyleStr(valueStyle),
|
|
|
columns,
|
|
|
data
|
|
|
},
|
|
|
@@ -73,17 +74,20 @@ function tableConfig(model) {
|
|
|
fontSize: fontSize || getFontSize(),
|
|
|
pageSize: pagesize,
|
|
|
refreshInterval: interval,
|
|
|
- title: title,
|
|
|
+ title: renderFunction(title),
|
|
|
render: renderFunction(render),
|
|
|
- columns: columns.map((v, i) => {
|
|
|
+ columns: columns ? columns.map((v, i) => {
|
|
|
v.key = i;
|
|
|
v.render = renderFunction(v.render);
|
|
|
+ v.rowStyle = parseStyleStr(v.rowstyle);
|
|
|
return v;
|
|
|
- }),
|
|
|
- data: data.map((v, i) => {
|
|
|
- v.key = i;
|
|
|
+ }) : [],
|
|
|
+ data: data ? data.map((v, i) => {
|
|
|
+ if(v){
|
|
|
+ v.key = i;
|
|
|
+ }
|
|
|
return v;
|
|
|
- }),
|
|
|
+ }) : [],
|
|
|
headerRowsStyle: parseStyleStr(headerrowsstyle),
|
|
|
rowsStyle: parseStyleStr(rowsstyle),
|
|
|
},
|
|
|
@@ -94,7 +98,6 @@ function tableConfig(model) {
|
|
|
function barConfig(model) {
|
|
|
let { type, config, layout } = model;
|
|
|
let { fontSize, title, subtitle, xtitle, xtype, xfields, ytitle, ytype, yfields, series } = config;
|
|
|
-
|
|
|
let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(','));
|
|
|
return {
|
|
|
type: 'charts',
|
|
|
@@ -263,7 +266,8 @@ function pieConfig(model) {
|
|
|
}
|
|
|
|
|
|
function renderFunction(funcStr) {
|
|
|
- let func = function (_v, _r, _i) { return { children: _v, props: {} } };
|
|
|
+ // let func = function (_v, _r, _i) { return { children: _v, props: {} } };
|
|
|
+ let func = undefined;
|
|
|
try {
|
|
|
func = (new Function("return " + funcStr))();
|
|
|
} catch (ex) {
|
|
|
@@ -425,6 +429,23 @@ function parseStyleStr(str) {
|
|
|
return obj
|
|
|
}
|
|
|
|
|
|
+function replaceSpecTag(str) {
|
|
|
+ if (str) {
|
|
|
+ if (typeof (str) === 'string') {
|
|
|
+ return str.replace(/&/g, '&')
|
|
|
+ .replace(/</g, '<')
|
|
|
+ .replace(/>/g, '>')
|
|
|
+ .replace(/'/g, '\'')
|
|
|
+ .replace(/"/g, '"')
|
|
|
+ .replace(/ /g, ' ');
|
|
|
+ } else {
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function getScreenSize() {
|
|
|
let root = document.getElementById('root');
|
|
|
let height = root.offsetHeight;
|