Browse Source

对接异常反馈记录

李富豪 1 year ago
parent
commit
44def56091

+ 1 - 1
Web/package.json

@@ -36,4 +36,4 @@
     "vite": "5.3.0",
     "vite-plugin-vconsole": "^2.1.0"
   }
-}
+}

+ 40 - 28
Web/src/api/custom/index.ts

@@ -2,6 +2,15 @@ import request from '/@/api/http/request';
 import { getWorkspaceId } from '/@/utils/index';
 
 // Api参数类型
+export type FetchDeviceFeedbackRecordListApiParams = Partial<{
+    begin_time: number,
+    end_time: number,
+    username: number,
+    search_info: string,
+    page: number,
+    page_size: number,
+}>;
+
 export type CreateDeviceFeedbackApiParams = {
     logs_info: string,
     happen_time: number,
@@ -23,19 +32,24 @@ export type SignLoginApiParams = {
     signature: string,
 };
 
-export type FetchFeedbackRecordListApiParams = {
+export type FetchFeedbackRecordListApiParams = Partial<{
+    begin_time: number,
+    end_time: number,
+    status: number,
+    username: number,
+    search_info: string,
     page: number,
     page_size: number,
-};
+}>;
 
-export type FetchChangeRecordListApiParams = {
+export type FetchChangeRecordListApiParams = Partial<{
+    begin_time: number,
+    end_time: number,
+    device_name: string,
+    search_info: string,
     page: number,
     page_size: number,
-    begin_time?: number, // 开始时间
-    end_time?: number, // 结束时间
-    device_name?: string,//设备类型
-    logsInformation?: string,//模糊查询内容
-};
+}>;
 
 export type FetchMediaFileListApiParams = Partial<{
     begin_time: number,
@@ -87,25 +101,17 @@ export type FetchPilotPasswordApiParams = {
     userId: string,
 };
 
-export type FetchGetLogListApiParms = {
-    begin_time: number,
-    end_time: number,
-    template_type: number,
-    username: number,
-    search_info: string,
-    page: number,
-    page_size: number,
-}
-
 // Api函数类型
 export type FetchDeviceLogListApi = (sn: string, params: { domain_list: string }) => Promise<any>;
+export type FetchDeviceFeedbackRecordListApi = (sn: string, params: FetchDeviceFeedbackRecordListApiParams) => Promise<any>;
+export type FetchDeviceLogDetailApi = (params: { logsId: string }) => Promise<any>;
 export type CreateDeviceFeedbackApi = (sn: string, data: CreateDeviceFeedbackApiParams) => 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>;
 export type FetchPayloadListApi = () => Promise<any>;
 export type FetchFeedbackRecordListApi = (data: FetchFeedbackRecordListApiParams) => Promise<any>;
-export type FetchChangeRecordListApi = (params: FetchFeedbackRecordListApiParams) => Promise<any>;
+export type FetchChangeRecordListApi = (params: FetchChangeRecordListApiParams) => Promise<any>;
 export type FetchProjectListApi = () => Promise<any>;
 export type FetchMediaFileListApi = (params: FetchMediaFileListApiParams) => Promise<any>;
 export type BatchDownloadMediaFileApi = (params: BatchDownloadMediaFileApiParams) => Promise<any>;
@@ -120,7 +126,6 @@ export type FetchTrajectoryListApi = (params: FetchTrajectoryListApiParams) => P
 export type FetchTrajectoryMapApi = (taskId: string) => Promise<any>;
 export type AddPilotApi = (data: AddPilotApiParams) => Promise<any>;
 export type FetchPilotPasswordApi = (params: FetchPilotPasswordApiParams) => Promise<any>;
-export type FetchGetLogListApi = (params: FetchGetLogListApiParms) => Promise<any>;
 
 export const getUploadPath = () => {
     return `api/media/api/v1/files/${getWorkspaceId()}/file/upload`;
@@ -132,6 +137,18 @@ const fetchDeviceLogListApi: FetchDeviceLogListApi = async (sn, params) => {
     return res.data;
 };
 
+// 获取设备异常反馈记录列表
+const fetchDeviceFeedbackRecordListApi: FetchDeviceFeedbackRecordListApi = async (sn, params) => {
+    const res = await request.get(`/manage/api/v1/workspaces/${getWorkspaceId()}/devices/${sn}/deviceSnLogsList`, { params: params });
+    return res.data;
+};
+
+// 获取设备日志详情
+const fetchDeviceLogDetailApi: FetchDeviceLogDetailApi = async (params) => {
+    const res = await request.get(`/manage/api/v1/workspaces/${getWorkspaceId()}/devices/logsDetail/`, { params: params });
+    return res.data;
+};
+
 // 创建设备异常反馈
 const createDeviceFeedbackApi: CreateDeviceFeedbackApi = async (sn, data) => {
     const res = await request.post(`/manage/api/v1/workspaces/${getWorkspaceId()}/devices/${sn}/createLogs`, data);
@@ -164,7 +181,7 @@ const fetchPayloadListApi: FetchPayloadListApi = async () => {
 
 // 获取反馈记录列表
 const fetchFeedbackRecordListApi: FetchFeedbackRecordListApi = async (data) => {
-    const res = await request.get('/manage/api/v1/devices', { params: data });
+    const res = await request.get(`/manage/api/v1/workspaces/${getWorkspaceId()}/devices/logsList`, { params: data });
     return res.data;
 };
 
@@ -271,14 +288,10 @@ const fetchPilotPasswordApi: FetchPilotPasswordApi = async (params) => {
     return res.data;
 };
 
-// 获取异常变化记录列表
-const fetchGetLogListApi: FetchGetLogListApi = async (params) => {
-    const res = await request.get(`/manage/api/v1/workspaces/${getWorkspaceId()}/devices/logsList`, { params: params });
-    return res.data;
-};
-
 export const apis = {
     fetchDeviceLogList: fetchDeviceLogListApi,
+    fetchDeviceFeedbackRecordList: fetchDeviceFeedbackRecordListApi,
+    fetchDeviceLogDetail: fetchDeviceLogDetailApi,
     createDeviceFeedback: createDeviceFeedbackApi,
     signLogin: signLoginApi,
     fetchDeviceModel: fetchDeviceModelApi,
@@ -300,5 +313,4 @@ export const apis = {
     fetchTrajectoryMap: fetchTrajectoryMapApi,
     AddPilot: addPilotApi,
     fetchPilotPassword: fetchPilotPasswordApi,
-    fetchGetLogList:fetchGetLogListApi,
 };

+ 14 - 1
Web/src/components/devices/deviceList/components/FeedbackDetailModal.vue

@@ -71,8 +71,21 @@ const state = reactive({
     loading: false,
 });
 
+const fetchDetail = async () => {
+    state.loading = true;
+    try {
+        const res = await apis.fetchDeviceLogDetail({ logsId: props.currentId });
+        console.log(res, 'res');
+
+    } catch (error) {
+        console.error(error);
+    } finally {
+        state.loading = false;
+    }
+}
+
 onMounted(async () => {
-    // await fetchList();
+    await fetchDetail();
 })
 </script>
 

+ 34 - 22
Web/src/components/devices/deviceList/components/FeedbackDrawer.vue

@@ -10,12 +10,8 @@
                         <a-range-picker style="width: 250px;" valueFormat="YYYY-MM-DD"
                             v-model:value="formModel.rangeDate" />
                     </a-form-item>
-                    <a-form-item name="device_name">
-                        <a-select style="width: 200px;" placeholder="请选择反馈人" v-model:value="formModel.device_name">
-                            <a-select-option value="1">
-                                pilot
-                            </a-select-option>
-                        </a-select>
+                    <a-form-item name="username">
+                        <a-input style="width: 200px;" placeholder="反馈人" v-model:value="formModel.username" />
                     </a-form-item>
                     <a-form-item name="search_info">
                         <a-input style="width: 200px;" placeholder="设备SN、设备异常描述"
@@ -37,15 +33,27 @@
             </div>
         </div>
         <div>
-            <a-table :scroll="{ x: '100%', y: 500 }" :childrenColumnName="null" rowKey="device_sn"
-                :loading="state.listLoading" :columns="columns" :dataSource="state.list" :pagination="paginationConfig">
+            <a-table :scroll="{ x: '100%', y: 500 }" rowKey="logs_id" :loading="state.listLoading" :columns="columns"
+                :dataSource="state.list" :pagination="paginationConfig">
+                <!-- 上传状态 -->
                 <template #status="{ record }">
-                    上传状态
+                    <div v-if="record.status === 1">
+                        上传中
+                    </div>
+                    <div v-else-if="record.status === 2">
+                        成功
+                    </div>
+                    <div v-else-if="record.status === 3">
+                        取消
+                    </div>
+                    <div v-else-if="record.status === 4">
+                        失败
+                    </div>
                 </template>
                 <!-- 操作 -->
                 <template #operation="{ record }">
                     <a-tooltip title="详情">
-                        <FileSearchOutlined @click="handleClickDetail(record.id)" />
+                        <FileSearchOutlined @click="handleClickDetail(record.logs_id)" />
                     </a-tooltip>
                 </template>
             </a-table>
@@ -68,6 +76,7 @@ import FeedbackCreateModal from '../components/FeedbackCreateModal.vue';
 import FeedbackDetailModal from '../components/FeedbackDetailModal.vue';
 import { apis, CreateDeviceFeedbackApiParams } from '/@/api/custom';
 import { Device } from '/@/types/device';
+import moment from 'moment';
 
 interface Props {
     visible: boolean,
@@ -83,15 +92,15 @@ const formRef = ref();
 
 const formModel = reactive({
     rangeDate: undefined,
-    device_name: undefined,
+    username: undefined,
     search_info: undefined,
 })
 
 type Query = Partial<{
-    begin_time: string,
-    end_time: string,
-    device_name: undefined,
-    search_info: undefined,
+    begin_time: number,
+    end_time: number,
+    username: number,
+    search_info: string,
 }>;
 
 interface State {
@@ -132,11 +141,14 @@ const paginationConfig = reactive({
 const fetchList = async () => {
     state.listLoading = true;
     try {
-        const res = await apis.fetchChangeRecordList({
-            ...state.query,
-            page: paginationConfig.current,
-            page_size: paginationConfig.pageSize
-        });
+        const res = await apis.fetchDeviceFeedbackRecordList(
+            props.device.device_sn,
+            {
+                ...state.query,
+                page: paginationConfig.current,
+                page_size: paginationConfig.pageSize
+            }
+        );
         if (res.code === 0) {
             paginationConfig.total = res.data.pagination.total
             paginationConfig.current = res.data.pagination.page
@@ -211,8 +223,8 @@ const handleClicSekarch = async () => {
     const data = { ...values };
     delete data.rangeDate;
     if (values.rangeDate.length === 2) {
-        data.begin_time = values.rangeDate[0];
-        data.end_time = values.rangeDate[1];
+        data.begin_time = moment(values.rangeDate[0]).valueOf();
+        data.end_time = moment(values.rangeDate[1]).valueOf();
     }
     state.query = data;
     await fetchList();

+ 1 - 1
Web/src/components/devices/deviceList/index.vue

@@ -80,7 +80,7 @@
   </div>
   <!-- 异常反馈 -->
   <FeedbackDrawer :visible="state.feedbackDrawerVisible" :device="state.currentDevice"
-    :onClose="() => state.feedbackDrawerVisible = false" />
+    :onClose="() => state.feedbackDrawerVisible = false" v-if="state.feedbackDrawerVisible" />
   <!-- 告警信息 -->
   <DeviceHmsDrawer v-model:visible="state.deviceHmsDrawerVisible" :device="state.currentDevice" />
 </template>

+ 0 - 40
Web/src/components/devices/feedbackRecord/components/CustomCell.vue

@@ -1,40 +0,0 @@
-<template>
-    <div class="customCell">
-        <div class="customCell-item">
-            {{ record[fieldName] }}
-        </div>
-        <div class="customCell-item" v-if="record.children && record.children[fieldName]">
-            <div class="mt-5 ml0"
-                style="border-left: 2px solid rgb(200,200,200); border-bottom: 2px solid rgb(200,200,200); height: 16px;width: 16px; float: left;">
-            </div>
-            <div style="margin-left: 5px;">
-                {{ record.children[fieldName] }}
-            </div>
-        </div>
-    </div>
-</template>
-
-<script lang="ts" setup>
-interface Props {
-    record: any,
-    fieldName: string,
-};
-
-const props = withDefaults(defineProps<Props>(), {
-
-});
-</script>
-
-<style lang="scss" scoped>
-.customCell {
-    display: flex;
-    flex-direction: column;
-    justify-content: center;
-
-    &-item {
-        height: 40px;
-        display: flex;
-        align-items: center;
-    }
-}
-</style>

+ 10 - 10
Web/src/components/devices/feedbackRecord/components/Search.vue

@@ -6,17 +6,17 @@
           <a-range-picker style="width: 250px;" v-model:value="formModel.date" />
         </a-form-item>
         <a-form-item name="status">
-          <a-select style="width: 200px;" placeholder="请选择状态" v-model:value="formModel.status">
-            <a-select-option value="1">
+          <a-select style="width: 200px;" placeholder="请选择上传状态" v-model:value="formModel.status">
+            <a-select-option :value="1">
               上传中
             </a-select-option>
-            <a-select-option value="2">
+            <a-select-option :value="2">
               成功
             </a-select-option>
-            <a-select-option value="3">
+            <a-select-option :value="3">
               取消
             </a-select-option>
-            <a-select-option value="4">
+            <a-select-option :value="4">
               失败
             </a-select-option>
           </a-select>
@@ -64,15 +64,13 @@ const formModel = reactive({
   date: [],
   status: undefined,
   username: undefined,
-  search_info: '',
+  search_info: undefined,
 })
 
 // 点击查询
 const handleClicSekarch = async () => {
   const values = formRef.value?.getFieldsValue();
-  const data = {
-    ...values,
-  };
+  const data = { ...values };
   delete data.date;
   if (values.date.length === 2) {
     data.begin_time = moment(values.date[0]).valueOf();
@@ -85,7 +83,9 @@ const handleClicSekarch = async () => {
 const handleClickReset = async () => {
   formRef.value?.resetFields();
   const values = formRef.value?.getFieldsValue();
-  await props.onClickReset(values);
+  const data = { ...values };
+  delete data.date;
+  await props.onClickReset(data);
 }
 </script>
 

+ 20 - 38
Web/src/components/devices/feedbackRecord/index.vue

@@ -2,27 +2,22 @@
   <div class="feedbackRecord">
     <Search :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
     <div class="feedbackRecord-table">
-      <a-table :scroll="{ x: '100%', y: 500 }" :childrenColumnName="null" rowKey="device_sn"
-        :loading="state.listLoading" :columns="columns" @change="refreshData" :rowClassName="rowClassName"
-        :dataSource="state.list" :pagination="paginationConfig">
-        <!-- 设备型号 -->
-        <template #device_name="{ record }">
-          <CustomCell :record="record" fieldName="device_name" />
-        </template>
-        <!-- 设备SN -->
-        <template #device_sn="{ record }">
-          <CustomCell :record="record" fieldName="device_sn" />
-        </template>
-        <!-- 设备名称 -->
-        <template #nick_name="{ record }">
-          <CustomCell :record="record" fieldName="nick_name" />
-        </template>
-        <!-- 固件版本 -->
-        <template #firmware_version="{ record }">
-          <CustomCell :record="record" fieldName="firmware_version" />
-        </template>
+      <a-table :scroll="{ x: '100%', y: 500 }" rowKey="logs_id" :loading="state.listLoading" :columns="columns"
+        @change="refreshData" :rowClassName="rowClassName" :dataSource="state.list" :pagination="paginationConfig">
+        <!-- 上传状态 -->
         <template #status="{ record }">
-          上传状态
+          <div v-if="record.status === 1">
+            上传中
+          </div>
+          <div v-else-if="record.status === 2">
+            成功
+          </div>
+          <div v-else-if="record.status === 3">
+            取消
+          </div>
+          <div v-else-if="record.status === 4">
+            失败
+          </div>
         </template>
         <!-- 操作 -->
         <template #operation="{ record }">
@@ -31,9 +26,6 @@
               <a-tooltip title="详情">
                 <FileSearchOutlined style="margin-right: 10px;" @click="onClickDetail(record.id)" />
               </a-tooltip>
-              <a-tooltip title="删除">
-                <DeleteOutlined @click="onClickDelete(record.id)" />
-              </a-tooltip>
             </div>
           </div>
         </template>
@@ -45,10 +37,8 @@
 
 <script lang="ts" setup>
 import { reactive, onMounted } from 'vue';
-import { Modal } from 'ant-design-vue';
-import { DeleteOutlined, FileSearchOutlined } from '@ant-design/icons-vue';
+import { FileSearchOutlined } from '@ant-design/icons-vue';
 import Search from './components/Search.vue';
-import CustomCell from './components/CustomCell.vue';
 import Drawer from './components/Drawer.vue';
 import { apis } from '/@/api/custom/index';
 
@@ -80,7 +70,7 @@ const paginationConfig = reactive({
 const fetchList = async () => {
   state.listLoading = true;
   try {
-    const res = await apis.fetchGetLogList({
+    const res = await apis.fetchFeedbackRecordList({
       ...state.query,
       page: paginationConfig.current,
       page_size: paginationConfig.pageSize
@@ -146,6 +136,9 @@ const columns = [
     dataIndex: 'logs_info',
     width: 150,
     ellipsis: true,
+    customRender: ({ text }: any) => {
+      return text || '--';
+    }
   },
   {
     title: '上传状态',
@@ -198,17 +191,6 @@ const onClickDetail = (id: string) => {
 const drawerOnClickClose = () => {
   state.drawerVisible = false;
 }
-
-// 点击删除
-const onClickDelete = (id: number) => {
-  Modal.confirm({
-    title: '提示',
-    content: '确定删除吗?',
-    onOk: async () => {
-
-    },
-  });
-}
 </script>
 
 <style lang="scss">