6 changed files with 1529 additions and 6 deletions
@ -1,5 +0,0 @@
|
||||
class Report { |
||||
constructor(report) { |
||||
this.reportId = report. |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
class Report { |
||||
constructor(report) { |
||||
this.reportId = report.reportId; |
||||
this.reportName = report.reportName; |
||||
this.cancelDefaultLinkag = report.cancelDefaultLinkag; |
||||
this.createBy = report.createBy; |
||||
this.filter = report.filter; |
||||
this.freeWidgetIds = report.freeWidgetIds; |
||||
this.linkageGroup = report.linkageGroup; |
||||
this.mobileWidgetConfig = report.mobileWidgetConfig; |
||||
this.templateStyle = report.templateStyle; |
||||
this.widgets = {}; |
||||
for (const wId in report.widgets) { |
||||
this.widgets[wId] = new Widget(report.widgets[wId]); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 找组件名是xxx的组件 |
||||
* 组件名是富文本,需要解析富文本才能拿到文字信息 |
||||
* 名字不应该特别复杂 |
||||
*/ |
||||
getWidgetByName(name) { |
||||
let widget; |
||||
for (const wId in this.widgets) { |
||||
const w = this.widgets[wId]; |
||||
if (w.getPlainWidgetName() === name) { |
||||
widget = w; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return widget; |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
const REGULAR_STRING = { |
||||
HTML_STYLE_TAG: '<[^<>]+>', |
||||
ENTER: '[\n\r]', |
||||
}; |
||||
|
||||
Utils = { |
||||
htmlDecode: function (text) { |
||||
return !text ? "" : (text + "").replaceAll("&|$|{|}|"|<|>| ", function (v) { |
||||
switch (v) { |
||||
case "&": |
||||
return "&"; |
||||
case "$": |
||||
return "$"; |
||||
case "{": |
||||
return "{"; |
||||
case "}": |
||||
return "}"; |
||||
case """: |
||||
return "\""; |
||||
case "<": |
||||
return "<"; |
||||
case ">": |
||||
return ">"; |
||||
case " ": |
||||
default: |
||||
return " "; |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
getPlainText: function (name) { |
||||
return Utils.htmlDecode( |
||||
name.replace(new RegExp(REGULAR_STRING.HTML_STYLE_TAG, "gm"), '').replace(new RegExp(REGULAR_STRING.ENTER, "gm"), '') |
||||
) |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
class Widget { |
||||
constructor(widget) { |
||||
this.wId = widget.wId; |
||||
this.name = widget.name; |
||||
this.type = widget.type; |
||||
this.tableName = widget.tableName; |
||||
this.viewAttr = widget.viewAttr; |
||||
this.allowOverlap = widget.allowOverlap; |
||||
this.showTitle = widget.showTitle; |
||||
this.view = widget.view; |
||||
this.dimensions = widget.dimensions; |
||||
this.allData = widget.allData; |
||||
this.settings = widget.settings; |
||||
this.linkageSetting = widget.linkageSetting; |
||||
this.linkage = widget.linkage; |
||||
this.jump = widget.jump; |
||||
this.drillOrder = widget.drillOrder; |
||||
this.resultFilter = widget.resultFilter; |
||||
this.equallyDivideColumn = widget.equallyDivideColumn; |
||||
this.measures = widget.measures; |
||||
} |
||||
|
||||
getWidgetName() { |
||||
return this.name; |
||||
} |
||||
|
||||
getPlainWidgetName() { |
||||
if (!this.pureName) { |
||||
this.pureName = Utils.getPlainText(this.getWidgetName());
|
||||
} |
||||
|
||||
return this.pureName; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue