ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.1k stars 14.64k forks source link

[Bug Report] el-date-picker[type=week]: `value-format` invalidation of `format` #8783

Open bowencool opened 6 years ago

bowencool commented 6 years ago

Element UI version

2.0.7

OS/Browsers version

windows10 chrome63.0.3239.84(正式版本) (64 位)

Vue version

2.5.2

Reproduction Link

https://jsfiddle.net/bowencool/ndkdwyka/1/

Steps to reproduce

见链接

What is Expected?

正常展示就行

What is actually happening?

不能正常展示数据

element-bot commented 6 years ago

Translation of this issue:

Element UI version

2.0.7

OS/Browsers version

Windows10 chrome63.0.3239.84 (official version) (64 bit)

Vue version

2.5.2

Reproduction Link

https://jsfiddle.net/bowencool/ndkdwyka/1/

Steps to reproduce

See links

What is Expected?

Normal display is all right

What is actually happening?

No normal display of data

Leopoldthecoder commented 6 years ago

@wacky6 Hi, could you take a look at this? Thanks.

wacky6 commented 6 years ago

Fecha does not support parsing / formatting of week. I guess element need to hack it somehow? Modify week's parser might solve the problem.

I might consider removing week in value-format, since it can not accurately indicate a time point (depends on the interpretation of start-of-week, etc).

d--j commented 6 years ago

I might consider removing week in value-format, since it can not accurately indicate a time point (depends on the interpretation of start-of-week, etc).

IMHO it is a valid value format. You are using ISO8601 week numbers and they are always starting with Monday.

https://github.com/ElemeFE/element/blob/af46f968ab8f56ddb87932eab35993782c4d5b2f/packages/date-picker/src/util/index.js#L97-L107


Anyways, the error (vue.js:1719 TypeError: e.getTime is not a function) also happens when you do not use WW in the value-format. E.g. in this fiddle I changed the value-format to yyyy-MM-dd and the error happens, too.

If you have a el-date-picker[type=week] and also set the value-format this error occurs. Looks like el-date-picker[type=week] cannot handle anything besides a JavaScript Date object as value.

This line https://github.com/ElemeFE/element/blob/aaf7a87848d33d3f07310f2865e4d3d14019c6f0/packages/date-picker/src/picker.vue#L167 should probably be

      let week = getWeekNumber(isDateObject(value) ? value : parseDate(value, format));
wacky6 commented 6 years ago

Interesting.

Can you make a PR for it? I recommend integrate week format into our custom fecha (/src/utils/date.js)? So date-picker can treat week number as normal dates. (Thus removing custom week picker logic)

wacky6 commented 6 years ago

@Leopoldthecoder What's the reasoning of current implementation? Will this be a breaking change?

Make fecha support WW/W format, so element can drop custom week picker logic, see TYPE_VALUE_RESOLVER_MAP's week

joachimVT commented 6 years ago

Any updates on this issue ?

bill-mark commented 6 years ago

when i set {type="week",value-format="yyyy-W"} ,will meet the same bug! " Error in render: "TypeError: src.getTime is not a function"" please help

wacky6 commented 6 years ago

Right now, W is not supported in value-format. Use MM/dd instead. The definition of W / WW format needs consensus. ISO-8601 week date may be considered in the future.

xch1029 commented 6 years ago

呜呜呜,终于知道为什么了,花了我半天时间,这磨人的week

kenziD commented 5 years ago

why this issue not solved after one year??

dengpan0513 commented 5 years ago

el-date-picker 像下面这样设置时,输入框的格式一直不正确

<el-date-picker
v-model="value1"
      type="week"
      format="yyyy 第 W 周"
      value-format="yyyy-W"
      placeholder="选择周">
</el-date-picker>

预览链接

JasonBoy commented 4 years ago

same problem here

marissagroves commented 4 years ago

Hi, can someone add this feature? image value-format still not support WW...

marissagroves commented 4 years ago

I use the computed attribute to parse week. But it's not very convinient. computed: { week() { return moment(this.date.W).format('YYYY [wk]WW'); } }

joshmacaraig commented 3 years ago

Still no update? :(

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ginkosen commented 8 months ago

Still no update? :(