Skip to content

Commit 9eb7031

Browse files
committed
rangepicker等时间控件报错(vue3.4以上版本有问题)
1 parent 8540e8d commit 9eb7031

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

src/components/Form/src/BasicForm.vue

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,39 @@
140140
}
141141
//update-end---author:wangshuai ---date:20230410 for:【issues/435】代码生成的日期控件赋默认值报错------------
142142
if (!Array.isArray(defaultValue)) {
143-
//update-begin---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
144-
if(valueFormat){
145-
schema.defaultValue = dateUtil(defaultValue).format(valueFormat);
146-
}else{
147-
schema.defaultValue = dateUtil(defaultValue);
143+
// update-begin--author:liaozhiyang---date:20240326---for:【QQYUN-8696】rangepicker等时间控件报错(vue3.4以上版本有问题)
144+
if (Object.prototype.toString.call(defaultValue) === '[object Date]') {
145+
//update-begin---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
146+
if (valueFormat) {
147+
schema.defaultValue = dateUtil(defaultValue).format(valueFormat);
148+
} else {
149+
schema.defaultValue = dateUtil(defaultValue);
150+
}
151+
//update-end---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
148152
}
149-
//update-end---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
153+
// update-end--author:liaozhiyang---date:20240326---for:【QQYUN-8696】rangepicker等时间控件报错(vue3.4以上版本有问题)
150154
} else {
151-
const def: dayjs.Dayjs[] = [];
155+
// update-begin--author:liaozhiyang---date:20240326---for:【QQYUN-8696】rangepicker等时间控件报错(vue3.4以上版本有问题)
156+
let isAssignment = false;
152157
defaultValue.forEach((item) => {
153-
//update-begin---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
154-
if(valueFormat){
155-
def.push(dateUtil(item).format(valueFormat));
156-
}else{
157-
def.push(dateUtil(item));
158+
if (Object.prototype.toString.call(item) === '[object Date]') {
159+
isAssignment = true;
158160
}
159-
//update-end---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
160161
});
161-
schema.defaultValue = def;
162+
if (isAssignment) {
163+
const def: dayjs.Dayjs[] = [];
164+
defaultValue.forEach((item) => {
165+
//update-begin---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
166+
if (valueFormat) {
167+
def.push(dateUtil(item).format(valueFormat));
168+
} else {
169+
def.push(dateUtil(item));
170+
}
171+
//update-end---author:wangshuai ---date:20221124 for:[issues/215]列表页查询框(日期选择框)设置初始时间,一进入页面时,后台报日期转换类型错误的------------
172+
});
173+
schema.defaultValue = def;
174+
}
175+
// update-end--author:liaozhiyang---date:20240326---for:【QQYUN-8696】rangepicker等时间控件报错(vue3.4以上版本有问题)
162176
}
163177
}
164178
}

0 commit comments

Comments
 (0)