Commit 147055d4f2363c251f9178b57e85d35afb5dcb07

Authored by ww
1 parent d6eeaed7

perf: 设备详情命令下发记录表格样式修复

@@ -22,6 +22,7 @@ export const columnSchema: BasicColumn[] = [ @@ -22,6 +22,7 @@ export const columnSchema: BasicColumn[] = [
22 { 22 {
23 title: '输出参数', 23 title: '输出参数',
24 dataIndex: 'outputParams', 24 dataIndex: 'outputParams',
  25 + slots: { customRender: 'outputParams' },
25 }, 26 },
26 ]; 27 ];
27 28
1 <script lang="ts" setup> 1 <script lang="ts" setup>
2 import { BasicTable, useTable } from '/@/components/Table'; 2 import { BasicTable, useTable } from '/@/components/Table';
3 import { formSchemas, columnSchema } from './config'; 3 import { formSchemas, columnSchema } from './config';
  4 + import { BasicModal, useModal } from '/@/components/Modal';
  5 + import { Textarea } from 'ant-design-vue';
  6 + import { ref } from 'vue';
  7 + import { formatToDateTime } from '/@/utils/dateUtil';
  8 + import { EyeOutlined } from '@ant-design/icons-vue';
  9 +
  10 + const outputData = ref<string>();
  11 +
4 const [register] = useTable({ 12 const [register] = useTable({
5 columns: columnSchema, 13 columns: columnSchema,
6 size: 'small', 14 size: 'small',
7 - rowKey: 'id',  
8 showIndexColumn: false, 15 showIndexColumn: false,
9 useSearchForm: true, 16 useSearchForm: true,
10 showTableSetting: true, 17 showTableSetting: true,
11 bordered: true, 18 bordered: true,
  19 + dataSource: [
  20 + {
  21 + time: formatToDateTime(new Date()),
  22 + identifier: '标识符',
  23 + eventName: '事件名',
  24 + eventType: '告警',
  25 + outputParams: { test: 1 },
  26 + },
  27 + ],
12 formConfig: { 28 formConfig: {
13 layout: 'inline', 29 layout: 'inline',
14 baseColProps: { span: 6 }, 30 baseColProps: { span: 6 },
@@ -20,8 +36,37 @@ @@ -20,8 +36,37 @@
20 return params; 36 return params;
21 }, 37 },
22 }); 38 });
  39 +
  40 + const [registerModal, { openModal }] = useModal();
  41 +
  42 + const handleViewDetail = () => {
  43 + outputData.value = JSON.stringify(
  44 + {
  45 + test: '123',
  46 + },
  47 + null,
  48 + 2
  49 + );
  50 + openModal(true);
  51 + };
23 </script> 52 </script>
24 53
25 <template> 54 <template>
26 - <BasicTable @register="register" style="background-color: #f0f2f5" /> 55 + <BasicTable class="event-manage-table" @register="register">
  56 + <template #outputParams>
  57 + <span class="cursor-pointer text-blue-500" @click="handleViewDetail">
  58 + <EyeOutlined class="svg:text-blue-500" />
  59 + <span class="ml-2">详情</span>
  60 + </span>
  61 + </template>
  62 + </BasicTable>
  63 + <BasicModal title="输出参数" @register="registerModal">
  64 + <Textarea v-model:value="outputData" :autosize="true" />
  65 + </BasicModal>
27 </template> 66 </template>
  67 +
  68 +<style lang="less" scoped>
  69 + .event-manage-table {
  70 + background-color: #f0f2f5;
  71 + }
  72 +</style>
1 -<template>  
2 - <div style="background-color: #f0f2f5">  
3 - <BasicTable @register="registerTable">  
4 - <template #recordContent="{ record }">  
5 - <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button>  
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>  
14 - </BasicTable>  
15 - </div>  
16 -</template>  
17 -<script lang="ts" setup>  
18 - import { h } from 'vue';  
19 - import { configColumns } from './config';  
20 - import { deviceCommandRecordGetQuery } from '/@/api/device/deviceConfigApi';  
21 - import { BasicTable, useTable } from '/@/components/Table';  
22 - import { Modal, Tag } from 'ant-design-vue';  
23 - import { JsonPreview } from '/@/components/CodeEditor';  
24 -  
25 - const props = defineProps({  
26 - fromId: {  
27 - type: String,  
28 - default: '',  
29 - },  
30 - });  
31 - const [registerTable] = useTable({  
32 - api: deviceCommandRecordGetQuery,  
33 - columns: configColumns,  
34 - beforeFetch: (params) => {  
35 - return {  
36 - ...params,  
37 - tbDeviceId: props.fromId,  
38 - };  
39 - },  
40 - showTableSetting: true,  
41 - bordered: true,  
42 - showIndexColumn: false,  
43 - });  
44 - const commonModalInfo = (title, value) => {  
45 - Modal.info({  
46 - title,  
47 - width: 600,  
48 - content: h(JsonPreview, { data: value }),  
49 - });  
50 - };  
51 - const handleRecordContent = (record) => {  
52 - if (!record?.request?.body?.params) return;  
53 - //如果是正常格式则返回params,否则输入什么内容则显示什么内容  
54 - const jsonParams = JSON.parse(record?.request?.body?.params);  
55 - commonModalInfo('命令下发内容', jsonParams?.params ? jsonParams?.params : jsonParams);  
56 - };  
57 -</script> 1 +<template>
  2 + <BasicTable class="command-record-table" @register="registerTable">
  3 + <template #recordContent="{ record }">
  4 + <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button>
  5 + </template>
  6 + <template #responseContent="{ record }">
  7 + <Tag
  8 + v-if="!record.request?.oneway"
  9 + :color="record.request?.response?.status === 'SUCCESS' ? 'green' : 'red'"
  10 + >{{ record.request?.response?.status === 'SUCCESS' ? '成功' : '失败' }}</Tag
  11 + >
  12 + </template>
  13 + </BasicTable>
  14 +</template>
  15 +<script lang="ts" setup>
  16 + import { h } from 'vue';
  17 + import { configColumns } from './config';
  18 + import { deviceCommandRecordGetQuery } from '/@/api/device/deviceConfigApi';
  19 + import { BasicTable, useTable } from '/@/components/Table';
  20 + import { Modal, Tag } from 'ant-design-vue';
  21 + import { JsonPreview } from '/@/components/CodeEditor';
  22 +
  23 + const props = defineProps({
  24 + fromId: {
  25 + type: String,
  26 + default: '',
  27 + },
  28 + });
  29 + const [registerTable] = useTable({
  30 + api: deviceCommandRecordGetQuery,
  31 + columns: configColumns,
  32 + beforeFetch: (params) => {
  33 + return {
  34 + ...params,
  35 + tbDeviceId: props.fromId,
  36 + };
  37 + },
  38 + showTableSetting: true,
  39 + bordered: true,
  40 + showIndexColumn: false,
  41 + });
  42 + const commonModalInfo = (title, value) => {
  43 + Modal.info({
  44 + title,
  45 + width: 600,
  46 + content: h(JsonPreview, { data: value }),
  47 + });
  48 + };
  49 + const handleRecordContent = (record) => {
  50 + if (!record?.request?.body?.params) return;
  51 + //如果是正常格式则返回params,否则输入什么内容则显示什么内容
  52 + const jsonParams = JSON.parse(record?.request?.body?.params);
  53 + commonModalInfo('命令下发内容', jsonParams?.params ? jsonParams?.params : jsonParams);
  54 + };
  55 +</script>
  56 +
  57 +<style lang="less" scoped>
  58 + .command-record-table {
  59 + background-color: #f0f2f5;
  60 + padding: 16px;
  61 + }
  62 +</style>