489a680ed1dd671cd3fc3a1025d8f2c5d182c2a6.svn-base 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. var g;
  2. /*var title = "";*/
  3. var type = "";
  4. var depts;
  5. var loadParams = "";
  6. var role_id =top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  7. var dept_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  8. var deptsel = "";
  9. //var statusDate = '0';
  10. var mycol = [
  11. {display : '一级表头', name : 'TABLE_HEAD_529',align : 'center',width : "25%"},
  12. /* {display : '报表字段', name : 'TABLE_COLUMN_529',align : 'center',width : "20%"},*/
  13. {display : '字段描述', name : 'COLUMN_NAME_529',align : 'center', width : "25%"},
  14. /*{display : '二级表头', name : 'COLUMN_NAME_529',align : 'center', width : "25%"},*/
  15. {display : '是否在用', name : 'IS_USED_529',align : 'center', width : "25%",render:function (rowdata, rowindex, value, column){
  16. if(value=="0"){
  17. return "字段在使用";
  18. }
  19. return "备用字段";
  20. }},
  21. {display : '是否统计', name : 'IS_COUNT_529',align : 'center', width : "25%",render:function (rowdata, rowindex, value, column){
  22. if(value=="0"){
  23. return "该字段既统计又要输入数字";
  24. }else if(value=="1"){
  25. return "该字段不统计但要输入数字";
  26. }else{
  27. return "该字段既不统计又不要输入数字";
  28. }
  29. }}];
  30. function initComplete() {
  31. var url = decodeURI(window.location.search);
  32. var type = url.split("?")[1];
  33. var table = url.split("?")[2];
  34. $("#type").val(type);
  35. $("#tables").val(table);
  36. loadParams = {
  37. "listId" : '529',
  38. "condition" : "is_del =0 and report_type='"+type+"' and TABLE_HEAD is not null and COLUMN_NAME is not null",
  39. direction : 'desc', // 排序方式
  40. sort : 'REPORT_NAME_529'
  41. };
  42. init(table,loadParams);
  43. }
  44. function init(data,params){
  45. var option = {
  46. columns : [
  47. {
  48. display :data ,
  49. columns : [
  50. {display : '一级表头', name : 'TABLE_HEAD_529',align : 'center',width : "25%"},
  51. /*{display : '字段描述', name : 'COLUMN_NAME_529',align : 'center', width : "25%"},*/
  52. {display : '二级表头', name : 'COLUMN_NAME_529',align : 'center', width : "25%"},
  53. {display : '是否在用', name : 'IS_USED_529_SHOW',align : 'center', width : "25%"},
  54. {display : '是否统计', name : 'IS_COUNT_529_SHOW',align : 'center', width : "25%"}
  55. ],
  56. }
  57. ],
  58. pageSize : 10,
  59. rownumbers : true,
  60. percentWidthMode : true,
  61. checkbox : true
  62. };
  63. //var roleCons = roleButtonArr();
  64. var toblBars = {
  65. items :[ {text : '新增',click : 'onAdd',iconClass : 'add1_tem',disabled : false},
  66. {text : '删除',click : 'onDelete',iconClass : 'delete_tem', disabled : false},
  67. {text : '修改', click : 'onEdit',iconClass : 'update_tem',disabled : false},
  68. {text : '预览', click : 'onView',iconClass : 'view_tem',disabled : false},
  69. {text : '导出', click : 'onReportExport',iconClass : 'export_tem',disabled : false},
  70. {text : '返回', click : 'goback',iconClass : 'back_tem',disabled : false},
  71. ],
  72. // roleCons:roleCons
  73. };
  74. var options={
  75. url : $.pathname() + '/ws/crud/CRUDService/queryQui',
  76. params : params,
  77. width : "100%",
  78. gridOptions:option,
  79. paperOpration:{showInput:"true"},
  80. toolBarOptions:toblBars
  81. };
  82. g=gridAndSingleRecode=$("#maingrid").quickgridAndSingleRecode(options);
  83. }
  84. //增加
  85. function onAdd(){
  86. /*var sel = $("#sel").val();*/
  87. /*var dept = $("#dept").val();*/
  88. /*var data = g.getData();*/
  89. var url = "/nwyj/page/business/am/report/dictionary/Type_Add.html?"+$("#type").val()+"?"+$("#tables").val();
  90. window.parent.document.getElementById("frmright").setAttribute("src", encodeURI(url));
  91. }
  92. //删除
  93. function onDelete(){
  94. var rows = g.getSelectedRows();
  95. var rowsLength = rows.length;
  96. if (rowsLength == 0) {
  97. top.Dialog.alert("请选中要删除的记录!");
  98. return;
  99. }
  100. var ids = "";
  101. var flag = true;
  102. for ( var i = 0; i < rowsLength; i++) {
  103. if(rows[i].IS_USED_529=="1"){
  104. flag = false;
  105. top.Dialog.alert("备用字段不能删除");
  106. return;
  107. }else{
  108. ids += rows[i].FD_OBJECTID_529 + ";";
  109. }
  110. }
  111. if(flag){
  112. top.Dialog.confirm("确定要删除吗?|删除", function() {
  113. // 删除记录
  114. $.post($.pathname() +"/ws/xianlutingyun/XianlutingyunService/deleteReport", {
  115. fd_id : ids,type:"rc"
  116. }, function(result) {
  117. if (result.Msg.sucsess == true) {
  118. top.Dialog.alert("删除成功",null,null,null,null);
  119. // 刷新表格数据
  120. g.rend();
  121. } else {
  122. top.Dialog.alert("删除失败!");
  123. }
  124. }, "json");
  125. });
  126. }
  127. }
  128. //修改
  129. function onEdit(){
  130. var row = g.getSelectedRows();
  131. if(row.length==0){
  132. top.Dialog.alert("请选择一条记录修改");
  133. return;
  134. }
  135. if(row.length>1){
  136. top.Dialog.alert("一次只能修改一条记录");
  137. return;
  138. }
  139. var title = row[0].TABLE_HEAD_529;
  140. var desc = row[0].COLUMN_NAME_529;
  141. var name = row[0].TABLE_COLUMN_529;
  142. var count = row[0].IS_COUNT_529;
  143. var type = row[0].REPORT_TYPE_529;
  144. var report_name = row[0].REPORT_NAME_529;
  145. window.parent.document.getElementById("frmright").setAttribute("src", encodeURI("/nwyj/page/business/am/report/dictionary/Type_Alter.html?"+title+"?"+desc+"?"+name+"?"+count+"?"+type+"?"+report_name));
  146. }
  147. //预览
  148. function onView(){
  149. window.parent.document.getElementById("frmright").setAttribute("src",encodeURI("/nwyj/page/business/am/report/dictionary/View.html?"+$("#type").val()+"?"+$("#tables").val()));
  150. }
  151. function onReportExport(){
  152. var url = decodeURI(window.location.search);
  153. var type = url.split("?")[1];
  154. var table = url.split("?")[2];
  155. var Columns = findColumn(type);
  156. var columns_sub = Columns.substring(0, Columns.lastIndexOf(","));
  157. var condition = '1=1';
  158. //alert(findId(type));
  159. var sql = {
  160. "flag":"muban",
  161. //"listId" :findId(type),
  162. "condition":condition,
  163. "id":dept_id,
  164. "report_type":type
  165. };
  166. excelExport(type,sql," 导出"+table,['FD_OBJECTID','REPORT_ID','TEST','COMP_ID',columns_sub],table+"模板","rcreport");
  167. }
  168. function goback(){
  169. var iframe = parent.document.getElementsByName("frmright")[0];
  170. iframe.src = "/nwyj/page/business/am/report/dictionary/report_model.jsp";
  171. }
  172. //根据选中记录查找classId
  173. function findId(type){
  174. var classId="";
  175. $.ajax({
  176. url : $.pathname() + "/ws/getReportId/ExportExcelService/getReportClassId",
  177. type : 'post',
  178. timeout : 15000,
  179. async : false,
  180. data : {
  181. report_type:type
  182. },
  183. dataType : 'json',
  184. success : function(data) {
  185. classId = data.rows[0].CLASSID;
  186. },
  187. error : function(e) {
  188. $.messager.alert('获取ID失败!', '访问服务失败!', 'error');
  189. }
  190. });
  191. return classId;
  192. }
  193. //过滤没用的列
  194. function findColumn(type){
  195. //把首次导入的清除
  196. var column="";
  197. $.ajax({
  198. url : $.pathname() + "/ws/getReportId/ExportExcelService/getColumn",
  199. type : 'post',
  200. timeout : 15000,
  201. async : false,
  202. data : {
  203. report_type:type
  204. },
  205. dataType : 'json',
  206. success : function(data) {
  207. for(var i=0;i<data.rows.length;i++){
  208. column += data.rows[i].TABLE_COLUMN+",";
  209. }
  210. },
  211. error : function(e) {
  212. $.messager.alert('获取列失败!', '访问服务失败!', 'error');
  213. }
  214. });
  215. return column;
  216. }