Browse Source

fix: 用户判断的问题

master
guoapeng 2 weeks ago
parent
commit
d777260977
  1. 6
      src/components/audit/History.vue
  2. 59
      src/layouts/default.vue
  3. 39
      src/stores/systemStore.ts
  4. 8
      src/views/login/index.vue

6
src/components/audit/History.vue

@ -127,14 +127,16 @@ const deleteBtnVisible = computed(() => {
<el-table :data="tableData" style="width: 100%" height="100%" @selection-change="handleSelectionChange"> <el-table :data="tableData" style="width: 100%" height="100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55" />
<el-table-column type="index" label="序号" width="80" /> <el-table-column type="index" label="序号" width="80" />
<el-table-column prop="name" label="消毒日期"/>
<el-table-column prop="name" label="消毒日期" />
<el-table-column prop="detail" label="操作" width="200"> <el-table-column prop="detail" label="操作" width="200">
<template #default="scoped"> <template #default="scoped">
<div class="user-opera"> <div class="user-opera">
<el-button class="view-button" @click.stop="showDetail(scoped.row)"> <el-button class="view-button" @click.stop="showDetail(scoped.row)">
查看 查看
</el-button> </el-button>
<el-button class="print-button" title="打印" @click.stop="printDetail(scoped.row)">打印</el-button>
<el-button class="print-button" title="打印" @click.stop="printDetail(scoped.row)">
打印
</el-button>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>

59
src/layouts/default.vue

@ -3,7 +3,8 @@ import WifiConnSvg from 'assets/images/wifi-conn.svg'
import WifiUnconnSvg from 'assets/images/wifi-unconn.svg' import WifiUnconnSvg from 'assets/images/wifi-unconn.svg'
import ErrorEventsModal from 'components/system/ErrorEventsModal.vue' import ErrorEventsModal from 'components/system/ErrorEventsModal.vue'
import NetReconnection from 'components/system/NetReconnection.vue' import NetReconnection from 'components/system/NetReconnection.vue'
import { formatDateTime, openFullscreen } from 'libs/utils'
import { delToken } from 'libs/token'
import { formatDateTime } from 'libs/utils'
import { authRoutes } from 'router/routes' import { authRoutes } from 'router/routes'
import { useDeviceStore } from 'stores/deviceStore' import { useDeviceStore } from 'stores/deviceStore'
import { computed, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue' import { computed, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue'
@ -38,12 +39,6 @@ const liquidDrainState = ref(liquidStore.liquidDrainWorkState)
const deviceState = ref(deviceStore.deviceState) const deviceState = ref(deviceStore.deviceState)
const sealInfo = ref(sealStore.sealInfo) const sealInfo = ref(sealStore.sealInfo)
const websocketConnected = ref(systemStore.websocketConnected) const websocketConnected = ref(systemStore.websocketConnected)
let touchStartTime = 0
let touchCount = 0
const userData = localStorage.getItem('user')
const userInfo = userData ? JSON.parse(userData) : {}
const userRole = userInfo.roleType || ''
const deviceType = __DEVICE_TYPE__ const deviceType = __DEVICE_TYPE__
@ -57,31 +52,37 @@ const menuList = computed(() => {
) { ) {
return false return false
} }
return !(item.name === 'debug' && userRole !== 'admin')
return !(item.name === 'debug' && systemStore.systemUser?.name !== 'admin')
}) })
}) })
onMounted(() => { onMounted(() => {
runSystemTime(systemStore.systemTime)
console.log(systemStore.systemUser)
// 3 // 3
onFullScreen()
// onFullScreen()
}) })
const onFullScreen = () => {
document.body.addEventListener('touchstart', (event) => {
const now = Date.now()
const timeDiff = now - touchStartTime
if (timeDiff < 300 && timeDiff > 0) {
touchCount++
if (touchCount === 3) {
event.preventDefault()
openFullscreen()
}
}
else {
touchCount = 1
}
touchStartTime = now
})
}
// const touchStartTime = 0
// const touchCount = 0
// const onFullScreen = () => {
// document.body.addEventListener('touchstart', (event) => {
// const now = Date.now()
// const timeDiff = now - touchStartTime
// if (timeDiff < 300 && timeDiff > 0) {
// touchCount++
// if (touchCount === 3) {
// event.preventDefault()
// openFullscreen()
// }
// }
// else {
// touchCount = 1
// }
// touchStartTime = now
// })
// }
const showDeviceStateName = () => { const showDeviceStateName = () => {
if (deviceState.value.state?.toLocaleLowerCase() !== 'idle') { if (deviceState.value.state?.toLocaleLowerCase() !== 'idle') {
@ -103,10 +104,6 @@ const showDeviceStateName = () => {
} }
} }
onMounted(() => {
runSystemTime(systemStore.systemTime)
})
watchEffect(() => { watchEffect(() => {
deviceInfo.value = deviceStore.deviceInfo deviceInfo.value = deviceStore.deviceInfo
websocketConnected.value = systemStore.websocketConnected websocketConnected.value = systemStore.websocketConnected
@ -158,6 +155,8 @@ const onLogout = () => {
} }
FtMessageBox.warning('请确认是否退出登录?').then(() => { FtMessageBox.warning('请确认是否退出登录?').then(() => {
localStorage.removeItem('user') localStorage.removeItem('user')
delToken()
useSystemStore().updateUser(null)
router.push('/login') router.push('/login')
}) })
} }

39
src/stores/systemStore.ts

@ -7,9 +7,7 @@ import { sendCmd } from '@/apis/system'
export const useSystemStore = defineStore('system', () => { export const useSystemStore = defineStore('system', () => {
const websocketConnected = ref(true) const websocketConnected = ref(true)
const systemUser = ref({
username: '',
})
const systemUser = ref<any>(null)
const systemLogList = ref<System.SystemLog[]>([]) const systemLogList = ref<System.SystemLog[]>([])
const insertLog = (log: System.SystemLog) => { const insertLog = (log: System.SystemLog) => {
systemLogList.value.unshift(log) systemLogList.value.unshift(log)
@ -25,19 +23,37 @@ export const useSystemStore = defineStore('system', () => {
uuids.clear() uuids.clear()
} }
uuids.add(item.uuid) uuids.add(item.uuid)
if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) { // 传感器检测失败弹窗事件
if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) {
// 传感器检测失败弹窗事件
item.errCheckPoints.forEach((errCheckPoint) => { item.errCheckPoints.forEach((errCheckPoint) => {
const log: System.SystemLog = { name: `${errCheckPoint.ecodeInfo}(${errCheckPoint.ecode})`, status: 'check', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid }
const log: System.SystemLog = {
name: `${errCheckPoint.ecodeInfo}(${errCheckPoint.ecode})`,
status: 'check',
time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()),
uuid: item.uuid,
}
insertLog(log) insertLog(log)
}) })
} }
if (item.type === 'AppWarningPromoptEvent') { // 报警事件
const log: System.SystemLog = { name: item.description || '', status: 'warn', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid }
if (item.type === 'AppWarningPromoptEvent') {
// 报警事件
const log: System.SystemLog = {
name: item.description || '',
status: 'warn',
time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()),
uuid: item.uuid,
}
ElMessage.warning(item.description) ElMessage.warning(item.description)
insertLog(log) insertLog(log)
} }
if (item.type === 'AppPromoptEvent') { // 普通弹窗事件
const log: System.SystemLog = { name: item.message || '', status: 'info', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid }
if (item.type === 'AppPromoptEvent') {
// 普通弹窗事件
const log: System.SystemLog = {
name: item.message || '',
status: 'info',
time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()),
uuid: item.uuid,
}
insertLog(log) insertLog(log)
} }
}) })
@ -76,6 +92,10 @@ export const useSystemStore = defineStore('system', () => {
websocketConnected.value = isConnected websocketConnected.value = isConnected
} }
const updateUser = (data: any) => {
systemUser.value = data
}
/** /**
* @function subscribeDisinfectEvent * @function subscribeDisinfectEvent
* @desc * @desc
@ -136,6 +156,7 @@ export const useSystemStore = defineStore('system', () => {
websocketConnected, websocketConnected,
systemTime, systemTime,
systemLogList, systemLogList,
updateUser,
updateLoading, updateLoading,
updateConnected, updateConnected,
getSystemTime, getSystemTime,

8
src/views/login/index.vue

@ -72,16 +72,18 @@ const loginHandle = async () => {
className: 'UserMgrService', className: 'UserMgrService',
fnName: 'getLoginUser', fnName: 'getLoginUser',
} }
syncSendCmd(params).then((res) => {
syncSendCmd(params).then(async (res) => {
if (res.ackcode === 0) { if (res.ackcode === 0) {
useSystemStore().updateUser(res.rely.loginUser)
localStorage.setItem('user', JSON.stringify(res.rely.loginUser)) localStorage.setItem('user', JSON.stringify(res.rely.loginUser))
setToken('111')
deviceStore.setDeviceState(res.rely.loginUser) deviceStore.setDeviceState(res.rely.loginUser)
} }
})
await router.push('/home') await router.push('/home')
}
loading.value = false loading.value = false
}) })
}
})
.catch(() => { .catch(() => {
loading.value = false loading.value = false
FtMessage.error('网络连接异常,请检查网络') FtMessage.error('网络连接异常,请检查网络')

Loading…
Cancel
Save