Commit ac6ad4c57ff41bd82a9e28728563521a4f30adea

Authored by xp.Huang
2 parents c676c5e3 33ec611c

Merge branch 'ww' into 'main'

feat: 设备详情事件管理前后端接口联调

See merge request yunteng/thingskit-front!490
  1 +import { EventManageRequest } from './model/eventManageModel';
  2 +import { defHttp } from '/@/utils/http/axios';
  3 +enum EventManage {
  4 + LIST = '/event',
  5 +}
  6 +
  7 +/**
  8 + * @description 获取事件管理列表
  9 + * @param params
  10 + * @returns
  11 + */
  12 +export const getEventManageListRecord = (params: EventManageRequest) => {
  13 + return defHttp.get({
  14 + url: EventManage.LIST,
  15 + params,
  16 + });
  17 +};
... ...
... ... @@ -177,6 +177,8 @@ export interface DeviceRecord {
177 177 default: boolean;
178 178 defaultRuleChainId: string;
179 179 profileId: string;
  180 + alias?: string;
  181 + brand?: string;
180 182 }
181 183
182 184 export interface DeviceModelOfMatterAttrs {
... ...
  1 +import { BasicPageParams } from '../../model/baseModel';
  2 +
  3 +export interface EventManageRequest extends BasicPageParams {
  4 + eventIdentifier?: string;
  5 + eventType?: string;
  6 + tbDeviceId: string;
  7 + startTime?: string;
  8 + endTime?: string;
  9 +}
... ...
... ... @@ -49,7 +49,7 @@
49 49 <!-- 网关设备并且是TBox -->
50 50
51 51 <TabPane key="eventManage" tab="事件管理">
52   - <EventManage />
  52 + <EventManage :tbDeviceId="deviceDetail.tbDeviceId" />
53 53 </TabPane>
54 54 </Tabs>
55 55 </BasicDrawer>
... ... @@ -70,6 +70,7 @@
70 70 // import HistoryData from '../tabs/HistoryData.vue';
71 71 import ModelOfMatter from '../tabs/ModelOfMatter.vue';
72 72 import EventManage from '../tabs/EventManage/index.vue';
  73 + import { DeviceRecord } from '/@/api/device/model/deviceModel';
73 74
74 75 export default defineComponent({
75 76 name: 'DeviceModal',
... ... @@ -93,7 +94,7 @@
93 94 const activeKey = ref('1');
94 95 const size = ref('small');
95 96 const deviceDetailRef = ref();
96   - const deviceDetail = ref<any>({});
  97 + const deviceDetail = ref<DeviceRecord>({} as unknown as DeviceRecord);
97 98 const tbDeviceId = ref('');
98 99 // 详情回显
99 100 const [register] = useDrawerInner(async (data) => {
... ...
... ... @@ -8,7 +8,7 @@ export const columnSchema: BasicColumn[] = [
8 8 },
9 9 {
10 10 title: '标识符',
11   - dataIndex: 'identifier',
  11 + dataIndex: 'eventIdentifier',
12 12 helpMessage: ['标识符格式为模块标识符: 功能定义标识符'],
13 13 },
14 14 {
... ... @@ -28,15 +28,17 @@ export const columnSchema: BasicColumn[] = [
28 28
29 29 export const formSchemas: FormSchema[] = [
30 30 {
31   - field: 'identifier',
  31 + field: 'eventIdentifier',
32 32 label: '标识符',
33 33 component: 'Input',
  34 + componentProps: {
  35 + placeholder: '请输入标识符',
  36 + },
34 37 },
35 38 {
36   - field: 'alarmType',
  39 + field: 'eventType',
37 40 label: '告警类型',
38 41 component: 'ApiSelect',
39   - defaultValue: 'INFO',
40 42 componentProps: {
41 43 placeholder: '请选择事件类型',
42 44 api: findDictItemByCode,
... ... @@ -52,5 +54,8 @@ export const formSchemas: FormSchema[] = [
52 54 label: '时间范围',
53 55 component: 'RangePicker',
54 56 colProps: { span: 10 },
  57 + componentProps: {
  58 + showTime: true,
  59 + },
55 60 },
56 61 ];
... ...
... ... @@ -2,13 +2,16 @@
2 2 import { BasicTable, useTable } from '/@/components/Table';
3 3 import { formSchemas, columnSchema } from './config';
4 4 import { BasicModal, useModal } from '/@/components/Modal';
5   - import { Textarea } from 'ant-design-vue';
  5 + import { Input } from 'ant-design-vue';
6 6 import { ref } from 'vue';
7   - import { formatToDateTime } from '/@/utils/dateUtil';
8 7 import { EyeOutlined } from '@ant-design/icons-vue';
  8 + import { getEventManageListRecord } from '/@/api/device/eventManage';
  9 + import { EventManageRequest } from '/@/api/device/model/eventManageModel';
9 10
10 11 const outputData = ref<string>();
11 12
  13 + const props = defineProps<{ tbDeviceId: string }>();
  14 +
12 15 const [register] = useTable({
13 16 columns: columnSchema,
14 17 size: 'small',
... ... @@ -16,24 +19,25 @@
16 19 useSearchForm: true,
17 20 showTableSetting: true,
18 21 bordered: true,
19   - dataSource: [
20   - {
21   - time: formatToDateTime(new Date()),
22   - identifier: '标识符',
23   - eventName: '事件名',
24   - eventType: '告警',
25   - outputParams: { test: 1 },
26   - },
27   - ],
  22 + api: getEventManageListRecord,
  23 + fetchSetting: {
  24 + totalField: 'totalElements',
  25 + listField: 'data',
  26 + },
28 27 formConfig: {
29 28 layout: 'inline',
30 29 baseColProps: { span: 6 },
31 30 labelWidth: 80,
32 31 schemas: formSchemas,
  32 + fieldMapToTime: [['dateRange', ['startTime', 'endTime']]],
33 33 },
34   - handleSearchInfoFn: (params: Recordable) => {
35   - // console.log(params);
36   - return params;
  34 + beforeFetch: (params: EventManageRequest) => {
  35 + return {
  36 + ...params,
  37 + startTime: params.startTime ? new Date(params.startTime).getTime() : params.startTime,
  38 + endTime: params.endTime ? new Date(params.endTime).getTime() : params.endTime,
  39 + tbDeviceId: props.tbDeviceId,
  40 + };
37 41 },
38 42 });
39 43
... ... @@ -61,7 +65,7 @@
61 65 </template>
62 66 </BasicTable>
63 67 <BasicModal title="输出参数" @register="registerModal">
64   - <Textarea v-model:value="outputData" :autosize="true" />
  68 + <Input.TextArea v-model:value="outputData" :autosize="true" />
65 69 </BasicModal>
66 70 </template>
67 71
... ...
... ... @@ -13,7 +13,7 @@
13 13 import HistoryData from './HistoryData.vue';
14 14 import { BasicModal, useModal } from '/@/components/Modal';
15 15 import { getDeviceAttrs } from '/@/api/device/deviceManager';
16   - import { DeviceModelOfMatterAttrs } from '/@/api/device/model/deviceModel';
  16 + import { DeviceModelOfMatterAttrs, DeviceRecord } from '/@/api/device/model/deviceModel';
17 17 import { computed } from '@vue/reactivity';
18 18 import { Specs, StructJSON } from '/@/api/device/model/modelOfMatterModel';
19 19 import { isArray, isObject } from '/@/utils/is';
... ... @@ -34,7 +34,7 @@
34 34 }
35 35
36 36 const props = defineProps<{
37   - deviceDetail: Record<'tbDeviceId' | 'profileId' | 'id' | 'deviceProfileId', string>;
  37 + deviceDetail: DeviceRecord;
38 38 }>();
39 39
40 40 const grid = {
... ...