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

V2值班移动端

上级 79f517cf
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
## Recommended IDE Setup
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>值班管理</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
此差异已折叠。
{
"name": "wxlezduty",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"animate.css": "^4.1.1",
"axios": "^1.5.0",
"dayjs": "^1.11.9",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
"vant": "^4.6.6",
"vue": "^3.3.4",
"vue-cookies": "^1.8.3",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"less": "^4.2.0",
"unplugin-vue-components": "^0.25.1",
"vite": "^4.4.5"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>消息跳转</title>
</head>
<body>
<!-- <iframe id="ifr" src="" frameborder="0"></iframe>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
var script = document.createElement('script') ;
script.type ='text/javascript' ;
script.src = "https://res.wx.qq.com/open/js/jweixin-1.6.0.js";
var head = document.getElementsByTagName('head').item(0);
head.appendChild(script);
script.onload = function(){
$("#ifr").attr("src","https://asc.neaic.com/SRFlowIfream/view/RequestLeavingBackFileUpload.html?imgDel=1&PKVal=2583&FK_MapFrame=ND26201_Frame1&WorkID=2583&FK_Node=26201&UserNo=101&UserName=");
};
</script> -->
<script id="identifyEl" src="/a/manager/identify/identify.js"></script>
<script>
function GetQueryValue(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var itemStr = window.location.href;
console.log(itemStr);
var itemArr = itemStr.split("links=");
//console.log(itemIndex);
var r = itemArr[1];
for (var i = 2; i < itemArr.length; i++) {
r = r + "links=" + itemArr[i];
}
//匹配目标参数
console.log(r)
return r + "&qrcode=" + getUrlParam("qrcode"); //返回参数值
}
function scriptLoad(script, callback) {
if (script.readyState) { //IE
script.onreadystatechange = function () {
if (script.readyState == 'complete' || script.readyState == 'loaded') {
script.onreadystatechange = null;
callback();
}
}
} else { //非IE
script.onload = function () {
callback();
}
}
}
var identifyEl = document.getElementById('identifyEl');
var i = 0;
var token = null;
while (i == 0) {
if (token != null) {
i = 1;
var links = GetQueryValue("links");
if (links) {
if (token) {
idt.Jump(links, '1');
}
} else {
alert("未找到跳转路径,请核对!");
}
} else {
token = idt.GetToken();
}
}
window.location.href = `/DutyManagement/wx/#/getInfo?type=2&links=${getUrlParam('links')}&id=${getUrlParam('id')}&token=${token}`;
console.log("🚀🚀🚀ssohtml,links,", links)
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if (r != null) return unescape(r[2]);
return null; //返回参数值
}
</script>
</body>
</html>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
\ No newline at end of file
<script setup>
</script>
<template>
<router-view></router-view>
</template>
<style scoped>
@import "style.css";
body{
margin: 0;
}
</style>
import {requestGet, requestPost} from '../util/request.js'
import axios from 'axios'
/**
* 单点
* **/
export function SSONewWX(data) {
//单点
return requestGet(`/api/Login/api/Login/SSONewWX?token=${data.token}`, data)
// axios.get(`/api/Login/api/Login/SSOPC`,data)
}
export function SSOPC(data) {
//单点
return requestGet(`/api/Login/api/Login/SSOPC?token=${data.token}`, data)
// axios.get(`/api/Login/api/Login/SSOPC`,data)
}
export function GetTokenInfo(data) {
//获取用户信息
return requestGet(`/api/Login/api/Login/GetTokenInfo`, data)
}
export function RefreshToken(data) {
//刷新token
return requestGet(`/api/Login/api/Login/RefreshToken`, data)
}
export function SSOPCWX(data) {
//刷新token
return requestGet(`/api/Login/api/Login/SSOPCWX?&code=${data.code}&sign=${data.sign}&timestamp=${data.timestamp}`, data)
}
/**
* 值班列表
*
* */
export function GetWatchList(data) {
//获取值班列表
return requestPost('/api/Watch/api/Watch/GetWatchList', data)
}
export function GetWatchHourTime(data) {
//获取值班时段
return requestGet(`/api/Watch/api/Watch/GetWatchHourTime`, data)
}
export function GetWatchTypeSelect(data) {
//获取值班类型
return requestGet(`/api/Watch/api/Watch/GetWatchTypeSelect`, data)
}
export function GetWatchDepSelect(data) {
//获取值班部门
return requestGet(`/api/Watch/api/Watch/GetWatchDepSelect`, data)
}
export function GetWatchCampusSelect(data) {
//获取校区
return requestGet(`/api/Watch/api/Watch/GetWatchCampusSelect`, data)
}
export function GetWatchInfo(data) {
//获取值班详情
return requestGet(`/api/Watch/api/Watch/GetWatchInfo?id=${data.id}`, data)
}
/***
*
* 签到列表
*
*
* */
export function GetSignRecordList(data) {
//获取签到列表
return requestPost(`/api/SignRecord/api/SignRecord/GetSignRecordList`, data)
}
export function SignInOrOut(data) {
//批量签到签退
return requestPost(`/api/SignRecord/api/SignRecord/SignInOrOut`, data)
}
export function SignLogSave(data) {
//填写日志
return requestGet(`/api/SignRecord/api/SignRecord/SignLogSave?signId=${data.signId}&content=${data.content}`, data)
}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
\ No newline at end of file
<template>
<van-button type="primary">主要按钮</van-button>
<van-button type="success">成功按钮</van-button>
<van-button type="default">默认按钮</van-button>
<van-button type="warning">警告按钮</van-button>
<van-button type="danger">危险按钮</van-button>
</template>
<script setup>
</script>
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from "./router/index.js";
import 'animate.css' //引入
import VueCookies from 'vue-cookies'
const app = createApp(App)
app.config.globalProperties.$cookies = VueCookies
app.use(router)
app.mount('#app')
<template>
<van-nav-bar
left-text="返回"
left-arrow
@click-left="onClickLeft"
></van-nav-bar>
<van-empty style="width: 100%;height: 100%" image="error" description="异常" />
<!-- <van-button primary='success' @click="onClickLeft">返回</van-button>-->
</template>
<script setup>
import {useRouter} from "vue-router";
const router = useRouter()
const onClickLeft = () => router.replace({name:'welcome'});
</script>
<template>
<div style="display: flex; justify-content: center; margin-top: 50%">
<van-loading size="38px" color="#1989fa" vertical> 登录中</van-loading>
</div>
<!-- {{router.currentRoute.value.query.token}}-->
</template>
<script setup>
// import router from "../router/index.js";
import Cookies from 'js-cookie'
import {useRouter} from 'vue-router'
import {onMounted} from 'vue'
import * as api from '../api/index.js'
const router = useRouter()
const getTokenAction = async (date) => {
const res = await api.SSONewWX(date)
if (res.code !== 1) {
await router.replace({
name: '403'
})
} else if (res.response.access_token.token_content !== '') {
// access_token.token_content
Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires)
const user = await api.GetTokenInfo()
Cookies.set('user-info', user.response.role)
localStorage.setItem('user-info', user.response.role)
await router.replace({
name: 'welcome'
})
}
}
const getTokenActionWx = async (date) => {
const res = await api.SSOPCWX(date)
if (res.code !== 1) {
await router.replace({
name: '403'
})
} else if (res.response.access_token.token_content !== '') {
Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires)
const user = await api.GetTokenInfo()
Cookies.set('user-info', user.response.role)
localStorage.setItem('user-info', user.response.role)
await router.replace({
name: 'welcome'
})
}
}
const getToken = async () => {
if (Number(router.currentRoute.value.query.type) === 2) {
Cookies.set('token', router.currentRoute.value.query.token)
// localStorage.setItem('token', router.currentRoute.value.query.token)
let date = {
token: Cookies.get('token')
}
await getTokenAction(date)
} else if (Number(router.currentRoute.value.query.type) === 1) {
// Cookies.set('sign', router.currentRoute.value.query.sign)
// Cookies.set('code', router.currentRoute.value.query.code)
// Cookies.set('timestamp', router.currentRoute.value.query.timestamp)
let date = {
sign: router.currentRoute.value.query.sign,
code: router.currentRoute.value.query.code,
timestamp: router.currentRoute.value.query.timestamp,
}
// Cookies.set('sign', router.currentRoute.value.query.sign,)
// Cookies.set('code', router.currentRoute.value.query.code,)
// Cookies.set('timestamp', router.currentRoute.value.query.timestamp,)
await getTokenActionWx(date)
}
}
onMounted(() => {
getToken()
})
</script>
<template>
<div style="display: flex; justify-content: center; margin-top: 50%">
<van-loading size="38px" color="#1989fa" vertical> 登录中</van-loading>
</div>
</template>
<script setup>
import Cookies from 'js-cookie'
import {useRouter} from 'vue-router'
import {onMounted} from 'vue'
import * as api from '../api/index.js'
const router = useRouter()
const getTokenAction = async (date) => {
const res = await api.SSONewWX(date)
if (res.code !== 1) {
await router.replace({
name: '403'
})
} else if (res.response.access_token.token_content !== '') {
Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires)
let links = router.currentRoute.value.query.links
let id = router.currentRoute.value.query.id
await router.push({
path: `/${links}`,
query: {
id: id
}
})
}
}
const getTokenActionWx = async (date) => {
const res = await api.SSOPCWX(date)
if (res.code !== 1) {
await router.replace({
name: '403'
})
} else if (res.response.access_token.token_content !== '') {
Cookies.set('admin-token', res.response.access_token.token_content)
Cookies.set('time', res.response.access_token.expires)
let links = router.currentRoute.value.query.links
let id = router.currentRoute.value.query.id
await router.push({
path: `/${links}`,
query: {
id: id
}
})
}
}
const getToken = async () => {
if (Number(router.currentRoute.value.query.type) === 2) {
Cookies.set('token', router.currentRoute.value.query.token)
let date = {
token: Cookies.get('token')
}
console.log("🚀🚀🚀,ASC的data", date)
console.log("🚀🚀🚀,ASC的token", Cookies.get('token'))
await getTokenAction(date)
} else if (Number(router.currentRoute.value.query.type) === 1) {
let date = {
sign: router.currentRoute.value.query.sign,
code: router.currentRoute.value.query.code,
timestamp: router.currentRoute.value.query.timestamp,
}
await getTokenActionWx(date)
}
}
onMounted(() => {
getToken()
})
</script>
<template>
<van-nav-bar
left-text="返回"
left-arrow
@click-left="onClickLeft"
></van-nav-bar>
<van-empty style="width: 100%;height: 100%" image="error" description="暂无权限!" />
<!-- <van-button primary='success' @click="onClickLeft">返回</van-button>-->
</template>
<script setup>
import {useRouter} from "vue-router";
const router = useRouter()
const onClickLeft = () => router.replace({name:'welcome'});
</script>
<template>
<van-nav-bar
title="值班信息"
left-text="返回"
left-arrow
@click-left="onClickLeft"
/>
<div class="container">
<!-- v-for="(dutyObject.data,index) in dutyObject.data" :key="index"-->
<van-cell-group class="cardContainer" inset>
<van-cell class="cardContent" :title="dutyObject.data.username">
<template #extra>
<van-tag type="primary" plain><span>{{ dutyObject.data.card_name }}</span></van-tag>
<van-tag color="#7232dd" type="primary" plain style="margin-left: 10px">{{
['值班教师', '值班领导'][dutyObject.data.is_lead]
}}
</van-tag>
<!-- <van-tag :color="['','#7232dd'][dutyObject.data.is_lead]" type="primary" plain style="margin-left: 10px">-->
<!-- <span>{{ ['值班教师', '值班领导'][dutyObject.data.is_lead] }}</span></van-tag>-->
</template>
</van-cell>
<van-cell class="cardContent" title="手机号">
<template #extra>
<van-tag type="primary" plain><span>{{ dutyObject.data.mobile }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="日期">
<template #extra>
<van-tag type="primary" plain><span>{{ dutyObject.data.watch_date }}</span></van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="时段">
<template #extra>
<van-tag type="primary" plain style="margin-left: 10px"><span>{{ dutyObject.data.watch_hour_time }}</span>
</van-tag>
</template>
</van-cell>
<van-cell class="cardContent" title="类型">
<template #extra>
<van-tag type="primary" plain>
<span>{{
dutyObject.data.watchtypename + '-' + dutyObject.data.dept_name + '-' + dutyObject.data.campusname
}}</span>
</van-tag>
</template>
</van-cell>
</van-cell-group>
</div>
</template>
<script setup>
import dayjs from 'dayjs';
import * as api from '../../api/index.js';
import {ref, reactive, onMounted, watch} from 'vue';
import {useRouter} from "vue-router";
import {showToast} from "vant";
const router = useRouter()
let dutyObject = reactive({
data: {}
})
const getDutyMessage = async () => {
let data = {
id: router.currentRoute.value.query.id
}
const res = await api.GetWatchInfo(data)
dutyObject.data = res.response
console.log(dutyObject.data, "🚀🚀🚀,", res.response)
}
onMounted(() => {
getDutyMessage()
})
const onClickLeft = () => history.back();
</script>
<style>
.container {
.cardContainer {
margin-top: 10px;
width: 95%;
background-color: #ffffff;
height: 20%;
.cardContent {
//height: 150px;
}
}
}
</style>
<template>
<van-pull-refresh v-model="myDuty.loading" @refresh="onRefresh">
<div style="position: fixed;z-index: 2;width: 100%">
<!-- &lt;!&ndash; 圆角弹窗(居中) &ndash;&gt;-->
<van-popup v-model:show="myDuty.showCenter" round style="width: 100%; padding: 10px;">
<template v-slot:default>
<van-field
v-model="myDuty.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="myDuty.showCenter = false">取消
</van-button>
<van-button 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"
></van-nav-bar>
<van-search
v-model="searchValue"
shape="round"
placeholder="请输入搜索关键词"
/>
<van-dropdown-menu :overlay="false">
<van-dropdown-item @close="closeMenu" :key="myDuty.menuKey" @open="openMenu" title="日期">
<template #default>
<van-calendar v-model:show="myDuty.show" type="range" @confirm="dateRange"/>
</template>
</van-dropdown-item>
<van-dropdown-item v-model="myDuty[item[2]]" v-for="(item,index) in myDuty.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'][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 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.dept_name + '-' + item.campusname }}</span></van-tag>
</template>
</van-cell>
<!-- <van-cell class="cardContent">-->
<!-- <template #value>-->
<!-- <van-button @click="dutyLog(item)" type="primary" icon="edit" size="small" style="margin-right: 10px">日志</van-button>-->
<!-- </template>-->
<!-- </van-cell>-->
</van-cell-group>
<div style="width: 100%;height: 100px"></div>
</van-list>
</van-pull-refresh>
</template>
<style>
.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} from 'vue';
import dayjs from 'dayjs';
import {showToast} from "vant";
const onClickLeft = () => history.back();
let myDuty = reactive({
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
})
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
let searchValue = ref('')
watch([searchValue, () => myDuty.watchtypeid, () => myDuty.watch_hour_id, () => myDuty.campusid, () => myDuty.dept_id], (newValue, oldValue) => {
console.log("🚀🚀🚀,", newValue[0], newValue[1])
if (newValue[0] || newValue[1] || newValue[2] || newValue[3] || newValue[4]) {
clearTimeout(myDuty.deleteSetTimeOut)
myDuty.deleteSetTimeOut = setTimeout(async () => {
await search()
showToast('操作成功!')
}, 500)
}
}, {deep: true})
const onRefresh = async () => {
myDuty.loading = true
myDuty.startTime = dayjs().format('YYYY-MM-DD')
myDuty.endTime = dayjs().format('YYYY-MM-DD')
await onLoad()
myDuty.loading = false
//初始化刷新
// myDuty.loading = true
// let data = {
// "dep_id": "",
// "key_name": "",
// "start_time": myDuty.startTime,
// "end_time": myDuty.endTime,
// "type_id": "",
// "watchhour_time": "",
// "is_lead": 3,
// "campus_id": "",
// "page_index": myDuty.page_index,
// "page_size": myDuty.page_size,
// }
// const res = await api.GetWatchList(data)
// list.value = res.response.data
// myDuty.total = res.response.data_count
}
const dutyLog = (e) => {
console.log("🚀🚀🚀,", e)
myDuty.showCenter = true
}
const search = async () => {
let data = {
"dep_id": myDuty.dept_id,
"key_name": searchValue.value,
"start_time": myDuty.startTime,
"end_time": myDuty.endTime,
"type_id": myDuty.watchtypeid,
"watchhour_time": myDuty.watch_hour_id,
"is_lead": 3,
"campus_id": myDuty.campusid,
"page_index": myDuty.page_index,
"page_size": myDuty.page_size,
}
const res = await api.GetWatchList(data)
list.value = res.response.data
myDuty.total = res.response.data_count
}
const onLoad = async () => {
clearTimeout(myDuty.deleteSetTimeOut)
myDuty.deleteSetTimeOut = setTimeout(async () => {
let data = {
"dep_id": "",
"key_name": "",
"start_time": myDuty.startTime,
"end_time": myDuty.endTime,
"type_id": "",
"watchhour_time": "",
"is_lead": 3,
"campus_id": "",
"page_index": myDuty.page_index,
"page_size": myDuty.page_size,
}
const res = await api.GetWatchList(data)
list.value = res.response.data
myDuty.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(myDuty.total)) {
finished.value = true;
showToast('加载完成!')
} else if (list.value.length < Number(myDuty.total)) {
myDuty.page_size = myDuty.page_size + 10
}
}, 100)
}
const dateRange = async (e) => {
myDuty.startTime = dayjs(e[0]).format('YYYY-MM-DD')
myDuty.endTime = dayjs(e[1]).format('YYYY-MM-DD')
await search()
myDuty.menuKey++
closeMenu()
}
const closeMenu = () => {
myDuty.show = false
}
const openMenu = () => {
myDuty.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 => {
myDuty.addDutySelectList = res
myDuty.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)
})
}
onMounted(() => {
addDutySearchSelectList()
})
</script>
此差异已折叠。
此差异已折叠。
import {createRouter,createWebHashHistory } from 'vue-router'
import routes from "./routes.js";
import * as api from '../api/index.js'
import Cookies from 'js-cookie'
const router = new createRouter({
history:createWebHashHistory(),
routes:routes,
})
// 全局守卫:登录拦截 本地没有存token,请重新登录
router.beforeEach(async (to, from, next) => {
if (to.meta.isAuth && to.meta.admin) {
if (Cookies.get('user-info')) {
next()
// Cookies.get('user-info').split('"').indexOf('值班领导') === -1 ? next({name: 'undefinedAuthorization'}) : next()
} else {
const res = await api.GetTokenInfo()
Cookies.set('user-info', res.response.role)
if (Cookies.get('user-info')) next()
else {
next({name: '403'})
}
}
} else if (to.meta.isAuth) {
if (Cookies.get('user-info')) {
next()
} else {
const res = await api.GetTokenInfo()
Cookies.set('user-info', res.response.role)
if (Cookies.get('user-info')) next()
else {
next({name: '403'})
}
}
} else if (!to.meta.isAuth) {
next()
}
});
export default router
const routes = [
{
name: '403',
path: '/403',
component: () => import('../pages/403/index.vue'),
},
{
name: 'undefinedAuthorization',
path: '/undefinedAuthorization',
component: () => import('../pages/authPage/index.vue'),
},
{
name: 'et',
path: '/et',
component: () => import('../pages/SSO.vue')
},
{
name: 'getInfo',
path: '/getInfo',
component: () => import('../pages/SSOInfo.vue')
},
{
name: 'welcome',
path: '/welcome',
component: () => import('../pages/welcome/index.vue'),
meta: {isAuth: true},
},
{
name: 'signList',
path: '/signList',
component: () => import('../pages/signList/index.vue'),
meta: {isAuth: true, admin: true}
},
{
name: 'myDuty',
path: '/myDuty',
component: () => import('../pages/myDuty/index.vue'),
meta: {isAuth: true}
},
{
name: 'messageDetails',
path: '/messageDetails',
component: () => import('../pages/messageDetails/index.vue'),
}
]
export default routes
.container{
box-sizing: border-box;
background-color: #e8e5e5;
width: 100%;
height: 100%;
min-height: 812px;
/*max-width: 600px;*/
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: flex-start;
}
/*:root {*/
/* font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;*/
/* line-height: 1.5;*/
/* font-weight: 400;*/
/* color-scheme: light dark;*/
/* color: rgba(255, 255, 255, 0.87);*/
/* !*background-color: #242424;*!*/
/* font-synthesis: none;*/
/* text-rendering: optimizeLegibility;*/
/* -webkit-font-smoothing: antialiased;*/
/* -moz-osx-font-smoothing: grayscale;*/
/* -webkit-text-size-adjust: 100%;*/
/*}*/
/*a {*/
/* font-weight: 500;*/
/* color: #646cff;*/
/* text-decoration: inherit;*/
/*}*/
/*a:hover {*/
/* color: #535bf2;*/
/*}*/
/*a {*/
/* font-weight: 500;*/
/* color: #646cff;*/
/* text-decoration: inherit;*/
/*}*/
/*a:hover {*/
/* color: #535bf2;*/
/*}*/
/*body {*/
/* margin: 0;*/
/* display: flex;*/
/* place-items: center;*/
/* min-width: 320px;*/
/* min-height: 100vh;*/
/*}*/
/*h1 {*/
/* font-size: 3.2em;*/
/* line-height: 1.1;*/
/*}*/
/*button {*/
/* border-radius: 8px;*/
/* border: 1px solid transparent;*/
/* padding: 0.6em 1.2em;*/
/* font-size: 1em;*/
/* font-weight: 500;*/
/* font-family: inherit;*/
/* background-color: #1a1a1a;*/
/* cursor: pointer;*/
/* transition: border-color 0.25s;*/
/*}*/
/*button:hover {*/
/* border-color: #646cff;*/
/*}*/
/*button:focus,*/
/*button:focus-visible {*/
/* outline: 4px auto -webkit-focus-ring-color;*/
/*}*/
/*.card {*/
/* padding: 2em;*/
/*}*/
/*#app {*/
/* max-width: 1280px;*/
/* margin: 0 auto;*/
/* padding: 2rem;*/
/* text-align: center;*/
/*}*/
/*@media (prefers-color-scheme: light) {*/
/* :root {*/
/* color: #213547;*/
/* background-color: #ffffff;*/
/* }*/
/* a:hover {*/
/* color: #747bff;*/
/* }*/
/* button {*/
/* background-color: #f9f9f9;*/
/* }*/
/*}*/
import axios from 'axios';
import Cookies from 'js-cookie'
import {showToast} from 'vant';
import 'vant/es/toast/style';
import dayjs from 'dayjs';
import * as api from '../api/index.js'
// import {BASE_URL} from './publicURL.js'
// const BASE_URL = BASE_URL // 替换成你的API的基本URL
const axiosInstance = axios.create({
// baseURL: 'https://asc.hnasct.cn/DutyManagement',
baseURL: '/DutyManagement', // 默认地址代理转换为··域名·· 请求地址为 域名 + baseURL + 动态传入URL
timeout: 10000, // 设置请求超时时间,单位为毫秒
headers: {
'Content-Type': 'application/json',
// 可以在这里添加其他请求头信息
},
});
// const refreshTokenAction = () => {
// let flag = 1
// let currentTime = dayjs(dayjs().valueOf())
// // let refreshTime = dayjs(dayjs('2023-09-06T16:07:31.230Z').valueOf())
// let refreshTime = dayjs(dayjs(Cookies.get('time')).valueOf())
// console.log("🚀🚀🚀,")
// if (currentTime.diff(refreshTime) <= 2 * 60 * 60 * 1000 && flag === 1) {
// flag = 2
// api.RefreshToken()
// .then(res => {
// console.log('asdasd', res)
// Cookies.set('admin-token', res.response.access_token.token_content)
// Cookies.set('time', res.response.access_token.expires)
// flag = 1
// })
//
//
// }
//
//
// // console.log("🚀🚀🚀,", currentTime.diff(refreshTime))
// // console.log("🚀🚀🚀 dayjs().valueOf(),",currentTime,refreshTime,currentTime.diff(refreshTime) <= 15 * 60 * 1000)
// }
// 添加请求拦截器
let flag = 1; // 将 flag 移出函数,以便在多次调用之间保持不变
const refreshTokenAction = async () => {
if (flag === 1) {
flag = 2;
let currentTime = dayjs(dayjs().valueOf());
let refreshTime = dayjs(dayjs(Cookies.get('time')).valueOf());
if (refreshTime.diff(currentTime) <= 2 * 60 * 60 * 1000) {
try {
const res = await api.RefreshToken();
// console.log('asdasd', res.response.token_content, currentTime.format('YYYY-MM-DD HH:mm:ss'), refreshTime.format('YYYY-MM-DD HH:mm:ss'), refreshTime.diff(currentTime),);
Cookies.set('admin-token', res.response.token_content);
Cookies.set('time', res.response.expires);
} catch (error) {
console.error('刷新 Token 失败', error);
} finally {
flag = 1; // 无论成功或失败,都将 flag 重置为 1
}
}
}
};
axiosInstance.interceptors.request.use(
(config) => {
// 在发送请求之前可以进行一些处理,例如添加认证信息、日志等
let token = Cookies.get('admin-token')
config.headers['Authorization'] = 'Bearer ' + token
refreshTokenAction()
return config;
},
(error) => {
// 处理请求错误
return Promise.reject(error);
}
);
// 添加响应拦截器
axiosInstance.interceptors.response.use(
(response) => {
// 在这里可以对响应数据进行处理,例如解析JSON、错误处理等
return response.data;
},
(error) => {
// 处理响应错误
if (error && error.response) {
let msg = ''
switch (error.response.status) {
case 400:
msg = '请求错误';
break;
case 401:
msg = '未授权,请登录';
break;
case 403:
msg = '拒绝访问';
break;
case 404:
msg = `请求地址出错: ${error.response.config.url}`;
break;
case 408:
msg = '请求超时';
break;
case 500:
msg = '服务器内部错误';
break;
case 501:
msg = '服务未实现';
break;
case 502:
msg = '网关错误';
break;
case 503:
msg = '服务不可用';
break;
case 504:
msg = '网关超时';
break;
case 505:
msg = 'HTTP版本不受支持';
break;
default:
msg = '网络出了小差~';
break;
}
showToast(msg);
}
return Promise.reject(error);
}
);
export default axiosInstance
// export const BASE_URL = 'https://asc.hnasct.cn/DutyManagement/'; // 替换成你的API的基本URL
import axiosInstance from './axios.js'
export let requestGet = (url,data)=>{
return new Promise((resolve,reject)=>{
axiosInstance.get(url,data)
.then(res=>{
resolve(res)
})
.catch(err=>{
reject(err)
})
})
}
export const requestPost = (url,data)=>{
return new Promise((resolve,reject)=>{
axiosInstance.post(url,data)
.then(res=>{
resolve(res)
})
.catch(err=>{
reject(err)
})
})
}
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import {VantResolver} from 'unplugin-vue-components/resolvers';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
Components({
resolvers: [VantResolver()],
}),
],
base: './',
server: {
// host: "127.0.0.1",
// cors: true,
// port: 8991,
// open: true, //自动打开
proxy: {
// 这里的ccc可乱写, 是拼接在url后面的地址 如果接口中没有统一的后缀可自定义
// 如果有统一后缀, 如api, 直接写api即可, 也不用rewrite了
"/DutyManagement": {
target: "https://asc.hnasct.cn/", // 真实接口地址, 后端给的基地址
changeOrigin: true, // 允许跨域
// rewrite: (path) => path.replace(/^\/DutyManagement/, ""), // 将ccc替换为空
},
},
}
})
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或