Commit 5053cd3bfcf30ec6833f39f370eee4c1c9d96799

Authored by fengwotao
1 parent 021aa9bb

pref:优化命令下发记录

... ... @@ -14,6 +14,15 @@ export const configColumns: BasicColumn[] = [
14 14 {
15 15 title: '命令类型',
16 16 dataIndex: 'additionalInfo.cmdType',
  17 + format: (text) => {
  18 + return h(
  19 + Tag,
  20 + {
  21 + color: Number(text) === 0 ? 'blue' : 'green',
  22 + },
  23 + () => (Number(text) === 0 ? '自定义' : '服务')
  24 + );
  25 + },
17 26 },
18 27 {
19 28 title: '响应类型',
... ... @@ -50,16 +59,8 @@ export const configColumns: BasicColumn[] = [
50 59 },
51 60 {
52 61 title: '响应结果',
53   - dataIndex: 'response',
54   - customRender: (text) => {
55   - return h(
56   - Tag,
57   - {
58   - color: text?.status === 'SUCCESS' ? 'green' : 'red',
59   - },
60   - () => (text?.status === 'SUCCESS' ? '成功' : '失败')
61   - );
62   - },
  62 + dataIndex: 'response111',
  63 + slots: { customRender: 'responseContent' },
63 64 },
64 65 {
65 66 title: '响应失败内容',
... ...
... ... @@ -4,6 +4,13 @@
4 4 <template #recordContent="{ record }">
5 5 <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button>
6 6 </template>
  7 + <template #responseContent="{ record }">
  8 + <Tag
  9 + v-if="!record.request?.oneway"
  10 + :color="record.request?.response?.status === 'SUCCESS' ? 'green' : 'red'"
  11 + >{{ record.request?.response?.status === 'SUCCESS' ? '成功' : '失败' }}</Tag
  12 + >
  13 + </template>
7 14 </BasicTable>
8 15 </div>
9 16 </template>
... ... @@ -12,7 +19,7 @@
12 19 import { configColumns } from './config';
13 20 import { deviceCommandRecordGetQuery } from '/@/api/device/deviceConfigApi';
14 21 import { BasicTable, useTable } from '/@/components/Table';
15   - import { Modal } from 'ant-design-vue';
  22 + import { Modal, Tag } from 'ant-design-vue';
16 23 import { JsonPreview } from '/@/components/CodeEditor';
17 24
18 25 const props = defineProps({
... ... @@ -42,6 +49,12 @@
42 49 });
43 50 };
44 51 const handleRecordContent = (record) => {
45   - commonModalInfo('命令下发内容', JSON.parse(record?.request?.body?.params));
  52 + try {
  53 + //如果是正常格式则返回params,否则输入什么内容则显示什么内容
  54 + const jsonParams = JSON.parse(record?.request?.body?.params);
  55 + commonModalInfo('命令下发内容', jsonParams.params ? jsonParams.params : jsonParams);
  56 + } catch (e) {
  57 + console.log('位置/device/list/cpns/tabs/commandRecord/index.vue', e);
  58 + }
46 59 };
47 60 </script>
... ...