Merge pull request #1138 from sunxiaobin89/main

修复几个小问题以及新增一些功能
pull/1141/head
贤心 2022-10-08 10:36:49 +08:00 committed by GitHub
commit 3f49bc9fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -48,6 +48,9 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
,reload: function(options){ ,reload: function(options){
that.reload.call(that, options); that.reload.call(that, options);
} }
,remove: function () {
that.remove()
}
} }
} }

View File

@ -105,7 +105,7 @@
var elem = lay(options.elem || that.config.elem); var elem = lay(options.elem || that.config.elem);
if(elem.length > 1){ if(elem.length > 1){
lay.each(elem, function(){ lay.each(elem, function(){
laydate.render(lay.extend({}, that.config, lay.options(this),{ laydate.render(lay.extend({}, that.config, {
elem: this elem: this
})); }));
}); });
@ -113,7 +113,7 @@
} }
// 初始化 id 参数 // 初始化 id 参数
options = that.config; options = lay.extend(that.config, lay.options(elem[0])); // 继承节点上的属性
options.id = ('id' in options) ? options.id : that.index; options.id = ('id' in options) ? options.id : that.index;
// 初始化 // 初始化
@ -162,6 +162,7 @@
,zIndex: null //控件层叠顺序 ,zIndex: null //控件层叠顺序
,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发 ,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发
,change: null //日期时间改变后的回调 ,change: null //日期时间改变后的回调
,autoConfirm: true //是否自动确认(日期|年份|月份选择器非range下是否自动确认
}; };
//多语言 //多语言
@ -579,7 +580,7 @@
lay(this).addClass(THIS); lay(this).addClass(THIS);
if (options.position !== 'static' && !options.range) { if (options.position !== 'static' && !options.range && options.autoConfirm) {
if (type === 'date') { if (type === 'date') {
that.choose(lay(elem).find('td.layui-this')) that.choose(lay(elem).find('td.layui-this'))
} else if (type === 'year' || type === 'month') { } else if (type === 'year' || type === 'month') {
@ -1352,7 +1353,7 @@
//若为月选择器,只有当选择月份时才自动关闭; //若为月选择器,只有当选择月份时才自动关闭;
//若为年选择器,选择年份即自动关闭 //若为年选择器,选择年份即自动关闭
//且在范围未开启时 //且在范围未开启时
if(!options.range){ if(!options.range && options.autoConfirm){
if((options.type === 'month' && type === 'month') || (options.type === 'year' && type === 'year')){ if((options.type === 'month' && type === 'month') || (options.type === 'year' && type === 'year')){
that.setValue(that.parse()).remove().done(); that.setValue(that.parse()).remove().done();
} }
@ -1640,7 +1641,7 @@
} else if(options.position === 'static'){ //直接嵌套的选中 } else if(options.position === 'static'){ //直接嵌套的选中
that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调 that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调
} else if(options.type === 'date'){ } else if(options.type === 'date'){
that.setValue(that.parse()).remove().done(); options.autoConfirm ? that.setValue(that.parse()).remove().done() : that.calendar().done(null, 'change');
} else if(options.type === 'datetime'){ } else if(options.type === 'datetime'){
that.calendar().done(null, 'change'); that.calendar().done(null, 'change');
} }

View File

@ -309,6 +309,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
,text: { ,text: {
none: '无数据' none: '无数据'
} }
,cols: []
}; };
// 表格渲染 // 表格渲染
@ -2331,7 +2332,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
var tableIns = table.render(options); var tableIns = table.render(options);
//获取表体数据 //获取表体数据
if (trElem.length && !tableIns.config.url) { if (trElem.length && !settings.data && !tableIns.config.url) {
var tdIndex = 0; var tdIndex = 0;
table.eachCols(tableIns.config.id, function (i3, item3) { table.eachCols(tableIns.config.id, function (i3, item3) {
trElem.each(function(i1){ trElem.each(function(i1){