From 8e3f3890e93d097df4be744648b9ac404d20a558 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 23 四月 2026 17:58:50 +0800
Subject: [PATCH] 2026.4.23
---
miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker.js | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker.js b/miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker.js
index ac86150..321a391 100644
--- a/miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker.js
+++ b/miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker.js
@@ -1 +1 @@
-var _a,_b;import{__decorate}from"tslib";import config from"../common/config";import{SuperComponent,wxComponent}from"../common/src/index";import props from"./props";import dayjsLocaleMap from"./locale/dayjs";const dayjs=require("dayjs"),localeData=require("dayjs/plugin/localeData");dayjs.extend(localeData),dayjs.locale("zh-cn");const defaultLocale=(null===(_a=dayjsLocaleMap[dayjs.locale()])||void 0===_a?void 0:_a.key)||(null===(_b=dayjsLocaleMap.default)||void 0===_b?void 0:_b.key),{prefix:prefix}=config,name=`${prefix}-date-time-picker`;var ModeItem;!function(e){e.YEAR="year",e.MONTH="month",e.DATE="date",e.HOUR="hour",e.MINUTE="minute",e.SECOND="second"}(ModeItem||(ModeItem={}));const DATE_MODES=["year","month","date"],TIME_MODES=["hour","minute","second"],FULL_MODES=[...DATE_MODES,...TIME_MODES];let DateTimePicker=class extends SuperComponent{constructor(){super(...arguments),this.properties=props,this.externalClasses=[`${prefix}-class`,`${prefix}-class-confirm`,`${prefix}-class-cancel`,`${prefix}-class-title`],this.options={multipleSlots:!0},this.observers={"start, end, value":function(){this.updateColumns()},customLocale(e){e&&dayjsLocaleMap[e].key&&this.setData({locale:dayjsLocaleMap[e].i18n,dayjsLocale:dayjsLocaleMap[e].key})},mode(e){const t=this.getFullModeArray(e);this.setData({fullModes:t}),this.updateColumns()}},this.date=null,this.data={prefix:prefix,classPrefix:name,columns:[],columnsValue:[],fullModes:[],locale:dayjsLocaleMap[defaultLocale].i18n,dayjsLocale:dayjsLocaleMap[defaultLocale].key},this.controlledProps=[{key:"value",event:"change"}],this.methods={updateColumns(){this.date=this.getParseDate();const{columns:e,columnsValue:t}=this.getValueCols();this.setData({columns:e,columnsValue:t})},getDaysOfWeekInMonth(e,t){var a;const{locale:s,steps:o,dayjsLocale:n}=this.data,i=e.startOf("month"),l=this.getOptionEdge("min",t),r=this.getOptionEdge("max",t),u=null!==(a=null==o?void 0:o[t])&&void 0!==a?a:1,d=[];for(let e=l;e<=r;e+=u){const t=i.date(e).locale(n).format("ddd");d.push({value:`${e}`,label:`${e}${s.date||""} ${t}`})}return d},getParseDate(){const{value:e,defaultValue:t}=this.properties,a=this.getMinDate();let s=e||t;if(this.isTimeMode()){const e=dayjs(a).format("YYYY-MM-DD");s=dayjs(`${e} ${s}`)}const o=dayjs(s||a);return o.isValid()?o:a},normalize:(e,t)=>e&&dayjs(e).isValid()?dayjs(e):t,getMinDate(){return this.normalize(this.properties.start,dayjs().subtract(10,"year"))},getMaxDate(){return this.normalize(this.properties.end,dayjs().add(10,"year"))},getDateRect(e="default"){const t=this[{min:"getMinDate",max:"getMaxDate",default:"getDate"}[e]]();return["year","month","date","hour","minute","second"].map(e=>{var a;return null===(a=t[e])||void 0===a?void 0:a.call(t)})},getDate(){return this.clipDate((null==this?void 0:this.date)||this.getMinDate())},clipDate(e){const t=this.getMinDate(),a=this.getMaxDate();return dayjs(Math.min(Math.max(t.valueOf(),e.valueOf()),a.valueOf()))},setYear(e,t){const a=e.date(),s=e.year(t).daysInMonth();return e.date(Math.min(a.valueOf(),s.valueOf())).year(t)},setMonth(e,t){const a=e.date(),s=e.month(t).daysInMonth();return e.date(Math.min(a.valueOf(),s.valueOf())).month(t)},getColumnOptions(){const{fullModes:e,filter:t}=this.data,a=[];return null==e||e.forEach(e=>{const s=this.getOptionByType(e);"function"==typeof t?a.push(t(e,s)):a.push(s)}),a},getOptionByType(e){var t;const{locale:a,steps:s,showWeek:o}=this.data,n=[],i=this.getOptionEdge("min",e),l=this.getOptionEdge("max",e),r=null!==(t=null==s?void 0:s[e])&&void 0!==t?t:1,u=dayjs().locale(this.data.dayjsLocale).localeData().monthsShort();if("date"===e&&o)return this.getDaysOfWeekInMonth(this.date,e);for(let t=i;t<=l;t+=r)n.push({value:`${t}`,label:"month"===e?u[t]:`${t+a[e]}`});return n},getYearOptions(e){const{locale:t}=this.data,{minDateYear:a,maxDateYear:s}=e,o=[];for(let e=a;e<=s;e+=1)o.push({value:`${e}`,label:`${e+t.year}`});return o},getOptionEdge(e,t){const a=this.getDateRect(),s=this.getDateRect(e),o={month:[0,11],date:[1,this.getDate().daysInMonth()],hour:[0,23],minute:[0,59],second:[0,59]},n=["year","month","date","hour","minute","second"];for(let i=0,l=a.length;i<l;i+=1){if(n[i]===t)return s[i];if(s[i]!==a[i])return o[t]["min"===e?0:1]}return o[t]["min"===e?0:1]},getMonthOptions(){const e=[],t=this.getOptionEdge("min","month"),a=this.getOptionEdge("max","month"),s=dayjs.monthsShort();for(let o=t;o<=a;o+=1)e.push({value:`${o}`,label:s[o]});return e},getDayOptions(){const{locale:e}=this.data,t=[],a=this.getOptionEdge("min","date"),s=this.getOptionEdge("max","date");for(let o=a;o<=s;o+=1)t.push({value:`${o}`,label:`${o+e.day}`});return t},getHourOptions(){const{locale:e}=this.data,t=[],a=this.getOptionEdge("min","hour"),s=this.getOptionEdge("max","hour");for(let o=a;o<=s;o+=1)t.push({value:`${o}`,label:`${o+e.hour}`});return t},getMinuteOptions(){const{locale:e}=this.data,t=[],a=this.getOptionEdge("min","minute"),s=this.getOptionEdge("max","minute");for(let o=a;o<=s;o+=1)t.push({value:`${o}`,label:`${o+e.minute}`});return t},getValueCols(){return{columns:this.getColumnOptions(),columnsValue:this.getColumnsValue()}},getColumnsValue(){const{fullModes:e}=this.data,t=this.getDate(),a=[];return null==e||e.forEach(e=>{a.push(`${t[e]()}`)}),a},getNewDate(e,t){let a=this.getDate();switch(t){case ModeItem.YEAR:a=this.setYear(a,e);break;case ModeItem.MONTH:a=this.setMonth(a,e);break;case ModeItem.DATE:a=a.date(e);break;case ModeItem.HOUR:a=a.hour(e);break;case ModeItem.MINUTE:a=a.minute(e);break;case ModeItem.SECOND:a=a.second(e)}return this.clipDate(a)},onColumnChange(e){const{value:t,column:a}=null==e?void 0:e.detail,{fullModes:s,format:o}=this.data,n=null==t?void 0:t[a],i=null==s?void 0:s[a],l=this.getNewDate(parseInt(n,10),i);this.date=l;const{columns:r,columnsValue:u}=this.getValueCols();this.setData({columns:r,columnsValue:u});const d=this.getDate(),h=o?d.format(o):d.valueOf();this.triggerEvent("pick",{value:h})},onConfirm(){const{format:e}=this.properties,t=this.getDate(),a=e?t.format(e):t.valueOf();this._trigger("change",{value:a}),this.triggerEvent("confirm",{value:a}),this.resetColumns()},onCancel(){this.resetColumns(),this.triggerEvent("cancel")},onVisibleChange(e){e.detail.visible||this.resetColumns()},onClose(e){const{trigger:t}=e.detail;this.triggerEvent("close",{trigger:t})},resetColumns(){const e=this.getParseDate();this.date=e;const{columns:t,columnsValue:a}=this.getValueCols();this.setData({columns:t,columnsValue:a})}}}getFullModeArray(e){if("string"==typeof e||e instanceof String)return this.getFullModeByModeString(e,FULL_MODES);if(Array.isArray(e)){if(1===(null==e?void 0:e.length))return this.getFullModeByModeString(e[0],FULL_MODES);if(2===(null==e?void 0:e.length)){return[...this.getFullModeByModeString(e[0],DATE_MODES),...this.getFullModeByModeString(e[1],TIME_MODES)]}}}getFullModeByModeString(e,t){if(!e)return[];const a=null==t?void 0:t.findIndex(t=>e===t);return null==t?void 0:t.slice(0,a+1)}isTimeMode(){const{fullModes:e}=this.data;return e[0]===ModeItem.HOUR}};DateTimePicker=__decorate([wxComponent()],DateTimePicker);export default DateTimePicker;
\ No newline at end of file
+import{__decorate}from"tslib";import config from"../common/config";import{SuperComponent,wxComponent}from"../common/src/index";import usingConfig from"../mixins/using-config";import props from"./props";const dayjs=require("dayjs"),localeData=require("dayjs/plugin/localeData");dayjs.extend(localeData),dayjs.locale("zh-cn");const{prefix:prefix}=config,componentName="date-time-picker";var ModeItem;!function(t){t.YEAR="year",t.MONTH="month",t.DATE="date",t.HOUR="hour",t.MINUTE="minute",t.SECOND="second"}(ModeItem||(ModeItem={}));const DATE_MODES=["year","month","date"],TIME_MODES=["hour","minute","second"],FULL_MODES=[...DATE_MODES,...TIME_MODES];let DateTimePicker=class extends SuperComponent{constructor(){super(...arguments),this.behaviors=[usingConfig({componentName:componentName})],this.properties=props,this.externalClasses=[`${prefix}-class`,`${prefix}-class-confirm`,`${prefix}-class-cancel`,`${prefix}-class-title`],this.options={multipleSlots:!0},this.observers={"start, end, value, globalConfig"(){this.updateColumns()},mode(t){const e=this.getFullModeArray(t);this.setData({fullModes:e}),this.updateColumns()}},this.date=null,this.data={prefix:prefix,classPrefix:`${prefix}-${componentName}`,columns:[],columnsValue:[],fullModes:[]},this.controlledProps=[{key:"value",event:"change"}],this.methods={updateColumns(){this.date=this.getParseDate();const{columns:t,columnsValue:e}=this.getValueCols();this.setData({columns:t,columnsValue:e})},getDaysOfWeekInMonth(t,e){var o;const{globalConfig:s,steps:a}=this.data,n=t.startOf("month"),i=this.getOptionEdge("min",e),l=this.getOptionEdge("max",e),r=null!==(o=null==a?void 0:a[e])&&void 0!==o?o:1,u=[],d=(null==s?void 0:s.dayjsLocale)||"zh-cn";for(let t=i;t<=l;t+=r){const e=n.date(t).locale(d).format("ddd");u.push({value:`${t}`,label:`${t}${null==s?void 0:s.dateLabel} ${e}`})}return u},getParseDate(){const{value:t,defaultValue:e}=this.properties,o=this.getMinDate();let s=t||e;if(this.isTimeMode()){const t=dayjs(o).format("YYYY-MM-DD");s=dayjs(`${t} ${s}`)}let a=dayjs(s||o);if(!a.isValid()&&"string"==typeof s){const t=s.match(/(\d{4}[-/]\d{1,2}[-/]\d{1,2}(\s+\d{1,2}:\d{1,2}(:\d{1,2})?)?)/);t&&(a=dayjs(t[1]))}return a.isValid()?a:o},normalize:(t,e)=>t&&dayjs(t).isValid()?dayjs(t):e,getMinDate(){return this.normalize(this.properties.start,dayjs().subtract(10,"year"))},getMaxDate(){return this.normalize(this.properties.end,dayjs().add(10,"year"))},getDateRect(t="default"){const e=this[{min:"getMinDate",max:"getMaxDate",default:"getDate"}[t]]();return["year","month","date","hour","minute","second"].map(t=>{var o;return null===(o=e[t])||void 0===o?void 0:o.call(e)})},getDate(){return this.clipDate((null==this?void 0:this.date)||this.getMinDate())},clipDate(t){const e=this.getMinDate(),o=this.getMaxDate();return dayjs(Math.min(Math.max(e.valueOf(),t.valueOf()),o.valueOf()))},setYear(t,e){const o=t.date(),s=t.year(e).daysInMonth();return t.date(Math.min(o.valueOf(),s.valueOf())).year(e)},setMonth(t,e){const o=t.date(),s=t.month(e).daysInMonth();return t.date(Math.min(o.valueOf(),s.valueOf())).month(e)},getColumnOptions(){const{fullModes:t,filter:e}=this.data,o=[];return null==t||t.forEach(t=>{const s=this.getOptionByType(t);"function"==typeof e?o.push(e(t,s)):o.push(s)}),o},getOptionByType(t){var e,o;const{globalConfig:s,steps:a,showWeek:n}=this.data,i=[],l=this.getOptionEdge("min",t),r=this.getOptionEdge("max",t),u=null!==(e=null==a?void 0:a[t])&&void 0!==e?e:1;if("date"===t&&n)return this.getDaysOfWeekInMonth(this.date,t);for(let e=l;e<=r;e+=u)i.push({value:`${e}`,label:"month"===t?null===(o=s.months)||void 0===o?void 0:o[e]:`${e}${s[`${t}Label`]}`});return i},getYearOptions(t){const{globalConfig:e}=this.data,{minDateYear:o,maxDateYear:s}=t,a=[];for(let t=o;t<=s;t+=1)a.push({value:`${t}`,label:`${t}${e.yearLabel}`});return a},getOptionEdge(t,e){const o=this.getDateRect(),s=this.getDateRect(t),a={month:[0,11],date:[1,this.getDate().daysInMonth()],hour:[0,23],minute:[0,59],second:[0,59]},n=["year","month","date","hour","minute","second"];for(let i=0,l=o.length;i<l;i+=1){if(n[i]===e)return s[i];if(s[i]!==o[i])return a[e]["min"===t?0:1]}return a[e]["min"===t?0:1]},getMonthOptions(){const{globalConfig:t}=this.data,e=[],o=this.getOptionEdge("min","month"),s=this.getOptionEdge("max","month");for(let a=o;a<=s;a+=1)e.push({value:`${a}`,label:t.months[a]});return e},getDayOptions(){const{globalConfig:t}=this.data,e=[],o=this.getOptionEdge("min","date"),s=this.getOptionEdge("max","date");for(let a=o;a<=s;a+=1)e.push({value:`${a}`,label:`${a}${t.dateLabel}`});return e},getHourOptions(){const{globalConfig:t}=this.data,e=[],o=this.getOptionEdge("min","hour"),s=this.getOptionEdge("max","hour");for(let a=o;a<=s;a+=1)e.push({value:`${a}`,label:`${a}${t.hourLabel}`});return e},getMinuteOptions(){const{globalConfig:t}=this.data,e=[],o=this.getOptionEdge("min","minute"),s=this.getOptionEdge("max","minute");for(let a=o;a<=s;a+=1)e.push({value:`${a}`,label:`${a}${t.minuteLabel}`});return e},getValueCols(){return{columns:this.getColumnOptions(),columnsValue:this.getColumnsValue()}},getColumnsValue(){const{fullModes:t}=this.data,e=this.getDate(),o=[];return null==t||t.forEach(t=>{o.push(`${e[t]()}`)}),o},getNewDate(t,e){let o=this.getDate();switch(e){case ModeItem.YEAR:o=this.setYear(o,t);break;case ModeItem.MONTH:o=this.setMonth(o,t);break;case ModeItem.DATE:o=o.date(t);break;case ModeItem.HOUR:o=o.hour(t);break;case ModeItem.MINUTE:o=o.minute(t);break;case ModeItem.SECOND:o=o.second(t)}return this.clipDate(o)},onColumnChange(t){const{value:e,column:o}=null==t?void 0:t.detail,{fullModes:s,format:a}=this.data,n=null==e?void 0:e[o],i=null==s?void 0:s[o],l=this.getNewDate(parseInt(n,10),i);this.date=l;const{columns:r,columnsValue:u}=this.getValueCols();this.setData({columns:r,columnsValue:u});const d=this.getDate(),h=a?d.format(a):d.valueOf();this.triggerEvent("pick",{value:h})},onConfirm(){const{format:t}=this.properties,e=this.getDate(),o=t?e.format(t):e.valueOf();this._trigger("change",{value:o}),this.triggerEvent("confirm",{value:o}),this.resetColumns()},onCancel(){this.resetColumns(),this.triggerEvent("cancel")},onVisibleChange(t){t.detail.visible||this.resetColumns()},onClose(t){const{trigger:e}=t.detail;this.triggerEvent("close",{trigger:e})},resetColumns(){const t=this.getParseDate();this.date=t;const{columns:e,columnsValue:o}=this.getValueCols();this.setData({columns:e,columnsValue:o})}}}getFullModeArray(t){if("string"==typeof t||t instanceof String)return this.getFullModeByModeString(t,FULL_MODES);if(Array.isArray(t)){if(1===(null==t?void 0:t.length))return this.getFullModeByModeString(t[0],FULL_MODES);if(2===(null==t?void 0:t.length)){return[...this.getFullModeByModeString(t[0],DATE_MODES),...this.getFullModeByModeString(t[1],TIME_MODES)]}}}getFullModeByModeString(t,e){if(!t)return[];const o=null==e?void 0:e.findIndex(e=>t===e);return null==e?void 0:e.slice(0,o+1)}isTimeMode(){const{fullModes:t}=this.data;return t[0]===ModeItem.HOUR}};DateTimePicker=__decorate([wxComponent()],DateTimePicker);export default DateTimePicker;
\ No newline at end of file
--
Gitblit v1.9.3