Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
D
dutyManagement
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
刘英杰
dutyManagement
提交
0e65b3d2
提交
0e65b3d2
编写于
11月 22, 2023
作者:
钟一霄
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
签到功能、换班功能、领导值班日志功能 20231121
上级
a55af60a
变更
6
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
413 行增加
和
81 行删除
+413
-81
.gitignore
.gitignore
+1
-0
index.js
src/api/index.js
+25
-0
main.js
src/main.js
+1
-1
index.vue
src/pages/myDuty/index.vue
+101
-5
index.vue
src/pages/signList/index.vue
+283
-75
axios.js
src/util/axios.js
+2
-0
未找到文件。
.gitignore
浏览文件 @
0e65b3d2
...
...
@@ -23,3 +23,4 @@ dist-ssr
*.sln
*.sw?
*.zip
*.rar
src/api/index.js
浏览文件 @
0e65b3d2
...
...
@@ -66,6 +66,11 @@ export function GetWatchInfo(data) {
return
requestGet
(
`/api/Watch/api/Watch/GetWatchInfo?id=
${
data
.
id
}
`
,
data
)
}
export
function
WatchInfoSaveOneSelf
(
id
,
card_name
)
{
//给自己换班
return
requestGet
(
`/api/Watch/api/Watch/WatchInfoSaveOneSelf?id=
${
id
}
&card_name=
${
card_name
}
`
)
}
/***
*
* 签到列表
...
...
@@ -86,6 +91,10 @@ export function SignLogSave(data) {
//填写日志
return
requestGet
(
`/api/SignRecord/api/SignRecord/SignLogSave?signId=
${
data
.
signId
}
&content=
${
data
.
content
}
`
,
data
)
}
export
function
LeadLogInit
(
signid
)
{
//领导日志初始化
return
requestGet
(
`/api/SignRecord/api/SignRecord/LeadLogInit?signid=
${
signid
}
`
)
}
/**
* Attendance
...
...
@@ -94,6 +103,22 @@ export function GetAttendanceList() {
//获取考勤列表
return
requestGet
(
`/api/Attendance/GetAttendanceList`
)
}
export
function
ImageUpLoad
(
data
)
{
//照片上传
return
requestPost
(
`/api/Attendance/ImageUpLoad`
,
data
)
}
export
function
AttendanceSubmit
(
data
)
{
//考勤打卡
return
requestPost
(
`/api/Attendance/AttendanceSubmit`
,
data
)
}
/**
* UserInfo
*/
export
function
GetUserSelect
(
condition
)
{
//获取用户信息(选项框)
return
requestGet
(
`/api/UserInfo/api/UserInfo/GetUserSelect?condition=
${
condition
}
`
)
}
/**
* 微信
...
...
src/main.js
浏览文件 @
0e65b3d2
...
...
@@ -6,7 +6,7 @@ import 'animate.css' //引入
import
VueCookies
from
'
vue-cookies
'
import
VConsole
from
'
vconsole
'
;
const
app
=
createApp
(
App
)
const
vConsole
=
new
VConsole
();
//
const vConsole = new VConsole();
app
.
config
.
globalProperties
.
$cookies
=
VueCookies
app
.
use
(
router
)
app
.
mount
(
'
#app
'
)
src/pages/myDuty/index.vue
浏览文件 @
0e65b3d2
...
...
@@ -75,6 +75,11 @@
</
template
>
</van-cell>
<van-cell
v-if=
"item.card_name == userInfo.card_number"
class=
""
title=
"换班"
>
<
template
#value
>
<van-button
plain
type=
"warning"
size=
"small"
@
click=
"pickerChgSftOpen(item)"
>
换班
</van-button>
</
template
>
</van-cell>
<!-- <van-cell class="cardContent">-->
<!-- <template #value>-->
<!-- <van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">日志</van-button>-->
...
...
@@ -86,8 +91,24 @@
</van-list>
</van-pull-refresh>
<!-- 换班人员选择器 -->
<van-popup
v-model:show=
"changeShiftsPickerShow"
round
position=
"bottom"
>
<!-- 搜索框 -->
<van-search
v-model=
"changeSftInput"
placeholder=
"请输入姓名或工号"
@
update:model-value=
"searchChange"
/>
<!-- 选择器 -->
<van-picker
:columns=
"userList"
:loading=
"pickerLoading"
@
cancel=
"pickerCancel"
@
confirm=
"pickerConfirm"
/>
</van-popup>
</template>
<
style
>
<
style
scoped
lang=
"less"
>
.container {
//box-sizing: border-box; //background-color: #706c6c; //width: 100%; //height: 100%; //min-height: 896px; //display: flex; //flex-wrap: wrap; //justify-content: center; //align-content: flex-start;
...
...
@@ -98,9 +119,9 @@
background-color: #ffffff;
height: 20%;
.cardContent
{
//
height
:
150px
;
}
//
.cardContent {
//
height: 150px;
//
}
}
.cardContainer:nth-last-child(1) {
...
...
@@ -114,7 +135,9 @@ import _ from 'lodash';
import
*
as
api
from
'
../../api/index.js
'
;
import
{
ref
,
reactive
,
onMounted
,
watch
}
from
'
vue
'
;
import
dayjs
from
'
dayjs
'
;
import
{
showToast
}
from
"
vant
"
;
import
'
vant/es/dialog/style
'
import
{
showToast
,
showSuccessToast
,
showFailToast
,
showConfirmDialog
}
from
"
vant
"
;
import
Cookies
from
'
js-cookie
'
const
onClickLeft
=
()
=>
history
.
back
();
let
myDuty
=
reactive
({
...
...
@@ -136,6 +159,17 @@ const list = ref([]);
const
loading
=
ref
(
false
);
const
finished
=
ref
(
false
);
let
searchValue
=
ref
(
''
)
const
userInfo
=
ref
({})
// 选中值班obj
const
attendanceObj
=
ref
({})
// 换班选择器显示
const
changeShiftsPickerShow
=
ref
(
false
)
// 搜索条件
const
changeSftInput
=
ref
(
''
)
// 换班选择器列表
const
userList
=
ref
([])
const
pickerLoading
=
ref
(
false
)
watch
([
searchValue
,
()
=>
myDuty
.
watchtypeid
,
()
=>
myDuty
.
watch_hour_id
,
()
=>
myDuty
.
campusid
,
()
=>
myDuty
.
dept_id
],
(
newValue
,
oldValue
)
=>
{
console
.
log
(
"
🚀🚀🚀,
"
,
newValue
[
0
],
newValue
[
1
])
...
...
@@ -264,7 +298,69 @@ const getSearchSelectListPromiseAllAction = (publicName, title, objectAttribute,
resolve
(
array
)
})
}
// 打开换班选择器
function
pickerChgSftOpen
(
obj
)
{
changeShiftsPickerShow
.
value
=
true
attendanceObj
.
value
=
obj
}
// 搜索值改变
function
searchChange
(
val
)
{
pickerLoading
.
value
=
true
api
.
GetUserSelect
(
val
).
then
(
res
=>
{
// console.log('搜索换班人员', res)
if
(
res
.
code
==
1
)
{
userList
.
value
=
res
.
response
.
map
(
a
=>
{
return
{
...
a
,
text
:
a
.
name
,
value
:
a
.
id
,
}
})
}
else
{
showFailToast
(
res
.
msg_detail
)
}
}).
finally
(()
=>
{
pickerLoading
.
value
=
false
})
}
// 换班选择器确认
function
pickerConfirm
(
val
)
{
// console.log('选择器确认', val)
if
(
val
.
selectedOptions
[
0
]
==
undefined
)
{
// 未选择人员
showToast
(
'
请选择换班人员
'
)
return
}
showConfirmDialog
({
title
:
'
提示
'
,
message
:
'
是否确认换班?
'
,
}).
then
(()
=>
{
let
id
=
attendanceObj
.
value
.
watchid
let
card_name
=
val
.
selectedOptions
[
0
].
id
api
.
WatchInfoSaveOneSelf
(
id
,
card_name
).
then
(
res
=>
{
// console.log('换班请求', res)
if
(
res
.
code
==
1
)
{
showSuccessToast
(
res
.
response
)
changeShiftsPickerShow
.
value
=
false
onLoad
()
}
else
{
showFailToast
(
res
.
msg_detail
)
}
})
}).
catch
(()
=>
{
})
}
// 换班选择器取消
function
pickerCancel
()
{
changeShiftsPickerShow
.
value
=
false
}
onMounted
(()
=>
{
addDutySearchSelectList
()
// 获取当前用户信息
userInfo
.
value
=
JSON
.
parse
(
Cookies
.
get
(
'
userInfo
'
))
})
</
script
>
src/pages/signList/index.vue
浏览文件 @
0e65b3d2
...
...
@@ -112,20 +112,42 @@
<
template
#extra
>
<van-text-ellipsis
:rows=
"1"
:content=
"item.content"
expand-text=
"展开"
collapse-text=
"收起"
/>
</
template
>
<
template
#value
>
<van-button
v-if=
"item.card_name == userInfo.card_number && userInfo.role[0].indexOf('值班领导') != -1"
type=
"primary"
size=
"small"
@
click=
"leadLog(item)"
>
查看日志
</van-button>
</
template
>
</van-cell>
<van-cell
class=
"cardContent"
title=
"签到"
v-if=
"item.card_name == userInfo.card_number && item.sign_type != 0"
>
<van-button
type=
"primary"
v-if=
"item.sign_type == 1"
size=
"small"
:disabled=
"signBtDis(item) && signIOO <= 2"
>
<!-- <van-button
v-if="item.sign_type == 1 && item.sign < 2"
plain
size="small"
:type="item.sign == 0 ? 'success' : 'primary'"
:disabled="signBtDis(item)"
@click="signBt(item)">
<van-icon name="edit" />
签到
</van-button>
<van-button
type=
"success"
v-if=
"item.sign_type == 2"
size=
"small"
:disabled=
"signBtDis(item) && signIOO >= 2"
@
click=
"locSignIn(item)"
>
{{ `${item.sign == 0 ? '签到' : '签退'}` }}
</van-button> -->
<van-button
v-if=
"item.sign < 2"
size=
"small"
:plain=
"item.sign_type == 1"
:type=
"item.sign == 0 ? 'success' : 'primary'"
:disabled=
"signBtDis(item)"
@
click=
"locSignIn(item)"
>
<van-icon
name=
"edit"
/>
签到
{{ `${item.sign == 0 ? '签到' : '签退'}` }}
</van-button>
<span
v-else
>
签到完成
</span>
<!-- <van-button type="danger" @click="changeSignTimeTest(item)">测试用,修改签到时间限制</van-button> -->
</van-cell>
<!-- <van-cell class="cardContent" style="display: flex;flex-wrap: nowrap;align-items: center">
...
...
@@ -161,6 +183,48 @@
</van-list>
</van-pull-refresh>
<!-- 定位打卡签到 -->
<van-action-sheet
v-model:show=
"signAcStShow"
ref=
"VAS"
style=
"height: 80%;"
:close-on-click-overlay=
"false"
:title=
"signObj.sign == 0 ? '签到' : '签退'"
>
<div
style=
"padding: 16px;"
>
<div
style=
"width: 80%; margin: auto;"
>
<img
style=
"width: 100%;"
:src=
"signImgUrl"
/>
</div>
<van-sticky
container=
"VAS"
position=
"bottom"
:offset-bottom=
"16"
>
<van-button
:type=
"signObj.sign == 0 ? 'success' : 'primary'"
block
@
click=
"signBt(signObj)"
>
{{ `${signObj.sign == 0 ? '签到' : '签退'}` }}
</van-button>
</van-sticky>
</div>
</van-action-sheet>
<!-- 领导查看日志 -->
<van-action-sheet
v-model:show=
"logAcStShow"
ref=
"VASLog"
style=
"height: 80%;"
title=
"值班日志"
:close-on-click-overlay=
"false"
>
<div
style=
"padding: 16px;"
>
<van-field
id=
"teacherLog"
v-model=
"allLog"
readonly
autosize
label=
"教师日志"
label-align=
"top"
type=
"textarea"
/>
<van-sticky
container=
"VAS"
position=
"bottom"
:offset-bottom=
"16"
>
<van-button
type=
"primary"
block
@
click=
"copyLog"
>
复制
</van-button>
</van-sticky>
</div>
</van-action-sheet>
</template>
<
style
scoped
lang=
"less"
>
.a {
...
...
@@ -201,9 +265,9 @@
background-color: #ffffff;
height: 20%;
.cardContent {
//height: 150px;
}
//
.cardContent {
//
height: 150px;
//
}
}
.cardContainer:nth-last-child(1) {
...
...
@@ -217,7 +281,7 @@ import _ from 'lodash';
import
*
as
api
from
'
../../api/index.js
'
;
import
{
ref
,
reactive
,
onMounted
,
watch
,
computed
,
onUnmounted
}
from
'
vue
'
;
import
dayjs
from
'
dayjs
'
;
import
{
showToast
,
showDialog
}
from
"
vant
"
;
import
{
showToast
,
showDialog
,
ActionSheet
,
closeToast
,
showSuccessToast
,
showFailToast
}
from
"
vant
"
;
import
Cookies
from
'
js-cookie
'
import
wx
from
"
weixin-js-sdk
"
import
$
from
"
jquery
"
;
...
...
@@ -257,6 +321,11 @@ const dateConfig = reactive({
minute
:
'
2-digit
'
,
second
:
'
2-digit
'
,
})
const
dateConfigTime
=
reactive
({
hour
:
'
2-digit
'
,
minute
:
'
2-digit
'
,
second
:
'
2-digit
'
,
})
// 定位用↓
const
PI
=
ref
(
3.1415926535897932384626
)
...
...
@@ -269,11 +338,21 @@ const address = ref('')
const
timer
=
ref
({})
// 是否允许打卡
const
allowSignIn
=
ref
(
false
)
// 签到/签退 1.签到 2.签退
const
signIOO
=
ref
(
1
)
// 点击签到的obj和考勤地点的obj
const
signObj
=
ref
({})
const
signPosObj
=
ref
({})
// 拍照打卡ActionSheet显示
const
signAcStShow
=
ref
(
false
)
// 打卡照片url
const
signImgUrl
=
ref
(
''
)
// 查看日志ActionSheet显示
const
logAcStShow
=
ref
(
false
)
// 领导获取的教师日志
const
allLog
=
ref
(
''
)
watch
([
searchValue
,
()
=>
signList
.
watchtypeid
,
()
=>
signList
.
watch_hour_id
,
()
=>
signList
.
campusid
,
()
=>
signList
.
dept_id
,
()
=>
signList
.
checked
],
(
newValue
,
oldValue
)
=>
{
console
.
log
(
"
🚀🚀🚀,
"
,
newValue
[
5
])
//
console.log("🚀🚀🚀,", newValue[5])
if
(
newValue
[
0
]
||
newValue
[
1
]
||
newValue
[
2
]
||
newValue
[
3
]
||
newValue
[
4
])
{
clearTimeout
(
signList
.
deleteSetTimeOut
)
signList
.
deleteSetTimeOut
=
setTimeout
(
async
()
=>
{
...
...
@@ -437,23 +516,23 @@ function initWxPosition() {
timestamp
:
data
.
timeStamp
,
// 必填,生成签名的时间戳
nonceStr
:
data
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
data
.
signature
,
// 必填,签名,见附录1
jsApiList
:
[
"
getLocation
"
],
jsApiList
:
[
"
getLocation
"
,
"
getLocalImgData
"
,
"
chooseImage
"
],
// 必填,需要使用的JS接口列表
});
wx
.
ready
(()
=>
{
console
.
log
(
'
wx.ready
'
)
//
console.log('wx.ready')
// 判断当前客户端版本是否支持指定JS接口
wx
.
checkJsApi
({
jsApiList
:
[
'
chooseImage
'
],
// 需要检测的JS接口列表,所有JS接口列表见附录2,
success
:
function
(
res
)
{
// 以键值对的形式返回,可用的api值true,不可用为false
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
console
.
log
(
'
支持的接口
'
,
res
)
}
});
console
.
log
(
'
开始获取定位
'
)
//
wx.checkJsApi({
//
jsApiList: ['chooseImage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
//
success: function(res) {
//
// 以键值对的形式返回,可用的api值true,不可用为false
//
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
//
console.log('支持的接口', res)
//
}
//
});
//
console.log('开始获取定位')
getAddress
()
timer
.
value
=
setInterval
(()
=>
{
getAddress
()
...
...
@@ -478,8 +557,14 @@ function getAddress() {
geocoder
(
wgs84Loc
[
1
],
wgs84Loc
[
0
]);
// 地址解析
// 判断是否进入考勤地点
if
(
attendanceList
.
value
.
some
(
a
=>
latlngDiff
(
wdNow
.
value
,
jdNow
.
value
,
a
.
latitude
,
a
.
longitude
)
<
a
.
offset
))
{
console
.
log
(
'
进入考勤地点
'
)
if
(
attendanceList
.
value
.
some
(
a
=>
{
let
flag
=
latlngDiff
(
wdNow
.
value
,
jdNow
.
value
,
a
.
latitude
,
a
.
longitude
)
<
a
.
offset
if
(
flag
)
{
signPosObj
.
value
=
a
}
return
flag
}))
{
// console.log('进入考勤地点')
allowSignIn
.
value
=
true
}
resolve
()
...
...
@@ -489,9 +574,9 @@ function getAddress() {
title
:
'
定位失败
'
,
message
:
'
请检查是否已打开手机定位功能、授权微信APP定位权限、授权公众号使用定位等
'
,
theme
:
'
round-button
'
,
}).
then
(()
=>
{
})
/*
.then(() => {
clearInterval(that.intervalBox2);
});
});
*/
}
});
})
...
...
@@ -499,7 +584,7 @@ function getAddress() {
}
// 地址解析
function
geocoder
(
latitude
,
longitude
)
{
var
that
=
this
;
//
var that = this;
var
ll
=
latitude
+
"
,
"
+
longitude
;
$
.
ajax
({
type
:
"
get
"
,
...
...
@@ -531,7 +616,7 @@ function geocoder(latitude, longitude) {
}
},
error
:
function
(
err
)
{
console
.
log
(
err
);
//
console.log(err);
showDialog
({
title
:
'
地址解析错误
'
,
message
:
JSON
.
stringify
(
err
),
...
...
@@ -600,7 +685,7 @@ function latlngDiff(lat1, lng1, lat2, lng2) {
s
=
s
*
6378137.0
;
// 取WGS84标准参考椭球中的地球长半径(单位:m)
s
=
Math
.
round
(
s
*
10000
)
/
10000
;
}
console
.
log
(
'
定位距离
'
,
s
);
//
console.log('定位距离',s);
return
s
;
}
function
Rad
(
d
)
{
...
...
@@ -609,58 +694,181 @@ function Rad(d) {
// 签到按钮禁用计算属性
const
signBtDis
=
computed
(()
=>
function
(
obj
)
{
// console.log('签到按钮类型计算属性', obj
, obj.sign_in_time
)
// console.log('签到按钮类型计算属性', obj)
// let nowDate = new Date().toLocaleDateString('zh-CN', dateConfig).split('/').join('-')
let
nowDate
=
new
Date
().
toLocaleDateString
(
'
zh-CN
'
,
dateConfig
)
let
signInDate
=
new
Date
(
obj
.
sign_in_time
)
let
signOutDate
=
new
Date
(
obj
.
sign_out_time
)
signInDate
.
setMinutes
(
signInDate
.
getMinutes
()
+
30
)
signOutDate
.
setMinutes
(
signOutDate
.
getMinutes
()
+
30
)
let
signInDateStr
=
signInDate
=
signInDate
.
toLocaleDateString
(
'
zh-CN
'
,
dateConfig
)
let
signOutDateStr
=
signOutDate
=
signOutDate
.
toLocaleDateString
(
'
zh-CN
'
,
dateConfig
)
// nowDate = nowDate.slice(0, nowDate.length - 3)
return
!
(
nowDate
>
signInDateStr
&&
nowDate
<
signOutDateStr
)
// let nowDate = new Date().toLocaleDateString('zh-CN', dateConfig)
// let signInTime = new Date(obj.sign_in_time).toLocaleDateString('zh-CN', dateConfig)
// let signOutTime = new Date(obj.sign_out_time).toLocaleDateString('zh-CN', dateConfig)
let
nowDate
=
dayjs
()
let
signInTime
=
dayjs
(
obj
.
sign_in_time
)
let
signOutTime
=
dayjs
(
obj
.
sign_out_time
)
return
!
(
obj
.
sign
==
0
?
(
nowDate
>
signInTime
/*&& nowDate < signOutTime*/
)
:
obj
.
sign
==
1
?
(
nowDate
>
signOutTime
)
:
false
)
})
// 定位签到
function
locSignIn
(
obj
)
{
console
.
log
(
'
定位签到
'
)
signObj
.
value
=
Object
.
assign
({},
obj
)
if
(
obj
.
sign_type
==
1
)
{
// 不需要定位拍照的签到
signAcStShow
.
value
=
true
return
}
if
(
allowSignIn
.
value
)
{
console
.
log
(
'
调用相机
'
)
wx
.
chooseImage
({
count
:
1
,
// 默认9
sizeType
:
[
'
compressed
'
],
// 可以指定是原图还是压缩图,默认二者都有
sourceType
:
[
'
camera
'
],
// 可以指定来源是相册还是相机,默认二者都有
success
:
function
(
res
)
{
var
localIds
=
res
.
localIds
;
// 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
getWxImgX
(
localIds
,
new
Date
())
}
});
const
params
=
{
url
:
window
.
location
.
href
.
replace
(
window
.
location
.
hash
,
""
),
};
var
urla
=
`
${
window
.
location
.
origin
}
/wx/eicrs/api/GetJSSDK/GetWxConfig`
api
.
GetWxInfo
(
urla
,
params
).
then
((
result
)
=>
{
console
.
log
(
'
GetWxInfo!!!!!!!!!
'
)
let
data
=
result
;
wx
.
config
({
// beta: true,
debug
:
false
,
appId
:
data
.
appId
,
// 必填,公众号的唯一标识
timestamp
:
data
.
timeStamp
,
// 必填,生成签名的时间戳
nonceStr
:
data
.
nonceStr
,
// 必填,生成签名的随机串
signature
:
data
.
signature
,
// 必填,签名,见附录1
jsApiList
:
[
"
getLocation
"
],
});
}
else
{
// console.log('不在签到范围')
showToast
({
message
:
"
不在签到范围
"
})
}
}
// 微信图片上传到本地
function
getWxImgX
(
localId
,
date
)
{
showToast
({
message
:
"
加载中...
"
,
duration
:
0
,
forbidClick
:
true
,
loadingType
:
"
spinner
"
,
type
:
"
loading
"
,
});
wx
.
getLocalImgData
({
localId
:
localId
.
pop
(),
success
:
function
(
resp
)
{
var
localData
=
resp
.
localData
;
// localData是图片的base64数据,可以用img标签显示
if
(
localData
.
indexOf
(
"
data:image
"
)
!=
0
)
{
//判断是否有这样的头部
localData
=
"
data:image/jpeg;base64,
"
+
localData
;
}
localData
=
localData
// .replace(/\r|\n/g, "")
.
replace
(
"
data:image/jgp
"
,
"
data:image/jpeg
"
);
const
blobBin
=
atob
(
localData
.
split
(
"
,
"
)[
1
]);
let
data
=
[];
for
(
var
i
=
0
;
i
<
blobBin
.
length
;
i
++
)
{
data
.
push
(
blobBin
.
charCodeAt
(
i
));
}
const
type
=
localData
.
split
(
"
;
"
)[
0
].
split
(
"
:
"
)[
1
];
wx
.
ready
(()
=>
{
wx
.
chooseImage
({
count
:
1
,
sizeType
:
[
'
original
'
],
sourceType
:
[
'
album
'
,
'
camera
'
],
success
(
res
)
{
var
localIds
=
res
.
localIds
;
// 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
console
.
log
(
'
拍照之后
'
,
res
)
}
})
});
const
name
=
`image.
${
localData
.
split
(
"
;
"
)[
0
].
split
(
"
:
"
)[
1
].
split
(
"
/
"
)[
1
]}
`
;
let
fileBlob
=
new
Blob
([
new
Uint8Array
(
data
)],
{
type
:
type
});
const
file
=
new
File
([
fileBlob
],
name
,
{
type
:
type
});
afterRead
(
file
,
localId
,
date
);
},
error
:
function
(
e
)
{
console
.
err
(
'
上传错误
'
,
e
)
},
});
}
// 文件读取完成后的回调函数
function
afterRead
(
file
,
localIds
,
date
)
{
// console.log(localIds);
let
params
=
new
FormData
()
// params.append("time", `${new Date(this.nowTimestamp).getHours()}:${new Date(this.nowTimestamp).getMinutes()}`);
// params.append("date", this.getAPPDate(new Date(this.nowTimestamp)));
let
time
=
date
.
toLocaleDateString
(
'
zh-CN
'
,
dateConfigTime
)
time
=
time
.
slice
(
time
.
length
-
8
)
params
.
append
(
"
time
"
,
time
);
params
.
append
(
"
date
"
,
date
.
toLocaleDateString
(
'
zh-CN
'
,
dateConfig
).
split
(
'
/
'
).
join
(
'
-
'
));
params
.
append
(
"
address
"
,
address
.
value
);
params
.
append
(
"
file
"
,
file
);
api
.
ImageUpLoad
(
params
).
then
(
res
=>
{
// console.log('照片上传后端后', res)
if
(
res
.
code
==
1
)
{
signAcStShow
.
value
=
true
signImgUrl
.
value
=
res
.
response
.
file_path
closeToast
()
}
})
}
// 签到按钮
function
signBt
(
obj
)
{
if
(
obj
.
sign
!=
2
)
{
let
data
=
{
id
:
obj
.
signid
,
link
:
signImgUrl
.
value
,
sign
:
obj
.
sign
==
0
?
1
:
2
,
attendance
:
signPosObj
.
value
,
}
showToast
({
message
:
"
加载中...
"
,
duration
:
0
,
forbidClick
:
true
,
loadingType
:
"
spinner
"
,
type
:
"
loading
"
,
});
api
.
AttendanceSubmit
(
data
).
then
(
res
=>
{
// console.log(res)
if
(
res
.
code
==
1
)
{
closeToast
()
showSuccessToast
(
res
.
response
)
signAcStShow
.
value
=
false
// 重新获取列表
onLoad
()
}
else
{
closeToast
()
showFailToast
(
res
.
msg_detail
)
}
})
}
else
{
console
.
log
(
'
不在签到范围
'
)
}
}
// 测试用,修改签到时间限制
// function changeSignTimeTest(obj) {
// if (obj.sign == 0) {
// obj.sign_in_time = new Date().toLocaleDateString('zh-CN', dateConfig).split('/').join('-')
// } else if (obj.sign == 1) {
// obj.sign_out_time = new Date().toLocaleDateString('zh-CN', dateConfig).split('/').join('-')
// }
// }
// 领导查看日志
function
leadLog
(
obj
)
{
showToast
({
message
:
"
加载中...
"
,
duration
:
0
,
forbidClick
:
true
,
loadingType
:
"
spinner
"
,
type
:
"
loading
"
,
});
logAcStShow
.
value
=
true
api
.
LeadLogInit
(
obj
.
signid
).
then
(
res
=>
{
// console.log(res)
if
(
res
.
code
==
1
)
{
allLog
.
value
=
res
.
response
closeToast
()
}
else
{
closeToast
()
showFailToast
(
res
.
msg_detail
)
}
})
}
// 复制教师日志
function
copyLog
()
{
// 创建input元素
const
el
=
document
.
createElement
(
'
input
'
)
// 给input元素赋值需要复制的文本
el
.
setAttribute
(
'
value
'
,
allLog
.
value
)
// 将input元素插入页面
document
.
body
.
appendChild
(
el
)
// 选中input元素的文本
el
.
select
()
// 复制内容到剪贴板
document
.
execCommand
(
'
copy
'
)
// 删除input元素
document
.
body
.
removeChild
(
el
)
showSuccessToast
(
'
复制成功
'
)
}
onMounted
(()
=>
{
addDutySearchSelectList
()
...
...
@@ -675,10 +883,10 @@ onMounted(() => {
})
// 获取当前用户信息
// console.log('获取当前用户信息', JSON.parse(Cookies.get('userInfo')))
userInfo
.
value
=
JSON
.
parse
(
Cookies
.
get
(
'
userInfo
'
))
// console.log('获取当前用户信息', userInfo.value)
})
onUnmounted
(()
=>
{
setInterval
(
timer
)
clearInterval
(
timer
.
value
)
})
</
script
>
src/util/axios.js
浏览文件 @
0e65b3d2
...
...
@@ -65,6 +65,8 @@ axiosInstance.interceptors.request.use(
// 在发送请求之前可以进行一些处理,例如添加认证信息、日志等
let
token
=
Cookies
.
get
(
'
admin-token
'
)
config
.
headers
[
'
Authorization
'
]
=
'
Bearer
'
+
token
if
(
config
.
url
.
indexOf
(
'
ImageUpLoad
'
)
!=
-
1
)
config
.
headers
[
'
Content-Type
'
]
=
'
multipart/form-data
'
refreshTokenAction
()
return
config
;
},
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录