修复 laydate 开启 `rangeLinked` 属性后,done 函数第二个参数未能正确返回开始日期的问题

pull/1368/head
贤心 2023-09-11 11:23:04 +08:00
parent 9a6b85f1a2
commit 4d9365e4f1
1 changed files with 26 additions and 22 deletions

View File

@ -1041,6 +1041,7 @@
that.hint('value ' + lang.invalidDate + lang.formatError[1]); that.hint('value ' + lang.invalidDate + lang.formatError[1]);
} }
// 初始赋值 startDate,endState
that.startDate = that.startDate || value && lay.extend({}, options.dateTime); // 有默认值才初始化startDate that.startDate = that.startDate || value && lay.extend({}, options.dateTime); // 有默认值才初始化startDate
that.autoCalendarModel.auto && that.autoCalendarModel(); that.autoCalendarModel.auto && that.autoCalendarModel();
that.endState = !options.range || !that.rangeLinked || !!(that.startDate && that.endDate); // 初始化选中范围状态 that.endState = !options.range || !that.rangeLinked || !!(that.startDate && that.endDate); // 初始化选中范围状态
@ -1586,16 +1587,17 @@
// 转义为规定格式的日期字符 // 转义为规定格式的日期字符
Class.prototype.parse = function(state, date) { Class.prototype.parse = function(state, date) {
var that = this var that = this;
,options = that.config var options = that.config;
,dateTime = date || (state == 'end' var startDate = (that.rangeLinked ? that.startDate : options.dateTime)
? lay.extend({}, that.endDate, that.endTime) var dateTime = date || (
: ( state == 'end' ? lay.extend({}, that.endDate, that.endTime) : (
options.range options.range
? lay.extend({}, that.rangeLinked ? that.startDate : options.dateTime, that.startTime) ? lay.extend({}, startDate || options.dateTime, that.startTime)
: options.dateTime) : options.dateTime
) )
,format = laydate.parse(dateTime, that.format, 1); );
var format = laydate.parse(dateTime, that.format, 1);
// 返回日期范围字符 // 返回日期范围字符
if (options.range && state === undefined) { if (options.range && state === undefined) {
@ -1758,10 +1760,12 @@
// 执行 done/change 回调 // 执行 done/change 回调
Class.prototype.done = function(param, type){ Class.prototype.done = function(param, type){
var that = this var that = this;
,options = that.config var options = that.config;
,start = lay.extend({}, lay.extend(options.dateTime, that.startTime)) var start = lay.extend({},
,end = lay.extend({}, lay.extend(that.endDate, that.endTime)) lay.extend(that.rangeLinked ? that.startDate : options.dateTime, that.startTime)
);
var end = lay.extend({}, lay.extend(that.endDate, that.endTime));
lay.each([start, end], function(i, item){ lay.each([start, end], function(i, item){
if(!('month' in item)) return; if(!('month' in item)) return;