¶Ô±ÈÐÂÎļþ |
| | |
| | | import { defHttp } from '/@/utils/http/axios'; |
| | | |
| | | enum Api { |
| | | sendCommand = '/dry/real/sendCommand', |
| | | } |
| | | /** |
| | | * åéå½ä»¤ |
| | | * @param params |
| | | */ |
| | | export const sendCommand = (params) => defHttp.post({ url: Api.sendCommand, params },{ isTransformResponse: false }); |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <a-modal v-model:visible="visible" centered :mask="false" :closable="false" :cancelText="null" title="è¦å" |
| | | @ok="hideModal"> |
| | | <a-card> |
| | | <div class="indented-text">å¨ä½¿ç¨è¿ç¨æ§å¶è®¾å¤åï¼è¯·ç¡®ä¿æºå¨å¨å´æ²¡æå
¶ä»äººåã建ç«ä¸ä¸ªå®å
¨åºåï¼ç¡®ä¿æ²¡æäººè½å¤è¿å
¥è¯¥åºåï¼é²æ¢ä¸å¿
è¦ç伤害ã</div> |
| | | </a-card> |
| | | |
| | | </a-modal> |
| | | <div class="app"> |
| | | <a-card title="æä»¤"> |
| | | <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> |
| | | </a-card> |
| | | <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 } from "./api"; |
| | | |
| | | const visible = ref<boolean>(false); |
| | | |
| | | interface Commant { |
| | | id: number; |
| | | title: string; |
| | | icon: string; |
| | | } |
| | | |
| | | 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" |
| | | }]); |
| | | |
| | | 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 hideModal = () => { |
| | | visible.value = false; |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | showModal(); |
| | | }); |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |
| | | .app { |
| | | margin: 10px; |
| | | } |
| | | |
| | | .com-box { |
| | | display: flex; |
| | | flex-wrap: wrap; |
| | | |
| | | .com-btn { |
| | | margin: 10px; |
| | | } |
| | | } |
| | | |
| | | .log-box { |
| | | min-height: 200px; |
| | | max-height: 300px; |
| | | overflow-y: scroll; |
| | | } |
| | | .indented-text { |
| | | text-indent: 20px; |
| | | font-size: 16px; |
| | | } |
| | | |
| | | |
| | | </style> |