Browse Source

对接设备异常反馈

李富豪 1 year ago
parent
commit
d565ee335a

+ 8 - 0
Web/src/api/custom/index.ts

@@ -76,6 +76,7 @@ export type FetchPilotPasswordApiParams = {
 };
 
 // Api函数类型
+export type FetchDeviceLogListApi = (sn: string, params: { domain_list: number }) => Promise<any>;
 export type SignLoginApi = (data: SignLoginApiParams) => Promise<any>;
 export type FetchDeviceModelApi = (params?: { flg: boolean }) => Promise<any>;
 export type FetchDeviceStatusApi = (params: { snList: string }) => Promise<any>;
@@ -101,6 +102,12 @@ export const getUploadPath = () => {
     return `api/media/api/v1/files/${getWorkspaceId()}/file/upload`;
 }
 
+// 获取设备日志列表
+const fetchDeviceLogListApi: FetchDeviceLogListApi = async (sn, params) => {
+    const res = await request.get(`/manage/api/v1/workspaces/${getWorkspaceId()}/devices/${sn}/logs`, { params: params });
+    return res.data;
+};
+
 // 密钥登录
 const signLoginApi: SignLoginApi = async (data) => {
     const res = await request.post('/manage/api/v1/signLogin', data);
@@ -235,6 +242,7 @@ const fetchPilotPasswordApi: FetchPilotPasswordApi = async (params) => {
 };
 
 export const apis = {
+    fetchDeviceLogList: fetchDeviceLogListApi,
     signLogin: signLoginApi,
     fetchDeviceModel: fetchDeviceModelApi,
     fetchDeviceStatus: fetchDeviceStatusApi,

+ 1 - 1
Web/src/components/airport/index.vue

@@ -71,7 +71,7 @@
       </div>
       <div class="content-info-right">
         <a-button type="text"
-          :disabled="!(deviceInfo[dock.sn] && deviceInfo[dock.sn].mode_code !== EDockModeCode.Disconnected)"
+          :disabled="!(dockInfo[dock.gateway.sn] && dockInfo[dock.gateway.sn].basic_osd?.mode_code !== EDockModeCode.Disconnected)"
           @click.stop="onClickLookInfo">
           <img :src="infoSrc">
         </a-button>

+ 102 - 23
Web/src/components/devices/deviceList/components/FeedbackCreateModal.vue

@@ -1,5 +1,5 @@
 <template>
-    <a-modal :width="800" title="设备异常反馈" :maskClosable="false" :closable="false" okText="提交" v-model:visible="visible"
+    <a-modal :width="950" title="设备异常反馈" :maskClosable="false" :closable="false" okText="提交" v-model:visible="visible"
         @ok="handleClickSubmit" @cancel="onClickClose">
         <a-form ref="formRef" :model="formModel" :colon="false" :label-col="labelCol" :wrapper-col="wrapperCol">
             <a-form-item label='异常描述' name="describe"
@@ -39,11 +39,19 @@
                 <a-table :columns="airportLogColumns" :scroll="{ x: '100%', y: 600 }"
                     :data-source="state.airportLogList" :loading="state.listLoading"
                     :row-selection="airportTableLogState.rowSelection" rowKey="boot_index" :pagination="false">
-                    <template #log_time="{ record }">
-                        <!-- <div>{{ getLogTime(record) }}</div> -->
+                    <template #log="{ record }">
+                        <div style="font-size: 12px;">
+                            {{ getDateTime(record.start_time) }}
+                            <span style="margin: 0 5px;">
+                                -
+                            </span>
+                            {{ getDateTime(record.end_time) }}
+                        </div>
                     </template>
                     <template #size="{ record }">
-                        <!-- <div>{{ getLogSize(record.size) }}</div> -->
+                        <div>
+                            {{ getLogSize(record.size) }} G
+                        </div>
                     </template>
                 </a-table>
             </div>
@@ -51,11 +59,19 @@
                 <a-table :columns="droneLogColumns" :scroll="{ x: '100%', y: 600 }" :data-source="state.droneLogList"
                     :loading="state.listLoading" :row-selection="droneTableLogState.rowSelection" rowKey="boot_index"
                     :pagination="false">
-                    <template #log_time="{ record }">
-                        <!-- <div>{{ getLogTime(record) }}</div> -->
+                    <template #log="{ record }">
+                        <div style="font-size: 12px;">
+                            {{ getDateTime(record.start_time) }}
+                            <span style="margin: 0 5px;">
+                                -
+                            </span>
+                            {{ getDateTime(record.end_time) }}
+                        </div>
                     </template>
                     <template #size="{ record }">
-                        <!-- <div>{{ getLogSize(record.size) }}</div> -->
+                        <div>
+                            {{ getLogSize(record.size) }} G
+                        </div>
                     </template>
                 </a-table>
             </div>
@@ -67,9 +83,10 @@
 import { ref, reactive, onMounted } from 'vue';
 import { apis, getUploadPath } from '/@/api/custom';
 import { getHeaders } from '/@/api/http/request';
-import { message } from 'ant-design-vue';
+import moment from 'moment';
 
 interface Props {
+    sn: string,
     visible: boolean,
     onClickSubmit: () => Promise<any>
     onClickClose: () => void,
@@ -96,8 +113,18 @@ const wrapperCol = { span: 18 };
 
 interface State {
     listLoading: boolean,
-    airportLogList: any[]
-    droneLogList: any[],
+    airportLogList: {
+        boot_index: number,
+        start_time: number,
+        end_time: number,
+        size: number,
+    }[],
+    droneLogList: {
+        boot_index: number,
+        start_time: number,
+        end_time: number,
+        size: number,
+    }[],
 };
 
 const state: State = reactive({
@@ -106,8 +133,47 @@ const state: State = reactive({
     droneLogList: [],
 });
 
+const fetchAirportLogList = async () => {
+    state.listLoading = true;
+    try {
+        const res = await apis.fetchDeviceLogList(props.sn, { domain_list: 3 });
+        state.airportLogList = res.data.files[0].list;
+    } catch (error) {
+        console.error(error);
+    } finally {
+        state.listLoading = false;
+    }
+}
+
+const fetchDroneLogList = async () => {
+    state.listLoading = true;
+    try {
+        const res = await apis.fetchDeviceLogList(props.sn, { domain_list: 0 });
+        state.droneLogList = res.data.files[0].list;
+    } catch (error) {
+        console.error(error);
+    } finally {
+        state.listLoading = false;
+    }
+}
+
+const getDateTime = (timestamp: number) => {
+    const date = moment.unix(timestamp).format('YYYY-MM-DD HH:mm');
+    return date;
+}
+
+const getLogSize = (size: number) => {
+    // 将字节转换为GB
+    const gbSize = size / (1024 * 1024 * 1024);
+    // 保留一位小数
+    return parseFloat(gbSize.toFixed(1));
+};
+
 onMounted(async () => {
-    // await fetchList();
+    await Promise.all([
+        fetchAirportLogList(),
+        fetchDroneLogList(),
+    ]);
 })
 
 const handleChangeUpload = (info: any) => {
@@ -131,23 +197,38 @@ const handleChangeUpload = (info: any) => {
     }
 };
 
-// 表格
 const airportLogColumns = [
-    { title: '机场日志', dataIndex: 'time', width: 100, slots: { customRender: 'log_time' } },
-    { title: '文件大小', dataIndex: 'size', width: 25, slots: { customRender: 'size' } },
+    {
+        title: '机场日志',
+        dataIndex: 'log',
+        slots: { customRender: 'log' }
+    },
+    {
+        title: '文件大小',
+        dataIndex: 'size',
+        width: 100,
+        slots: { customRender: 'size' }
+    }
 ]
 
 const droneLogColumns = [
-    { title: '飞行器日志', dataIndex: 'time', width: 100, slots: { customRender: 'log_time' } },
-    { title: '文件大小', dataIndex: 'size', width: 25, slots: { customRender: 'size' } },
+    {
+        title: '飞行器日志',
+        dataIndex: 'log',
+        slots: { customRender: 'log' }
+    },
+    {
+        title: '文件大小',
+        dataIndex: 'size',
+        width: 100,
+        slots: { customRender: 'size' }
+    }
 ]
 
 const airportTableLogState = reactive({
-    logList: {} as DeviceLogFileInfo,
-    tableLoading: false,
     selectRow: [],
     rowSelection: {
-        columnWidth: 15,
+        columnWidth: 40,
         selectedRowKeys: [] as number[],
         onChange: (selectedRowKeys: number[], selectedRows: []) => {
             airportTableLogState.rowSelection.selectedRowKeys = selectedRowKeys
@@ -158,11 +239,9 @@ const airportTableLogState = reactive({
 })
 
 const droneTableLogState = reactive({
-    logList: {} as DeviceLogFileInfo,
-    tableLoading: false,
     selectRow: [],
     rowSelection: {
-        columnWidth: 15,
+        columnWidth: 40,
         selectedRowKeys: [] as number[],
         onChange: (selectedRowKeys: number[], selectedRows: []) => {
             droneTableLogState.rowSelection.selectedRowKeys = selectedRowKeys
@@ -184,7 +263,7 @@ const handleClickSubmit = () => {
     justify-content: space-between;
 
     &-item {
-        width: 48%;
+        width: 48.5%;
     }
 }
 </style>

+ 4 - 3
Web/src/components/devices/deviceList/components/FeedbackDrawer.vue

@@ -52,11 +52,12 @@
         </div>
     </a-drawer>
     <!-- 异常反馈-信息弹出层 -->
-    <FeedbackCreateModal :visible="state.createModalVisible" :onClickSubmit="createModalOnClickSubmit"
-        :onClickClose="() => state.createModalVisible = false" />
+    <FeedbackCreateModal :sn="device.device_sn" :visible="state.createModalVisible"
+        :onClickSubmit="createModalOnClickSubmit" :onClickClose="() => state.createModalVisible = false"
+        v-if="state.createModalVisible" />
     <!-- 异常反馈-详情弹出层 -->
     <FeedbackDetailModal :currentId="state.currentId" :visible="state.detailModalVisible"
-        :onClickClose="() => state.detailModalVisible = false" />
+        :onClickClose="() => state.detailModalVisible = false" v-if="state.detailModalVisible" />
 </template>
 
 <script lang="ts" setup>