From db029d023c099a578bdfb9db844ce365edd9e41e Mon Sep 17 00:00:00 2001
From: 朱桂飞 <18597012158>
Date: 星期一, 27 十一月 2023 14:06:00 +0800
Subject: [PATCH] 添加远程控制页面

---
 src/views/dashboard/control/api.ts    |   11 +++
 src/views/dashboard/control/index.vue |  168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/views/dashboard/video/index.vue   |    0 
 3 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/src/views/dashboard/control/api.ts b/src/views/dashboard/control/api.ts
new file mode 100644
index 0000000..76a5c9f
--- /dev/null
+++ b/src/views/dashboard/control/api.ts
@@ -0,0 +1,11 @@
+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 });
+
diff --git a/src/views/dashboard/control/index.vue b/src/views/dashboard/control/index.vue
new file mode 100644
index 0000000..5085e12
--- /dev/null
+++ b/src/views/dashboard/control/index.vue
@@ -0,0 +1,168 @@
+<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: "婊氱瓛姝h浆",
+    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) {
+  //鍙戦�乴og
+  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>
diff --git a/src/views/dry/video/index.vue b/src/views/dashboard/video/index.vue
similarity index 100%
rename from src/views/dry/video/index.vue
rename to src/views/dashboard/video/index.vue

--
Gitblit v1.9.3