msgcheck.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /**
  2. * mcare_admin/ msgcheck
  3. */
  4. var mcare_admin_msgcheck = function(){
  5. mcare_admin.call(this);
  6. var self = this;
  7. var $searchText = $("#search-text"),
  8. $search = $("#search"),
  9. $endDate = $("#endDate"),
  10. $selectOption = $("#select-option"),
  11. $strDate = $("#strDate"),
  12. $grid = $("#grid"),
  13. $crudServiceBaseUrl = contextPath + "/admin/msgcheck";
  14. var gridDataSource = null;
  15. this.init = function(){
  16. initDropDownList();
  17. initDatePicker();
  18. gridDataSource = setDataSource();
  19. initGrid();
  20. addEvent();
  21. };
  22. var addEvent = function(){
  23. // 검색 이벤트
  24. $search.on("click", function(e){
  25. //mcare_admin 상속
  26. self.search( gridDataSource, true );
  27. });
  28. };
  29. var initDropDownList = function(){
  30. //mcare_admin 상속
  31. self.dropDownList( $selectOption );
  32. };
  33. var initDatePicker = function(){
  34. //mcare_admin 상속
  35. self.datePicker( $endDate, $strDate, $selectOption );
  36. };
  37. var setDataSource = function(){
  38. var dataSource = new kendo.data.DataSource({
  39. transport: {
  40. read: {
  41. url: $crudServiceBaseUrl + "/getMsgList.json",
  42. method: "post",
  43. dataType: "json",
  44. contentType: "application/json",
  45. complete: gridActionComplete
  46. },
  47. parameterMap: parameterMap
  48. },
  49. pageSize: 13,
  50. serverPaging: true,
  51. serverSorting: true,
  52. schema: {
  53. data: "data",
  54. total: "totalCount",
  55. model: {
  56. id: "contentsSeq",
  57. fields: {
  58. contentsSeq: { type: "number"},
  59. formId: { type: "string"},
  60. userId: { type: "string"},
  61. messageValue: { type: "string"},
  62. logDt: { type: "string"}
  63. }
  64. }
  65. }
  66. });
  67. dataSource.query({page: 1, pageSize: 13});
  68. function parameterMap( options, operation ){
  69. kendo.ui.progress($(".main-wrapper"), true);
  70. var param = $.extend(true, {}, options, {
  71. strDate : new Date( self.getStartDatePickerValue() ).setHours(0, 0, 0, 0),
  72. endDate : new Date( +self.getEndDatePickerValue()).setHours(0, 0, 0, 0),
  73. userId : $searchText.val(),
  74. }, null);
  75. return self.util.stringifyJson( param );
  76. }
  77. /**
  78. * 그리드 이벤트 동작 complate
  79. * @private
  80. */
  81. function gridActionComplete( e ){
  82. kendo.ui.progress($(".main-wrapper"), false);
  83. var result = self.util.parseJson( e.responseText );
  84. if( result.msg ){
  85. alert( result.msg );
  86. if( result.type == "AuthException" ){
  87. window.location.href = contextPath + "/admin/logout.page";
  88. return;
  89. }
  90. }
  91. };
  92. return dataSource;
  93. };
  94. var initGrid = function(){
  95. var option = {
  96. dataSource: gridDataSource,
  97. pageable: true,
  98. sortable: true,
  99. resizable: true,
  100. autoBind: false,
  101. selectable: true,
  102. filterable: {
  103. extra: false,
  104. operators: {
  105. string: {
  106. eq: "일치",
  107. neq: "불일치",
  108. contains:"포함"
  109. }
  110. }
  111. },
  112. detailInit: detailInit,
  113. dataBound: function() {
  114. //this.expandRow(this.tbody.find("tr.k-master-row").first());
  115. },
  116. height : 550,
  117. columns : [
  118. { field: "contentsSeq", title: "시퀀스", hidden:true, width: 30 }
  119. ,{ field: "userId", title: "환자번호", hidden:false, width: 50 }
  120. ,{ field: "formId", title: "유형", width: 70, attributes: {style: "text-align: center;"},filterable: {cell: {enabled: true,delay: 1500}},}
  121. ,{ field: "messageValue", title: "메시지", width: 140, attributes: {style: "text-align: center;"},filterable:false}
  122. ,{ field: "logDt", title: "전송일시", width: 50, attributes: {style: "text-align: center;"},filterable:false}
  123. // 사용안하고 있어서 주석처리함
  124. //,{ title: "관리", width: 80, template: "<button type='button' class='k-button detailBtn' data-userId='#=userId#' data-seq='#=contentsSeq#'>상세보기</button>", attributes: {"class": "detailBtn", style: "text-align: center;"}}
  125. ]
  126. };
  127. self.historyGrid = self.grid( $grid, option );
  128. function detailInit(e) {
  129. kendo.ui.progress($(".main-wrapper"), true);
  130. $("<div/>").appendTo(e.detailCell).kendoGrid({
  131. dataSource: {
  132. transport: {
  133. read:
  134. function(options) {
  135. // $.ajax({
  136. // url: $crudServiceBaseUrl + "/getMsgDetailInfoList.json",
  137. // method: "post",
  138. // dataType: "json",
  139. // contentType: "application/json",
  140. // data:self.util.stringifyJson({contentsSeq:e.data.contentsSeq,receiverId:e.data.userId}),
  141. // success: function(result) {
  142. //
  143. // options.success(result);
  144. // },
  145. // error: function(result) {
  146. //
  147. // options.error(result);
  148. // alert("상세 정보 조회 실패");
  149. // },
  150. // complete:function(){
  151. // kendo.ui.progress($(".main-wrapper"), false);
  152. // }
  153. // });
  154. var opt = {
  155. url: $crudServiceBaseUrl + "/getMsgDetailInfoList.json",
  156. method: "post",
  157. dataType: "json",
  158. contentType: "application/json",
  159. data:self.util.stringifyJson({contentsSeq:e.data.contentsSeq,receiverId:e.data.userId}),
  160. complete : function(){
  161. kendo.ui.progress( $(".main-wrapper"), false );
  162. }
  163. };
  164. var success = function(data){
  165. options.success(data);
  166. };
  167. var error = function(xhr,d,t){
  168. options.error(xhr);
  169. alert("상세 정보 조회 실패");
  170. };
  171. self.ajaxAdmin( opt, success, error );
  172. }
  173. },
  174. //pageSize: 10
  175. },
  176. scrollable: false,
  177. sortable: true,
  178. //pageable: true,
  179. columns: [
  180. { field: "cotentsSeq",hidden:true },
  181. { field: "receiverId", hidden:true },
  182. { field: "deviceTokenId", hidden:true },
  183. { field: "platformType", title: "플랫폼",template:platformTemplete, width: "100px",attributes: {style: "text-align: center;"} },
  184. { field: "successYn", title: "성공여부",template:successYnTemplete, width: "100px",attributes: {style: "text-align: center;"} },
  185. { field: "errorType", title: "에러유형", width: "200px" ,attributes: {style: "text-align: center;"}}
  186. ]
  187. });
  188. function platformTemplete(e){
  189. if(e == null || e.platformType == null) {
  190. return "UNKNOWN";
  191. }
  192. if(e.platformType == "A") {
  193. return "Android";
  194. }
  195. if(e.platformType == "I") {
  196. return "iOS";
  197. }
  198. return e.platformType;
  199. };
  200. function successYnTemplete(e){
  201. if(e == null || e.successYn == null) {
  202. return "UNKNOWN";
  203. }
  204. if(e.successYn == "Y") {
  205. return "성공";
  206. }
  207. return "실패";
  208. };
  209. };
  210. };
  211. };