Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
7ceecce5
Commit
7ceecce5
authored
Oct 17, 2017
by
wacky6.AriesMBP
Committed by
杨奕
Oct 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
date-picker: fix typo, fix value-format parsing
parent
f0b7debd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
packages/date-picker/src/picker.vue
packages/date-picker/src/picker.vue
+6
-6
packages/date-picker/src/util/index.js
packages/date-picker/src/util/index.js
+4
-0
test/unit/specs/date-picker.spec.js
test/unit/specs/date-picker.spec.js
+12
-4
No files found.
packages/date-picker/src/picker.vue
View file @
7ceecce5
...
...
@@ -69,7 +69,7 @@
<
script
>
import
Vue
from
'
vue
'
;
import
Clickoutside
from
'
element-ui/src/utils/clickoutside
'
;
import
{
formatDate
,
parseDate
,
isDate
,
getWeekNumber
}
from
'
./util
'
;
import
{
formatDate
,
parseDate
,
isDate
,
isDateObject
,
getWeekNumber
}
from
'
./util
'
;
import
Popper
from
'
element-ui/src/utils/vue-popper
'
;
import
Emitter
from
'
element-ui/src/mixins/emitter
'
;
import
Focus
from
'
element-ui/src/mixins/focus
'
;
...
...
@@ -229,23 +229,23 @@ const PLACEMENT_MAP = {
right
:
'
bottom-end
'
};
const
parseAsFormatAndType
=
(
value
,
cu
ts
omFormat
,
type
,
rangeSeparator
=
'
-
'
)
=>
{
const
parseAsFormatAndType
=
(
value
,
cu
st
omFormat
,
type
,
rangeSeparator
=
'
-
'
)
=>
{
if
(
!
value
)
return
null
;
const
parser
=
(
TYPE_VALUE_RESOLVER_MAP
[
type
]
||
TYPE_VALUE_RESOLVER_MAP
[
'
default
'
]
).
parser
;
const
format
=
cu
ts
omFormat
||
DEFAULT_FORMATS
[
type
];
const
format
=
cu
st
omFormat
||
DEFAULT_FORMATS
[
type
];
return
parser
(
value
,
format
,
rangeSeparator
);
};
const
formatAsFormatAndType
=
(
value
,
cu
ts
omFormat
,
type
)
=>
{
const
formatAsFormatAndType
=
(
value
,
cu
st
omFormat
,
type
)
=>
{
if
(
!
value
)
return
null
;
const
formatter
=
(
TYPE_VALUE_RESOLVER_MAP
[
type
]
||
TYPE_VALUE_RESOLVER_MAP
[
'
default
'
]
).
formatter
;
const
format
=
cu
ts
omFormat
||
DEFAULT_FORMATS
[
type
];
const
format
=
cu
st
omFormat
||
DEFAULT_FORMATS
[
type
];
return
formatter
(
value
,
format
);
};
...
...
@@ -421,7 +421,7 @@ export default {
},
parsedValue
()
{
const
isParsed
=
isDate
(
this
.
value
)
||
(
Array
.
isArray
(
this
.
value
)
&&
this
.
value
.
every
(
isDate
));
const
isParsed
=
isDate
Object
(
this
.
value
)
||
(
Array
.
isArray
(
this
.
value
)
&&
this
.
value
.
every
(
isDateObject
));
if
(
this
.
valueFormat
&&
!
isParsed
)
{
return
parseAsFormatAndType
(
this
.
value
,
this
.
valueFormat
,
this
.
type
,
this
.
rangeSeparator
)
||
this
.
value
;
}
else
{
...
...
packages/date-picker/src/util/index.js
View file @
7ceecce5
...
...
@@ -31,6 +31,10 @@ export const isDate = function(date) {
return
true
;
};
export
const
isDateObject
=
function
(
val
)
{
return
val
instanceof
Date
;
};
export
const
formatDate
=
function
(
date
,
format
)
{
date
=
toDate
(
date
);
if
(
!
date
)
return
''
;
...
...
test/unit/specs/date-picker.spec.js
View file @
7ceecce5
...
...
@@ -411,20 +411,28 @@ describe('DatePicker', () => {
ref="compo"
v-model="value"
type="date"
value-format="dd-MM-yyyy" />`
,
format="yyyy-MM-dd"
value-format="dd/MM yyyy" />`
,
data
()
{
return
{
value
:
'
01
-02-
2000
'
value
:
'
01
/02
2000
'
};
}
},
true
);
vm
.
$refs
.
compo
.
$el
.
querySelector
(
'
input
'
).
focus
();
const
input
=
vm
.
$refs
.
compo
.
$el
.
querySelector
(
'
input
'
);
expect
(
input
.
value
).
to
.
equal
(
'
2000-02-01
'
);
expect
(
vm
.
$refs
.
compo
.
parsedValue
).
to
.
be
.
an
.
instanceof
(
Date
);
input
.
focus
();
setTimeout
(
_
=>
{
const
date
=
vm
.
$refs
.
compo
.
picker
.
date
;
expect
(
date
.
getFullYear
()).
to
.
equal
(
2000
);
expect
(
date
.
getMonth
()).
to
.
equal
(
1
);
expect
(
date
.
getDate
()).
to
.
equal
(
1
);
done
();
vm
.
$refs
.
compo
.
picker
.
$el
.
querySelector
(
'
.el-date-table .current
'
).
click
();
setTimeout
(
_
=>
{
expect
(
input
.
value
).
to
.
equal
(
'
2000-02-01
'
);
done
();
},
DELAY
);
},
DELAY
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment