提交 1e299f4b 编写于 作者: 刘英杰's avatar 刘英杰

整合签到列表代码

上级 63515242
...@@ -17,6 +17,8 @@ dist-ssr ...@@ -17,6 +17,8 @@ dist-ssr
!.vscode/extensions.json !.vscode/extensions.json
.idea .idea
.DS_Store .DS_Store
/node_modules
#/dist
*.suo *.suo
*.ntvs* *.ntvs*
*.njsproj *.njsproj
......
default:
before_script:
- chcp 65001
stages:
- publish
build:
stage: publish
script:
- remove-item -Force -Recurse D:\ASC_web\A00051\dutyManagement\wx*
- xcopy "dist" "D:\ASC_web\A00051\dutyManagement\wx\" /s/e/y/
only:
- wx
import { createApp } from 'vue' import {createApp} from 'vue'
import './style.css' import './style.css'
import App from './App.vue' import App from './App.vue'
import router from "./router/index.js"; import router from "./router/index.js";
import 'animate.css' //引入 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')
...@@ -49,10 +49,10 @@ const getTokenActionWx = async (date) => { ...@@ -49,10 +49,10 @@ const getTokenActionWx = async (date) => {
} }
const getToken = async () => { const getToken = async () => {
if (Number(router.currentRoute.value.query.type) === 2) { if (Number(router.currentRoute.value.query.type) === 2) {
Cookies.set('token', router.currentRoute.value.query.token) // Cookies.set('token', router.currentRoute.value.query.token)
// localStorage.setItem('token', router.currentRoute.value.query.token) // localStorage.setItem('token', router.currentRoute.value.query.token)
let date = { let date = {
token: Cookies.get('token') token: router.currentRoute.value.query.token
} }
await getTokenAction(date) await getTokenAction(date)
} else if (Number(router.currentRoute.value.query.type) === 1) { } else if (Number(router.currentRoute.value.query.type) === 1) {
......
...@@ -39,12 +39,12 @@ const getTokenActionWx = async (date) => { ...@@ -39,12 +39,12 @@ const getTokenActionWx = async (date) => {
Cookies.set('admin-token', res.response.access_token.token_content) Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires) Cookies.set('time', res.response.access_token.expires)
let links = router.currentRoute.value.query.links let links = router.currentRoute.value.query.links
let id = router.currentRoute.value.query.id // let id = router.currentRoute.value.query.id
await router.push({ await router.push({
path: `/${links}`, path: `/${links}`,
query: { // query: {
id: id // id: id
} // }
}) })
} }
} }
...@@ -54,8 +54,8 @@ const getToken = async () => { ...@@ -54,8 +54,8 @@ const getToken = async () => {
let date = { let date = {
token: Cookies.get('token') token: Cookies.get('token')
} }
console.log("🚀🚀🚀,ASC的data", date) // console.log("🚀🚀🚀,ASC的data", date)
console.log("🚀🚀🚀,ASC的token", Cookies.get('token')) // console.log("🚀🚀🚀,ASC的token", Cookies.get('token'))
await getTokenAction(date) await getTokenAction(date)
} else if (Number(router.currentRoute.value.query.type) === 1) { } else if (Number(router.currentRoute.value.query.type) === 1) {
let date = { let date = {
......
...@@ -71,7 +71,7 @@ onMounted(() => { ...@@ -71,7 +71,7 @@ onMounted(() => {
getDutyMessage() getDutyMessage()
}) })
const onClickLeft = () => router.push({ const onClickLeft = () => router.push({
name: 'welcome' name: 'signList'
}); });
</script> </script>
<style> <style>
......
...@@ -37,7 +37,8 @@ ...@@ -37,7 +37,8 @@
<van-dropdown-menu :overlay="false"> <van-dropdown-menu :overlay="false">
<van-dropdown-item @close="closeMenu" :key="myDuty.menuKey" @open="openMenu" title="日期"> <van-dropdown-item @close="closeMenu" :key="myDuty.menuKey" @open="openMenu" title="日期">
<template #default> <template #default>
<van-calendar v-model:show="myDuty.show" type="range" @confirm="dateRange"/> <van-calendar :minDate="myDuty.minDate"
:maxDate="myDuty.maxDate" v-model:show="myDuty.show" type="range" @confirm="dateRange"/>
</template> </template>
</van-dropdown-item> </van-dropdown-item>
<van-dropdown-item v-model="myDuty[item[2]]" v-for="(item,index) in myDuty.addDutySelectList" :key="index" <van-dropdown-item v-model="myDuty[item[2]]" v-for="(item,index) in myDuty.addDutySelectList" :key="index"
...@@ -110,7 +111,7 @@ ...@@ -110,7 +111,7 @@
</template> </template>
<style scoped lang="less"> <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;
.cardContainer { .cardContainer {
...@@ -141,6 +142,8 @@ import Cookies from 'js-cookie' ...@@ -141,6 +142,8 @@ import Cookies from 'js-cookie'
const onClickLeft = () => history.back(); const onClickLeft = () => history.back();
let myDuty = reactive({ let myDuty = reactive({
minDate: new Date(dayjs().year(), dayjs().month() - 1, 1),
maxDate: new Date(dayjs().year(), dayjs().month() + 1, 1),
addDutySelectList: [], addDutySelectList: [],
DatePickerKey: 1, DatePickerKey: 1,
showCenter: false, showCenter: false,
...@@ -243,6 +246,7 @@ const onLoad = async () => { ...@@ -243,6 +246,7 @@ const onLoad = async () => {
"page_size": myDuty.page_size, "page_size": myDuty.page_size,
} }
const res = await api.GetWatchList(data) const res = await api.GetWatchList(data)
// showToast('刷新成功!')
list.value = res.response.data list.value = res.response.data
myDuty.total = res.response.data_count myDuty.total = res.response.data_count
// 异步更新数据 // 异步更新数据
...@@ -254,7 +258,7 @@ const onLoad = async () => { ...@@ -254,7 +258,7 @@ const onLoad = async () => {
// 数据全部加载完成 // 数据全部加载完成
if (list.value.length >= Number(myDuty.total)) { if (list.value.length >= Number(myDuty.total)) {
finished.value = true; finished.value = true;
showToast('加载完成!') // showToast('加载完成!')
} else if (list.value.length < Number(myDuty.total)) { } else if (list.value.length < Number(myDuty.total)) {
myDuty.page_size = myDuty.page_size + 10 myDuty.page_size = myDuty.page_size + 10
...@@ -304,6 +308,7 @@ function pickerChgSftOpen(obj) { ...@@ -304,6 +308,7 @@ function pickerChgSftOpen(obj) {
changeShiftsPickerShow.value = true changeShiftsPickerShow.value = true
attendanceObj.value = obj attendanceObj.value = obj
} }
// 搜索值改变 // 搜索值改变
function searchChange(val) { function searchChange(val) {
pickerLoading.value = true pickerLoading.value = true
...@@ -324,6 +329,7 @@ function searchChange(val) { ...@@ -324,6 +329,7 @@ function searchChange(val) {
pickerLoading.value = false pickerLoading.value = false
}) })
} }
// 换班选择器确认 // 换班选择器确认
function pickerConfirm(val) { function pickerConfirm(val) {
// console.log('选择器确认', val) // console.log('选择器确认', val)
...@@ -352,6 +358,7 @@ function pickerConfirm(val) { ...@@ -352,6 +358,7 @@ function pickerConfirm(val) {
}) })
} }
// 换班选择器取消 // 换班选择器取消
function pickerCancel() { function pickerCancel() {
changeShiftsPickerShow.value = false changeShiftsPickerShow.value = false
......
<template>
<van-pull-refresh v-model="signList.loading" @refresh="onRefresh">
<van-floating-bubble
axis="xy"
icon="chat"
magnetic="x"
:gap="35"
@click="batch(1)"
v-if="signList.floatingBubble"
>
<template v-slot:default>
<div>批量签</div>
</template>
</van-floating-bubble>
<van-floating-bubble
axis="xy"
icon="chat"
magnetic="x"
@click="batch(2)"
:gap="0"
v-if="signList.floatingBubble"
>
<template v-slot:default>
<div>批量休</div>
</template>
</van-floating-bubble>
<div style="position: fixed;z-index: 2;width: 100%">
<!-- &lt;!&ndash; 圆角弹窗(居中) &ndash;&gt;-->
<van-popup v-model:show="signList.showCenter" round style="width: 100%; padding: 10px;">
<template v-slot:default>
<van-field
v-model="signList.message"
rows="2"
autosize
clearable
type="textarea"
maxlength="100"
placeholder="请输入日志"
show-word-limit
/>
<div style="float: right">
<van-button icon="close" size="small" style="margin-right: 10px" @click="signList.showCenter = false">取消
</van-button>
<van-button @click="submitLog" type="primary" icon="passed" size="small" style="margin-right: 10px">提交
</van-button>
</div>
</template>
</van-popup>
<van-nav-bar
title="签到列表"
left-text="返回"
left-arrow
@click-left="onClickLeft"
>
<template v-slot:title><span style="margin-right: 20vw">签到列表</span></template>
<template v-slot:right>
<van-tabs v-model:active="signList.is_lead" shrink type="card" @click-tab="tabs">
<van-tab title="教师">
<template v-slot:title>
<span style="">值班教师</span>
</template>
</van-tab>
<van-tab title="领导">
<template v-slot:title>
<span style="">值班领导</span>
</template>
</van-tab>
</van-tabs>
</template>
</van-nav-bar>
<van-search
v-model="searchValue"
shape="round"
placeholder="请输入搜索关键词"
/>
<van-dropdown-menu :overlay="false">
<van-dropdown-item v-model="signList.sign" title="状态"
:options="signList.signClass"></van-dropdown-item>
<van-dropdown-item @close="closeMenu" :key="signList.menuKey" @open="openMenu" title="日期">
<template #default>
<van-calendar :max-date="signList.maxDate" :minDate="signList.minDate" v-model:show="signList.show"
type="range" @confirm="dateRange"/>
</template>
</van-dropdown-item>
<van-dropdown-item v-model="signList[item[2]]" v-for="(item,index) in signList.addDutySelectList" :key="index"
:title="item[1]" :options="item[0]"/>
</van-dropdown-menu>
</div>
<van-list
class="container"
@load="onLoad"
direction="down"
:finished="finished"
offset="600"
>
<div style="width: 100%;height: 150px"></div>
<!-- <van-cell/>-->
<van-cell-group inset class="cardContainer" v-for="(item,index) in list" :key="index">
<van-cell class="cardContent" :title="item.username">
<template #extra>
<van-tag type="primary" plain><span>{{ item.card_name }}</span></van-tag>
<van-tag color="#7232dd" type="primary" plain style="margin-left: 10px">{{ item.mobile }}</van-tag>
<!-- <van-tag :color="['','#7232dd'][item.is_lead]" type="primary" plain style="margin-left: 10px">-->
<!-- <span>{{ ['值班教师', '值班领导'][item.is_lead] }}</span></van-tag>-->
</template>
</van-cell>
<van-cell class="cardContent" title="日期">
<template #extra>
<van-tag type="primary" plain><span>{{ item.watch_date }}</span></van-tag>
<van-tag v-if="item.mobile!==''" type="primary" plain style="margin-left: 10px">
<span>{{ item.watch_hour_time }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="类型">
<template #extra>
<van-tag type="primary" plain>
<span>{{ item.watchtypename + '-' + item.campusname }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent">
<template #title>
<span>日志</span>
</template>
<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
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" />
{{ `${item.sign == 0 ? '签到' : '签退'}` }}
</van-button> -->
<van-button
v-if="item.sign !== 0 && item.sign !==2"
size="small"
:disabled="true"
style="margin-right: 10px;"
>
<van-icon name="edit"/>
{{ `${item.sign == 1 ? '已签到' : ''}` }}
</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">
<template #value>
<div style="display: flex;flex-wrap: nowrap;align-items: center">
<van-checkbox-group v-model="signList.checked">
<van-checkbox :disabled="item.sign=== 2 || item.sign_set === 1 || signList.authUserInfo === -1"
v-model="item.signid" :name="item.signid"></van-checkbox>
</van-checkbox-group>
<div style="margin-left: auto">
<van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">
日志
</van-button>
<van-button @click="sign(item,2)"
v-if="item.sign === 1 && item.sign_set === 0 && signList.authUserInfo!== -1" type="warning"
icon="guide-o" size="small" style="margin-right: 10px">签退
</van-button>
<van-button @click="sign(item,1)"
v-if="item.sign === 0 && item.sign_set === 0 && signList.authUserInfo!== -1" type="success"
icon="passed" size="small" style="margin-right: 10px">签到
</van-button>
<van-button :disabled="item.sign === 2" v-if="item.sign === 2" size="small" style="margin-right: 10px">
<van-icon name="passed" style=" margin-left: 5px;color: #23da6f"/>
完成考勤
</van-button>
</div>
</div>
</template>
</van-cell> -->
</van-cell-group>
<div style="width: 100%;height: 100px"></div>
</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 {
margin-bottom: 50px;
}
.van-floating-bubble {
position: fixed;
left: -81px;
top: 10px;
right: var(--van-floating-bubble-initial-gap);
bottom: -81px;
width: var(--van-floating-bubble-size);
height: var(--van-floating-bubble-size);
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
touch-action: none;
background: var(--van-floating-bubble-background);
color: var(--van-floating-bubble-color);
border-radius: var(--van-floating-bubble-border-radius);
z-index: var(--van-floating-bubble-z-index);
transition: transform var(--van-duration-base);
}
.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;
.cardContainer {
margin-top: 10px;
width: 95%;
background-color: #ffffff;
height: 20%;
// .cardContent {
// height: 150px;
// }
}
.cardContainer:nth-last-child(1) {
background-color: red;
}
}
</style>
<script setup>
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, ActionSheet, closeToast, showSuccessToast, showFailToast} from "vant";
import Cookies from 'js-cookie'
import wx from "weixin-js-sdk"
import $ from "jquery";
import {useRouter} from "vue-router";
let active = ref(1)
let signList = reactive({
minDate: new Date(dayjs().year(), dayjs().month() - 1, 1),
maxDate: new Date(dayjs().year(), dayjs().month() + 1, 1),
sign: 9,
signClass: [
{
text: '全部状态',
value: 9
},
{
text: '待签到',
value: "0"
},
{
text: '已签到',
value: 1
},
{
text: '已签退',
value: 2
},
],
addDutySelectList: [],
DatePickerKey: 1,
showCenter: false,
message: '',
show: false,
startTime: dayjs().startOf('day').format('YYYY-MM-DD'),
endTime: dayjs().startOf('day').format('YYYY-MM-DD'),
page_index: 1,
page_size: 5,
total: '',
deleteSetTimeOut: '',
menuKey: 1,
loading: false,
authUserInfo: '',
checked: [],
floatingBubble: false,
logId: '',
is_lead: 0,
})
const router = useRouter();
const onClickLeft = () => router.push({
name: 'welcome'
});
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
let searchValue = ref('')
const attendanceList = ref([])
const userInfo = ref({})
const dateConfig = reactive({
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
const dateConfigTime = reactive({
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
// 定位用↓
const PI = ref(3.1415926535897932384626)
const a = ref(6378245.0)
const ee = ref(0.00669342162296594323)
const jdNow = ref(0)
const wdNow = ref(0)
const address = ref('')
// 定时器
const timer = ref({})
// 是否允许打卡
const allowSignIn = ref(false)
// 点击签到的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.sign,
() => signList.checked,
], (newValue, oldValue) => {
// console.log("🚀🚀🚀,", newValue[5])
if (newValue[0] || newValue[1] || newValue[2] || newValue[3] || newValue[4]) {
clearTimeout(signList.deleteSetTimeOut)
signList.deleteSetTimeOut = setTimeout(async () => {
await search()
// showToast('操作成功!')
}, 500)
}
if (newValue[5]) {
// signList.floatingBubble = signList.checked.lenght ? true :false
signList.floatingBubble = !!signList.checked.length
}
}, {deep: true})
const tabs = (e) => {
signList.is_lead = e.name
onLoad()
}
const batch = async (value) => {
let data = []
signList.checked.map((cur, index) => {
data.push({signid: cur, sign: value})
})
const res = await api.SignInOrOut(data)
signList.checked = []
res.code !== 1 ? showToast(res.msg_detail) : await onLoad()
}
const sign = async (e, signValue) => {
let data = [{
"signid": e.signid,
"sign": signValue
}]
let res = await api.SignInOrOut(data)
await onLoad()
}
const onRefresh = async () => {
signList.loading = true
signList.startTime = dayjs().format('YYYY-MM-DD')
signList.endTime = dayjs().format('YYYY-MM-DD')
signList.sign = 9
signList.is_lead = 0
// signList.page_size = 5
list.value = []
await onLoad()
signList.loading = false
}
const submitLog = async () => {
let data = {
signId: signList.logId,
content: signList.message,
}
const res = await api.SignLogSave(data)
signList.showCenter = false
await onLoad()
}
const dutyLog = (e) => {
signList.logId = e.signid
signList.message = e.content
signList.showCenter = true
}
const search = async () => {
let data = {
"dep_id": signList.dept_id,
"key_name": searchValue.value,
"start_time": signList.startTime,
"end_time": signList.endTime,
"type_id": signList.watchtypeid,
"watchhour_time": signList.watch_hour_id,
"is_lead": signList.is_lead,
sign: Number(signList.sign),
"campus_id": signList.campusid,
"page_index": signList.page_index,
"page_size": signList.page_size,
}
const res = await api.GetSignRecordList(data)
list.value = res.response.data
signList.total = res.response.data_count
}
const onLoad = async () => {
clearTimeout(signList.deleteSetTimeOut)
signList.deleteSetTimeOut = setTimeout(async () => {
let data = {
"dep_id": "",
"key_name": "",
"start_time": signList.startTime,
"end_time": signList.endTime,
"type_id": "",
"watchhour_time": "",
"is_lead": signList.is_lead,
sign: Number(signList.sign),
"campus_id": "",
"page_index": signList.page_index,
"page_size": signList.page_size,
}
const res = await api.GetSignRecordList(data)
list.value = res.response.data
signList.total = res.response.data_count
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
// for (let i = 0; i < 10; i++) {
// list.value.push(list.value.length + 1);
// }
// 数据全部加载完成
if (list.value.length >= Number(signList.total)) {
finished.value = true;
// showToast('操作成功!')
} else if (list.value.length < Number(signList.total)) {
signList.page_size = signList.page_size + 10
// signList.page_index = signList.page_index + 1
}
}, 100)
}
const dateRange = async (e) => {
signList.startTime = dayjs(e[0]).format('YYYY-MM-DD')
signList.endTime = dayjs(e[1]).format('YYYY-MM-DD')
await search()
signList.menuKey++
closeMenu()
}
const closeMenu = () => {
signList.show = false
}
const openMenu = () => {
signList.show = true
}
const addDutySearchSelectList = () => {
Promise.all([
getSearchSelectListPromiseAllAction("dutyType", '类型', "watchtypeid", api.GetWatchTypeSelect),
// getSearchSelectListPromiseAllAction("dutyHourTime", '时段', "watch_hour_id", api.GetWatchHourTime),
getSearchSelectListPromiseAllAction("campusname", '校区', "campusid", api.GetWatchCampusSelect),
getSearchSelectListPromiseAllAction("dept_name", '部门', "dept_id", api.GetWatchDepSelect),
])
.then(res => {
signList.addDutySelectList = res
signList.DatePickerKey++
})
}
const getSearchSelectListPromiseAllAction = (publicName, title, objectAttribute, apiFunction) => {
return new Promise(async (resolve, reject) => {
const publicName = await apiFunction()
const list = []
publicName.response.map((cur, index) => {
list.push({text: cur.name, value: cur.id})
})
let array = [list, title, objectAttribute]
resolve(array)
})
}
//微信获取地理位置
function initWxPosition() {
// 微信初始化,并且获取用户当前定位
var getCurrentData = new Promise((resolve, reject) => {
const params = {
url: window.location.href.replace(window.location.hash, ""),
};
// var urla = `https://asc.hnasct.cn/wx/eicrs/api/GetJSSDK/GetWxConfig`
var urla = `${window.location.origin}/wx/eicrs/api/GetJSSDK/GetWxConfig`
api.GetWxInfo(urla, params).then((result) => {
let data = result;
wx.config({
// beta: true,
debug: false,
appId: data.appId, // 必填,公众号的唯一标识
timestamp: data.timeStamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名,见附录1
jsApiList: ["getLocation", "getLocalImgData", "chooseImage"], // 必填,需要使用的JS接口列表
});
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('开始获取定位')
getAddress()
timer.value = setInterval(() => {
getAddress()
}, 30000);
});
});
});
}
//获取定位
function getAddress() {
return new Promise((resolve, reject) => {
wx.getLocation({
type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
IsHighAccuracy: true,
success: function (res) {
//iOS给的坐标是number 安卓给的坐标是string
const wgs84Loc = gcj02towgs84(Number(res.longitude), Number(res.latitude))
// console.log('wgs84Loc:', wgs84Loc)
jdNow.value = res.longitude; // 经度,浮点数,范围为180 ~ -180。
wdNow.value = res.latitude; // 纬度,浮点数,范围为90 ~ -90
// that.$notify({ type: 'success', message: '获取地址成功' + jdNow + ',' + wdNow });
geocoder(wgs84Loc[1], wgs84Loc[0]);// 地址解析
// 判断是否进入考勤地点
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()
},
fail: function (err) {
showDialog({
title: '定位失败',
message: '请检查是否已打开手机定位功能、授权微信APP定位权限、授权公众号使用定位等',
theme: 'round-button',
})/*.then(() => {
clearInterval(that.intervalBox2);
});*/
}
});
})
}
// 地址解析
function geocoder(latitude, longitude) {
// var that = this;
var ll = latitude + "," + longitude;
$.ajax({
type: "get",
url: "https://apis.map.qq.com/ws/geocoder/v1",
async: false,
dataType: "jsonp",
data: {
key: "ZNMBZ-NYOEO-WNMWL-SJF4C-MWKQT-KJB7W", //开发密钥
location: ll, //位置坐标
coord_type: "1", //输入的locations的坐标类型,1 GPS坐标
output: "jsonp"
},
success: function (data, textStatus) {
// console.log(data);
if (data.status == 0) {
address.value =
data.result.address_component.province +
data.result.address_component.city +
data.result.formatted_addresses.recommend;
} else {
// that.$toast("获取地址失败");
showDialog({
title: '获取地址失败',
message: JSON.stringify(data),
theme: 'round-button',
}).then(() => {
// on close
});
}
},
error: function (err) {
// console.log(err);
showDialog({
title: '地址解析错误',
message: JSON.stringify(err),
theme: 'round-button',
}).then(() => {
// on close
});
}
});
}
//GCJ02 转换为 WGS84
function gcj02towgs84(lng, lat) {
if (out_of_china(lng, lat)) {
return [lng, lat]
} else {
var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0);
var radlat = lat / 180.0 * PI.value;
var magic = Math.sin(radlat);
magic = 1 - ee.value * magic * magic;
var sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a.value * (1 - ee.value)) / (magic * sqrtmagic) * PI.value);
dlng = (dlng * 180.0) / (a.value / sqrtmagic * Math.cos(radlat) * PI.value);
var mglat = lat + dlat;
var mglng = lng + dlng;
return [(lng * 2) - mglng, (lat * 2) - mglat];
}
}
//判断是否在国内,不在国内则不做偏移
function out_of_china(lng, lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
}
function transformlat(lng, lat) {
var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lat * PI.value) + 40.0 * Math.sin(lat / 3.0 * PI.value)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(lat / 12.0 * PI.value) + 320 * Math.sin(lat * PI.value / 30.0)) * 2.0 / 3.0;
return ret
}
function transformlng(lng, lat) {
var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lng * PI.value) + 40.0 * Math.sin(lng / 3.0 * PI.value)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(lng / 12.0 * PI.value) + 300.0 * Math.sin(lng / 30.0 * PI.value)) * 2.0 / 3.0;
return ret
}
//根据经纬度计算两点之间的距离
function latlngDiff(lat1, lng1, lat2, lng2) {
var s = 999999999;
if (lat1 != null && lng1 != null && lat2 != null && lng2 != null) {
var radLat1 = Rad(lat1);
var radLat2 = Rad(lat2);
var a = radLat1 - radLat2;
var b = Rad(lng1) - Rad(lng2);
s =
2 *
Math.asin(
Math.sqrt(
Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) *
Math.cos(radLat2) *
Math.pow(Math.sin(b / 2), 2)
)
);
s = s * 6378137.0; // 取WGS84标准参考椭球中的地球长半径(单位:m)
s = Math.round(s * 10000) / 10000;
}
// console.log('定位距离',s);
return s;
}
function Rad(d) {
return (d * Math.PI) / 180.0;
}
// 签到按钮禁用计算属性
const signBtDis = computed(() => function (obj) {
// console.log('签到按钮类型计算属性', obj)
// let nowDate = new Date().toLocaleDateString('zh-CN', dateConfig).split('/').join('-')
// 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) {
signObj.value = Object.assign({}, obj)
if (obj.sign_type == 1) {
// 不需要定位拍照的签到
signAcStShow.value = true
return
}
if (allowSignIn.value) {
wx.chooseImage({
count: 1, // 默认9
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
getWxImgX(localIds, new Date())
}
});
} 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];
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)
}
})
}
}
// 测试用,修改签到时间限制
// 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()
signList.authUserInfo = Cookies.get('user-info').split('"').indexOf('值班领导') === -1 ? -1 : 1
api.GetAttendanceList().then(res => {
// console.log('获取考勤列表', res.response)
attendanceList.value = res.response
// 微信初始化
initWxPosition()
})
// 获取当前用户信息
userInfo.value = JSON.parse(Cookies.get('userInfo'))
// console.log('获取当前用户信息', userInfo.value)
})
onUnmounted(() => {
clearInterval(timer.value)
})
</script>
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
</van-floating-bubble> </van-floating-bubble>
<div style="position: fixed;z-index: 2;width: 100%"> <div style="position: fixed;z-index: 2;width: 100%">
<!-- &lt;!&ndash; 圆角弹窗(居中) &ndash;&gt;--> <!-- &lt;!&ndash; 圆角弹窗(居中) &ndash;&gt;-->
<van-popup v-model:show="signList.showCenter" round style="width: 100%; padding: 10px;"> <van-popup v-model:show="signList.showCenter" round style="width: 100%; padding: 10px;">
<template v-slot:default> <template v-slot:default>
...@@ -56,7 +54,24 @@ ...@@ -56,7 +54,24 @@
left-text="返回" left-text="返回"
left-arrow left-arrow
@click-left="onClickLeft" @click-left="onClickLeft"
></van-nav-bar> >
<template v-slot:title><span style="margin-right: 20vw">签到列表</span></template>
<template v-slot:right>
<van-tabs v-model:active="signList.is_lead" shrink type="card" @click-tab="tabs">
<van-tab title="教师">
<template v-slot:title>
<span style="">值班教师</span>
</template>
</van-tab>
<van-tab title="领导">
<template v-slot:title>
<span style="">值班领导</span>
</template>
</van-tab>
</van-tabs>
</template>
</van-nav-bar>
<van-search <van-search
v-model="searchValue" v-model="searchValue"
shape="round" shape="round"
...@@ -64,13 +79,19 @@ ...@@ -64,13 +79,19 @@
/> />
<van-dropdown-menu :overlay="false"> <van-dropdown-menu :overlay="false">
<van-dropdown-item v-model="signList.sign" title="状态"
:options="signList.signClass"></van-dropdown-item>
<van-dropdown-item @close="closeMenu" :key="signList.menuKey" @open="openMenu" title="日期"> <van-dropdown-item @close="closeMenu" :key="signList.menuKey" @open="openMenu" title="日期">
<template #default> <template #default>
<van-calendar v-model:show="signList.show" type="range" @confirm="dateRange"/> <van-calendar :max-date="signList.maxDate" :minDate="signList.minDate" v-model:show="signList.show"
type="range" @confirm="dateRange"/>
</template> </template>
</van-dropdown-item> </van-dropdown-item>
<van-dropdown-item v-model="signList[item[2]]" v-for="(item,index) in signList.addDutySelectList" :key="index" <van-dropdown-item v-model="signList[item[2]]" v-for="(item,index) in signList.addDutySelectList" :key="index"
:title="item[1]" :options="item[0]"/> :title="item[1]" :options="item[0]"/>
</van-dropdown-menu> </van-dropdown-menu>
</div> </div>
...@@ -110,11 +131,12 @@ ...@@ -110,11 +131,12 @@
<span>日志</span> <span>日志</span>
</template> </template>
<template #extra> <template #extra>
<van-text-ellipsis :rows="1" :content="item.content" expand-text="展开" collapse-text="收起"/> <van-text-ellipsis v-if="item.is_lead === 0" :rows="1" :content="item.content" expand-text="展开"
collapse-text="收起"/>
</template> </template>
<template #value> <template #value>
<van-button <van-button
v-if="item.card_name == userInfo.card_number && userInfo.role[0].indexOf('值班领导') != -1" v-if="item.card_name == userInfo.card_number && item.is_lead == 1"
type="primary" type="primary"
size="small" size="small"
@click="leadLog(item)"> @click="leadLog(item)">
...@@ -122,34 +144,8 @@ ...@@ -122,34 +144,8 @@
</van-button> </van-button>
</template> </template>
</van-cell> </van-cell>
<van-cell <van-cell class="cardContent" style="display: flex;flex-wrap: nowrap;align-items: center"
class="cardContent" v-if="item.is_lead === 0">
title="签到"
v-if="item.card_name == userInfo.card_number && item.sign_type != 0">
<!-- <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" />
{{ `${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">
<template #value> <template #value>
<div style="display: flex;flex-wrap: nowrap;align-items: center"> <div style="display: flex;flex-wrap: nowrap;align-items: center">
...@@ -158,10 +154,11 @@ ...@@ -158,10 +154,11 @@
v-model="item.signid" :name="item.signid"></van-checkbox> v-model="item.signid" :name="item.signid"></van-checkbox>
</van-checkbox-group> </van-checkbox-group>
<div style="margin-left: auto"> <div style="margin-left: auto">
<van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px"> <van-button @click="dutyLog(item)" type="primary" icon="edit" size="small"
style="margin-right: 10px">
日志 日志
</van-button> </van-button>
<van-button @click="sign(item,2)" <!-- <van-button @click="sign(item,2)"
v-if="item.sign === 1 && item.sign_set === 0 && signList.authUserInfo!== -1" type="warning" v-if="item.sign === 1 && item.sign_set === 0 && signList.authUserInfo!== -1" type="warning"
icon="guide-o" size="small" style="margin-right: 10px">签退 icon="guide-o" size="small" style="margin-right: 10px">签退
</van-button> </van-button>
...@@ -172,11 +169,36 @@ ...@@ -172,11 +169,36 @@
<van-button :disabled="item.sign === 2" v-if="item.sign === 2" size="small" style="margin-right: 10px"> <van-button :disabled="item.sign === 2" v-if="item.sign === 2" size="small" style="margin-right: 10px">
<van-icon name="passed" style=" margin-left: 5px;color: #23da6f"/> <van-icon name="passed" style=" margin-left: 5px;color: #23da6f"/>
完成考勤 完成考勤
</van-button> </van-button> -->
</div> </div>
</div> </div>
</template> </template>
</van-cell> --> </van-cell>
<van-cell
class="cardContent"
title="签到"
v-if=" item.sign_type !== 0 && signList.is_lead !== 1">
<van-button
v-if="item.sign !== 0 && item.sign !==2"
size="small"
:disabled="true"
style="margin-right: 10px;"
>
<van-icon name="edit"/>
{{ `${item.sign == 1 ? '已签到' : ''}` }}
</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-cell>
</van-cell-group> </van-cell-group>
<div style="width: 100%;height: 100px"></div> <div style="width: 100%;height: 100px"></div>
...@@ -256,7 +278,7 @@ ...@@ -256,7 +278,7 @@
} }
.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;
.cardContainer { .cardContainer {
...@@ -285,9 +307,32 @@ import {showToast, showDialog, ActionSheet, closeToast, showSuccessToast, showFa ...@@ -285,9 +307,32 @@ import {showToast, showDialog, ActionSheet, closeToast, showSuccessToast, showFa
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";
import {useRouter} from "vue-router";
const onClickLeft = () => history.back(); let active = ref(1)
let signList = reactive({ let signList = reactive({
minDate: new Date(dayjs().year(), dayjs().month() - 1, 1),
maxDate: new Date(dayjs().year(), dayjs().month() + 1, 1),
sign: 9,
signClass: [
{
text: '全部状态',
value: 9
},
{
text: '待签到',
value: "0"
},
{
text: '已签到',
value: 1
},
{
text: '已签退',
value: 2
},
],
addDutySelectList: [], addDutySelectList: [],
DatePickerKey: 1, DatePickerKey: 1,
showCenter: false, showCenter: false,
...@@ -305,7 +350,13 @@ let signList = reactive({ ...@@ -305,7 +350,13 @@ let signList = reactive({
checked: [], checked: [],
floatingBubble: false, floatingBubble: false,
logId: '', logId: '',
is_lead: 0,
}) })
const router = useRouter();
const onClickLeft = () => router.push({
name: 'welcome'
});
const list = ref([]); const list = ref([]);
const loading = ref(false); const loading = ref(false);
const finished = ref(false); const finished = ref(false);
...@@ -351,13 +402,21 @@ const logAcStShow = ref(false) ...@@ -351,13 +402,21 @@ const logAcStShow = ref(false)
// 领导获取的教师日志 // 领导获取的教师日志
const allLog = ref('') 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.sign,
() => 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 () => {
await search() await search()
showToast('操作成功!') // showToast('操作成功!')
}, 500) }, 500)
} }
...@@ -366,7 +425,10 @@ watch([searchValue, () => signList.watchtypeid, () => signList.watch_hour_id, () ...@@ -366,7 +425,10 @@ watch([searchValue, () => signList.watchtypeid, () => signList.watch_hour_id, ()
signList.floatingBubble = !!signList.checked.length signList.floatingBubble = !!signList.checked.length
} }
}, {deep: true}) }, {deep: true})
const tabs = (e) => {
signList.is_lead = e.name
onLoad()
}
const batch = async (value) => { const batch = async (value) => {
let data = [] let data = []
signList.checked.map((cur, index) => { signList.checked.map((cur, index) => {
...@@ -390,6 +452,11 @@ const onRefresh = async () => { ...@@ -390,6 +452,11 @@ const onRefresh = async () => {
signList.loading = true signList.loading = true
signList.startTime = dayjs().format('YYYY-MM-DD') signList.startTime = dayjs().format('YYYY-MM-DD')
signList.endTime = dayjs().format('YYYY-MM-DD') signList.endTime = dayjs().format('YYYY-MM-DD')
signList.sign = 9
signList.is_lead = 0
// signList.page_size = 5
list.value = []
await onLoad() await onLoad()
signList.loading = false signList.loading = false
...@@ -417,7 +484,8 @@ const search = async () => { ...@@ -417,7 +484,8 @@ const search = async () => {
"end_time": signList.endTime, "end_time": signList.endTime,
"type_id": signList.watchtypeid, "type_id": signList.watchtypeid,
"watchhour_time": signList.watch_hour_id, "watchhour_time": signList.watch_hour_id,
"is_lead": 3, "is_lead": signList.is_lead,
sign: Number(signList.sign),
"campus_id": signList.campusid, "campus_id": signList.campusid,
"page_index": signList.page_index, "page_index": signList.page_index,
"page_size": signList.page_size, "page_size": signList.page_size,
...@@ -436,12 +504,14 @@ const onLoad = async () => { ...@@ -436,12 +504,14 @@ const onLoad = async () => {
"end_time": signList.endTime, "end_time": signList.endTime,
"type_id": "", "type_id": "",
"watchhour_time": "", "watchhour_time": "",
"is_lead": 3, "is_lead": signList.is_lead,
sign: Number(signList.sign),
"campus_id": "", "campus_id": "",
"page_index": signList.page_index, "page_index": signList.page_index,
"page_size": signList.page_size, "page_size": signList.page_size,
} }
const res = await api.GetSignRecordList(data) const res = await api.GetSignRecordList(data)
list.value = res.response.data list.value = res.response.data
signList.total = res.response.data_count signList.total = res.response.data_count
// 异步更新数据 // 异步更新数据
...@@ -453,10 +523,10 @@ const onLoad = async () => { ...@@ -453,10 +523,10 @@ const onLoad = async () => {
// 数据全部加载完成 // 数据全部加载完成
if (list.value.length >= Number(signList.total)) { if (list.value.length >= Number(signList.total)) {
finished.value = true; finished.value = true;
showToast('操作成功!') // showToast('操作成功!')
} else if (list.value.length < Number(signList.total)) { } else if (list.value.length < Number(signList.total)) {
signList.page_size = signList.page_size + 10 signList.page_size = signList.page_size + 10
// signList.page_index = signList.page_index + 1
} }
}, 100) }, 100)
} }
...@@ -476,13 +546,13 @@ const openMenu = () => { ...@@ -476,13 +546,13 @@ const openMenu = () => {
const addDutySearchSelectList = () => { const addDutySearchSelectList = () => {
Promise.all([ Promise.all([
getSearchSelectListPromiseAllAction("dutyType", '类型', "watchtypeid", api.GetWatchTypeSelect), getSearchSelectListPromiseAllAction("dutyType", '类型', "watchtypeid", api.GetWatchTypeSelect),
getSearchSelectListPromiseAllAction("dutyHourTime", '时段', "watch_hour_id", api.GetWatchHourTime), // getSearchSelectListPromiseAllAction("dutyHourTime", '时段', "watch_hour_id", api.GetWatchHourTime),
getSearchSelectListPromiseAllAction("campusname", '校区', "campusid", api.GetWatchCampusSelect), getSearchSelectListPromiseAllAction("campusname", '校区', "campusid", api.GetWatchCampusSelect),
getSearchSelectListPromiseAllAction("dept_name", '部门', "dept_id", api.GetWatchDepSelect), getSearchSelectListPromiseAllAction("dept_name", '部门', "dept_id", api.GetWatchDepSelect),
]) ])
.then(res => { .then(res => {
signList.addDutySelectList = res signList.addDutySelectList = res
signList.DatePickerKey++ signList.DatePickerKey++
}) })
} }
...@@ -506,6 +576,7 @@ function initWxPosition() { ...@@ -506,6 +576,7 @@ function initWxPosition() {
const params = { const params = {
url: window.location.href.replace(window.location.hash, ""), url: window.location.href.replace(window.location.hash, ""),
}; };
// var urla = `https://asc.hnasct.cn/wx/eicrs/api/GetJSSDK/GetWxConfig`
var urla = `${window.location.origin}/wx/eicrs/api/GetJSSDK/GetWxConfig` var urla = `${window.location.origin}/wx/eicrs/api/GetJSSDK/GetWxConfig`
api.GetWxInfo(urla, params).then((result) => { api.GetWxInfo(urla, params).then((result) => {
let data = result; let data = result;
...@@ -541,6 +612,7 @@ function initWxPosition() { ...@@ -541,6 +612,7 @@ function initWxPosition() {
}); });
}); });
} }
//获取定位 //获取定位
function getAddress() { function getAddress() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -582,6 +654,7 @@ function getAddress() { ...@@ -582,6 +654,7 @@ function getAddress() {
}) })
} }
// 地址解析 // 地址解析
function geocoder(latitude, longitude) { function geocoder(latitude, longitude) {
// var that = this; // var that = this;
...@@ -627,12 +700,12 @@ function geocoder(latitude, longitude) { ...@@ -627,12 +700,12 @@ function geocoder(latitude, longitude) {
} }
}); });
} }
//GCJ02 转换为 WGS84 //GCJ02 转换为 WGS84
function gcj02towgs84(lng, lat) { function gcj02towgs84(lng, lat) {
if (out_of_china(lng, lat)) { if (out_of_china(lng, lat)) {
return [lng, lat] return [lng, lat]
} } else {
else {
var dlat = transformlat(lng - 105.0, lat - 35.0); var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0); var dlng = transformlng(lng - 105.0, lat - 35.0);
var radlat = lat / 180.0 * PI.value; var radlat = lat / 180.0 * PI.value;
...@@ -646,10 +719,12 @@ function gcj02towgs84(lng, lat) { ...@@ -646,10 +719,12 @@ function gcj02towgs84(lng, lat) {
return [(lng * 2) - mglng, (lat * 2) - mglat]; return [(lng * 2) - mglng, (lat * 2) - mglat];
} }
} }
//判断是否在国内,不在国内则不做偏移 //判断是否在国内,不在国内则不做偏移
function out_of_china(lng, lat) { function out_of_china(lng, lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false); return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
} }
function transformlat(lng, lat) { function transformlat(lng, lat) {
var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)); var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0; ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0;
...@@ -657,6 +732,7 @@ function transformlat(lng, lat) { ...@@ -657,6 +732,7 @@ function transformlat(lng, lat) {
ret += (160.0 * Math.sin(lat / 12.0 * PI.value) + 320 * Math.sin(lat * PI.value / 30.0)) * 2.0 / 3.0; ret += (160.0 * Math.sin(lat / 12.0 * PI.value) + 320 * Math.sin(lat * PI.value / 30.0)) * 2.0 / 3.0;
return ret return ret
} }
function transformlng(lng, lat) { function transformlng(lng, lat) {
var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)); var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0; ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0;
...@@ -664,6 +740,7 @@ function transformlng(lng, lat) { ...@@ -664,6 +740,7 @@ function transformlng(lng, lat) {
ret += (150.0 * Math.sin(lng / 12.0 * PI.value) + 300.0 * Math.sin(lng / 30.0 * PI.value)) * 2.0 / 3.0; ret += (150.0 * Math.sin(lng / 12.0 * PI.value) + 300.0 * Math.sin(lng / 30.0 * PI.value)) * 2.0 / 3.0;
return ret return ret
} }
//根据经纬度计算两点之间的距离 //根据经纬度计算两点之间的距离
function latlngDiff(lat1, lng1, lat2, lng2) { function latlngDiff(lat1, lng1, lat2, lng2) {
var s = 999999999; var s = 999999999;
...@@ -688,6 +765,7 @@ function latlngDiff(lat1, lng1, lat2, lng2) { ...@@ -688,6 +765,7 @@ function latlngDiff(lat1, lng1, lat2, lng2) {
// console.log('定位距离',s); // console.log('定位距离',s);
return s; return s;
} }
function Rad(d) { function Rad(d) {
return (d * Math.PI) / 180.0; return (d * Math.PI) / 180.0;
} }
...@@ -732,6 +810,7 @@ function locSignIn(obj) { ...@@ -732,6 +810,7 @@ function locSignIn(obj) {
}) })
} }
} }
// 微信图片上传到本地 // 微信图片上传到本地
function getWxImgX(localId, date) { function getWxImgX(localId, date) {
showToast({ showToast({
...@@ -762,8 +841,8 @@ function getWxImgX(localId, date) { ...@@ -762,8 +841,8 @@ function getWxImgX(localId, date) {
const name = `image.${localData.split(";")[0].split(":")[1].split("/")[1]}`; const name = `image.${localData.split(";")[0].split(":")[1].split("/")[1]}`;
let fileBlob = new Blob([new Uint8Array(data)], { type: type }); let fileBlob = new Blob([new Uint8Array(data)], {type: type});
const file = new File([fileBlob], name, { type: type }); const file = new File([fileBlob], name, {type: type});
afterRead(file, localId, date); afterRead(file, localId, date);
}, },
error: function (e) { error: function (e) {
...@@ -771,6 +850,7 @@ function getWxImgX(localId, date) { ...@@ -771,6 +850,7 @@ function getWxImgX(localId, date) {
}, },
}); });
} }
// 文件读取完成后的回调函数 // 文件读取完成后的回调函数
function afterRead(file, localIds, date) { function afterRead(file, localIds, date) {
// console.log(localIds); // console.log(localIds);
...@@ -792,6 +872,7 @@ function afterRead(file, localIds, date) { ...@@ -792,6 +872,7 @@ function afterRead(file, localIds, date) {
} }
}) })
} }
// 签到按钮 // 签到按钮
function signBt(obj) { function signBt(obj) {
if (obj.sign != 2) { if (obj.sign != 2) {
...@@ -823,6 +904,7 @@ function signBt(obj) { ...@@ -823,6 +904,7 @@ function signBt(obj) {
}) })
} }
} }
// 测试用,修改签到时间限制 // 测试用,修改签到时间限制
// function changeSignTimeTest(obj) { // function changeSignTimeTest(obj) {
// if (obj.sign == 0) { // if (obj.sign == 0) {
...@@ -853,6 +935,7 @@ function leadLog(obj) { ...@@ -853,6 +935,7 @@ function leadLog(obj) {
} }
}) })
} }
// 复制教师日志 // 复制教师日志
function copyLog() { function copyLog() {
// 创建input元素 // 创建input元素
...@@ -873,11 +956,9 @@ function copyLog() { ...@@ -873,11 +956,9 @@ function copyLog() {
onMounted(() => { onMounted(() => {
addDutySearchSelectList() addDutySearchSelectList()
signList.authUserInfo = Cookies.get('user-info').split('"').indexOf('值班领导') === -1 ? -1 : 1 signList.authUserInfo = Cookies.get('user-info').split('"').indexOf('值班领导') === -1 ? -1 : 1
api.GetAttendanceList().then(res => { api.GetAttendanceList().then(res => {
// console.log('获取考勤列表', res.response) // console.log('获取考勤列表', res.response)
attendanceList.value = res.response attendanceList.value = res.response
// 微信初始化 // 微信初始化
initWxPosition() initWxPosition()
}) })
......
<template>
<van-pull-refresh v-model="signList.loading" @refresh="onRefresh">
<van-floating-bubble
axis="xy"
icon="chat"
magnetic="x"
:gap="35"
@click="batch(1)"
v-if="signList.floatingBubble"
>
<template v-slot:default>
<div>批量签</div>
</template>
</van-floating-bubble>
<van-floating-bubble
axis="xy"
icon="chat"
magnetic="x"
@click="batch(2)"
:gap="0"
v-if="signList.floatingBubble"
>
<template v-slot:default>
<div>批量休</div>
</template>
</van-floating-bubble>
<div style="position: fixed;z-index: 2;width: 100%">
<!-- &lt;!&ndash; 圆角弹窗(居中) &ndash;&gt;-->
<van-popup v-model:show="signList.showCenter" round style="width: 100%; padding: 10px;">
<template v-slot:default>
<van-field
v-model="signList.message"
rows="2"
autosize
clearable
type="textarea"
maxlength="100"
placeholder="请输入日志"
show-word-limit
/>
<div style="float: right">
<van-button icon="close" size="small" style="margin-right: 10px" @click="signList.showCenter = false">取消
</van-button>
<van-button @click="submitLog" type="primary" icon="passed" size="small" style="margin-right: 10px">提交
</van-button>
</div>
</template>
</van-popup>
<van-nav-bar
title="签到列表"
left-text="返回"
left-arrow
@click-left="onClickLeft"
>
<template v-slot:title><span style="margin-right: 20vw">签到列表</span></template>
<template v-slot:right>
<van-tabs v-model:active="signList.is_lead" shrink type="card" @click-tab="tabs">
<van-tab title="教师">
<template v-slot:title>
<span style="">值班教师</span>
</template>
</van-tab>
<van-tab title="领导">
<template v-slot:title>
<span style="">值班领导</span>
</template>
</van-tab>
</van-tabs>
</template>
</van-nav-bar>
<van-search
v-model="searchValue"
shape="round"
placeholder="请输入搜索关键词"
/>
<van-dropdown-menu :overlay="false">
<van-dropdown-item v-model="signList.sign" title="状态"
:options="signList.signClass"></van-dropdown-item>
<van-dropdown-item @close="closeMenu" :key="signList.menuKey" @open="openMenu" title="日期">
<template #default>
<van-calendar :max-date="signList.maxDate" :minDate="signList.minDate" v-model:show="signList.show"
type="range" @confirm="dateRange"/>
</template>
</van-dropdown-item>
<van-dropdown-item v-model="signList[item[2]]" v-for="(item,index) in signList.addDutySelectList" :key="index"
:title="item[1]" :options="item[0]"/>
</van-dropdown-menu>
</div>
<van-list
class="container"
@load="onLoad"
direction="down"
:finished="finished"
offset="600"
>
<div style="width: 100%;height: 150px"></div>
<!-- <van-cell/>-->
<van-cell-group inset class="cardContainer" v-for="(item,index) in list" :key="index">
<van-cell class="cardContent" :title="item.username">
<template #extra>
<van-tag type="primary" plain><span>{{ item.card_name }}</span></van-tag>
<van-tag color="#7232dd" type="primary" plain style="margin-left: 10px">{{ item.mobile }}</van-tag>
<!-- <van-tag :color="['','#7232dd'][item.is_lead]" type="primary" plain style="margin-left: 10px">-->
<!-- <span>{{ ['值班教师', '值班领导'][item.is_lead] }}</span></van-tag>-->
</template>
</van-cell>
<van-cell class="cardContent" title="日期">
<template #extra>
<van-tag type="primary" plain><span>{{ item.watch_date }}</span></van-tag>
<van-tag v-if="item.mobile!==''" type="primary" plain style="margin-left: 10px">
<span>{{ item.watch_hour_time }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="类型">
<template #extra>
<van-tag type="primary" plain>
<span>{{ item.watchtypename + '-' + item.campusname }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent">
<template #title>
<span>日志</span>
</template>
<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
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" />
{{ `${item.sign == 0 ? '签到' : '签退'}` }}
</van-button> -->
<van-button
v-if="item.sign !== 0 && item.sign !==2"
size="small"
:disabled="true"
style="margin-right: 10px;"
>
<van-icon name="edit"/>
{{ `${item.sign == 1 ? '已签到' : ''}` }}
</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">
<template #value>
<div style="display: flex;flex-wrap: nowrap;align-items: center">
<van-checkbox-group v-model="signList.checked">
<van-checkbox :disabled="item.sign=== 2 || item.sign_set === 1 || signList.authUserInfo === -1"
v-model="item.signid" :name="item.signid"></van-checkbox>
</van-checkbox-group>
<div style="margin-left: auto">
<van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">
日志
</van-button>
<van-button @click="sign(item,2)"
v-if="item.sign === 1 && item.sign_set === 0 && signList.authUserInfo!== -1" type="warning"
icon="guide-o" size="small" style="margin-right: 10px">签退
</van-button>
<van-button @click="sign(item,1)"
v-if="item.sign === 0 && item.sign_set === 0 && signList.authUserInfo!== -1" type="success"
icon="passed" size="small" style="margin-right: 10px">签到
</van-button>
<van-button :disabled="item.sign === 2" v-if="item.sign === 2" size="small" style="margin-right: 10px">
<van-icon name="passed" style=" margin-left: 5px;color: #23da6f"/>
完成考勤
</van-button>
</div>
</div>
</template>
</van-cell> -->
</van-cell-group>
<div style="width: 100%;height: 100px"></div>
</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 {
margin-bottom: 50px;
}
.van-floating-bubble {
position: fixed;
left: -81px;
top: 10px;
right: var(--van-floating-bubble-initial-gap);
bottom: -81px;
width: var(--van-floating-bubble-size);
height: var(--van-floating-bubble-size);
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
touch-action: none;
background: var(--van-floating-bubble-background);
color: var(--van-floating-bubble-color);
border-radius: var(--van-floating-bubble-border-radius);
z-index: var(--van-floating-bubble-z-index);
transition: transform var(--van-duration-base);
}
.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;
.cardContainer {
margin-top: 10px;
width: 95%;
background-color: #ffffff;
height: 20%;
// .cardContent {
// height: 150px;
// }
}
.cardContainer:nth-last-child(1) {
background-color: red;
}
}
</style>
<script setup>
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, ActionSheet, closeToast, showSuccessToast, showFailToast} from "vant";
import Cookies from 'js-cookie'
import wx from "weixin-js-sdk"
import $ from "jquery";
import {useRouter} from "vue-router";
let active = ref(1)
let signList = reactive({
minDate: new Date(dayjs().year(), dayjs().month() - 1, 1),
maxDate: new Date(dayjs().year(), dayjs().month() + 1, 1),
sign: 9,
signClass: [
{
text: '全部状态',
value: 9
},
{
text: '待签到',
value: "0"
},
{
text: '已签到',
value: 1
},
{
text: '已签退',
value: 2
},
],
addDutySelectList: [],
DatePickerKey: 1,
showCenter: false,
message: '',
show: false,
startTime: dayjs().startOf('day').format('YYYY-MM-DD'),
endTime: dayjs().startOf('day').format('YYYY-MM-DD'),
page_index: 1,
page_size: 5,
total: '',
deleteSetTimeOut: '',
menuKey: 1,
loading: false,
authUserInfo: '',
checked: [],
floatingBubble: false,
logId: '',
is_lead: 0,
})
const router = useRouter();
const onClickLeft = () => router.push({
name: 'welcome'
});
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
let searchValue = ref('')
const attendanceList = ref([])
const userInfo = ref({})
const dateConfig = reactive({
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
const dateConfigTime = reactive({
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
})
// 定位用↓
const PI = ref(3.1415926535897932384626)
const a = ref(6378245.0)
const ee = ref(0.00669342162296594323)
const jdNow = ref(0)
const wdNow = ref(0)
const address = ref('')
// 定时器
const timer = ref({})
// 是否允许打卡
const allowSignIn = ref(false)
// 点击签到的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.sign,
() => signList.checked,
], (newValue, oldValue) => {
// console.log("🚀🚀🚀,", newValue[5])
if (newValue[0] || newValue[1] || newValue[2] || newValue[3] || newValue[4]) {
clearTimeout(signList.deleteSetTimeOut)
signList.deleteSetTimeOut = setTimeout(async () => {
await search()
// showToast('操作成功!')
}, 500)
}
if (newValue[5]) {
// signList.floatingBubble = signList.checked.lenght ? true :false
signList.floatingBubble = !!signList.checked.length
}
}, {deep: true})
const tabs = (e) => {
signList.is_lead = e.name
onLoad()
}
const batch = async (value) => {
let data = []
signList.checked.map((cur, index) => {
data.push({signid: cur, sign: value})
})
const res = await api.SignInOrOut(data)
signList.checked = []
res.code !== 1 ? showToast(res.msg_detail) : await onLoad()
}
const sign = async (e, signValue) => {
let data = [{
"signid": e.signid,
"sign": signValue
}]
let res = await api.SignInOrOut(data)
await onLoad()
}
const onRefresh = async () => {
signList.loading = true
signList.startTime = dayjs().format('YYYY-MM-DD')
signList.endTime = dayjs().format('YYYY-MM-DD')
signList.sign = 9
signList.is_lead = 0
// signList.page_size = 5
list.value = []
await onLoad()
signList.loading = false
}
const submitLog = async () => {
let data = {
signId: signList.logId,
content: signList.message,
}
const res = await api.SignLogSave(data)
signList.showCenter = false
await onLoad()
}
const dutyLog = (e) => {
signList.logId = e.signid
signList.message = e.content
signList.showCenter = true
}
const search = async () => {
let data = {
"dep_id": signList.dept_id,
"key_name": searchValue.value,
"start_time": signList.startTime,
"end_time": signList.endTime,
"type_id": signList.watchtypeid,
"watchhour_time": signList.watch_hour_id,
"is_lead": signList.is_lead,
sign: Number(signList.sign),
"campus_id": signList.campusid,
"page_index": signList.page_index,
"page_size": signList.page_size,
}
const res = await api.GetSignRecordList(data)
list.value = res.response.data
signList.total = res.response.data_count
}
const onLoad = async () => {
clearTimeout(signList.deleteSetTimeOut)
signList.deleteSetTimeOut = setTimeout(async () => {
let data = {
"dep_id": "",
"key_name": "",
"start_time": signList.startTime,
"end_time": signList.endTime,
"type_id": "",
"watchhour_time": "",
"is_lead": signList.is_lead,
sign: Number(signList.sign),
"campus_id": "",
"page_index": signList.page_index,
"page_size": signList.page_size,
}
const res = await api.GetSignRecordList(data)
list.value = res.response.data
signList.total = res.response.data_count
// 异步更新数据
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
// for (let i = 0; i < 10; i++) {
// list.value.push(list.value.length + 1);
// }
// 数据全部加载完成
if (list.value.length >= Number(signList.total)) {
finished.value = true;
// showToast('操作成功!')
} else if (list.value.length < Number(signList.total)) {
signList.page_size = signList.page_size + 10
// signList.page_index = signList.page_index + 1
}
}, 100)
}
const dateRange = async (e) => {
signList.startTime = dayjs(e[0]).format('YYYY-MM-DD')
signList.endTime = dayjs(e[1]).format('YYYY-MM-DD')
await search()
signList.menuKey++
closeMenu()
}
const closeMenu = () => {
signList.show = false
}
const openMenu = () => {
signList.show = true
}
const addDutySearchSelectList = () => {
Promise.all([
getSearchSelectListPromiseAllAction("dutyType", '类型', "watchtypeid", api.GetWatchTypeSelect),
// getSearchSelectListPromiseAllAction("dutyHourTime", '时段', "watch_hour_id", api.GetWatchHourTime),
getSearchSelectListPromiseAllAction("campusname", '校区', "campusid", api.GetWatchCampusSelect),
getSearchSelectListPromiseAllAction("dept_name", '部门', "dept_id", api.GetWatchDepSelect),
])
.then(res => {
signList.addDutySelectList = res
signList.DatePickerKey++
})
}
const getSearchSelectListPromiseAllAction = (publicName, title, objectAttribute, apiFunction) => {
return new Promise(async (resolve, reject) => {
const publicName = await apiFunction()
const list = []
publicName.response.map((cur, index) => {
list.push({text: cur.name, value: cur.id})
})
let array = [list, title, objectAttribute]
resolve(array)
})
}
//微信获取地理位置
function initWxPosition() {
// 微信初始化,并且获取用户当前定位
var getCurrentData = new Promise((resolve, reject) => {
const params = {
url: window.location.href.replace(window.location.hash, ""),
};
// var urla = `https://asc.hnasct.cn/wx/eicrs/api/GetJSSDK/GetWxConfig`
var urla = `${window.location.origin}/wx/eicrs/api/GetJSSDK/GetWxConfig`
api.GetWxInfo(urla, params).then((result) => {
let data = result;
wx.config({
// beta: true,
debug: false,
appId: data.appId, // 必填,公众号的唯一标识
timestamp: data.timeStamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填,签名,见附录1
jsApiList: ["getLocation", "getLocalImgData", "chooseImage"], // 必填,需要使用的JS接口列表
});
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('开始获取定位')
getAddress()
timer.value = setInterval(() => {
getAddress()
}, 30000);
});
});
});
}
//获取定位
function getAddress() {
return new Promise((resolve, reject) => {
wx.getLocation({
type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
IsHighAccuracy: true,
success: function (res) {
//iOS给的坐标是number 安卓给的坐标是string
const wgs84Loc = gcj02towgs84(Number(res.longitude), Number(res.latitude))
// console.log('wgs84Loc:', wgs84Loc)
jdNow.value = res.longitude; // 经度,浮点数,范围为180 ~ -180。
wdNow.value = res.latitude; // 纬度,浮点数,范围为90 ~ -90
// that.$notify({ type: 'success', message: '获取地址成功' + jdNow + ',' + wdNow });
geocoder(wgs84Loc[1], wgs84Loc[0]);// 地址解析
// 判断是否进入考勤地点
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()
},
fail: function (err) {
showDialog({
title: '定位失败',
message: '请检查是否已打开手机定位功能、授权微信APP定位权限、授权公众号使用定位等',
theme: 'round-button',
})/*.then(() => {
clearInterval(that.intervalBox2);
});*/
}
});
})
}
// 地址解析
function geocoder(latitude, longitude) {
// var that = this;
var ll = latitude + "," + longitude;
$.ajax({
type: "get",
url: "https://apis.map.qq.com/ws/geocoder/v1",
async: false,
dataType: "jsonp",
data: {
key: "ZNMBZ-NYOEO-WNMWL-SJF4C-MWKQT-KJB7W", //开发密钥
location: ll, //位置坐标
coord_type: "1", //输入的locations的坐标类型,1 GPS坐标
output: "jsonp"
},
success: function (data, textStatus) {
// console.log(data);
if (data.status == 0) {
address.value =
data.result.address_component.province +
data.result.address_component.city +
data.result.formatted_addresses.recommend;
} else {
// that.$toast("获取地址失败");
showDialog({
title: '获取地址失败',
message: JSON.stringify(data),
theme: 'round-button',
}).then(() => {
// on close
});
}
},
error: function (err) {
// console.log(err);
showDialog({
title: '地址解析错误',
message: JSON.stringify(err),
theme: 'round-button',
}).then(() => {
// on close
});
}
});
}
//GCJ02 转换为 WGS84
function gcj02towgs84(lng, lat) {
if (out_of_china(lng, lat)) {
return [lng, lat]
} else {
var dlat = transformlat(lng - 105.0, lat - 35.0);
var dlng = transformlng(lng - 105.0, lat - 35.0);
var radlat = lat / 180.0 * PI.value;
var magic = Math.sin(radlat);
magic = 1 - ee.value * magic * magic;
var sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a.value * (1 - ee.value)) / (magic * sqrtmagic) * PI.value);
dlng = (dlng * 180.0) / (a.value / sqrtmagic * Math.cos(radlat) * PI.value);
var mglat = lat + dlat;
var mglng = lng + dlng;
return [(lng * 2) - mglng, (lat * 2) - mglat];
}
}
//判断是否在国内,不在国内则不做偏移
function out_of_china(lng, lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
}
function transformlat(lng, lat) {
var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lat * PI.value) + 40.0 * Math.sin(lat / 3.0 * PI.value)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(lat / 12.0 * PI.value) + 320 * Math.sin(lat * PI.value / 30.0)) * 2.0 / 3.0;
return ret
}
function transformlng(lng, lat) {
var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI.value) + 20.0 * Math.sin(2.0 * lng * PI.value)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lng * PI.value) + 40.0 * Math.sin(lng / 3.0 * PI.value)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(lng / 12.0 * PI.value) + 300.0 * Math.sin(lng / 30.0 * PI.value)) * 2.0 / 3.0;
return ret
}
//根据经纬度计算两点之间的距离
function latlngDiff(lat1, lng1, lat2, lng2) {
var s = 999999999;
if (lat1 != null && lng1 != null && lat2 != null && lng2 != null) {
var radLat1 = Rad(lat1);
var radLat2 = Rad(lat2);
var a = radLat1 - radLat2;
var b = Rad(lng1) - Rad(lng2);
s =
2 *
Math.asin(
Math.sqrt(
Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) *
Math.cos(radLat2) *
Math.pow(Math.sin(b / 2), 2)
)
);
s = s * 6378137.0; // 取WGS84标准参考椭球中的地球长半径(单位:m)
s = Math.round(s * 10000) / 10000;
}
// console.log('定位距离',s);
return s;
}
function Rad(d) {
return (d * Math.PI) / 180.0;
}
// 签到按钮禁用计算属性
const signBtDis = computed(() => function (obj) {
// console.log('签到按钮类型计算属性', obj)
// let nowDate = new Date().toLocaleDateString('zh-CN', dateConfig).split('/').join('-')
// 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) {
signObj.value = Object.assign({}, obj)
if (obj.sign_type == 1) {
// 不需要定位拍照的签到
signAcStShow.value = true
return
}
if (allowSignIn.value) {
wx.chooseImage({
count: 1, // 默认9
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
getWxImgX(localIds, new Date())
}
});
} 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];
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)
}
})
}
}
// 测试用,修改签到时间限制
// 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()
signList.authUserInfo = Cookies.get('user-info').split('"').indexOf('值班领导') === -1 ? -1 : 1
api.GetAttendanceList().then(res => {
// console.log('获取考勤列表', res.response)
attendanceList.value = res.response
// 微信初始化
initWxPosition()
})
// 获取当前用户信息
userInfo.value = JSON.parse(Cookies.get('userInfo'))
// console.log('获取当前用户信息', userInfo.value)
})
onUnmounted(() => {
clearInterval(timer.value)
})
</script>
...@@ -15,7 +15,16 @@ ...@@ -15,7 +15,16 @@
<!-- <router-link to="/messageDetails">--> <!-- <router-link to="/messageDetails">-->
<!-- <van-button>123123</van-button>--> <!-- <van-button>123123</van-button>-->
<!-- </router-link>--> <!-- </router-link>-->
<van-cell-group style="width: 100%;margin-top: 10px"> <van-cell-group style="width: 100%;margin-top: 10px">
<!-- <van-swipe @change="swiperNext" class="my-swipe" indicator-color="white">-->
<!-- <van-swipe-item>1</van-swipe-item>-->
<!-- <van-swipe-item>2</van-swipe-item>-->
<!-- <van-swipe-item>3</van-swipe-item>-->
<!-- <van-swipe-item style="color: red;">-->
<!-- </van-swipe-item>-->
<!-- </van-swipe>-->
<div class="dateContainer"> <div class="dateContainer">
<div class="left" @click="reductionDate"> <div class="left" @click="reductionDate">
<span class="SlideButton"><van-icon name="arrow-left"/></span> <span class="SlideButton"><van-icon name="arrow-left"/></span>
...@@ -58,7 +67,6 @@ ...@@ -58,7 +67,6 @@
<template #extra> <template #extra>
<van-tag type="primary" plain> <van-tag type="primary" plain>
<span>{{ item.watchtypename + '-' + item.dept_name + '-' + item.campusname }}</span></van-tag> <span>{{ item.watchtypename + '-' + item.dept_name + '-' + item.campusname }}</span></van-tag>
</template> </template>
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
...@@ -105,6 +113,12 @@ let GetWatchListObject = reactive({ ...@@ -105,6 +113,12 @@ let GetWatchListObject = reactive({
GetWatchListInitArray: [], GetWatchListInitArray: [],
}) })
const swiperPrev = () => {
console.log("🚀swiperPrev🚀🚀,",)
}
const swiperNext = (e) => {
console.log("🚀🚀swiperNext🚀,", e)
}
const onRefresh = async () => { const onRefresh = async () => {
dateArray.loading = true dateArray.loading = true
GetWatchListObject.startTime = dayjs().format('YYYY-MM-DD') GetWatchListObject.startTime = dayjs().format('YYYY-MM-DD')
...@@ -263,6 +277,14 @@ onMounted(() => { ...@@ -263,6 +277,14 @@ onMounted(() => {
}) })
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.my-swipe .van-swipe-item {
width: 100px;
color: #fff;
font-size: 20px;
line-height: 150px;
text-align: center;
background-color: #39ed81;
}
.container { .container {
.dateContainer { .dateContainer {
......
...@@ -15,9 +15,8 @@ export default defineConfig({ ...@@ -15,9 +15,8 @@ export default defineConfig({
], ],
base: './', base: './',
server: { server: {
// host: "127.0.0.1", // host: "0.0.0.0",
// cors: true, // cors: true,
// port: 8991, // port: 8991,
// open: true, //自动打开 // open: true, //自动打开
......
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或