71c798a21defff9a77ec22808409fd46455a195a.svn-base 8.0 KB

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