Browse Source

fix(laydate): 增加类型为date或者datetime时点击年列表换到月选择器功能 (#2235)

pull/2284/head
地亚尔-IT 1 month ago committed by GitHub
parent
commit
e7d4ea634d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      src/modules/laydate.js

13
src/modules/laydate.js

@ -514,9 +514,9 @@
}(), function(){ //年月选择 }(), function(){ //年月选择
var elem = lay.elem('div', { var elem = lay.elem('div', {
"class": 'laydate-set-ym' "class": 'laydate-set-ym'
}), spanY = lay.elem('span'), spanM = lay.elem('span'); });
elem.appendChild(spanY); elem.appendChild(lay.elem('span'));
elem.appendChild(spanM); elem.appendChild(lay.elem('span'));
return elem; return elem;
}(), function(){ //下一月 }(), function(){ //下一月
var elem = lay.elem('i', { var elem = lay.elem('i', {
@ -1788,13 +1788,14 @@
} }
//当为年选择器或者年月选择器 //当为年选择器或者年月选择器
var isYearOrMonth = options.type === 'year' || options.type === 'month'; var isYearOrMonth = ['year', 'month'].indexOf(options.type) !== -1;
if(isYearOrMonth){ var isChangeMonth = type === 'year' && ['date', 'datetime'].indexOf(options.type) !== -1;
if (isYearOrMonth || isChangeMonth) {
lay(ul).find('.'+ THIS).removeClass(THIS); lay(ul).find('.'+ THIS).removeClass(THIS);
lay(this).addClass(THIS); lay(this).addClass(THIS);
//如果为年月选择器,点击了年列表,则切换到月选择器 //如果为年月选择器,点击了年列表,则切换到月选择器
if(options.type === 'month' && type === 'year'){ if ((options.type === 'month' && type === 'year') || isChangeMonth) {
that.listYM[index][0] = ym; that.listYM[index][0] = ym;
isAlone && ((index ? that.endDate : dateTime).year = ym); isAlone && ((index ? that.endDate : dateTime).year = ym);
that.list('month', index); that.list('month', index);

Loading…
Cancel
Save