提交 0e65b3d2 编写于 作者: 钟一霄's avatar 钟一霄

签到功能、换班功能、领导值班日志功能 20231121

上级 a55af60a
...@@ -23,3 +23,4 @@ dist-ssr ...@@ -23,3 +23,4 @@ dist-ssr
*.sln *.sln
*.sw? *.sw?
*.zip *.zip
*.rar
...@@ -66,6 +66,11 @@ export function GetWatchInfo(data) { ...@@ -66,6 +66,11 @@ export function GetWatchInfo(data) {
return requestGet(`/api/Watch/api/Watch/GetWatchInfo?id=${data.id}`, 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) { ...@@ -86,6 +91,10 @@ export function SignLogSave(data) {
//填写日志 //填写日志
return requestGet(`/api/SignRecord/api/SignRecord/SignLogSave?signId=${data.signId}&content=${data.content}`, 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 * Attendance
...@@ -94,6 +103,22 @@ export function GetAttendanceList() { ...@@ -94,6 +103,22 @@ export function GetAttendanceList() {
//获取考勤列表 //获取考勤列表
return requestGet(`/api/Attendance/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}`)
}
/** /**
* 微信 * 微信
......
...@@ -6,7 +6,7 @@ import 'animate.css' //引入 ...@@ -6,7 +6,7 @@ import 'animate.css' //引入
import VueCookies from 'vue-cookies' import VueCookies from 'vue-cookies'
import VConsole from 'vconsole'; import VConsole from 'vconsole';
const app = createApp(App) const app = createApp(App)
const vConsole = new VConsole(); // const vConsole = new VConsole();
app.config.globalProperties.$cookies = VueCookies app.config.globalProperties.$cookies = VueCookies
app.use(router) app.use(router)
app.mount('#app') app.mount('#app')
...@@ -75,6 +75,11 @@ ...@@ -75,6 +75,11 @@
</template> </template>
</van-cell> </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">--> <!-- <van-cell class="cardContent">-->
<!-- <template #value>--> <!-- <template #value>-->
<!-- <van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">日志</van-button>--> <!-- <van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">日志</van-button>-->
...@@ -86,8 +91,24 @@ ...@@ -86,8 +91,24 @@
</van-list> </van-list>
</van-pull-refresh> </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> </template>
<style> <style scoped lang="less">
.container { .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; //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 @@ ...@@ -98,9 +119,9 @@
background-color: #ffffff; background-color: #ffffff;
height: 20%; height: 20%;
.cardContent { // .cardContent {
//height: 150px; // height: 150px;
} // }
} }
.cardContainer:nth-last-child(1) { .cardContainer:nth-last-child(1) {
...@@ -114,7 +135,9 @@ import _ from 'lodash'; ...@@ -114,7 +135,9 @@ import _ from 'lodash';
import * as api from '../../api/index.js'; import * as api from '../../api/index.js';
import {ref, reactive, onMounted, watch} from 'vue'; import {ref, reactive, onMounted, watch} from 'vue';
import dayjs from 'dayjs'; 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(); const onClickLeft = () => history.back();
let myDuty = reactive({ let myDuty = reactive({
...@@ -136,6 +159,17 @@ const list = ref([]); ...@@ -136,6 +159,17 @@ const list = ref([]);
const loading = ref(false); const loading = ref(false);
const finished = ref(false); const finished = ref(false);
let searchValue = ref('') 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) => { watch([searchValue, () => myDuty.watchtypeid, () => myDuty.watch_hour_id, () => myDuty.campusid, () => myDuty.dept_id], (newValue, oldValue) => {
console.log("🚀🚀🚀,", newValue[0], newValue[1]) console.log("🚀🚀🚀,", newValue[0], newValue[1])
...@@ -264,7 +298,69 @@ const getSearchSelectListPromiseAllAction = (publicName, title, objectAttribute, ...@@ -264,7 +298,69 @@ const getSearchSelectListPromiseAllAction = (publicName, title, objectAttribute,
resolve(array) 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(() => { onMounted(() => {
addDutySearchSelectList() addDutySearchSelectList()
// 获取当前用户信息
userInfo.value = JSON.parse(Cookies.get('userInfo'))
}) })
</script> </script>
...@@ -112,20 +112,42 @@ ...@@ -112,20 +112,42 @@
<template #extra> <template #extra>
<van-text-ellipsis :rows="1" :content="item.content" expand-text="展开" collapse-text="收起"/> <van-text-ellipsis :rows="1" :content="item.content" expand-text="展开" collapse-text="收起"/>
</template> </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>
<van-cell <van-cell
class="cardContent" class="cardContent"
title="签到" title="签到"
v-if="item.card_name == userInfo.card_number && item.sign_type != 0"> 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-icon name="edit" />
签到 {{ `${item.sign == 0 ? '签到' : '签退'}` }}
</van-button> </van-button> -->
<van-button type="success" v-if="item.sign_type == 2" size="small" :disabled="signBtDis(item) && signIOO >= 2" @click="locSignIn(item)"> <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" /> <van-icon name="edit" />
签到 {{ `${item.sign == 0 ? '签到' : '签退'}` }}
</van-button> </van-button>
<span v-else>签到完成</span>
<!-- <van-button type="danger" @click="changeSignTimeTest(item)">测试用,修改签到时间限制</van-button> -->
</van-cell> </van-cell>
<!-- <van-cell class="cardContent" style="display: flex;flex-wrap: nowrap;align-items: center"> <!-- <van-cell class="cardContent" style="display: flex;flex-wrap: nowrap;align-items: center">
...@@ -161,6 +183,48 @@ ...@@ -161,6 +183,48 @@
</van-list> </van-list>
</van-pull-refresh> </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> </template>
<style scoped lang="less"> <style scoped lang="less">
.a { .a {
...@@ -201,9 +265,9 @@ ...@@ -201,9 +265,9 @@
background-color: #ffffff; background-color: #ffffff;
height: 20%; height: 20%;
.cardContent { // .cardContent {
//height: 150px; // height: 150px;
} // }
} }
.cardContainer:nth-last-child(1) { .cardContainer:nth-last-child(1) {
...@@ -217,7 +281,7 @@ import _ from 'lodash'; ...@@ -217,7 +281,7 @@ import _ from 'lodash';
import * as api from '../../api/index.js'; import * as api from '../../api/index.js';
import {ref, reactive, onMounted, watch, computed, onUnmounted} from 'vue'; import {ref, reactive, onMounted, watch, computed, onUnmounted} from 'vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import {showToast, showDialog} from "vant"; import {showToast, showDialog, ActionSheet, closeToast, showSuccessToast, showFailToast} from "vant";
import Cookies from 'js-cookie' import Cookies from 'js-cookie'
import wx from "weixin-js-sdk" import wx from "weixin-js-sdk"
import $ from "jquery"; import $ from "jquery";
...@@ -257,6 +321,11 @@ const dateConfig = reactive({ ...@@ -257,6 +321,11 @@ const dateConfig = reactive({
minute: '2-digit', minute: '2-digit',
second: '2-digit', second: '2-digit',
}) })
const dateConfigTime = reactive({
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
// 定位用↓ // 定位用↓
const PI = ref(3.1415926535897932384626) const PI = ref(3.1415926535897932384626)
...@@ -269,11 +338,21 @@ const address = ref('') ...@@ -269,11 +338,21 @@ const address = ref('')
const timer = ref({}) const timer = ref({})
// 是否允许打卡 // 是否允许打卡
const allowSignIn = ref(false) const allowSignIn = ref(false)
// 签到/签退 1.签到 2.签退 // 点击签到的obj和考勤地点的obj
const signIOO = ref(1) 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) => { 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]) { if (newValue[0] || newValue[1] || newValue[2] || newValue[3] || newValue[4]) {
clearTimeout(signList.deleteSetTimeOut) clearTimeout(signList.deleteSetTimeOut)
signList.deleteSetTimeOut = setTimeout(async () => { signList.deleteSetTimeOut = setTimeout(async () => {
...@@ -437,23 +516,23 @@ function initWxPosition() { ...@@ -437,23 +516,23 @@ function initWxPosition() {
timestamp: data.timeStamp, // 必填,生成签名的时间戳 timestamp: data.timeStamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串 nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名,见附录1 signature: data.signature, // 必填,签名,见附录1
jsApiList: ["getLocation"], jsApiList: ["getLocation", "getLocalImgData", "chooseImage"], // 必填,需要使用的JS接口列表
}); });
wx.ready(() => { wx.ready(() => {
console.log('wx.ready') // console.log('wx.ready')
// 判断当前客户端版本是否支持指定JS接口 // 判断当前客户端版本是否支持指定JS接口
wx.checkJsApi({ // wx.checkJsApi({
jsApiList: ['chooseImage'], // 需要检测的JS接口列表,所有JS接口列表见附录2, // jsApiList: ['chooseImage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: function(res) { // success: function(res) {
// 以键值对的形式返回,可用的api值true,不可用为false // // 以键值对的形式返回,可用的api值true,不可用为false
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"} // // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
console.log('支持的接口', res) // console.log('支持的接口', res)
} // }
}); // });
console.log('开始获取定位') // console.log('开始获取定位')
getAddress() getAddress()
timer.value = setInterval(() => { timer.value = setInterval(() => {
getAddress() getAddress()
...@@ -478,8 +557,14 @@ function getAddress() { ...@@ -478,8 +557,14 @@ function getAddress() {
geocoder(wgs84Loc[1], wgs84Loc[0]);// 地址解析 geocoder(wgs84Loc[1], wgs84Loc[0]);// 地址解析
// 判断是否进入考勤地点 // 判断是否进入考勤地点
if (attendanceList.value.some(a => latlngDiff(wdNow.value, jdNow.value, a.latitude, a.longitude) < a.offset)) { if (attendanceList.value.some(a => {
console.log('进入考勤地点') 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 allowSignIn.value = true
} }
resolve() resolve()
...@@ -489,9 +574,9 @@ function getAddress() { ...@@ -489,9 +574,9 @@ function getAddress() {
title: '定位失败', title: '定位失败',
message: '请检查是否已打开手机定位功能、授权微信APP定位权限、授权公众号使用定位等', message: '请检查是否已打开手机定位功能、授权微信APP定位权限、授权公众号使用定位等',
theme: 'round-button', theme: 'round-button',
}).then(() => { })/*.then(() => {
clearInterval(that.intervalBox2); clearInterval(that.intervalBox2);
}); });*/
} }
}); });
}) })
...@@ -499,7 +584,7 @@ function getAddress() { ...@@ -499,7 +584,7 @@ function getAddress() {
} }
// 地址解析 // 地址解析
function geocoder(latitude, longitude) { function geocoder(latitude, longitude) {
var that = this; // var that = this;
var ll = latitude + "," + longitude; var ll = latitude + "," + longitude;
$.ajax({ $.ajax({
type: "get", type: "get",
...@@ -531,7 +616,7 @@ function geocoder(latitude, longitude) { ...@@ -531,7 +616,7 @@ function geocoder(latitude, longitude) {
} }
}, },
error: function (err) { error: function (err) {
console.log(err); // console.log(err);
showDialog({ showDialog({
title: '地址解析错误', title: '地址解析错误',
message: JSON.stringify(err), message: JSON.stringify(err),
...@@ -600,7 +685,7 @@ function latlngDiff(lat1, lng1, lat2, lng2) { ...@@ -600,7 +685,7 @@ function latlngDiff(lat1, lng1, lat2, lng2) {
s = s * 6378137.0; // 取WGS84标准参考椭球中的地球长半径(单位:m) s = s * 6378137.0; // 取WGS84标准参考椭球中的地球长半径(单位:m)
s = Math.round(s * 10000) / 10000; s = Math.round(s * 10000) / 10000;
} }
console.log('定位距离',s); // console.log('定位距离',s);
return s; return s;
} }
function Rad(d) { function Rad(d) {
...@@ -609,58 +694,181 @@ function Rad(d) { ...@@ -609,58 +694,181 @@ function Rad(d) {
// 签到按钮禁用计算属性 // 签到按钮禁用计算属性
const signBtDis = computed(() => function (obj) { 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).split('/').join('-')
let nowDate = new Date().toLocaleDateString('zh-CN', dateConfig) // let nowDate = new Date().toLocaleDateString('zh-CN', dateConfig)
let signInDate = new Date(obj.sign_in_time) // let signInTime = new Date(obj.sign_in_time).toLocaleDateString('zh-CN', dateConfig)
let signOutDate = new Date(obj.sign_out_time) // let signOutTime = new Date(obj.sign_out_time).toLocaleDateString('zh-CN', dateConfig)
signInDate.setMinutes(signInDate.getMinutes() + 30) let nowDate = dayjs()
signOutDate.setMinutes(signOutDate.getMinutes() + 30) let signInTime = dayjs(obj.sign_in_time)
let signInDateStr = signInDate = signInDate.toLocaleDateString('zh-CN', dateConfig) let signOutTime = dayjs(obj.sign_out_time)
let signOutDateStr = signOutDate = signOutDate.toLocaleDateString('zh-CN', dateConfig) return !(obj.sign == 0 ? (nowDate > signInTime /*&& nowDate < signOutTime*/) : obj.sign == 1 ? (nowDate > signOutTime) : false)
// nowDate = nowDate.slice(0, nowDate.length - 3)
return !(nowDate > signInDateStr && nowDate < signOutDateStr)
}) })
// 定位签到 // 定位签到
function locSignIn(obj) { function locSignIn(obj) {
console.log('定位签到') signObj.value = Object.assign({}, obj)
if (obj.sign_type == 1) {
// 不需要定位拍照的签到
signAcStShow.value = true
return
}
if (allowSignIn.value) { 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 = { } else {
url: window.location.href.replace(window.location.hash, ""), // console.log('不在签到范围')
}; showToast({
var urla = `${window.location.origin}/wx/eicrs/api/GetJSSDK/GetWxConfig` message: "不在签到范围"
api.GetWxInfo(urla, params).then((result) => { })
console.log('GetWxInfo!!!!!!!!!') }
let data = result; }
wx.config({ // 微信图片上传到本地
// beta: true, function getWxImgX(localId, date) {
debug: false, showToast({
appId: data.appId, // 必填,公众号的唯一标识 message: "加载中...",
timestamp: data.timeStamp, // 必填,生成签名的时间戳 duration: 0,
nonceStr: data.nonceStr, // 必填,生成签名的随机串 forbidClick: true,
signature: data.signature, // 必填,签名,见附录1 loadingType: "spinner",
jsApiList: ["getLocation"], 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(() => { const name = `image.${localData.split(";")[0].split(":")[1].split("/")[1]}`;
wx.chooseImage({
count: 1, let fileBlob = new Blob([new Uint8Array(data)], { type: type });
sizeType: ['original'], const file = new File([fileBlob], name, { type: type });
sourceType: ['album', 'camera'], afterRead(file, localId, date);
success(res) { },
var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片 error: function (e) {
console.log('拍照之后', res) 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(() => { onMounted(() => {
addDutySearchSelectList() addDutySearchSelectList()
...@@ -675,10 +883,10 @@ onMounted(() => { ...@@ -675,10 +883,10 @@ onMounted(() => {
}) })
// 获取当前用户信息 // 获取当前用户信息
// console.log('获取当前用户信息', JSON.parse(Cookies.get('userInfo')))
userInfo.value = JSON.parse(Cookies.get('userInfo')) userInfo.value = JSON.parse(Cookies.get('userInfo'))
// console.log('获取当前用户信息', userInfo.value)
}) })
onUnmounted(() => { onUnmounted(() => {
setInterval(timer) clearInterval(timer.value)
}) })
</script> </script>
...@@ -65,6 +65,8 @@ axiosInstance.interceptors.request.use( ...@@ -65,6 +65,8 @@ axiosInstance.interceptors.request.use(
// 在发送请求之前可以进行一些处理,例如添加认证信息、日志等 // 在发送请求之前可以进行一些处理,例如添加认证信息、日志等
let token = Cookies.get('admin-token') let token = Cookies.get('admin-token')
config.headers['Authorization'] = 'Bearer ' + token config.headers['Authorization'] = 'Bearer ' + token
if (config.url.indexOf('ImageUpLoad') != -1)
config.headers['Content-Type'] = 'multipart/form-data'
refreshTokenAction() refreshTokenAction()
return config; return config;
}, },
......
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或