common.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. * 删除数据
  71. * @param {[type]} url [description]
  72. * @return {[type]} [description]
  73. */
  74. function delWin(url, ids) {
  75. ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
  76. console.log(g.currentDataTableIds);
  77. if (ids == '' || ids == undefined) {
  78. layer.msg('请先选择数据');
  79. return;
  80. }
  81. layer.confirm('是否确认删除?', {
  82. btn: ['确认', '取消'] //按钮
  83. }, function () {
  84. $.getJSON(url + ids, function (data, textStatus) {
  85. if (data.status == '1') {
  86. reloadDataTable();
  87. layer.msg('删除成功');
  88. } else {
  89. layer.msg(data.msg);
  90. }
  91. });
  92. }, function () {
  93. });
  94. }
  95. /**
  96. * 结算全场
  97. * @param {[type]} url [description]
  98. * @return {[type]} [description]
  99. */
  100. function allbalance(url, ids) {
  101. ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
  102. // console.log(1111);
  103. if (ids == '' || ids == undefined) {
  104. layer.msg('请先选择数据');
  105. return;
  106. }
  107. layer.confirm('是否确认结算?', {
  108. btn: ['确认', '取消'] //按钮
  109. }, function () {
  110. $.getJSON(url + ids, function (data, textStatus) {
  111. if (data.status == '1') {
  112. reloadDataTable();
  113. g.currentDataTableIdArray = undefined;
  114. layer.msg('结算成功');
  115. } else {
  116. layer.msg(data.msg);
  117. }
  118. });
  119. }, function () {
  120. });
  121. }
  122. /**
  123. * 多赛事作废
  124. * @param {[type]} url [description]
  125. * @return {[type]} [description]
  126. */
  127. function allrevoke(url, ids) {
  128. ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
  129. // console.log(1111);
  130. if (ids == '' || ids == undefined) {
  131. layer.msg('请先选择数据');
  132. return;
  133. }
  134. layer.confirm('是否确认作废?', {
  135. btn: ['确认', '取消'] //按钮
  136. }, function () {
  137. $.getJSON(url + ids, function (data, textStatus) {
  138. if (data.status == '1') {
  139. reloadDataTable();
  140. g.currentDataTableIdArray = undefined;
  141. layer.msg('作废成功');
  142. } else {
  143. layer.msg(data.msg);
  144. }
  145. });
  146. }, function () {
  147. });
  148. }
  149. $(document).ready(function () {
  150. $('*[eventType=eventForm]').submit(function () {
  151. $(this).attr('method', 'get');
  152. return true;
  153. });
  154. $('*[eventType=eventAjaxForm]').submit(function () {
  155. var uid = $(this).serialize() + $(this).attr('action');
  156. if (g.parentUid == uid) {
  157. return false;
  158. }
  159. g.parentUid = uid;
  160. var msgIndex = parent.layer.msg('数据提交中...', {
  161. icon: 16,
  162. shade: 0.71
  163. });
  164. $.post($(this).attr('action'), $(this).serialize(), function (data, status) {
  165. parent.layer.close(msgIndex);
  166. if (data.status == '1') {
  167. try {
  168. cbFormSuccess(data);
  169. } catch (ex) {
  170. window.history.back();
  171. // parent.window.location.reload();
  172. }
  173. } else {
  174. try {
  175. cbFormFail(data);
  176. } catch (ex) {
  177. parent.layer.msg(data.msg);
  178. }
  179. }
  180. });
  181. return false;
  182. });
  183. $(document).on('click', '[eventType=event-view]', function () {
  184. var url = $(this).attr('uri');
  185. var pid = $(this).attr('pid');
  186. var width = $(this).attr('win-width');
  187. var height = $(this).attr('win-height');
  188. var id = $(this).parent().find('span').attr('data-' + pid);
  189. openWin(url + id, '查看详细信息', width, height);
  190. });
  191. $(document).on('click', '[eventType=event-edit]', function () {
  192. var url = $(this).attr('uri');
  193. var pid = $(this).attr('pid');
  194. var width = $(this).attr('win-width');
  195. var height = $(this).attr('win-height');
  196. var id = $(this).parent().find('span').attr('data-' + pid);
  197. openWin(url + id, '修改信息', width, height);
  198. });
  199. $('form').keyup(function (event) {
  200. if (event.keyCode == 13) {
  201. try {
  202. $(".lay-btn-diy").trigger("click");
  203. } catch (ex) {
  204. }
  205. try {
  206. $('*[eventType=event-query-submit]').click();
  207. } catch (ex) {
  208. }
  209. }
  210. });
  211. });
  212. try {
  213. $('*[eventType=event-query-submit]').click(function () {
  214. $('*[eventType=eventForm]').submit();
  215. });
  216. } catch (ex) {
  217. }
  218. // try {
  219. // $(".lay-btn-diy").click(function () {
  220. // $('*[eventType=eventForm]').submit();
  221. // });
  222. // } catch (ex) { }
  223. function selfTab(name, value) {
  224. $('*[name=' + name + "]").val(value);
  225. // $('*[eventType=event-query-submit]').click();
  226. }
  227. layui.use(['table', 'form', 'tree', 'laydate'], function () {
  228. laydate = layui.laydate //日期;
  229. lay('*[eventType=event-datetime]').each(function () {
  230. laydate.render({
  231. elem: this,
  232. type: 'datetime',
  233. trigger: 'click'
  234. });
  235. });
  236. $('select[eventType=event_query]', function (data) {
  237. // try {
  238. // $(".lay-btn-diy").trigger("click");
  239. // } catch (ex) { }
  240. // try {
  241. // $('*[eventType=event-query-submit]').click();
  242. // } catch (ex) { }
  243. });
  244. });
  245. /**
  246. * 删除数据
  247. * @param {[type]} url [description]
  248. * @return {[type]} [description]
  249. */
  250. function editLine(url, title) {
  251. layer.confirm('是否确认修改?', {
  252. btn: ['确认', '取消'] //按钮
  253. }, function () {
  254. $.getJSON(url, function (data, textStatus) {
  255. if (data.status == '1') {
  256. layer.msg('修改成功');
  257. reloadDataTable();
  258. } else {
  259. layer.msg(data.msg);
  260. }
  261. });
  262. }, function () {
  263. });
  264. }
  265. //js 正则判断
  266. function jsReg(type, content) {
  267. switch (type) {
  268. case 'number':
  269. return /^\d+$/.exec(content);
  270. break;
  271. case 'char':
  272. return /^[a-zA-Z]+$/.exec(content);
  273. break;
  274. case 'numberchar':
  275. return /^\w+$/.exec(content);
  276. break;
  277. default:
  278. return false;
  279. }
  280. return false;
  281. }