2023-09-20 21:33:11 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<!-- 订单音效 -->
|
|
|
|
<audio controls="controls" hidden src="@/assets/sound/newMsg.mp3" ref="newMsg"></audio>
|
|
|
|
<audio controls="controls" hidden src="@/assets/sound/rebackMsg.mp3" ref="rebackMsg"></audio>
|
|
|
|
<!-- menu缩进按钮 -->
|
|
|
|
<div class="w-50px h-50px fc l" id="menuTabB" @click="handleCollapse">
|
|
|
|
<i class="iconfont f-s-26" :class="isCollapse ? 'icon-a-yousuojin3x' : 'icon-a-zuosuojin3x'"></i>
|
|
|
|
</div>
|
|
|
|
<!-- 面包屑 -->
|
|
|
|
<Breadcrumb class="l l-h-50 m-l-5" />
|
|
|
|
<!-- 头像 -->
|
|
|
|
<div class="right-menu m-r-5">
|
|
|
|
<el-dropdown class="avatar-container" trigger="click">
|
|
|
|
<div class="avatar-wrapper">
|
2023-10-18 15:58:44 +08:00
|
|
|
<img v-if="avatar.indexOf('.jpg') !== -1 || avatar.indexOf('.gif') !== -1 || avatar.indexOf('.png') !== -1"
|
|
|
|
:src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar">
|
|
|
|
<el-avatar v-else size="medium" icon="el-icon-user-solid"></el-avatar>
|
2023-09-20 21:33:11 +08:00
|
|
|
<i class="el-icon-caret-bottom" />
|
|
|
|
</div>
|
|
|
|
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
|
|
|
<el-dropdown-item divided>
|
|
|
|
<RouterLink to="/">
|
|
|
|
主控
|
|
|
|
</RouterLink>
|
|
|
|
</el-dropdown-item>
|
|
|
|
<el-dropdown-item divided @click.native="logout">
|
|
|
|
<span style="display:block;">退出登录</span>
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</div>
|
|
|
|
<!-- 页面刷新 -->
|
|
|
|
<div class="l-h-50 p-r-15 r">
|
|
|
|
<el-button size="small" icon="iconfont icon-shuaxin" @click="refreshPage" circle></el-button>
|
|
|
|
</div>
|
|
|
|
<!-- 订单信息按钮 -->
|
2023-11-09 21:39:50 +08:00
|
|
|
<el-badge :hidden="pendingCount + processingCount + requestedCount == 0 ? true : false"
|
|
|
|
:value="pendingCount + processingCount + requestedCount" class="navbarBadge l-h-50 p-r-15 r">
|
|
|
|
<el-button :type="pendingCount + processingCount + requestedCount !== 0 ? 'primary' : ''" @click="drawer = true"
|
|
|
|
size="small" :icon="orderIcon" circle></el-button>
|
2023-09-20 21:33:11 +08:00
|
|
|
</el-badge>
|
2023-11-09 21:39:50 +08:00
|
|
|
<el-drawer :visible.sync="drawer" size="40%" :append-to-body="true" :modal-append-to-body="false">
|
|
|
|
<template slot="title">
|
|
|
|
<div>
|
|
|
|
<i class="l f-s-18 iconfont icon-jinjidingdan m-r-5 l-h-18"></i>
|
|
|
|
<h3>
|
|
|
|
待处理订单
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<el-button-group class="m-l-20 m-b-15">
|
|
|
|
<SelectionShopId v-model="shop_id" />
|
|
|
|
</el-button-group>
|
2023-09-20 21:33:11 +08:00
|
|
|
<el-tabs type="card">
|
2023-11-09 21:39:50 +08:00
|
|
|
<el-tab-pane>
|
|
|
|
<template slot="label">
|
|
|
|
<span>已付款处理中</span>
|
|
|
|
<el-badge :hidden="pendingCount == 0 ? true : false" :value="pendingCount">
|
|
|
|
</el-badge>
|
|
|
|
</template>
|
|
|
|
<QuestTabs :fil='0' :shop_id="shop_id" />
|
2023-09-20 21:33:11 +08:00
|
|
|
</el-tab-pane>
|
2023-11-09 21:39:50 +08:00
|
|
|
<el-tab-pane>
|
|
|
|
<template slot="label">
|
|
|
|
<span>已接单备货中</span>
|
|
|
|
<el-badge :hidden="processingCount == 0 ? true : false" :value="processingCount">
|
|
|
|
</el-badge>
|
|
|
|
</template>
|
|
|
|
<QuestTabs :fil='1' :shop_id="shop_id" />
|
2023-09-20 21:33:11 +08:00
|
|
|
</el-tab-pane>
|
2023-11-09 21:39:50 +08:00
|
|
|
<el-tab-pane>
|
|
|
|
<template slot="label">
|
|
|
|
<span>申请退款订单</span>
|
|
|
|
<el-badge :hidden="requestedCount == 0 ? true : false" :value="requestedCount">
|
|
|
|
</el-badge>
|
|
|
|
</template>
|
|
|
|
<QuestTabs :fil='2' :shop_id="shop_id" />
|
2023-09-20 21:33:11 +08:00
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
</el-drawer>
|
|
|
|
<!-- mqtt状态灯 -->
|
2023-10-18 15:58:44 +08:00
|
|
|
<div class="l-h-50 p-r-15 r">
|
|
|
|
<el-button size="small" :type="mqttState === true ? 'success' : 'danger'"
|
|
|
|
:icon="mqttState === true ? 'iconfont icon-yaokong2' : 'iconfont icon-yaokong2-copy'" circle
|
|
|
|
@click="mqttState === true ? $message.success('指令服务器链接正常') : $message.error('未链接到指令服务器')"></el-button>
|
|
|
|
</div>
|
2023-09-20 21:33:11 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import mqtt from '@/utils/mqtt'
|
|
|
|
import Breadcrumb from '@/components/Breadcrumb'
|
|
|
|
import QuestTabs from '@/components/QuestTabs'
|
2023-11-09 21:39:50 +08:00
|
|
|
import SelectionShopId from '@/components/SelectionShopId'
|
2023-09-20 21:33:11 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'Headbar',
|
|
|
|
data () {
|
|
|
|
return {
|
2023-11-09 21:39:50 +08:00
|
|
|
shop_id: '', // 商铺id 过滤条件
|
|
|
|
pendingCount: null, // 处理中 订单总数
|
|
|
|
processingCount: null, // 备货中 订单总数
|
|
|
|
requestedCount: null, // 申请退款 订单总数
|
2023-09-20 21:33:11 +08:00
|
|
|
drawer: false,
|
|
|
|
getQuestInterval: null, // 用于销毁时间轴
|
|
|
|
animationTrumpet: true // 喇叭动画
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
Breadcrumb,
|
2023-11-09 21:39:50 +08:00
|
|
|
QuestTabs,
|
|
|
|
SelectionShopId
|
2023-09-20 21:33:11 +08:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
/**
|
|
|
|
* @description: 侧边栏显隐
|
|
|
|
*/
|
|
|
|
isCollapse () {
|
|
|
|
return this.$store.state.app.isCollapse
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: mqtt服务器连接状态
|
|
|
|
*/
|
|
|
|
mqttState () {
|
|
|
|
return this.$store.state.app.mqttState
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 用户头像地址
|
|
|
|
*/
|
|
|
|
avatar () {
|
2024-04-26 23:07:51 +08:00
|
|
|
return this.$store.state.settings.photoPath + this.$store.state.user.photo
|
2023-09-20 21:33:11 +08:00
|
|
|
},
|
|
|
|
/**
|
2023-11-09 21:39:50 +08:00
|
|
|
* @description: 获取订单列表
|
2023-09-20 21:33:11 +08:00
|
|
|
*/
|
2023-11-09 21:39:50 +08:00
|
|
|
orderList () {
|
|
|
|
return this.$store.state.orderList
|
2023-09-20 21:33:11 +08:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 面包条 订单图标动画
|
|
|
|
* @return {*} 图标样式
|
|
|
|
*/
|
|
|
|
orderIcon () {
|
2023-11-09 21:39:50 +08:00
|
|
|
if (this.pendingCount + this.processingCount + this.requestedCount === 0) {
|
2023-09-20 21:33:11 +08:00
|
|
|
return 'iconfont icon-meiyoudingdan-01'
|
|
|
|
} else {
|
|
|
|
if (this.animationTrumpet) {
|
|
|
|
return 'iconfont icon-tongzhi'
|
|
|
|
} else {
|
|
|
|
return 'iconfont icon-jinjidingdan'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
/**
|
|
|
|
* @description: 切换侧边栏 显隐
|
|
|
|
*/
|
|
|
|
handleCollapse () {
|
|
|
|
this.$store.commit('app/setCollapse')
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 计算订单数量 订单变化播放声音 显示在图标右上角小红圈内
|
|
|
|
* @param {*} list 要处理的订单列表
|
|
|
|
*/
|
|
|
|
computeQuestList (list) {
|
|
|
|
if (this.getQuestInterval !== null) {
|
|
|
|
clearInterval(this.getQuestInterval)
|
|
|
|
}
|
2024-06-04 18:12:32 +08:00
|
|
|
const pending = list.filter(item => item.status === 'pending' && item.back === 'normal')// 过滤处理中 订单
|
|
|
|
const processing = list.filter(item => item.status === 'processing' && item.back === 'normal')// 过滤 备货中订单
|
2023-11-09 21:39:50 +08:00
|
|
|
const requested = list.filter(item => item.back === 'requested')// 过滤退款订单
|
|
|
|
if (this.pendingCount < pending.length && this.pendingCount != null) { // 有新的数据 播放提示声音
|
2023-09-20 21:33:11 +08:00
|
|
|
this.playMusic('newMsg')// 新消息 声音播放
|
|
|
|
}
|
2023-11-09 21:39:50 +08:00
|
|
|
if (this.requestedCount < requested.length && this.requestedCount != null) { // 有新的数据 播放提示声音
|
2023-09-20 21:33:11 +08:00
|
|
|
this.playMusic('rebackMsg')// 退款 声音播放
|
|
|
|
}
|
2023-11-09 21:39:50 +08:00
|
|
|
this.pendingCount = pending.length// 处理中 订单总数
|
|
|
|
this.processingCount = processing.length// 备货中 订单总数
|
|
|
|
this.requestedCount = requested.length// 申请退款 订单总数
|
2023-09-20 21:33:11 +08:00
|
|
|
this.getQuestInterval = setInterval(() => {
|
|
|
|
this.animationTrumpet = !this.animationTrumpet// 面包条订单图标跳动
|
|
|
|
}, 500)
|
|
|
|
},
|
|
|
|
// 新消息 声音播放
|
|
|
|
playMusic (domId) {
|
|
|
|
const audioElement = this.$refs[domId]
|
|
|
|
if (!audioElement) {
|
|
|
|
console.error(`音频元素 ${domId} 不存在`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
audioElement.currentTime = 0 // 从头开始播放
|
|
|
|
audioElement.play()
|
|
|
|
.then(() => {
|
|
|
|
console.log('音频播放成功')
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('音频播放失败', error)
|
|
|
|
})
|
|
|
|
setTimeout(() => {
|
|
|
|
audioElement.pause() // 停止
|
|
|
|
}, 11000)
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 刷新当前页面
|
|
|
|
*/
|
|
|
|
refreshPage () {
|
|
|
|
mqtt.mqttDestroy()// 断开mqtt
|
|
|
|
this.$router.go(0)// 刷新页面
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @description: 登出
|
|
|
|
*/
|
|
|
|
logout () {
|
|
|
|
this.$store.dispatch('user/destroyUserAsync').then(
|
|
|
|
this.$router.push('/login')
|
|
|
|
)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2023-11-09 21:39:50 +08:00
|
|
|
orderList (val) {
|
2023-09-20 21:33:11 +08:00
|
|
|
this.computeQuestList(val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import "@/styles/theme.scss";
|
|
|
|
|
|
|
|
#menuTabB:hover {
|
|
|
|
background-color: $border4-color;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-dropdown-menu {
|
|
|
|
span {
|
|
|
|
color: $maintext-color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.right-menu {
|
|
|
|
float: right;
|
|
|
|
height: 100%;
|
|
|
|
line-height: 50px;
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.right-menu-item {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 0 8px;
|
|
|
|
height: 100%;
|
|
|
|
font-size: 18px;
|
|
|
|
vertical-align: text-bottom;
|
|
|
|
|
|
|
|
&.hover-effect {
|
|
|
|
cursor: pointer;
|
|
|
|
transition: background .3s;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: rgba(0, 0, 0, .025)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.avatar-container {
|
|
|
|
margin-right: 30px;
|
|
|
|
|
|
|
|
.avatar-wrapper {
|
|
|
|
margin-top: 5px;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
.user-avatar {
|
|
|
|
cursor: pointer;
|
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
|
|
|
border-radius: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-icon-caret-bottom {
|
|
|
|
cursor: pointer;
|
|
|
|
position: absolute;
|
|
|
|
right: -20px;
|
|
|
|
top: 25px;
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|