hookehuyr

临时处理日期选择控件format问题

...@@ -102,6 +102,25 @@ VantComponent({ ...@@ -102,6 +102,25 @@ VantComponent({
102 if (defaultFormatter) { 102 if (defaultFormatter) {
103 formatter = defaultFormatter; 103 formatter = defaultFormatter;
104 } 104 }
105 + // 默认写死配置
106 + formatter = (type, value) => {
107 + if (type === 'year') {
108 + return `${value}年`;
109 + }
110 + if (type === 'month') {
111 + return `${value}月`;
112 + }
113 + if (type === 'day') {
114 + return `${value}日`;
115 + }
116 + if (type === 'hour') {
117 + return `${value}时`;
118 + }
119 + if (type === 'minute') {
120 + return `${value}分`;
121 + }
122 + return value;
123 + }
105 const results = this.getOriginColumns().map((column) => ({ 124 const results = this.getOriginColumns().map((column) => ({
106 values: column.values.map((value) => formatter(column.type, value)), 125 values: column.values.map((value) => formatter(column.type, value)),
107 })); 126 }));
...@@ -266,7 +285,26 @@ VantComponent({ ...@@ -266,7 +285,26 @@ VantComponent({
266 updateColumnValue(value) { 285 updateColumnValue(value) {
267 let values = []; 286 let values = [];
268 const { type } = this.data; 287 const { type } = this.data;
269 - const formatter = this.data.formatter || defaultFormatter; 288 + let formatter = this.data.formatter || defaultFormatter;
289 + // 默认写死配置
290 + formatter = (type, value) => {
291 + if (type === 'year') {
292 + return `${value}年`;
293 + }
294 + if (type === 'month') {
295 + return `${value}月`;
296 + }
297 + if (type === 'day') {
298 + return `${value}日`;
299 + }
300 + if (type === 'hour') {
301 + return `${value}时`;
302 + }
303 + if (type === 'minute') {
304 + return `${value}分`;
305 + }
306 + return value;
307 + }
270 const picker = this.getPicker(); 308 const picker = this.getPicker();
271 if (type === 'time') { 309 if (type === 'time') {
272 const pair = value.split(':'); 310 const pair = value.split(':');
......