初始化提交
This commit is contained in:
213
public/static/plugs/admin/excel.js
Normal file
213
public/static/plugs/admin/excel.js
Normal file
@@ -0,0 +1,213 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define(function () {
|
||||
|
||||
/*! 定义构造函数 */
|
||||
function Excel(data, name) {
|
||||
if (data && name) this.export(data, name);
|
||||
}
|
||||
|
||||
/*! 默认导出配置 */
|
||||
Excel.prototype.options = {writeOpt: {bookSST: true}};
|
||||
|
||||
/*! 导出 Excel 文件 */
|
||||
Excel.prototype.export = function (data, name, options) {
|
||||
if (name.substring(0, -5).toLowerCase() !== '.xlsx') name += '.xlsx';
|
||||
layui.excel.exportExcel(data, name, 'xlsx', options || this.options || {writeOpt: {bookSST: true}});
|
||||
};
|
||||
|
||||
/*! 绑定导出的事件 */
|
||||
// <a data-form-export>通用导出</a>
|
||||
// <a data-form-export="URL链接">指定链接导出</a>
|
||||
// <!-- 自定义导出 Excel 文件 -->
|
||||
// <a id="EXPORT1" data-excel="URL链接">自定义导出1</a>
|
||||
// <a id="EXPORT2" data-excel="URL链接">自定义导出2</a>
|
||||
// <script>
|
||||
// Excel.bind(DONE1,FILENAME1,'#EXPORT1')
|
||||
// Excel.bind(DONE2,FILENAME2,'#EXPORT2')
|
||||
// </script>
|
||||
Excel.prototype.bind = function (done, filename, selector, options) {
|
||||
let that = this;
|
||||
this.options = options || {}
|
||||
$('body').off('click', selector || '[data-form-export]').on('click', selector || '[data-form-export]', function () {
|
||||
let form = $(this).parents('form');
|
||||
let name = this.dataset.filename || filename;
|
||||
let method = this.dataset.method || form.attr('method') || 'get';
|
||||
let location = this.dataset.excel || this.dataset.formExport || form.attr('action') || '';
|
||||
let sortType = $(this).attr('data-sort-type') || '', sortField = $(this).attr('data-sort-field') || '';
|
||||
if (sortField.length > 0 && sortType.length > 0) {
|
||||
location += (location.indexOf('?') > -1 ? '&' : '?') + '_order_=' + sortType + '&_field_=' + sortField;
|
||||
}
|
||||
that.load(location, form.serialize(), method).then(function (data) {
|
||||
that.export(done.call(that, data, []), name);
|
||||
}).fail(function (ret) {
|
||||
$.msg.tips(ret || '文件导出失败');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/*! 加载导出的文档 */
|
||||
Excel.prototype.load = function (url, data, method) {
|
||||
return (function (defer, lists, loaded) {
|
||||
loaded = $.msg.loading('正在加载 <span data-upload-count>0.00</span>%');
|
||||
return (lists = []), LoadNextPage(1, 1), defer;
|
||||
|
||||
function LoadNextPage(curPage, maxPage, urlParams) {
|
||||
let proc = (curPage / maxPage * 100).toFixed(2);
|
||||
$('[data-upload-count]').html(proc > 100 ? '100.00' : proc);
|
||||
if (curPage > maxPage) return $.msg.close(loaded), defer.resolve(lists);
|
||||
urlParams = (url.indexOf('?') > -1 ? '&' : '?') + 'output=json¬_cache_limit=1&limit=100&page=' + curPage;
|
||||
$.form.load(url + urlParams, data, method, function (ret) {
|
||||
if (ret.code) {
|
||||
lists = lists.concat(ret.data.list);
|
||||
if (ret.data.page) LoadNextPage((ret.data.page.current || 1) + 1, ret.data.page.pages || 1);
|
||||
} else {
|
||||
defer.reject('数据加载异常');
|
||||
}
|
||||
return false;
|
||||
}, false);
|
||||
}
|
||||
})($.Deferred());
|
||||
};
|
||||
|
||||
/*! 设置表格导出样式 */
|
||||
// this.withStyle(data, {A: 60, B: 80, C: 99, E: 120, G: 120}, 99, 28)
|
||||
Excel.prototype.withStyle = function (data, colsWidth, defaultWidth, defaultHeight) {
|
||||
// 自动计算列序
|
||||
let idx, colN = 0, defaC = {}, lastCol;
|
||||
for (idx in data[0]) defaC[lastCol = layui.excel.numToTitle(++colN)] = defaultWidth || 99;
|
||||
defaC[lastCol] = 160;
|
||||
|
||||
// 设置表头样式
|
||||
layui.excel.setExportCellStyle(data, 'A1:' + lastCol + '1', {
|
||||
s: {
|
||||
font: {sz: 12, bold: true, color: {rgb: "FFFFFF"}, name: '微软雅黑', shadow: true},
|
||||
fill: {bgColor: {indexed: 64}, fgColor: {rgb: '5FB878'}},
|
||||
alignment: {vertical: 'center', horizontal: 'center'}
|
||||
}
|
||||
});
|
||||
|
||||
// 设置内容样式
|
||||
(function (style1, style2) {
|
||||
layui.excel.setExportCellStyle(data, 'A2:' + lastCol + data.length, {s: style1}, function (rawCell, newCell, row, config, curRow) {
|
||||
typeof rawCell !== 'object' && (rawCell = {v: rawCell});
|
||||
rawCell.s = Object.assign({}, style2, rawCell.s || {});
|
||||
return (curRow % 2 === 0) ? newCell : rawCell;
|
||||
});
|
||||
})({
|
||||
font: {sz: 10, shadow: true, name: '微软雅黑'},
|
||||
fill: {bgColor: {indexed: 64}, fgColor: {rgb: "EAEAEA"}},
|
||||
alignment: {vertical: 'center', horizontal: 'center'}
|
||||
}, {
|
||||
font: {sz: 10, shadow: true, name: '微软雅黑'},
|
||||
fill: {bgColor: {indexed: 64}, fgColor: {rgb: "FFFFFF"}},
|
||||
alignment: {vertical: 'center', horizontal: 'center'}
|
||||
});
|
||||
|
||||
// 设置表格行宽高,需要设置最后的行或列宽高,否则部分不生效 ???
|
||||
let rowsC = {1: 33}, colsC = Object.assign({}, defaC, {A: 60}, colsWidth || {});
|
||||
rowsC[data.length] = defaultHeight || 28, this.options.extend = Object.assign({}, {
|
||||
'!cols': layui.excel.makeColConfig(colsC, defaultWidth || 99),
|
||||
'!rows': layui.excel.makeRowConfig(rowsC, defaultHeight || 28),
|
||||
}, this.options.extend || {});
|
||||
return data;
|
||||
}
|
||||
|
||||
/*! 直接推送表格内容 */
|
||||
// url: 记录推送地址
|
||||
// sheet: 表格 Sheet 名称
|
||||
// cols: { _: 1, 表头名1: 字段名1, 表头名2: 字段名2 },其中字段 _ 配置起始行
|
||||
// filter: 数据过滤处理,如果返回 false 不上传记录
|
||||
// Excel.push(ACTION, '用户信息', {_:1, username: "用户名称", phone: "联系手机"})
|
||||
Excel.prototype.push = function (url, sheet, cols, filter) {
|
||||
let loaded, $input;
|
||||
$input = $('<input class="layui-hide" type="file" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">');
|
||||
$input.appendTo($('body')).click().on('change', function (event) {
|
||||
if (!event.target.files || event.target.files.length < 1) return $.msg.tips('没有可操作文件');
|
||||
loaded = $.msg.loading('<span data-load-name>读取</span> <span data-load-count>0.00%</span>');
|
||||
try {
|
||||
// 导入Excel数据,并逐行上传处理
|
||||
layui.excel.importExcel(event.target.files, {}, function (data) {
|
||||
if (!data[0][sheet]) return $.msg.tips('未读取到表[' + sheet + ']的数据');
|
||||
let _cols = {}, _data = data[0][sheet], items = [], row, col, key, item;
|
||||
for (row in _data) if (parseInt(row) + 1 === parseInt(cols._ || '1')) {
|
||||
for (col in _data[row]) for (key in cols) if (_data[row][col] === cols[key]) _cols[key] = col;
|
||||
} else if (parseInt(row) + 1 > cols._ || 1) {
|
||||
item = {};
|
||||
for (key in _cols) item[key] = CellToValue(_data[row][_cols[key]]);
|
||||
items.push(item);
|
||||
}
|
||||
PushQueue(items, items.length, 0, 0, 1);
|
||||
});
|
||||
} catch (e) {
|
||||
$.msg.error('读取 Excel 文件失败!')
|
||||
}
|
||||
});
|
||||
|
||||
/*! 单项推送数据 */
|
||||
function PushQueue(items, total, ers, oks, idx) {
|
||||
if ((total = items.length) < 1) return CleanAll(), $.msg.tips('未读取到有效数据');
|
||||
return (ers = 0, oks = 0, idx = 0), $('[data-load-name]').html('更新'), DoPostItem(idx, items[idx]);
|
||||
|
||||
/*! 执行导入的数据 */
|
||||
function DoPostItem(idx, item, data) {
|
||||
if (idx >= total) {
|
||||
return CleanAll(), $.msg.success('共处理' + total + '条记录( 成功 ' + oks + ' 条, 失败 ' + ers + ' 条 )', 3, function () {
|
||||
$.form.reload();
|
||||
});
|
||||
} else {
|
||||
let proc = (idx * 100 / total).toFixed(2);
|
||||
$('[data-load-count]').html((proc > 100 ? '100.00' : proc) + '%( 成功 ' + oks + ' 条, 失败 ' + ers + ' 条 )');
|
||||
/*! 单元数据过滤 */
|
||||
data = item;
|
||||
if (filter && (data = filter(item)) === false) {
|
||||
return (ers++), DoPostItem(idx + 1, items[idx + 1]);
|
||||
}
|
||||
/*! 提交单个数据 */
|
||||
DoUpdate(url, data).then(function (ret) {
|
||||
(ret.code ? oks++ : ers++), DoPostItem(idx + 1, items[idx + 1]);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*! 清理文件选择器 */
|
||||
function CleanAll() {
|
||||
$input.remove();
|
||||
if (loaded) $.msg.close(loaded);
|
||||
}
|
||||
|
||||
/*! 表格单元内容转换 */
|
||||
function CellToValue(v) {
|
||||
if (typeof v !== 'undefined' && /^\d+\.\d{12}$/.test(v)) {
|
||||
return LAY_EXCEL.dateCodeFormat(v, 'YYYY-MM-DD HH:ii:ss');
|
||||
} else {
|
||||
return typeof v !== 'undefined' ? v : '';
|
||||
}
|
||||
}
|
||||
|
||||
/*! 队列方式上传数据 */
|
||||
function DoUpdate(url, item) {
|
||||
return (function (defer) {
|
||||
return $.form.load(url, item, 'post', function (ret) {
|
||||
return defer.resolve(ret), false;
|
||||
}, false), defer.promise();
|
||||
})($.Deferred());
|
||||
}
|
||||
}
|
||||
|
||||
/*! 返回对象实例 */
|
||||
return new Excel;
|
||||
});
|
||||
101
public/static/plugs/admin/queue.js
Normal file
101
public/static/plugs/admin/queue.js
Normal file
@@ -0,0 +1,101 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define(function () {
|
||||
|
||||
let template = '<div class="padding-30 padding-bottom-0" data-queue-load="{{d.code}}"><div class="layui-elip notselect nowrap" data-message-title><b class="color-desc">...</b></div><div class="margin-top-15 layui-progress layui-progress-big" lay-showPercent="yes"><div class="layui-progress-bar transition" lay-percent="0.00%"></div></div>' + '<div class="margin-top-15"><code class="layui-textarea layui-bg-black border-0" style="resize:none;overflow:hidden;height:190px"></code></div></div>';
|
||||
|
||||
return Queue;
|
||||
|
||||
function Queue(code, doScript, element) {
|
||||
let queue = this;
|
||||
(this.doAjax = true) && (this.doReload = false) || layer.open({
|
||||
type: 1, title: false, area: ['560px', '315px'], anim: 2, shadeClose: false, end: function () {
|
||||
queue.doAjax = queue.doReload && doScript && $.layTable.reload(((element || {}).dataset || {}).tableId || true) && false;
|
||||
}, content: laytpl(template).render({code: code}), success: function ($elem) {
|
||||
new Progress($elem, code, queue, doScript);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function Progress($elem, code, queue, doScript) {
|
||||
let that = this;
|
||||
|
||||
this.$box = $elem.find('[data-queue-load=' + code + ']');
|
||||
if (queue.doAjax === false || this.$box.length < 1) return false;
|
||||
|
||||
this.$code = this.$box.find('code');
|
||||
this.$title = this.$box.find('[data-message-title]');
|
||||
this.$percent = this.$box.find('.layui-progress div');
|
||||
|
||||
// 设置数据缓存
|
||||
this.SetCache = function (code, index, value) {
|
||||
let ckey = code + '_' + index, ctype = 'admin-queue-script';
|
||||
return value !== undefined ? layui.data(ctype, {key: ckey, value: value}) : layui.data(ctype)[ckey] || 0;
|
||||
};
|
||||
|
||||
// 更新任务显示状态
|
||||
this.SetState = function (status, message) {
|
||||
if (message.indexOf('javascript:') === -1) if (status === 1) {
|
||||
that.$title.html('<b class="color-text">' + message + '</b>').addClass('text-center');
|
||||
that.$percent.addClass('layui-bg-blue').removeClass('layui-bg-green layui-bg-red');
|
||||
} else if (status === 2) {
|
||||
if (message.indexOf('>>>') > -1) {
|
||||
that.$title.html('<b class="color-blue">' + message + '</b>').addClass('text-center');
|
||||
} else {
|
||||
that.$title.html('<b class="color-blue">正在处理:</b>' + message).removeClass('text-center');
|
||||
}
|
||||
that.$percent.addClass('layui-bg-blue').removeClass('layui-bg-green layui-bg-red');
|
||||
} else if (status === 3) {
|
||||
queue.doReload = true;
|
||||
that.$title.html('<b class="color-green">' + message + '</b>').addClass('text-center');
|
||||
that.$percent.addClass('layui-bg-green').removeClass('layui-bg-blue layui-bg-red');
|
||||
} else if (status === 4) {
|
||||
that.$title.html('<b class="color-red">' + message + '</b>').addClass('text-center');
|
||||
that.$percent.addClass('layui-bg-red').removeClass('layui-bg-blue layui-bg-green');
|
||||
}
|
||||
};
|
||||
|
||||
// 读取任务进度信息
|
||||
this.LoadProgress = function () {
|
||||
if (queue.doAjax === false || that.$box.length < 1) return false;
|
||||
$.form.load(tapiRoot + '/api.queue/progress', {code: code}, 'post', function (ret) {
|
||||
if (ret.code) {
|
||||
let lines = [];
|
||||
for (let idx in ret.data.history) {
|
||||
let line = ret.data.history[idx], percent = '[ ' + line.progress + '% ] ';
|
||||
if (line.message.indexOf('javascript:') === -1) {
|
||||
lines.push(line.message.indexOf('>>>') > -1 ? line.message : percent + line.message);
|
||||
} else if (!that.SetCache(code, idx) && doScript !== false) {
|
||||
that.SetCache(code, idx, 1)
|
||||
$.form.goto(line.message);
|
||||
}
|
||||
}
|
||||
if (ret.data.status > 0) {
|
||||
that.SetState(parseInt(ret.data.status), ret.data.message);
|
||||
that.$percent.attr('lay-percent', (parseFloat(ret.data.progress || '0.00').toFixed(2)) + '%') && layui.element.render();
|
||||
that.$code.html('<p class="layui-elip">' + lines.join('</p><p class="layui-elip">') + '</p>').animate({scrollTop: that.$code[0].scrollHeight + 'px'}, 200);
|
||||
parseInt(ret.data.status) === 3 || parseInt(ret.data.status) === 4 || setTimeout(that.LoadProgress, Math.floor(Math.random() * 200));
|
||||
} else {
|
||||
setTimeout(that.LoadProgress, Math.floor(Math.random() * 500) + 200);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, false);
|
||||
};
|
||||
|
||||
// 首页加载进度信息
|
||||
this.LoadProgress();
|
||||
}
|
||||
});
|
||||
126
public/static/plugs/admin/validate.js
Normal file
126
public/static/plugs/admin/validate.js
Normal file
@@ -0,0 +1,126 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define(function () {
|
||||
|
||||
return Validate;
|
||||
|
||||
function Validate(form) {
|
||||
let that = this;
|
||||
// 绑定表单元素
|
||||
this.form = $(form);
|
||||
// 绑定元素事件
|
||||
this.evts = 'blur change';
|
||||
// 检测表单元素
|
||||
this.tags = 'input,textarea';
|
||||
// 验证成功回调
|
||||
this.dones = [];
|
||||
// 预设检测规则
|
||||
this.patterns = {
|
||||
qq: '^[1-9][0-9]{4,11}$',
|
||||
ip: '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$',
|
||||
url: '^https?://([a-zA-Z0-9-]+\\.)+[-_a-zA-Z0-9-]+',
|
||||
phone: '^1[3-9][0-9]{9}$',
|
||||
mobile: '^1[3-9][0-9]{9}$',
|
||||
email: '^([a-zA-Z0-9_\\.-])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$',
|
||||
wechat: '^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$',
|
||||
cardid: '^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$',
|
||||
userame: '^[a-zA-Z0-9_-]{4,16}$',
|
||||
};
|
||||
// 设置完成回调
|
||||
this.addDoneEvent = function (done) {
|
||||
if (typeof done === 'function') this.dones.push(done);
|
||||
};
|
||||
this.isRegex = function (el, value, pattern) {
|
||||
pattern = pattern || el.getAttribute('pattern');
|
||||
if ((value = value || $.trim($(el).val())) === '') return true;
|
||||
if (!(pattern = this.patterns[pattern] || pattern)) return true;
|
||||
return new RegExp(pattern, 'i').test(value);
|
||||
};
|
||||
this.hasProp = function (el, prop) {
|
||||
let attrProp = el.getAttribute(prop);
|
||||
return typeof attrProp !== 'undefined' && attrProp !== null && attrProp !== false;
|
||||
};
|
||||
this.hasCheck = function (el, type) {
|
||||
if (this.hasProp(el, 'data-auto-none')) return false;
|
||||
type = (el.getAttribute('type') || '').replace(/\W+/, '').toLowerCase();
|
||||
return $.inArray(type, ['file', 'reset', 'image', 'radio', 'checkbox', 'submit', 'hidden']) < 0;
|
||||
};
|
||||
this.checkAllInput = function () {
|
||||
let status = true;
|
||||
return this.form.find(this.tags).each(function () {
|
||||
!that.checkInput(this) && status && (status = !$(this).focus());
|
||||
}) && status;
|
||||
};
|
||||
this.checkInput = function (el) {
|
||||
if (!this.hasCheck(el = typeof el === 'string' ? form[el] : el)) return true;
|
||||
if (this.hasProp(el, 'required') && $.trim($(el).val()) === '') return this.remind(el, 'required');
|
||||
return this.isRegex(el) ? !!this.hideError(el) : this.remind(el, 'pattern');
|
||||
};
|
||||
this.remind = function (el, type, tips) {
|
||||
return $(el).is(':visible') ? this.showError(el, tips || el.getAttribute(type + '-error') || function (name, tips) {
|
||||
return name ? name + (type === 'required' ? '不能为空' : "格式错误") : (tips || el.getAttribute('placeholder') || '输入格式错误');
|
||||
}(el.getAttribute('vali-name') || el.getAttribute('data-vali-name'), el.getAttribute('title'))) && false : true;
|
||||
};
|
||||
this.showError = function (el, tip) {
|
||||
return this.insertError($(el).addClass('validate-error')).addClass('layui-anim-fadein').css({width: 'auto'}).html(tip);
|
||||
};
|
||||
this.hideError = function (el) {
|
||||
return this.insertError($(el).removeClass('validate-error')).removeClass('layui-anim-fadein').css({width: '30px'}).html('');
|
||||
};
|
||||
this.insertError = function ($el) {
|
||||
return (function ($icon) {
|
||||
return $el.data('vali-tags').css({
|
||||
top: $el.position().top + 'px', right: (($icon ? $icon.width() + parseFloat($icon.css('right') || 0) : 0) + 10) + 'px',
|
||||
paddingTop: $el.css('marginTop'), lineHeight: ($el.get(0).nodeName || '') === 'TEXTAREA' ? '32px' : $el.css('height'),
|
||||
});
|
||||
})($el.nextAll('.input-right-icon'), $el.data('vali-tags') || function () {
|
||||
let css = 'display:block;position:absolute;text-align:center;color:#c44;font-size:12px;z-index:2';
|
||||
$el.data('vali-tags', $('<span class="layui-anim notselect" style="' + css + '"></span>').insertAfter($el));
|
||||
}());
|
||||
};
|
||||
/*! 预埋异常标签*/
|
||||
this.form.find(this.tags).each(function (i, el) {
|
||||
that.hasCheck(this) && that.hideError(el, '');
|
||||
});
|
||||
/*! 表单元素验证 */
|
||||
this.form.attr({onsubmit: 'return false', novalidate: 'novalidate', autocomplete: 'off'}).on('keydown', this.tags, function () {
|
||||
that.hideError(this)
|
||||
}).off(this.evts, this.tags).on(this.evts, this.tags, function () {
|
||||
that.checkInput(this);
|
||||
}).data('validate', this).bind('submit', function (evt) {
|
||||
evt.preventDefault();
|
||||
/* 检查所有表单元素是否通过H5的规则验证 */
|
||||
if (that.checkAllInput() && that.dones.length > 0) {
|
||||
if (typeof CKEDITOR === 'object' && typeof CKEDITOR.instances === 'object') {
|
||||
for (let i in CKEDITOR.instances) CKEDITOR.instances[i].updateElement();
|
||||
}
|
||||
/* 触发表单提交后,锁定三秒不能再次提交表单 */
|
||||
if (that.form.attr('submit-locked')) return false;
|
||||
evt.submit = that.form.find('button[type=submit],button:not([type=button])');
|
||||
$.base.onConfirm(evt.submit.attr('data-confirm'), function () {
|
||||
that.form.attr('submit-locked', 1) && evt.submit.addClass('submit-button-loading');
|
||||
setTimeout(function () {
|
||||
that.form.removeAttr('submit-locked') && evt.submit.removeClass('submit-button-loading');
|
||||
}, 3000) && that.dones.forEach(function (done) {
|
||||
done.call(form, that.form.formToJson(), []);
|
||||
});
|
||||
});
|
||||
}
|
||||
}).find('[data-form-loaded]').map(function () {
|
||||
$(this).html(this.dataset.formLoaded || this.innerHTML);
|
||||
$(this).removeAttr('data-form-loaded').removeClass('layui-disabled');
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user