sysReportEdit.jsp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <%--
  2. time:2012-04-12 09:59:47
  3. desc:edit the 报表模板
  4. --%>
  5. <%@page language="java" pageEncoding="UTF-8"%>
  6. <%@include file="/commons/include/html_doctype.html"%>
  7. <html>
  8. <head>
  9. <title>编辑 报表模板</title>
  10. <%@include file="/commons/include/form.jsp" %>
  11. <f:link href="tree/zTreeStyle.css"></f:link>
  12. <script type="text/javascript" src="${ctx}/js/hotent/platform/system/Share.js"></script>
  13. <script type="text/javascript"src="${ctx}/js/hotent/platform/system/ScriptDialog.js"></script>
  14. <script type="text/javascript" src="${ctx}/js/hotent/CustomValid.js"></script>
  15. <script type="text/javascript" src="${ctx}/js/hotent/platform/system/SysDialog.js"></script>
  16. <script type="text/javascript" src="${ctx}/js/hotent/platform/form/FormUtil.js"></script>
  17. <script type="text/javascript" src="${ctx}/js/hotent/platform/form/CommonDialog.js"></script>
  18. <script type="text/javascript" src="${ctx}/js/lg/plugins/ligerComboBox.js"></script>
  19. <script type="text/javascript" src="${ctx}/js/lg/plugins/htCatCombo.js"></script>
  20. <script type="text/javascript" src="${ctx}/js/tree/jquery.ztree.js"></script>
  21. <script type="text/javascript">
  22. $(function() {
  23. $("a.save").click(function() {
  24. var rtn=$('#reportForm').form().valid();
  25. if(!rtn) return;
  26. if(!'${report.reportId}'){
  27. var path = $("#file").val();
  28. var index = path.lastIndexOf('.');
  29. var extName = path.substring(index+1,path.length);
  30. if(path==''){
  31. $.ligerDialog.warn("请上传模板文件");
  32. return false ;
  33. }else if('zip'!=extName && 'jrxml'!=extName){
  34. $.ligerDialog.warn("请选择 *.zip或*.jrxml文件进行上传!","提示信息");
  35. return false ;
  36. }
  37. }
  38. //设置报表参数
  39. var paraInfo = $('#paraInfo tbody tr');
  40. var paramArr = [] ;
  41. for(var i=0;i<paraInfo.length;i++){
  42. var self = $(paraInfo[i]);
  43. var obj = {} ;
  44. obj.field = $('#field',self).text();
  45. obj.paraType = $('#paraType',self).text();
  46. obj.comment = $('#comment',self).val();
  47. var type = obj.defaultType = $('#defaultType',self).val();
  48. if(type=='0'){
  49. obj.defaultValue = $('#defaultValue',self).val();
  50. }else if(type=='1'){
  51. //表单输入,添加控件类型
  52. obj.paraCt = $('#paraCt',self).val();
  53. var dialogCt = $('#settingSpan',self);
  54. if(dialogCt.css('display')!='none'){
  55. //添加自定义对话框控件参数
  56. var dialogType = $('#dialog-type',dialogCt).val();
  57. var dialogParam = $('#dialog-param',dialogCt).val();
  58. if(!dialogType){
  59. $.ligerDialog.warn("请选择自定义对话框");
  60. return false ;
  61. }else if(!dialogType){
  62. $.ligerDialog.warn("请选择对话框返回值");
  63. return false ;
  64. }
  65. obj.dialog = dialogType;
  66. obj.dialogParam = dialogParam;
  67. }
  68. }else{
  69. obj.defaultValue = $('#area',self).val();
  70. }
  71. paramArr.push(obj);
  72. }
  73. $('#params').val(JSON2.stringify(paramArr));
  74. $("#reportForm").submit();
  75. $.ligerDialog.waitting('处理中,请稍候……','提示');
  76. });
  77. $("#reportForm").ajaxForm({success:showResponse});
  78. function showResponse(responseText, statusText){
  79. $.ligerDialog.closeWaitting();
  80. var json=eval('('+responseText+')');
  81. if(json.result==1){
  82. if(json.message){
  83. $.ligerDialog.confirm('报表中包含参数,是否继续设置?','添加报表成功',function(result){
  84. if(result){
  85. window.location.href='edit.ht?reportId='+json.message;
  86. }else{
  87. window.location.href='list.ht';
  88. }
  89. });
  90. }else{
  91. $.ligerDialog.confirm('保存成功,是否继续操作?','提示',function(result){
  92. if(!result){
  93. window.location.href='list.ht';
  94. }
  95. });
  96. }
  97. }else{
  98. $.ligerDialog.err("提示信息","报表模板保存失败!",json.message.trim());
  99. }
  100. }
  101. //获取自定义对话框
  102. getDialogs();
  103. $('#selectBtn').live('click',function(){
  104. var self = this ;
  105. var closestTd = $(self).closest('td');
  106. var type = $(this).siblings('#paraCt').val();
  107. switch (parseInt(type)) {
  108. //自定义对话框
  109. case 0 :
  110. var dialog = closestTd.find('#dialog-type');
  111. var dialogParam = closestTd.find('#dialog-param').val();
  112. var alias = dialog.val();
  113. if(!dialogParam){
  114. $.ligerDialog.warn("请选择对话框返回值");
  115. return false ;
  116. }
  117. var rtnValue = "" ;
  118. var temp = {};
  119. CommonDialog(alias,function(data){
  120. if(Object.prototype.toString.call((data)) == '[object Array]'){
  121. for(var j=0;j<data.length;j++){
  122. temp = data[j];
  123. if(temp[dialogParam])
  124. rtnValue+=temp[dialogParam]+',';
  125. }
  126. dialogCallBack(rtnValue.substring(0,rtnValue.length-1),"",self);
  127. }else{
  128. dialogCallBack(data[dialogParam],"",self);
  129. }
  130. });
  131. break;
  132. // 人员选择器(单选)
  133. case 4 :
  134. UserDialog({
  135. isSingle : true,
  136. callback : function(ids, names) {
  137. dialogCallBack(ids,names,self);
  138. }
  139. });
  140. break;
  141. // 角色选择器(单选)
  142. case 17 :
  143. RoleDialog({
  144. isSingle : true,
  145. callback : function(ids, names) {
  146. dialogCallBack(ids,names,self);
  147. }
  148. });
  149. break;
  150. // 组织选择器(单选)
  151. case 18 :
  152. OrgDialog({
  153. isSingle : true,
  154. callback : function(ids, names) {
  155. dialogCallBack(ids,names,self);
  156. }
  157. });
  158. break;
  159. // 岗位选择器(单选)
  160. case 19 :
  161. PosDialog({
  162. isSingle : true,
  163. callback : function(ids, names) {
  164. dialogCallBack(ids,names,self);
  165. }
  166. });
  167. break;
  168. }
  169. });
  170. if('${paramList}'){
  171. //构造参数表格
  172. var param = constructParamTable(${paramList});
  173. $("#paraInfo").empty().append(param);
  174. }
  175. //初始化报表分类
  176. initReportType();
  177. });
  178. function initReportType(){
  179. var typeId = 0;
  180. if("${report.typeId}"){
  181. typeId = "${report.typeId}";
  182. }else if("${param.typeId}"){
  183. typeId = "${param.typeId}";
  184. }
  185. //设置返回路径参数
  186. if(typeId!=0){
  187. var backUrl = $('a.link.back').attr('href');
  188. $('a.link.back').attr('href',backUrl+'?typeId='+typeId);
  189. }
  190. }
  191. function typeChange(obj){
  192. var self = $(obj);
  193. var selfValue = self.val();
  194. self.siblings().hide();
  195. if(selfValue=='1'){
  196. //表单输入
  197. self.siblings('#paraCt').show();
  198. }else if(selfValue=='0'){
  199. //固定值
  200. self.siblings('#defaultValue').show();
  201. var paraCt = self.siblings('#paraCt');
  202. paraCt.show();
  203. if(paraCt.val()!="1" && paraCt.val()!="-1"){
  204. self.siblings('#selectBtn').show();
  205. }
  206. }else{
  207. self.siblings('#script').show();
  208. }
  209. }
  210. function paraChange(obj){
  211. var self = $(obj);
  212. var defaultValue = self.siblings('#defaultValue');
  213. defaultValue.removeClass('date');
  214. var selfVal = self.val();
  215. var selectBtn = self.siblings('#selectBtn');
  216. self.siblings('#settingSpan').hide();
  217. if(selfVal=='1' || selfVal=="-1"){
  218. //单行文件或日期控件
  219. selectBtn.hide();
  220. if(selfVal=="-1") defaultValue.addClass('date');
  221. }else if(selfVal=='0'){
  222. //对话框
  223. self.siblings('#settingSpan').show();
  224. }else if(self.siblings('#defaultType').val()!='1'){
  225. selectBtn.show();
  226. }else{
  227. selectBtn.hide();
  228. }
  229. }
  230. function dialogCallBack(ids,names,obj){
  231. var defaultValue=$(obj).siblings('#defaultValue');
  232. defaultValue.val(ids);
  233. }
  234. //选择不同的对话框
  235. function dialogChange(obj){
  236. var dia=$(obj).find("option:selected");
  237. var v = dia.attr("fields");
  238. if(v){
  239. var paramSelector = $(obj).siblings("#dialog-param");
  240. var opt = paramSelector.find("option:first-child");
  241. paramSelector.text('');
  242. //添加 请选择…… option
  243. paramSelector.append(opt);
  244. var fields = $.parseJSON(v);
  245. for(var i=0,f;f=fields[i++];){
  246. opt = $('<option value="'+f.field+'">'+f.comment+'</option>');
  247. paramSelector.append(opt);
  248. }
  249. }
  250. }
  251. //获取自定义对话框
  252. function getDialogs(){
  253. var url = __ctx + '/platform/form/bpmFormDialog/getAllDialogs.ht';
  254. $.ajax({
  255. type:"get",
  256. async:false,
  257. url:url,
  258. success:function(data){
  259. if (data) {
  260. for(var i=0,c;c=data[i++];){
  261. var opt = $('<option value="'+c.alias+'">'+c.name+'</option>');
  262. opt.attr("fields",c.resultfield);
  263. $("select#dialog-type").append(opt);
  264. }
  265. }
  266. }
  267. });
  268. };
  269. function constructParamTable(params){
  270. var table = $("#para-txt table").clone();
  271. var tbody = $("tbody",table).empty();
  272. for(var i=0;i<params.length;i++){
  273. var tr = constructParamTr(params[i]);
  274. tbody.append(tr);
  275. }
  276. return table;
  277. };
  278. function constructParamTr(p){
  279. var tr = $("#para-txt table tbody tr").clone();
  280. $("[name='field']",tr).text(p.field);
  281. $("[name='paraType']",tr).text(p.paraType);
  282. $("[name='comment']",tr).val(p.comment);
  283. $("[name='paraCt']",tr).val(p.paraCt);
  284. var defaultType = $('[name=defaultType]',tr);
  285. defaultType.val(p.defaultType);
  286. typeChange(defaultType);
  287. $('[name=defaultValue]',tr).val(p.defaultValue);
  288. if(p.dialog){
  289. $('#settingSpan',tr).show();
  290. $('#dialog-type',tr).val(p.dialog)
  291. dialogChange($('#dialog-type',tr));
  292. $('#dialog-param',tr).val(p.dialogParam)
  293. }
  294. return tr;
  295. };
  296. function selectScript(obj) {
  297. var txtObj=$(obj).closest('div').siblings("textarea")[0];
  298. ScriptDialog({
  299. callback : function(script) {
  300. $.insertText(txtObj,script);
  301. }
  302. });
  303. };
  304. </script>
  305. <style type="text/css">
  306. html,body{height:100%;width:100%; overflow: hidden;}
  307. .para-info-table th, .para-info-table td{text-align: center;height: 32px;}
  308. select{width:90px;}
  309. </style>
  310. </head>
  311. <body>
  312. <div class="panel">
  313. <div class="panel-top">
  314. <div class="tbar-title">
  315. <c:choose>
  316. <c:when test="${not empty report.reportId}">
  317. <span class="tbar-label">编辑报表模板</span>
  318. </c:when>
  319. <c:otherwise>
  320. <span class="tbar-label">添加报表模板</span>
  321. </c:otherwise>
  322. </c:choose>
  323. </div>
  324. <div class="panel-toolbar">
  325. <div class="toolBar">
  326. <div class="group">
  327. <a class="link save" id="dataFormSave" href="javascript:;"><span></span>保存</a>
  328. </div>
  329. <div class="l-bar-separator"></div>
  330. <div class="group">
  331. <a class="link back" href="list.ht"><span></span>返回</a>
  332. </div>
  333. </div>
  334. </div>
  335. </div>
  336. <div class="panel-body">
  337. <form id="reportForm" method="post" action="save.ht" enctype="multipart/form-data">
  338. <table class="table-detail" cellpadding="0" cellspacing="0" border="0">
  339. <tr>
  340. <th width="15%">标题: <span class="required">*</span></th>
  341. <td>
  342. <input type="text" id="title" name="title" validate="{required:true}" tipId="errorTitle"
  343. value="${report.title}" class="inputText"/><label id="errorTitle"></label>
  344. </td>
  345. </tr>
  346. <tr>
  347. <th>数据源别名: <span class="required">*</span></th>
  348. <td>
  349. <select name="dsName" style="width:115px;">
  350. <option value="">空数据源</option>
  351. <c:forEach var="item" items="${dsList}">
  352. <option value="${item.alias }" <c:if test="${report.dsName eq item.alias}">selected="selected"</c:if>>${item.alias }</option>
  353. </c:forEach>
  354. </select>
  355. </td>
  356. </tr>
  357. <tr>
  358. <th>报表分类: </th>
  359. <td>
  360. <c:choose>
  361. <c:when test="${not empty report.typeId}">
  362. <c:set var="catValue" value="${report.typeId}"></c:set>
  363. </c:when>
  364. <c:when test="${not empty param.typeId}">
  365. <c:set var="catValue" value="${param.typeId}"></c:set>
  366. </c:when>
  367. <c:otherwise>
  368. <c:set var="catValue" value=""></c:set>
  369. </c:otherwise>
  370. </c:choose>
  371. <input class="catComBo" catKey="REPORT_TYPE" valueField="typeId" catValue="${catValue}" name="typeName" height="150" width="150"/>
  372. </td>
  373. </tr>
  374. <c:if test="${not empty paramList}">
  375. <tr>
  376. <th>主报表参数: </th>
  377. <td id="paraInfo">
  378. </td>
  379. </tr>
  380. </c:if>
  381. <tr>
  382. <th>描述: </th>
  383. <td>
  384. <textarea rows="5" cols="60" id="descp" name="descp"
  385. class="textarea">${report.descp}</textarea>
  386. </td>
  387. </tr>
  388. <tr>
  389. <th>报表模板路径: <span class="required">*</span></th>
  390. <td>
  391. <c:choose>
  392. <c:when test="${empty report.reportId}">
  393. <input id="file" name="file" style="width: 200px;" class="inputText" type="file"
  394. value="${report.filePath}" />
  395. </c:when>
  396. <c:otherwise>
  397. <label>${report.filePath}</label>
  398. </c:otherwise>
  399. </c:choose>
  400. </td>
  401. </tr>
  402. </table>
  403. <input type="hidden" name="params" value="[{}]" id="params">
  404. <input type="hidden" name="reportId" value="${report.reportId}" />
  405. <input type="hidden" name="filePath" value="${report.filePath}" />
  406. </form>
  407. </div>
  408. <div class="hidden">
  409. <div id="para-txt">
  410. <table class="table-detail para-info-table" cellpadding="0" cellspacing="0" border="0">
  411. <thead>
  412. <tr>
  413. <th width="15%">参数信息</th>
  414. <th width="15%">参数类型</th>
  415. <th width="20%">参数说明</th>
  416. <th width="50%">参数值</th>
  417. </tr>
  418. </thead>
  419. <tbody>
  420. <tr>
  421. <td><span name="field" id="field"></span></td>
  422. <td><span name="paraType" id="paraType"></span></td>
  423. <td>
  424. <input type="text" name="comment" id="comment" validate="{required:true}" tipId="errorComment"/>
  425. <label id="errorComment"></label>
  426. </td>
  427. <td style="text-align:left;">
  428. <select name="defaultType" id="defaultType" onchange="typeChange(this)">
  429. <option value="0">固定值</option>
  430. <option value="1">表单输入</option>
  431. <option value="2">脚本</option>
  432. </select>
  433. <div style="display:none;width:200px" id="script">
  434. <div name='btnScript'>
  435. <a href='#' class='link var' title='常用脚本' onclick='selectScript(this)'>常用脚本</a>
  436. </div>
  437. <textarea cols='20' rows='3' id="area" name="defaultValue"></textarea>
  438. </div>
  439. <input type="text" style="width:100px;" value="" id="defaultValue" name="defaultValue">
  440. <select name="paraCt" id="paraCt" onchange="paraChange(this)">
  441. <option value="1">单行文本框</option>
  442. <option value="4">人员选择器(单选)</option>
  443. <option value="17">角色选择器(单选)</option>
  444. <option value="18">组织选择器(单选)</option>
  445. <option value="19">岗位选择器(单选)</option>
  446. <option value="0">自定义对话框</option>
  447. <option value="-1">日期控件</option>
  448. </select>
  449. <span style="display: none;" id="settingSpan">
  450. <select id="dialog-type" name="dialog-type" onchange="dialogChange(this)" style="width:100px;">
  451. <option value="">请选择对话框……</option>
  452. </select>
  453. <select id="dialog-param" name="dialog-param" style="width:100px;">
  454. <option value="">请选择返回值……</option>
  455. </select>
  456. </span>
  457. <input type="button" id="selectBtn" value="…" style="display:none;width:20px;" />
  458. </td>
  459. </tr>
  460. </tbody>
  461. </table>
  462. </div>
  463. </div>
  464. </div>
  465. </body>
  466. </html>