Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mes-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
周远喜
mes-ui
Commits
e45ca723
Commit
e45ca723
authored
May 27, 2020
by
康振飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
时间段控件
parent
5cc2638e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
168 additions
and
57 deletions
+168
-57
dtSearch.vue
components/page/dtSearch.vue
+70
-57
dtSearchold.vue
components/page/dtSearchold.vue
+98
-0
No files found.
components/page/dtSearch.vue
View file @
e45ca723
<
template
>
<
template
>
<div>
<DatePicker
<DatePicker
type=
"datetimerange"
:type=
"type === 'date' ?'daterange':'datetimerange'"
:format=
"type === 'date' ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'"
:options=
"options01"
v-model=
"name"
placement=
"bottom-end"
:format=
"type === 'date' ? 'yyyy/MM/dd' : 'yyyy/MM/dd HH:mm:ss'"
placeholder=
"选择时间段"
placeholder=
"选择时间段"
v-model=
"dataValue"
:clearable=
"true"
@
on-clear=
"onClear"
@
on-change=
"changeFormat"
@
on-change=
"changeFormat"
style=
"float:left
"
class=
"wp
"
></DatePicker>
></DatePicker>
<div
v-if=
"showFast"
>
<RadioGroup
type=
"button"
size=
"small"
style=
"margin-left:5px;line-height:35px;"
@
on-change=
"getTime"
>
<Radio
label=
"当天"
></Radio>
<Radio
label=
"近一周"
></Radio>
<Radio
label=
"近一月"
></Radio>
</RadioGroup>
<!--
<Button
size=
"small"
type=
"text"
@
click=
"getTime('1')"
>
当天
</Button>
<Button
size=
"small"
type=
"text"
@
click=
"getTime('2')"
>
近一周
</Button>
<Button
size=
"small"
type=
"text"
@
click=
"getTime('3')"
>
近一月
</Button>
-->
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
...
@@ -34,14 +21,50 @@ export default {
...
@@ -34,14 +21,50 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
name
:
this
.
value
dataValue
:
this
.
value
,
options01
:
{
shortcuts
:
[
{
text
:
'当天'
,
value
()
{
const
start
=
new
Date
(
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
()
)
const
end
=
new
Date
()
return
[
start
,
end
]
}
},
{
text
:
'近一周'
,
value
()
{
const
start
=
new
Date
(
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
()
)
const
end
=
new
Date
()
start
.
setTime
(
start
.
getTime
()
-
3600
*
1000
*
24
*
7
)
return
[
start
,
end
]
}
},
{
text
:
'近一月'
,
value
()
{
const
start
=
new
Date
(
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
()
)
const
end
=
new
Date
()
start
.
setTime
(
start
.
getTime
()
-
3600
*
1000
*
24
*
30
)
return
[
start
,
end
]
}
}
]
}
}
}
},
},
props
:
{
props
:
{
value
:
[
String
,
Number
,
Array
],
value
:
[
String
,
Number
,
Array
],
type
:
{
type
:
{
type
:
String
,
type
:
String
,
default
:
'date
Time
'
default
:
'date'
},
},
showFast
:
{
showFast
:
{
type
:
Boolean
,
type
:
Boolean
,
...
@@ -51,47 +74,37 @@ export default {
...
@@ -51,47 +74,37 @@ export default {
created
()
{},
created
()
{},
methods
:
{
methods
:
{
changeFormat
(
val
)
{
changeFormat
(
val
)
{
let
newVal
=
[]
console
.
log
(
val
)
if
(
val
!=
','
)
{
if
(
val
)
{
if
(
this
.
type
==
'date'
)
{
let
newVal
=
[]
newVal
.
push
(
val
[
0
].
substr
(
0
,
10
)
+
' 00:00:00'
)
if
(
val
.
length
==
2
)
{
newVal
.
push
(
val
[
1
].
substr
(
0
,
10
)
+
' 23:59:59'
)
if
(
this
.
type
==
'date'
)
{
}
else
{
if
(
val
[
0
]){
newVal
=
val
newVal
.
push
(
val
[
0
].
substr
(
0
,
10
)
+
' 00:00:00'
)
newVal
.
push
(
val
[
1
].
substr
(
0
,
10
)
+
' 23:59:59'
)
}
else
{
newVal
=
[]
}
}
else
{
newVal
=
val
}
}
}
this
.
dataValue
=
newVal
val
=
newVal
;
}
}
this
.
$emit
(
'on-change'
,
val
)
this
.
name
=
newVal
this
.
$emit
(
'on-change'
,
newVal
)
},
},
getTime
(
val
)
{
let
timeVal
=
[]
onClear
()
{
let
day1
=
new
Date
()
this
.
$nextTick
(()
=>
{
let
day2
=
new
Date
()
this
.
dataValue
=
null
let
day3
=
new
Date
()
})
let
today
=
day1
.
setDate
(
day1
.
getDate
())
today
=
this
.
$u
.
toTime
(
today
)
let
week
=
day2
.
setDate
(
day2
.
getDate
()
-
6
)
week
=
this
.
$u
.
toTime
(
week
)
let
month
=
day3
.
setMonth
(
day3
.
getMonth
()
-
1
)
month
=
this
.
$u
.
toTime
(
month
)
switch
(
val
)
{
case
'当天'
:
timeVal
=
[
today
,
today
]
break
case
'近一周'
:
timeVal
=
[
week
,
today
]
break
default
:
timeVal
=
[
month
,
today
]
}
this
.
changeFormat
(
timeVal
)
}
}
},
},
computed
:
{},
computed
:
{},
watch
:
{
watch
:
{
nam
e
(
v
)
{
dataValu
e
(
v
)
{
// this.
nam
e = v
// this.
dataValu
e = v
}
}
}
}
}
}
...
...
components/page/dtSearchold.vue
0 → 100644
View file @
e45ca723
<
template
>
<div>
<DatePicker
type=
"datetimerange"
:format=
"type === 'date' ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'"
v-model=
"name"
placeholder=
"选择时间段"
@
on-change=
"changeFormat"
style=
"float:left"
></DatePicker>
<div
v-if=
"showFast"
>
<RadioGroup
type=
"button"
size=
"small"
style=
"margin-left:5px;line-height:35px;"
@
on-change=
"getTime"
>
<Radio
label=
"当天"
></Radio>
<Radio
label=
"近一周"
></Radio>
<Radio
label=
"近一月"
></Radio>
</RadioGroup>
<!--
<Button
size=
"small"
type=
"text"
@
click=
"getTime('1')"
>
当天
</Button>
<Button
size=
"small"
type=
"text"
@
click=
"getTime('2')"
>
近一周
</Button>
<Button
size=
"small"
type=
"text"
@
click=
"getTime('3')"
>
近一月
</Button>
-->
</div>
</div>
</
template
>
<
script
>
export
default
{
name
:
'dtSearch'
,
model
:
{
prop
:
'value'
,
event
:
'on-change'
},
data
()
{
return
{
name
:
this
.
value
}
},
props
:
{
value
:
[
String
,
Number
,
Array
],
type
:
{
type
:
String
,
default
:
'dateTime'
},
showFast
:
{
type
:
Boolean
,
default
:
true
}
},
created
()
{},
methods
:
{
changeFormat
(
val
)
{
let
newVal
=
[]
if
(
val
!=
','
)
{
if
(
this
.
type
==
'date'
)
{
newVal
.
push
(
val
[
0
].
substr
(
0
,
10
)
+
' 00:00:00'
)
newVal
.
push
(
val
[
1
].
substr
(
0
,
10
)
+
' 23:59:59'
)
}
else
{
newVal
=
val
}
}
this
.
name
=
newVal
this
.
$emit
(
'on-change'
,
newVal
)
},
getTime
(
val
)
{
let
timeVal
=
[]
let
day1
=
new
Date
()
let
day2
=
new
Date
()
let
day3
=
new
Date
()
let
today
=
day1
.
setDate
(
day1
.
getDate
())
today
=
this
.
$u
.
toTime
(
today
)
let
week
=
day2
.
setDate
(
day2
.
getDate
()
-
6
)
week
=
this
.
$u
.
toTime
(
week
)
let
month
=
day3
.
setMonth
(
day3
.
getMonth
()
-
1
)
month
=
this
.
$u
.
toTime
(
month
)
switch
(
val
)
{
case
'当天'
:
timeVal
=
[
today
,
today
]
break
case
'近一周'
:
timeVal
=
[
week
,
today
]
break
default
:
timeVal
=
[
month
,
today
]
}
this
.
changeFormat
(
timeVal
)
}
},
computed
:
{},
watch
:
{
name
(
v
)
{
// this.name = v
}
}
}
</
script
>
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