| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- var g = {};
- /**
- * 打开新窗口
- * @param {[type]} url [description]
- * @param {[type]} title [description]
- * @param {[type]} width [description]
- * @param {[type]} height [description]
- * @return {[type]} [description]
- */
- function openWin(url, title, width, height) {
- if (width == undefined) {
- width = $(window).width() * 0.6 + 'px';
- }
- if (height == undefined) {
- height = $(window).height() * 0.75 + 'px';
- }
- if (title == undefined) {
- title = '系统管理';
- }
- g.currentWin = layer.open({
- type: 2,
- title: title,
- shadeClose: true,
- shade: [0.1, '#fff'],
- maxmin: true, //开启最大化最小化按钮
- area: [width, height],
- content: url
- });
- }
- function openHtml(obj, title, width, height) {
- if (width == undefined) {
- width = $(window).width() * 0.6 + 'px';
- }
- if (height == undefined) {
- height = $(window).height() * 0.75 + 'px';
- }
- if (title == undefined) {
- title = '系统管理';
- }
- g.currentHtmlWin = layer.open({
- type: 1,
- shadeClose: true,
- shade: [0.1, '#fff'],
- title: title,
- maxmin: true, //开启最大化最小化按钮
- // skin: 'layui-layer-rim', //加上边框
- area: [width, height],
- content: $(obj).html()
- });
- }
- /**
- * 添加到标答
- * @param {*}
- * @param {*}
- */
- function joinTab($title, $url) {
- parent.addTab(null, $title, $url);
- }
- function closeWin() {
- layer.close(g.currentWin);
- }
- //无刷新重载表格
- function reloadDataTable() {
- try {
- g.currentDataTableReload['reload'].call();
- } catch (ex) {
- }
- }
- /**
- * 删除数据
- * @param {[type]} url [description]
- * @return {[type]} [description]
- */
- function delWin(url, ids) {
- ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
- console.log(g.currentDataTableIds);
- if (ids == '' || ids == undefined) {
- layer.msg('请先选择数据');
- return;
- }
- layer.confirm('是否确认删除?', {
- btn: ['确认', '取消'] //按钮
- }, function () {
- $.getJSON(url + ids, function (data, textStatus) {
- if (data.status == '1') {
- reloadDataTable();
- layer.msg('删除成功');
- } else {
- layer.msg(data.msg);
- }
- });
- }, function () {
- });
- }
- /**
- * 结算全场
- * @param {[type]} url [description]
- * @return {[type]} [description]
- */
- function allbalance(url, ids) {
- ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
- if (ids == '' || ids == undefined) {
- layer.msg('请先选择数据');
- return;
- }
- layer.confirm('是否确认结算?', {
- btn: ['确认', '取消'] //按钮
- }, function () {
- $.getJSON(url + ids, function (data, textStatus) {
- if (data.status == '1') {
- reloadDataTable();
- g.currentDataTableIdArray = undefined;
- layer.msg('结算成功');
- } else {
- layer.msg(data.msg);
- }
- });
- }, function () {
- });
- }
- /**
- * 多赛事作废
- * @param {[type]} url [description]
- * @return {[type]} [description]
- */
- function allrevoke(url, ids) {
- ids = (ids == undefined || ids == '') ? g.currentDataTableIds : ids;
- // console.log(1111);
- if (ids == '' || ids == undefined) {
- layer.msg('请先选择数据');
- return;
- }
- layer.confirm('是否确认作废?', {
- btn: ['确认', '取消'] //按钮
- }, function () {
- $.getJSON(url + ids, function (data, textStatus) {
- if (data.status == '1') {
- reloadDataTable();
- g.currentDataTableIdArray = undefined;
- layer.msg('作废成功');
- } else {
- layer.msg(data.msg);
- }
- });
- }, function () {
- });
- }
- $(document).ready(function () {
- $('*[eventType=eventForm]').submit(function () {
- $(this).attr('method', 'get');
- return true;
- });
- $('*[eventType=eventAjaxForm]').submit(function () {
- var uid = $(this).serialize() + $(this).attr('action');
- if (g.parentUid == uid) {
- return false;
- }
- g.parentUid = uid;
- var msgIndex = parent.layer.msg('数据提交中...', {
- icon: 16,
- shade: 0.71
- });
- $.post($(this).attr('action'), $(this).serialize(), function (data, status) {
- parent.layer.close(msgIndex);
- if (data.status == '1') {
- try {
- cbFormSuccess(data);
- } catch (ex) {
- window.history.back();
- // parent.window.location.reload();
- }
- } else {
- try {
- cbFormFail(data);
- } catch (ex) {
- parent.layer.msg(data.msg);
- }
- }
- });
- return false;
- });
- $(document).on('click', '[eventType=event-view]', function () {
- var url = $(this).attr('uri');
- var pid = $(this).attr('pid');
- var width = $(this).attr('win-width');
- var height = $(this).attr('win-height');
- var id = $(this).parent().find('span').attr('data-' + pid);
- openWin(url + id, '查看详细信息', width, height);
- });
- $(document).on('click', '[eventType=event-edit]', function () {
- var url = $(this).attr('uri');
- var pid = $(this).attr('pid');
- var width = $(this).attr('win-width');
- var height = $(this).attr('win-height');
- var id = $(this).parent().find('span').attr('data-' + pid);
- openWin(url + id, '修改信息', width, height);
- });
- $('form').keyup(function (event) {
- if (event.keyCode == 13) {
- try {
- $(".lay-btn-diy").trigger("click");
- } catch (ex) {
- }
- try {
- $('*[eventType=event-query-submit]').click();
- } catch (ex) {
- }
- }
- });
- });
- try {
- $('*[eventType=event-query-submit]').click(function () {
- $('*[eventType=eventForm]').submit();
- });
- } catch (ex) {
- }
- // try {
- // $(".lay-btn-diy").click(function () {
- // $('*[eventType=eventForm]').submit();
- // });
- // } catch (ex) { }
- function selfTab(name, value) {
- $('*[name=' + name + "]").val(value);
- // $('*[eventType=event-query-submit]').click();
- }
- layui.use(['table', 'form', 'tree', 'laydate'], function () {
- laydate = layui.laydate //日期;
- lay('*[eventType=event-datetime]').each(function () {
- laydate.render({
- elem: this,
- type: 'datetime',
- trigger: 'click'
- });
- });
- $('select[eventType=event_query]', function (data) {
- // try {
- // $(".lay-btn-diy").trigger("click");
- // } catch (ex) { }
- // try {
- // $('*[eventType=event-query-submit]').click();
- // } catch (ex) { }
- });
- });
- /**
- * 删除数据
- * @param {[type]} url [description]
- * @return {[type]} [description]
- */
- function editLine(url, title) {
- layer.confirm('是否确认修改?', {
- btn: ['确认', '取消'] //按钮
- }, function () {
- $.getJSON(url, function (data, textStatus) {
- if (data.status == '1') {
- layer.msg('修改成功');
- reloadDataTable();
- } else {
- layer.msg(data.msg);
- }
- });
- }, function () {
- });
- }
- //js 正则判断
- function jsReg(type, content) {
- switch (type) {
- case 'number':
- return /^\d+$/.exec(content);
- break;
- case 'char':
- return /^[a-zA-Z]+$/.exec(content);
- break;
- case 'numberchar':
- return /^\w+$/.exec(content);
- break;
- default:
- return false;
- }
- return false;
- }
|