159 lines
5.0 KiB
HTML
159 lines
5.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
|
|
<meta http-equiv="Pragma" content="no-cache"/>
|
|
<meta http-equiv="Expires" content="0"/>
|
|
<title>Index</title>
|
|
<script src="/reportbro/static/src/js/dist/ext/jquery.js"></script>
|
|
<link rel="stylesheet" href="/reportbro/static/src/js/dist/reportbro.css"/>
|
|
<script src="/reportbro/static/src/js/dist/reportbro.js"></script>
|
|
<link rel="stylesheet" href="/reportbro/static/src/js/dist/ext/spectrum.css"/>
|
|
<script src="/reportbro/static/src/js/dist/ext/autosize.js"></script>
|
|
<script src="/reportbro/static/src/js/dist/ext/JsBarcode.all.min.js"></script>
|
|
<script src="/reportbro/static/src/js/dist/ext/spectrum.js"></script>
|
|
<link rel="stylesheet" href="/reportbro/static/src/js/dist/src/iconfonts/font.css"/>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
|
|
//var report_id=get_report_id();
|
|
//var report_id = getUrlArgs().report_id;
|
|
function get_report_id()
|
|
{
|
|
$.ajax({
|
|
url: '/api/report/get_report_id',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
type: 'post',
|
|
data: JSON.stringify({"report_id": ''}),
|
|
success: function (res) {
|
|
if (res.result.code === 0) {
|
|
return res.result.id;
|
|
}
|
|
else {
|
|
alert('错误');
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//取URL 参数
|
|
function getUrlArgs() {
|
|
var url = top.location.href;
|
|
var i = url.indexOf('#');
|
|
if (i == -1) return;
|
|
var querystr = url.substr(i + 1);
|
|
var arr1 = querystr.split('&');
|
|
var arr2 = new Object();
|
|
for (i in arr1) {
|
|
var t = arr1[i].split('=');
|
|
arr2[t[0]] = t[1];
|
|
}
|
|
return arr2;
|
|
}
|
|
//读取数据库配置
|
|
function report_designer() {
|
|
$.ajax({
|
|
url: '/api/report/get_report_id',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
type: 'post',
|
|
data: JSON.stringify({"report_id": ''}),
|
|
success: function (res) {
|
|
if (res.result.code === 0) {
|
|
$.ajax({
|
|
url: '/api/report/report_read',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
type: 'post',
|
|
data: JSON.stringify({"report_id": res.result.id}),
|
|
success: function (r) {
|
|
if (r.result.code === 0) {
|
|
$('#reportbro').reportBro('load',r.result.msg);
|
|
}
|
|
else {
|
|
alert(r.result.msg)
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
else {
|
|
alert('错误');
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
function saveReport() {
|
|
var report_data = $('#reportbro').reportBro('getReport');
|
|
|
|
$.ajax({
|
|
url: '/api/report/get_report_id',
|
|
dataType: 'json',
|
|
contentType: 'application/json',
|
|
type: 'post',
|
|
data: JSON.stringify({"report_id": ''}),
|
|
success: function (res) {
|
|
if (res.result.code === 0) {
|
|
$.ajax({
|
|
url: '/api/report/report_save',
|
|
data: JSON.stringify({
|
|
'report_id': res.result.id,
|
|
'report_data': report_data
|
|
}),
|
|
dataType: 'json',
|
|
type: 'POST',
|
|
async: false,
|
|
contentType: 'application/json',
|
|
success: function (r) {
|
|
if (r.result.code == 0) {
|
|
alert(r.result.msg);
|
|
} else {
|
|
alert(r.result.msg);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Save Fail');
|
|
},
|
|
|
|
});
|
|
}
|
|
else {
|
|
alert('错误');
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
$('#reportbro').reportBro({
|
|
saveCallback: saveReport,
|
|
reportServerUrl: "/api/report/report_server/run",
|
|
additionalFonts: [{name: 'Courier', value: 'courier'},{name: 'Helvetica', value: 'helvetica'},{name: 'Times New Roman', value: 'times'},{name: '雅黑常规', value: 'msyh'}]//客户端添加字体及样式里添加,服务端也要添加同样名称字体支持中文
|
|
});
|
|
report_designer();
|
|
|
|
|
|
});
|
|
</script>
|
|
|
|
<div id="reportbro"></div>
|
|
</body>
|
|
</html>
|