huangxiaomin 3 years ago
parent
commit
8c283eb067
  1. 5
      ureport2-console/src/main/java/com/bstek/ureport/console/html/HtmlPreviewServletAction.java
  2. 2
      ureport2-console/src/main/resources/ureport-html/html-preview.html
  3. 2
      ureport2-js/src/designer.js
  4. 29
      ureport2-js/src/tools/BackTool.js
  5. 33
      ureport2-js/src/tools/PreviewTool.js

5
ureport2-console/src/main/java/com/bstek/ureport/console/html/HtmlPreviewServletAction.java

@ -120,6 +120,8 @@ public class HtmlPreviewServletAction extends RenderPageServletAction {
String customParameters = buildCustomParameters(req);
context.put("customParameters", customParameters);
context.put("_t", "");
boolean isBack = StringUtils.isNotBlank(req.getParameter("isBack"));
context.put("isback",isBack);
Tools tools = null;
if (MobileUtils.isMobile(req)) {
tools = new Tools(false);
@ -140,6 +142,9 @@ public class HtmlPreviewServletAction extends RenderPageServletAction {
context.put("hasTools", true);
} else {
tools = new Tools(false);
if(!isBack){
tools.setShow(false);
}
}
}
context.put("tools", tools);

2
ureport2-console/src/main/resources/ureport-html/html-preview.html

@ -123,9 +123,11 @@ ${upSearchFormHtml}
<span id='pageLinkContainer'></span>
</span>
#end
#if($isback)
<button type="button" class="btn btn-default ureport-back-btn" style="display:inline-block;padding:0;background:#f8f8f8;border:none;margin:3px;float: right" title="返回">
<img src='${contextPath}/ureport/res/ureport-asserts/icons/back.svg' width="22px" height="22px">
</button>
#end
</div>
</div>
#end

2
ureport2-js/src/designer.js

@ -35,6 +35,7 @@ import {undoManager} from './Utils.js';
import PrintLine from './PrintLine.js';
import FileInfo from './FileInfo.js';
import {renderRowHeader} from './table/HeaderUtils.js';
import BackTool from "./tools/BackTool";
export default class UReportDesigner{
constructor(containerId,searchFormContainerId){
@ -144,6 +145,7 @@ export default class UReportDesigner{
this.tools.push(new ChartTool(context));
this.tools.push(new SettingsTool(context));
this.tools.push(new SearchFormSwitchTool(context));
this.tools.push(new BackTool(context));
for(const tool of this.tools){
toolbar.append(tool.buildButton());
}

29
ureport2-js/src/tools/BackTool.js

@ -0,0 +1,29 @@
/**
* Created by Jacky.Gao on 2017-01-25.
*/
import Tool from './Tool.js';
export default class OpenTool extends Tool{
constructor(context){
super(context);
}
execute(){
window.parent.postMessage({'goback': -1},'*')
}
getTitle(){
return `${window.i18n.openFile}`;
}
getIcon(){
return `<img src='${window._contextPath}/ureport/res/ureport-asserts/icons/back.svg' width="22px" height="22px">`;
}
// buildButton(){
// const btn=$(`<button type="button" class="btn btn-default" style="border:none;border-radius:0;background: #f8f8f8;padding: 6px 5px;" title="${this.getTitle()}">
// ${this.getIcon()}
// </button>`);
// const _this=this;
// btn.click(function(){
// _this.execute();
// });
// return btn;
// }
}

33
ureport2-js/src/tools/PreviewTool.js

@ -32,7 +32,7 @@ export default class PreviewTool extends Tool{
type:'POST',
success:function(){
resetDirty();
_this.doPreview();
_this.doPreview(false);
},
error:function(response){
if(response && response.responseText){
@ -60,23 +60,26 @@ export default class PreviewTool extends Tool{
}
doPreview(withPaging){
// let targetUrl=window._server+"/preview?_u=p";
let targetUrl=window._server+"/preview?_u="+ withPaging ? "p" : window._reportFile;
console.log("前往预览")
let targetUrl=window._server+"/preview?_u="+ (withPaging ? "p" : window._reportFile);
// if(withPaging){
// targetUrl+='&_i=1&_r=1';
// }
const content=tableToXml(this.context);
$.ajax({
url:window._server+"/designer/savePreviewData",
type:'POST',
data:{content},
success:function(){
let newWindow=window.open(targetUrl,"_blank");
newWindow.focus();
},
error:function(){
alert(`${window.i18n.tools.preview.previewFail}`);
}
});
// const content=tableToXml(this.context);
let newWindow=window.open(targetUrl,"_blank");
newWindow.focus();
// $.ajax({
// url:window._server+"/designer/savePreviewData",
// type:'POST',
// data:{content},
// success:function(){
// let newWindow=window.open(targetUrl,"_blank");
// newWindow.focus();
// },
// error:function(){
// alert(`${window.i18n.tools.preview.previewFail}`);
// }
// });
}
getTitle(){
return `${window.i18n.tools.preview.preview}`;

Loading…
Cancel
Save