floatButton

This commit is contained in:
shijing 2021-10-19 16:38:39 +08:00
parent 5ac6a2b1bf
commit ba69ce62de
10 changed files with 118 additions and 9 deletions

View File

@ -14,9 +14,19 @@ export default {
},
data(){
return{
isRouterAlive:true
isRouterAlive:true,
timer:null
}
},
mounted(){
this.$store.dispatch("user/getCount", {})
this.timer = window.setInterval(() => {
setTimeout(() => {
this.$store.dispatch("user/getCount", {})
},0)
},30000)
},
methods:{
reload(){
this.isRouterAlive=false;
@ -24,6 +34,9 @@ export default {
this.isRouterAlive=true;
})
},
},
destroyed() {
clearInterval(this.timer)
}
}
</script>
@ -36,4 +49,9 @@ export default {
.el-step__title.is-process{
color: #409EFF;
}
.navbarBadge .el-badge__content.is-fixed{
top: 15px;
right: 18px;
}
</style>

View File

@ -1,7 +1,7 @@
import request from '@/utils/request'
export function faceLogin(data) {
return request({
url: '/system/facelogin/',
url: '/hrm/facelogin/',
method: 'post',
data
})

View File

@ -225,3 +225,11 @@ export function getTicketFlowlog(id) {
method: 'get'
})
}
//工单代办数量
export function getCount(data) {
return request({
url: `/wf/ticket/duty_agg/`,
method: 'get',
params:data
})
}

View File

@ -6,6 +6,9 @@
<div class="right-menu">
<template>
<el-badge v-if="count>0" :value="count" class="item right-menu-item navbarBadge" @click.native="gotoTicketPage">
<el-icon class="el-icon-s-management" @click.native="gotoTicketPage" style="font-size: 25px;color: #409EFF;padding-top: 12px;cursor: pointer;"></el-icon>
</el-badge>
<search id="header-search" class="right-menu-item" />
<el-tooltip content="全局组件大小" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
@ -69,9 +72,14 @@ export default {
'sidebar',
'avatar',
'name',
'count',
])
},
methods: {
gotoTicketPage(){
debugger;
this.$router.push({name:'ticket',params:{}})
},
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},

View File

@ -8,6 +8,12 @@
<tags-view />
</div>
<app-main />
<div class="floatDiv" @click="gotoTicketPage" v-if="count>0">
<el-badge :value="count" class="item ">
<el-icon class="el-icon-s-management" style="font-size: 30px;color: #409EFF;padding-top: 12px;"></el-icon>
</el-badge>
</div>
</div>
</div>
</template>
@ -15,6 +21,7 @@
<script>
import { Navbar, Sidebar, AppMain,TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
import { mapGetters } from 'vuex'
export default {
name: 'Layout',
@ -26,6 +33,9 @@ export default {
},
mixins: [ResizeMixin],
computed: {
...mapGetters([
'count',
]),
sidebar() {
return this.$store.state.app.sidebar
},
@ -47,7 +57,10 @@ export default {
methods: {
handleClickOutside() {
this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
}
},
gotoTicketPage(){
this.$router.push({name:'ticket',params:{}})
},
}
}
</script>
@ -92,4 +105,17 @@ export default {
.mobile .fixed-header {
width: 100%;
}
.floatDiv{
position: fixed;
z-index: 3000;
bottom: 10vh;
right: 5vh;
width: 50px;
height: 50px;
cursor: pointer;
text-align: center;
line-height: 50px;
border-radius: 26px;
border: 2px solid #409EFF;
}
</style>

View File

@ -5,6 +5,7 @@ const getters = {
avatar: state => state.user.avatar,
name: state => state.user.name,
perms: state => state.user.perms,
count: state => state.user.count,
size: state => state.app.size,
permission_routes: state => state.permission.routes,
visitedViews: state => state.tagsView.visitedViews,

View File

@ -1,4 +1,5 @@
import { login, logout, getInfo } from '@/api/user'
import { getCount } from '@/api/workflow'
import { getToken, setToken, removeToken } from '@/utils/auth'
import { resetRouter } from '@/router'
@ -7,6 +8,7 @@ const getDefaultState = () => {
token: getToken(),
name: '',
avatar: '',
count: '',
perms: []
}
}
@ -28,6 +30,9 @@ const mutations = {
},
SET_PERMS: (state, perms) => {
state.perms = perms
},
SET_COUNT: (state, count) => {
state.count = count
}
}
@ -90,15 +95,27 @@ const actions = {
},
// remove token
resetToken({ commit }) {
resetToken({ commit },data) {
return new Promise(resolve => {
removeToken() // must remove token first
commit('RESET_STATE')
removeToken(); // must remove token first
commit('RESET_STATE');
commit('SET_TOKEN', data.access);
setToken(data.access);
resolve()
})
},
setSize({ commit }, size) {
commit('SET_SIZE', size)
},
getCount({ commit }) {
return new Promise((resolve, reject) => {
getCount({}).then((res) => {
commit('SET_COUNT', res.data.total_count);
resolve()
}).catch(error => {
reject(error)
})
})
}
}

View File

@ -1,5 +1,9 @@
<template>
<div class="dashboard-container">
<el-badge v-if="count>0" :value="count" class="item" @click.native="gotoTicketPage">
<el-icon class="el-icon-s-management" @click.native="gotoTicketPage" style="font-size: 70px;color: #d29898"></el-icon>
</el-badge>
<div></div>
<div class="dashboard-text">name: {{ name }}</div>
<div class="dashboard-text">perms: <span v-for="perm in perms" :key="perm">{{ perm }}</span></div>
</div>
@ -13,8 +17,15 @@ export default {
computed: {
...mapGetters([
'name',
'perms'
'perms',
'count'
])
},
methods:{
gotoTicketPage(){
debugger;
this.$router.push({name:'ticket',params:{}})
},
}
}
</script>

View File

@ -140,6 +140,7 @@
this.$store
.dispatch("user/login", this.loginForm)
.then(() => {
this.$store.dispatch("user/getCount", {})
this.$router.push({ path: this.redirect || "/" });
this.loading = false;
localStorage.setItem("rem_username", this.loginForm.username);
@ -148,6 +149,7 @@
.catch(() => {
this.loading = false;
});
} else {
console.log("error submit!!");
return false;

View File

@ -13,13 +13,15 @@
<script>
import {faceLogin} from "@/api/testModel";
import { setToken, removeToken } from '@/utils/auth'
import { login, getInfo } from '@/api/user'
// import "tracking/build/data/face-min.js";
// import "tracking/build/data/mouth-min.js";
// import "tracking/build/data/tracking-min.js";
// import "tracking/examples/assets/stats.min.js";
// import "tracking/examples/assets/stats.min.js";
export default {
props:['src'],
inject:['reload'],
data () {
return {
videoWidth: 500,
@ -69,9 +71,25 @@
let image = new Image();
image = canvas.toDataURL('image/png');
document.getElementById('res').innerHTML = '<img src="'+image+'">';
let imgData = {base64:image};
let img = image.split(',')[1];
let imgData = {base64:img};
faceLogin(imgData).then((res) => {
if (res.code >= 200) {
debugger;
console.log(res);
let data = res.data;
this.$confirm("是否切换登陆人?", "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "warning",
}).then(async () => {
await this.$store.dispatch("user/resetToken",data);
await this.$store.dispatch("user/getInfo",data.access);
window.location.reload();
})
.catch((err) => {
console.error(err);
});
this.$message.success("成功");
}
});