Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
cube-ui
提交
2b87dc7a
C
cube-ui
项目概览
DiDi
/
cube-ui
12 个月 前同步成功
通知
34
Star
9078
Fork
1508
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cube-ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b87dc7a
编写于
11月 29, 2017
作者:
A
AmyFoxFN
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add picker select param selectedText + add date-picker props min, max
上级
f1b57541
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
14 deletion
+49
-14
example/components/date-picker.vue
example/components/date-picker.vue
+38
-9
example/pages/picker.vue
example/pages/picker.vue
+5
-3
src/components/picker/picker.vue
src/components/picker/picker.vue
+6
-2
未找到文件。
example/components/date-picker.vue
浏览文件 @
2b87dc7a
...
...
@@ -16,13 +16,11 @@
let
value
=
polyfill
&&
i
<
10
?
'
0
'
+
i
:
i
arr
.
push
({
text
:
value
,
value
:
value
value
:
i
})
}
return
arr
}
const
year
=
range
(
2010
,
2020
)
const
month
=
range
(
1
,
12
)
const
COMPONENT_NAME
=
'
date-picker
'
const
EVENT_SELECT
=
'
select
'
...
...
@@ -30,22 +28,53 @@
export
default
{
name
:
COMPONENT_NAME
,
props
:
{
min
:
{
type
:
Array
,
default
()
{
return
[
2010
,
2
,
1
]
}
},
max
:
{
type
:
Array
,
default
()
{
return
[
2020
,
2
,
1
]
}
}
},
data
()
{
return
{
tempIndex
:
[
0
,
0
,
0
]
}
},
computed
:
{
dateData
()
{
years
()
{
return
range
(
this
.
min
[
0
],
this
.
max
[
0
])
},
months
()
{
let
minMonth
=
!
this
.
tempIndex
[
0
]
?
this
.
min
[
1
]
:
1
let
maxMonth
=
this
.
tempIndex
[
0
]
===
this
.
years
.
length
-
1
?
this
.
max
[
1
]
:
12
return
range
(
minMonth
,
maxMonth
)
},
days
()
{
const
currentMonth
=
this
.
months
[
this
.
tempIndex
[
1
]].
value
let
day
=
30
if
([
0
,
2
,
4
,
6
,
7
,
9
,
11
].
includes
(
this
.
tempIndex
[
1
]
))
{
if
([
1
,
3
,
5
,
7
,
8
,
10
,
12
].
includes
(
currentMonth
))
{
day
=
31
}
else
{
if
(
this
.
tempIndex
[
1
]
===
1
)
{
if
(
currentMonth
===
2
)
{
day
=
this
.
tempIndex
[
0
]
%
4
?
28
:
29
}
}
return
[
year
,
month
,
range
(
1
,
day
)]
let
minDay
=
!
this
.
tempIndex
[
0
]
&&
!
this
.
tempIndex
[
1
]
?
this
.
min
[
2
]
:
1
let
maxDay
=
this
.
tempIndex
[
0
]
===
this
.
years
.
length
-
1
&&
this
.
tempIndex
[
1
]
===
this
.
months
.
length
-
1
?
this
.
max
[
2
]
:
day
return
range
(
minDay
,
maxDay
)
},
dateData
()
{
return
[
this
.
years
,
this
.
months
,
this
.
days
]
}
},
methods
:
{
...
...
@@ -59,8 +88,8 @@
this
.
tempIndex
.
splice
(
i
,
1
,
newIndex
)
this
.
$refs
.
datePicker
.
setData
(
this
.
dateData
,
this
.
tempIndex
)
},
select
(
selectedVal
,
selectedIndex
)
{
this
.
$emit
(
EVENT_SELECT
,
selectedVal
,
selectedIndex
)
select
(
selectedVal
,
selectedIndex
,
selectedText
)
{
this
.
$emit
(
EVENT_SELECT
,
selectedVal
,
selectedIndex
,
selectedText
)
},
cancel
()
{
this
.
$emit
(
EVENT_CANCEL
)
...
...
example/pages/picker.vue
浏览文件 @
2b87dc7a
...
...
@@ -22,7 +22,7 @@
import
Vue
from
'
vue
'
import
createAPI
from
'
@/modules/create-api
'
createAPI
(
Vue
,
DatePicker
,
[
'
select
'
,
'
cancel
'
],
false
)
createAPI
(
Vue
,
DatePicker
,
[
'
min
'
,
'
max
'
,
'
select
'
,
'
cancel
'
],
false
)
function
range
(
n
,
m
,
polyfill
=
false
)
{
let
arr
=
[]
...
...
@@ -122,6 +122,8 @@
})
this
.
datePicker
=
this
.
$createDatePicker
({
min
:
[
2008
,
8
,
8
],
max
:
[
2024
,
10
,
20
],
onSelect
:
(
selectedVal
,
selectedIndex
)
=>
{
this
.
$createDialog
({
type
:
'
warn
'
,
...
...
@@ -142,10 +144,10 @@
title
:
'
HH:MM:SS
'
,
data
:
[
range
(
0
,
23
,
true
),
range
(
0
,
59
,
true
),
range
(
0
,
59
,
true
)],
selectedIndex
:
[
10
,
20
,
59
],
onSelect
:
(
selectedVal
,
selectedIndex
)
=>
{
onSelect
:
(
selectedVal
,
selectedIndex
,
selectedText
)
=>
{
this
.
$createDialog
({
type
:
'
warn
'
,
content
:
`HH:MM:SS:
${
selected
Val
.
join
(
'
:
'
)}
<br/> selected index:
${
selectedIndex
.
join
(
'
,
'
)}
`
,
content
:
`HH:MM:SS:
${
selected
Text
.
join
(
'
:
'
)}
<br/> selected index:
${
selectedIndex
.
join
(
'
,
'
)}
`
,
icon
:
'
cubeic-alert
'
}).
show
()
},
...
...
src/components/picker/picker.vue
浏览文件 @
2b87dc7a
...
...
@@ -95,24 +95,28 @@
this
.
hide
()
let
changed
=
false
let
pickerSelectedText
=
[]
for
(
let
i
=
0
;
i
<
this
.
pickerData
.
length
;
i
++
)
{
let
index
=
this
.
wheels
[
i
].
getSelectedIndex
()
this
.
pickerSelectedIndex
[
i
]
=
index
let
value
=
null
let
text
=
''
if
(
this
.
pickerData
[
i
].
length
)
{
value
=
this
.
pickerData
[
i
][
index
].
value
text
=
this
.
pickerData
[
i
][
index
].
text
}
if
(
this
.
pickerSelectedVal
[
i
]
!==
value
)
{
changed
=
true
}
this
.
pickerSelectedVal
[
i
]
=
value
pickerSelectedText
[
i
]
=
text
}
this
.
$emit
(
EVENT_SELECT
,
this
.
pickerSelectedVal
,
this
.
pickerSelectedIndex
)
this
.
$emit
(
EVENT_SELECT
,
this
.
pickerSelectedVal
,
this
.
pickerSelectedIndex
,
pickerSelectedText
)
if
(
changed
)
{
this
.
$emit
(
EVENT_VALUE_CHANGE
,
this
.
pickerSelectedVal
,
this
.
pickerSelectedIndex
)
this
.
$emit
(
EVENT_VALUE_CHANGE
,
this
.
pickerSelectedVal
,
this
.
pickerSelectedIndex
,
pickerSelectedText
)
}
},
cancel
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录