¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <a-modal v-model:visible="visible" centered :mask="true" :maskClosable="false" :keyboard="false" :closable="false" :cancelText="null" title="è¦å" |
| | | @ok="hideModal" @cancel="cnacelModal" > |
| | | <a-card> |
| | | <div class="indented-text">å¨ä½¿ç¨è¿ç¨æ§å¶è®¾å¤åï¼è¯·ç¡®ä¿æºå¨å¨å´æ²¡æå
¶ä»äººåã建ç«ä¸ä¸ªå®å
¨åºåï¼ç¡®ä¿æ²¡æäººè½å¤è¿å
¥è¯¥åºåï¼é²æ¢ä¸å¿
è¦ç伤害ã</div> |
| | | <div style="display: flex; justify-content: space-between; padding-top: 20px; "> |
| | | <p style="font-weight: bold;" >请è¾å
¥å¯ç ï¼</p> |
| | | <p style="color: red">{{ error }}</p> |
| | | </div> |
| | | <div > |
| | | <a-input-password v-model:value="password" placeholder="请è¾å
¥å¯ç ï¼"></a-input-password> |
| | | </div> |
| | | </a-card> |
| | | |
| | | </a-modal> |
| | | <div class="app"> |
| | | <a-row> |
| | | <div style="width: 60%"> |
| | | <a-card title="ç
§æ" > |
| | | <div class="light-box"> |
| | | <div v-for="item in lightList" :key="item.identifier" class="center"> |
| | | <!-- <a-button v-if="item.type == 0" type="primary" class="com-btn" |
| | | @click="deviceClick(item)"> |
| | | {{ item.name }} |
| | | </a-button> --> |
| | | <div v-if="item.type==0" @click="deviceClick(item)"> |
| | | <div :class="[ item.value?'lightOn':'lightOff' ,'device']"> |
| | | |
| | | |
| | | </div> |
| | | <div class="text-center">{{ item.name }}</div> |
| | | |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | </a-card> |
| | | </div> |
| | | <div style="width: 40%"> |
| | | <a-card title="çæ§" style=" margin-left: 10px;"> |
| | | <div class="monitor-box"> |
| | | <div v-for="item in lightList" :key="item.identifier" class="center" > |
| | | <div v-if="item.type==1" @click="deviceClick(item)"> |
| | | <div :class="[ item.value?'camOn':'camOff' ,'device']"> |
| | | |
| | | |
| | | </div> |
| | | <div class="text-center">{{ item.name }}</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </a-card> |
| | | </div> |
| | | </a-row> |
| | | <a-row> |
| | | <div style="width: 50%"> |
| | | <a-card title="æä»¤" style="margin-top: 10px; "> |
| | | <div class="com-box"> |
| | | <!-- <a-button v-for="item in comList" :key="item.id" type="primary" class="com-btn" |
| | | @click="comClick(item)"> |
| | | {{ item.title }} |
| | | </a-button> --> |
| | | <div style="width: 500px;" > |
| | | |
| | | <a-row class="button-row"> |
| | | <a-button type="primary" :disabled="btnDisabled" @click="clickButton(1010, 'å¹²ç¥å¯å¨')" class="com-btn"> |
| | | <div> <PlayCircleOutlined style="font-size: 20px;" /> </div> |
| | | <div> å¹²ç¥å¯å¨ </div> |
| | | |
| | | </a-button> |
| | | <!-- <a-button type="normal" @click="clickButton(1012)" class="com-btn"> |
| | | <div> <SplitCellsOutlined style="font-size: 20px;" /> </div> |
| | | <div> åé¨å¼å
³ </div> |
| | | |
| | | </a-button> --> |
| | | <a-button type="default" :disabled="btnDisabled" @click="clickButton(1003,'æ»çå')" class="com-btn w300"> |
| | | <div> <UpCircleOutlined style="font-size: 20px;" /> </div> |
| | | <div> æ»çå </div> |
| | | |
| | | </a-button> |
| | | <a-button type="normal" :disabled="btnDisabled" @click="clickButton(1016,'æ¸
é¤')" class="com-btn"> |
| | | <div> <ClearOutlined style="font-size: 20px;" /> </div> |
| | | <div> æ¸
é¤ </div> |
| | | |
| | | </a-button> |
| | | </a-row> |
| | | <a-row class="button-row"> |
| | | <a-button type="normal" :disabled="btnDisabled" @click="clickButton(1005,'æ»çæ£è½¬')" class="com-btn h100"> |
| | | <div> <RedoOutlined style="font-size: 20px;" /> </div> |
| | | <div> æ»çæ£è½¬ </div> |
| | | </a-button> |
| | | <a-button type="danger" :disabled="btnDisabled" @click="clickButton(1007,'忢')" class="com-btn h100 w300 " > |
| | | <div> <PauseCircleOutlined style="font-size: 20px;" /> </div> |
| | | <div> 忢 </div> |
| | | </a-button> |
| | | <a-button type="normal" :disabled="btnDisabled" @click="clickButton(1006,'æ»çå转')" class="com-btn h100"> |
| | | <div> <UndoOutlined style="font-size: 20px;" /> </div> |
| | | <div> æ»çå转 </div> |
| | | </a-button> |
| | | </a-row> |
| | | <a-row class="button-row"> |
| | | <a-button type="success" :disabled="btnDisabled" @click="clickButton(1015,'åºæ')" class="com-btn"> |
| | | <div> <DownloadOutlined style="font-size: 20px;" /> </div> |
| | | <div> åºæ </div> |
| | | |
| | | </a-button> |
| | | <!-- <a-button type="normal" @click="clickButton(1010)" class="com-btn"> |
| | | <div> <SplitCellsOutlined style="font-size: 20px;" /> </div> |
| | | <div> åé¨å¼å
³ </div> |
| | | </a-button> --> |
| | | <a-button type="normal" :disabled="btnDisabled" @click="clickButton(1004,'æ»çé')" class="com-btn w300"> |
| | | <div> <DownCircleOutlined style="font-size: 20px;" /> </div> |
| | | <div> æ»çé </div> |
| | | </a-button> |
| | | <a-button type="normal" :disabled="btnDisabled" @click="clickButton(1013,'çé£å¯å¨')" class="com-btn"> |
| | | <div> <FireOutlined style="font-size: 20px;" /> </div> |
| | | <div> çé£å¯å¨ </div> |
| | | |
| | | </a-button> |
| | | </a-row> |
| | | |
| | | </div> |
| | | |
| | | |
| | | </div> |
| | | </a-card> |
| | | </div> |
| | | <div style="width: 50%"> |
| | | <a-card title="ç¶æ" style="margin-left: 10px;margin-top:10px"> |
| | | <div class="com-box"> |
| | | <div> |
| | | <div> |
| | | <a-button type="warning" :disabled="btnDisabled" @click="clickButton(1017,'æå¨/èªå¨')" class="com-btn"> |
| | | <div> <SyncOutlined style="font-size: 20px;" /> </div> |
| | | <div> æå¨/èªå¨ </div> |
| | | |
| | | </a-button> |
| | | |
| | | </div> |
| | | <div> |
| | | <a-button type="info" :disabled="btnDisabled" @click="clickButton(1014, 'å¼é¨è§å¯')" class="com-btn"> |
| | | <div> <SettingOutlined style="font-size: 20px;" /> </div> |
| | | <div> å¼é¨è§å¯ </div> |
| | | |
| | | </a-button> |
| | | |
| | | </div> |
| | | <div> |
| | | <a-button type="normal" @click="lock()" class="com-btn"> |
| | | <div> <Icon :icon="lockIcon" :size="28" /> </div> |
| | | <div> {{lockText}} </div> |
| | | |
| | | </a-button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </a-card> |
| | | </div> |
| | | </a-row> |
| | | |
| | | <a-card title="æ§å¶å°" style="margin-top: 10px; "> |
| | | <div class="log-box"> |
| | | <p v-for="log in logList" :key="log"> {{ log }}</p> |
| | | </div> |
| | | |
| | | </a-card> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { ref, onMounted } from "vue"; |
| | | import { sendCommand, sendWriteCommand, listAll } from "./api"; |
| | | import { useGlobSetting } from '/@/hooks/setting'; |
| | | import { connectWebSocket, onWebSocket } from '/@/hooks/web/useWebSocket'; |
| | | import { useUserStore } from '/@/store/modules/user'; |
| | | import { RedoOutlined ,SettingOutlined, UndoOutlined,FireOutlined, SplitCellsOutlined, DownloadOutlined, PauseCircleOutlined,ClearOutlined, SyncOutlined,PlayCircleOutlined, SwapOutlined , UpCircleOutlined, DownCircleOutlined, LeftCircleOutlined, RightCircleOutlined} from '@ant-design/icons-vue'; |
| | | import { router } from '/@/router' |
| | | const error = ref('') |
| | | const lockIcon = ref('tdesign:lock-off') |
| | | const lockText = ref('è§£é') |
| | | const password = ref() |
| | | const visible = ref<boolean>(false); |
| | | const glob = useGlobSetting(); |
| | | interface Commant { |
| | | id: number; |
| | | title: string; |
| | | icon: string; |
| | | } |
| | | |
| | | interface Device { |
| | | name: string; |
| | | identifier: string; |
| | | value: boolean; |
| | | sort_order: number; |
| | | } |
| | | const userStore = useUserStore(); |
| | | const logList = ref<string[]>([]); |
| | | const comList = ref<Commant[]>([ |
| | | { |
| | | id: 1010, |
| | | title: "å¹²ç¥å¯å¨", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1007, |
| | | title: "忢è¿è¡", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1013, |
| | | title: "çé£å¯å¨", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1012, |
| | | title: "åé¨å¼å
³", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1003, |
| | | title: "æ»çå", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1004, |
| | | title: "æ»çé", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1005, |
| | | title: "æ»çæ£è½¬", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1006, |
| | | title: "æ»çå转", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1014, |
| | | title: "å¼é¨è§å¯", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1015, |
| | | title: "åºæ", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1016, |
| | | title: "æ¸
é¤", |
| | | icon: "caret-right-outlined" |
| | | }, { |
| | | id: 1017, |
| | | title: "æå¨/èªå¨", |
| | | icon: "caret-right-outlined" |
| | | }]); |
| | | |
| | | const btnDisabled = ref(true) |
| | | const lightList = ref<Device[]>([]); |
| | | const monitorList = ref<Device[]>([]); |
| | | |
| | | function lock() { |
| | | btnDisabled.value = !btnDisabled.value |
| | | lockIcon.value = btnDisabled.value?'tdesign:lock-off':'tdesign:lock-on' |
| | | lockText.value = btnDisabled.value?'è§£é': 'éå®' |
| | | if (btnDisabled.value) { |
| | | showModal() |
| | | } |
| | | } |
| | | |
| | | function comClick(item) { |
| | | addLog("åé", item.title); |
| | | //åéæä»¤ |
| | | sendCmd(item); |
| | | } |
| | | |
| | | /** |
| | | * åéæä»¤ |
| | | * @param item |
| | | */ |
| | | function sendCmd(item) { |
| | | var params = { msg: item.title, code: item.id, tenantId: 1003, machineId: "GM001" }; |
| | | sendCommand(params).then(res => { |
| | | if (res.success) { |
| | | addLog("ååº", res.message); |
| | | console.info(res); |
| | | } else { |
| | | console.info(res); |
| | | addLog("ååº", res.message); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å log |
| | | * @param type |
| | | * @param msg |
| | | */ |
| | | function addLog(type, msg) { |
| | | //åélog |
| | | const date = new Date(); |
| | | const format = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")} ${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}`; |
| | | const log = format + " " + type + ":" + msg; |
| | | logList.value.unshift(log); |
| | | } |
| | | |
| | | const showModal = () => { |
| | | visible.value = true; |
| | | }; |
| | | |
| | | const cnacelModal = () => { |
| | | router.back() |
| | | } |
| | | |
| | | const hideModal = () => { |
| | | if(!password.value || password.value.length<=0) { |
| | | error.value="请è¾å
¥å¯ç ï¼" |
| | | }else |
| | | if(password.value === 'LBit@123') { |
| | | visible.value = false; |
| | | password.value = '' |
| | | error.value = '' |
| | | } else { |
| | | error.value = 'å¯ç é误ï¼' |
| | | } |
| | | |
| | | |
| | | }; |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¯åæå头å表 |
| | | */ |
| | | function queryDevice() { |
| | | listAll({}).then(res => { |
| | | console.log("ress000:",res); |
| | | lightList.value = res |
| | | }) |
| | | |
| | | |
| | | } |
| | | |
| | | function clickButton(cmd, msg) { |
| | | console.log("target::::",cmd); |
| | | let tenantId = userStore.getTenant; |
| | | var params = { msg: msg, code: cmd, tenantId: tenantId, machineId: "GM001" }; |
| | | sendCommand(params).then(res => { |
| | | if (res.success) { |
| | | addLog("ååº", res.message); |
| | | console.info(res); |
| | | } else { |
| | | console.info(res); |
| | | addLog("ååº", res.message); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | function deviceClick(item) { |
| | | //console.log("item===",item.value); |
| | | let params = {code: item.identifier, msg: !item.value} |
| | | sendWriteCommand(params).then(res => { |
| | | console.log("åæä»¤ç»æï¼ï¼", res) |
| | | if(res.success) { |
| | | lightList.value.forEach(device => { |
| | | if(device.identifier == item.identifier) { |
| | | device.value = !item.value |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | |
| | | // åå§å WebSocket |
| | | function initWebSocket() { |
| | | |
| | | let user = userStore.getUserInfo; |
| | | let tenantId = user.loginTenantId; |
| | | |
| | | console.log(user); |
| | | // WebSocket䏿®éçè¯·æ±æç¨åè®®ææä¸åï¼wsçåäºhttpï¼wssçåäºhttps |
| | | let url = glob.domainUrl?.replace('https://', 'wss://').replace('http://', 'ws://') + '/drySocket/' + tenantId; |
| | | |
| | | connectWebSocket(url); |
| | | onWebSocket(onWebSocketMessage); |
| | | } |
| | | |
| | | function onWebSocketMessage(data) { |
| | | console.log("drysocket:data::",data) |
| | | lightList.value.forEach(item => { |
| | | if(item.identifier == data.identifier) { |
| | | item.value = data.value |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function keydown(e) { |
| | | error.value = '' |
| | | if(e.keyCode == 13) { |
| | | hideModal() |
| | | } |
| | | } |
| | | |
| | | onMounted(() => { |
| | | showModal(); |
| | | initWebSocket(); |
| | | window.addEventListener('keydown', keydown) |
| | | }); |
| | | |
| | | queryDevice() |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | .app { |
| | | margin: 10px; |
| | | } |
| | | |
| | | .com-box { |
| | | // margin-left: 200px; |
| | | |
| | | display: flex; |
| | | justify-content: center; |
| | | |
| | | .com-btn { |
| | | border-radius: 5px; |
| | | width: 100px; |
| | | margin: 10px; |
| | | height: 70px; |
| | | } |
| | | } |
| | | |
| | | .button-row { |
| | | display: flex; justify-content: space-between; |
| | | } |
| | | |
| | | .log-box { |
| | | min-height: 150px; |
| | | max-height: 150px; |
| | | overflow-y: auto; |
| | | } |
| | | .indented-text { |
| | | text-indent: 20px; |
| | | font-size: 16px; |
| | | } |
| | | |
| | | .light-box { |
| | | display: flex; |
| | | justify-items: center; |
| | | justify-content: center; |
| | | flex-wrap: wrap; |
| | | |
| | | } |
| | | .center { |
| | | display: flex; |
| | | justify-items: center; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .text-center { |
| | | text-align: center; |
| | | } |
| | | |
| | | .lightOn { |
| | | background-image: url(/src/assets/images/dry/control/light.png); |
| | | background-repeat: no-repeat; |
| | | background-size: 50px; |
| | | /* border-radius: 10px; */ |
| | | background-position: 48px 0px; |
| | | } |
| | | .lightOff { |
| | | background-image: url(/src/assets/images/dry/control/light-close.png); |
| | | background-repeat: no-repeat; |
| | | background-size: 50px; |
| | | /* border-radius: 10px; */ |
| | | background-position: 48px 0px; |
| | | } |
| | | |
| | | .camOn { |
| | | background-image: url(/src/assets/images/dry/control/cam1.png); |
| | | background-repeat: no-repeat; |
| | | background-size: 50px; |
| | | /* border-radius: 10px; */ |
| | | background-position: 48px 0px; |
| | | } |
| | | .camOff { |
| | | background-image: url(/src/assets/images/dry/control/cam0.png); |
| | | background-repeat: no-repeat; |
| | | background-size: 50px; |
| | | /* border-radius: 10px; */ |
| | | background-position: 48px 0px; |
| | | } |
| | | |
| | | |
| | | .device { |
| | | width: 150px; height: 60px; |
| | | |
| | | } |
| | | |
| | | .h100 { |
| | | height: 70px !important; |
| | | } |
| | | |
| | | .w300 { |
| | | width: 100px !important; |
| | | } |
| | | |
| | | .monitor-box { |
| | | display: flex; |
| | | justify-items: center; |
| | | justify-content: center; |
| | | flex-wrap: wrap; |
| | | |
| | | } |
| | | |
| | | |
| | | </style> |