Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-easy-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
easyUI
hls-easy-ui
Commits
8fa33570
Commit
8fa33570
authored
Aug 26, 2020
by
JingChao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
field组件
parent
7f91df80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
96 deletions
+94
-96
OptionButton.vue
packages/components/ItemOption/OptionButton.vue
+1
-2
index.vue
packages/components/ItemOption/index.vue
+93
-93
demo.vue
src/pages/ItemOption/demo.vue
+0
-1
No files found.
packages/components/ItemOption/OptionButton.vue
View file @
8fa33570
<
template
>
<div
:class=
"type"
class=
"function"
@
touchstart
=
"itemClick"
>
{{
text
}}
</div>
<div
:class=
"type"
class=
"function"
@
click
=
"itemClick"
>
{{
text
}}
</div>
</
template
>
<
script
>
...
...
@@ -23,7 +23,6 @@ export default {
},
methods
:
{
itemClick
(
e
)
{
e
.
preventDefault
()
this
.
$parent
&&
this
.
$parent
.
reset
()
},
},
...
...
packages/components/ItemOption/index.vue
View file @
8fa33570
...
...
@@ -13,107 +13,107 @@
</
template
>
<
script
>
import
optionButton
from
'./OptionButton'
import
optionButton
from
'./OptionButton'
export
default
{
name
:
'ItemOption'
,
components
:
{
optionButton
},
props
:
{
deleteText
:
{
type
:
String
,
default
:
'删除'
,
},
editText
:
{
type
:
String
,
default
:
'编辑'
,
},
buttonWidth
:
{
type
:
Number
,
default
:
70
,
},
cusClass
:
{
type
:
String
,
default
:
''
,
},
hasBorder
:
{
type
:
Boolean
,
default
:
true
,
},
export
default
{
name
:
'ItemOption'
,
components
:
{
optionButton
},
props
:
{
deleteText
:
{
type
:
String
,
default
:
'删除'
,
},
data
()
{
return
{
dis
:
0
,
buttons
:
0
,
startX
:
0
,
// 触摸位置
endX
:
0
,
// 结束位置
optionItem
:
[],
}
editText
:
{
type
:
String
,
default
:
'编辑'
,
},
computed
:
{
bottomBorder
()
{
return
this
.
hasBorder
?
'vux-1px-b'
:
''
},
buttonWidth
:
{
type
:
Number
,
default
:
70
,
},
mounted
()
{
this
.
init
()
cusClass
:
{
type
:
String
,
default
:
''
,
},
updated
()
{
this
.
init
()
hasBorder
:
{
type
:
Boolean
,
default
:
true
,
},
methods
:
{
touchStart
(
ev
)
{
this
.
$refs
.
optionItem
.
style
.
transform
=
'translate3d(0px,0px,0px)'
this
.
reset
()
ev
=
ev
||
event
// tounches类数组,等于1时表示此时有只有一只手指在触摸屏幕
if
(
ev
.
touches
.
length
===
1
)
{
// 记录开始位置
this
.
startX
=
ev
.
touches
[
0
].
clientX
}
},
touchEnd
(
e
)
{
let
parentElement
=
e
.
currentTarget
.
parentElement
this
.
endX
=
e
.
changedTouches
[
0
].
clientX
// console.log(this.endX)
if
(
parentElement
.
dataset
.
type
===
'0'
&&
this
.
startX
-
this
.
endX
>
30
)
{
parentElement
.
dataset
.
type
=
'1'
parentElement
.
style
.
transform
=
'translate3d(-'
+
this
.
dis
+
'px,0px,0px)'
}
if
(
parentElement
.
dataset
.
type
===
'1'
&&
this
.
startX
-
this
.
endX
<
-
30
)
{
parentElement
.
style
.
transform
=
'translate3d(0px,0px,0px)'
parentElement
.
dataset
.
type
=
'0'
}
this
.
startX
=
0
this
.
endX
=
0
},
// 判断当前是否有滑块处于滑动状态
checkSlide
()
{
let
listItems
=
this
.
$refs
.
optionItem
for
(
let
i
=
0
;
i
<
listItems
.
length
;
i
++
)
{
if
(
listItems
[
i
].
dataset
.
type
===
'1'
)
{
return
true
}
}
return
false
},
// 初始化
init
()
{
let
vm
=
this
let
childerLength
=
vm
.
optionItem
.
length
vm
.
dis
=
vm
.
buttonWidth
*
(
childerLength
)
vm
.
optionItem
.
forEach
((
option
,
index
)
=>
{
option
.
$el
.
style
.
right
=
'-'
+
(
vm
.
buttonWidth
*
(
index
+
1
))
+
'px'
})
},
reset
()
{
let
l
=
document
.
getElementsByClassName
(
'option-item'
).
length
for
(
let
i
=
0
;
i
<
l
;
i
++
)
{
document
.
getElementsByClassName
(
'option-item'
)[
i
].
style
.
transform
=
'translate3d(0px,0px,0px)'
document
.
getElementsByClassName
(
'option-item'
)[
i
].
dataset
.
type
=
'0'
},
data
()
{
return
{
dis
:
0
,
buttons
:
0
,
startX
:
0
,
// 触摸位置
endX
:
0
,
// 结束位置
optionItem
:
[],
}
},
computed
:
{
bottomBorder
()
{
return
this
.
hasBorder
?
'vux-1px-b'
:
''
},
},
mounted
()
{
this
.
init
()
},
updated
()
{
this
.
init
()
},
methods
:
{
touchStart
(
ev
)
{
this
.
$refs
.
optionItem
.
style
.
transform
=
'translate3d(0px,0px,0px)'
this
.
reset
()
ev
=
ev
||
event
// tounches类数组,等于1时表示此时有只有一只手指在触摸屏幕
if
(
ev
.
touches
.
length
===
1
)
{
// 记录开始位置
this
.
startX
=
ev
.
touches
[
0
].
clientX
}
},
touchEnd
(
e
)
{
let
parentElement
=
e
.
currentTarget
.
parentElement
this
.
endX
=
e
.
changedTouches
[
0
].
clientX
// console.log(this.endX)
if
(
parentElement
.
dataset
.
type
===
'0'
&&
this
.
startX
-
this
.
endX
>
30
)
{
parentElement
.
dataset
.
type
=
'1'
parentElement
.
style
.
transform
=
'translate3d(-'
+
this
.
dis
+
'px,0px,0px)'
}
if
(
parentElement
.
dataset
.
type
===
'1'
&&
this
.
startX
-
this
.
endX
<
-
30
)
{
parentElement
.
style
.
transform
=
'translate3d(0px,0px,0px)'
parentElement
.
dataset
.
type
=
'0'
}
this
.
startX
=
0
this
.
endX
=
0
},
// 判断当前是否有滑块处于滑动状态
checkSlide
()
{
let
listItems
=
this
.
$refs
.
optionItem
for
(
let
i
=
0
;
i
<
listItems
.
length
;
i
++
)
{
if
(
listItems
[
i
].
dataset
.
type
===
'1'
)
{
return
true
}
},
}
return
false
},
}
// 初始化
init
()
{
let
vm
=
this
let
childerLength
=
vm
.
optionItem
.
length
vm
.
dis
=
vm
.
buttonWidth
*
(
childerLength
)
vm
.
optionItem
.
forEach
((
option
,
index
)
=>
{
option
.
$el
.
style
.
right
=
'-'
+
(
vm
.
buttonWidth
*
(
index
+
1
))
+
'px'
})
},
reset
()
{
let
l
=
document
.
getElementsByClassName
(
'option-item'
).
length
for
(
let
i
=
0
;
i
<
l
;
i
++
)
{
document
.
getElementsByClassName
(
'option-item'
)[
i
].
style
.
transform
=
'translate3d(0px,0px,0px)'
document
.
getElementsByClassName
(
'option-item'
)[
i
].
dataset
.
type
=
'0'
}
},
},
}
</
script
>
<
style
lang=
"less"
scoped
type=
"text/less"
>
...
...
src/pages/ItemOption/demo.vue
View file @
8fa33570
...
...
@@ -45,7 +45,6 @@ export default {
methods
:
{
deleteFun
(
index
)
{
this
.
colors
.
remove
(
index
)
// this.$refs.option[index].reset()
this
.
colors
.
sort
()
},
},
...
...
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