Browse Source

修改密码

master
maochaoying 2 years ago
parent
commit
289ef49817
  1. 3
      src/components/Operator.vue
  2. 83
      src/components/Progress.vue
  3. 8
      src/components/Setting/components/Admin.vue
  4. 14
      src/components/Setting/components/User.vue
  5. 8
      src/mock/command.js
  6. 8
      src/pages/Home.vue
  7. 168
      src/store/modules/websocket.js

3
src/components/Operator.vue

@ -117,7 +117,7 @@ const logVal = ref(1)
const roomSize = ref(0) const roomSize = ref(0)
watch(() => { watch(() => {
roomSize.value = props.input.match(/\d+/g)
roomSize.value = props.input.match(/\d+/g)[0]
}) })
const changeLogVal = val => { const changeLogVal = val => {
@ -131,6 +131,7 @@ const startDisinfect = () => {
if (roomSize.value == 0) { if (roomSize.value == 0) {
showFailToast('请调整房间大小设置,不能为0') showFailToast('请调整房间大小设置,不能为0')
} else { } else {
console.log(roomSize.value)
webSocketStore.sendCommandMsg( webSocketStore.sendCommandMsg(
startDisinfectionJSON(logVal.value, roomSize.value), startDisinfectionJSON(logVal.value, roomSize.value),
) )

83
src/components/Progress.vue

@ -59,6 +59,7 @@ import { useOperatorStore, useWebSocketStore } from '@/store'
import { import {
stopDisinfectionJSON, stopDisinfectionJSON,
getStateJSON, getStateJSON,
continueDisinfectionJSON,
pauseDisinfectionJSON, pauseDisinfectionJSON,
} from '@/mock/command' } from '@/mock/command'
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
@ -66,7 +67,7 @@ import * as echarts from 'echarts'
const binOption = ref({ const binOption = ref({
legend: { legend: {
data: ['Email', 'Union Ads', 'Video Ads'],
data: ['温度', '湿度', '过氧化氢浓度'],
}, },
grid: { grid: {
left: '3%', left: '3%',
@ -84,19 +85,19 @@ const binOption = ref({
}, },
series: [ series: [
{ {
name: 'Email',
name: '温度',
type: 'line', type: 'line',
stack: 'Total', stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210], data: [120, 132, 101, 134, 90, 230, 210],
}, },
{ {
name: 'Union Ads',
name: '湿度',
type: 'line', type: 'line',
stack: 'Total', stack: 'Total',
data: [220, 182, 191, 234, 290, 330, 310], data: [220, 182, 191, 234, 290, 330, 310],
}, },
{ {
name: 'Video Ads',
name: '过氧化氢浓度',
type: 'line', type: 'line',
stack: 'Total', stack: 'Total',
data: [150, 232, 201, 154, 190, 330, 410], data: [150, 232, 201, 154, 190, 330, 410],
@ -104,8 +105,18 @@ const binOption = ref({
], ],
}) })
const envir1Option = ref({ const envir1Option = ref({
legend: {
data: ['温度', '湿度', '过氧化氢浓度'],
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
}, },
yAxis: { yAxis: {
@ -113,14 +124,38 @@ const envir1Option = ref({
}, },
series: [ series: [
{ {
data: [150, 230, 224, 218, 135, 147, 260],
name: '温度',
type: 'line', type: 'line',
stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210],
},
{
name: '湿度',
type: 'line',
stack: 'Total',
data: [220, 182, 191, 234, 290, 330, 310],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: [150, 232, 201, 154, 190, 330, 410],
}, },
], ],
}) })
const envir2Option = ref({ const envir2Option = ref({
legend: {
data: ['温度', '湿度', '过氧化氢浓度'],
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
}, },
yAxis: { yAxis: {
@ -128,8 +163,22 @@ const envir2Option = ref({
}, },
series: [ series: [
{ {
data: [150, 230, 224, 218, 135, 147, 260],
name: '温度',
type: 'line',
stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210],
},
{
name: '湿度',
type: 'line', type: 'line',
stack: 'Total',
data: [220, 182, 191, 234, 290, 330, 310],
},
{
name: '过氧化氢浓度',
type: 'line',
stack: 'Total',
data: [150, 232, 201, 154, 190, 330, 410],
}, },
], ],
}) })
@ -150,12 +199,21 @@ onMounted(() => {
timer.value = setInterval(() => { timer.value = setInterval(() => {
webSocketStore.sendCommandMsg(getStateJSON) webSocketStore.sendCommandMsg(getStateJSON)
}, 1000) }, 1000)
var binCharts = echarts.init(document.getElementById('bin'))
binCharts.setOption(binOption.value)
var envir1Charts = echarts.init(document.getElementById('envir1'))
envir1Charts.setOption(envir1Option.value)
var envir2Charts = echarts.init(document.getElementById('envir2'))
envir2Charts.setOption(envir2Option.value)
let a = echarts.getInstanceByDom(document.getElementById('bin'))
if (a == undefined) {
var binCharts = echarts.init(document.getElementById('bin'))
binCharts.setOption(binOption.value)
}
let b = echarts.getInstanceByDom(document.getElementById('envir1'))
if (b == undefined) {
var envir1Charts = echarts.init(document.getElementById('envir1'))
envir1Charts.setOption(envir1Option.value)
}
let c = echarts.getInstanceByDom(document.getElementById('envir2'))
if (c == undefined) {
var envir2Charts = echarts.init(document.getElementById('envir2'))
envir2Charts.setOption(envir2Option.value)
}
}) })
onUnmounted(() => { onUnmounted(() => {
timer.value = null timer.value = null
@ -177,6 +235,7 @@ const stopDisinfect = () => {
const continueDisinfect = () => { const continueDisinfect = () => {
if (!operatorStore.disinfectStatus) { if (!operatorStore.disinfectStatus) {
webSocketStore.sendCommandMsg(continueDisinfectionJSON)
operatorStore.updateDisinfectStatus(true) operatorStore.updateDisinfectStatus(true)
} }
} }

8
src/components/Setting/components/Admin.vue

@ -66,9 +66,13 @@
<script setup> <script setup>
import Eye from '@/assets/img/login/eye.png' import Eye from '@/assets/img/login/eye.png'
import Open from '@/assets/img/login/open.png' import Open from '@/assets/img/login/open.png'
import { chpasswdJSON } from '@/mock/command'
import { useWebSocketStore, useUserStore } from '@/store'
import { showSuccessToast, showFailToast } from 'vant' import { showSuccessToast, showFailToast } from 'vant'
import { ref } from 'vue' import { ref } from 'vue'
const webSocketStore = useWebSocketStore()
const userStore = useUserStore()
const initShowPassword = ref(false) const initShowPassword = ref(false)
const updateShowPassword = ref(false) const updateShowPassword = ref(false)
const initPassword = ref('') const initPassword = ref('')
@ -100,7 +104,9 @@ const handleUpdatePassword = () => {
} }
initTip.value = '' initTip.value = ''
updateTip.value = '' updateTip.value = ''
showSuccessToast('修改成功')
webSocketStore.sendCommandMsg(
chpasswdJSON(userStore.loginUser, updatePassword.value, initPassword.value),
)
} }
</script> </script>

14
src/components/Setting/components/User.vue

@ -133,9 +133,19 @@ const updateUserPassword = () => {
return return
} }
updateUserInfoTip.value = '' updateUserInfoTip.value = ''
webSocketStore.sendCommandMsg(
chpasswdJSON(userStore.operUser, updateUserNewPassword.value),
// userlistuser
const arr = userStore.allUserList.filter(
item => item.uid == userStore.operUser,
) )
if (arr?.length > 0) {
webSocketStore.sendCommandMsg(
chpasswdJSON(
userStore.operUser,
updateUserNewPassword.value,
arr[0]?.passwd,
),
)
}
} }
const handleAddPasswordShow = () => { const handleAddPasswordShow = () => {

8
src/mock/command.js

@ -15,11 +15,12 @@ export const logoutJSON = {
} }
// 改密码 // 改密码
export const chpasswdJSON = (userId, passwd) => {
export const chpasswdJSON = (userId, newpasswd, passwd) => {
return { return {
command: 'chpasswd', command: 'chpasswd',
messageId: 'chpasswd', messageId: 'chpasswd',
userId, userId,
newpasswd,
passwd, passwd,
} }
} }
@ -41,6 +42,11 @@ export const startDisinfectionJSON = (loglevel, roomVolume) => {
} }
} }
export const continueDisinfectionJSON = {
command: 'continueDisinfection',
messageId: 'continueDisinfection',
}
// 停止消毒 // 停止消毒
export const stopDisinfectionJSON = { export const stopDisinfectionJSON = {
command: 'stopDisinfection', command: 'stopDisinfection',

8
src/pages/Home.vue

@ -120,7 +120,7 @@
<p class="text">设置</p> <p class="text">设置</p>
</div> </div>
</div> </div>
<!-- <Operator
<Operator
v-if="activeTab == 1 && showOpertor" v-if="activeTab == 1 && showOpertor"
:changeShowOperator="changeShowOperator" :changeShowOperator="changeShowOperator"
:handleShowKeyBoard="handleShowKeyBoard" :handleShowKeyBoard="handleShowKeyBoard"
@ -130,8 +130,7 @@
<Progress <Progress
v-if="activeTab == 1 && !showOpertor" v-if="activeTab == 1 && !showOpertor"
:changeShowOperator="changeShowOperator" :changeShowOperator="changeShowOperator"
/> -->
<Progress v-if="activeTab == 1" />
/>
<LiquidHandle v-if="activeTab == 2" :tabType="1" /> <LiquidHandle v-if="activeTab == 2" :tabType="1" />
<LiquidHandle v-if="activeTab == 3" :tabType="2" /> <LiquidHandle v-if="activeTab == 3" :tabType="2" />
<Test v-if="activeTab == 4" /> <Test v-if="activeTab == 4" />
@ -242,6 +241,9 @@ const onChange = a => {
} }
const changeTab = index => { const changeTab = index => {
if ([2, 3, 4, 5].includes(index) && operatorStore.disinfectStatus) {
return
}
activeTab.value = index activeTab.value = index
if (index == 5) { if (index == 5) {
// getAllSetting // getAllSetting

168
src/store/modules/websocket.js

@ -5,6 +5,7 @@ import { useUserStore } from './user'
import { useOperatorStore } from './operator' import { useOperatorStore } from './operator'
import { useDeviceStore } from './device' import { useDeviceStore } from './device'
import { useTestStore } from './test' import { useTestStore } from './test'
import { showSuccessToast, showFailToast } from 'vant'
export const useWebSocketStore = defineStore({ export const useWebSocketStore = defineStore({
id: 'websocket', // id必填,且需要唯一 id: 'websocket', // id必填,且需要唯一
@ -32,88 +33,91 @@ export const useWebSocketStore = defineStore({
// console.log(JSON.parse(ev.data)) // console.log(JSON.parse(ev.data))
const { ackcode, messageId } = JSON.parse(ev.data) const { ackcode, messageId } = JSON.parse(ev.data)
if (ackcode == 0) {
switch (messageId) {
case 'getState':
// 初始化完毕
const { state } = JSON.parse(ev.data)
const {
workState,
estimatedRemainingTimeS,
disinfection_id,
isLogin,
permissionLevel,
sensor_data,
} = state || {}
if (!isLogin) {
window.location.href = '/login'
return
}
const {
h2o2_1,
h2o2_2,
h2o2_3,
humid_1,
humid_2,
humid_3,
temp_1,
temp_2,
temp_3,
airCompressor,
disinfectant_volume,
heatingStrip,
airBlower,
sprinklerPump,
chargingPump,
} = sensor_data
// 将sensor_data中的数据更新到store中
testStore.updateAirCompressorObj(airCompressor)
testStore.updateAirBlowerObj(airBlower)
testStore.updateHeatingStripObj(heatingStrip)
testStore.updateSprinklerPump(sprinklerPump)
testStore.updateChargingPump(chargingPump)
settingStore.updateDeviceIp('127.0.0.1')
deviceStore.updateDisinfectantCapacity(disinfectant_volume)
deviceStore.updateBinTemperature(temp_1)
deviceStore.updateBinHumidity(humid_1)
deviceStore.updateBinHP(h2o2_1)
deviceStore.updateEnvirTemperature1(temp_2)
deviceStore.updateEnvirHumidity1(humid_2)
deviceStore.updateEnvirHP1(h2o2_2)
deviceStore.updateEnvirTemperature2(temp_3)
deviceStore.updateEnvirHumidity2(humid_3)
deviceStore.updateEnvirHP2(h2o2_3)
switch (messageId) {
case 'getState':
// 初始化完毕
const { state } = JSON.parse(ev.data)
const {
workState,
estimatedRemainingTimeS,
disinfection_id,
isLogin,
permissionLevel,
sensor_data,
} = state || {}
if (!isLogin) {
window.location.href = '/login'
return
}
const {
h2o2_1,
h2o2_2,
h2o2_3,
humid_1,
humid_2,
humid_3,
temp_1,
temp_2,
temp_3,
airCompressor,
disinfectant_volume,
heatingStrip,
airBlower,
sprinklerPump,
chargingPump,
} = sensor_data
// 将sensor_data中的数据更新到store中
testStore.updateAirCompressorObj(airCompressor)
testStore.updateAirBlowerObj(airBlower)
testStore.updateHeatingStripObj(heatingStrip)
testStore.updateSprinklerPump(sprinklerPump)
testStore.updateChargingPump(chargingPump)
settingStore.updateDeviceIp('192.168.8.10')
deviceStore.updateDisinfectantCapacity(disinfectant_volume)
deviceStore.updateBinTemperature(temp_1)
deviceStore.updateBinHumidity(humid_1)
deviceStore.updateBinHP(h2o2_1)
deviceStore.updateEnvirTemperature1(temp_2)
deviceStore.updateEnvirHumidity1(humid_2)
deviceStore.updateEnvirHP1(h2o2_2)
deviceStore.updateEnvirTemperature2(temp_3)
deviceStore.updateEnvirHumidity2(humid_3)
deviceStore.updateEnvirHP2(h2o2_3)
userStore.updatePermission(permissionLevel)
settingStore.updateInitLoading()
operatorStore.updateDisinfectStatus(workState)
operatorStore.updateEstimatedRemainingTimeS(
estimatedRemainingTimeS,
)
operatorStore.updateDisinfectionId(disinfection_id)
// 将sensor_data中的数据更新到store中
break
case 'getAllUser':
const { dbval } = JSON.parse(ev.data)
userStore.updateUserList(dbval)
break
case 'chpasswd':
break
case 'startDisinfection':
break
case 'stopDisinfection':
break
case 'login':
break
case 'getAllRecords':
break
case 'getAllSetting':
const { dbval: allSetting } = JSON.parse(ev.data)
settingStore.updateAllSettingList(allSetting)
break
default:
break
}
userStore.updatePermission(permissionLevel)
settingStore.updateInitLoading()
operatorStore.updateDisinfectStatus(workState)
operatorStore.updateEstimatedRemainingTimeS(estimatedRemainingTimeS)
operatorStore.updateDisinfectionId(disinfection_id)
// 将sensor_data中的数据更新到store中
break
case 'getAllUser':
const { dbval } = JSON.parse(ev.data)
userStore.updateUserList(dbval)
break
case 'chpasswd':
console.log(JSON.parse(ev.data))
if (ackcode != 0) {
// 修改失败
showFailToast('修改失败')
} else {
showSuccessToast('修改成功')
}
break
case 'startDisinfection':
break
case 'stopDisinfection':
break
case 'login':
break
case 'getAllRecords':
break
case 'getAllSetting':
const { dbval: allSetting } = JSON.parse(ev.data)
settingStore.updateAllSettingList(allSetting)
break
default:
break
} }
} }
this.socketCommandInstance = init this.socketCommandInstance = init
@ -157,7 +161,7 @@ export const useWebSocketStore = defineStore({
testStore.updateHeatingStripObj(heatingStrip) testStore.updateHeatingStripObj(heatingStrip)
testStore.updateSprinklerPump(sprinklerPump) testStore.updateSprinklerPump(sprinklerPump)
testStore.updateChargingPump(chargingPump) testStore.updateChargingPump(chargingPump)
settingStore.updateDeviceIp('127.0.0.1')
settingStore.updateDeviceIp('192.168.8.10')
deviceStore.updateDisinfectantCapacity(disinfectant_volume) deviceStore.updateDisinfectantCapacity(disinfectant_volume)
deviceStore.updateBinTemperature(temp_1) deviceStore.updateBinTemperature(temp_1)
deviceStore.updateBinHumidity(humid_1) deviceStore.updateBinHumidity(humid_1)

Loading…
Cancel
Save