Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
955a0ec6
提交
955a0ec6
authored
5月 21, 2021
作者:
fit2cloud-chenyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 时间组件参数改为时间戳
上级
c38bc7f3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
55 行增加
和
26 行删除
+55
-26
DeDate.vue
frontend/src/components/widget/DeWidget/DeDate.vue
+15
-26
index.js
frontend/src/utils/index.js
+40
-0
没有找到文件。
frontend/src/components/widget/DeWidget/DeDate.vue
浏览文件 @
955a0ec6
...
...
@@ -13,7 +13,7 @@
</
template
>
<
script
>
import
{
dateFormat
}
from
'@/utils'
import
{
timeSection
}
from
'@/utils'
export
default
{
props
:
{
...
...
@@ -29,7 +29,7 @@ export default {
data
()
{
return
{
options
:
null
,
operator
:
'
eq
'
,
operator
:
'
in
'
,
values
:
null
}
},
...
...
@@ -50,37 +50,26 @@ export default {
this
.
inDraw
&&
this
.
$store
.
dispatch
(
'conditions/add'
,
param
)
},
dateChange
(
value
)
{
// const nvalue = dateFormat(value, this.getFormat())
// console.log(nvalue)
this
.
setCondition
()
},
formatValues
(
values
)
{
if
(
!
values
||
values
.
length
===
0
)
{
return
[]
}
return
values
.
map
(
value
=>
dateFormat
(
value
,
this
.
getFormat
()))
},
getFormat
()
{
let
format
=
'yyyy'
switch
(
this
.
options
.
attrs
.
type
)
{
case
'year'
:
format
=
'yyyy'
break
case
'month'
:
format
=
'yyyy-MM'
break
case
'date'
:
format
=
'yyyy-MM-dd'
break
case
'daterange'
:
format
=
'yyyy-MM-dd'
this
.
operator
=
'in'
break
default
:
format
=
'yyyy'
break
if
(
this
.
options
.
attrs
.
type
===
'daterange'
)
{
if
(
values
.
length
!==
2
)
{
return
null
}
let
start
=
values
[
0
]
let
end
=
values
[
1
]
start
=
timeSection
(
start
,
'date'
)[
0
]
end
=
timeSection
(
end
,
'date'
)[
1
]
const
results
=
[
start
,
end
]
return
results
}
else
{
const
value
=
values
[
0
]
return
timeSection
(
value
,
this
.
options
.
attrs
.
type
)
}
return
format
}
}
}
...
...
frontend/src/utils/index.js
浏览文件 @
955a0ec6
/**
* Created by PanJiaChen on 16/11/18.
*/
export
function
timeSection
(
date
,
type
)
{
if
(
!
date
)
{
return
null
}
const
timeRanger
=
new
Array
(
2
)
date
.
setHours
(
0
)
date
.
setMinutes
(
0
)
date
.
setSeconds
(
0
)
date
.
setMilliseconds
(
0
)
const
end
=
new
Date
(
date
)
if
(
type
===
'year'
)
{
date
.
setDate
(
1
)
date
.
setMonth
(
0
)
end
.
setFullYear
(
date
.
getFullYear
()
+
1
)
timeRanger
[
1
]
=
end
.
getTime
()
-
1
}
if
(
type
===
'month'
)
{
date
.
setDate
(
1
)
const
currentMonth
=
date
.
getMonth
()
if
(
currentMonth
===
11
)
{
end
.
setFullYear
(
date
.
getFullYear
()
+
1
)
end
.
setMonth
(
0
)
}
else
{
end
.
setMonth
(
date
.
getMonth
()
+
1
)
}
timeRanger
[
1
]
=
end
.
getTime
()
-
1
}
if
(
type
===
'date'
)
{
end
.
setHours
(
23
)
end
.
setMinutes
(
59
)
end
.
setSeconds
(
59
)
end
.
setMilliseconds
(
999
)
timeRanger
[
1
]
=
end
.
getTime
()
}
timeRanger
[
0
]
=
date
.
getTime
()
return
timeRanger
}
export
function
dateFormat
(
date
,
fmt
)
{
let
ret
const
opt
=
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论