Skip to content

Commit

Permalink
fix: 修复日期控件格式化问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhenfei committed Nov 18, 2020
1 parent bb40e63 commit 7ccc77d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/pi-calendar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export default {
// 已选择的时间格式化显示规则
dateFormat: {
type: String,
// 'yyyy-mm-dd'
// 'YYYY-MM-DD'
default: calendar.dateFormat
},
/**
Expand Down
7 changes: 5 additions & 2 deletions components/pi-code-input/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default {
// 自动拉起键盘延时
autoFocusDelay: {
required: false,
type: Boolean,
type: [String, Number],
// 350
default: codeInput.autoFocusDelay
},
Expand Down Expand Up @@ -118,6 +118,9 @@ export default {
getLength() {
return parseInt(this.length, 10)
},
getAutoFocusDelay() {
return parseInt(this.autoFocusDelay, 10)
},
arrCode: function() {
return this.val ? this.val.split('') : []
},
Expand All @@ -129,7 +132,7 @@ export default {
if (this.autoFocus) {
setTimeout(() => {
this.focus = true
}, this.autoFocusDelay)
}, this.getAutoFocusDelay)
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion config/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
rangeBg: 'rgba(254, 106, 0, 0.1)', // 范围内日期背景色,默认('rgba(254, 106, 0, 0.1)')
startText: '开始', // type=range时生效,起始日期自定义文案,默认('开始')
endText: '结束', // type=range时生效,结束日期自定义文案,默认('结束')
dateFormat: 'yyyy-mm-dd', // 已选择的时间格式化显示规则,默认('yyyy-mm-dd')
dateFormat: 'YYYY-MM-DD', // 已选择的时间格式化显示规则,默认('YYYY-MM-DD')
/**
* 弹窗的配置,默认选项请参照popup
* -------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/datePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
endYear, // 结束年份(默认当前年份)
field: 'day', // 选择器的粒度 year、month、day、hour、minute、second
defaultValue: '', // 日期默认值
format: 'yyyy-mm-dd', // 返回的日期格式
format: 'YYYY-MM-DD', // 返回的日期格式
toolbarPosition: 'bottom', // 操作条(确定,取消按钮)位置,可选值 'top', 'bottom'
showTitle: false, // 是否显示title(默认:true)
title: '日期选择', // 标题(默认:日期选择)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sadais-piui",
"version": "1.0.21",
"version": "1.0.23",
"description": "piui组件库",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions tools/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const parseDate = (value = new Date(), weekPrefix = '星期') => {
second: date.getSeconds(), // 秒
time: date,
timestamp: date.getTime(), // 时间戳
format(fmt = 'yyyy-mm-dd HH:MM:ss') {
format(fmt = 'YYYY-MM-DD hh:mm:ss') {
return formatDate(date, fmt)
}
}
Expand All @@ -40,15 +40,15 @@ export const parseDate = (value = new Date(), weekPrefix = '星期') => {
* @param {*} value Date 日期
* @param {*} fmt 格式化规则
*/
export const formatDate = (value = new Date(), fmt = 'yyyy-mm-dd') => {
export const formatDate = (value = new Date(), fmt = 'YYYY-MM-DD') => {
let date = parseDate(value)
let ret
let opt = {
'y+|Y+': date.year, // 年
'm+': date.month, // 月
'M+': date.month, // 月
'd+|D+': date.date, // 日
'h+|H+': date.hour, // 时
'M+': date.minute, // 分
'm+': date.minute, // 分
's+': date.second // 秒
}
for (let k in opt) {
Expand Down

0 comments on commit 7ccc77d

Please sign in to comment.