diff --git a/ReportService/wwwroot/js/site.js b/ReportService/wwwroot/js/site.js
index 445941c..a732032 100644
--- a/ReportService/wwwroot/js/site.js
+++ b/ReportService/wwwroot/js/site.js
@@ -83,5 +83,35 @@ var myjs = {
this.post(this.urls.GetServerTime, { format: format }, function (r) {
callback(r.str);
});
- }
+ },
+ toExcel: {
+ uri: 'data:application/vnd.ms-excel;base64,',
+ template: '
' +
+ ' ' +
+ '',
+ base64(s) {
+ return window.btoa(unescape(encodeURIComponent(s)));
+ },
+ format(s, c) {
+ return s.replace(/{(\w+)}/g,
+ function (m, p) {
+ return c[p];
+ });
+ },
+ tableToExcel(tableid, sheetName) {
+ if (!tableid.nodeType) tableid = document.getElementById(tableid);
+ var ctx = { worksheet: sheetName || 'Worksheet', table: tableid.innerHTML };
+ window.open(this.uri + this.base64(this.format(this.template, ctx)));
+ },
+ },
};
\ No newline at end of file
diff --git a/ReportService/wwwroot/report/报表1.html b/ReportService/wwwroot/report/报表1.html
index b845cf8..942f29f 100644
--- a/ReportService/wwwroot/report/报表1.html
+++ b/ReportService/wwwroot/report/报表1.html
@@ -1,27 +1,29 @@
@@ -41,6 +44,13 @@
var findPerson = new Vue({
el: "#findPerson",
data: {
+ //存储过程名称
+ ProcedureName: "example",
+ //报表名称
+ reportName: "报表1",
+
+ //除非你知道以下数据含义,否则不要修改
+ sqlStr: "",
url: myjs.urls.getresult,
result: [],
uid: "",
@@ -53,7 +63,7 @@
methods: {
find() {
var sql = myjs.createSql("#para");
- $("input[name='sqlStr']").val(sql);
+ this.sqlStr = sql;
console.log(sql);
myjs.post(this.url, { sql: sql }, function (d) {
findPerson.result = d;
@@ -61,9 +71,12 @@
},
print() {
var sql = myjs.createSql("#para");
- $("input[name='sqlStr']").val(sql);
+ this.sqlStr = sql;
myjs.print();
},
+ down() {
+ myjs.toExcel.tableToExcel("resultTable", this.reportName);
+ },
}
});