Browse Source

打分初版

master
jian 3 years ago
parent
commit
97136dda92
  1. 8
      index.html
  2. 5
      paper/_Report.js
  3. 35
      paper/core/Report.js
  4. 36
      paper/core/Utils.js
  5. 35
      paper/core/Widget.js
  6. 1416
      paper/paper_1.js

8
index.html

@ -15,7 +15,15 @@
<input type="file" id="file-input" accept="application/zip" hidden>
</label>
</div>
<!-- zip解压 -->
<script src="./third/zip-no-worker-inflate.min.js"></script>
<!-- 核心代码 -->
<script src="./paper/core/Utils.js"></script>
<script src="./paper/core/Widget.js"></script>
<script src="./paper/core/Report.js"></script>
<!-- 试卷评分 -->
<script src="./paper/Paper_1.js"></script>
<!-- 入口 -->
<script src="./index.js"></script>
</body>
</html>

5
paper/_Report.js

@ -1,5 +0,0 @@
class Report {
constructor(report) {
this.reportId = report.
}
}

35
paper/core/Report.js

@ -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;
}
}

36
paper/core/Utils.js

@ -0,0 +1,36 @@
const REGULAR_STRING = {
HTML_STYLE_TAG: '<[^<>]+>',
ENTER: '[\n\r]',
};
Utils = {
htmlDecode: function (text) {
return !text ? "" : (text + "").replaceAll("&amp;|&dollar;|&lcub;|&rcub;|&quot;|&lt;|&gt;|&nbsp;", function (v) {
switch (v) {
case "&amp;":
return "&";
case "&dollar;":
return "$";
case "&lcub;":
return "{";
case "&rcub;":
return "}";
case "&quot;":
return "\"";
case "&lt;":
return "<";
case "&gt;":
return ">";
case "&nbsp;":
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"), '')
)
}
}

35
paper/core/Widget.js

@ -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;
}
}

1416
paper/paper_1.js

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save