appointment-table.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. (function() {
  2. $.jgrid.defaults.styleUI="Bootstrap";
  3. Vue.component('appointment-table', {
  4. template: '<div class="mt10">\
  5. <div ref="container" style="overflow-x: hidden">\
  6. <div class="jqGrid_wrapper">\
  7. <table id="table_list"></table>\
  8. </div>\
  9. </div>\
  10. <div id="pager_list">\
  11. </div>\
  12. </div>',
  13. props: [],
  14. data: function() {
  15. return {
  16. }
  17. },
  18. mounted: function() {
  19. initTable()
  20. initContainer(this)
  21. initEventOnBus()
  22. bindEvents()
  23. },
  24. methods: {
  25. }
  26. })
  27. function resetWidth(vm) {
  28. var $searchbar = $("#searchbar")
  29. $("#table_list").setGridWidth($(window).width());
  30. $("#table_list").jqGrid("setGridHeight", $(window).height() - $searchbar.height() - 158)
  31. }
  32. function initContainer(vm) {
  33. resetWidth(vm)
  34. window.onresize = function() {
  35. resetWidth(vm)
  36. }
  37. }
  38. var kwObj = null;
  39. function initEventOnBus() {
  40. EventBus.$on('appointment-search', function (arg) {
  41. kwObj = arg.data
  42. $("#table_list").jqGrid('setGridParam',{datatype:'json', page: 1, postData: arg.data}).trigger('reloadGrid');
  43. })
  44. }
  45. function initTable() {
  46. $("#table_list").jqGrid({
  47. url: APIService.server+"/third/guahao/GetRegList",
  48. datatype:"local",
  49. mtype: 'GET',
  50. postData: {
  51. },
  52. loadBeforeSend: function(request, grid) {
  53. var userAgent = window.sessionStorage.getItem("LoginUser");
  54. if(userAgent) {
  55. userAgent = JSON.parse(userAgent)
  56. request.setRequestHeader(APIService.agentName, JSON.stringify({
  57. "id":userAgent.id,"uid":userAgent.code,"mobile":userAgent.mobile
  58. }));
  59. }
  60. },
  61. prmNames: {
  62. page: "page",
  63. rows: "size"
  64. },
  65. jsonReader: {
  66. root: "data",
  67. page: "data.page",
  68. records: "data.records",
  69. total: "data.total"
  70. },
  71. ondblClickRow: function(rowId) {
  72. var rowData = jQuery(this).getRowData(rowId);
  73. console.log('dddddddddddd',rowData)
  74. var code = rowData.operation;
  75. code = code.match(/code="(\S*)"/)[1];
  76. var ssc = rowData.ssc;
  77. param = {
  78. code: code,
  79. ssc: ssc
  80. }
  81. top.layer.open({
  82. type: 2,
  83. title: '预约挂号详情',
  84. shadeClose: false,
  85. closeBtn: true, //显示关闭按钮
  86. shade: 0.8,
  87. area: ['800px', "90%"],
  88. content: 'customer-service/page/appointment/appointment-detail.html?code='+code+'&param='+encodeURIComponent(JSON.stringify(param))+'&kwObj='+encodeURIComponent(JSON.stringify(kwObj)) //iframe的url
  89. });
  90. },
  91. height:400,
  92. autowidth:true,
  93. loadtext: "加载中...",
  94. loadui: "block",
  95. shrinkToFit:true,
  96. rowNum:9,
  97. rowList:[10,20,30],
  98. colNames:["居民姓名","身份证号","社保卡号","就诊医院","科室",
  99. "医生","就诊时间","预约状态","操作"],
  100. colModel:[
  101. {name:"name",index:"name",width:100,sortable:false,align:"center"},
  102. {name:"idcard",index:"idcard",width:200,sortable:false,align:"center",formatter: function(v) {
  103. var len = v.length
  104. if (len == 18) {
  105. return v.substr(0, 4) + '**********' + v.substr(14, 4)
  106. } else if (len == 15) {
  107. return v.substr(0, 4) + '*******' + v.substr(11, 4)
  108. }
  109. }},
  110. {name:"ssc",index:"ssc",width:150,sortable:false,align:"center"},
  111. {name:"orgName",index:"orgName",width:200,sortable:false,align:"center"},
  112. {name:"deptName",index:"deptName",width:150,sortable:false,align:"center"},
  113. {name:"doctorName",index:"doctorName",width:150,sortable:false,align:"center"},
  114. {name:"startTime",index:"startTime",width:200,sortable:false,align:"center"},
  115. {name:"status",index:"status",width:100,sortable:false,align:"center",formatter: function(v) {
  116. return ["已取消","","预约成功"][v]
  117. }},
  118. {name:"operation",index:"operation",width:200,sortable:false,align:"center",formatter: function(v, row, data) {
  119. var btns = '<a class="view-detail-btn operation-icon chakan-icon" data-ssc="' + data.ssc + '"data-code="' + data.code + '" href="javascript:void(0)" style="color: #33c05a;" title="查看"></a>'
  120. if(data.status != "0") {
  121. btns += '<a class="view-delete-btn ml15 operation-icon shanchu-icon" data-ssc="' + data.ssc + '"data-code="' + data.code + '" href="javascript:void(0)" style="color: #ff3b30;" title="取消"></a>'
  122. }
  123. return btns
  124. }},
  125. ],
  126. pager:"#pager_list",
  127. pagerpos: "left"})
  128. }
  129. function bindEvents() {
  130. $(document.body).on("click", ".view-detail-btn", function() {
  131. var code = $(this).attr("data-code"),
  132. ssc = $(this).attr("data-ssc"),
  133. param = {
  134. code: code,
  135. ssc: ssc
  136. }
  137. top.layer.open({
  138. type: 2,
  139. title: '预约挂号详情',
  140. shadeClose: false,
  141. closeBtn: true, //显示关闭按钮
  142. shade: 0.8,
  143. area: ['800px', "90%"],
  144. content: 'customer-service/page/appointment/appointment-detail.html?code='+code+'&param='+encodeURIComponent(JSON.stringify(param))+'&kwObj='+encodeURIComponent(JSON.stringify(kwObj)) //iframe的url
  145. });
  146. })
  147. $(document.body).on("click", ".view-delete-btn", function() {
  148. var code = $(this).attr("data-code"),
  149. ssc = $(this).attr("data-ssc")
  150. var layerid = top.layer.confirm('请与居民确认:<br>一个月内连续取消预约三次,系统会自动将居民年列入黑名单,三个月后才 可再次预约。', {
  151. title: '取消预约',
  152. closeBtn: true,
  153. btn: ['确定','取消'] //按钮
  154. }, function(){
  155. var loadingid = top.layer.load(1, {
  156. shade: [0.1,'#fff'] //0.1透明度的白色背景
  157. });
  158. APIService.cancelOrder({
  159. code: code,
  160. ssc: ssc
  161. }).then(function(res) {
  162. top.layer.close(loadingid)
  163. if(res.status == 200) {
  164. top.layer.close(layerid)
  165. top.showSuccessMessage("取消预约成功!")
  166. EventBus.$emit('appointment-search',{
  167. data: kwObj
  168. })
  169. } else {
  170. top.showErrorMessage(res.msg || "取消预约失败!")
  171. }
  172. }).catch(function(e) {
  173. top.layer.close(loadingid)
  174. console && console.error(e)
  175. })
  176. }, function(){
  177. });
  178. })
  179. }
  180. })()