common.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. var g = {};
  2. /**
  3. * 打开新窗口
  4. * @param {[type]} url [description]
  5. * @param {[type]} title [description]
  6. * @param {[type]} width [description]
  7. * @param {[type]} height [description]
  8. * @return {[type]} [description]
  9. */
  10. function openWin(url, title, width, height) {
  11. if (width == undefined) {
  12. width = $(window).width() * 0.6 + 'px';
  13. }
  14. if (height == undefined) {
  15. height = $(window).height() * 0.75 + 'px';
  16. }
  17. if (title == undefined) {
  18. title = '系统管理';
  19. }
  20. g.currentWin = layer.open({
  21. type: 2,
  22. title: title,
  23. shadeClose: true,
  24. shade: [0.1, '#fff'],
  25. maxmin: true, //开启最大化最小化按钮
  26. area: [width, height],
  27. content: url
  28. });
  29. }
  30. function openHtml(obj, title, width, height) {
  31. if (width == undefined) {
  32. width = $(window).width() * 0.6 + 'px';
  33. }
  34. if (height == undefined) {
  35. height = $(window).height() * 0.75 + 'px';
  36. }
  37. if (title == undefined) {
  38. title = '系统管理';
  39. }
  40. g.currentHtmlWin = layer.open({
  41. type: 1,
  42. shadeClose: true,
  43. shade: [0.1, '#fff'],
  44. title: title,
  45. maxmin: true, //开启最大化最小化按钮
  46. // skin: 'layui-layer-rim', //加上边框
  47. area: [width, height],
  48. content: $(obj).html()
  49. });
  50. }
  51. /**
  52. * 添加到标答
  53. * @param {*}
  54. * @param {*}
  55. */
  56. function joinTab($title, $url) {
  57. parent.addTab(null, $title, $url);
  58. }
  59. function closeWin() {
  60. layer.close(g.currentWin);
  61. }
  62. //无刷新重载表格
  63. function reloadDataTable() {
  64. try {
  65. g.currentDataTableReload['reload'].call();
  66. } catch (ex) {}
  67. }
  68. /**
  69. * 删除数据
  70. * @param {[type]} url [description]
  71. * @return {[type]} [description]
  72. */
  73. function delWin(url, ids) {
  74. ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
  75. console.log(g.currentDataTableIds);
  76. if (ids == '' || ids == undefined) {
  77. layer.msg('请先选择数据');
  78. return;
  79. }
  80. layer.confirm('是否确认删除?', {
  81. btn: ['确认', '取消'] //按钮
  82. }, function() {
  83. $.getJSON(url + ids, function(data, textStatus) {
  84. if (data.status == '1') {
  85. reloadDataTable();
  86. layer.msg('删除成功');
  87. } else {
  88. layer.msg(data.msg);
  89. }
  90. });
  91. }, function() {
  92. });
  93. }
  94. /**
  95. * 结算全场
  96. * @param {[type]} url [description]
  97. * @return {[type]} [description]
  98. */
  99. function allbalance(url, ids) {
  100. ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
  101. // console.log(1111);
  102. if (ids == '' || ids == undefined) {
  103. layer.msg('请先选择数据');
  104. return;
  105. }
  106. layer.confirm('是否确认结算?', {
  107. btn: ['确认', '取消'] //按钮
  108. }, function() {
  109. $.getJSON(url + ids, function(data, textStatus) {
  110. if (data.status == '1') {
  111. reloadDataTable();
  112. g.currentDataTableIdArray=undefined;
  113. layer.msg('结算成功');
  114. } else {
  115. layer.msg(data.msg);
  116. }
  117. });
  118. }, function() {
  119. });
  120. }
  121. /**
  122. * 多赛事作废
  123. * @param {[type]} url [description]
  124. * @return {[type]} [description]
  125. */
  126. function allrevoke(url, ids) {
  127. ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
  128. // console.log(1111);
  129. if (ids == '' || ids == undefined) {
  130. layer.msg('请先选择数据');
  131. return;
  132. }
  133. layer.confirm('是否确认作废?', {
  134. btn: ['确认', '取消'] //按钮
  135. }, function() {
  136. $.getJSON(url + ids, function(data, textStatus) {
  137. if (data.status == '1') {
  138. reloadDataTable();
  139. g.currentDataTableIdArray=undefined;
  140. layer.msg('作废成功');
  141. } else {
  142. layer.msg(data.msg);
  143. }
  144. });
  145. }, function() {
  146. });
  147. }
  148. $(document).ready(function() {
  149. $('*[eventType=eventForm]').submit(function() {
  150. $(this).attr('method', 'get');
  151. return true;
  152. });
  153. $('*[eventType=eventAjaxForm]').submit(function() {
  154. var uid = $(this).serialize() + $(this).attr('action');
  155. if (g.parentUid == uid) {
  156. return false;
  157. }
  158. g.parentUid = uid;
  159. var msgIndex = parent.layer.msg('数据提交中...', {
  160. icon: 16,
  161. shade: 0.71
  162. });
  163. $.post($(this).attr('action'), $(this).serialize(), function(data, status) {
  164. parent.layer.close(msgIndex);
  165. if (data.status == '1') {
  166. try {
  167. cbFormSuccess(data);
  168. } catch (ex) {
  169. window.history.back();
  170. // parent.window.location.reload();
  171. }
  172. } else {
  173. try {
  174. cbFormFail(data);
  175. } catch (ex) {
  176. parent.layer.msg(data.msg);
  177. }
  178. }
  179. });
  180. return false;
  181. });
  182. $(document).on('click', '[eventType=event-view]', function() {
  183. var url = $(this).attr('uri');
  184. var pid = $(this).attr('pid');
  185. var width = $(this).attr('win-width');
  186. var height = $(this).attr('win-height');
  187. var id = $(this).parent().find('span').attr('data-' + pid);
  188. openWin(url + id, '查看详细信息', width, height);
  189. });
  190. $(document).on('click', '[eventType=event-edit]', function() {
  191. var url = $(this).attr('uri');
  192. var pid = $(this).attr('pid');
  193. var width = $(this).attr('win-width');
  194. var height = $(this).attr('win-height');
  195. var id = $(this).parent().find('span').attr('data-' + pid);
  196. openWin(url + id, '修改信息', width, height);
  197. });
  198. $('form').keyup(function(event) {
  199. if (event.keyCode == 13) {
  200. try {
  201. $(".lay-btn-diy").trigger("click");
  202. } catch (ex) {}
  203. try {
  204. $('*[eventType=event-query-submit]').click();
  205. } catch (ex) {}
  206. }
  207. });
  208. });
  209. try {
  210. $('*[eventType=event-query-submit]').click(function() {
  211. $('*[eventType=eventForm]').submit();
  212. });
  213. } catch (ex) {}
  214. // try {
  215. // $(".lay-btn-diy").click(function () {
  216. // $('*[eventType=eventForm]').submit();
  217. // });
  218. // } catch (ex) { }
  219. function selfTab(name, value) {
  220. $('*[name=' + name + "]").val(value);
  221. // $('*[eventType=event-query-submit]').click();
  222. }
  223. layui.use(['table', 'form', 'tree', 'laydate'], function() {
  224. laydate = layui.laydate //日期;
  225. lay('*[eventType=event-datetime]').each(function() {
  226. laydate.render({
  227. elem: this,
  228. type: 'datetime',
  229. trigger: 'click'
  230. });
  231. });
  232. $('select[eventType=event_query]', function(data) {
  233. // try {
  234. // $(".lay-btn-diy").trigger("click");
  235. // } catch (ex) { }
  236. // try {
  237. // $('*[eventType=event-query-submit]').click();
  238. // } catch (ex) { }
  239. });
  240. });
  241. /**
  242. * 删除数据
  243. * @param {[type]} url [description]
  244. * @return {[type]} [description]
  245. */
  246. function editLine(url, title) {
  247. layer.confirm('是否确认修改?', {
  248. btn: ['确认', '取消'] //按钮
  249. }, function() {
  250. $.getJSON(url, function(data, textStatus) {
  251. if (data.status == '1') {
  252. layer.msg('修改成功');
  253. reloadDataTable();
  254. } else {
  255. layer.msg(data.msg);
  256. }
  257. });
  258. }, function() {});
  259. }