1.修复 页面多个日期控制时无法独立显示格式问题

2.新增 日期控件增加选定回调功能、增加控制按键自定义功能
3.新增 控制通过扩展属性data-btn、data-callback实现功能自定义
pull/82/head
chenw 6 years ago
parent f48b9ff9b9
commit 49a9b3e015

@ -69,24 +69,49 @@ $(function() {
}
// laydate time-input 时间控件绑定
if ($(".time-input").length > 0) {
layui.use('laydate', function() {
var laydate = layui.laydate;
var times = $(".time-input");
layui.use('laydate', function () {
var com = layui.laydate;
$(".time-input").each(function (index, item) {
var time = $(item);
// 控制控件外观
var type = times.attr("data-type") || 'date';
var type = time.attr("data-type") || 'date';
// 控制回显格式
var format = times.attr("data-format") || 'yyyy-MM-dd';
for (var i = 0; i < times.length; i++) {
var time = times[i];
laydate.render({
elem: time,
var format = time.attr("data-format") || 'yyyy-MM-dd';
// 控制日期控件按钮
var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
// 日期控件选择完成后回调处理
var callback = time.attr("data-callback") || {};
if (buttons) {
if (buttons.indexOf("|") > 0) {
var btnArr = buttons.split("|"), btnLen = btnArr.length;
for (var j = 0; j < btnLen; j++) {
if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
newBtnArr.push(btnArr[j]);
}
}
} else {
if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
newBtnArr.push(buttons);
}
}
} else {
newBtnArr = ['clear', 'now', 'confirm'];
}
com.render({
elem: item,
theme: 'molv',
trigger: 'click',
type: type,
format: format,
done: function(value, date) {}
});
btns: newBtnArr,
done: function (value, data) {
if (typeof window[callback] != 'undefined'
&& window[callback] instanceof Function) {
window[callback](value, data);
}
}
});
});
});
}
// tree 关键字搜索绑定

Loading…
Cancel
Save