Commit 6695d737526f42947130825bfef260963b1d1d46
1 parent
2c122df0
feat:租户配置分页接口和新增和删除接口,wip:设备配置新增报警规则
Showing
19 changed files
with
371 additions
and
342 deletions
... | ... | @@ -30,10 +30,9 @@ export const deviceConfigGetDetail = (id: string) => { |
30 | 30 | /** |
31 | 31 | * 获取规则链 |
32 | 32 | */ |
33 | -export const deviceConfigGetRuleChain = (params: {}) => { | |
33 | +export const deviceConfigGetRuleChain = () => { | |
34 | 34 | return defHttp.get({ |
35 | 35 | url: EDeviceConfigApi.DEVICE_CONFIG_GET_RULECHAIN, |
36 | - params, | |
37 | 36 | }); |
38 | 37 | }; |
39 | 38 | ... | ... |
... | ... | @@ -28,20 +28,42 @@ enum Api { |
28 | 28 | getTenantRoles = '/admin/tenant/roles/', |
29 | 29 | postAddTenantProfile = '/tenantProfile', |
30 | 30 | getTenantProfile = '/tenantProfiles', |
31 | + deleteTenantProfile = '/tenantProfiles', | |
32 | +} | |
33 | + | |
34 | +export async function deleteTenantProfileApi(tenantIds) { | |
35 | + await defHttp.delete( | |
36 | + { | |
37 | + url: `${Api.deleteTenantProfile}/${tenantIds}`, | |
38 | + }, | |
39 | + { | |
40 | + joinPrefix: false, | |
41 | + } | |
42 | + ); | |
31 | 43 | } |
32 | 44 | |
33 | 45 | export const getTableTenantProfileApi = (params?: QueryTenantProfilesParam) => { |
34 | - return defHttp.get({ | |
35 | - params: params, | |
36 | - url: Api.getTenantProfile, | |
37 | - }); | |
46 | + return defHttp.get( | |
47 | + { | |
48 | + params: params, | |
49 | + url: Api.getTenantProfile, | |
50 | + }, | |
51 | + { | |
52 | + joinPrefix: false, | |
53 | + } | |
54 | + ); | |
38 | 55 | }; |
39 | 56 | |
40 | 57 | export async function saveTenantProfileApi(params: tenantProfileDTO) { |
41 | - await defHttp.post({ | |
42 | - params: params, | |
43 | - url: Api.postAddTenantProfile, | |
44 | - }); | |
58 | + await defHttp.post( | |
59 | + { | |
60 | + params: params, | |
61 | + url: Api.postAddTenantProfile, | |
62 | + }, | |
63 | + { | |
64 | + joinPrefix: false, | |
65 | + } | |
66 | + ); | |
45 | 67 | } |
46 | 68 | |
47 | 69 | export function getTenantPage(params: TenantPageRequestParams) { | ... | ... |
src/components/Application/src/AppTest.vue
0 → 100644
1 | +<template> 111</template> | ... | ... |
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | |
42 | 42 | import { defineComponent } from 'vue'; |
43 | 43 | import { Dropdown, Menu, Popconfirm } from 'ant-design-vue'; |
44 | - import { Icon } from '/@/components/Icon'; | |
44 | + // import { Icon } from '/@/components/Icon'; | |
45 | 45 | import { omit } from 'lodash-es'; |
46 | 46 | import { isFunction } from '/@/utils/is'; |
47 | 47 | |
... | ... | @@ -52,7 +52,7 @@ |
52 | 52 | Menu, |
53 | 53 | MenuItem: Menu.Item, |
54 | 54 | MenuDivider: Menu.Divider, |
55 | - Icon, | |
55 | + // Icon, | |
56 | 56 | Popconfirm, |
57 | 57 | }, |
58 | 58 | props: { | ... | ... |
... | ... | @@ -16,7 +16,12 @@ |
16 | 16 | </a-steps> |
17 | 17 | </div> |
18 | 18 | <div class="mt-5"> |
19 | - <DeviceProfileStep1 :echoStep1="editEchoData" @next="handleStepNext1" v-if="current === 0" /> | |
19 | + <DeviceProfileStep1 | |
20 | + ref="DeviceProfileStep1Ref" | |
21 | + :echoStep1="editEchoData" | |
22 | + @next="handleStepNext1" | |
23 | + v-if="current === 0" | |
24 | + /> | |
20 | 25 | <DeviceProfileStep2 |
21 | 26 | :echoStep2="editEchoData" |
22 | 27 | @prev="handleStepPrev" |
... | ... | @@ -66,6 +71,7 @@ |
66 | 71 | }, |
67 | 72 | emits: ['success', 'register'], |
68 | 73 | setup(_, { emit }) { |
74 | + const DeviceProfileStep1Ref = ref(null); | |
69 | 75 | const { createMessage } = useMessage(); |
70 | 76 | const getStepData = ref(null); |
71 | 77 | const { proxy } = getCurrentInstance(); |
... | ... | @@ -84,14 +90,16 @@ |
84 | 90 | const [register, { closeModal }] = useModalInner((data) => { |
85 | 91 | isUpdate.value = !!data?.isUpdate; |
86 | 92 | if (!unref(isUpdate)) { |
93 | + console.log('新增'); | |
87 | 94 | current.value = 0; |
88 | 95 | postDeviceConfogData.value = {}; |
96 | + proxy.$refs.DeviceProfileStep1Ref.customResetFunc(); | |
89 | 97 | } |
90 | 98 | if (unref(isUpdate)) { |
99 | + console.log('编辑'); | |
91 | 100 | current.value = 0; |
92 | 101 | postEditId.value = data.record.id; |
93 | 102 | editEchoData.value = data.record; |
94 | - editEchoData.value.key = 'edit'; | |
95 | 103 | } |
96 | 104 | }); |
97 | 105 | function handleStepPrev() { |
... | ... | @@ -145,10 +153,11 @@ |
145 | 153 | emit('success'); |
146 | 154 | } |
147 | 155 | }; |
148 | - const handleCancel = async () => { | |
149 | - console.log(2); | |
156 | + const handleCancel = () => { | |
157 | + return; | |
150 | 158 | }; |
151 | 159 | return { |
160 | + DeviceProfileStep1Ref, | |
152 | 161 | editEchoData, |
153 | 162 | getStepData, |
154 | 163 | handleStep3Next, | ... | ... |
... | ... | @@ -166,10 +166,12 @@ |
166 | 166 | } |
167 | 167 | |
168 | 168 | const [register1, { openModal: openModalExcel }] = useModal(); |
169 | - function handleExport(record: Recordable) { | |
170 | - openModalExcel(); | |
169 | + const handleExport = (record: Recordable) => { | |
171 | 170 | console.log(record); |
172 | - } | |
171 | + setTimeout(() => { | |
172 | + openModalExcel(); | |
173 | + }, 50); | |
174 | + }; | |
173 | 175 | function handleImport() { |
174 | 176 | console.log('record'); |
175 | 177 | } | ... | ... |
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | </div> |
7 | 7 | </template> |
8 | 8 | <script lang="ts"> |
9 | - import { defineComponent, watch } from 'vue'; | |
9 | + import { defineComponent, watch, onMounted } from 'vue'; | |
10 | 10 | import { BasicForm, useForm } from '/@/components/Form'; |
11 | 11 | import { step1Schemas } from './data'; |
12 | 12 | import { Select, Input, Divider } from 'ant-design-vue'; |
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | [Input.Group.name]: Input.Group, |
20 | 20 | [Divider.name]: Divider, |
21 | 21 | }, |
22 | - emits: ['next'], | |
22 | + emits: ['next', 'resetFunc'], | |
23 | 23 | props: { |
24 | 24 | echoStep1: Object, |
25 | 25 | }, |
... | ... | @@ -35,15 +35,16 @@ |
35 | 35 | text: '下一步', |
36 | 36 | }, |
37 | 37 | submitFunc: customSubmitFunc, |
38 | + // resetFunc: customResetFunc, | |
38 | 39 | }); |
40 | + onMounted(() => { | |
41 | + setFieldsValue({ ...props.echoStep1 }); | |
42 | + }); | |
43 | + | |
39 | 44 | watch( |
40 | 45 | () => props.echoStep1, |
41 | 46 | (newV) => { |
42 | - if (newV?.key == 'edit') { | |
43 | - setFieldsValue({ ...newV }); | |
44 | - } else { | |
45 | - resetFields(); | |
46 | - } | |
47 | + setFieldsValue({ ...newV }); | |
47 | 48 | } |
48 | 49 | ); |
49 | 50 | async function customSubmitFunc() { |
... | ... | @@ -53,7 +54,14 @@ |
53 | 54 | } catch (error) {} |
54 | 55 | } |
55 | 56 | |
56 | - return { register }; | |
57 | + const customResetFunc = async () => { | |
58 | + await resetFields(); | |
59 | + // try { | |
60 | + // emit('resetFunc', resetValue); | |
61 | + // } catch (error) {} | |
62 | + }; | |
63 | + | |
64 | + return { register, customResetFunc }; | |
57 | 65 | }, |
58 | 66 | }); |
59 | 67 | </script> | ... | ... |
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 | </template> |
133 | 133 | |
134 | 134 | <script lang="ts"> |
135 | - import { defineComponent, ref, unref, getCurrentInstance, watch, onMounted } from 'vue'; | |
135 | + import { defineComponent, ref, unref, getCurrentInstance, watch } from 'vue'; | |
136 | 136 | import type { alarmListItem } from '../types/index'; |
137 | 137 | import { CollapseContainer } from '/@/components/Container/index'; |
138 | 138 | import { BasicForm, useForm } from '/@/components/Form'; |
... | ... | @@ -278,7 +278,6 @@ |
278 | 278 | }; |
279 | 279 | const getAllFieldsEnabFunc = (v) => { |
280 | 280 | enableObj.value = v; |
281 | - console.log(enableObj.value); | |
282 | 281 | }; |
283 | 282 | const getAllFieldsRuleFunc = (v) => { |
284 | 283 | ruleObj.value = v; |
... | ... | @@ -286,32 +285,43 @@ |
286 | 285 | value: ruleObj.value?.value, |
287 | 286 | }; |
288 | 287 | const predicate = { |
289 | - predicate: ruleObj.value?.predicate, | |
288 | + operation: 'GREATER_OR_EQUAL', | |
289 | + value: { | |
290 | + defaultValue: 12, | |
291 | + }, | |
292 | + type: 'NUMERIC', | |
293 | + }; | |
294 | + const spec = { | |
295 | + // type: ruleObj.value?.spec, | |
296 | + type: 'SIMPLE', | |
290 | 297 | }; |
298 | + | |
291 | 299 | const getCondition = { |
292 | 300 | condition: [ |
293 | 301 | { |
294 | 302 | key: { |
295 | 303 | type: ruleObj.value?.type, |
296 | - key: ruleObj.value?.type, | |
304 | + key: ruleObj.value?.key, | |
297 | 305 | }, |
298 | 306 | valueType: ruleObj.value?.valueType, |
299 | 307 | value, |
300 | 308 | predicate, |
301 | 309 | }, |
302 | 310 | ], |
311 | + spec, | |
303 | 312 | }; |
304 | 313 | |
305 | - const spec = { | |
306 | - spec: ruleObj.value?.spec, | |
307 | - }; | |
314 | + // const spec = { | |
315 | + // spec: ruleObj.value?.spec, | |
316 | + // }; | |
308 | 317 | |
309 | 318 | const getValueConditon = { |
310 | - spec, | |
319 | + // spec, | |
311 | 320 | condition: getCondition, |
312 | 321 | }; |
313 | 322 | Object.assign(additionalObj.value, getValueConditon); |
314 | 323 | }; |
324 | + | |
315 | 325 | const handleFormStep3toStep4Next = async () => { |
316 | 326 | try { |
317 | 327 | const scheduleValue = { |
... | ... | @@ -338,6 +348,10 @@ |
338 | 348 | createRules: getAdditionalPropObj, |
339 | 349 | }; |
340 | 350 | const valueRegisterForm = await validateRegisterForm(); |
351 | + const valueRegisterFormAndId = { | |
352 | + alarmType: Object.values(valueRegisterForm)[0], | |
353 | + }; | |
354 | + | |
341 | 355 | const valueRegisterFormHighSetting = await validateRegisterFormHighSetting(); |
342 | 356 | const valueRegisterFormCreateAlarm = await validateRegisterFormCreateAlarm(); |
343 | 357 | const getValueRegisterFormHighSetting = { |
... | ... | @@ -347,7 +361,7 @@ |
347 | 361 | |
348 | 362 | Object.assign( |
349 | 363 | emptyObj.value, |
350 | - valueRegisterForm, | |
364 | + valueRegisterFormAndId, | |
351 | 365 | getValueRegisterFormHighSetting, |
352 | 366 | getCreateRulesAllObj |
353 | 367 | ); |
... | ... | @@ -356,7 +370,6 @@ |
356 | 370 | alarms: alarmss.value, |
357 | 371 | }; |
358 | 372 | Object.assign(getAllFormData.value, getAlarms); |
359 | - console.log('第三步的数据', getAllFormData.value); | |
360 | 373 | emit('next', getAllFormData.value); |
361 | 374 | } catch (error) {} |
362 | 375 | }; |
... | ... | @@ -369,19 +382,19 @@ |
369 | 382 | isRuleAlarmRuleConditions.value = 1; |
370 | 383 | setTimeout(() => { |
371 | 384 | openModal1(true); |
372 | - }, 10); | |
385 | + }, 50); | |
373 | 386 | }; |
374 | 387 | const handleOpenEnableRule = () => { |
375 | 388 | isRuleAlarmRuleConditions.value = 2; |
376 | 389 | setTimeout(() => { |
377 | 390 | openModal2(true); |
378 | - }, 10); | |
391 | + }, 50); | |
379 | 392 | }; |
380 | 393 | const handleOpenAlaramRuleConditions = () => { |
381 | 394 | isRuleAlarmRuleConditions.value = 3; |
382 | 395 | setTimeout(() => { |
383 | 396 | openModal3(true); |
384 | - }, 10); | |
397 | + }, 50); | |
385 | 398 | }; |
386 | 399 | |
387 | 400 | return { | ... | ... |
1 | 1 | { |
2 | - "alarmProfile": { | |
3 | - "alarmContactId": "string", | |
4 | - "createTime": "2021-12-20T08:19:59.510Z", | |
5 | - "creator": "string", | |
6 | - "defaultConfig": "string", | |
7 | - "description": "string", | |
8 | - "deviceProfileId": "string", | |
9 | - "enabled": true, | |
10 | - "icon": "string", | |
11 | - "id": "string", | |
12 | - "messageMode": "string", | |
13 | - "name": "string", | |
14 | - "roleIds": [ | |
15 | - "string" | |
16 | - ], | |
17 | - "tenantExpireTime": "2021-12-20T08:19:59.511Z", | |
18 | - "tenantId": "string", | |
19 | - "tenantStatus": "DISABLED", | |
20 | - "updateTime": "2021-12-20T08:19:59.511Z", | |
21 | - "updater": "string" | |
22 | - }, | |
23 | - "convertJs": "string", | |
24 | - "createTime": "2021-12-20T08:19:59.511Z", | |
25 | - "creator": "string", | |
26 | - "defaultConfig": "string", | |
27 | - "defaultQueueName": "string", | |
28 | - "defaultRuleChainId": "string", | |
29 | - "description": "string", | |
30 | - "enabled": true, | |
31 | - "icon": "string", | |
32 | - "id": "string", | |
33 | - "name": "string", | |
34 | 2 | "profileData": { |
35 | - "configuration": {}, | |
36 | - "transportConfiguration": {}, | |
37 | - "provisionConfiguration": { | |
38 | - "provisionDeviceSecret": "string" | |
39 | - }, | |
40 | - "alarms": [ | |
41 | - { | |
42 | - "id": "highTemperatureAlarmID", | |
43 | - "alarmType": "High Temperature Alarm", | |
44 | - "propagate": true, | |
45 | - "propagateRelationTypes": [ | |
46 | - "string" | |
47 | - ], | |
48 | - "createRules": { | |
49 | - "additionalProp1": { | |
50 | - "condition": { | |
51 | - "condition": [ | |
52 | - { | |
53 | - "key": { | |
54 | - "type": "TIME_SERIES", | |
55 | - "key": "temp" | |
56 | - }, | |
57 | - "valueType": "NUMERIC", | |
58 | - "value": {}, | |
59 | - "predicate": {} | |
60 | - } | |
61 | - ], | |
62 | - "spec": {} | |
63 | - }, | |
64 | - "schedule": { | |
65 | - "type": "ANY_TIME" | |
66 | - }, | |
67 | - "alarmDetails": "string", | |
68 | - "dashboardId": { | |
69 | - "id": "784f394c-42b6-435a-983c-b7beff2784f9", | |
70 | - "entityType": "DASHBOARD" | |
71 | - } | |
72 | - }, | |
73 | - "additionalProp2": { | |
74 | - "condition": { | |
75 | - "condition": [ | |
76 | - { | |
77 | - "key": { | |
78 | - "type": "TIME_SERIES", | |
79 | - "key": "temp" | |
80 | - }, | |
81 | - "valueType": "NUMERIC", | |
82 | - "value": {}, | |
83 | - "predicate": {} | |
84 | - } | |
85 | - ], | |
86 | - "spec": {} | |
87 | - }, | |
88 | - "schedule": { | |
89 | - "type": "ANY_TIME" | |
90 | - }, | |
91 | - "alarmDetails": "string", | |
92 | - "dashboardId": { | |
93 | - "id": "784f394c-42b6-435a-983c-b7beff2784f9", | |
94 | - "entityType": "DASHBOARD" | |
95 | - } | |
96 | - }, | |
97 | - "additionalProp3": { | |
98 | - "condition": { | |
99 | - "condition": [ | |
100 | - { | |
101 | - "key": { | |
102 | - "type": "TIME_SERIES", | |
103 | - "key": "temp" | |
104 | - }, | |
105 | - "valueType": "NUMERIC", | |
106 | - "value": {}, | |
107 | - "predicate": {} | |
108 | - } | |
109 | - ], | |
110 | - "spec": {} | |
111 | - }, | |
112 | - "schedule": { | |
113 | - "type": "ANY_TIME" | |
114 | - }, | |
115 | - "alarmDetails": "string", | |
116 | - "dashboardId": { | |
117 | - "id": "784f394c-42b6-435a-983c-b7beff2784f9", | |
118 | - "entityType": "DASHBOARD" | |
119 | - } | |
120 | - } | |
121 | - }, | |
122 | - "clearRule": { | |
123 | - "condition": { | |
124 | - "condition": [ | |
125 | - { | |
126 | - "key": { | |
127 | - "type": "TIME_SERIES", | |
128 | - "key": "temp" | |
129 | - }, | |
130 | - "valueType": "NUMERIC", | |
131 | - "value": {}, | |
132 | - "predicate": {} | |
133 | - } | |
134 | - ], | |
135 | - "spec": {} | |
136 | - }, | |
137 | - "schedule": { | |
138 | - "type": "ANY_TIME" | |
139 | - }, | |
140 | - "alarmDetails": "string", | |
141 | - "dashboardId": { | |
142 | - "id": "784f394c-42b6-435a-983c-b7beff2784f9", | |
143 | - "entityType": "DASHBOARD" | |
144 | - } | |
145 | - } | |
146 | - } | |
147 | - ] | |
3 | + "configuration": { | |
4 | + "maxDevices": "1", | |
5 | + "maxAssets": "1", | |
6 | + "maxCustomers": "1", | |
7 | + "maxUsers": "1", | |
8 | + "maxDashboards": "1", | |
9 | + "maxRuleChains": "1", | |
10 | + "maxResourcesInBytes": "1", | |
11 | + "maxOtaPackagesInBytes": "1", | |
12 | + "maxTransportMessages": "1", | |
13 | + "maxTransportDataPoints": "1", | |
14 | + "maxREExecutions": "1", | |
15 | + "maxJSExecutions": "1", | |
16 | + "maxDPStorageDays": "1", | |
17 | + "defaultStorageTtlDays": "1", | |
18 | + "alarmsTtlDays": "1", | |
19 | + "rpcTtlDays": "1", | |
20 | + "maxRuleNodeExecutionsPerMessage": "1", | |
21 | + "maxEmails": "1", | |
22 | + "maxSms": "1", | |
23 | + "maxCreatedAlarms": "1", | |
24 | + "transportTenantMsgRateLimit": "1", | |
25 | + "transportTenantTelemetryMsgRateLimit": "1", | |
26 | + "transportTenantTelemetryDataPointsRateLimit": "1", | |
27 | + "transportDeviceMsgRateLimit": "1", | |
28 | + "transportDeviceTelemetryMsgRateLimit": "1", | |
29 | + "transportDeviceTelemetryDataPointsRateLimit": "1" | |
30 | + } | |
148 | 31 | }, |
149 | - "roleIds": [ | |
150 | - "string" | |
151 | - ], | |
152 | - "tbProfileId": "string", | |
153 | - "tenantExpireTime": "2021-12-20T08:19:59.511Z", | |
154 | - "tenantId": "string", | |
155 | - "tenantStatus": "DISABLED", | |
156 | - "transportType": "COAP", | |
157 | - "updateTime": "2021-12-20T08:19:59.511Z", | |
158 | - "updater": "string" | |
32 | + "name": "1", | |
33 | + "isolatedTbRuleEngine": true, | |
34 | + "description": "1" | |
159 | 35 | } | ... | ... |
1 | 1 | { |
2 | - "name": "设备配置1", | |
3 | - "description": "设备配置1", | |
4 | - "transportType": "COAP", | |
2 | + "name": "租户配置测试1", | |
3 | + "isolatedTbCore": true, | |
4 | + "isolatedTbRuleEngine": null, | |
5 | 5 | "profileData": { |
6 | - "alarms": [ | |
7 | - { | |
8 | - "alarmType": "设备配置1", | |
9 | - "propagate": true, | |
10 | - "propagateRelationTypes": [ | |
11 | - "设备配置1" | |
12 | - ], | |
13 | - "createRules": { | |
14 | - "WARNING": { | |
15 | - "alarmDetails": "设备配置1", | |
16 | - "schedule": { | |
17 | - "type": "SPECIFIC_TIME" | |
18 | - }, | |
19 | - "spec": { | |
20 | - "spec": "HOURS" | |
21 | - }, | |
22 | - "condition": { | |
23 | - "condition": [ | |
24 | - { | |
25 | - "key": { | |
26 | - "type": "TIME_SERIES", | |
27 | - "key": "TIME_SERIES" | |
28 | - }, | |
29 | - "valueType": "CURRENT_DEVICE", | |
30 | - "value": { | |
31 | - "value": "设备配置1" | |
32 | - }, | |
33 | - "predicate": { | |
34 | - "predicate": "设备配置1" | |
35 | - } | |
36 | - } | |
37 | - ] | |
38 | - } | |
39 | - } | |
40 | - } | |
41 | - } | |
42 | - ] | |
6 | + "configuration": { | |
7 | + "maxDevices": 1, | |
8 | + "maxAssets": 1, | |
9 | + "maxCustomers": 1, | |
10 | + "maxUsers": 1, | |
11 | + "maxDashboards": 1, | |
12 | + "maxRuleChains": 1, | |
13 | + "maxResourcesInBytes": 1, | |
14 | + "maxOtaPackagesInBytes": 1, | |
15 | + "transportTenantMsgRateLimit": "1", | |
16 | + "transportTenantTelemetryMsgRateLimit": "1", | |
17 | + "transportTenantTelemetryDataPointsRateLimit": "1", | |
18 | + "transportDeviceMsgRateLimit": "当前客户", | |
19 | + "transportDeviceTelemetryMsgRateLimit": "1", | |
20 | + "transportDeviceTelemetryDataPointsRateLimit": "d", | |
21 | + "maxTransportMessages": 1, | |
22 | + "maxTransportDataPoints": 1, | |
23 | + "maxREExecutions": 1, | |
24 | + "maxJSExecutions": 1, | |
25 | + "maxDPStorageDays": 1, | |
26 | + "maxRuleNodeExecutionsPerMessage": 1, | |
27 | + "maxEmails": 1, | |
28 | + "maxSms": 1, | |
29 | + "maxCreatedAlarms": 1, | |
30 | + "defaultStorageTtlDays": 1, | |
31 | + "alarmsTtlDays": 1, | |
32 | + "rpcTtlDays": 1, | |
33 | + "type": "DEFAULT" | |
34 | + } | |
43 | 35 | }, |
44 | - "alarmProfile": { | |
45 | - "alarmContactId": "ce350734-9504-48c2-82d2-277e3fe5583f", | |
46 | - "messageMode": "PHONE_MESSAGE" | |
47 | - } | |
36 | + "description": "1" | |
48 | 37 | } | ... | ... |
src/views/device/profile/step/cpns/3.json
deleted
100644 → 0
1 | -{ | |
2 | - "name": "设备配置", | |
3 | - "description": "设备配置", | |
4 | - "transportType": "COAP", | |
5 | - "profileData": { | |
6 | - "alarms": [ | |
7 | - { | |
8 | - "alarmType": "设备配置", | |
9 | - "propagate": true, | |
10 | - "propagateRelationTypes": [ | |
11 | - "设备配置" | |
12 | - ], | |
13 | - "createRules": { | |
14 | - "MINOR": { | |
15 | - "schedule": { | |
16 | - "type": "SPECIFIC_TIME" | |
17 | - } | |
18 | - } | |
19 | - } | |
20 | - } | |
21 | - ] | |
22 | - }, | |
23 | - "alarmProfile": { | |
24 | - "alarmContactId": "ce350734-9504-48c2-82d2-277e3fe5583f", | |
25 | - "messageMode": "DING_TALK_MESSAGE" | |
26 | - } | |
27 | -} |
1 | 1 | import { FormSchema, BasicColumn } from '/@/components/Table'; |
2 | +import { DescItem } from '/@/components/Description/index'; | |
2 | 3 | |
3 | 4 | /** |
4 | 5 | * 所使用的枚举值 |
... | ... | @@ -8,7 +9,15 @@ export enum TriggerEnum { |
8 | 9 | IS_DEVICE_ACT = '', |
9 | 10 | IS_TIME_ACT = 'TIME_SERIES', |
10 | 11 | IS_SCENE_ACT = 'CONSTANT', |
12 | + IS_CURRENT_CUSTOMER = 'CURRENT_CUSTOMER', | |
13 | + IS_CURRENT_DEVICE = 'CURRENT_DEVICE', | |
11 | 14 | } |
15 | +export const isCurrentCus = (type: string) => { | |
16 | + return type === TriggerEnum.IS_CURRENT_CUSTOMER; | |
17 | +}; | |
18 | +export const isCurrentDev = (type: string) => { | |
19 | + return type === TriggerEnum.IS_CURRENT_DEVICE; | |
20 | +}; | |
12 | 21 | |
13 | 22 | export const isShiDu = (type: string) => { |
14 | 23 | return type === TriggerEnum.IS_DEVICE_ACT; |
... | ... | @@ -29,14 +38,37 @@ export const columns: BasicColumn[] = [ |
29 | 38 | }, |
30 | 39 | { |
31 | 40 | title: '键类型', |
32 | - dataIndex: 'value', | |
41 | + dataIndex: 'type', | |
42 | + width: 200, | |
43 | + }, | |
44 | +]; | |
45 | +export const columnsView: BasicColumn[] = [ | |
46 | + { | |
47 | + title: '键名', | |
48 | + dataIndex: 'key', | |
49 | + width: 200, | |
50 | + }, | |
51 | + { | |
52 | + title: '键类型', | |
53 | + dataIndex: 'type', | |
33 | 54 | width: 200, |
34 | 55 | }, |
35 | 56 | ]; |
36 | 57 | |
37 | -export const formSchema: FormSchema[] = [ | |
58 | +export const DescDetailSchema: DescItem[] = [ | |
59 | + { | |
60 | + field: 'key', | |
61 | + label: '键名', | |
62 | + }, | |
38 | 63 | { |
39 | 64 | field: 'type', |
65 | + label: '键类型', | |
66 | + }, | |
67 | +]; | |
68 | + | |
69 | +export const formSchema: FormSchema[] = [ | |
70 | + { | |
71 | + field: 'type1', | |
40 | 72 | label: '条件类型', |
41 | 73 | colProps: { span: 24 }, |
42 | 74 | component: 'Select', |
... | ... | @@ -50,23 +82,23 @@ export const formSchema: FormSchema[] = [ |
50 | 82 | }, |
51 | 83 | }, |
52 | 84 | { |
53 | - field: 'valueType', | |
85 | + field: 'valueType1', | |
54 | 86 | label: '动态源类型', |
55 | 87 | colProps: { span: 24 }, |
56 | 88 | component: 'Select', |
57 | 89 | componentProps: { |
58 | 90 | placeholder: '请选择动态源类型', |
59 | 91 | options: [ |
60 | - { label: '无动态值', value: '' }, | |
61 | - { label: '当前租户', value: 'CURRENT_CUSTOMER' }, | |
62 | - { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
63 | - { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
92 | + { label: '无动态值', value: 'STRING' }, | |
93 | + { label: '当前租户', value: 'NUMERIC' }, | |
94 | + { label: '当前客户', value: 'BOOLEAN' }, | |
95 | + { label: '当前设备', value: 'NUMERIC' }, | |
64 | 96 | ], |
65 | 97 | }, |
66 | 98 | ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), |
67 | 99 | }, |
68 | 100 | { |
69 | - field: 'value', | |
101 | + field: 'value1', | |
70 | 102 | label: '源属性', |
71 | 103 | colProps: { span: 24 }, |
72 | 104 | component: 'Input', |
... | ... | @@ -76,23 +108,23 @@ export const formSchema: FormSchema[] = [ |
76 | 108 | ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), |
77 | 109 | }, |
78 | 110 | { |
79 | - field: 'valueType', | |
111 | + field: 'valueType1', | |
80 | 112 | label: '动态源类型', |
81 | 113 | colProps: { span: 24 }, |
82 | 114 | component: 'Select', |
83 | 115 | componentProps: { |
84 | 116 | placeholder: '请选择动态源类型', |
85 | 117 | options: [ |
86 | - { label: '无动态值', value: '' }, | |
87 | - { label: '当前租户', value: 'CURRENT_TENANT' }, | |
88 | - { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
89 | - { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
118 | + { label: '无动态值', value: 'BOOLEAN' }, | |
119 | + { label: '当前租户', value: 'STRING' }, | |
120 | + { label: '当前客户', value: 'NUMERIC' }, | |
121 | + { label: '当前设备', value: 'COMPLEX' }, | |
90 | 122 | ], |
91 | 123 | }, |
92 | 124 | ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), |
93 | 125 | }, |
94 | 126 | { |
95 | - field: 'value', | |
127 | + field: 'value1', | |
96 | 128 | label: '源属性', |
97 | 129 | colProps: { span: 24 }, |
98 | 130 | component: 'Input', |
... | ... | @@ -102,7 +134,7 @@ export const formSchema: FormSchema[] = [ |
102 | 134 | ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), |
103 | 135 | }, |
104 | 136 | { |
105 | - field: 'predicate', | |
137 | + field: 'predicate1', | |
106 | 138 | label: '持续时间值', |
107 | 139 | colProps: { span: 24 }, |
108 | 140 | component: 'Input', |
... | ... | @@ -112,7 +144,7 @@ export const formSchema: FormSchema[] = [ |
112 | 144 | ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), |
113 | 145 | }, |
114 | 146 | { |
115 | - field: 'spec', | |
147 | + field: 'spec1', | |
116 | 148 | label: '时间单位', |
117 | 149 | colProps: { span: 24 }, |
118 | 150 | component: 'Select', |
... | ... | @@ -138,4 +170,13 @@ export const formSchema: FormSchema[] = [ |
138 | 170 | rules: [{ message: '事件计数应在1到2147483637之间', trigger: 'blur' }], |
139 | 171 | ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), |
140 | 172 | }, |
173 | + { | |
174 | + field: '', | |
175 | + label: '', | |
176 | + component: 'Checkbox', | |
177 | + renderComponentContent: 'Inherit from owner', | |
178 | + ifShow: ({ values }) => | |
179 | + isCurrentCus(Reflect.get(values, 'valueType')) || | |
180 | + isCurrentDev(Reflect.get(values, 'valueType')), | |
181 | + }, | |
141 | 182 | ]; | ... | ... |
... | ... | @@ -5,9 +5,9 @@ import { FormSchema } from '/@/components/Table'; |
5 | 5 | */ |
6 | 6 | |
7 | 7 | export enum TriggerEnum { |
8 | - IS_DEVICE_ACT = '1', | |
9 | - IS_TIME_ACT = '2', | |
10 | - IS_SCENE_ACT = '3', | |
8 | + IS_DEVICE_ACT = '属性', | |
9 | + IS_TIME_ACT = 'TIME_SERIES', | |
10 | + IS_SCENE_ACT = '常量', | |
11 | 11 | } |
12 | 12 | |
13 | 13 | export const isShiDu = (type: string) => { |
... | ... | @@ -23,73 +23,73 @@ export const isTimeAll = (type: string) => { |
23 | 23 | |
24 | 24 | export const formSchema: FormSchema[] = [ |
25 | 25 | { |
26 | - field: 'default', | |
26 | + field: 'type', | |
27 | 27 | label: '键类型', |
28 | 28 | colProps: { span: 24 }, |
29 | 29 | component: 'Select', |
30 | 30 | componentProps: { |
31 | 31 | placeholder: '请选择键类型', |
32 | 32 | options: [ |
33 | - { label: '属性', value: '1' }, | |
34 | - { label: 'Timeseries', value: '2' }, | |
35 | - { label: '常量', value: '3' }, | |
33 | + { label: '属性', value: '属性' }, | |
34 | + { label: 'Timeseries', value: 'TIME_SERIES' }, | |
35 | + { label: '常量', value: '常量' }, | |
36 | 36 | ], |
37 | 37 | }, |
38 | 38 | }, |
39 | 39 | { |
40 | - field: '2', | |
40 | + field: 'key', | |
41 | 41 | label: '键名', |
42 | 42 | colProps: { span: 24 }, |
43 | 43 | component: 'Select', |
44 | 44 | componentProps: { |
45 | 45 | placeholder: '请选择键名', |
46 | 46 | options: [ |
47 | - { label: 'active', value: '' }, | |
48 | - { label: 'inactivityAlarmTime', value: '' }, | |
49 | - { label: 'lastActivityTime', value: '' }, | |
50 | - { label: 'lastConnectTime', value: '' }, | |
51 | - { label: 'lastDisconnectTime', value: '' }, | |
47 | + { label: 'active', value: 'active' }, | |
48 | + { label: 'inactivityAlarmTime', value: 'inactivityAlarmTime' }, | |
49 | + { label: 'lastActivityTime', value: 'lastActivityTime' }, | |
50 | + { label: 'lastConnectTime', value: 'lastConnectTime' }, | |
51 | + { label: 'lastDisconnectTime', value: 'lastDisconnectTime' }, | |
52 | 52 | ], |
53 | 53 | }, |
54 | - ifShow: ({ values }) => isShiDu(Reflect.get(values, 'default')), | |
54 | + ifShow: ({ values }) => isShiDu(Reflect.get(values, 'type')), | |
55 | 55 | }, |
56 | 56 | { |
57 | - field: '21', | |
57 | + field: 'key', | |
58 | 58 | label: '键名', |
59 | 59 | colProps: { span: 24 }, |
60 | 60 | component: 'Select', |
61 | 61 | componentProps: { |
62 | 62 | placeholder: '请选择键名', |
63 | 63 | options: [ |
64 | - { label: 'CO2', value: '' }, | |
65 | - { label: 'temp', value: '' }, | |
66 | - { label: 'temp', value: '' }, | |
64 | + { label: 'CO2', value: 'CO2' }, | |
65 | + { label: 'temp', value: 'temp' }, | |
66 | + { label: 'wet', value: 'wet' }, | |
67 | 67 | ], |
68 | 68 | }, |
69 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'default')), | |
69 | + ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), | |
70 | 70 | }, |
71 | 71 | { |
72 | - field: '22', | |
72 | + field: 'key', | |
73 | 73 | label: '键名', |
74 | 74 | colProps: { span: 24 }, |
75 | 75 | component: 'Input', |
76 | 76 | componentProps: { |
77 | 77 | placeholder: '请输入键名', |
78 | 78 | }, |
79 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'default')), | |
79 | + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
80 | 80 | }, |
81 | 81 | { |
82 | - field: '3', | |
82 | + field: 'valueType', | |
83 | 83 | label: '值类型', |
84 | 84 | colProps: { span: 24 }, |
85 | 85 | component: 'Select', |
86 | 86 | componentProps: { |
87 | 87 | placeholder: '请选择值类型', |
88 | 88 | options: [ |
89 | - { label: '字符串', value: '' }, | |
90 | - { label: '数字', value: '' }, | |
91 | - { label: '布尔值', value: '' }, | |
92 | - { label: '日期时间', value: '' }, | |
89 | + { label: '字符串', value: 'STRING' }, | |
90 | + { label: '数字', value: 'NUMERIC' }, | |
91 | + { label: '布尔值', value: 'BOOLEAN' }, | |
92 | + { label: '日期时间', value: 'COMPLEX' }, | |
93 | 93 | ], |
94 | 94 | }, |
95 | 95 | }, | ... | ... |
... | ... | @@ -15,28 +15,37 @@ |
15 | 15 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
16 | 16 | import { BasicForm, useForm } from '/@/components/Form'; |
17 | 17 | import { formSchema } from './config'; |
18 | - // import { useMessage } from '/@/hooks/web/useMessage'; | |
19 | 18 | |
20 | 19 | export default defineComponent({ |
21 | 20 | name: 'index', |
22 | 21 | components: { BasicModal, BasicForm }, |
23 | 22 | emits: ['success', 'register'], |
24 | - setup() { | |
25 | - // const { createMessage } = useMessage(); | |
23 | + setup(_, { emit }) { | |
26 | 24 | const isUpdate = ref(true); |
25 | + const getValue: any = ref(null); | |
27 | 26 | const getTitle = computed(() => (!unref(isUpdate) ? '新增键名筛选器' : '编辑键名筛选器')); |
28 | - const [register] = useModalInner((data) => { | |
29 | - isUpdate.value = !!data?.isUpdate; | |
30 | - }); | |
31 | - const [registerForm] = useForm({ | |
27 | + const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ | |
32 | 28 | labelWidth: 120, |
33 | 29 | schemas: formSchema, |
34 | 30 | }); |
31 | + const [register, { closeModal }] = useModalInner(async (data) => { | |
32 | + isUpdate.value = !!data?.isUpdate; | |
33 | + if (unref(isUpdate)) { | |
34 | + await setFieldsValue({ | |
35 | + ...data.record, | |
36 | + }); | |
37 | + } else { | |
38 | + await resetFields(); | |
39 | + } | |
40 | + }); | |
41 | + | |
35 | 42 | const handleSubmit = () => { |
36 | - console.log(1); | |
43 | + getValue.value = getFieldsValue(); | |
44 | + emit('success', getValue.value); | |
45 | + closeModal(); | |
37 | 46 | }; |
38 | 47 | const handleCancel = () => { |
39 | - console.log(1); | |
48 | + return; | |
40 | 49 | }; |
41 | 50 | return { |
42 | 51 | registerForm, | ... | ... |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | @ok="handleSubmit" |
8 | 8 | > |
9 | 9 | <CollapseContainer title="键名筛选器" class="border mb-8"> |
10 | - <BasicTable @register="registerTable"> | |
10 | + <BasicTable :resizeHeightOffset="200" @register="registerTable" :dataSource="getTableApiData"> | |
11 | 11 | <template #toolbar> |
12 | 12 | <a-button type="primary" @click="handleAddKey"> 新增键名筛选器 </a-button> |
13 | 13 | </template> |
... | ... | @@ -33,18 +33,20 @@ |
33 | 33 | </template> |
34 | 34 | </BasicTable> |
35 | 35 | </CollapseContainer> |
36 | - <CollapseContainer title="筛选器预览" class="border mb-8"><div>1</div> </CollapseContainer> | |
36 | + <CollapseContainer title="筛选器预览" class="border mb-8"> | |
37 | + <BasicTable :resizeHeightOffset="200" :columns="columnsView" :dataSource="detailData" /> | |
38 | + </CollapseContainer> | |
37 | 39 | <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> |
38 | 40 | </BasicModal> |
39 | - <KeyValueModal @register="registerModal" /> | |
41 | + <KeyValueModal @register="registerModal" @success="handleSuccess" /> | |
40 | 42 | </template> |
41 | 43 | <script lang="ts"> |
42 | - import { defineComponent, ref, computed, unref } from 'vue'; | |
44 | + import { defineComponent, ref, computed, unref, onMounted } from 'vue'; | |
43 | 45 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
44 | 46 | import { BasicForm, useForm } from '/@/components/Form'; |
45 | - import { formSchema, columns } from './config'; | |
47 | + import { formSchema, columns, DescDetailSchema, columnsView } from './config'; | |
46 | 48 | import { CollapseContainer } from '/@/components/Container/index'; |
47 | - import { BasicTable, useTable } from '/@/components/Table'; | |
49 | + import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |
48 | 50 | import { useModal } from '/@/components/Modal'; |
49 | 51 | import KeyValueModal from './cpns/index.vue'; |
50 | 52 | |
... | ... | @@ -56,23 +58,25 @@ |
56 | 58 | BasicForm, |
57 | 59 | CollapseContainer, |
58 | 60 | BasicTable, |
61 | + TableAction, | |
59 | 62 | }, |
60 | 63 | emits: ['success', 'register', 'getAllFieldsRule'], |
61 | 64 | setup(_, { emit }) { |
65 | + const getTableApiData: any = ref([]); | |
66 | + const detailData: any = ref([]); | |
67 | + const receiveData: any = ref(null); | |
62 | 68 | const isUpdate = ref(true); |
63 | 69 | const [registerForm, { getFieldsValue }] = useForm({ |
64 | 70 | labelWidth: 120, |
65 | 71 | schemas: formSchema, |
66 | 72 | }); |
67 | 73 | const [registerModal, { openModal }] = useModal(); |
68 | - | |
69 | 74 | const getTitle = computed(() => (!unref(isUpdate) ? '添加报警规则条件' : '编辑报警规则条件')); |
70 | 75 | const [register, { closeModal }] = useModalInner((data) => { |
71 | 76 | isUpdate.value = !!data?.isUpdate; |
72 | 77 | }); |
73 | - const [registerTable] = useTable({ | |
78 | + const [registerTable, { reload }] = useTable({ | |
74 | 79 | title: '键名筛选器', |
75 | - // api: deviceConfigGetQuery, | |
76 | 80 | columns, |
77 | 81 | bordered: true, |
78 | 82 | showIndexColumn: false, |
... | ... | @@ -83,9 +87,16 @@ |
83 | 87 | slots: { customRender: 'action' }, |
84 | 88 | }, |
85 | 89 | }); |
90 | + | |
86 | 91 | const handleSubmit = () => { |
87 | - const values = getFieldsValue(); | |
88 | - emit('getAllFieldsRule', values); | |
92 | + if (unref(isUpdate.value)) { | |
93 | + console.log(1); | |
94 | + const values = getFieldsValue(); | |
95 | + getTableApiData.value.push(values); | |
96 | + detailData.value.push(values); | |
97 | + } | |
98 | + // const values = getFieldsValue(); | |
99 | + emit('getAllFieldsRule', receiveData.value); | |
89 | 100 | closeModal(); |
90 | 101 | }; |
91 | 102 | const handleAddKey = () => { |
... | ... | @@ -93,15 +104,38 @@ |
93 | 104 | isUpdate: false, |
94 | 105 | }); |
95 | 106 | }; |
96 | - const handleEdit = () => { | |
107 | + const handleEdit = (record: Recordable) => { | |
97 | 108 | openModal(true, { |
98 | 109 | isUpdate: true, |
110 | + record, | |
99 | 111 | }); |
100 | 112 | }; |
101 | - const handleDelete = () => { | |
102 | - console.log(1); | |
113 | + const handleDelete = (record: Recordable) => { | |
114 | + console.log(record); | |
115 | + getTableApiData.value.splice(0, 1); | |
116 | + detailData.value.splice(0, 1); | |
117 | + reload(); | |
103 | 118 | }; |
119 | + const handleSuccess = (v) => { | |
120 | + receiveData.value = v; | |
121 | + console.log(receiveData.value); | |
122 | + setTimeout(() => { | |
123 | + doFunc(); | |
124 | + }, 10); | |
125 | + }; | |
126 | + const doFunc = () => { | |
127 | + getTableApiData.value.push(receiveData.value); | |
128 | + detailData.value.push(receiveData.value); | |
129 | + }; | |
130 | + onMounted(() => { | |
131 | + console.log(1); | |
132 | + }); | |
104 | 133 | return { |
134 | + columnsView, | |
135 | + DescDetailSchema, | |
136 | + detailData, | |
137 | + getTableApiData, | |
138 | + handleSuccess, | |
105 | 139 | handleEdit, |
106 | 140 | handleDelete, |
107 | 141 | registerModal, | ... | ... |
... | ... | @@ -21,10 +21,21 @@ export const step1Schemas: FormSchema[] = [ |
21 | 21 | label: '请选择规则链', |
22 | 22 | component: 'ApiSelect', |
23 | 23 | componentProps: { |
24 | + // api: async () => { | |
25 | + // const data = await deviceConfigGetRuleChain(); | |
26 | + // const returnData = data.map((m) => { | |
27 | + // return { | |
28 | + // labelField: m.name, | |
29 | + // valueField: m.id.id, | |
30 | + // }; | |
31 | + // }); | |
32 | + // console.log(returnData); | |
33 | + // return returnData; | |
34 | + // }, | |
24 | 35 | api: deviceConfigGetRuleChain, |
25 | 36 | labelField: 'name', |
26 | - valueField: 'type', | |
27 | - resultField: '', | |
37 | + valueField: '', | |
38 | + // resultField: '', | |
28 | 39 | }, |
29 | 40 | }, |
30 | 41 | // { | ... | ... |
... | ... | @@ -3,6 +3,18 @@ import { numberRule } from '/@/utils/rules'; |
3 | 3 | |
4 | 4 | export const formSchema: FormSchema[] = [ |
5 | 5 | { |
6 | + required: true, | |
7 | + field: 'type', | |
8 | + label: '类型', | |
9 | + component: 'Select', | |
10 | + colProps: { span: 24 }, | |
11 | + componentProps: { | |
12 | + placeholder: '请选择类型', | |
13 | + options: [{ label: '默认', value: 'DEFAULT' }], | |
14 | + }, | |
15 | + rules: numberRule, | |
16 | + }, | |
17 | + { | |
6 | 18 | field: 'maxDevices', |
7 | 19 | label: '最大设备数(0-无限制)', |
8 | 20 | component: 'Input', | ... | ... |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | > |
8 | 8 | <template #toolbar> |
9 | 9 | <a-button type="primary" @click="handleAdd"> 新增租户配置 </a-button> |
10 | - <a-button type="error" @click="handleToolbarDel"> 删除 </a-button> | |
10 | + <!-- <a-button type="error" @click="handleToolbarDel"> 删除 </a-button> --> | |
11 | 11 | </template> |
12 | 12 | <template #action="{ record }"> |
13 | 13 | <TableAction |
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 | import TenantSettingDrawer from './useDrawer.vue'; |
45 | 45 | import { columns } from './config'; |
46 | 46 | import { useMessage } from '/@/hooks/web/useMessage'; |
47 | - import { getTableTenantProfileApi } from '/@/api/tenant/tenantApi'; | |
47 | + import { getTableTenantProfileApi, deleteTenantProfileApi } from '/@/api/tenant/tenantApi'; | |
48 | 48 | |
49 | 49 | export default defineComponent({ |
50 | 50 | name: 'Index', |
... | ... | @@ -96,9 +96,9 @@ |
96 | 96 | }); |
97 | 97 | echoEditData = record; |
98 | 98 | } |
99 | - async function handleDelete() { | |
100 | - // let ids = [record.id]; | |
101 | - // await screenLinkPageDeleteApi(ids); | |
99 | + async function handleDelete(record: Recordable) { | |
100 | + let ids = record.id; | |
101 | + await deleteTenantProfileApi(ids); | |
102 | 102 | createMessage.success('删除成功'); |
103 | 103 | reload(); |
104 | 104 | } | ... | ... |
... | ... | @@ -33,16 +33,25 @@ |
33 | 33 | let getValuesFormData: any = reactive({}); |
34 | 34 | const { proxy } = getCurrentInstance(); |
35 | 35 | const getChildData = ref(null); |
36 | - const [registerForm, { validateFields, getFieldsValue, resetFields }] = useForm({ | |
37 | - schemas: formSchema, | |
38 | - showActionButtonGroup: false, | |
39 | - }); | |
36 | + const editGetId: any = ref(''); | |
37 | + const [registerForm, { validateFields, getFieldsValue, resetFields, setFieldsValue }] = | |
38 | + useForm({ | |
39 | + schemas: formSchema, | |
40 | + showActionButtonGroup: false, | |
41 | + }); | |
40 | 42 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
41 | 43 | //清除表单值 |
42 | 44 | proxy.$refs.getChildData.funcResetFields(); |
43 | 45 | await resetFields(); |
44 | 46 | setDrawerProps({ confirmLoading: false }); |
45 | 47 | isUpdate.value = !!data?.isUpdate; |
48 | + //编辑 | |
49 | + if (unref(isUpdate)) { | |
50 | + editGetId.value = data.record.id; | |
51 | + await setFieldsValue({ | |
52 | + ...data.record, | |
53 | + }); | |
54 | + } | |
46 | 55 | }); |
47 | 56 | const getTitle = computed(() => (!unref(isUpdate) ? '新增租户配置' : '编辑租户配置')); |
48 | 57 | |
... | ... | @@ -66,6 +75,27 @@ |
66 | 75 | closeDrawer(); |
67 | 76 | emit('success'); |
68 | 77 | resetFields(); |
78 | + if (unref(isUpdate)) { | |
79 | + let res = validateFields(); | |
80 | + if (!res) return; | |
81 | + getValuesFormData = getFieldsValue(); | |
82 | + getValuesFormData.id = editGetId.value; | |
83 | + let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
84 | + let profileData1 = { | |
85 | + configuration: getChildValues, | |
86 | + }; | |
87 | + Object.assign( | |
88 | + postAllData, | |
89 | + { | |
90 | + profileData: profileData1, | |
91 | + }, | |
92 | + getValuesFormData | |
93 | + ); | |
94 | + await saveTenantProfileApi(postAllData); | |
95 | + createMessage.success('租户配置编辑成功'); | |
96 | + closeDrawer(); | |
97 | + emit('success'); | |
98 | + } | |
69 | 99 | } |
70 | 100 | return { |
71 | 101 | getChildData, | ... | ... |