Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
cube-ui
提交
5bed5252
C
cube-ui
项目概览
DiDi
/
cube-ui
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
5bed5252
编写于
3月 24, 2018
作者:
A
Amy
提交者:
doly mood
3月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
<add>: pickerMixin (#133)
上级
d747db5a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
125 deletion
+69
-125
src/common/mixins/picker.js
src/common/mixins/picker.js
+61
-0
src/components/cascade-picker/cascade-picker.vue
src/components/cascade-picker/cascade-picker.vue
+6
-65
src/components/picker/picker.vue
src/components/picker/picker.vue
+2
-60
未找到文件。
src/common/mixins/picker.js
0 → 100644
浏览文件 @
5bed5252
const
DEFAULT_KEYS
=
{
value
:
'
value
'
,
text
:
'
text
'
}
export
default
{
props
:
{
data
:
{
type
:
Array
,
default
()
{
return
[]
}
},
selectedIndex
:
{
type
:
Array
,
default
()
{
return
[]
}
},
title
:
{
type
:
String
},
cancelTxt
:
{
type
:
String
,
default
:
'
取消
'
},
confirmTxt
:
{
type
:
String
,
default
:
'
确定
'
},
swipeTime
:
{
type
:
Number
,
default
:
2500
},
alias
:
{
type
:
Object
,
default
()
{
return
{}
}
},
zIndex
:
{
type
:
Number
}
},
computed
:
{
valueKey
()
{
return
this
.
alias
.
value
||
DEFAULT_KEYS
.
value
},
textKey
()
{
return
this
.
alias
.
text
||
DEFAULT_KEYS
.
text
}
},
watch
:
{
data
(
newVal
)
{
this
.
setData
(
newVal
,
this
.
selectedIndex
)
},
selectedIndex
(
newVal
)
{
this
.
setData
(
this
.
data
,
newVal
)
}
}
}
src/components/cascade-picker/cascade-picker.vue
浏览文件 @
5bed5252
...
...
@@ -16,59 +16,16 @@
<
script
type=
"text/ecmascript-6"
>
import
CubePicker
from
'
../picker/picker.vue
'
import
apiMixin
from
'
../../common/mixins/api
'
import
pickerMixin
from
'
../../common/mixins/picker
'
const
COMPONENT_NAME
=
'
cube-cascade-picker
'
const
EVENT_SELECT
=
'
select
'
const
EVENT_CANCEL
=
'
cancel
'
const
EVENT_CHANGE
=
'
change
'
const
DEFAULT_KEYS
=
{
value
:
'
value
'
,
text
:
'
text
'
}
export
default
{
name
:
COMPONENT_NAME
,
mixins
:
[
apiMixin
],
props
:
{
title
:
{
type
:
String
,
default
:
'
Cascade Picker
'
},
data
:
{
type
:
Array
,
default
()
{
return
[]
}
},
selectedIndex
:
{
type
:
Array
,
default
()
{
return
[]
}
},
cancelTxt
:
{
type
:
String
,
default
:
'
取消
'
},
confirmTxt
:
{
type
:
String
,
default
:
'
确定
'
},
swipeTime
:
{
type
:
Number
,
default
:
2500
},
alias
:
{
type
:
Object
,
default
()
{
return
{}
}
},
zIndex
:
{
type
:
Number
}
},
mixins
:
[
apiMixin
,
pickerMixin
],
data
()
{
return
{
cascadeData
:
this
.
data
.
slice
(),
...
...
@@ -76,24 +33,8 @@
pickerData
:
[]
}
},
computed
:
{
valueKey
()
{
return
this
.
alias
.
value
||
DEFAULT_KEYS
.
value
},
textKey
()
{
return
this
.
alias
.
text
||
DEFAULT_KEYS
.
text
}
},
created
()
{
this
.
updatePickerData
()
},
watch
:
{
data
(
newVal
)
{
this
.
setData
(
newVal
,
this
.
selectedIndex
)
},
selectedIndex
(
newVal
)
{
this
.
setData
(
this
.
data
,
newVal
)
}
this
.
_updatePickerData
()
},
methods
:
{
show
()
{
...
...
@@ -105,7 +46,7 @@
setData
(
data
,
selectedIndex
=
[])
{
this
.
cascadeData
=
data
this
.
pickerSelectedIndex
=
selectedIndex
this
.
updatePickerData
()
this
.
_
updatePickerData
()
},
_pickerSelect
(
selectedVal
,
selectedIndex
,
selectedText
)
{
this
.
$emit
(
EVENT_SELECT
,
selectedVal
,
selectedIndex
,
selectedText
)
...
...
@@ -116,11 +57,11 @@
_pickerChange
(
i
,
newIndex
)
{
if
(
newIndex
!==
this
.
pickerSelectedIndex
[
i
])
{
this
.
pickerSelectedIndex
.
splice
(
i
,
1
,
newIndex
)
this
.
updatePickerData
(
i
+
1
)
this
.
_
updatePickerData
(
i
+
1
)
}
this
.
$emit
(
EVENT_CHANGE
,
i
,
newIndex
)
},
updatePickerData
(
fromColumn
=
0
)
{
_
updatePickerData
(
fromColumn
=
0
)
{
let
data
=
this
.
cascadeData
let
i
=
0
while
(
data
)
{
...
...
src/components/picker/picker.vue
浏览文件 @
5bed5252
...
...
@@ -37,6 +37,7 @@
import
BScroll
from
'
better-scroll
'
import
CubePopup
from
'
../popup/popup.vue
'
import
apiMixin
from
'
../../common/mixins/api
'
import
pickerMixin
from
'
../../common/mixins/picker
'
const
COMPONENT_NAME
=
'
cube-picker
'
...
...
@@ -45,66 +46,15 @@
const
EVENT_CANCEL
=
'
cancel
'
const
EVENT_CHANGE
=
'
change
'
const
DEFAULT_KEYS
=
{
value
:
'
value
'
,
text
:
'
text
'
}
export
default
{
name
:
COMPONENT_NAME
,
mixins
:
[
apiMixin
],
props
:
{
data
:
{
type
:
Array
,
default
()
{
return
[]
}
},
selectedIndex
:
{
type
:
Array
,
default
()
{
return
[]
}
},
title
:
{
type
:
String
},
cancelTxt
:
{
type
:
String
,
default
:
'
取消
'
},
confirmTxt
:
{
type
:
String
,
default
:
'
确定
'
},
swipeTime
:
{
type
:
Number
,
default
:
2500
},
alias
:
{
type
:
Object
,
default
()
{
return
{}
}
},
zIndex
:
{
type
:
Number
}
},
mixins
:
[
apiMixin
,
pickerMixin
],
data
()
{
return
{
pickerData
:
this
.
data
.
slice
(),
pickerSelectedIndex
:
this
.
selectedIndex
}
},
computed
:
{
valueKey
()
{
return
this
.
alias
.
value
||
DEFAULT_KEYS
.
value
},
textKey
()
{
return
this
.
alias
.
text
||
DEFAULT_KEYS
.
text
}
},
created
()
{
this
.
pickerSelectedVal
=
[]
if
(
!
this
.
pickerSelectedIndex
.
length
)
{
...
...
@@ -293,14 +243,6 @@
})
}
},
watch
:
{
data
(
newVal
)
{
this
.
setData
(
newVal
,
this
.
selectedIndex
)
},
selectedIndex
(
newVal
)
{
this
.
setData
(
this
.
data
,
newVal
)
}
},
components
:
{
CubePopup
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录