Forráskód Böngészése

feat: 发送机载指令

wanggaokun 10 hónapja
szülő
commit
a38d5abae3

+ 17 - 0
src/api/modules/manage/instructionInfo.ts

@@ -68,3 +68,20 @@ export const importDataApi = (data: any) => {
 export const exportApi = (data: any) => {
   return http.downloadPost('/manage/instructionInfo/export', data)
 }
+/**
+ * @name 重连
+ * @param id id
+ * @returns returns
+ */
+export const connectApi = () => {
+  return http.post<any>(`/netty/client/connect`, {}, { loading: false })
+}
+
+/**
+ * @name 发送
+ * @param content 内容
+ * @returns returns
+ */
+export const sendApi = (content: String) => {
+  return http.post<any>(`/netty/client/send`, content, { loading: false })
+}

+ 43 - 1
src/views/manage/instructionInfo/index.vue

@@ -10,6 +10,7 @@
     >
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
+        <el-button type="primary" v-auth="['manage:instructionInfo:add']" :icon="CirclePlus" @click="connect()"> 连接 </el-button>
         <el-button type="primary" v-auth="['manage:instructionInfo:add']" :icon="CirclePlus" @click="openDialog(1, '指令信息新增')"> 新增 </el-button>
         <el-button type="primary" v-auth="['manage:instructionInfo:import']" :icon="Upload" plain @click="batchAdd"> 导入 </el-button>
         <el-button type="primary" v-auth="['manage:instructionInfo:export']" :icon="Download" plain @click="downloadFile"> 导出 </el-button>
@@ -26,6 +27,7 @@
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
+        <el-button type="primary" link :icon="View" v-auth="['manage:instructionInfo:query']" @click="send(scope.row)"> 发送 </el-button>
         <el-button type="primary" link :icon="View" v-auth="['manage:instructionInfo:query']" @click="openDialog(3, '指令信息查看', scope.row)">
           查看
         </el-button>
@@ -46,7 +48,7 @@
 import { ref, reactive } from 'vue'
 import { useHandleData } from '@/hooks/useHandleData'
 import { useDownload } from '@/hooks/useDownload'
-import { ElMessageBox } from 'element-plus'
+import { ElMessage, ElMessageBox } from 'element-plus'
 import ProTable from '@/components/ProTable/index.vue'
 import ImportExcel from '@/components/ImportExcel/index.vue'
 import FormDialog from '@/components/DialogOld/form.vue'
@@ -60,8 +62,11 @@ import {
   importTemplateApi,
   importDataApi,
   exportApi,
+  sendApi,
+  connectApi,
   getInstructionInfoApi
 } from '@/api/modules/manage/instructionInfo'
+import { getDictsApi } from '@/api/modules/system/dictData'
 
 // ProTable 实例
 const proTable = ref<ProTableInstance>()
@@ -133,6 +138,22 @@ const openDialog = async (type: number, title: string, row?: any) => {
   formDialogRef.value?.openDialog(params)
 }
 
+const connect = async () => {
+  const res = await connectApi()
+  if (res.code == 200) {
+    ElMessage.success('机载服务端连接成功')
+  }
+}
+
+const send = async (data: any) => {
+  console.log(data)
+
+  const res = await sendApi('ssdsd')
+  if (res.code == 200) {
+    ElMessage.success('发送成功')
+  }
+}
+
 // 表格配置项
 const columns = reactive<ColumnProps<any>[]>([
   { type: 'selection', fixed: 'left', width: 70 },
@@ -143,6 +164,15 @@ const columns = reactive<ColumnProps<any>[]>([
       el: 'input'
     }
   },
+  {
+    prop: 'attribute',
+    tag: true,
+    enum: () => getDictsApi('air_order'),
+    search: {
+      el: 'select'
+    },
+    fieldNames: { label: 'dictLabel', value: 'dictValue' }
+  },
   {
     prop: 'content',
     label: '指令内容',
@@ -165,6 +195,18 @@ const setFieldList = () => {
       field: 'attribute',
       placeholder: '请输入指令属性'
     },
+    {
+      label: '指令属性',
+      field: 'attribute',
+      enum: () => getDictsApi('air_order'),
+      type: 'select',
+      rules: [{ required: true, message: '指令不能为空', trigger: 'change' }],
+      options: {
+        labelKey: 'dictLabel',
+        valueKey: 'dictValue'
+      },
+      placeholder: '请选择指令'
+    },
     {
       label: '指令内容',
       field: 'content',