Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
S
shop-new
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王天霸
shop-new
Commits
114f8820
提交
114f8820
authored
5月 10, 2021
作者:
huaxinzhu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
格式整理
上级
bf6cd3cc
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
94 行增加
和
90 行删除
+94
-90
main.js
src/main.js
+0
-1
ruoyi.js
src/utils/ruoyi.js
+94
-89
没有找到文件。
src/main.js
浏览文件 @
114f8820
...
...
@@ -50,7 +50,6 @@ import VueDND from 'awe-dnd'
Vue
.
use
(
VueDND
)
//富文本
import
VueQuillEditor
from
'vue-quill-editor'
// require styles
...
...
src/utils/ruoyi.js
浏览文件 @
114f8820
...
...
@@ -7,101 +7,103 @@ const baseURL = process.env.VUE_APP_BASE_API
// 日期格式化
export
function
parseTime
(
time
,
pattern
)
{
if
(
arguments
.
length
===
0
||
!
time
)
{
return
null
}
const
format
=
pattern
||
'{y}-{m}-{d} {h}:{i}:{s}'
let
date
if
(
typeof
time
===
'object'
)
{
date
=
time
}
else
{
if
((
typeof
time
===
'string'
)
&&
(
/^
[
0-9
]
+$/
.
test
(
time
)))
{
time
=
parseInt
(
time
)
}
else
if
(
typeof
time
===
'string'
)
{
time
=
time
.
replace
(
new
RegExp
(
/-/gm
),
'/'
);
}
if
((
typeof
time
===
'number'
)
&&
(
time
.
toString
().
length
===
10
))
{
time
=
time
*
1000
}
date
=
new
Date
(
time
)
}
const
formatObj
=
{
y
:
date
.
getFullYear
(),
m
:
date
.
getMonth
()
+
1
,
d
:
date
.
getDate
(),
h
:
date
.
getHours
(),
i
:
date
.
getMinutes
(),
s
:
date
.
getSeconds
(),
a
:
date
.
getDay
()
}
const
time_str
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
let
value
=
formatObj
[
key
]
// Note: getDay() returns 0 on Sunday
if
(
key
===
'a'
)
{
return
[
'日'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
][
value
]
}
if
(
result
.
length
>
0
&&
value
<
10
)
{
value
=
'0'
+
value
}
return
value
||
0
})
return
time_str
if
(
arguments
.
length
===
0
||
!
time
)
{
return
null
}
const
format
=
pattern
||
'{y}-{m}-{d} {h}:{i}:{s}'
let
date
if
(
typeof
time
===
'object'
)
{
date
=
time
}
else
{
if
((
typeof
time
===
'string'
)
&&
(
/^
[
0-9
]
+$/
.
test
(
time
)))
{
time
=
parseInt
(
time
)
}
else
if
(
typeof
time
===
'string'
)
{
time
=
time
.
replace
(
new
RegExp
(
/-/gm
),
'/'
);
}
if
((
typeof
time
===
'number'
)
&&
(
time
.
toString
().
length
===
10
))
{
time
=
time
*
1000
}
date
=
new
Date
(
time
)
}
const
formatObj
=
{
y
:
date
.
getFullYear
(),
m
:
date
.
getMonth
()
+
1
,
d
:
date
.
getDate
(),
h
:
date
.
getHours
(),
i
:
date
.
getMinutes
(),
s
:
date
.
getSeconds
(),
a
:
date
.
getDay
()
}
const
time_str
=
format
.
replace
(
/{
(
y|m|d|h|i|s|a
)
+}/g
,
(
result
,
key
)
=>
{
let
value
=
formatObj
[
key
]
// Note: getDay() returns 0 on Sunday
if
(
key
===
'a'
)
{
return
[
'日'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
][
value
]
}
if
(
result
.
length
>
0
&&
value
<
10
)
{
value
=
'0'
+
value
}
return
value
||
0
})
return
time_str
}
// 表单重置
export
function
resetForm
(
refName
)
{
if
(
this
.
$refs
[
refName
])
{
this
.
$refs
[
refName
].
resetFields
();
}
if
(
this
.
$refs
[
refName
])
{
this
.
$refs
[
refName
].
resetFields
();
}
}
// 添加日期范围
export
function
addDateRange
(
params
,
dateRange
)
{
var
search
=
params
;
search
.
beginTime
=
""
;
search
.
endTime
=
""
;
if
(
null
!=
dateRange
&&
''
!=
dateRange
)
{
search
.
beginTime
=
this
.
dateRange
[
0
];
search
.
endTime
=
this
.
dateRange
[
1
];
}
return
search
;
var
search
=
params
;
search
.
beginTime
=
""
;
search
.
endTime
=
""
;
if
(
null
!=
dateRange
&&
''
!=
dateRange
)
{
search
.
beginTime
=
this
.
dateRange
[
0
];
search
.
endTime
=
this
.
dateRange
[
1
];
}
return
search
;
}
// 回显数据字典
export
function
selectDictLabel
(
datas
,
value
)
{
var
actions
=
[];
Object
.
keys
(
datas
).
map
((
key
)
=>
{
if
(
datas
[
key
].
key
==
(
''
+
value
))
{
actions
.
push
(
datas
[
key
].
value
);
return
false
;
}
})
return
actions
.
join
(
''
);
var
actions
=
[];
Object
.
keys
(
datas
).
map
((
key
)
=>
{
if
(
datas
[
key
].
key
==
(
''
+
value
))
{
actions
.
push
(
datas
[
key
].
value
);
return
false
;
}
})
return
actions
.
join
(
''
);
}
// 通用下载方法
export
function
download
(
fileName
)
{
window
.
location
.
href
=
baseURL
+
"/common/download?fileName="
+
encodeURI
(
fileName
)
+
"&delete="
+
true
;
window
.
location
.
href
=
baseURL
+
"/common/download?fileName="
+
encodeURI
(
fileName
)
+
"&delete="
+
true
;
}
// 字符串格式化(%s )
export
function
sprintf
(
str
)
{
var
args
=
arguments
,
flag
=
true
,
i
=
1
;
str
=
str
.
replace
(
/%s/g
,
function
()
{
var
arg
=
args
[
i
++
];
if
(
typeof
arg
===
'undefined'
)
{
flag
=
false
;
return
''
;
}
return
arg
;
});
return
flag
?
str
:
''
;
var
args
=
arguments
,
flag
=
true
,
i
=
1
;
str
=
str
.
replace
(
/%s/g
,
function
()
{
var
arg
=
args
[
i
++
];
if
(
typeof
arg
===
'undefined'
)
{
flag
=
false
;
return
''
;
}
return
arg
;
});
return
flag
?
str
:
''
;
}
// 转换字符串,undefined,null等转化为""
export
function
praseStrEmpty
(
str
)
{
if
(
!
str
||
str
==
"undefined"
||
str
==
"null"
)
{
return
""
;
}
return
str
;
if
(
!
str
||
str
==
"undefined"
||
str
==
"null"
)
{
return
""
;
}
return
str
;
}
/**
...
...
@@ -113,21 +115,24 @@ export function praseStrEmpty(str) {
* @param {*} rootId 根Id 默认 0
*/
export
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
id
=
id
||
'id'
parentId
=
parentId
||
'parentId'
children
=
children
||
'children'
rootId
=
rootId
||
0
//对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
//循环所有项
const
treeData
=
cloneData
.
filter
(
father
=>
{
let
branchArr
=
cloneData
.
filter
(
child
=>
{
//返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
]
});
branchArr
.
length
>
0
?
father
.
children
=
branchArr
:
''
;
//返回第一层
return
father
[
parentId
]
===
rootId
;
});
return
treeData
!=
''
?
treeData
:
data
;
}
id
=
id
||
'id'
parentId
=
parentId
||
'parentId'
children
=
children
||
'children'
rootId
=
rootId
||
0
//对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
//循环所有项
const
treeData
=
cloneData
.
filter
(
father
=>
{
let
branchArr
=
cloneData
.
filter
(
child
=>
{
//返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
]
});
branchArr
.
length
>
0
?
father
.
children
=
branchArr
:
''
;
//返回第一层
return
father
[
parentId
]
===
rootId
;
});
return
treeData
!=
''
?
treeData
:
data
;
}
// 标准时间转化为时间戳
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论