Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
attendance-performance-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
attendance-performance-platform
Commits
f992d4c3
Commit
f992d4c3
authored
Dec 17, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
5e3d4f07
73f0498f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
203 additions
and
156 deletions
+203
-156
attendance-performance-manager-ui/admin/src/assets/utils/index.js
...ce-performance-manager-ui/admin/src/assets/utils/index.js
+151
-136
attendance-performance-manager-ui/admin/src/views/attendance/record/list.vue
...nce-manager-ui/admin/src/views/attendance/record/list.vue
+52
-20
No files found.
attendance-performance-manager-ui/admin/src/assets/utils/index.js
View file @
f992d4c3
import
Qs
from
'
qs
'
;
import
{
post
,
get
,
upload
}
from
'
./ajax
'
;
import
queue
from
'
./queue
'
;
import
axios
from
'
axios
'
;
import
cookie
from
'
./cookie
'
;
import
httpErrorHandler
from
'
./httpErrorHandler
'
;
import
Qs
from
"
qs
"
;
import
{
post
,
get
,
upload
}
from
"
./ajax
"
;
import
queue
from
"
./queue
"
;
import
axios
from
"
axios
"
;
import
cookie
from
"
./cookie
"
;
import
httpErrorHandler
from
"
./httpErrorHandler
"
;
/**
* 获取参数的类型
...
...
@@ -12,7 +12,7 @@ import httpErrorHandler from './httpErrorHandler';
* @returns {string} 参数类型
*/
export
const
type
=
(
data
)
=>
{
return
Object
.
prototype
.
toString
.
call
(
data
).
replace
(
/
(\[
object |
\])
/g
,
''
)
return
Object
.
prototype
.
toString
.
call
(
data
).
replace
(
/
(\[
object |
\])
/g
,
""
);
};
/**
...
...
@@ -22,7 +22,7 @@ export const type = (data) => {
*/
export
const
getLoginStatus
=
()
=>
{
return
window
.
sessionStorage
.
isLogin
;
}
}
;
/**
* 解析url参数
...
...
@@ -30,9 +30,8 @@ export const getLoginStatus = () => {
* @returns {object} localtion的query对象
*/
export
const
query
=
()
=>
{
return
Qs
.
parse
(
window
.
location
.
href
.
split
(
'
?
'
)[
1
])
}
return
Qs
.
parse
(
window
.
location
.
href
.
split
(
"
?
"
)[
1
]);
};
/**
* 编码url参数
...
...
@@ -41,8 +40,8 @@ export const query = () => {
* @returns string
*/
export
const
encodeURI
=
(
data
)
=>
{
return
Qs
.
stringify
(
data
,
{
arrayFormat
:
'
repeat
'
,
allowDots
:
true
});
}
return
Qs
.
stringify
(
data
,
{
arrayFormat
:
"
repeat
"
,
allowDots
:
true
});
}
;
/**
* formatterDate
...
...
@@ -51,19 +50,23 @@ export const encodeURI = (data) => {
* @returns {string} val 解析后的结果
*/
export
function
formatterDate
(
time
)
{
if
(
time
===
'
undefined
'
||
time
===
null
)
{
return
'
--
'
}
if
(
time
===
"
undefined
"
||
time
===
null
)
{
return
"
--
"
;
}
if
(
!
time
)
return
'
--
'
;
if
(
!
time
)
return
"
--
"
;
let
date
=
new
Date
(
Number
(
time
));
let
Y
=
date
.
getFullYear
()
+
'
-
'
;
let
M
=
(
date
.
getMonth
()
+
1
<
10
?
'
0
'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
)
+
'
-
'
;
let
D
=
panLeft
(
date
.
getDate
())
+
'
'
;
let
h
=
panLeft
(
date
.
getHours
())
+
'
:
'
;
let
m
=
panLeft
(
date
.
getMinutes
())
+
'
:
'
;
let
Y
=
date
.
getFullYear
()
+
"
-
"
;
let
M
=
(
date
.
getMonth
()
+
1
<
10
?
"
0
"
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
)
+
"
-
"
;
let
D
=
panLeft
(
date
.
getDate
())
+
"
"
;
let
h
=
panLeft
(
date
.
getHours
())
+
"
:
"
;
let
m
=
panLeft
(
date
.
getMinutes
())
+
"
:
"
;
let
s
=
panLeft
(
date
.
getSeconds
());
return
Y
+
M
+
D
+
h
+
m
+
s
;
}
;
}
/**
* formatterDate
*
...
...
@@ -91,7 +94,7 @@ export function formatterDateDay(datetime) {
return
Y
+
M
+
D
;
}
return
datetime
;
}
;
}
/**
* 当前日期加天数后得到的相应日期
* @param {*} day
...
...
@@ -117,10 +120,9 @@ function doHandleMonth(month) {
}
function
panLeft
(
num
)
{
return
num
<
10
?
'
0
'
+
num
:
num
;
return
num
<
10
?
"
0
"
+
num
:
num
;
}
/**
* call方法
*
...
...
@@ -132,23 +134,24 @@ function panLeft(num) {
*/
const
call
=
(
callMethod
,
url
,
formData
,
config
=
{})
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
callMethod
(
url
,
formData
,
config
).
then
(
res
=>
{
const
{
code
,
msg
,
data
}
=
res
;
if
(
code
!==
1
)
{
reject
({
message
:
msg
||
''
});
return
;
}
resolve
(
res
);
})
.
catch
(
error
=>
{
callMethod
(
url
,
formData
,
config
)
.
then
((
res
)
=>
{
const
{
code
,
msg
,
data
}
=
res
;
if
(
code
!==
1
)
{
reject
({
message
:
msg
||
""
,
});
return
;
}
resolve
(
res
);
})
.
catch
((
error
)
=>
{
if
(
error
.
status
===
403
)
{
window
.
location
.
href
=
'
/#/login
'
window
.
location
.
href
=
"
/#/login
"
;
}
reject
(
error
);
})
})
})
;
})
;
};
/**
...
...
@@ -176,10 +179,10 @@ export const normalCallGet = (url, formData, config = {}) => {
};
const
mimeMap
=
{
xlsx
:
'
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
'
,
zip
:
'
application/zip
'
,
doc
:
'
application/msword
'
}
xlsx
:
"
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
"
,
zip
:
"
application/zip
"
,
doc
:
"
application/msword
"
,
}
;
/**
* 普通的ajax download请求
...
...
@@ -192,90 +195,107 @@ const mimeMap = {
export
const
download
=
(
url
,
formData
,
config
=
{})
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
option
=
Object
.
assign
({},
config
,
{
responseType
:
'
blob
'
})
responseType
:
"
blob
"
,
})
;
try
{
const
data
=
await
post
(
url
,
formData
,
option
)
const
link
=
document
.
createElement
(
'
a
'
)
let
blob
let
extName
const
data
=
await
post
(
url
,
formData
,
option
)
;
const
link
=
document
.
createElement
(
"
a
"
);
let
blob
;
let
extName
;
if
(
option
.
type
==
"
zip
"
)
{
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
zip
})
extName
=
"
zip
"
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
zip
})
;
extName
=
"
zip
"
;
}
else
if
(
option
.
type
==
"
excel
"
)
{
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
xlsx
})
extName
=
"
xlsx
"
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
xlsx
})
;
extName
=
"
xlsx
"
;
}
else
if
(
option
.
type
==
"
doc
"
)
{
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
doc
})
extName
=
"
doc
"
blob
=
new
Blob
([
data
],
{
type
:
mimeMap
.
doc
})
;
extName
=
"
doc
"
;
}
else
{
extName
=
"
xlsx
"
extName
=
"
xlsx
"
;
}
let
fileName
=
"
导出
"
let
fileName
=
"
导出
"
;
if
(
option
.
fileName
)
{
fileName
=
option
.
fileName
fileName
=
option
.
fileName
;
}
link
.
href
=
URL
.
createObjectURL
(
blob
)
link
.
setAttribute
(
'
download
'
,
`
${
fileName
}
.
${
extName
}
`
)
// 设置下载文件名称
document
.
body
.
appendChild
(
link
)
link
.
click
()
document
.
body
.
appendChild
(
link
)
link
.
href
=
URL
.
createObjectURL
(
blob
)
;
link
.
setAttribute
(
"
download
"
,
`
${
fileName
}
.
${
extName
}
`
);
// 设置下载文件名称
document
.
body
.
appendChild
(
link
)
;
link
.
click
()
;
document
.
body
.
appendChild
(
link
)
;
resolve
();
}
catch
(
error
)
{
reject
(
error
);
}
})
})
;
};
export
const
downloadWithCustName
=
(
url
,
formData
,
config
=
{})
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
const
option
=
Object
.
assign
({},
config
,
{
responseType
:
'
blob
'
,
baseURL
:
'
/m
'
,
responseType
:
"
blob
"
,
baseURL
:
"
/m
"
,
headers
:
{
post
:
{
'
Content-Type
'
:
'
application/x-www-form-urlencoded;charset=UTF-8
'
}
}
})
"
Content-Type
"
:
"
application/x-www-form-urlencoded;charset=UTF-8
"
,
}
,
}
,
})
;
try
{
const
params
=
Object
.
assign
({},
formData
,
{
__mortals_token__
:
cookie
.
getItem
(
'
__mortals_token__
'
),
})
var
requestData
=
Qs
.
stringify
(
params
,
{
arrayFormat
:
'
repeat
'
,
allowDots
:
true
});
axios
.
post
(
url
,
requestData
,
option
)
.
then
(
response
=>
{
if
(
response
.
data
.
type
==
'
application/json
'
)
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
event
)
{
var
content
=
reader
.
result
;
reject
(
content
);
};
reader
.
readAsText
(
response
.
data
);
return
;
__mortals_token__
:
cookie
.
getItem
(
"
__mortals_token__
"
),
});
var
requestData
=
Qs
.
stringify
(
params
,
{
arrayFormat
:
"
repeat
"
,
allowDots
:
true
,
});
axios
.
post
(
url
,
requestData
,
option
)
.
then
(
(
response
)
=>
{
if
(
response
.
data
.
type
==
"
application/json
"
)
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
event
)
{
var
content
=
reader
.
result
;
reject
(
content
);
};
reader
.
readAsText
(
response
.
data
);
return
;
}
const
filename
=
decodeURI
(
response
.
headers
[
"
content-disposition
"
]
.
split
(
"
;
"
)[
1
]
.
split
(
"
=
"
)[
1
]
)
||
`
${
url
.
substr
(
1
)
.
replace
(
/
\/
/g
,
"
_
"
)}
_
${
new
Date
().
getTime
()}
.xls`
;
let
downloadUrl
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
])
);
let
link
=
document
.
createElement
(
"
a
"
);
link
.
style
.
display
=
"
none
"
;
link
.
href
=
downloadUrl
;
link
.
setAttribute
(
"
download
"
,
filename
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
resolve
();
},
(
err
)
=>
{
reject
(
err
);
}
const
filename
=
decodeURI
(
response
.
headers
[
'
content-disposition
'
].
split
(
'
;
'
)[
1
].
split
(
'
=
'
)[
1
])
||
`
${
url
.
substr
(
1
).
replace
(
/
\/
/g
,
'
_
'
)}
_
${
new
Date
().
getTime
()}
.xls`
let
downloadUrl
=
window
.
URL
.
createObjectURL
(
new
Blob
([
response
.
data
]))
let
link
=
document
.
createElement
(
'
a
'
)
link
.
style
.
display
=
'
none
'
;
link
.
href
=
downloadUrl
;
link
.
setAttribute
(
'
download
'
,
filename
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
document
.
body
.
removeChild
(
link
);
resolve
();
},
err
=>
{
reject
(
err
);
}).
catch
((
error
)
=>
{
reject
(
error
)
})
)
.
catch
((
error
)
=>
{
reject
(
error
);
});
}
catch
(
error
)
{
reject
(
error
);
}
})
})
;
};
/**
...
...
@@ -309,16 +329,15 @@ export async function getUserListByQuery(query) {
try
{
/* //下拉只获取正常状态数据:status{0: "停用", 1: "正常", 2: "冻结", 3: "销户", 4: "离职"}
query["query.status"] = 1;*/
const
data
=
await
normalCallPost
(
'
/user/list
'
,
query
);
const
data
=
await
normalCallPost
(
"
/user/list
"
,
query
);
const
list
=
data
.
data
.
result
.
map
(({
id
,
loginName
,
realName
,
mobile
})
=>
{
return
{
id
,
loginName
,
realName
,
mobile
}
return
{
id
,
loginName
,
realName
,
mobile
}
;
});
return
list
;
}
catch
(
error
)
{
return
[];
}
};
}
/**
* 构造树型结构数据
...
...
@@ -329,41 +348,48 @@ export async function getUserListByQuery(query) {
* @param {*} rootId 根Id 默认 0
*/
export
function
handleTree
(
data
,
id
,
parentId
,
children
,
rootId
)
{
console
.
log
(
"
handle
"
)
id
=
id
||
'
id
'
parentId
=
parentId
||
'
parentId
'
children
=
children
||
'
children
'
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
(
item
=>
{
return
item
[
parentId
]
}))
||
0
console
.
log
(
"
handle
"
);
id
=
id
||
"
id
"
;
parentId
=
parentId
||
"
parentId
"
;
children
=
children
||
"
children
"
;
rootId
=
rootId
||
Math
.
min
.
apply
(
Math
,
data
.
map
((
item
)
=>
{
return
item
[
parentId
];
})
)
||
0
;
//对源数据深度克隆
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
const
cloneData
=
JSON
.
parse
(
JSON
.
stringify
(
data
))
;
//循环所有项
console
.
log
(
"
11111
"
,
cloneData
)
const
treeData
=
cloneData
.
filter
(
father
=>
{
let
branchArr
=
cloneData
.
filter
(
child
=>
{
console
.
log
(
"
11111
"
,
cloneData
)
;
const
treeData
=
cloneData
.
filter
(
(
father
)
=>
{
let
branchArr
=
cloneData
.
filter
(
(
child
)
=>
{
//返回每一项的子级数组
return
father
[
id
]
===
child
[
parentId
]
return
father
[
id
]
===
child
[
parentId
]
;
});
branchArr
.
length
>
0
?
father
.
children
=
branchArr
:
''
;
branchArr
.
length
>
0
?
(
father
.
children
=
branchArr
)
:
""
;
//返回第一层
return
father
[
parentId
]
===
rootId
;
});
console
.
log
(
"
treeData
"
,
treeData
)
return
treeData
!=
''
?
treeData
:
data
;
};
console
.
log
(
"
treeData
"
,
treeData
);
return
treeData
!=
""
?
treeData
:
data
;
}
/**
* 下载文件
* @param {String} path - 下载地址/下载请求地址。
* @param {String} name - 下载文件的名字/重命名(考虑到兼容性问题,最好加上后缀名)
*/
* 下载文件
* @param {String} path - 下载地址/下载请求地址。
* @param {String} name - 下载文件的名字/重命名(考虑到兼容性问题,最好加上后缀名)
*/
export
function
downloadFile
(
path
,
name
)
{
if
(
path
&&
name
)
{
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
get
"
,
path
);
xhr
.
responseType
=
"
blob
"
;
xhr
.
send
();
xhr
.
onload
=
function
()
{
xhr
.
onload
=
function
()
{
if
(
this
.
status
===
200
||
this
.
status
===
304
)
{
// 如果是IE10及以上,不支持download属性,采用msSaveOrOpenBlob方法,但是IE10以下也不支持msSaveOrOpenBlob
if
(
"
msSaveOrOpenBlob
"
in
navigator
)
{
...
...
@@ -384,10 +410,8 @@ export function downloadFile(path, name) {
}
};
}
}
// 当元素滚动条被滚动时运行的脚本
export
function
handleScroll
()
{
let
scrollbarEl
=
this
.
$refs
[
"
scroll
"
].
wrap
;
...
...
@@ -446,13 +470,4 @@ export function jump(index) {
_this
.
$refs
[
"
scroll
"
].
wrap
.
scrollTop
=
distance
;
}
}
};
}
attendance-performance-manager-ui/admin/src/views/attendance/record/list.vue
View file @
f992d4c3
...
...
@@ -335,8 +335,6 @@ export default {
},
/** 导出Excel */
doExport
()
{
this
.
isExport
=
true
;
this
.
progress
=
true
;
let
params
=
{};
for
(
let
value
of
this
.
config
.
search
)
{
if
(
this
.
query
[
value
.
name
])
{
...
...
@@ -349,25 +347,59 @@ export default {
if
(
this
.
checkList
.
length
>
0
)
{
params
[
"
properties
"
]
=
this
.
checkList
;
}
this
.
$download
(
"
/attendance/record/exportExcel
"
,
{
...
params
,
},
{
type
:
"
excel
"
}
)
.
then
(()
=>
{
this
.
percent
=
100
;
this
.
progress
=
false
;
this
.
isExport
=
false
;
this
.
checkList
=
[];
})
.
catch
((
error
)
=>
{
this
.
progress
=
false
;
let
flag
=
this
.
checkDate
(
params
.
attendanceDateStart
,
params
.
attendanceDateEnd
,
1
);
if
(
!
flag
)
{
this
.
isExport
=
true
;
this
.
isExport
=
false
;
this
.
$message
.
error
(
error
.
message
);
});
this
.
progress
=
true
;
this
.
$download
(
"
/attendance/record/exportExcel
"
,
{
...
params
,
},
{
type
:
"
excel
"
}
)
.
then
((
res
)
=>
{
this
.
percent
=
100
;
this
.
progress
=
false
;
this
.
isExport
=
false
;
this
.
checkList
=
[];
})
.
catch
((
error
)
=>
{
this
.
percent
=
100
;
this
.
progress
=
false
;
this
.
isExport
=
false
;
this
.
$message
.
error
(
error
.
message
);
});
}
},
checkDate
(
startTime
,
endTime
,
compDay
)
{
if
(
startTime
==
""
||
startTime
==
null
||
startTime
==
undefined
)
{
this
.
$message
.
error
(
"
开始时间为空,请检查!
"
);
return
true
;
}
if
(
endTime
==
""
||
endTime
==
null
||
endTime
==
undefined
)
{
this
.
$message
.
error
(
"
结束时间为空,请检查!
"
);
return
true
;
}
var
data1
=
Date
.
parse
(
startTime
.
replace
(
/-/g
,
"
/
"
));
var
data2
=
Date
.
parse
(
endTime
.
replace
(
/-/g
,
"
/
"
));
var
datadiff
=
data2
-
data1
;
var
time
=
parseInt
(
compDay
)
*
(
60
*
60
*
24
*
1000
);
if
(
datadiff
<
0
)
{
this
.
$message
.
error
(
"
开始时间应小于结束时间
"
);
return
true
;
}
if
(
datadiff
>
time
)
{
this
.
$message
.
error
(
"
时间间隔大于
"
+
parseInt
(
compDay
)
+
"
天,请检查!
"
);
return
true
;
}
return
false
;
},
setdialog
()
{
this
.
isdialog
=
true
;
...
...
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