|
1
|
1
|
<template>
|
|
2
|
|
- <BasicDrawer :maskClosable="false" @close="handleClose" destroyOnClose v-bind="$attrs" @register="registerDrawer"
|
|
3
|
|
- showFooter :title="getTitle" width="30%" @ok="handleSubmit">
|
|
|
2
|
+ <BasicDrawer
|
|
|
3
|
+ :maskClosable="false"
|
|
|
4
|
+ @close="handleClose"
|
|
|
5
|
+ destroyOnClose
|
|
|
6
|
+ v-bind="$attrs"
|
|
|
7
|
+ @register="registerDrawer"
|
|
|
8
|
+ showFooter
|
|
|
9
|
+ :title="getTitle"
|
|
|
10
|
+ width="30%"
|
|
|
11
|
+ @ok="handleSubmit"
|
|
|
12
|
+ >
|
|
4
|
13
|
<BasicForm @register="registerForm">
|
|
5
|
|
- <template #devices>
|
|
6
|
|
- <Select placeholder="请选择设备" v-model:value="selectDevice" style="width: 100%" :options="selectOptions"
|
|
7
|
|
- @change="handleDeviceChange" mode="multiple" labelInValue allowClear notFoundContent="请选择设备" />
|
|
|
14
|
+ <template #devices="{ model, field }">
|
|
|
15
|
+ <p style="display: none">{{ field }}</p>
|
|
|
16
|
+ <p>{{ orgFunc(model['organizationId']) }}</p>
|
|
|
17
|
+ <Select
|
|
|
18
|
+ placeholder="请选择设备"
|
|
|
19
|
+ v-model:value="selectDevice"
|
|
|
20
|
+ style="width: 100%"
|
|
|
21
|
+ :options="selectOptions"
|
|
|
22
|
+ @change="handleDeviceChange"
|
|
|
23
|
+ @deselect="handleDeselect"
|
|
|
24
|
+ mode="multiple"
|
|
|
25
|
+ labelInValue
|
|
|
26
|
+ allowClear
|
|
|
27
|
+ notFoundContent="请选择设备"
|
|
|
28
|
+ />
|
|
8
|
29
|
<div style="margin-top: 1.5vh"></div>
|
|
9
|
|
- <DeviceAttrCpns ref="deviceAttrRef" @change="handleChange" :value="deviceList"
|
|
10
|
|
- :orgId="organizationId || orgId" />
|
|
|
30
|
+ <template v-for="(item, index) in deviceList" :key="item.value">
|
|
|
31
|
+ <p style="display: none">{{ index }}</p>
|
|
|
32
|
+ <DeviceAttrCpns
|
|
|
33
|
+ :ref="bindDeviceRefObj.deviceAttrRef"
|
|
|
34
|
+ :value="item"
|
|
|
35
|
+ :orgId="organizationId || orgId"
|
|
|
36
|
+ />
|
|
|
37
|
+ </template>
|
|
11
|
38
|
</template>
|
|
12
|
39
|
</BasicForm>
|
|
13
|
40
|
</BasicDrawer>
|
|
14
|
41
|
</template>
|
|
15
|
42
|
<script lang="ts" setup>
|
|
16
|
|
-import { ref, computed, unref, reactive, watch, Ref } from 'vue';
|
|
17
|
|
-import { BasicForm, useForm } from '/@/components/Form';
|
|
18
|
|
-import { formSchema, organizationId } from './config.data';
|
|
19
|
|
-import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
|
20
|
|
-import { createOrEditReportManage, putReportConfigManage, reportEditDetailPage } from '/@/api/report/reportManager';
|
|
21
|
|
-import { useMessage } from '/@/hooks/web/useMessage';
|
|
22
|
|
-import moment from 'moment';
|
|
23
|
|
-import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
|
|
24
|
|
-import { Select } from 'ant-design-vue';
|
|
25
|
|
-import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue';
|
|
26
|
|
-import { SelectTypes } from 'ant-design-vue/es/select';
|
|
27
|
|
-import { SchemaFiled } from './config.data';
|
|
28
|
|
-import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config';
|
|
29
|
|
-import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
|
|
|
43
|
+ import { ref, computed, unref, reactive, watch, Ref } from 'vue';
|
|
|
44
|
+ import { BasicForm, useForm } from '/@/components/Form';
|
|
|
45
|
+ import { formSchema, organizationId } from './config.data';
|
|
|
46
|
+ import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
|
|
47
|
+ import {
|
|
|
48
|
+ createOrEditReportManage,
|
|
|
49
|
+ putReportConfigManage,
|
|
|
50
|
+ reportEditDetailPage,
|
|
|
51
|
+ } from '/@/api/report/reportManager';
|
|
|
52
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
53
|
+ import moment from 'moment';
|
|
|
54
|
+ import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
|
|
|
55
|
+ import { Select } from 'ant-design-vue';
|
|
|
56
|
+ import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue';
|
|
|
57
|
+ import { SelectTypes } from 'ant-design-vue/es/select';
|
|
|
58
|
+ import { SchemaFiled } from './config.data';
|
|
|
59
|
+ import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config';
|
|
|
60
|
+ import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
|
|
30
|
61
|
|
|
31
|
|
-type TDeviceList = {
|
|
32
|
|
- key?: string,
|
|
33
|
|
- value?: string,
|
|
34
|
|
- label?: string,
|
|
35
|
|
- attribute?: string,
|
|
36
|
|
- device?: string,
|
|
37
|
|
- name?: string
|
|
38
|
|
-}
|
|
39
|
|
-const emit = defineEmits(['success', 'register']);
|
|
40
|
|
-const deviceAttrRef = ref<InstanceType<typeof DeviceAttrCpns> | null>(null)
|
|
41
|
|
-const isUpdate = ref(true);
|
|
42
|
|
-const editId = ref('');
|
|
43
|
|
-const orgId = ref('');
|
|
44
|
|
-const selectOptions: Ref<SelectTypes['options']> = ref([]);
|
|
45
|
|
-const selectDevice = ref([]);
|
|
46
|
|
-const deviceList: Ref<TDeviceList[]> = ref([]);
|
|
47
|
|
-const editDeviceList: Ref<TDeviceList[]> = ref([]);
|
|
48
|
|
-let editResData: any = reactive({})
|
|
49
|
|
-const watchOrgId = ref('')
|
|
50
|
|
-const editDeviceAttr: any = ref([])
|
|
51
|
|
-
|
|
52
|
|
-watch(organizationId, async (newValue: string) => {
|
|
53
|
|
- if (!newValue) return;
|
|
54
|
|
- //获取设备
|
|
55
|
|
- watchOrgId.value = newValue
|
|
56
|
|
- const { items } = await screenLinkPageByDeptIdGetDevice({
|
|
57
|
|
- organizationId: newValue,
|
|
58
|
|
- });
|
|
59
|
|
- selectOptions.value = items.map((item) => {
|
|
60
|
|
- if (item.deviceType !== 'GATEWAY')
|
|
61
|
|
- return {
|
|
62
|
|
- label: item.name,
|
|
63
|
|
- value: item.tbDeviceId,
|
|
64
|
|
- };
|
|
65
|
|
- });
|
|
66
|
|
-});
|
|
67
|
|
-const handleDeviceChange = (e) => {
|
|
68
|
|
- console.log(e)
|
|
69
|
|
- deviceList.value = e;
|
|
70
|
|
-};
|
|
71
|
|
-const [registerForm, { validate, setFieldsValue, resetFields, updateSchema, getFieldsValue }] = useForm({
|
|
72
|
|
- labelWidth: 120,
|
|
73
|
|
- schemas: formSchema,
|
|
74
|
|
- showActionButtonGroup: false,
|
|
75
|
|
- fieldMapToTime: [[SchemaFiled.DATE_RANGE, [SchemaFiled.START_TS, SchemaFiled.END_TS]]],
|
|
76
|
|
-});
|
|
77
|
|
-const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
78
|
|
- await resetFields();
|
|
79
|
|
- setDrawerProps({ confirmLoading: false });
|
|
80
|
|
- isUpdate.value = !!data?.isUpdate;
|
|
81
|
|
- if (unref(isUpdate)) {
|
|
82
|
|
- //编辑回显数据
|
|
83
|
|
- editResData = await reportEditDetailPage(data.record.id)
|
|
84
|
|
- //回显基础数据
|
|
85
|
|
- editId.value = editResData.data.id;
|
|
86
|
|
- await setFieldsValue(editResData.data);
|
|
87
|
|
- //回显嵌套数据
|
|
88
|
|
- await setFieldsValue({
|
|
89
|
|
- agg: editResData.data.queryCondition?.agg,
|
|
90
|
|
- interval: editResData.data.queryCondition?.interval,
|
|
91
|
|
- limit1: editResData.data.queryCondition?.limit,
|
|
92
|
|
- orderBy: editResData.data.queryCondition?.orderBy,
|
|
93
|
|
- useStrictDataTypes: editResData.data.queryCondition?.useStrictDataTypes
|
|
94
|
|
- });
|
|
95
|
|
- //回显聚合条件
|
|
96
|
|
- const dataCompareOpions = [
|
|
97
|
|
- { label: '最小值', value: AggregateDataEnum.MIN },
|
|
98
|
|
- { label: '最大值', value: AggregateDataEnum.MAX },
|
|
99
|
|
- { label: '平均值', value: AggregateDataEnum.AVG },
|
|
100
|
|
- { label: '求和', value: AggregateDataEnum.SUM },
|
|
101
|
|
- { label: '空', value: AggregateDataEnum.NONE }
|
|
102
|
|
- ]
|
|
103
|
|
- const updateSchemaAgg = (options: {}) => {
|
|
104
|
|
- updateSchema({
|
|
105
|
|
- field: SchemaFiled.AGG,
|
|
106
|
|
- componentProps: {
|
|
107
|
|
- options,
|
|
108
|
|
- },
|
|
109
|
|
- });
|
|
|
62
|
+ type TDeviceList = {
|
|
|
63
|
+ key?: string;
|
|
|
64
|
+ value?: string;
|
|
|
65
|
+ label?: string;
|
|
|
66
|
+ attribute?: string;
|
|
|
67
|
+ device?: string;
|
|
|
68
|
+ name?: string;
|
|
|
69
|
+ };
|
|
|
70
|
+ const emit = defineEmits(['success', 'register']);
|
|
|
71
|
+ const bindDeviceRefObj = {
|
|
|
72
|
+ deviceAttrRef: ref([]),
|
|
|
73
|
+ };
|
|
|
74
|
+ const isUpdate = ref(true);
|
|
|
75
|
+ const editId = ref('');
|
|
|
76
|
+ const orgId = ref('');
|
|
|
77
|
+ const selectOptions: Ref<SelectTypes['options']> = ref([]);
|
|
|
78
|
+ const selectDevice = ref([]);
|
|
|
79
|
+ const deviceList: Ref<TDeviceList[]> = ref([]);
|
|
|
80
|
+ const editDeviceList: Ref<TDeviceList[]> = ref([]);
|
|
|
81
|
+ let editResData: any = reactive({});
|
|
|
82
|
+ const editDeviceAttr: any = ref([]);
|
|
|
83
|
+ const orgFuncId = ref('');
|
|
|
84
|
+ const orgFunc = (e) => {
|
|
|
85
|
+ orgFuncId.value = e;
|
|
|
86
|
+ };
|
|
|
87
|
+ watch(
|
|
|
88
|
+ () => orgFuncId.value,
|
|
|
89
|
+ async (newValue: string) => {
|
|
|
90
|
+ if (newValue) {
|
|
|
91
|
+ //获取设备
|
|
|
92
|
+ const { items } = await screenLinkPageByDeptIdGetDevice({
|
|
|
93
|
+ organizationId: newValue,
|
|
|
94
|
+ });
|
|
|
95
|
+ selectOptions.value = items.map((item) => {
|
|
|
96
|
+ if (item.deviceType !== 'GATEWAY')
|
|
|
97
|
+ return {
|
|
|
98
|
+ label: item.name,
|
|
|
99
|
+ value: item.tbDeviceId,
|
|
|
100
|
+ };
|
|
|
101
|
+ });
|
|
|
102
|
+ }
|
|
110
|
103
|
}
|
|
111
|
|
- if (editResData.data.dataType == 1) updateSchemaAgg(dataCompareOpions.slice(0, 4))
|
|
112
|
|
- else updateSchemaAgg(dataCompareOpions.slice(4, 5))
|
|
113
|
|
- //回显执行方式和查询周期
|
|
114
|
|
- const dataQueryOpions = [
|
|
115
|
|
- { label: '固定周期', value: QueryWay.LATEST },
|
|
116
|
|
- { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
117
|
|
- ];
|
|
118
|
|
- const updateSchemaQuery = (options: {}) => {
|
|
119
|
|
- updateSchema({
|
|
120
|
|
- field: SchemaFiled.WAY,
|
|
121
|
|
- componentProps: {
|
|
122
|
|
- options,
|
|
123
|
|
- },
|
|
|
104
|
+ );
|
|
|
105
|
+ //设备Select选中
|
|
|
106
|
+ const handleDeviceChange = (e) => {
|
|
|
107
|
+ if (unref(isUpdate)) {
|
|
|
108
|
+ editDeviceAttr.value.forEach((f) => {
|
|
|
109
|
+ deviceList.value = [f, ...e];
|
|
124
|
110
|
});
|
|
|
111
|
+ let deWeightThree = () => {
|
|
|
112
|
+ let map = new Map();
|
|
|
113
|
+ for (let item of deviceList.value) {
|
|
|
114
|
+ if (!map.has(item.value)) {
|
|
|
115
|
+ map.set(item.value, item);
|
|
|
116
|
+ }
|
|
|
117
|
+ }
|
|
|
118
|
+ return [...map.values()];
|
|
|
119
|
+ };
|
|
|
120
|
+ deviceList.value = deWeightThree();
|
|
|
121
|
+ } else {
|
|
|
122
|
+ deviceList.value = e;
|
|
|
123
|
+ }
|
|
|
124
|
+ };
|
|
|
125
|
+ //设备取消删除
|
|
|
126
|
+ const handleDeselect = (e) => {
|
|
|
127
|
+ if (unref(isUpdate)) {
|
|
|
128
|
+ const eEditDevice = e.key || e.value;
|
|
|
129
|
+ let deWeightThree = () => {
|
|
|
130
|
+ let map = new Map();
|
|
|
131
|
+ for (let item of deviceList.value) {
|
|
|
132
|
+ if (!map.has(item.value)) {
|
|
|
133
|
+ map.set(item.value, item);
|
|
|
134
|
+ }
|
|
|
135
|
+ }
|
|
|
136
|
+ return [...map.values()];
|
|
|
137
|
+ };
|
|
|
138
|
+ deviceList.value = deWeightThree();
|
|
|
139
|
+ const findEditValue = deviceList.value.findIndex((f) => f.value == eEditDevice);
|
|
|
140
|
+ if (findEditValue !== -1) deviceList.value.splice(findEditValue, 1);
|
|
|
141
|
+ } else {
|
|
|
142
|
+ const eDevice = e.key || e.value;
|
|
|
143
|
+ const findValue = deviceList.value.findIndex((f) => f.value == eDevice);
|
|
|
144
|
+ if (findValue !== -1) deviceList.value.splice(findValue, 1);
|
|
125
|
145
|
}
|
|
126
|
|
- if (editResData.data.executeWay == 0) updateSchemaQuery(dataQueryOpions)
|
|
127
|
|
- else updateSchemaQuery(dataQueryOpions.slice(0, 1))
|
|
128
|
|
- //回显设备
|
|
129
|
|
- orgId.value = editResData.data.organizationId;
|
|
130
|
|
- const { items } = await screenLinkPageByDeptIdGetDevice({
|
|
131
|
|
- organizationId: editResData.data.organizationId,
|
|
|
146
|
+ };
|
|
|
147
|
+ const [registerForm, { validate, setFieldsValue, resetFields, updateSchema, getFieldsValue }] =
|
|
|
148
|
+ useForm({
|
|
|
149
|
+ labelWidth: 120,
|
|
|
150
|
+ schemas: formSchema,
|
|
|
151
|
+ showActionButtonGroup: false,
|
|
|
152
|
+ fieldMapToTime: [[SchemaFiled.DATE_RANGE, [SchemaFiled.START_TS, SchemaFiled.END_TS]]],
|
|
132
|
153
|
});
|
|
133
|
|
- selectOptions.value = items.map((item) => {
|
|
134
|
|
- if (item.deviceType !== 'GATEWAY')
|
|
|
154
|
+ const isViewDetail = ref(false);
|
|
|
155
|
+
|
|
|
156
|
+ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
|
157
|
+ await resetFields();
|
|
|
158
|
+ setDrawerProps({ confirmLoading: false });
|
|
|
159
|
+ isUpdate.value = !!data?.isUpdate;
|
|
|
160
|
+ isViewDetail.value = !!data?.isView;
|
|
|
161
|
+ if (unref(isViewDetail)) {
|
|
|
162
|
+ setDrawerProps({ showFooter: true });
|
|
|
163
|
+ if (unref(isUpdate)) {
|
|
|
164
|
+ setDrawerProps({ title: '编辑报表配置' });
|
|
|
165
|
+ } else {
|
|
|
166
|
+ setDrawerProps({ title: '新增报表配置' });
|
|
|
167
|
+ }
|
|
|
168
|
+ } else {
|
|
|
169
|
+ setDrawerProps({ showFooter: false });
|
|
|
170
|
+ setDrawerProps({ title: '查看报表配置' });
|
|
|
171
|
+ }
|
|
|
172
|
+ if (unref(isUpdate)) {
|
|
|
173
|
+ //编辑回显数据
|
|
|
174
|
+ editResData = await reportEditDetailPage(data.record.id);
|
|
|
175
|
+ //回显基础数据
|
|
|
176
|
+ editId.value = editResData.data.id;
|
|
|
177
|
+ await setFieldsValue(editResData.data);
|
|
|
178
|
+ //回显嵌套数据
|
|
|
179
|
+ await setFieldsValue({
|
|
|
180
|
+ agg: editResData.data.queryCondition?.agg,
|
|
|
181
|
+ interval: editResData.data.queryCondition?.interval,
|
|
|
182
|
+ limit1: editResData.data.queryCondition?.limit,
|
|
|
183
|
+ orderBy: editResData.data.queryCondition?.orderBy,
|
|
|
184
|
+ useStrictDataTypes: editResData.data.queryCondition?.useStrictDataTypes,
|
|
|
185
|
+ startTs: editResData.data.queryCondition?.startTs,
|
|
|
186
|
+ endTs: editResData.data.queryCondition?.endTs,
|
|
|
187
|
+ });
|
|
|
188
|
+ //回显聚合条件
|
|
|
189
|
+ const dataCompareOpions = [
|
|
|
190
|
+ { label: '最小值', value: AggregateDataEnum.MIN },
|
|
|
191
|
+ { label: '最大值', value: AggregateDataEnum.MAX },
|
|
|
192
|
+ { label: '平均值', value: AggregateDataEnum.AVG },
|
|
|
193
|
+ { label: '求和', value: AggregateDataEnum.SUM },
|
|
|
194
|
+ { label: '空', value: AggregateDataEnum.NONE },
|
|
|
195
|
+ ];
|
|
|
196
|
+ const updateSchemaAgg = (options: {}) => {
|
|
|
197
|
+ updateSchema({
|
|
|
198
|
+ field: SchemaFiled.AGG,
|
|
|
199
|
+ componentProps: {
|
|
|
200
|
+ options,
|
|
|
201
|
+ },
|
|
|
202
|
+ });
|
|
|
203
|
+ };
|
|
|
204
|
+ if (editResData.data.dataType == 1) updateSchemaAgg(dataCompareOpions.slice(0, 4));
|
|
|
205
|
+ else updateSchemaAgg(dataCompareOpions.slice(4, 5));
|
|
|
206
|
+ //回显执行方式和查询周期
|
|
|
207
|
+ const dataQueryOpions = [
|
|
|
208
|
+ { label: '固定周期', value: QueryWay.LATEST },
|
|
|
209
|
+ { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
|
210
|
+ ];
|
|
|
211
|
+ const updateSchemaQuery = (options: {}) => {
|
|
|
212
|
+ updateSchema({
|
|
|
213
|
+ field: SchemaFiled.WAY,
|
|
|
214
|
+ componentProps: {
|
|
|
215
|
+ options,
|
|
|
216
|
+ },
|
|
|
217
|
+ });
|
|
|
218
|
+ };
|
|
|
219
|
+ if (editResData.data.executeWay == 0) updateSchemaQuery(dataQueryOpions);
|
|
|
220
|
+ else updateSchemaQuery(dataQueryOpions.slice(0, 1));
|
|
|
221
|
+ //回显设备
|
|
|
222
|
+ orgId.value = editResData.data.organizationId;
|
|
|
223
|
+ const { items } = await screenLinkPageByDeptIdGetDevice({
|
|
|
224
|
+ organizationId: editResData.data.organizationId,
|
|
|
225
|
+ });
|
|
|
226
|
+ selectOptions.value = items.map((item) => {
|
|
|
227
|
+ if (item.deviceType !== 'GATEWAY')
|
|
|
228
|
+ return {
|
|
|
229
|
+ label: item.name,
|
|
|
230
|
+ value: item.tbDeviceId,
|
|
|
231
|
+ };
|
|
|
232
|
+ });
|
|
|
233
|
+ const deviceIds = editResData.data.executeAttributes.map((m) => {
|
|
|
234
|
+ return {
|
|
|
235
|
+ label: m.name,
|
|
|
236
|
+ key: m.device,
|
|
|
237
|
+ };
|
|
|
238
|
+ });
|
|
|
239
|
+ selectDevice.value = deviceIds;
|
|
|
240
|
+ //回显设备属性
|
|
|
241
|
+ editDeviceAttr.value = editResData.data.executeAttributes?.map((item) => {
|
|
135
|
242
|
return {
|
|
136
|
243
|
label: item.name,
|
|
137
|
|
- value: item.tbDeviceId,
|
|
|
244
|
+ value: item.device,
|
|
|
245
|
+ attributes: item.attributes,
|
|
138
|
246
|
};
|
|
139
|
|
- });
|
|
140
|
|
- const deviceIds = editResData.data.executeAttributes.map(m => {
|
|
141
|
|
- return {
|
|
142
|
|
- label: m.name,
|
|
143
|
|
- key: m.device
|
|
144
|
|
- }
|
|
145
|
|
- })
|
|
146
|
|
- selectDevice.value = deviceIds;
|
|
147
|
|
- //回显设备属性
|
|
148
|
|
- editDeviceAttr.value = editResData.data.executeAttributes?.map(item => {
|
|
149
|
|
- return {
|
|
150
|
|
- label: item.name,
|
|
151
|
|
- value: item.device,
|
|
152
|
|
- attributes: item.attributes,
|
|
153
|
|
- }
|
|
154
|
|
- })
|
|
155
|
|
- deviceList.value = editDeviceAttr.value
|
|
156
|
|
- editDeviceList.value = editResData.data.executeAttributes
|
|
157
|
|
- } else {
|
|
158
|
|
- editId.value = '';
|
|
159
|
|
- orgId.value = '';
|
|
160
|
|
- selectDevice.value = [];
|
|
161
|
|
- selectOptions.value = [];
|
|
162
|
|
- deviceList.value = [];
|
|
163
|
|
- getAttrDevice.value = []
|
|
164
|
|
- editDeviceList.value = []
|
|
165
|
|
- editDeviceAttr.value = []
|
|
166
|
|
- updateSchema({
|
|
167
|
|
- field: SchemaFiled.AGG,
|
|
168
|
|
- componentProps: {
|
|
169
|
|
- options: [],
|
|
170
|
|
- },
|
|
171
|
|
- });
|
|
172
|
|
- //新增显示执行方式和查询周期
|
|
173
|
|
- const dataQueryOpions = [
|
|
174
|
|
- { label: '固定周期', value: QueryWay.LATEST },
|
|
175
|
|
- { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
176
|
|
- ];
|
|
177
|
|
- const updateSchemaQuery = (options: {}) => {
|
|
|
247
|
+ });
|
|
|
248
|
+ deviceList.value = editDeviceAttr.value;
|
|
|
249
|
+ editDeviceList.value = editResData.data.executeAttributes;
|
|
|
250
|
+ } else {
|
|
|
251
|
+ editId.value = '';
|
|
|
252
|
+ orgId.value = '';
|
|
|
253
|
+ selectDevice.value = [];
|
|
|
254
|
+ selectOptions.value = [];
|
|
|
255
|
+ deviceList.value = [];
|
|
|
256
|
+ getAttrDevice.value = [];
|
|
|
257
|
+ editDeviceList.value = [];
|
|
|
258
|
+ editDeviceAttr.value = [];
|
|
178
|
259
|
updateSchema({
|
|
179
|
|
- field: SchemaFiled.WAY,
|
|
|
260
|
+ field: SchemaFiled.AGG,
|
|
180
|
261
|
componentProps: {
|
|
181
|
|
- options,
|
|
|
262
|
+ options: [],
|
|
182
|
263
|
},
|
|
183
|
264
|
});
|
|
|
265
|
+ //新增显示执行方式和查询周期
|
|
|
266
|
+ const dataQueryOpions = [
|
|
|
267
|
+ { label: '固定周期', value: QueryWay.LATEST },
|
|
|
268
|
+ { label: '自定义周期', value: QueryWay.TIME_PERIOD },
|
|
|
269
|
+ ];
|
|
|
270
|
+ const updateSchemaQuery = (options: {}) => {
|
|
|
271
|
+ updateSchema({
|
|
|
272
|
+ field: SchemaFiled.WAY,
|
|
|
273
|
+ componentProps: {
|
|
|
274
|
+ options,
|
|
|
275
|
+ },
|
|
|
276
|
+ });
|
|
|
277
|
+ };
|
|
|
278
|
+ if (getFieldsValue().executeWay == 0) updateSchemaQuery(dataQueryOpions);
|
|
184
|
279
|
}
|
|
185
|
|
- if (getFieldsValue().executeWay == 0) updateSchemaQuery(dataQueryOpions)
|
|
186
|
|
- }
|
|
187
|
|
-});
|
|
188
|
|
-const handleClose = () => {
|
|
189
|
|
- deviceList.value = [];
|
|
190
|
|
-}
|
|
191
|
|
-const getAttrDevice: Ref<TDeviceList[]> = ref([]);
|
|
192
|
|
-const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置'));
|
|
193
|
|
-const handleChange = (e: any) => {
|
|
194
|
|
- getAttrDevice.value = e
|
|
195
|
|
-};
|
|
196
|
|
-let postObj: any = reactive({});
|
|
197
|
|
-let queryCondition: any = reactive({});
|
|
198
|
|
-let executeContent: any = reactive({});
|
|
199
|
|
-const startTs = ref(0)
|
|
200
|
|
-const endTs = ref(0);
|
|
201
|
|
-async function handleSubmit() {
|
|
202
|
|
- setDrawerProps({ confirmLoading: true });
|
|
203
|
|
- try {
|
|
204
|
|
- const { createMessage } = useMessage();
|
|
205
|
|
- const values = await validate();
|
|
206
|
|
- if (!values) return;
|
|
207
|
|
- if (!unref(isUpdate)) {
|
|
208
|
|
- if (getAttrDevice.value.length === 0) {
|
|
209
|
|
- return createMessage.error('请选择设备及其属性');
|
|
|
280
|
+ });
|
|
|
281
|
+ const handleClose = () => {
|
|
|
282
|
+ deviceList.value = [];
|
|
|
283
|
+ editId.value = '';
|
|
|
284
|
+ orgId.value = '';
|
|
|
285
|
+ selectDevice.value = [];
|
|
|
286
|
+ selectOptions.value = [];
|
|
|
287
|
+ getAttrDevice.value = [];
|
|
|
288
|
+ editDeviceList.value = [];
|
|
|
289
|
+ editDeviceAttr.value = [];
|
|
|
290
|
+ };
|
|
|
291
|
+ const getAttrDevice: Ref<TDeviceList[]> = ref([]);
|
|
|
292
|
+ const getTitle = computed(() => (!unref(isUpdate) ? '新增报表配置' : '编辑报表配置'));
|
|
|
293
|
+ let postObj: any = reactive({});
|
|
|
294
|
+ let queryCondition: any = reactive({});
|
|
|
295
|
+ let executeContent: any = reactive({});
|
|
|
296
|
+ const startTs = ref(0);
|
|
|
297
|
+ const endTs = ref(0);
|
|
|
298
|
+
|
|
|
299
|
+ const getFormValueFunc = () => {
|
|
|
300
|
+ const item: any = unref(bindDeviceRefObj.deviceAttrRef)?.map((item: any) => item.emitChange());
|
|
|
301
|
+ getAttrDevice.value = item;
|
|
|
302
|
+ };
|
|
|
303
|
+
|
|
|
304
|
+ async function handleSubmit() {
|
|
|
305
|
+ setDrawerProps({ confirmLoading: true });
|
|
|
306
|
+ try {
|
|
|
307
|
+ const { createMessage } = useMessage();
|
|
|
308
|
+ const values = await validate();
|
|
|
309
|
+ if (!values) return;
|
|
|
310
|
+ getFormValueFunc();
|
|
|
311
|
+ if (!unref(isUpdate)) {
|
|
|
312
|
+ if (getAttrDevice.value.length === 0) {
|
|
|
313
|
+ return createMessage.error('请选择设备及其属性');
|
|
|
314
|
+ }
|
|
210
|
315
|
}
|
|
211
|
|
- }
|
|
212
|
|
- if (values.executeWay == 0) {
|
|
213
|
|
- executeContent = null;
|
|
214
|
|
- } else {
|
|
215
|
|
- executeContent = values.cronTime
|
|
216
|
|
- }
|
|
217
|
|
- queryCondition = {
|
|
218
|
|
- agg: values.agg,
|
|
219
|
|
- interval: values.interval,
|
|
220
|
|
- limit: values.limit1,
|
|
221
|
|
- };
|
|
222
|
|
- if (values.way === QueryWay.LATEST) {
|
|
223
|
|
- startTs.value = moment().subtract(values.startTs, 'ms').valueOf()
|
|
224
|
|
- endTs.value = Date.now()
|
|
225
|
|
- } else {
|
|
226
|
|
- startTs.value = moment(values.startTs).valueOf()
|
|
227
|
|
- endTs.value = moment(values.endTs).valueOf()
|
|
228
|
|
- }
|
|
229
|
|
- delete values.devices;
|
|
230
|
|
- delete values.agg;
|
|
231
|
|
- delete values.interval;
|
|
232
|
|
- delete values.timeZone;
|
|
233
|
|
- delete values.timeWeek;
|
|
234
|
|
- delete values.cronTime;
|
|
235
|
|
- delete values.cronWeek;
|
|
236
|
|
- delete values.cronYear;
|
|
237
|
|
- delete values.limit1;
|
|
238
|
|
- postObj = {
|
|
239
|
|
- ...values,
|
|
240
|
|
- ...{ executeAttributes: getAttrDevice.value.length == 0 ? editDeviceList.value : getAttrDevice.value },
|
|
241
|
|
- ...{ queryCondition },
|
|
242
|
|
- ...{
|
|
243
|
|
- startTs: startTs.value
|
|
244
|
|
- },
|
|
245
|
|
- ...{
|
|
246
|
|
- endTs: endTs.value
|
|
247
|
|
- },
|
|
248
|
|
- ...{ executeContent },
|
|
249
|
|
- ...{ id: editId.value !== '' ? editId.value : '' },
|
|
250
|
|
- };
|
|
251
|
|
- let saveMessage = '添加成功';
|
|
252
|
|
- let updateMessage = '修改成功';
|
|
253
|
|
- editId.value !== ''
|
|
254
|
|
- ? await putReportConfigManage(postObj)
|
|
255
|
|
- : await createOrEditReportManage(postObj);
|
|
|
316
|
+ if (values.executeWay == 0) {
|
|
|
317
|
+ executeContent = null;
|
|
|
318
|
+ } else {
|
|
|
319
|
+ executeContent = values.cronTime;
|
|
|
320
|
+ }
|
|
|
321
|
+ if (values.way === QueryWay.LATEST) {
|
|
|
322
|
+ startTs.value = moment().subtract(values.startTs, 'ms').valueOf();
|
|
|
323
|
+ endTs.value = Date.now();
|
|
|
324
|
+ } else {
|
|
|
325
|
+ startTs.value = moment(values.startTs).valueOf();
|
|
|
326
|
+ endTs.value = moment(values.endTs).valueOf();
|
|
|
327
|
+ }
|
|
|
328
|
+ queryCondition = {
|
|
|
329
|
+ agg: values.agg,
|
|
|
330
|
+ interval: values.interval,
|
|
|
331
|
+ limit: values.limit1,
|
|
|
332
|
+ ...{
|
|
|
333
|
+ startTs: startTs.value,
|
|
|
334
|
+ },
|
|
|
335
|
+ ...{
|
|
|
336
|
+ endTs: endTs.value,
|
|
|
337
|
+ },
|
|
|
338
|
+ };
|
|
|
339
|
+
|
|
|
340
|
+ delete values.devices;
|
|
|
341
|
+ delete values.agg;
|
|
|
342
|
+ delete values.interval;
|
|
|
343
|
+ delete values.timeZone;
|
|
|
344
|
+ delete values.timeWeek;
|
|
|
345
|
+ delete values.cronTime;
|
|
|
346
|
+ delete values.cronWeek;
|
|
|
347
|
+ delete values.cronYear;
|
|
|
348
|
+ delete values.limit1;
|
|
|
349
|
+ delete values.startTs;
|
|
|
350
|
+ postObj = {
|
|
|
351
|
+ ...values,
|
|
|
352
|
+ ...{
|
|
|
353
|
+ executeAttributes:
|
|
|
354
|
+ getAttrDevice.value.length == 0 ? editDeviceList.value : getAttrDevice.value,
|
|
|
355
|
+ },
|
|
|
356
|
+ ...{ queryCondition },
|
|
|
357
|
+
|
|
|
358
|
+ ...{ executeContent },
|
|
|
359
|
+ ...{ id: editId.value !== '' ? editId.value : '' },
|
|
|
360
|
+ };
|
|
|
361
|
+ let saveMessage = '添加成功';
|
|
|
362
|
+ let updateMessage = '修改成功';
|
|
|
363
|
+ editId.value !== ''
|
|
|
364
|
+ ? await putReportConfigManage(postObj)
|
|
|
365
|
+ : await createOrEditReportManage(postObj);
|
|
256
|
366
|
|
|
257
|
|
- closeDrawer();
|
|
258
|
|
- emit('success');
|
|
259
|
|
- createMessage.success(unref(isUpdate) ? updateMessage : saveMessage);
|
|
260
|
|
- } finally {
|
|
261
|
|
- setTimeout(() => {
|
|
262
|
|
- setDrawerProps({ confirmLoading: false });
|
|
263
|
|
- }, 300);
|
|
|
367
|
+ closeDrawer();
|
|
|
368
|
+ emit('success');
|
|
|
369
|
+ createMessage.success(unref(isUpdate) ? updateMessage : saveMessage);
|
|
|
370
|
+ handleClose();
|
|
|
371
|
+ } finally {
|
|
|
372
|
+ setTimeout(() => {
|
|
|
373
|
+ setDrawerProps({ confirmLoading: false });
|
|
|
374
|
+ }, 300);
|
|
|
375
|
+ }
|
|
264
|
376
|
}
|
|
265
|
|
-}
|
|
266
|
377
|
</script> |
...
|
...
|
|