大屏优化

This commit is contained in:
赵正易 2025-02-22 14:31:00 +08:00
parent 71e3a1bbe3
commit 126eeff5c3
5 changed files with 303 additions and 276 deletions

View File

@ -1,114 +1,114 @@
<template>
<div :class="{ hidden: hidden }" class="pagination-container">
<el-pagination
small
background
v-model:current-page="currentPage"
v-model:page-size="pageSize"
:layout="layout"
:page-sizes="pageSizes"
:pager-count="pagerCount"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange" />
</div>
<div :class="{ hidden: hidden }" class="pagination-container">
<el-pagination
size="small"
background
v-model:current-page="currentPage"
v-model:page-size="pageSize"
:layout="layout"
:page-sizes="pageSizes"
:pager-count="pagerCount"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange" />
</div>
</template>
<script>
// import { scrollTo } from "@/utils/scroll-to";
import { computed } from 'vue'
export default {
name: 'pagingation',
emits: ['update:page', 'update:limit', 'pagination'],
props: {
total: {
required: true,
type: Number
name: 'pagingation',
emits: ['update:page', 'update:limit', 'pagination'],
props: {
total: {
required: true,
type: Number
},
page: {
type: Number,
default: 1
},
limit: {
type: Number,
default: 20
},
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50, 100]
}
},
// 5
pagerCount: {
type: Number,
default: document.body.clientWidth < 992 ? 5 : 7
},
layout: {
type: String,
default: 'total, sizes, prev, pager, next, jumper'
},
background: {
type: Boolean,
default: true
},
autoScroll: {
type: Boolean,
default: true
},
hidden: {
type: Boolean,
default: false
}
},
page: {
type: Number,
default: 1
},
limit: {
type: Number,
default: 20
},
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50, 100]
}
},
// 5
pagerCount: {
type: Number,
default: document.body.clientWidth < 992 ? 5 : 7
},
layout: {
type: String,
default: 'total, sizes, prev, pager, next, jumper'
},
background: {
type: Boolean,
default: true
},
autoScroll: {
type: Boolean,
default: true
},
hidden: {
type: Boolean,
default: false
}
},
setup(props, { ctx, emit }) {
const currentPage = computed({
get() {
return props.page
},
set(val) {
emit('update:page', val)
}
})
const pageSize = computed({
get() {
return props.limit
},
set(val) {
emit('update:limit', val)
}
})
setup(props, { ctx, emit }) {
const currentPage = computed({
get() {
return props.page
},
set(val) {
emit('update:page', val)
}
})
const pageSize = computed({
get() {
return props.limit
},
set(val) {
emit('update:limit', val)
}
})
function handleSizeChange(val) {
emit('pagination', { page: currentPage.value, limit: val })
if (props.autoScroll) {
// scrollTo(0, 800);
}
}
function handleCurrentChange(val) {
emit('pagination', { page: val, limit: pageSize.value })
if (props.autoScroll) {
// scrollTo(0, 800);
}
}
function handleSizeChange(val) {
emit('pagination', { page: currentPage.value, limit: val })
if (props.autoScroll) {
// scrollTo(0, 800);
}
}
function handleCurrentChange(val) {
emit('pagination', { page: val, limit: pageSize.value })
if (props.autoScroll) {
// scrollTo(0, 800);
}
}
return {
currentPage,
pageSize,
handleSizeChange,
handleCurrentChange
return {
currentPage,
pageSize,
handleSizeChange,
handleCurrentChange
}
}
}
}
</script>
<style scoped>
.pagination-container {
/* background: #fff; */
padding: 20px 16px 0;
display: flex;
justify-content: flex-end;
/* background: #fff; */
padding: 20px 16px 0;
display: flex;
justify-content: flex-end;
}
.pagination-container.hidden {
display: none;
display: none;
}
</style>

View File

@ -5,79 +5,82 @@ import { webNotify } from '@/utils/index'
import gongaoIcon from '@/assets/icons/svg/gonggao.svg'
export default {
onMessage(connection) {
connection.on(MsgType.M001, (data) => {
useSocketStore().setOnlineUsers(data)
})
// 接收后台手动推送消息
connection.on('receiveNotice', (title, data) => {
ElNotification({
type: 'info',
title: title,
message: data,
dangerouslyUseHTMLString: true,
duration: 0
})
webNotify({ title: title, body: '你有一条新消息', icon: gongaoIcon })
})
// 接收系统通知/公告
connection.on('moreNotice', (data) => {
if (data.code == 200) {
useSocketStore().setNoticeList(data.data)
}
})
// 接收在线用户
// connection.on('onlineUser', (data) => {
// useSocketStore().setOnlineUsers(data)
// })
// 接收强退通知
connection.on('forceUser', (data) => {
useSocketStore().setGlobalError({ code: 0, msg: `你的账号已被强退,原因:${data.reason || '无'}` })
useUserStore()
.logOut()
.then(() => {
location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'error'
onMessage(connection) {
connection.on(MsgType.M001, (data) => {
useSocketStore().setOnlineUsers(data)
})
})
// 接收聊天数据
connection.on('receiveChat', (data) => {
const { fromUser, message } = data
useSocketStore().setChat(data)
if (data.userId != useUserStore().userId) {
ElNotification({
title: fromUser.nickName,
message: message,
type: 'success',
duration: 3000
// 接收后台手动推送消息
connection.on('receiveNotice', (title, data) => {
ElNotification({
type: 'info',
title: title,
message: data,
dangerouslyUseHTMLString: true,
duration: 0
})
webNotify({ title: title, body: '你有一条新消息', icon: gongaoIcon })
})
webNotify({ title: '来自:' + fromUser.nickName, body: message, icon: gongaoIcon })
}
})
connection.on('onlineInfo', (data) => {
useSocketStore().getOnlineInfo(data)
})
connection.on(MsgType.LogOut, () => {
useUserStore()
.logOut()
.then(() => {
ElMessageBox.alert(`你的账号已在其他设备登录,如果不是你的操作请尽快修改密码`, '提示', {
confirmButtonText: '确定',
callback: () => {
location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index'
// 接收系统通知/公告
connection.on('moreNotice', (data) => {
if (data.code == 200) {
useSocketStore().setNoticeList(data.data)
}
})
})
})
}
// 接收在线用户
// connection.on('onlineUser', (data) => {
// useSocketStore().setOnlineUsers(data)
// })
// 接收强退通知
connection.on('forceUser', (data) => {
useSocketStore().setGlobalError({ code: 0, msg: `你的账号已被强退,原因:${data.reason || '无'}` })
useUserStore()
.logOut()
.then(() => {
location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'error'
})
})
// 接收聊天数据
connection.on('receiveChat', (data) => {
const { fromUser, message } = data
useSocketStore().setChat(data)
if (data.userId != useUserStore().userId) {
ElNotification({
title: fromUser.nickName,
message: message,
type: 'success',
duration: 3000
})
webNotify({ title: '来自:' + fromUser.nickName, body: message, icon: gongaoIcon })
}
})
connection.on('onlineInfo', (data) => {
useSocketStore().getOnlineInfo(data)
})
connection.on(MsgType.M002, (data) => {
console.log('connId', data)
})
connection.on(MsgType.LogOut, () => {
useUserStore()
.logOut()
.then(() => {
ElMessageBox.alert(`你的账号已在其他设备登录,如果不是你的操作请尽快修改密码`, '提示', {
confirmButtonText: '确定',
callback: () => {
location.href = import.meta.env.VITE_APP_ROUTER_PREFIX + 'index'
}
})
})
})
}
}
const MsgType = {
M001: 'onlineNum',
M002: 'connId',
LogOut: 'logOut'
M001: 'onlineNum',
M002: 'connId',
LogOut: 'logOut'
}

View File

@ -5,120 +5,129 @@ import cache from '@/plugins/cache'
import analysis from '@/signalr/analysis'
export default {
// signalR对象
SR: {},
PBL_SR: {},
// 失败连接重试次数
failNum: 4,
PBL_failNum: 5,
// signalR对象
SR: {},
PBL_SR: {},
// 失败连接重试次数
failNum: 4,
PBL_failNum: 5,
init(url) {
var socketUrl = window.location.origin + url + '?clientId=' + cache.local.get('clientId')
const connection = new signalR.HubConnectionBuilder()
.withUrl(socketUrl, { accessTokenFactory: () => getToken() })
.withAutomaticReconnect() //自动重新连接
.configureLogging(signalR.LogLevel.Warning)
.build()
init(url) {
var socketUrl = window.location.origin + url + '?clientId=' + cache.local.get('clientId')
const connection = new signalR.HubConnectionBuilder()
.withUrl(socketUrl, { accessTokenFactory: () => getToken() })
.withAutomaticReconnect() //自动重新连接
.configureLogging(signalR.LogLevel.Warning)
.build()
this.SR = connection
this.SR = connection
// 断线重连
connection.onclose(async (error) => {
console.error('断开连接了', error)
await this.start()
})
// 断线重连
connection.onclose(async (error) => {
console.error('断开连接了', error)
await this.start()
})
connection.onreconnected((connectionId) => {
ElMessage({
message: '主信号通道与服务器通讯已连接成功',
type: 'success',
duration: 2000
})
console.log('断线重新连接成功', connectionId)
})
connection.onreconnected((connectionId) => {
ElMessage({
message: '主信号通道与服务器通讯已连接成功',
type: 'success',
duration: 2000
})
console.log('断线重新连接成功', connectionId)
})
connection.onreconnecting(() => {
console.log('断线重新连接中...')
})
connection.onreconnecting(() => {
console.log('断线重新连接中...')
})
// 启动连接后设置消息处理函数
this.start().then(() => {
analysis.onMessage(connection)
})
},
// 启动连接后设置消息处理函数
this.start().then(() => {
analysis.onMessage(connection)
})
},
async start() {
try {
console.log('signalR-1', this.SR.state)
if (this.SR.state === signalR.HubConnectionState.Disconnected) {
await this.SR.start()
}
console.log('signalR-2', this.SR.state)
return true
} catch (error) {
console.error(error)
this.failNum--
if (this.failNum > 0 && this.SR.state === signalR.HubConnectionState.Disconnected) {
setTimeout(async () => {
await this.start()
}, 5000)
}
return false
async start() {
try {
console.log('signalR-1', this.SR.state)
if (this.SR.state === signalR.HubConnectionState.Disconnected) {
await this.SR.start()
}
console.log('signalR-2', this.SR.state)
return true
} catch (error) {
console.error(error)
this.failNum--
if (this.failNum > 0 && this.SR.state === signalR.HubConnectionState.Disconnected) {
setTimeout(async () => {
await this.start()
}, 5000)
}
return false
}
},
initPBL(url) {
var socketUrl = window.location.origin + url + '?clientId=' + cache.local.get('clientId')
const connection = new signalR.HubConnectionBuilder()
.withUrl(socketUrl, { accessTokenFactory: () => getToken() })
.withAutomaticReconnect() //自动重新连接
.configureLogging(signalR.LogLevel.Warning)
.build()
this.PBL_SR = connection
// 断线重连
connection.onclose(async (error) => {
console.error('PBL后台断开连接了', error)
await this.doPblSrStart()
})
connection.onreconnected((connectionId) => {
ElMessage({
message: 'PBL后台信号通道与服务器通讯已连接成功',
type: 'success',
duration: 2000
})
console.log('断线重新连接成功', connectionId)
})
connection.onreconnecting(() => {
console.log('PBL后台断线重新连接中...')
})
// 启动连接后设置消息处理函数
this.doPblSrStart().then(() => {
//analysis.onMessage(connection)
connection.on('PBL_bom_except', (data) => {
// console.log('PBL_bom_except', data)
})
connection.on('PBL_storagelocation_change', (data) => {
// console.log('PBL_storagelocation_change', data)
})
connection.on('pbl_lack_alarm', (data) => {
// console.log('pbl_lack_alarm', data)
})
})
},
async doPblSrStart() {
try {
console.log('PBL_signalR-1', this.PBL_SR.state)
if (this.PBL_SR.state === signalR.HubConnectionState.Disconnected) {
await this.PBL_SR.start()
}
console.log('PBL_signalR-2', this.PBL_SR.state)
return true
} catch (error) {
console.error(error)
this.PBL_failNum--
if (this.PBL_failNum > 0 && this.PBL_SR.state === signalR.HubConnectionState.Disconnected) {
setTimeout(async () => {
await this.doPblSrStart()
}, 5000)
}
return false
}
}
},
initPBL(url) {
var socketUrl = window.location.origin + url + '?clientId=' + cache.local.get('clientId')
const connection = new signalR.HubConnectionBuilder()
.withUrl(socketUrl, { accessTokenFactory: () => getToken() })
.withAutomaticReconnect() //自动重新连接
.configureLogging(signalR.LogLevel.Warning)
.build()
this.PBL_SR = connection
// 断线重连
connection.onclose(async (error) => {
console.error('PBL后台断开连接了', error)
await this.doPblSrStart()
})
connection.onreconnected((connectionId) => {
ElMessage({
message: 'PBL后台信号通道与服务器通讯已连接成功',
type: 'success',
duration: 2000
})
console.log('断线重新连接成功', connectionId)
})
connection.onreconnecting(() => {
console.log('PBL后台断线重新连接中...')
})
// 启动连接后设置消息处理函数
this.doPblSrStart().then(() => {
analysis.onMessage(connection)
})
},
async doPblSrStart() {
try {
console.log('PBL_signalR-1', this.PBL_SR.state)
if (this.PBL_SR.state === signalR.HubConnectionState.Disconnected) {
await this.PBL_SR.start()
}
console.log('PBL_signalR-2', this.PBL_SR.state)
return true
} catch (error) {
console.error(error)
this.PBL_failNum--
if (this.PBL_failNum > 0 && this.PBL_SR.state === signalR.HubConnectionState.Disconnected) {
setTimeout(async () => {
await this.doPblSrStart()
}, 5000)
}
return false
}
}
}

View File

@ -30,9 +30,9 @@
<el-col :span="1.5">
<el-button type="warning" v-hasPermi="['storagelocation:export']" plain icon="download" @click="handleExport"> 导出数据 </el-button>
</el-col>
<el-col :span="1.5">
<!-- <el-col :span="1.5">
<el-button type="info" v-hasPermi="['storagelocation:import']" plain icon="upload" @click="handleImport"> 导入数据 </el-button>
</el-col>
</el-col> -->
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row>
@ -49,6 +49,13 @@
</el-table-column>
<el-table-column prop="maxCapacity" label="层容量" align="center" v-if="columns.showColumn('maxCapacity')" />
<el-table-column prop="packageNum" label="当前箱数" align="center" v-if="columns.showColumn('packageNum')" />
<el-table-column prop="alarmNum" label="最低安全库存" align="center" />
<el-table-column prop="isLackAlarm" label="是否触发补料报警" align="center">
<template #default="scope">
<span v-if="scope.row.isLackAlarm == 1"></span>
<span v-if="scope.row.isLackAlarm == 0"></span>
</template>
</el-table-column>
<el-table-column prop="createdBy" label="创建人" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('createdBy')" />
<el-table-column prop="createdTime" label="创建时间" :show-overflow-tooltip="true" v-if="columns.showColumn('createdTime')" />
<el-table-column prop="updatedBy" label="更新人" align="center" :show-overflow-tooltip="true" v-if="columns.showColumn('updatedBy')" />
@ -85,6 +92,11 @@
<el-input v-model.number="form.maxCapacity" placeholder="请输入箱容量" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="最低安全库存" prop="alarmNum">
<el-input v-model.number="form.alarmNum" placeholder="请输入最低安全库存" />
</el-form-item>
</el-col>
<el-col :lg="12">
<el-form-item label="当前箱数" prop="packageNum">
<el-input v-model.number="form.packageNum" placeholder="请输入当前箱数" />

View File

@ -67,7 +67,7 @@
<div>
<!-- 控制按钮 -->
<button @click="toggleMute">{{ isMuted ? '取消静音' : '静音' }}</button>
<button @click="togglePlay">{{ isPlaying ? '暂停' : '播放' }}</button>
<button @click="togglePlay">{{ isPlaying ? '暂停' : '允许播放' }}</button>
</div>
</div>
</el-col>
@ -160,6 +160,7 @@ function getBoxClass(packageCount, slotIndex) {
const mqtt = mqttStore()
function initializeSignalR() {
const messageHandler = (data) => {
console.log('接收到消息[messageHandler]:', data)
if (typeof data === 'string') {
pblBomExceptMessage.value = data
} else {
@ -167,9 +168,11 @@ function initializeSignalR() {
}
}
const packageChangeHandler = () => {
console.log('接收到消息[packageChangeHandler]')
fetchShelfData()
}
const lackAlarmHandler = () => {
console.log('接收到消息[lackAlarmHandler]')
togglePlay()
fetchShelfData()
}
@ -198,8 +201,8 @@ onMounted(() => {
//
// let refreshTimer = null
// function startAutoRefresh() {
// clearInterval(refreshTimer)
// refreshTimer = setInterval(fetchShelfData, 1000)
// clearInterval(refreshTimer)
// refreshTimer = setInterval(fetchShelfData, 1000)
// }
// onMounted(startAutoRefresh)