暂无描述

newVersionUpdate.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. $(document).ready(function () {
  2. //加载列表
  3. initTable();
  4. //搜索
  5. $(".search").on("click", function(){
  6. initTable();
  7. })
  8. //添加
  9. $(".add").on("click", function(){
  10. btnAdd();
  11. })
  12. //修改
  13. $(".modify").on("click", function(){
  14. btnModify();
  15. })
  16. // 鼠标移动 显示二维码
  17. // $('.topbarClient').hover(function () {
  18. // $('.topbarClient .topbarClient-box').css('left', $(this).offset().left);
  19. // });
  20. // 获取客户端地址并转成二维码
  21. getClients();
  22. })
  23. //获取客户端地址并转成二维码
  24. function getClients() {
  25. var curentHost = window.location.protocol + '//' + window.location.host;
  26. var clientURL = curentHost + '/newVersionUpdate/download.html?n=' + Math.random();
  27. var qrcode = new QRCode(document.getElementById('elevator-app-qrcode'), {
  28. width: 108,
  29. height: 108
  30. });
  31. qrcode.makeCode(clientURL);
  32. }
  33. //列表
  34. function initTable() {
  35. //先销毁表格
  36. $('#workorderlist').bootstrapTable('destroy');
  37. //初始化表格,动态从服务器加载数据
  38. $("#workorderlist").bootstrapTable({
  39. method: "get", //使用get请求到服务器获取数据
  40. url: huayi.config.callcenter_url + "ApplicationsVersion/GetList", //获取数据的Servlet地址
  41. contentType: 'application/x-www-form-urlencoded',
  42. striped: true, //表格显示条纹
  43. pagination: true, //启动分页
  44. pageSize: 10, //每页显示的记录数
  45. pageNumber: 1, //当前第几页
  46. pageList: [10, 20, 50, 100], //记录数可选列表
  47. search: false, //是否启用查询
  48. showColumns: false, //显示下拉框勾选要显示的列
  49. showRefresh: false, //显示刷新按钮
  50. sidePagination: "server", //表示服务端请求
  51. //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
  52. //设置为limit可以获取limit, offset, search, sort, order
  53. queryParamsType: "undefined",
  54. queryParams: function queryParams(params) { //设置查询参数
  55. var param = {
  56. token: $.cookie("token"),
  57. keywords: $("#searchBlurry").val().replace(/\ +/g,""), //模糊搜索
  58. pageindex: params.pageNumber, //页码
  59. pagesize: params.pageSize, //条数
  60. };
  61. return param;
  62. },
  63. onLoadSuccess: function () { //加载成功时执行
  64. //layer.msg("加载成功");
  65. },
  66. onLoadError: function () { //加载失败时执行
  67. //layer.msg("加载数据失败", { time: 1500, icon: 2 });
  68. }
  69. });
  70. }
  71. //添加
  72. function btnAdd () {
  73. layer.open({
  74. type: 2,
  75. title: '添加',
  76. maxmin: true, //开启最大化最小化按钮
  77. area: ['50%', '80%'],
  78. content: "./newVersionUpdateAdd.html?",
  79. });
  80. }
  81. //修改
  82. function btnModify () {
  83. var ids = $.map($("#workorderlist").bootstrapTable('getSelections'), function (row) {
  84. return row.F_ID;
  85. });
  86. var id = ids.toString();
  87. if (ids.length != 1) {
  88. layer.confirm('请选择一行进行修改!', {
  89. btn: ['确定']
  90. });
  91. return;
  92. } else {
  93. layer.open({
  94. type: 2,
  95. title: '修改',
  96. maxmin: true, //开启最大化最小化按钮
  97. area: ['50%', '80%'],
  98. content: "./newVersionUpdateModify.html?id=" + id,
  99. });
  100. }
  101. }
  102. //删除
  103. var delid;
  104. $('.delete').click(function () {
  105. var ids = $.map($("#workorderlist").bootstrapTable('getSelections'), function (row) {
  106. return row.F_ID;
  107. });
  108. delid = ids;
  109. if (ids.length <= 0) {
  110. layer.confirm('请选择要删除的行!', {
  111. btn: ['确定']
  112. });
  113. return;
  114. } else {
  115. var laye = layer.confirm('您确定要删除吗?', {
  116. btn: ['确定', '取消'] //可以无限个按钮
  117. }, function () {
  118. //按钮【按钮一】的回调
  119. $.ajax({
  120. type: "post",
  121. url: huayi.config.callcenter_url + "ApplicationsVersion/DelApp",
  122. async: true,
  123. dataType: "json",
  124. data: {
  125. token: $.cookie("token"),
  126. ids: delid
  127. },
  128. success: function (data) {
  129. if (data.state.toLowerCase() == 'success') {
  130. layer.msg("删除成功!");
  131. $("#workorderlist").bootstrapTable('refresh');
  132. }
  133. }
  134. });
  135. }, function (index) {
  136. //按钮【按钮二】的回调
  137. layer.close(laye)
  138. });
  139. }
  140. })
  141. function setCode (val, row, index) {
  142. return index + 1;
  143. }
  144. // 应用分类
  145. function appType (val, row) {
  146. if (val === 0 ) {
  147. return "Android";
  148. } else if (val === 1) {
  149. return "IOS";
  150. }
  151. }
  152. // 下载地址
  153. function formatterUrl (val, row) {
  154. if (val === 0) {
  155. if (row.FileUrl.length === 0) {
  156. return "-";
  157. } else if (row.FileUrl.length > 0) {
  158. return "<a href='" + row.FileUrl[0].F_Url + "' class='abtn' download = '" + row.FileUrl[0].F_Name + "' title = '点击下载'>" + row.FileUrl[0].F_Name + "</a>"
  159. }
  160. } else if (val === 1) {
  161. return "<a href='" + row.F_Url + "'>ios下载地址</a>"
  162. }
  163. }
  164. // 添加时间
  165. function formatterCreateTime (val, row) {
  166. if (val.length === 0) {
  167. return "-";
  168. } else if (val.length > 0) {
  169. return val[0].F_CreateTime;
  170. }
  171. }
  172. //按enter搜索
  173. $('#searchBlurry').bind('keypress', function (event) {
  174. if (event.keyCode == "13") {
  175. initTable();
  176. return false;
  177. }
  178. });