85da5c462ed157adcfb515e861d5f67b8908c4e9.svn-base 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. var grid;
  2. var fdObjectId=null;
  3. function resolveUrl(){
  4. var encondeCondition=window.location.search;
  5. var condition= decodeURI(encondeCondition.substring(1,encondeCondition.length));
  6. var conditionArr=condition.split("&");
  7. var condJson={};
  8. for(var item in conditionArr){
  9. var temArr=conditionArr[item].split("=");
  10. condJson[temArr[0]]=temArr[1];
  11. }
  12. return condJson;
  13. }
  14. var option={
  15. columns: [
  16. {name: 'FD_OBJECTID', hide : true},
  17. {display : '标题',name : 'TITLENAME', align : 'center',width :'20%' },
  18. {display : '内容',name : 'PLANKINFO', align : 'center',width : '60%'},
  19. {display : '时间',name : 'PLANKDATE', align : 'center',width : '20%'}
  20. ],
  21. data:[],
  22. rownumbers:true,
  23. checkbox:true,
  24. height: '100%',
  25. width:"100%",
  26. pageSize: '10',
  27. percentWidthMode:true,
  28. //顶部图标按钮栏
  29. toolbar:
  30. {
  31. items: [
  32. { text: '新增', click: onAdd, iconClass: 'icon_add', disabled: false },
  33. { line: true },
  34. { text: '修改', click: onEdit, iconClass: 'icon_edit', disabled: false },
  35. { line: true }
  36. ]
  37. }
  38. };
  39. //初始化列表
  40. /*function createGrid(){
  41. }*/
  42. /*
  43. * 加载数据表格
  44. */
  45. function loadGridData() {
  46. if (fdObjectId == null)
  47. return;
  48. $.post($.pathname()+ "/ws/IntelligenceService/IntelligenceService/getIntelligencInfo",
  49. {
  50. fdObjectId : fdObjectId
  51. },
  52. function(result) {
  53. if (result.state == "FAILURE")
  54. throw new Error("查询失败");
  55. if(grid==null){
  56. option.data=result;
  57. grid = $("#i_main_grid").quiGrid(option);
  58. }else{
  59. grid.setOptions({
  60. data : result
  61. });
  62. grid.loadData();
  63. }
  64. }, "json");
  65. }
  66. /**
  67. * 新增
  68. */
  69. function onAdd(){
  70. var url = "add_intelligence.jsp?fdObjectId="+fdObjectId;
  71. window.parent.document.getElementById("frmright").
  72. setAttribute("src", "/nwyj/page/system/externalSystem/"+encodeURI(url));
  73. }
  74. /**
  75. * 返回主页面
  76. */
  77. function goBack() {
  78. //获取iframe中的元素值
  79. var iframe =parent.document.getElementsByName("frmright")[0];
  80. iframe.src = $.pathname()+"/page/system/externalSystem/intelligence.jsp";
  81. }
  82. function init(){
  83. $.post("/nwyj/ws/IntelligenceService/IntelligenceService/getTitle",{},function(result){
  84. if(result.state=="FAILURE") throw new Error("查询失败");
  85. $("#Ititle").val(result.rows[0].TITLENAME);
  86. fdObjectId=result.rows[0]["FD_OBJECTID"];
  87. loadGridData();
  88. },"json");};
  89. /**
  90. * 初始化
  91. */
  92. $(function(){
  93. var params=resolveUrl();
  94. fdObjectId=params.fdObjectId;
  95. init();
  96. $("#Isave").on("click",function(){
  97. checkTitle();
  98. });
  99. });
  100. /**
  101. * 判断title是否存在
  102. */
  103. function checkTitle(){
  104. $.post($.pathname() + '/ws/IntelligenceService/IntelligenceService/getIntelligencId',{title:$("#Ititle").val()},function(result){
  105. if(result.state=="FAILURE") throw new Error("查询失败");
  106. if(result.rows=="null"){
  107. top.Dialog.confirm("尚未查询到"+$("#Ititle").val()+";请问是否增加"+$("#Ititle").val(),function(){
  108. save($("#Ititle").val());},function(){return false;});
  109. }else{
  110. fdObjectId=result.rows;
  111. loadGridData();
  112. }
  113. },"json");
  114. }
  115. /**
  116. * 保存title
  117. * @param title
  118. */
  119. function save(title){
  120. $.post($.pathname() + "/ws/IntelligenceService/IntelligenceService/saveIntelligencInfo",{title:title},function(result){
  121. if(result.state=="FAILURE") throw new Error("查询失败");
  122. fdObjectId=result.rows;
  123. loadGridData();
  124. },"json");
  125. }
  126. /**
  127. * 增加
  128. */
  129. function addExternal(){
  130. $form = $('#fillForm');
  131. var url = $.pathname() + '/ws/crud/CRUDService/create';
  132. $.ajax({
  133. url : url,
  134. type : 'post',
  135. data : $form.serialize(),
  136. dataType : 'text',
  137. timeout : 60000,
  138. success : function(data){
  139. goBack();
  140. $.messager.alert("保存成功",null,null,null,1);
  141. },
  142. error : function(){
  143. $.messager.alert('操作失败');
  144. }
  145. });
  146. };
  147. /**
  148. * 修改
  149. */
  150. function onEdit(){
  151. var rows = grid.getSelectedRows();
  152. if(rows.length==0){
  153. top.Dialog.alert("请选择一条记录");
  154. return;
  155. }
  156. if(rows.length>1){
  157. top.Dialog.alert("只能选择一条记录");
  158. return;
  159. }
  160. var fd_id = rows[0].FD_OBJECTID;
  161. var iframe =parent.document.getElementsByName("frmright")[0];
  162. var url = "edit_intelligence.jsp?fdObjectId="+fdObjectId+"&id="+fd_id;
  163. iframe.src = $.pathname()+"/page/system/externalSystem/"+encodeURI(url);
  164. };