jobLayoutJs.jsp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
  2. <%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
  3. <script>
  4. /* ************************** 全局变量定义 **************************** */
  5. var Util = $.Util;
  6. var schemeVersionList = [];
  7. /* *************************** 自定义模块 ***************************** */
  8. var jobLayout = {
  9. dialog:null,
  10. grid:null,
  11. init:function(){
  12. var me = this;
  13. $('.m-retrieve-area').show();
  14. $.ajax({
  15. url: '${contextRoot}/datacollect/getLayout',
  16. dataType: "json",
  17. success: function (data) {
  18. if(data.successFlg){
  19. schemeVersionList = data.detailModelList || [];
  20. }else{
  21. $.ligerDialog.error(data.message);
  22. }
  23. },
  24. error: function (jqXHR, textStatus, errorThrown) {
  25. $.ligerDialog.error("获取适配方案版本列表失败!")
  26. }
  27. });
  28. me.grid = $("#div_grid").ligerGrid({
  29. url: '${contextRoot}/datacollect/getSchemeVersionList',
  30. usePager: false,
  31. columns: [
  32. { display: 'schemeId', name: 'schemeId', hide:true },
  33. { display: 'id', name: 'id', hide:true },
  34. {display:'适配方案',name:'', width: '20%',render: function (row, rowindex, value, column) {
  35. var select= '<select class="sel-scheme-name form-control" id="schemeNm'+rowindex+'" style="margin-top:3px;font-size:12px;">';
  36. for(var i=0;i<schemeVersionList.length;i++){
  37. select+='<option value="'+schemeVersionList[i].schemeId+'">'+schemeVersionList[i].name+'</option>';
  38. }
  39. select = $(select+"</select>");
  40. $('option[value="'+row.schemeId+'"]',select).attr('selected',true);
  41. return select.prop("outerHTML");
  42. }},
  43. {display:'版本',name:'',width: '20%',render: function (row, rowindex, value, column) {
  44. var select= '<select class="sel-version-name form-control" id="versionNm'+rowindex+'" style="margin-top:3px;font-size:12px;">';
  45. var versionList = [];
  46. for(var i=0;i<schemeVersionList.length;i++){
  47. if(schemeVersionList[i].schemeId == row.schemeId){
  48. versionList = schemeVersionList[i].versionList;
  49. for(var j=0;j<versionList.length;j++){
  50. select+='<option value="'+versionList[j].id+'">'+versionList[j].name+'</option>';
  51. }
  52. }
  53. }
  54. select = $(select+"</select>");
  55. $('option[value="'+row.id+'"]',select).attr('selected',true);
  56. return select.prop("outerHTML");
  57. }},
  58. {display:'数据集名称',name:'dataSets', width: '40%',render: function (row, rowindex, value, column) {
  59. var dataSets = value.toString().substring(0,value.length-1);
  60. var html = '<input style="margin-top:3px;font-size:12px;" data-rowindex="'+rowindex+'" class="sel-dataset-name form-control" value="'+(dataSets || "")+'" >' +
  61. '<div style="display: none;" id="datasetId'+rowindex+'"></div>';
  62. return html;
  63. }},
  64. {display:'操作', name: 'operator', width: '20%', render: function (row) {
  65. var html = '<div class="m-inline-buttons" style="width:55px;">';
  66. html += '<a href="javascript:void(0)" onclick="javascript:jobLayout.mapping(\''+row.id+'\')">数据映射</a>';
  67. return html;
  68. }}
  69. ],
  70. onAfterShowData: function (gridData) {//显示完数据事件
  71. //【适配方案】change事件
  72. $(".sel-scheme-name").on("change", function() {
  73. var rowIndex = $(this).attr("id").replace("schemeId","");
  74. var option = "";
  75. for(var i=0;i<schemeVersionList.length;i++){
  76. if(schemeVersionList[i].schemeId == $(this).val()){
  77. versionList = schemeVersionList[i].versionList;
  78. for(var j=0;j<versionList.length;j++){
  79. option+='<option value="'+versionList[j].id+'">'+versionList[j].name+'</option>';
  80. }
  81. }
  82. }
  83. $("#versionId"+rowIndex).html("");
  84. $("#versionId"+rowIndex).append(option);
  85. });
  86. //【数据集名称】focus事件
  87. $(".sel-dataset-name").on("focus", function() {
  88. var rowindex = $(this).attr("data-rowindex");
  89. jobLayout.grid.select(rowindex);//选中行
  90. var row = jobLayout.grid.getSelectedRow();
  91. var params = {schemeId:row.schemeId,version:row.id,schemeNm:$("#schemeNm"+rowindex).find("option:selected").text()};
  92. me.dialog = $.ligerDialog.open({
  93. height: 600,
  94. width: 600,
  95. title: "数据集选择器",
  96. url: '${contextRoot}/datacollect/datasetDetail',
  97. //load: true,
  98. urlParms: params
  99. });
  100. });
  101. }
  102. });
  103. me.bindEvents();
  104. },
  105. //绑定按钮事件
  106. bindEvents: function () {
  107. var me = this;
  108. $('#btnAdd').click(function () {
  109. me.editor();
  110. });
  111. $('#btnSave').click(function(){
  112. //获取选择行
  113. debugger
  114. var row = me.grid.getSelectedRow();
  115. if(row!=null &&row.id!=undefined&&row.id.length>0)
  116. {
  117. $.ligerDialog.success("已交由后台运行!");
  118. var jobId = row.id;
  119. $.ajax({ //ajax处理
  120. type: "POST",
  121. url : "${contextRoot}/datacollect/executeJob",
  122. dataType : "json",
  123. data:{jobId:jobId},
  124. cache:false,
  125. success :function(data){
  126. if(!data.successFlg) {
  127. $.ligerDialog.error(data.message);
  128. }
  129. },
  130. error :function(data){
  131. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  132. }
  133. });
  134. }
  135. else{
  136. $.ligerDialog.warn('请选择要执行任务!');
  137. }
  138. });
  139. },
  140. //编辑弹窗
  141. editor:function(id){
  142. var me = this;
  143. var title = "新增任务";
  144. var params = null;
  145. if(id!=undefined&&id!=null)
  146. {
  147. title = "编辑任务";
  148. params = {jobId:id};
  149. }
  150. me.dialog = $.ligerDialog.open({
  151. height: 556,
  152. width: 700,
  153. title: title,
  154. url: '${contextRoot}/datacollect/editorJob',
  155. //load: true,
  156. urlParms: params
  157. });
  158. },
  159. //数据映射
  160. mapping:function(id){
  161. var me = this;
  162. var params = {jobId:id};
  163. me.dialog = $.ligerDialog.open({
  164. height: 600,
  165. width: 800,
  166. title: "数据映射",
  167. url: '${contextRoot}/datacollect/jobDataMapping',
  168. //load: true,
  169. urlParms: params
  170. });
  171. },
  172. //删除任务
  173. delete:function(id)
  174. {
  175. $.ligerDialog.confirm("确定要删除该任务吗?", function (confirm) {
  176. if (confirm)
  177. {
  178. $.ajax({ //ajax处理
  179. type: "POST",
  180. url : "${contextRoot}/datacollect/deleteJob",
  181. dataType : "json",
  182. data:{jobId:id},
  183. cache:false,
  184. success :function(data){
  185. if(data.successFlg) {
  186. $.ligerDialog.success(data.message);
  187. jobLayout.grid.reload();
  188. }
  189. else{
  190. $.ligerDialog.error(data.message);
  191. }
  192. },
  193. error :function(data){
  194. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  195. }
  196. });
  197. }
  198. });
  199. },
  200. //弹窗返回消息
  201. callbackDialog:function(message){
  202. $.ligerDialog.success(message);
  203. this.grid.reload();
  204. this.dialog.close();
  205. }
  206. }
  207. $(function () {
  208. jobLayout.init();
  209. });
  210. </script>