common.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. 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. }
  204. try {
  205. $('*[eventType=event-query-submit]').click();
  206. } catch (ex) {
  207. }
  208. }
  209. });
  210. });
  211. try {
  212. $('*[eventType=event-query-submit]').click(function () {
  213. $('*[eventType=eventForm]').submit();
  214. });
  215. } catch (ex) {
  216. }
  217. // try {
  218. // $(".lay-btn-diy").click(function () {
  219. // $('*[eventType=eventForm]').submit();
  220. // });
  221. // } catch (ex) { }
  222. function selfTab(name, value) {
  223. $('*[name=' + name + "]").val(value);
  224. // $('*[eventType=event-query-submit]').click();
  225. }
  226. layui.use(['table', 'form', 'tree', 'laydate'], function () {
  227. laydate = layui.laydate //日期;
  228. lay('*[eventType=event-datetime]').each(function () {
  229. laydate.render({
  230. elem: this,
  231. type: 'datetime',
  232. trigger: 'click'
  233. });
  234. });
  235. $('select[eventType=event_query]', function (data) {
  236. // try {
  237. // $(".lay-btn-diy").trigger("click");
  238. // } catch (ex) { }
  239. // try {
  240. // $('*[eventType=event-query-submit]').click();
  241. // } catch (ex) { }
  242. });
  243. });
  244. /**
  245. * 删除数据
  246. * @param {[type]} url [description]
  247. * @return {[type]} [description]
  248. */
  249. function editLine(url, title) {
  250. layer.confirm('是否确认修改?', {
  251. btn: ['确认', '取消'] //按钮
  252. }, function () {
  253. $.getJSON(url, function (data, textStatus) {
  254. if (data.status == '1') {
  255. layer.msg('修改成功');
  256. reloadDataTable();
  257. } else {
  258. layer.msg(data.msg);
  259. }
  260. });
  261. }, function () {
  262. });
  263. }
  264. //js 正则判断
  265. function jsReg(type, content) {
  266. switch (type) {
  267. case 'number':
  268. return /^\d+$/.exec(content);
  269. break;
  270. case 'char':
  271. return /^[a-zA-Z]+$/.exec(content);
  272. break;
  273. case 'numberchar':
  274. return /^\w+$/.exec(content);
  275. break;
  276. default:
  277. return false;
  278. }
  279. return false;
  280. }