Showing
21 changed files
with
462 additions
and
3595 deletions
... | ... | @@ -13,8 +13,6 @@ |
13 | 13 | <a-steps :current="current"> |
14 | 14 | <a-step title="设备配置" /> |
15 | 15 | <a-step title="传输配置" /> |
16 | - <a-step title="告警配置" /> | |
17 | - <a-step title="告警通知" /> | |
18 | 16 | </a-steps> |
19 | 17 | </div> |
20 | 18 | <div class="mt-5"> |
... | ... | @@ -25,29 +23,9 @@ |
25 | 23 | <!-- 设备配置 --> |
26 | 24 | <!-- 传输配置 --> |
27 | 25 | <div v-show="current === 1"> |
28 | - <DeviceProfileStep2 | |
29 | - ref="DeviceProfileStep2Ref" | |
30 | - @prev="handleStepPrev" | |
31 | - @next="handleStep2Next" | |
26 | + <DeviceProfileStep2 ref="DeviceProfileStep2Ref" @prev="handleStepPrev" | |
32 | 27 | /></div> |
33 | 28 | <!-- 传输配置 --> |
34 | - <!-- 告警配置 --> | |
35 | - <div v-show="current === 2"> | |
36 | - <DeviceProfileStep3 | |
37 | - ref="DeviceProfileStep3Ref" | |
38 | - @prev="handleStepPrev" | |
39 | - @next="handleStep3Next" | |
40 | - @redo="handleRedo" | |
41 | - :getAllStepThreeData="editData" | |
42 | - :isAddOrEdit="isStatus" | |
43 | - :isShowAddRule="isShowRule" | |
44 | - /></div> | |
45 | - <!-- 告警配置 --> | |
46 | - <!-- 告警通知 --> | |
47 | - <div v-show="current === 3"> | |
48 | - <DeviceProfileStep4 ref="DeviceProfileStep4Ref" @prev="handleStepPrev" /> | |
49 | - </div> | |
50 | - <!-- 告警通知 --> | |
51 | 29 | </div> |
52 | 30 | </BasicModal> |
53 | 31 | </div> |
... | ... | @@ -65,8 +43,6 @@ |
65 | 43 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
66 | 44 | import DeviceProfileStep1 from '/@/views/device/profiles/step/DeviceProfileStep1.vue'; |
67 | 45 | import DeviceProfileStep2 from '/@/views/device/profiles/step/DeviceProfileStep2.vue'; |
68 | - import DeviceProfileStep3 from '/@/views/device/profiles/step/DeviceProfileStep3.vue'; | |
69 | - import DeviceProfileStep4 from '/@/views/device/profiles/step/DeviceProfileStep4.vue'; | |
70 | 46 | import { Steps } from 'ant-design-vue'; |
71 | 47 | import { deviceConfigAddOrEdit, deviceConfigGetDetail } from '/@/api/device/deviceConfigApi'; |
72 | 48 | import { useMessage } from '/@/hooks/web/useMessage'; |
... | ... | @@ -77,56 +53,33 @@ |
77 | 53 | BasicModal, |
78 | 54 | DeviceProfileStep1, |
79 | 55 | DeviceProfileStep2, |
80 | - DeviceProfileStep3, | |
81 | - DeviceProfileStep4, | |
82 | 56 | [Steps.name]: Steps, |
83 | 57 | [Steps.Step.name]: Steps.Step, |
84 | 58 | }, |
85 | 59 | props: { |
86 | 60 | userData: { type: Object }, |
87 | 61 | }, |
88 | - emits: [ | |
89 | - 'success', | |
90 | - 'register', | |
91 | - 'handleStepPrev', | |
92 | - 'handleStep3Next', | |
93 | - 'handleRedo', | |
94 | - 'handleStep2Next', | |
95 | - ], | |
62 | + emits: ['success', 'register', 'handleStepPrev', 'handleStep3Next', 'handleRedo'], | |
96 | 63 | setup(_, { emit }) { |
97 | 64 | const { proxy } = getCurrentInstance() as any; |
98 | 65 | const DeviceProfileStep1Ref = ref(null); |
99 | 66 | const DeviceProfileStep2Ref = ref(null); |
100 | - const DeviceProfileStep3Ref = ref(null); | |
101 | - const DeviceProfileStep4Ref = ref(null); | |
102 | 67 | const { createMessage } = useMessage(); |
103 | - const postDeviceConfogData: any = ref({}); | |
68 | + let postDeviceConfogData: any = reactive({}); | |
104 | 69 | let getStepOneData: any = reactive({}); |
105 | 70 | let getStepTwoData: any = reactive({}); |
106 | 71 | const editData: any = ref({}); |
107 | - let getStepFourData: any = reactive({}); | |
108 | - const alarmProfileData = reactive({ | |
109 | - alarmProfile: { | |
110 | - alarmContactId: '', | |
111 | - messageMode: '', | |
112 | - }, | |
113 | - }); | |
114 | - let isGetStepThreeData: any = reactive({ | |
115 | - profileData: { | |
116 | - alarms: [], | |
117 | - }, | |
118 | - }); | |
119 | 72 | const postEditId = ref(''); |
120 | 73 | const current = ref(0); |
121 | 74 | const isUpdate = ref(0); |
122 | - const getAlarmContactId = ref(''); | |
123 | - const getMessageMode = ref(''); | |
124 | - const isStatus: any = ref(null); | |
125 | 75 | const isShowOkBtnFalse = ref(true); |
126 | - const isShowRule = ref(true); | |
127 | - const isEditAndChange = ref(true); | |
128 | - const isEchoEditStatus = ref(false); | |
129 | 76 | const isNextStatus = ref(false); |
77 | + let transportTypeObj = reactive({ | |
78 | + transportType: '', | |
79 | + }); | |
80 | + const profileDataObj = reactive({ | |
81 | + profileData: null, | |
82 | + }); | |
130 | 83 | |
131 | 84 | const getTitle = computed(() => |
132 | 85 | isUpdate.value == 1 ? '新增设备配置' : isUpdate.value == 2 ? '编辑设备配置' : '设备配置详情' |
... | ... | @@ -136,16 +89,11 @@ |
136 | 89 | isUpdate.value = data.isUpdate; |
137 | 90 | if (isUpdate.value == 1) { |
138 | 91 | handleCancel(); |
139 | - isShowRule.value = true; | |
140 | 92 | isShowOkBtnFalse.value = true; |
141 | 93 | current.value = 0; |
142 | - isStatus.value = !data.isUpdate; | |
143 | - isEchoEditStatus.value = false; | |
144 | 94 | } else if (isUpdate.value == 2) { |
145 | 95 | handleCancel(); |
146 | - isShowRule.value = true; | |
147 | 96 | isShowOkBtnFalse.value = true; |
148 | - isEchoEditStatus.value = true; | |
149 | 97 | current.value = 0; |
150 | 98 | postEditId.value = data.record.id; |
151 | 99 | editData.value = await deviceConfigGetDetail(postEditId.value); |
... | ... | @@ -158,7 +106,6 @@ |
158 | 106 | }); |
159 | 107 | } else if (isUpdate.value == 3) { |
160 | 108 | handleCancel(); |
161 | - isShowRule.value = false; | |
162 | 109 | isShowOkBtnFalse.value = false; |
163 | 110 | current.value = 0; |
164 | 111 | postEditId.value = data.record.id; |
... | ... | @@ -181,188 +128,64 @@ |
181 | 128 | if (isNextStatus.value) { |
182 | 129 | getStepOneData = { |
183 | 130 | ...v, |
184 | - ...{ icon: v1 }, | |
131 | + ...{ image: v1 }, | |
185 | 132 | }; |
186 | 133 | } |
187 | 134 | current.value++; |
188 | 135 | if (isUpdate.value == 2) { |
189 | - proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc({ | |
190 | - transportType: editData.value?.profileData.transportConfiguration.type, | |
191 | - }); | |
136 | + proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc( | |
137 | + editData.value?.profileData.transportConfiguration | |
138 | + ); | |
192 | 139 | } else if (isUpdate.value == 3) { |
193 | - proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc({ | |
194 | - transportType: editData.value?.profileData.transportConfiguration.type, | |
195 | - }); | |
140 | + proxy.$refs.DeviceProfileStep2Ref?.setStepTwoFieldsValueFunc( | |
141 | + editData.value?.profileData.transportConfiguration | |
142 | + ); | |
196 | 143 | } |
197 | 144 | } |
198 | - //第二步 | |
199 | - function handleStep2Next(v) { | |
200 | - isNextStatus.value = true; | |
201 | - if ((isNextStatus.value = true)) { | |
202 | - getStepTwoData = { | |
203 | - ...v, | |
145 | + const handleSubmit = async () => { | |
146 | + let getPic = null; | |
147 | + getStepTwoData = await proxy.$refs.DeviceProfileStep2Ref?.getStep2DataFunc(); | |
148 | + profileDataObj.profileData = getStepTwoData; | |
149 | + transportTypeObj.transportType = getStepTwoData.transportConfiguration.type; | |
150 | + //没有点击下一步 | |
151 | + if (!isNextStatus.value) { | |
152 | + const getStep1Obj = await proxy.$refs.DeviceProfileStep1Ref?.getStep1Func(); | |
153 | + getPic = getStep1Obj.icon; | |
154 | + getStepOneData = { | |
155 | + ...getStep1Obj.key, | |
156 | + ...{ image: getPic }, | |
204 | 157 | }; |
205 | 158 | } |
206 | - current.value++; | |
207 | - if (isUpdate.value == 2) { | |
208 | - try { | |
209 | - isEchoEditStatus.value = true; | |
210 | - proxy.$refs.DeviceProfileStep3Ref?.echoStep3DataFunc( | |
211 | - editData.value.profileData.alarms, | |
212 | - isEchoEditStatus.value | |
213 | - ); | |
214 | - } catch {} | |
215 | - } else if (isUpdate.value == 3) { | |
216 | - try { | |
217 | - isEchoEditStatus.value = true; | |
218 | - proxy.$refs.DeviceProfileStep3Ref?.echoStep3DataFunc( | |
219 | - editData.value.profileData.alarms, | |
220 | - isEchoEditStatus.value | |
221 | - ); | |
222 | - } catch {} | |
159 | + const id = isUpdate.value == 1 ? '' : postEditId.value; | |
160 | + postDeviceConfogData = { | |
161 | + ...getStepOneData, | |
162 | + ...profileDataObj, | |
163 | + ...transportTypeObj, | |
164 | + id, | |
165 | + }; | |
166 | + if (isUpdate.value == 1) { | |
167 | + delete postDeviceConfogData.id; | |
223 | 168 | } |
224 | - } | |
225 | - //第三步 | |
226 | - async function handleStep3Next(_, v1) { | |
227 | - try { | |
228 | - isNextStatus.value = true; | |
229 | - isEditAndChange.value = v1; | |
230 | - current.value++; | |
231 | - let step3NextVal = await proxy.$refs.DeviceProfileStep3Ref?.getStep3AllDataFunc( | |
232 | - isUpdate.value | |
233 | - ); | |
234 | - if (step3NextVal.length === 0) { | |
235 | - isGetStepThreeData.profileData.alarms = null; | |
236 | - } else { | |
237 | - isGetStepThreeData.profileData.alarms = step3NextVal; | |
238 | - } | |
239 | - proxy.$refs.DeviceProfileStep4Ref?.step3LinkStep4DefalutClose(); | |
240 | - if (isUpdate.value == 2) { | |
241 | - if ( | |
242 | - editData.value?.alarmProfile.messageMode !== null || | |
243 | - editData.value?.alarmProfile.alarmContactId !== null | |
244 | - ) { | |
245 | - proxy.$refs.DeviceProfileStep4Ref?.addStep4(); | |
246 | - } else { | |
247 | - proxy.$refs.DeviceProfileStep4Ref?.closeStep4(); | |
248 | - } | |
249 | - nextTick(() => { | |
250 | - proxy.$refs.DeviceProfileStep4Ref?.setAlaramContactAndNoticeMethodFunc({ | |
251 | - alarmContactId: editData.value?.alarmProfile.alarmContactId.split(','), | |
252 | - messageMode: editData.value?.alarmProfile.messageMode.split(','), | |
253 | - }); | |
254 | - }); | |
255 | - } else if (isUpdate.value == 3) { | |
256 | - if ( | |
257 | - editData.value?.alarmProfile.messageMode !== null || | |
258 | - editData.value?.alarmProfile.alarmContactId !== null | |
259 | - ) { | |
260 | - proxy.$refs.DeviceProfileStep4Ref?.addStep4(); | |
261 | - } else { | |
262 | - proxy.$refs.DeviceProfileStep4Ref?.closeStep4(); | |
263 | - } | |
264 | - nextTick(() => { | |
265 | - proxy.$refs.DeviceProfileStep4Ref?.setAlaramContactAndNoticeMethodFunc({ | |
266 | - alarmContactId: editData.value?.alarmProfile.alarmContactId.split(','), | |
267 | - messageMode: editData.value?.alarmProfile.messageMode.split(','), | |
268 | - }); | |
269 | - }); | |
270 | - } | |
271 | - } catch {} | |
272 | - } | |
273 | - const handleSubmit = async () => { | |
274 | - let getPic = null; | |
275 | - let getStep2Obj = proxy.$refs.DeviceProfileStep2Ref?.getStep2DataFunc(); | |
276 | - Object.assign(getStepTwoData, getStep2Obj); | |
277 | - try { | |
278 | - //没有点击下一步 | |
279 | - if (!isNextStatus.value) { | |
280 | - const getStep1Obj = await proxy.$refs.DeviceProfileStep1Ref?.getStep1Func(); | |
281 | - getPic = getStep1Obj.icon; | |
282 | - getStepOneData = { | |
283 | - ...getStep1Obj.key, | |
284 | - ...{ image: getPic }, | |
285 | - }; | |
286 | - Object.assign(getStepOneData, getStep1Obj.key); | |
287 | - } | |
288 | - let step3Val = await proxy.$refs.DeviceProfileStep3Ref?.getStep3AllDataFunc( | |
289 | - isUpdate.value | |
290 | - ); | |
291 | - if (step3Val.length === 0) { | |
292 | - isGetStepThreeData.profileData.alarms = null; | |
293 | - } else { | |
294 | - isGetStepThreeData.profileData.alarms = step3Val; | |
295 | - } | |
296 | - try { | |
297 | - getStepFourData = await proxy.$refs.DeviceProfileStep4Ref?.getAllFields(); | |
298 | - const getJoinAlarmContactIdData = getStepFourData.alarmContactId.join(','); | |
299 | - const getJoinMessageModeData = getStepFourData.messageMode.join(','); | |
300 | - getAlarmContactId.value = getJoinAlarmContactIdData; | |
301 | - getMessageMode.value = getJoinMessageModeData; | |
302 | - alarmProfileData.alarmProfile.alarmContactId = getAlarmContactId.value; | |
303 | - alarmProfileData.alarmProfile.messageMode = getMessageMode.value; | |
304 | - } catch {} | |
305 | - if (isUpdate.value == 1) { | |
306 | - Object.assign( | |
307 | - postDeviceConfogData.value, | |
308 | - getStepOneData, | |
309 | - getStepTwoData, | |
310 | - isGetStepThreeData, | |
311 | - alarmProfileData.alarmProfile.alarmContactId == '' ? null : alarmProfileData | |
312 | - ); | |
313 | - await deviceConfigAddOrEdit(postDeviceConfogData.value); | |
314 | - createMessage.success('新增成功'); | |
315 | - closeModal(); | |
316 | - emit('success'); | |
317 | - } else if (isUpdate.value == 2) { | |
318 | - const id = { | |
319 | - id: postEditId, | |
320 | - }; | |
321 | - Object.assign( | |
322 | - postDeviceConfogData.value, | |
323 | - getStepOneData, | |
324 | - getStepTwoData, | |
325 | - isGetStepThreeData, | |
326 | - id, | |
327 | - alarmProfileData.alarmProfile.alarmContactId == '' ? null : alarmProfileData | |
328 | - ); | |
329 | - console.log('==========', postDeviceConfogData.value); | |
330 | - // await deviceConfigAddOrEdit(postDeviceConfogData.value); | |
331 | - // createMessage.success('编辑成功'); | |
332 | - // closeModal(); | |
333 | - // emit('success'); | |
334 | - } | |
335 | - } catch {} | |
169 | + await deviceConfigAddOrEdit(postDeviceConfogData); | |
170 | + createMessage.success(isUpdate.value == 1 ? '新增' + '成功' : '编辑' + '成功'); | |
171 | + closeModal(); | |
172 | + emit('success'); | |
173 | + isNextStatus.value = false; | |
336 | 174 | }; |
337 | 175 | const handleCancel = () => { |
338 | - try { | |
339 | - nextTick(() => { | |
340 | - proxy.$refs.DeviceProfileStep1Ref?.customResetStepOneFunc(); | |
341 | - proxy.$refs.DeviceProfileStep1Ref?.resetIconFunc(); | |
342 | - proxy.$refs.DeviceProfileStep2Ref?.customClearStepTwoValueFunc(); | |
343 | - proxy.$refs.DeviceProfileStep3Ref?.clearStep3DataFunc(); | |
344 | - proxy.$refs.DeviceProfileStep4Ref?.clearAlaramContactAndNoticeMethodFunc(); | |
345 | - getStepOneData = {}; | |
346 | - getStepTwoData = {}; | |
347 | - isGetStepThreeData.profileData.alarms.length = 0; | |
348 | - alarmProfileData.alarmProfile.alarmContactId = ''; | |
349 | - alarmProfileData.alarmProfile.messageMode = ''; | |
350 | - }); | |
351 | - } catch {} | |
176 | + nextTick(() => { | |
177 | + proxy.$refs.DeviceProfileStep1Ref?.customResetStepOneFunc(); | |
178 | + proxy.$refs.DeviceProfileStep2Ref?.customClearStepTwoValueFunc(); | |
179 | + }); | |
352 | 180 | }; |
353 | 181 | function handleRedo() { |
354 | 182 | current.value = 0; |
355 | 183 | } |
356 | 184 | return { |
357 | - isShowRule, | |
358 | 185 | isShowOkBtnFalse, |
359 | - isStatus, | |
360 | 186 | DeviceProfileStep2Ref, |
361 | - DeviceProfileStep3Ref, | |
362 | - DeviceProfileStep4Ref, | |
363 | 187 | DeviceProfileStep1Ref, |
364 | 188 | editData, |
365 | - handleStep3Next, | |
366 | 189 | handleSubmit, |
367 | 190 | handleCancel, |
368 | 191 | register, |
... | ... | @@ -371,7 +194,6 @@ |
371 | 194 | current, |
372 | 195 | handleStepPrev, |
373 | 196 | handleStepNext1, |
374 | - handleStep2Next, | |
375 | 197 | handleRedo, |
376 | 198 | }; |
377 | 199 | }, | ... | ... |
... | ... | @@ -14,8 +14,8 @@ |
14 | 14 | :before-upload="beforeUploadqrcodePic" |
15 | 15 | > |
16 | 16 | <img |
17 | - v-if="peresonalPic || echoPic" | |
18 | - :src="peresonalPic != '' ? peresonalPic : echoPic" | |
17 | + v-if="peresonalPic" | |
18 | + :src="peresonalPic" | |
19 | 19 | alt="avatar" |
20 | 20 | style="width: 6.25rem; height: 6.25rem" |
21 | 21 | /> |
... | ... | @@ -54,8 +54,8 @@ |
54 | 54 | emits: ['next', 'resetFunc', 'register'], |
55 | 55 | setup(_, { emit }) { |
56 | 56 | const { createMessage } = useMessage(); |
57 | - const echoPic = ref(''); | |
58 | 57 | const peresonalPic = ref(''); |
58 | + | |
59 | 59 | const [register, { validate, setFieldsValue, resetFields }] = useForm({ |
60 | 60 | labelWidth: 100, |
61 | 61 | schemas: step1Schemas, |
... | ... | @@ -71,14 +71,7 @@ |
71 | 71 | //回显数据 |
72 | 72 | const setStepOneFieldsValueFunc = (v) => { |
73 | 73 | setFieldsValue(v); |
74 | - echoPic.value = v.image; | |
75 | - }; | |
76 | - const resetIconFunc = () => { | |
77 | - peresonalPic.value = ''; | |
78 | - echoPic.value = ''; | |
79 | - }; | |
80 | - const editIconFunc = (v) => { | |
81 | - peresonalPic.value = v; | |
74 | + peresonalPic.value = v.image; | |
82 | 75 | }; |
83 | 76 | const customUploadqrcodePic = async ({ file }) => { |
84 | 77 | if (beforeUploadqrcodePic(file)) { |
... | ... | @@ -90,7 +83,6 @@ |
90 | 83 | } |
91 | 84 | } |
92 | 85 | }; |
93 | - | |
94 | 86 | const beforeUploadqrcodePic = (file: FileItem) => { |
95 | 87 | const isJpgOrPng = |
96 | 88 | file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg'; |
... | ... | @@ -103,15 +95,15 @@ |
103 | 95 | } |
104 | 96 | return isJpgOrPng && isLt2M; |
105 | 97 | }; |
98 | + | |
106 | 99 | async function customSubmitFunc() { |
107 | - try { | |
108 | - const values = await validate(); | |
109 | - emit('next', values, peresonalPic.value); | |
110 | - } catch (error) {} | |
100 | + const values = await validate(); | |
101 | + emit('next', values, peresonalPic.value); | |
111 | 102 | } |
112 | 103 | //清空数据 |
113 | 104 | const customResetStepOneFunc = () => { |
114 | 105 | resetFields(); |
106 | + peresonalPic.value = ''; | |
115 | 107 | }; |
116 | 108 | const getStep1Func = async () => { |
117 | 109 | const valueStep1 = await validate(); |
... | ... | @@ -122,8 +114,6 @@ |
122 | 114 | }; |
123 | 115 | }; |
124 | 116 | return { |
125 | - editIconFunc, | |
126 | - resetIconFunc, | |
127 | 117 | register, |
128 | 118 | setStepOneFieldsValueFunc, |
129 | 119 | customResetStepOneFunc, |
... | ... | @@ -132,7 +122,6 @@ |
132 | 122 | beforeUploadqrcodePic, |
133 | 123 | customUploadqrcodePic, |
134 | 124 | getStep1Func, |
135 | - echoPic, | |
136 | 125 | }; |
137 | 126 | }, |
138 | 127 | }); | ... | ... |
1 | 1 | <template> |
2 | 2 | <div class="step2"> |
3 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register" /> | |
4 | - <div | |
5 | - style=" | |
6 | - display: flex; | |
7 | - width: 11vw; | |
8 | - height: 4vh; | |
9 | - flex-direction: row; | |
10 | - justify-content: space-between; | |
11 | - margin-left: 8vw; | |
12 | - margin-top: -4vh; | |
13 | - " | |
14 | - > | |
15 | - <div style="display: flex; width: 4vw; height: 4vh"> | |
16 | - <Button type="default" style="border-radius: 2px" class="mt-5" @click="customResetFunc" | |
17 | - >上一步</Button | |
3 | + <div class="step2-style"> | |
4 | + <div style="margin-top: 0.8vh; margin-left: 2.8vw; overflow: scroll"> | |
5 | + <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register" /> | |
6 | + <div | |
7 | + style=" | |
8 | + display: flex; | |
9 | + width: 11vw; | |
10 | + height: 8vh; | |
11 | + flex-direction: row; | |
12 | + justify-content: space-between; | |
13 | + margin-left: 17vw; | |
14 | + margin-top: -4vh; | |
15 | + " | |
18 | 16 | > |
19 | - </div> | |
20 | - <div style="display: flex; width: 4vw; height: 4vh"> | |
21 | - <Button type="default" class="mt-5" @click="customSubmitFunc"> 下一步</Button> | |
17 | + <div style="display: flex; width: 4vw; height: 4vh; margin-top: -2.35vh"> | |
18 | + <Button type="default" style="border-radius: 2px" class="mt-5" @click="customResetFunc" | |
19 | + >上一步</Button | |
20 | + > | |
21 | + </div> | |
22 | + </div> | |
22 | 23 | </div> |
23 | 24 | </div> |
24 | 25 | </div> |
25 | 26 | </template> |
26 | 27 | <script lang="ts"> |
27 | - import { defineComponent } from 'vue'; | |
28 | + import { defineComponent, reactive } from 'vue'; | |
28 | 29 | import { BasicForm, useForm } from '/@/components/Form'; |
29 | 30 | import { step2Schemas } from './data'; |
30 | 31 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; |
... | ... | @@ -41,7 +42,33 @@ |
41 | 42 | }, |
42 | 43 | emits: ['next', 'prev', 'register'], |
43 | 44 | setup(_, { emit }) { |
44 | - const [register, { getFieldsValue, validate, setFieldsValue, resetFields }] = useForm({ | |
45 | + const transportData: any = reactive({ | |
46 | + transportConfiguration: { | |
47 | + clientSettings: { | |
48 | + powerMode: null, | |
49 | + edrxCycle: null, | |
50 | + pagingTransmissionWindow: null, | |
51 | + psmActivityTimer: null, | |
52 | + }, | |
53 | + coapDeviceTypeConfiguration: { | |
54 | + coapDeviceType: null, | |
55 | + }, | |
56 | + deviceTelemetryTopic: null, | |
57 | + deviceAttributesTopic: null, | |
58 | + transportPayloadTypeConfiguration: { | |
59 | + transportPayloadType: null, | |
60 | + enableCompatibilityWithJsonPayloadFormat: false, | |
61 | + useJsonPayloadFormatForDefaultDownlinkTopics: false, | |
62 | + deviceAttributesProtoSchema: null, | |
63 | + deviceRpcRequestProtoSchema: null, | |
64 | + deviceRpcResponseProtoSchema: null, | |
65 | + deviceTelemetryProtoSchema: null, | |
66 | + }, | |
67 | + type: null, | |
68 | + }, | |
69 | + }); | |
70 | + | |
71 | + const [register, { validate, setFieldsValue, resetFields }] = useForm({ | |
45 | 72 | labelWidth: 80, |
46 | 73 | schemas: step2Schemas, |
47 | 74 | actionColOptions: { |
... | ... | @@ -49,7 +76,32 @@ |
49 | 76 | }, |
50 | 77 | }); |
51 | 78 | const setStepTwoFieldsValueFunc = (v) => { |
52 | - setFieldsValue(v); | |
79 | + console.log(v); | |
80 | + setFieldsValue({ | |
81 | + transportType: v?.type || v?.transportConfiguration.type, | |
82 | + transportPayloadType: | |
83 | + v?.transportPayloadTypeConfiguration?.transportPayloadType || | |
84 | + v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration?.transportPayloadType, | |
85 | + deviceTelemetryTopic: v?.deviceTelemetryTopic, | |
86 | + deviceAttributesTopic: v?.deviceAttributesTopic, | |
87 | + enableCompatibilityWithJsonPayloadFormat: | |
88 | + v?.transportPayloadTypeConfiguration?.enableCompatibilityWithJsonPayloadFormat, | |
89 | + useJsonPayloadFormatForDefaultDownlinkTopics: | |
90 | + v?.transportPayloadTypeConfiguration?.useJsonPayloadFormatForDefaultDownlinkTopics, | |
91 | + deviceAttributesProtoSchema: | |
92 | + v?.transportPayloadTypeConfiguration?.deviceAttributesProtoSchema, | |
93 | + deviceRpcRequestProtoSchema: | |
94 | + v?.transportPayloadTypeConfiguration?.deviceRpcRequestProtoSchema, | |
95 | + deviceRpcResponseProtoSchema: | |
96 | + v?.transportPayloadTypeConfiguration?.deviceRpcResponseProtoSchema, | |
97 | + deviceTelemetryProtoSchema: | |
98 | + v?.transportPayloadTypeConfiguration?.deviceTelemetryProtoSchema, | |
99 | + powerMode: v?.clientSettings?.powerMode, | |
100 | + edrxCycle: v?.clientSettings?.edrxCycle, | |
101 | + pagingTransmissionWindow: v?.clientSettings?.pagingTransmissionWindow, | |
102 | + psmActivityTimer: v?.clientSettings?.psmActivityTimer, | |
103 | + coapDeviceType: v?.coapDeviceTypeConfiguration?.coapDeviceType, | |
104 | + }); | |
53 | 105 | }; |
54 | 106 | const customClearStepTwoValueFunc = () => { |
55 | 107 | resetFields(); |
... | ... | @@ -57,23 +109,39 @@ |
57 | 109 | async function customResetFunc() { |
58 | 110 | emit('prev'); |
59 | 111 | } |
60 | - async function customSubmitFunc() { | |
61 | - try { | |
62 | - const values = await validate(); | |
63 | - emit('next', values); | |
64 | - } catch (error) { | |
65 | - console.log(error); | |
66 | - } finally { | |
67 | - } | |
68 | - } | |
69 | - | |
70 | - const getStep2DataFunc = () => { | |
71 | - const val = getFieldsValue(); | |
72 | - return val; | |
112 | + const getStep2DataFunc = async () => { | |
113 | + const val = await validate(); | |
114 | + if (!val) return; | |
115 | + transportData.transportConfiguration.deviceTelemetryTopic = val.deviceTelemetryTopic; | |
116 | + transportData.transportConfiguration.deviceAttributesTopic = val.deviceAttributesTopic; | |
117 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.transportPayloadType = | |
118 | + val.transportPayloadType; | |
119 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.enableCompatibilityWithJsonPayloadFormat = | |
120 | + val.enableCompatibilityWithJsonPayloadFormat; | |
121 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.useJsonPayloadFormatForDefaultDownlinkTopics = | |
122 | + val.useJsonPayloadFormatForDefaultDownlinkTopics; | |
123 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.enableCompatibilityWithJsonPayloadFormat = | |
124 | + val.enableCompatibilityWithJsonPayloadFormat; | |
125 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.deviceAttributesProtoSchema = | |
126 | + val.deviceAttributesProtoSchema; | |
127 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.deviceRpcRequestProtoSchema = | |
128 | + val.deviceRpcRequestProtoSchema; | |
129 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.deviceRpcResponseProtoSchema = | |
130 | + val.deviceRpcResponseProtoSchema; | |
131 | + transportData.transportConfiguration.transportPayloadTypeConfiguration.deviceTelemetryProtoSchema = | |
132 | + val.deviceTelemetryProtoSchema; | |
133 | + transportData.transportConfiguration.type = val.transportType; | |
134 | + transportData.transportConfiguration.clientSettings.powerMode = val.powerMode; | |
135 | + transportData.transportConfiguration.clientSettings.edrxCycle = val.edrxCycle; | |
136 | + transportData.transportConfiguration.clientSettings.psmActivityTimer = val.psmActivityTimer; | |
137 | + transportData.transportConfiguration.clientSettings.pagingTransmissionWindow = | |
138 | + val.pagingTransmissionWindow; | |
139 | + transportData.transportConfiguration.coapDeviceTypeConfiguration.coapDeviceType = | |
140 | + val.coapDeviceType; | |
141 | + return transportData; | |
73 | 142 | }; |
74 | 143 | return { |
75 | 144 | customResetFunc, |
76 | - customSubmitFunc, | |
77 | 145 | register, |
78 | 146 | setStepTwoFieldsValueFunc, |
79 | 147 | customClearStepTwoValueFunc, |
... | ... | @@ -84,7 +152,16 @@ |
84 | 152 | </script> |
85 | 153 | <style lang="less" scoped> |
86 | 154 | .step2 { |
87 | - width: 500px; | |
88 | - margin: 0 auto; | |
155 | + width: 100%; | |
156 | + .step2-style { | |
157 | + width: 43vw; | |
158 | + // height: 50vh; | |
159 | + border: 1px solid gray; | |
160 | + margin: 0vh 0.6vw; | |
161 | + border-radius: 4px; | |
162 | + } | |
163 | + } | |
164 | + ::-webkit-scrollbar { | |
165 | + display: none; | |
89 | 166 | } |
90 | 167 | </style> | ... | ... |
src/views/device/profiles/step/DeviceProfileStep3.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div> | |
3 | - <div> | |
4 | - <div | |
5 | - v-if="!getIsEchoEditStatus ? alarmsData.length == 0 : echoEditData.length == 0" | |
6 | - style="text-align: center" | |
7 | - > | |
8 | - <p style="font-size: large">未配置报警规则</p> | |
9 | - </div> | |
10 | - <div> | |
11 | - <template | |
12 | - v-for="(item, index) in !getIsEchoEditStatus ? alarmsData : echoEditData" | |
13 | - :key="index" | |
14 | - > | |
15 | - <div class="cursor-pointer" style="position: relative; top: 3.5vh; right: -41.6vw"> | |
16 | - <img | |
17 | - style="cursor: pointer" | |
18 | - @click="removeAlarmRule(item, index)" | |
19 | - alt="移除" | |
20 | - src="../../../../assets/images/delete.png" | |
21 | - /> | |
22 | - </div> | |
23 | - <div | |
24 | - style=" | |
25 | - margin-left: 0.21vw; | |
26 | - border-radius: 4px; | |
27 | - width: 44vw; | |
28 | - height: 47vh; | |
29 | - border: 1px solid grey; | |
30 | - overflow-y: scroll; | |
31 | - " | |
32 | - > | |
33 | - <CommonCpns | |
34 | - :ref="ruleRef.createRuleRefs" | |
35 | - :step3FatherEmitCpnData="!getIsEchoEditStatus ? 1 : item" | |
36 | - :step3FatherEmitCpnStatus=" | |
37 | - !getIsEchoEditStatus ? !getIsEchoEditStatus : getIsEchoEditStatus | |
38 | - " | |
39 | - /> | |
40 | - </div> | |
41 | - </template> | |
42 | - </div> | |
43 | - </div> | |
44 | - <!-- 按钮 --> | |
45 | - <div style="margin-left: 14.5vw; margin-top: 2vh"> | |
46 | - <a-button class="mr-5" @click="prevStepFunc">上一步</a-button> | |
47 | - <a-button @click="nextStepFunc">下一步</a-button> | |
48 | - <a-button | |
49 | - v-if="btnClose" | |
50 | - style="margin-left: 20px" | |
51 | - type="primary" | |
52 | - @click="clickAddAlaramRuleFunc" | |
53 | - >添加报警规则</a-button | |
54 | - > | |
55 | - </div> | |
56 | - <!-- 按钮 --> | |
57 | - </div> | |
58 | -</template> | |
59 | - | |
60 | -<script lang="ts"> | |
61 | - import { defineComponent, ref, getCurrentInstance, reactive, watch, nextTick } from 'vue'; | |
62 | - import CommonCpns from './common/index.vue'; | |
63 | - import { deteleObject } from '/@/hooks/web/useFilter'; | |
64 | - | |
65 | - export default defineComponent({ | |
66 | - components: { | |
67 | - CommonCpns, | |
68 | - }, | |
69 | - props: ['isShowAddRule'], | |
70 | - emits: ['next', 'prev'], | |
71 | - setup(props, { emit }) { | |
72 | - const { proxy } = getCurrentInstance() as any; | |
73 | - const commonCpnsRef = ref(null); | |
74 | - const alarmsData: any = ref([]); | |
75 | - const echoEditData: any = ref([]); | |
76 | - const getIsEchoEditStatus = ref(false); | |
77 | - const btnClose = ref(true); | |
78 | - let addObj = reactive({}); | |
79 | - const ruleRef = { | |
80 | - createRuleRefs: ref([]), | |
81 | - }; | |
82 | - const prevStepFunc = () => { | |
83 | - emit('prev'); | |
84 | - }; | |
85 | - const nextStepFunc = async () => { | |
86 | - emit('next', { | |
87 | - alarms: alarmsData.value, | |
88 | - }); | |
89 | - }; | |
90 | - const getStep3AllDataFunc = async (e) => { | |
91 | - let temp = []; | |
92 | - if (e == 1) { | |
93 | - temp = alarmsData.value; | |
94 | - } else { | |
95 | - temp = echoEditData.value; | |
96 | - } | |
97 | - for (let i = 0; i < temp.length; i++) { | |
98 | - for (const item of ruleRef.createRuleRefs.value) { | |
99 | - addObj = await item.getStep3AllDataFunc(); | |
100 | - alarmsData.value.push(addObj); | |
101 | - } | |
102 | - } | |
103 | - /** | |
104 | - * 过滤null和重复对象和1 | |
105 | - */ | |
106 | - alarmsData.value = alarmsData.value.filter((i) => i); | |
107 | - alarmsData.value = deteleObject(alarmsData.value); | |
108 | - alarmsData.value = alarmsData.value.filter((f) => f !== 1); | |
109 | - return alarmsData.value; | |
110 | - }; | |
111 | - const clickAddAlaramRuleFunc = async () => { | |
112 | - alarmsData.value.push(1); | |
113 | - nextTick(() => { | |
114 | - ruleRef.createRuleRefs.value[alarmsData.value.length - 1].updateCpnSchemaSelectEnableFunc( | |
115 | - alarmsData.value.length - 1 | |
116 | - ); | |
117 | - }); | |
118 | - | |
119 | - // try { | |
120 | - // // proxy.$refs['commonCpnsRef' + 0].updateCpnSchemaSelectEnableFunc(); | |
121 | - // // proxy.$refs['commonCpnsRef' + 1].updateCpnSchemaSelectEnableFunc(); | |
122 | - // if (getIsEchoEditStatus.value) { | |
123 | - // echoEditData.value.push(1); | |
124 | - // } | |
125 | - // } catch {} | |
126 | - }; | |
127 | - const removeAlarmRule = (e, i) => { | |
128 | - const key = alarmsData.value.indexOf(e); | |
129 | - console.log(i); | |
130 | - alarmsData.value.splice(key, 1); | |
131 | - if (getIsEchoEditStatus.value) { | |
132 | - const key1 = echoEditData.value.indexOf(e); | |
133 | - console.log(i); | |
134 | - echoEditData.value.splice(key1, 1); | |
135 | - } | |
136 | - }; | |
137 | - /** | |
138 | - * 清空数据 | |
139 | - */ | |
140 | - const clearStep3DataFunc = () => { | |
141 | - alarmsData.value.length = 0; | |
142 | - echoEditData.value.length = 0; | |
143 | - proxy.$refs.commonCpnsRef?.clearStep3CpnDataFunc(); | |
144 | - getIsEchoEditStatus.value = false; | |
145 | - }; | |
146 | - /** | |
147 | - * 回显数据 | |
148 | - */ | |
149 | - const echoStep3DataFunc = (e, s) => { | |
150 | - getIsEchoEditStatus.value = s; | |
151 | - if (getIsEchoEditStatus.value === true) { | |
152 | - echoEditData.value = e; | |
153 | - if (echoEditData.value == null) { | |
154 | - echoEditData.value = []; | |
155 | - } | |
156 | - } | |
157 | - }; | |
158 | - watch( | |
159 | - () => props.isShowAddRule, | |
160 | - (v) => { | |
161 | - btnClose.value = v; | |
162 | - } | |
163 | - ); | |
164 | - return { | |
165 | - clickAddAlaramRuleFunc, | |
166 | - prevStepFunc, | |
167 | - nextStepFunc, | |
168 | - alarmsData, | |
169 | - removeAlarmRule, | |
170 | - commonCpnsRef, | |
171 | - clearStep3DataFunc, | |
172 | - echoStep3DataFunc, | |
173 | - echoEditData, | |
174 | - getIsEchoEditStatus, | |
175 | - getStep3AllDataFunc, | |
176 | - btnClose, | |
177 | - ruleRef, | |
178 | - }; | |
179 | - }, | |
180 | - }); | |
181 | -</script> | |
182 | - | |
183 | -<style lang="less" scoped> | |
184 | - ::-webkit-scrollbar { | |
185 | - display: none; | |
186 | - } | |
187 | -</style> |
src/views/device/profiles/step/DeviceProfileStep4.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div class="step-4"> | |
3 | - <div v-if="isShow"> | |
4 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="register" /> | |
5 | - </div> | |
6 | - <div | |
7 | - style=" | |
8 | - display: flex; | |
9 | - width: 17vw; | |
10 | - height: 4vh; | |
11 | - flex-direction: row; | |
12 | - align-items: center; | |
13 | - justify-content: space-between; | |
14 | - margin-left: 14vw; | |
15 | - margin-top: -1.2vh; | |
16 | - " | |
17 | - > | |
18 | - <div style="width: 5vw; height: 4vh; margin-top: -3.6vh"> | |
19 | - <Button type="primary" style="border-radius: 2px" class="mt-5" @click="prevStep4" | |
20 | - >上一步</Button | |
21 | - > | |
22 | - </div> | |
23 | - <div style="width: 5vw; height: 4vh; margin-top: -3.6vh"> | |
24 | - <Button type="default" style="border-radius: 2px" class="mt-5" @click="addStep4"> | |
25 | - 打开告警通知</Button | |
26 | - > | |
27 | - </div> | |
28 | - <div style="width: 5vw; height: 4vh; margin-top: -3.6vh; margin-left: 2.2vw"> | |
29 | - <Button type="default" style="border-radius: 2px" class="mt-5" @click="closeStep4"> | |
30 | - 关闭</Button | |
31 | - > | |
32 | - </div> | |
33 | - </div> | |
34 | - </div> | |
35 | -</template> | |
36 | -<script lang="ts"> | |
37 | - import { defineComponent, ref, nextTick } from 'vue'; | |
38 | - import { BasicForm, useForm } from '/@/components/Form/index'; | |
39 | - import { alertContactsSchemas } from './data'; | |
40 | - import { Button } from '/@/components/Button'; | |
41 | - | |
42 | - export default defineComponent({ | |
43 | - components: { | |
44 | - BasicForm, | |
45 | - Button, | |
46 | - }, | |
47 | - emits: ['prev', 'register'], | |
48 | - setup(_, { emit }) { | |
49 | - const getValueData: any = ref({}); | |
50 | - const isShow = ref(false); | |
51 | - const [register, { setProps, validate, setFieldsValue, resetFields }] = useForm({ | |
52 | - schemas: alertContactsSchemas, | |
53 | - actionColOptions: { | |
54 | - span: 24, | |
55 | - }, | |
56 | - }); | |
57 | - const setAlaramContactAndNoticeMethodFunc = (v) => { | |
58 | - setFieldsValue(v); | |
59 | - }; | |
60 | - const clearAlaramContactAndNoticeMethodFunc = () => { | |
61 | - try { | |
62 | - nextTick(() => { | |
63 | - // resetFields(); | |
64 | - }); | |
65 | - } catch {} | |
66 | - }; | |
67 | - const getAllFields = async (getV) => { | |
68 | - const values = await validate(); | |
69 | - getValueData.value = values; | |
70 | - getV = getValueData.value; | |
71 | - return getV; | |
72 | - }; | |
73 | - const prevStep4 = () => { | |
74 | - emit('prev'); | |
75 | - }; | |
76 | - const addStep4 = () => { | |
77 | - isShow.value = true; | |
78 | - }; | |
79 | - const closeStep4 = () => { | |
80 | - isShow.value = false; | |
81 | - }; | |
82 | - const step3LinkStep4DefalutClose = () => { | |
83 | - isShow.value = false; | |
84 | - }; | |
85 | - return { | |
86 | - clearAlaramContactAndNoticeMethodFunc, | |
87 | - setAlaramContactAndNoticeMethodFunc, | |
88 | - getAllFields, | |
89 | - register, | |
90 | - setProps, | |
91 | - addStep4, | |
92 | - prevStep4, | |
93 | - isShow, | |
94 | - closeStep4, | |
95 | - step3LinkStep4DefalutClose, | |
96 | - }; | |
97 | - }, | |
98 | - }); | |
99 | -</script> | |
100 | -<style lang="less" scoped> | |
101 | - .step-4 { | |
102 | - // :deep .ant-btn { | |
103 | - // position: relative; | |
104 | - // right: 375px; | |
105 | - // top: 18px; | |
106 | - // } | |
107 | - } | |
108 | -</style> |
src/views/device/profiles/step/common/format-data/index.ts
deleted
100644 → 0
1 | -export const formatAlarmRuleConditionsData = (item) => { | |
2 | - console.log('==', item); | |
3 | - let item1 = []; | |
4 | - item1 = item.map((f) => { | |
5 | - return f?.predicate.operation == 'EQUAL' | |
6 | - ? f?.key.key + '等于' + f?.predicate.value.defaultValue | |
7 | - : f?.predicate.operation == 'STARTS_WITH' | |
8 | - ? f?.key.key + '开始于' + f?.predicate.value.defaultValue | |
9 | - : f?.predicate.operation == 'ENDS_WITH' | |
10 | - ? f?.key.key + '结束于' + f?.predicate.value.defaultValue | |
11 | - : f?.predicate.operation == 'NOT_CONTAINS' | |
12 | - ? f?.key.key + '不包含' + f?.predicate.value.defaultValue | |
13 | - : f?.predicate.operation == 'NOT_EQUAL' | |
14 | - ? f?.key.key + '不等于' + f?.predicate.value.defaultValue | |
15 | - : f?.predicate.operation == 'GREATER' | |
16 | - ? f?.key.key + '大于' + f?.predicate.value.defaultValue | |
17 | - : f?.predicate.operation == 'LESS' | |
18 | - ? f?.key.key + '小于' + f?.predicate.value.defaultValue | |
19 | - : f?.predicate.operation == 'GREATER_OR_EQUAL' | |
20 | - ? f?.key.key + '大于或等于' + f?.predicate.value.defaultValue | |
21 | - : f?.key.key + '小于或等于' + f?.predicate.value.defaultValue; | |
22 | - }); | |
23 | - return item1; | |
24 | -}; | |
25 | - | |
26 | -export const formatEnableRuleData = (f) => { | |
27 | - return f?.type == 'ANY_TIME' | |
28 | - ? '始终启用' | |
29 | - : f?.type == 'SPECIFIC_TIME' | |
30 | - ? '定时启用' | |
31 | - : '自定义启用'; | |
32 | -}; | |
33 | - | |
34 | -export const formatAlarmRuleConditionsData1 = (v) => { | |
35 | - let openEditRuleConditObj: any = {}; | |
36 | - for (const i in v) { | |
37 | - if (i == 'CRITICAL') { | |
38 | - openEditRuleConditObj = v[i]; | |
39 | - } else if (i == 'MAJOR') { | |
40 | - openEditRuleConditObj = v[i]; | |
41 | - } else if (i == 'MINOR') { | |
42 | - openEditRuleConditObj = v[i]; | |
43 | - } else if (i == 'WARNING') { | |
44 | - openEditRuleConditObj = v[i]; | |
45 | - } else if (i == 'INDETERMINATE') { | |
46 | - openEditRuleConditObj = v[i]; | |
47 | - } | |
48 | - } | |
49 | - return openEditRuleConditObj; | |
50 | -}; |
src/views/device/profiles/step/common/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div style="margin-left: 0.6vw"> | |
3 | - <!-- 报警类型和传递报警--> | |
4 | - <div> | |
5 | - <div class="alert-type" style="margin-left: -2.1vw; margin-top: 1vh"> | |
6 | - <BasicForm @register="registerForm" /> | |
7 | - </div> | |
8 | - <div style="margin-top: -15px"> | |
9 | - <div style="margin-left: -8px; margin-top: -10px"> | |
10 | - <BasicForm | |
11 | - @register="registerFormHighSetting" | |
12 | - style="margin-left: 12px; margin-top: -10px" | |
13 | - > | |
14 | - <template #checkBox="{ model, field }"> | |
15 | - <Checkbox v-model:checked="model[field]">传递报警</Checkbox> | |
16 | - </template> | |
17 | - </BasicForm> | |
18 | - </div> | |
19 | - </div> | |
20 | - </div> | |
21 | - <!-- 报警类型和传递报警 --> | |
22 | - <!-- 创建报警规则 --> | |
23 | - <div style="margin-top: -6vh"> | |
24 | - <p style="margin-left: 10px; font-size: medium">创建报警规则</p> | |
25 | - <p | |
26 | - v-if="createAlarmRuleData.length === 0 && createEditAlarmRuleData.length == 0" | |
27 | - style="text-align: center; font-size: large" | |
28 | - >请添加创建报警规则</p | |
29 | - > | |
30 | - <div v-if="createAlarmRuleData.length > 0 || createEditAlarmRuleData.length > 0"> | |
31 | - <template | |
32 | - v-for="(item, index) in !isStep3FatherAddOrEditStatus | |
33 | - ? createAlarmRuleData | |
34 | - : createEditAlarmRuleData" | |
35 | - :key="index" | |
36 | - > | |
37 | - <div class="cursor-pointer" style="position: relative; top: 15.5vh; right: -40.8vw"> | |
38 | - <img | |
39 | - style="cursor: pointer" | |
40 | - @click="removeAddCreateRuleFunc(item, index)" | |
41 | - alt="移除" | |
42 | - src="../../../../../../src/assets/images/close.png" | |
43 | - /> | |
44 | - </div> | |
45 | - <div style="width: 38vw; height: 30vh; border: 1px solid grey; border-radius: 4px"> | |
46 | - <div style="margin-top: 1vh"> | |
47 | - <AlarmSeverityCpn | |
48 | - :ref="conditionRefs.AlarmSeverityRef" | |
49 | - :AlarmSeverityCpnData="!isStep3FatherAddOrEditStatus ? 1 : item" | |
50 | - /> | |
51 | - <DetailTemplateCpn | |
52 | - :ref="conditionRefs.DetailTemplateRef" | |
53 | - :DetailTemplateCpnData="!isStep3FatherAddOrEditStatus ? 1 : item" | |
54 | - /> | |
55 | - <AlarmRuleConditionsCpn | |
56 | - :ref="conditionRefs.AlarmRuleConditionsRef" | |
57 | - @getAllFieldsRule="getAlarmRuleConditionsValFunc" | |
58 | - /> | |
59 | - <EnableRuleCpn | |
60 | - :ref="conditionRefs.EnableRuleRef" | |
61 | - @register="registerEnableRuleModal" | |
62 | - @getAllFieldsEnab="getEnableRuleFunc" | |
63 | - /> | |
64 | - <div style="margin-left: 0.5vw"> | |
65 | - <span style="color: red">请添加报警规则条件:</span> | |
66 | - <a-button | |
67 | - style="border-radius: 10px" | |
68 | - class="mt-5" | |
69 | - @click="clickAddAlarmRuleConditionsFunc(item, index)" | |
70 | - > | |
71 | - <PlusCircleOutlined /> | |
72 | - </a-button> | |
73 | - <div> | |
74 | - <div v-for="(item1, index1) in formatAlarmRuleConditions" :key="index1"> | |
75 | - <p v-if="item1.key === index && item1.data.length > 0"> | |
76 | - 报警规则条件:{{ formatAlarmRuleConditionsData(item1.data) }} | |
77 | - </p> | |
78 | - </div> | |
79 | - </div> | |
80 | - </div> | |
81 | - <div style="margin-left: 0.5vw"> | |
82 | - <span style="color: red">启用规则:</span> | |
83 | - <a-button style="border-radius: 10px" class="mt-5" @click="clickAddEnableRuleFunc"> | |
84 | - <PlusCircleOutlined /> | |
85 | - </a-button> | |
86 | - <div> | |
87 | - <p v-if="formatEnableRule.length == 0 && !isStep3FatherAddOrEditStatus" | |
88 | - >启用规则:始终启用</p | |
89 | - > | |
90 | - <div> | |
91 | - <template | |
92 | - v-for="(item2, index2) in !isStep3FatherAddOrEditStatus | |
93 | - ? formatEnableRule | |
94 | - : []" | |
95 | - :key="index2" | |
96 | - > | |
97 | - <p v-if="index2 == index"> 启用规则:{{ formatEnableRuleFunc(item2) }} </p> | |
98 | - </template> | |
99 | - </div> | |
100 | - <div v-if="isStep3FatherAddOrEditStatus && formatEditEnableData.length == 0"> | |
101 | - <p> 启用规则:{{ formatEnableRuleFuncData(item) }} </p> | |
102 | - </div> | |
103 | - <template | |
104 | - v-for="(item111, index111) in !isStep3FatherAddOrEditStatus | |
105 | - ? [] | |
106 | - : formatEditEnableData" | |
107 | - :key="index111" | |
108 | - > | |
109 | - <div | |
110 | - v-if=" | |
111 | - index111 == index && | |
112 | - isStep3FatherAddOrEditStatus && | |
113 | - formatEditEnableData.length > 0 | |
114 | - " | |
115 | - > | |
116 | - <p> 启用规则:{{ formatEditEnableRuleFunc(item111) }} </p> | |
117 | - </div> | |
118 | - </template> | |
119 | - </div> | |
120 | - </div> | |
121 | - <div></div> | |
122 | - <div></div> | |
123 | - </div> | |
124 | - </div> | |
125 | - </template> | |
126 | - </div> | |
127 | - <div> | |
128 | - <a-button style="border-radius: 10px" class="mt-5" @click="clickAddCreateRuleFunc"> | |
129 | - <PlusCircleOutlined /> | |
130 | - 添加创建条件 | |
131 | - </a-button> | |
132 | - </div> | |
133 | - <!-- 清除报警规则 --> | |
134 | - <div style="margin-top: 2vh"> | |
135 | - <p style="margin-left: 10px; font-size: medium">清除报警规则</p> | |
136 | - <div | |
137 | - v-if="isClearStatus" | |
138 | - class="cursor-pointer" | |
139 | - style="position: relative; top: 15.5vh; right: -40.8vw" | |
140 | - > | |
141 | - <img | |
142 | - style="cursor: pointer" | |
143 | - @click="removeAddClearRuleFunc" | |
144 | - alt="移除" | |
145 | - src="../../../../../../src/assets/images/close.png" | |
146 | - /> | |
147 | - </div> | |
148 | - <div | |
149 | - v-if="isClearStatus" | |
150 | - style="width: 38vw; height: 30vh; border: 1px solid grey; border-radius: 4px" | |
151 | - > | |
152 | - <div style="margin-top: 2vh"> | |
153 | - <div style="height: 3vh"> | |
154 | - <BasicForm @register="registerFormChangeClearDetail" /> | |
155 | - </div> | |
156 | - <AlarmRuleConditionsCpn | |
157 | - ref="AlarmClearRuleConditionsRef" | |
158 | - @register="registerClearAlarmRuleConditionsModal" | |
159 | - @getAllFieldsRule="getClearAlarmRuleConditionsValFunc" | |
160 | - /> | |
161 | - <EnableRuleCpn | |
162 | - ref="EnableClearRuleRef" | |
163 | - @register="registerClearEnableRuleModal" | |
164 | - @getAllFieldsEnab="getClearEnableRuleFunc" | |
165 | - /> | |
166 | - <div style="margin-left: 0.5vw"> | |
167 | - <span style="color: red">请添加报警规则条件:</span> | |
168 | - <a-button | |
169 | - style="border-radius: 10px" | |
170 | - class="mt-5" | |
171 | - @click="clickClearAlarmRuleConditionsFunc" | |
172 | - > | |
173 | - <PlusCircleOutlined /> | |
174 | - </a-button> | |
175 | - <div> | |
176 | - <div> | |
177 | - <template v-for="(item3, index3) in formatClearAlarmRuleConditions" :key="index3"> | |
178 | - <span style="display: none">{{ index3 }}</span> | |
179 | - <p> 报警规则条件:{{ formatClearAlarmRuleConditionsFunc(item3) }} </p> | |
180 | - </template> | |
181 | - </div> | |
182 | - </div> | |
183 | - </div> | |
184 | - <div style="margin-left: 0.5vw"> | |
185 | - <span style="color: red">启用规则:</span> | |
186 | - <a-button style="border-radius: 10px" class="mt-5" @click="clickClearEnableRuleFunc"> | |
187 | - <PlusCircleOutlined /> | |
188 | - </a-button> | |
189 | - <div> | |
190 | - <p v-if="formatEnableRule.length == 0 && !isStep3FatherAddOrEditStatus" | |
191 | - >启用规则:始终启用</p | |
192 | - > | |
193 | - <div> | |
194 | - <template v-for="(item4, index4) in formatClearEnableRule" :key="index4"> | |
195 | - <span style="display: none">{{ index4 }}</span> | |
196 | - <p> 启用规则:{{ formatClearEnableRuleFunc(item4) }} </p> | |
197 | - </template> | |
198 | - </div> | |
199 | - <div> | |
200 | - <template | |
201 | - v-for="(item44, index44) in isStep3FatherAddOrEditStatus | |
202 | - ? formatEditClearEnableRule | |
203 | - : []" | |
204 | - :key="index44" | |
205 | - > | |
206 | - <span style="display: none">{{ index44 }}</span> | |
207 | - <p> 启用规则:{{ formatEnableRuleData(item44) }} </p> | |
208 | - </template> | |
209 | - </div> | |
210 | - </div> | |
211 | - </div> | |
212 | - <div></div> | |
213 | - <div></div> | |
214 | - </div> | |
215 | - </div> | |
216 | - <div style="position: relative; top: -1.2vh"> | |
217 | - <a-button style="border-radius: 10px" class="mt-5" @click="clickAddClearRuleFunc"> | |
218 | - <PlusCircleOutlined /> | |
219 | - 添加清除条件 | |
220 | - </a-button> | |
221 | - </div> | |
222 | - </div> | |
223 | - <!-- 清除报警规则 --> | |
224 | - </div> | |
225 | - <!-- 创建报警规则 --> | |
226 | - </div> | |
227 | -</template> | |
228 | -<script lang="ts"> | |
229 | - import { defineComponent, ref, nextTick, getCurrentInstance, reactive, watch } from 'vue'; | |
230 | - import { BasicForm, useForm } from '/@/components/Form'; | |
231 | - import { step3Schemas, step3HighSetting, formChangeDetailSchema } from '../data'; | |
232 | - import { Checkbox } from 'ant-design-vue'; | |
233 | - import { PlusCircleOutlined } from '@ant-design/icons-vue'; | |
234 | - import AlarmSeverityCpn from '../cpns/alarmseverity/index.vue'; | |
235 | - import DetailTemplateCpn from '../cpns/detailtemplate/index.vue'; | |
236 | - import AlarmRuleConditionsCpn from '../cpns/alarmruleconditions/index.vue'; | |
237 | - import EnableRuleCpn from '../cpns/enablerule/index.vue'; | |
238 | - import { useModal } from '/@/components/Modal'; | |
239 | - import { generateUUID } from '/@/hooks/web/useGenerateUUID'; | |
240 | - | |
241 | - import { | |
242 | - formatAlarmRuleConditionsData, | |
243 | - formatEnableRuleData, | |
244 | - formatAlarmRuleConditionsData1, | |
245 | - } from '../common/format-data/index'; | |
246 | - | |
247 | - export default defineComponent({ | |
248 | - components: { | |
249 | - BasicForm, | |
250 | - Checkbox, | |
251 | - PlusCircleOutlined, | |
252 | - AlarmSeverityCpn, | |
253 | - DetailTemplateCpn, | |
254 | - AlarmRuleConditionsCpn, | |
255 | - EnableRuleCpn, | |
256 | - }, | |
257 | - props: ['step3FatherEmitCpnData', 'step3FatherEmitCpnStatus'], | |
258 | - setup(props) { | |
259 | - const getConditionData = ref([]); | |
260 | - const getConditionData1 = ref([{ key: 0, data: {} }]); | |
261 | - const { proxy } = getCurrentInstance() as any; | |
262 | - const createAlarmRuleData: any = ref([1]); | |
263 | - const createEditAlarmRuleData: any = ref([]); | |
264 | - const AlarmRuleConditionsRef = ref(null); | |
265 | - const EnableRuleRef = ref(null); | |
266 | - const AlarmClearRuleConditionsRef = ref(null); | |
267 | - const EnableClearRuleRef = ref(null); | |
268 | - const formatAlarmRuleConditions = ref([]); | |
269 | - const formatClearAlarmRuleConditions: any = ref([]); | |
270 | - const formatEditClearAlarmRuleConditions: any = ref([]); | |
271 | - const formatEnableRule: any = ref([]); | |
272 | - const formatClearEnableRule: any = ref([]); | |
273 | - const formatEditClearEnableRule: any = ref([]); | |
274 | - const level = ref(['CRITICAL', 'MAJOR', 'MINOR', 'WARNING', 'INDETERMINATE']); | |
275 | - const conditionRefs = { | |
276 | - AlarmRuleConditionsRef: ref([]), | |
277 | - AlarmSeverityRef: ref([]), | |
278 | - DetailTemplateRef: ref([]), | |
279 | - EnableRuleRef: ref([]), | |
280 | - }; | |
281 | - let alaramsObj: any = reactive({ | |
282 | - alarmType: null, | |
283 | - propagate: null, | |
284 | - propagateRelationTypes: null, | |
285 | - clearRule: {}, | |
286 | - createRules: {}, | |
287 | - id: '', | |
288 | - }); | |
289 | - const AlarmSeverityRef = ref(null); | |
290 | - const DetailTemplateRef = ref(null); | |
291 | - const tempDetailTemplateData: any = ref([]); | |
292 | - const isClearStatus = ref(false); | |
293 | - const isStep3FatherAddOrEditStatus = ref(false); | |
294 | - let val4: any = reactive({}); | |
295 | - let val5: any = reactive({}); | |
296 | - let val6: any = ref([]); | |
297 | - let val7: any = ref(null); | |
298 | - let val9: any = ref([]); | |
299 | - let val10: any = ref(null); | |
300 | - const formatEditRuleData: any = ref([]); | |
301 | - const formatEditEnableData: any = ref([]); | |
302 | - const [registerEnableRuleModal, { openModal: openModalEnableRule }] = useModal(); | |
303 | - const [ | |
304 | - registerClearAlarmRuleConditionsModal, | |
305 | - { openModal: openModalClearAlarmRuleConditions }, | |
306 | - ] = useModal(); | |
307 | - const [registerClearEnableRuleModal, { openModal: openModalClearEnableRule }] = useModal(); | |
308 | - const [ | |
309 | - registerForm, | |
310 | - { | |
311 | - setFieldsValue: setAlarmTypeValFunc, | |
312 | - validate: getAlarmTypeValFunc, | |
313 | - resetFields: resetAlarmTypeValFunc, | |
314 | - }, | |
315 | - ] = useForm({ | |
316 | - labelWidth: 120, | |
317 | - schemas: step3Schemas, | |
318 | - showResetButton: false, | |
319 | - showSubmitButton: false, | |
320 | - }); | |
321 | - const [ | |
322 | - registerFormHighSetting, | |
323 | - { | |
324 | - setFieldsValue: setDeliverAlertsValFunc, | |
325 | - getFieldsValue: getDeliverAlertsValFunc, | |
326 | - resetFields: resetDeliverAlertsValFunc, | |
327 | - }, | |
328 | - ] = useForm({ | |
329 | - labelWidth: 120, | |
330 | - schemas: step3HighSetting, | |
331 | - showResetButton: false, | |
332 | - showSubmitButton: false, | |
333 | - actionColOptions: { | |
334 | - span: 24, | |
335 | - }, | |
336 | - }); | |
337 | - const [ | |
338 | - registerFormChangeClearDetail, | |
339 | - { | |
340 | - setFieldsValue: setRegisterFormClearChangeDetailFunc, | |
341 | - getFieldsValue: getRegisterFormClearChangeDetailFunc, | |
342 | - resetFields: resetRegisterFormClearChangeDetailFunc, | |
343 | - }, | |
344 | - ] = useForm({ | |
345 | - labelWidth: 120, | |
346 | - schemas: formChangeDetailSchema, | |
347 | - showResetButton: false, | |
348 | - showSubmitButton: false, | |
349 | - actionColOptions: { | |
350 | - span: 24, | |
351 | - }, | |
352 | - }); | |
353 | - const clickAddCreateRuleFunc = () => { | |
354 | - let i = 1; | |
355 | - i--; | |
356 | - createAlarmRuleData.value.push(1); | |
357 | - nextTick(() => { | |
358 | - conditionRefs.AlarmSeverityRef.value.map((item, index) => { | |
359 | - if (i === index) { | |
360 | - nextTick(() => { | |
361 | - item.updateSchemaSelectDisableFunc(); | |
362 | - }); | |
363 | - } | |
364 | - }); | |
365 | - }); | |
366 | - if (isStep3FatherAddOrEditStatus.value) { | |
367 | - createEditAlarmRuleData.value.push(1); | |
368 | - } | |
369 | - }; | |
370 | - const updateCpnSchemaSelectEnableFunc = (select) => { | |
371 | - conditionRefs.AlarmSeverityRef.value.map((item, index) => { | |
372 | - if (select === index) { | |
373 | - nextTick(() => { | |
374 | - item.updateSchemaSelectEnableFunc(); | |
375 | - }); | |
376 | - } | |
377 | - }); | |
378 | - }; | |
379 | - | |
380 | - /** | |
381 | - * 获取清除报警规则数据 | |
382 | - */ | |
383 | - const clickAddClearRuleFunc = () => { | |
384 | - isClearStatus.value = true; | |
385 | - }; | |
386 | - const removeAddClearRuleFunc = () => { | |
387 | - isClearStatus.value = false; | |
388 | - alaramsObj.clearRule = null; | |
389 | - }; | |
390 | - const removeAddCreateRuleFunc = (e, i) => { | |
391 | - const key = createAlarmRuleData.value.indexOf(e); | |
392 | - createAlarmRuleData.value.splice(key, 1); | |
393 | - console.log(i); | |
394 | - Object.keys(alaramsObj.createRules).forEach((i1, e) => { | |
395 | - if (e == i) { | |
396 | - delete alaramsObj.createRules[i1]; | |
397 | - } | |
398 | - }); | |
399 | - if (isStep3FatherAddOrEditStatus.value) { | |
400 | - const key1 = createEditAlarmRuleData.value.indexOf(e); | |
401 | - createEditAlarmRuleData.value.splice(key1, 1); | |
402 | - } | |
403 | - }; | |
404 | - const clickAddAlarmRuleConditionsFunc = (e, i) => { | |
405 | - getConditionData.value = []; | |
406 | - | |
407 | - //获取对应下标 | |
408 | - let currentAlarmCondition = { key: 0, data: {} }; | |
409 | - let isUpdate = false; | |
410 | - getConditionData1.value.forEach((obj) => { | |
411 | - if (obj.data.length != undefined && obj.key == i) { | |
412 | - currentAlarmCondition.key = i; | |
413 | - currentAlarmCondition.data = obj.data; | |
414 | - isUpdate = true; | |
415 | - } | |
416 | - }); | |
417 | - getConditionData.value.push(currentAlarmCondition); | |
418 | - conditionRefs.AlarmRuleConditionsRef.value.map((item, index) => { | |
419 | - if (i === index) { | |
420 | - nextTick(() => { | |
421 | - item.resetDataFunc(index, currentAlarmCondition, isUpdate); | |
422 | - }); | |
423 | - } | |
424 | - }); | |
425 | - }; | |
426 | - | |
427 | - const clickAddEnableRuleFunc = () => { | |
428 | - nextTick(() => { | |
429 | - openModalEnableRule(true); | |
430 | - proxy.$refs.DetailTemplateRef?.resetDataFunc(); | |
431 | - }); | |
432 | - }; | |
433 | - const clickClearAlarmRuleConditionsFunc = () => { | |
434 | - nextTick(() => { | |
435 | - openModalClearAlarmRuleConditions(true); | |
436 | - proxy.$refs.AlarmRuleConditionsRef?.resetDataFunc(); | |
437 | - }); | |
438 | - }; | |
439 | - const clickClearEnableRuleFunc = () => { | |
440 | - nextTick(() => { | |
441 | - openModalClearEnableRule(true); | |
442 | - proxy.$refs.DetailTemplateRef?.resetDataFunc(); | |
443 | - }); | |
444 | - }; | |
445 | - const getAlarmRuleConditionsValFunc = (e) => { | |
446 | - console.log('获取值'); | |
447 | - if (!isStep3FatherAddOrEditStatus) { | |
448 | - formatAlarmRuleConditions.value.push(e); | |
449 | - } else { | |
450 | - for (let i = 0; i < formatAlarmRuleConditions.value.length; i++) { | |
451 | - if (formatAlarmRuleConditions.value[i].key == e.key) { | |
452 | - formatAlarmRuleConditions.value.splice(i, 1); | |
453 | - } | |
454 | - } | |
455 | - formatAlarmRuleConditions.value.push(e); | |
456 | - } | |
457 | - | |
458 | - let addValue = undefined; | |
459 | - getConditionData1.value.forEach((obj) => { | |
460 | - if (Object.keys(obj.data).length != 0 && obj.key == e.key) { | |
461 | - obj.data = e.data; | |
462 | - } else { | |
463 | - addValue = e; | |
464 | - } | |
465 | - }); | |
466 | - if (addValue != undefined) { | |
467 | - getConditionData1.value.push(addValue); | |
468 | - } | |
469 | - }; | |
470 | - const getClearAlarmRuleConditionsValFunc = (e) => { | |
471 | - formatClearAlarmRuleConditions.value.push({ | |
472 | - condition: e, | |
473 | - } as never); | |
474 | - }; | |
475 | - const formatClearAlarmRuleConditionsFunc = (e) => { | |
476 | - // let formatMap = e.condition.map((f: any) => formatAlarmRuleConditionsData(f)); | |
477 | - // return formatMap; | |
478 | - }; | |
479 | - const getEnableRuleFunc = (e) => { | |
480 | - formatEnableRule.value.push(e); | |
481 | - formatEditEnableData.value.push(e); | |
482 | - }; | |
483 | - const getClearEnableRuleFunc = (e) => { | |
484 | - formatClearEnableRule.value.push(e); | |
485 | - }; | |
486 | - const formatEnableRuleFunc = (e) => { | |
487 | - let formatMap = formatEnableRuleData(e); | |
488 | - return formatMap; | |
489 | - }; | |
490 | - const formatEditEnableRuleFunc = (e) => { | |
491 | - let formatMap = formatEnableRuleData(e); | |
492 | - return formatMap; | |
493 | - }; | |
494 | - const formatClearEnableRuleFunc = (e) => { | |
495 | - let formatMap = formatEnableRuleData(e); | |
496 | - return formatMap; | |
497 | - }; | |
498 | - /** | |
499 | - * 获取第三步所有的数据 | |
500 | - */ | |
501 | - const getStep3AllDataFunc = async () => { | |
502 | - try { | |
503 | - const UUID = generateUUID(); | |
504 | - const val1 = await getAlarmTypeValFunc(); | |
505 | - const val2 = getDeliverAlertsValFunc(); | |
506 | - const val3 = []; | |
507 | - val3.push(val2.propagateRelationTypes as never); | |
508 | - alaramsObj.alarmType = val1.alarmType; | |
509 | - alaramsObj.propagate = val2.propagate; | |
510 | - alaramsObj.id = UUID; | |
511 | - if (val2.propagateRelationTypes == undefined) { | |
512 | - alaramsObj.propagateRelationTypes = null; | |
513 | - } else { | |
514 | - alaramsObj.propagateRelationTypes = val3; | |
515 | - } | |
516 | - const val8 = getRegisterFormClearChangeDetailFunc(); | |
517 | - val9.value = proxy.$refs['AlarmClearRuleConditionsRef']?.getFieldsValueFunc(); | |
518 | - val10.value = proxy.$refs['EnableClearRuleRef']?.getFieldsValueFunc(); | |
519 | - if (val9.value == undefined || val10.value == undefined) { | |
520 | - alaramsObj.clearRule = null; | |
521 | - isClearStatus.value = false; | |
522 | - } else { | |
523 | - alaramsObj.clearRule = { | |
524 | - ...val8, | |
525 | - ...{ | |
526 | - schedule: val10.value == undefined ? undefined : val10.value, | |
527 | - }, | |
528 | - ...{ | |
529 | - condition: { | |
530 | - condition: val9.value == undefined ? undefined : val9.value, | |
531 | - }, | |
532 | - }, | |
533 | - }; | |
534 | - } | |
535 | - let temp = []; | |
536 | - if (!isStep3FatherAddOrEditStatus) { | |
537 | - temp = createAlarmRuleData.value; | |
538 | - } else { | |
539 | - temp = createEditAlarmRuleData.value; | |
540 | - } | |
541 | - for (let i = 0; i < temp.length; i++) { | |
542 | - formatAlarmRuleConditions.value.forEach((f, ii) => { | |
543 | - if (ii == i) { | |
544 | - conditionRefs.AlarmSeverityRef.value.forEach((item, index) => { | |
545 | - if (index == ii) { | |
546 | - val4 = item.getFieldsValueFunc(); | |
547 | - } | |
548 | - }); | |
549 | - conditionRefs.DetailTemplateRef.value.forEach((item, index) => { | |
550 | - if (index == ii) { | |
551 | - val5 = item.getFieldsValueFunc(); | |
552 | - } | |
553 | - }); | |
554 | - conditionRefs.AlarmRuleConditionsRef.value.forEach((item, index) => { | |
555 | - if (index == ii) { | |
556 | - val6.value = item.getFieldsValueFunc(); | |
557 | - } | |
558 | - }); | |
559 | - conditionRefs.EnableRuleRef.value.forEach((item, index) => { | |
560 | - if (index == ii) { | |
561 | - val7.value = item.getFieldsValueFunc(); | |
562 | - } | |
563 | - }); | |
564 | - alaramsObj.createRules[val4?.default] = { | |
565 | - ...val5, | |
566 | - ...{ | |
567 | - schedule: val7.value, | |
568 | - }, | |
569 | - ...{ | |
570 | - condition: { | |
571 | - condition: val6.value, | |
572 | - }, | |
573 | - }, | |
574 | - }; | |
575 | - } | |
576 | - }); | |
577 | - } | |
578 | - return alaramsObj; | |
579 | - } catch (e) { | |
580 | - console.log(e); | |
581 | - } | |
582 | - }; | |
583 | - /** | |
584 | - * 清空第三步数据 | |
585 | - */ | |
586 | - const clearStep3CpnDataFunc = () => { | |
587 | - try { | |
588 | - resetAlarmTypeValFunc(); | |
589 | - resetDeliverAlertsValFunc(); | |
590 | - proxy.$refs.AlarmSeverityRef?.resetFieldsFunc(); | |
591 | - proxy.$refs.DetailTemplateRef?.resetFieldsFunc(); | |
592 | - proxy.$refs.AlarmRuleConditionsRef?.resetFieldsFunc(); | |
593 | - proxy.$refs.EnableRuleRef?.resetFieldsFunc(); | |
594 | - resetRegisterFormClearChangeDetailFunc(); | |
595 | - formatAlarmRuleConditions.value.length = 0; | |
596 | - formatClearAlarmRuleConditions.value.length = 0; | |
597 | - formatEnableRule.value.length = 0; | |
598 | - formatClearEnableRule.value.length = 0; | |
599 | - tempDetailTemplateData.value.length = 0; | |
600 | - formatEditClearEnableRule.value.length = 0; | |
601 | - formatEditClearAlarmRuleConditions.value.length = 0; | |
602 | - createEditAlarmRuleData.value.length = 0; | |
603 | - alaramsObj.alarmType = null; | |
604 | - alaramsObj.propagate = null; | |
605 | - alaramsObj.propagateRelationTypes = null; | |
606 | - alaramsObj.clearRule = {}; | |
607 | - alaramsObj.createRules = {}; | |
608 | - alaramsObj.id = ''; | |
609 | - formatEditRuleData.value.length = 0; | |
610 | - formatEditEnableData.value.length = 0; | |
611 | - val6.value.length = 0; | |
612 | - val7.value = null; | |
613 | - val9.value.length = 0; | |
614 | - val10.value = null; | |
615 | - } catch {} | |
616 | - }; | |
617 | - /** | |
618 | - * 回显第三步数据 | |
619 | - */ | |
620 | - watch( | |
621 | - () => props.step3FatherEmitCpnData, | |
622 | - (v) => { | |
623 | - console.log(v); | |
624 | - } | |
625 | - ); | |
626 | - const echoStep3DataCpnFunc = () => { | |
627 | - if (props.step3FatherEmitCpnData !== 1) { | |
628 | - if (props.step3FatherEmitCpnData == undefined) return; | |
629 | - isStep3FatherAddOrEditStatus.value = props.step3FatherEmitCpnStatus; | |
630 | - for (let i in props.step3FatherEmitCpnData?.createRules) { | |
631 | - console.log(props.step3FatherEmitCpnData); | |
632 | - createEditAlarmRuleData.value.push({ | |
633 | - [i]: props.step3FatherEmitCpnData?.createRules[i], | |
634 | - }); | |
635 | - } | |
636 | - level.value.forEach((item, index) => { | |
637 | - createEditAlarmRuleData.value.forEach((item1) => { | |
638 | - for (let i in item1) { | |
639 | - if (i != undefined && i == item) { | |
640 | - formatAlarmRuleConditions.value.push({ | |
641 | - key: index, | |
642 | - data: item1[i].condition.condition, | |
643 | - }); | |
644 | - } | |
645 | - } | |
646 | - }); | |
647 | - }); | |
648 | - getConditionData1.value = formatAlarmRuleConditions.value; | |
649 | - nextTick(() => { | |
650 | - setAlarmTypeValFunc({ | |
651 | - alarmType: props.step3FatherEmitCpnData?.alarmType, | |
652 | - }); | |
653 | - try { | |
654 | - setDeliverAlertsValFunc({ | |
655 | - propagate: props.step3FatherEmitCpnData?.propagate, | |
656 | - propagateRelationTypes: props.step3FatherEmitCpnData?.propagateRelationTypes[0], | |
657 | - }); | |
658 | - } catch {} | |
659 | - if (props.step3FatherEmitCpnData?.clearRule?.alarmDetails !== '') { | |
660 | - isClearStatus.value = true; | |
661 | - nextTick(() => { | |
662 | - setRegisterFormClearChangeDetailFunc({ | |
663 | - alarmDetails: props.step3FatherEmitCpnData?.clearRule?.alarmDetails, | |
664 | - }); | |
665 | - }); | |
666 | - } | |
667 | - formatEditClearAlarmRuleConditions.value = | |
668 | - props.step3FatherEmitCpnData?.clearRule?.condition?.condition; | |
669 | - formatEditClearEnableRule.value.push(props.step3FatherEmitCpnData?.clearRule?.schedule); | |
670 | - if (props.step3FatherEmitCpnData?.clearRule == null) { | |
671 | - nextTick(() => { | |
672 | - return (isClearStatus.value = false); | |
673 | - }); | |
674 | - } else { | |
675 | - nextTick(() => { | |
676 | - return (isClearStatus.value = true); | |
677 | - }); | |
678 | - } | |
679 | - }); | |
680 | - } | |
681 | - }; | |
682 | - echoStep3DataCpnFunc(); | |
683 | - const formatEnableRuleFuncData = (v) => { | |
684 | - return formatEnableRuleData(formatAlarmRuleConditionsData1(v)?.schedule); | |
685 | - }; | |
686 | - return { | |
687 | - registerForm, | |
688 | - registerFormHighSetting, | |
689 | - clickAddCreateRuleFunc, | |
690 | - createAlarmRuleData, | |
691 | - clickAddClearRuleFunc, | |
692 | - removeAddCreateRuleFunc, | |
693 | - clickAddEnableRuleFunc, | |
694 | - clickAddAlarmRuleConditionsFunc, | |
695 | - AlarmRuleConditionsRef, | |
696 | - EnableRuleRef, | |
697 | - registerEnableRuleModal, | |
698 | - getAlarmRuleConditionsValFunc, | |
699 | - formatAlarmRuleConditions, | |
700 | - formatEnableRule, | |
701 | - formatEnableRuleFunc, | |
702 | - getEnableRuleFunc, | |
703 | - getStep3AllDataFunc, | |
704 | - AlarmSeverityRef, | |
705 | - DetailTemplateRef, | |
706 | - isClearStatus, | |
707 | - removeAddClearRuleFunc, | |
708 | - formatClearAlarmRuleConditions, | |
709 | - formatClearAlarmRuleConditionsFunc, | |
710 | - formatClearEnableRule, | |
711 | - formatClearEnableRuleFunc, | |
712 | - registerClearAlarmRuleConditionsModal, | |
713 | - registerClearEnableRuleModal, | |
714 | - clickClearAlarmRuleConditionsFunc, | |
715 | - clickClearEnableRuleFunc, | |
716 | - getClearAlarmRuleConditionsValFunc, | |
717 | - getClearEnableRuleFunc, | |
718 | - registerFormChangeClearDetail, | |
719 | - clearStep3CpnDataFunc, | |
720 | - echoStep3DataCpnFunc, | |
721 | - isStep3FatherAddOrEditStatus, | |
722 | - formatAlarmRuleConditionsData, | |
723 | - formatEditClearAlarmRuleConditions, | |
724 | - formatEnableRuleData, | |
725 | - formatEditClearEnableRule, | |
726 | - createEditAlarmRuleData, | |
727 | - formatEnableRuleFuncData, | |
728 | - AlarmClearRuleConditionsRef, | |
729 | - EnableClearRuleRef, | |
730 | - formatEditRuleData, | |
731 | - formatEditEnableData, | |
732 | - formatEditEnableRuleFunc, | |
733 | - updateCpnSchemaSelectEnableFunc, | |
734 | - getConditionData, | |
735 | - getConditionData1, | |
736 | - conditionRefs, | |
737 | - level, | |
738 | - }; | |
739 | - }, | |
740 | - }); | |
741 | -</script> | |
742 | - | |
743 | -<style lang="less" scoped></style> |
src/views/device/profiles/step/cpns/alarmruleconditions/config.ts
deleted
100644 → 0
1 | -import { FormSchema, BasicColumn } from '/@/components/Table'; | |
2 | -import { DescItem } from '/@/components/Description/index'; | |
3 | - | |
4 | -/** | |
5 | - * 所使用的枚举值 | |
6 | - */ | |
7 | - | |
8 | -export enum TriggerEnum { | |
9 | - IS_DEVICE_ACT = 'SIMPLE', | |
10 | - IS_TIME_ACT = 'DURATION', | |
11 | - IS_SCENE_ACT = 'REPEATING', | |
12 | - IS_CURRENT_CUSTOMER = 'CURRENT_CUSTOMER', | |
13 | - IS_CURRENT_DEVICE = 'CURRENT_DEVICE', | |
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 | -}; | |
21 | - | |
22 | -export const isShiDu = (type: string) => { | |
23 | - return type === TriggerEnum.IS_DEVICE_ACT; | |
24 | -}; | |
25 | -export const isWenDu = (type: string) => { | |
26 | - return type === TriggerEnum.IS_TIME_ACT; | |
27 | -}; | |
28 | - | |
29 | -export const isTimeAll = (type: string) => { | |
30 | - return type === TriggerEnum.IS_SCENE_ACT; | |
31 | -}; | |
32 | - | |
33 | -export const keyColumns: BasicColumn[] = [ | |
34 | - { | |
35 | - title: '键名', | |
36 | - dataIndex: 'key1', | |
37 | - width: 100, | |
38 | - }, | |
39 | - { | |
40 | - title: '键类型', | |
41 | - dataIndex: 'type', | |
42 | - width: 100, | |
43 | - }, | |
44 | - { | |
45 | - title: '操作', | |
46 | - dataIndex: 'operation', | |
47 | - width: 100, | |
48 | - format: (text: string, record: Recordable) => { | |
49 | - const findDay = [ | |
50 | - { label: '等于', value: 'EQUAL' }, | |
51 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
52 | - { label: '开始于', value: 'STARTS_WITH' }, | |
53 | - { label: '结束于', value: 'ENDS_WITH' }, | |
54 | - { label: '包含', value: 'CONTAINS' }, | |
55 | - { label: '不包含', value: 'NOT_CONTAINS' }, | |
56 | - { label: '等于', value: 'EQUAL' }, | |
57 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
58 | - { label: '大于', value: 'GREATER' }, | |
59 | - { label: '小于', value: 'LESS' }, | |
60 | - { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
61 | - { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
62 | - ]; | |
63 | - const findRuleByValue = findDay.find((f) => { | |
64 | - if (f.value == record.operation) { | |
65 | - return f.label; | |
66 | - } | |
67 | - }); | |
68 | - if (findRuleByValue) { | |
69 | - return findRuleByValue.label; | |
70 | - } | |
71 | - }, | |
72 | - }, | |
73 | - { | |
74 | - title: '值', | |
75 | - dataIndex: 'value1', | |
76 | - width: 80, | |
77 | - }, | |
78 | -]; | |
79 | -// export const columnsView: BasicColumn[] = [ | |
80 | -// { | |
81 | -// title: '键名', | |
82 | -// dataIndex: 'key1', | |
83 | -// width: 200, | |
84 | -// }, | |
85 | -// { | |
86 | -// title: '操作', | |
87 | -// dataIndex: 'operation', | |
88 | -// width: 200, | |
89 | -// format: (text: string, record: Recordable) => { | |
90 | -// const findDay = [ | |
91 | -// { label: '等于', value: 'EQUAL' }, | |
92 | -// { label: '不等于', value: 'NOT_EQUAL' }, | |
93 | -// { label: '开始于', value: 'STARTS_WITH' }, | |
94 | -// { label: '结束于', value: 'ENDS_WITH' }, | |
95 | -// { label: '包含', value: 'CONTAINS' }, | |
96 | -// { label: '不包含', value: 'NOT_CONTAINS' }, | |
97 | -// { label: '等于', value: 'EQUAL' }, | |
98 | -// { label: '不等于', value: 'NOT_EQUAL' }, | |
99 | -// { label: '大于', value: 'GREATER' }, | |
100 | -// { label: '小于', value: 'LESS' }, | |
101 | -// { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
102 | -// { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
103 | -// ]; | |
104 | -// const findRuleByValue = findDay.find((f) => { | |
105 | -// if (f.value == record.operation) { | |
106 | -// return f.label; | |
107 | -// } | |
108 | -// }); | |
109 | -// if (findRuleByValue) { | |
110 | -// return findRuleByValue.label; | |
111 | -// } | |
112 | -// }, | |
113 | -// }, | |
114 | -// { | |
115 | -// title: '值', | |
116 | -// dataIndex: 'value1', | |
117 | -// width: 200, | |
118 | -// }, | |
119 | -// ]; | |
120 | - | |
121 | -export const DescDetailSchema: DescItem[] = [ | |
122 | - { | |
123 | - field: 'key1', | |
124 | - label: '键名', | |
125 | - }, | |
126 | - { | |
127 | - field: 'type', | |
128 | - label: '键类型', | |
129 | - }, | |
130 | -]; | |
131 | - | |
132 | -export const formSchema: FormSchema[] = [ | |
133 | - { | |
134 | - field: 'conditionType', | |
135 | - label: '条件类型', | |
136 | - colProps: { span: 13 }, | |
137 | - component: 'Select', | |
138 | - defaultValue: 'SIMPLE', | |
139 | - componentProps: { | |
140 | - placeholder: '请选择报警日程表', | |
141 | - options: [ | |
142 | - { label: '简单', value: 'SIMPLE' }, | |
143 | - { label: '持续时间', value: 'DURATION' }, | |
144 | - { label: '重复', value: 'REPEATING' }, | |
145 | - ], | |
146 | - }, | |
147 | - }, | |
148 | - // { | |
149 | - // field: 'sourceType', | |
150 | - // label: '动态源类型', | |
151 | - // colProps: { span: 24 }, | |
152 | - // component: 'Select', | |
153 | - // componentProps: { | |
154 | - // placeholder: '请选择动态源类型', | |
155 | - // options: [ | |
156 | - // { label: '无动态值', value: '' }, | |
157 | - // { label: '当前租户', value: 'CURRENT_TENANT' }, | |
158 | - // { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
159 | - // { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
160 | - // ], | |
161 | - // }, | |
162 | - // ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')), | |
163 | - // show: ({ values }) => { | |
164 | - // return !!values.field5; | |
165 | - // }, | |
166 | - // }, | |
167 | - // { | |
168 | - // field: 'sourceAttribute', | |
169 | - // label: '源属性', | |
170 | - // colProps: { span: 24 }, | |
171 | - // component: 'Input', | |
172 | - // componentProps: { | |
173 | - // placeholder: '源属性', | |
174 | - // }, | |
175 | - // ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')), | |
176 | - // show: ({ values }) => { | |
177 | - // return !!values.field5; | |
178 | - // }, | |
179 | - // }, | |
180 | - // { | |
181 | - // field: 'sourceType', | |
182 | - // label: '动态源类型', | |
183 | - // colProps: { span: 24 }, | |
184 | - // component: 'Select', | |
185 | - // componentProps: { | |
186 | - // placeholder: '请选择动态源类型', | |
187 | - // options: [ | |
188 | - // { label: '无动态值', value: '' }, | |
189 | - // { label: '当前租户', value: 'CURRENT_TENANT' }, | |
190 | - // { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
191 | - // { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
192 | - // ], | |
193 | - // }, | |
194 | - // ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')), | |
195 | - // show: ({ values }) => { | |
196 | - // return !!values.field6; | |
197 | - // }, | |
198 | - // }, | |
199 | - // { | |
200 | - // field: 'sourceAttribute', | |
201 | - // label: '源属性', | |
202 | - // colProps: { span: 24 }, | |
203 | - // component: 'Input', | |
204 | - // componentProps: { | |
205 | - // placeholder: '源属性', | |
206 | - // }, | |
207 | - // ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')), | |
208 | - // show: ({ values }) => { | |
209 | - // return !!values.field6; | |
210 | - // }, | |
211 | - // }, | |
212 | - { | |
213 | - field: 'defaultValue', | |
214 | - label: '持续时间值', | |
215 | - colProps: { span: 13 }, | |
216 | - component: 'Input', | |
217 | - defaultValue: 0, | |
218 | - componentProps: { | |
219 | - maxLength: 16, | |
220 | - placeholder: '请输入持续时间值(请输入数字)', | |
221 | - }, | |
222 | - dynamicRules: () => { | |
223 | - return [ | |
224 | - { | |
225 | - validator: (_, value) => { | |
226 | - if (!value) { | |
227 | - return Promise.reject('持续时间值不能为空'); | |
228 | - } | |
229 | - const pwdRegex = new RegExp(/-?\d+/); | |
230 | - if (!pwdRegex.test(value)) { | |
231 | - return Promise.reject('只能为数字,且最长不超过16位'); | |
232 | - } | |
233 | - return Promise.resolve(); | |
234 | - }, | |
235 | - }, | |
236 | - ]; | |
237 | - }, | |
238 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')), | |
239 | - show: ({ values }) => { | |
240 | - return !values.field5; | |
241 | - }, | |
242 | - }, | |
243 | - // { | |
244 | - // field: 'field5', | |
245 | - // component: 'Switch', | |
246 | - // label: '切换到动态值', | |
247 | - // colProps: { | |
248 | - // span: 8, | |
249 | - // }, | |
250 | - // labelWidth: 200, | |
251 | - // ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')), | |
252 | - // }, | |
253 | - // { | |
254 | - // field: 'field6', | |
255 | - // component: 'Switch', | |
256 | - // label: '切换到动态值', | |
257 | - // colProps: { | |
258 | - // span: 8, | |
259 | - // }, | |
260 | - // labelWidth: 200, | |
261 | - // ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')), | |
262 | - // }, | |
263 | - { | |
264 | - field: 'unit', | |
265 | - label: '时间单位', | |
266 | - colProps: { span: 13 }, | |
267 | - component: 'Select', | |
268 | - componentProps: { | |
269 | - placeholder: '请选择时间单位', | |
270 | - options: [ | |
271 | - { label: '秒', value: 'SECONDS' }, | |
272 | - { label: '分钟', value: 'MINUTES' }, | |
273 | - { label: '小时', value: 'HOURS' }, | |
274 | - { label: '天', value: 'DAYS' }, | |
275 | - ], | |
276 | - }, | |
277 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'conditionType')), | |
278 | - }, | |
279 | - { | |
280 | - field: 'defaultValue', | |
281 | - label: '事件计数值必填', | |
282 | - colProps: { span: 13 }, | |
283 | - component: 'Input', | |
284 | - componentProps: { | |
285 | - maxLength: 2147483637, | |
286 | - placeholder: '请输入事件计数值(应在1到2147483637之间)', | |
287 | - }, | |
288 | - dynamicRules: () => { | |
289 | - return [ | |
290 | - { | |
291 | - validator: (_, value) => { | |
292 | - if (!value) { | |
293 | - return Promise.reject('事件计数不能为空'); | |
294 | - } | |
295 | - const pwdRegex = new RegExp(/-?\d+/); | |
296 | - if (!pwdRegex.test(value)) { | |
297 | - return Promise.reject('只能为数字,且最长不超过16位'); | |
298 | - } | |
299 | - return Promise.resolve(); | |
300 | - }, | |
301 | - }, | |
302 | - ]; | |
303 | - }, | |
304 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'conditionType')), | |
305 | - show: ({ values }) => { | |
306 | - return !values.field6; | |
307 | - }, | |
308 | - }, | |
309 | - { | |
310 | - field: 'inherit', | |
311 | - label: '', | |
312 | - colProps: { span: 13 }, | |
313 | - component: 'Checkbox', | |
314 | - renderComponentContent: 'Inherit from owner', | |
315 | - ifShow: ({ values }) => | |
316 | - isCurrentCus(Reflect.get(values, 'sourceType')) || | |
317 | - isCurrentDev(Reflect.get(values, 'sourceType')), | |
318 | - }, | |
319 | -]; |
src/views/device/profiles/step/cpns/alarmruleconditions/cpns/config.ts
deleted
100644 → 0
1 | -import { FormSchema } from '/@/components/Table'; | |
2 | -import { ref } from 'vue'; | |
3 | - | |
4 | -export const isWhereType: any = ref(null); | |
5 | - | |
6 | -/** | |
7 | - * 所使用的枚举值 | |
8 | - */ | |
9 | - | |
10 | -export enum TriggerEnum { | |
11 | - IS_DEVICE_ACT = '属性', | |
12 | - IS_TIME_ACT = 'TIME_SERIES', | |
13 | - IS_SCENE_ACT = '常量', | |
14 | - IS_STRING = 'STRING', | |
15 | - IS_NUMERIC = 'NUMERIC', | |
16 | - IS_BOOLEAN = 'BOOLEAN', | |
17 | - IS_COMPLEX = 'COMPLEX', | |
18 | -} | |
19 | - | |
20 | -export const isShiDu = (type: string) => { | |
21 | - return type === TriggerEnum.IS_DEVICE_ACT; | |
22 | -}; | |
23 | -export const isWenDu = (type: string) => { | |
24 | - return type === TriggerEnum.IS_TIME_ACT; | |
25 | -}; | |
26 | - | |
27 | -export const isTimeAll = (type: string) => { | |
28 | - return type === TriggerEnum.IS_SCENE_ACT; | |
29 | -}; | |
30 | - | |
31 | -export const isString = (type: string) => { | |
32 | - return type === TriggerEnum.IS_STRING; | |
33 | -}; | |
34 | - | |
35 | -export const isNumeric = (type: string) => { | |
36 | - return type === TriggerEnum.IS_NUMERIC; | |
37 | -}; | |
38 | - | |
39 | -export const isBoolean = (type: string) => { | |
40 | - return type === TriggerEnum.IS_BOOLEAN; | |
41 | -}; | |
42 | - | |
43 | -export const isComplex = (type: string) => { | |
44 | - return type === TriggerEnum.IS_COMPLEX; | |
45 | -}; | |
46 | - | |
47 | -export const formSchema: FormSchema[] = [ | |
48 | - { | |
49 | - field: 'id', | |
50 | - label: '', | |
51 | - component: 'InputNumber', | |
52 | - ifShow: false, | |
53 | - }, | |
54 | - { | |
55 | - field: 'type', | |
56 | - label: '键类型', | |
57 | - colProps: { span: 13 }, | |
58 | - component: 'Select', | |
59 | - componentProps: { | |
60 | - placeholder: '请选择键类型', | |
61 | - options: [ | |
62 | - { label: '属性', value: '属性' }, | |
63 | - { label: 'Timeseries', value: 'TIME_SERIES' }, | |
64 | - { label: '常量', value: '常量' }, | |
65 | - ], | |
66 | - }, | |
67 | - }, | |
68 | - { | |
69 | - field: 'key1', | |
70 | - label: '键名', | |
71 | - colProps: { span: 13 }, | |
72 | - component: 'Input', | |
73 | - componentProps: { | |
74 | - maxLength: 255, | |
75 | - placeholder: '请输入键名', | |
76 | - }, | |
77 | - | |
78 | - ifShow: ({ values }) => isShiDu(Reflect.get(values, 'type')), | |
79 | - }, | |
80 | - { | |
81 | - field: 'key1', | |
82 | - label: '键名', | |
83 | - colProps: { span: 13 }, | |
84 | - component: 'Input', | |
85 | - componentProps: { | |
86 | - maxLength: 255, | |
87 | - placeholder: '请输入键名', | |
88 | - }, | |
89 | - | |
90 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), | |
91 | - }, | |
92 | - { | |
93 | - field: 'key1', | |
94 | - label: '键名', | |
95 | - colProps: { span: 13 }, | |
96 | - component: 'Input', | |
97 | - componentProps: { | |
98 | - maxLength: 255, | |
99 | - placeholder: '请输入键名', | |
100 | - }, | |
101 | - | |
102 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
103 | - }, | |
104 | - { | |
105 | - field: 'type1', | |
106 | - label: '值类型', | |
107 | - colProps: { span: 13 }, | |
108 | - component: 'Select', | |
109 | - componentProps: { | |
110 | - placeholder: '请选择值类型', | |
111 | - options: [ | |
112 | - { label: '字符串', value: 'STRING' }, | |
113 | - { label: '数字', value: 'NUMERIC' }, | |
114 | - { label: '布尔值', value: 'BOOLEAN' }, | |
115 | - { label: '日期时间', value: 'COMPLEX' }, | |
116 | - ], | |
117 | - onChange: (v) => { | |
118 | - isWhereType.value = v; | |
119 | - }, | |
120 | - }, | |
121 | - }, | |
122 | - { | |
123 | - field: 'operation', | |
124 | - label: '操作', | |
125 | - colProps: { span: 13 }, | |
126 | - component: 'Select', | |
127 | - componentProps: { | |
128 | - placeholder: '请选择操作', | |
129 | - options: [ | |
130 | - { label: '等于', value: 'EQUAL' }, | |
131 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
132 | - { label: '开始于', value: 'STARTS_WITH' }, | |
133 | - { label: '结束于', value: 'ENDS_WITH' }, | |
134 | - { label: '包含', value: 'CONTAINS' }, | |
135 | - { label: '不包含', value: 'NOT_CONTAINS' }, | |
136 | - ], | |
137 | - }, | |
138 | - ifShow: ({ values }) => isString(Reflect.get(values, 'type1')), | |
139 | - }, | |
140 | - { | |
141 | - field: 'no', | |
142 | - label: '大小写', | |
143 | - component: 'Checkbox', | |
144 | - colProps: { span: 13 }, | |
145 | - renderComponentContent: '忽略大小写', | |
146 | - ifShow: ({ values }) => isString(Reflect.get(values, 'type1')), | |
147 | - }, | |
148 | - // { | |
149 | - // field: 'sourceType', | |
150 | - // label: '动态源类型', | |
151 | - // colProps: { span: 24 }, | |
152 | - // component: 'Select', | |
153 | - // componentProps: { | |
154 | - // placeholder: '请选择动态源类型', | |
155 | - // options: [ | |
156 | - // { label: '无动态值', value: '' }, | |
157 | - // { label: '当前租户', value: 'CURRENT_TENANT' }, | |
158 | - // { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
159 | - // { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
160 | - // ], | |
161 | - // }, | |
162 | - // ifShow: ({ values }) => isString(Reflect.get(values, 'type1')), | |
163 | - // show: ({ values }) => { | |
164 | - // return !!values.field5; | |
165 | - // }, | |
166 | - // }, | |
167 | - // { | |
168 | - // field: 'sourceAttribute', | |
169 | - // label: '源属性', | |
170 | - // colProps: { span: 24 }, | |
171 | - // component: 'Input', | |
172 | - // componentProps: { | |
173 | - // placeholder: '请输入源属性', | |
174 | - // }, | |
175 | - // ifShow: ({ values }) => isString(Reflect.get(values, 'type1')), | |
176 | - // show: ({ values }) => { | |
177 | - // return !!values.field5; | |
178 | - // }, | |
179 | - // }, | |
180 | - { | |
181 | - field: 'value1', | |
182 | - label: '默认值', | |
183 | - colProps: { span: 13 }, | |
184 | - component: 'InputNumber', | |
185 | - defaultValue: 0, | |
186 | - componentProps: { | |
187 | - maxLength: 16, | |
188 | - placeholder: '请输入值(数字)', | |
189 | - }, | |
190 | - dynamicRules: () => { | |
191 | - return [ | |
192 | - { | |
193 | - validator: (_, value) => { | |
194 | - if (!value) { | |
195 | - return Promise.reject('默认值不能为空'); | |
196 | - } | |
197 | - const pwdRegex = new RegExp(/-?\d+/); | |
198 | - if (!pwdRegex.test(value)) { | |
199 | - return Promise.reject('只能为数字,且最长不超过16位'); | |
200 | - } | |
201 | - return Promise.resolve(); | |
202 | - }, | |
203 | - }, | |
204 | - ]; | |
205 | - }, | |
206 | - ifShow: ({ values }) => isString(Reflect.get(values, 'type1')), | |
207 | - show: ({ values }) => { | |
208 | - return !values.field5; | |
209 | - }, | |
210 | - }, | |
211 | - // { | |
212 | - // field: 'field5', | |
213 | - // component: 'Switch', | |
214 | - // label: '切换到动态值', | |
215 | - // colProps: { | |
216 | - // span: 8, | |
217 | - // }, | |
218 | - // labelWidth: 200, | |
219 | - // ifShow: ({ values }) => isString(Reflect.get(values, 'type1')), | |
220 | - // }, | |
221 | - { | |
222 | - field: 'operation', | |
223 | - label: '操作', | |
224 | - colProps: { span: 13 }, | |
225 | - component: 'Select', | |
226 | - componentProps: { | |
227 | - placeholder: '请选择操作', | |
228 | - options: [ | |
229 | - { label: '等于', value: 'EQUAL' }, | |
230 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
231 | - { label: '大于', value: 'GREATER' }, | |
232 | - { label: '小于', value: 'LESS' }, | |
233 | - { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
234 | - { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
235 | - ], | |
236 | - }, | |
237 | - ifShow: ({ values }) => isNumeric(Reflect.get(values, 'type1')), | |
238 | - }, | |
239 | - | |
240 | - // { | |
241 | - // field: 'sourceType', | |
242 | - // label: '动态源类型', | |
243 | - // colProps: { span: 24 }, | |
244 | - // component: 'Select', | |
245 | - // componentProps: { | |
246 | - // placeholder: '请选择动态源类型', | |
247 | - // options: [ | |
248 | - // { label: '无动态值', value: '' }, | |
249 | - // { label: '当前租户', value: 'CURRENT_TENANT' }, | |
250 | - // { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
251 | - // { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
252 | - // ], | |
253 | - // }, | |
254 | - // ifShow: ({ values }) => isNumeric(Reflect.get(values, 'type1')), | |
255 | - // show: ({ values }) => { | |
256 | - // return !!values.field6; | |
257 | - // }, | |
258 | - // }, | |
259 | - // { | |
260 | - // field: 'sourceAttribute', | |
261 | - // label: '源属性', | |
262 | - // colProps: { span: 24 }, | |
263 | - // component: 'Input', | |
264 | - // componentProps: { | |
265 | - // placeholder: '请输入源属性', | |
266 | - // }, | |
267 | - // ifShow: ({ values }) => isNumeric(Reflect.get(values, 'type1')), | |
268 | - // show: ({ values }) => { | |
269 | - // return !!values.field6; | |
270 | - // }, | |
271 | - // }, | |
272 | - { | |
273 | - field: 'value1', | |
274 | - label: '值', | |
275 | - colProps: { span: 13 }, | |
276 | - component: 'InputNumber', | |
277 | - defaultValue: 0, | |
278 | - componentProps: { | |
279 | - placeholder: '请输入值(数字)', | |
280 | - }, | |
281 | - dynamicRules: () => { | |
282 | - return [ | |
283 | - { | |
284 | - validator: (_, value) => { | |
285 | - if (!value) { | |
286 | - return Promise.reject('值'); | |
287 | - } | |
288 | - const pwdRegex = new RegExp(/-?\d+/); | |
289 | - if (!pwdRegex.test(value)) { | |
290 | - return Promise.reject('只能为数字,且最长不超过16位'); | |
291 | - } | |
292 | - return Promise.resolve(); | |
293 | - }, | |
294 | - }, | |
295 | - ]; | |
296 | - }, | |
297 | - ifShow: ({ values }) => isNumeric(Reflect.get(values, 'type1')), | |
298 | - show: ({ values }) => { | |
299 | - return !values.field6; | |
300 | - }, | |
301 | - }, | |
302 | - // { | |
303 | - // field: 'field6', | |
304 | - // component: 'Switch', | |
305 | - // label: '切换到动态值', | |
306 | - // colProps: { | |
307 | - // span: 8, | |
308 | - // }, | |
309 | - // labelWidth: 200, | |
310 | - // ifShow: ({ values }) => isNumeric(Reflect.get(values, 'type1')), | |
311 | - // }, | |
312 | - | |
313 | - { | |
314 | - field: 'operation', | |
315 | - label: '操作', | |
316 | - colProps: { span: 13 }, | |
317 | - component: 'Select', | |
318 | - componentProps: { | |
319 | - placeholder: '请选择操作', | |
320 | - options: [ | |
321 | - { label: '等于', value: 'EQUAL' }, | |
322 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
323 | - ], | |
324 | - }, | |
325 | - ifShow: ({ values }) => isBoolean(Reflect.get(values, 'type1')), | |
326 | - }, | |
327 | - { | |
328 | - field: 'no', | |
329 | - label: '默认值', | |
330 | - colProps: { span: 13 }, | |
331 | - component: 'Checkbox', | |
332 | - renderComponentContent: '真', | |
333 | - ifShow: ({ values }) => isBoolean(Reflect.get(values, 'type1')), | |
334 | - show: ({ values }) => { | |
335 | - return !values.field7; | |
336 | - }, | |
337 | - }, | |
338 | - // { | |
339 | - // field: 'field7', | |
340 | - // component: 'Switch', | |
341 | - // label: '切换到动态值', | |
342 | - // colProps: { | |
343 | - // span: 8, | |
344 | - // }, | |
345 | - // labelWidth: 200, | |
346 | - // ifShow: ({ values }) => isBoolean(Reflect.get(values, 'type1')), | |
347 | - // }, | |
348 | - // { | |
349 | - // field: 'sourceType', | |
350 | - // label: '动态源类型', | |
351 | - // colProps: { span: 24 }, | |
352 | - // component: 'Select', | |
353 | - // componentProps: { | |
354 | - // placeholder: '请选择动态源类型', | |
355 | - // options: [ | |
356 | - // { label: '无动态值', value: '' }, | |
357 | - // { label: '当前租户', value: 'CURRENT_TENANT' }, | |
358 | - // { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
359 | - // { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
360 | - // ], | |
361 | - // }, | |
362 | - // ifShow: ({ values }) => isBoolean(Reflect.get(values, 'type1')), | |
363 | - // show: ({ values }) => { | |
364 | - // return !!values.field7; | |
365 | - // }, | |
366 | - // }, | |
367 | - // { | |
368 | - // field: 'sourceAttribute', | |
369 | - // label: '源属性', | |
370 | - // colProps: { span: 24 }, | |
371 | - // component: 'Input', | |
372 | - // componentProps: { | |
373 | - // placeholder: '请输入源属性', | |
374 | - // }, | |
375 | - // ifShow: ({ values }) => isBoolean(Reflect.get(values, 'type1')), | |
376 | - // show: ({ values }) => { | |
377 | - // return !!values.field7; | |
378 | - // }, | |
379 | - // }, | |
380 | - { | |
381 | - field: 'operation', | |
382 | - label: '操作', | |
383 | - colProps: { span: 13 }, | |
384 | - component: 'Select', | |
385 | - componentProps: { | |
386 | - placeholder: '请选择操作', | |
387 | - options: [ | |
388 | - { label: '等于', value: 'EQUAL' }, | |
389 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
390 | - { label: '大于', value: 'GREATER' }, | |
391 | - { label: '小于', value: 'LESS' }, | |
392 | - { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
393 | - { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
394 | - ], | |
395 | - }, | |
396 | - ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')), | |
397 | - }, | |
398 | - { | |
399 | - field: 'no', | |
400 | - component: 'DatePicker', | |
401 | - label: '请选择日期', | |
402 | - colProps: { | |
403 | - span: 13, | |
404 | - }, | |
405 | - ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')), | |
406 | - show: ({ values }) => { | |
407 | - return !values.field8; | |
408 | - }, | |
409 | - }, | |
410 | - { | |
411 | - field: 'no', | |
412 | - component: 'TimePicker', | |
413 | - label: '请选择时间', | |
414 | - colProps: { | |
415 | - span: 13, | |
416 | - }, | |
417 | - ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')), | |
418 | - show: ({ values }) => { | |
419 | - return !values.field8; | |
420 | - }, | |
421 | - }, | |
422 | - // { | |
423 | - // field: 'field8', | |
424 | - // component: 'Switch', | |
425 | - // label: '切换到动态值', | |
426 | - // colProps: { | |
427 | - // span: 8, | |
428 | - // }, | |
429 | - // labelWidth: 200, | |
430 | - // ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')), | |
431 | - // }, | |
432 | - // { | |
433 | - // field: 'sourceType', | |
434 | - // label: '动态源类型', | |
435 | - // colProps: { span: 24 }, | |
436 | - // component: 'Select', | |
437 | - // componentProps: { | |
438 | - // placeholder: '请选择动态源类型', | |
439 | - // options: [ | |
440 | - // { label: '无动态值', value: '' }, | |
441 | - // { label: '当前租户', value: 'CURRENT_TENANT' }, | |
442 | - // { label: '当前客户', value: 'CURRENT_CUSTOMER' }, | |
443 | - // { label: '当前设备', value: 'CURRENT_DEVICE' }, | |
444 | - // ], | |
445 | - // }, | |
446 | - // ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')), | |
447 | - // show: ({ values }) => { | |
448 | - // return !!values.field8; | |
449 | - // }, | |
450 | - // }, | |
451 | - // { | |
452 | - // field: 'sourceAttribute', | |
453 | - // label: '源属性', | |
454 | - // colProps: { span: 24 }, | |
455 | - // component: 'Input', | |
456 | - // componentProps: { | |
457 | - // placeholder: '请输入源属性', | |
458 | - // }, | |
459 | - // ifShow: ({ values }) => isComplex(Reflect.get(values, 'type1')), | |
460 | - // show: ({ values }) => { | |
461 | - // return !!values.field8; | |
462 | - // }, | |
463 | - // }, | |
464 | - // { | |
465 | - // field: 'value1', | |
466 | - // label: '默认值', | |
467 | - // colProps: { span: 24 }, | |
468 | - // component: 'Input', | |
469 | - // componentProps: { | |
470 | - // placeholder: '请输入默认值(数字)', | |
471 | - // }, | |
472 | - // }, | |
473 | -]; |
src/views/device/profiles/step/cpns/alarmruleconditions/cpns/cpns/config.ts
deleted
100644 → 0
1 | -import { FormSchema } from '/@/components/Table'; | |
2 | - | |
3 | -export const formSchema: FormSchema[] = [ | |
4 | - { | |
5 | - field: 'type', | |
6 | - label: '操作', | |
7 | - colProps: { span: 24 }, | |
8 | - component: 'Select', | |
9 | - componentProps: { | |
10 | - placeholder: '请选择操作', | |
11 | - options: [ | |
12 | - { label: '和', value: '和' }, | |
13 | - { label: '或', value: '或' }, | |
14 | - ], | |
15 | - }, | |
16 | - }, | |
17 | -]; |
src/views/device/profiles/step/cpns/alarmruleconditions/cpns/cpns/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <BasicModal | |
3 | - v-bind="$attrs" | |
4 | - width="55rem" | |
5 | - @register="registerAdd" | |
6 | - :title="getTitle" | |
7 | - @ok="handleSubmit" | |
8 | - @cancel="handleCancel" | |
9 | - > | |
10 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | |
11 | - </BasicModal> | |
12 | -</template> | |
13 | -<script lang="ts"> | |
14 | - import { defineComponent, ref, computed, unref } from 'vue'; | |
15 | - import { BasicModal, useModalInner } from '/@/components/Modal'; | |
16 | - import { BasicForm, useForm } from '/@/components/Form'; | |
17 | - import { formSchema } from './config'; | |
18 | - | |
19 | - export default defineComponent({ | |
20 | - name: 'index', | |
21 | - components: { BasicModal, BasicForm }, | |
22 | - emits: ['success', 'register'], | |
23 | - setup(_, { emit }) { | |
24 | - const isUpdate = ref(true); | |
25 | - const getValue: any = ref({}); | |
26 | - const setId: any = ref(1); | |
27 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增复合筛选器' : '编辑复合筛选器')); | |
28 | - const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ | |
29 | - labelWidth: 120, | |
30 | - schemas: formSchema, | |
31 | - }); | |
32 | - const [registerAdd, { closeModal }] = useModalInner(async (data) => { | |
33 | - isUpdate.value = !!data?.isUpdate; | |
34 | - if (!unref(isUpdate)) { | |
35 | - resetFields(); | |
36 | - } | |
37 | - if (unref(isUpdate)) { | |
38 | - setFieldsValue({ | |
39 | - ...data.record, | |
40 | - }); | |
41 | - } | |
42 | - }); | |
43 | - const handleSubmit = () => { | |
44 | - if (!unref(isUpdate)) { | |
45 | - getValue.value = getFieldsValue(); | |
46 | - setId.value += 1; | |
47 | - getValue.value.id = setId.value; | |
48 | - } else { | |
49 | - getValue.value = getFieldsValue(); | |
50 | - setId.value += 1000; | |
51 | - getValue.value.id = setId.value; | |
52 | - } | |
53 | - emit('success', getValue.value); | |
54 | - closeModal(); | |
55 | - }; | |
56 | - const handleCancel = () => { | |
57 | - return; | |
58 | - }; | |
59 | - return { | |
60 | - registerForm, | |
61 | - handleCancel, | |
62 | - handleSubmit, | |
63 | - registerAdd, | |
64 | - getTitle, | |
65 | - }; | |
66 | - }, | |
67 | - }); | |
68 | -</script> |
src/views/device/profiles/step/cpns/alarmruleconditions/cpns/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <BasicModal | |
3 | - v-bind="$attrs" | |
4 | - width="55rem" | |
5 | - @register="register" | |
6 | - :title="getTitle" | |
7 | - @ok="handleSubmit" | |
8 | - @cancel="handleCancel" | |
9 | - > | |
10 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | |
11 | - <template v-if="getIsWhereType"> | |
12 | - <div><p style="text-align: center">未配置筛选器</p></div> | |
13 | - <!-- <div><p style="text-align: left">筛选器</p></div> --> | |
14 | - <div style="width: 50vw; height: 5vh; display: flex; justify-content: space-between"> | |
15 | - <div style="width: 5vw; height: 2vh"> | |
16 | - <p v-for="(item, index) in n" :key="index"></p> | |
17 | - </div> | |
18 | - <div style="width: 45vw; height: 2vh"> | |
19 | - <BasicForm :showActionButtonGroup="false" @register="registerFilter"> | |
20 | - <template #add="{ field }"> | |
21 | - <!-- <Button v-if="Number(field) === 0" @click="add">添加</Button> --> | |
22 | - <Button v-if="Number(field) === 0" disabled @click="handleAdd">添加复合器</Button> | |
23 | - <!-- <Button v-if="Number(field) === 0" @click="handleEdit">编辑复合器</Button> --> | |
24 | - <Button v-if="field > 0" @click="del(field)">-</Button> | |
25 | - </template> | |
26 | - </BasicForm> | |
27 | - </div> | |
28 | - </div> | |
29 | - <AddkeyValueModal @register="registerModal" /> | |
30 | - </template> | |
31 | - </BasicModal> | |
32 | -</template> | |
33 | -<script lang="ts"> | |
34 | - import { defineComponent, ref, computed, unref, watch } from 'vue'; | |
35 | - import { BasicModal, useModalInner } from '/@/components/Modal'; | |
36 | - import { useModal } from '/@/components/Modal'; | |
37 | - import { BasicForm, useForm } from '/@/components/Form'; | |
38 | - import { formSchema, isWhereType } from './config'; | |
39 | - import { Button } from '/@/components/Button'; | |
40 | - import AddkeyValueModal from './cpns/index.vue'; | |
41 | - | |
42 | - export default defineComponent({ | |
43 | - name: 'index', | |
44 | - components: { BasicModal, BasicForm, Button, AddkeyValueModal }, | |
45 | - emits: ['success', 'register'], | |
46 | - setup(_, { emit }) { | |
47 | - const getIsWhereType: any = ref(null); | |
48 | - const isUpdate = ref(true); | |
49 | - const getValue: any = ref(null); | |
50 | - const getKeyAndValArr = ref<[]>([]); | |
51 | - | |
52 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增键名筛选器' : '编辑键名筛选器')); | |
53 | - const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ | |
54 | - labelWidth: 120, | |
55 | - schemas: formSchema, | |
56 | - }); | |
57 | - const [registerFilter, { appendSchemaByField, removeSchemaByFiled }] = useForm({ | |
58 | - // schemas: [ | |
59 | - // { | |
60 | - // field: 'field0a', | |
61 | - // component: 'Input', | |
62 | - // label: '字段0', | |
63 | - // colProps: { | |
64 | - // span: 8, | |
65 | - // }, | |
66 | - // required: true, | |
67 | - // }, | |
68 | - // { | |
69 | - // field: 'field0b', | |
70 | - // component: 'Input', | |
71 | - // label: '字段0', | |
72 | - // colProps: { | |
73 | - // span: 8, | |
74 | - // }, | |
75 | - // required: true, | |
76 | - // }, | |
77 | - // { | |
78 | - // field: '0', | |
79 | - // component: 'Input', | |
80 | - // label: ' ', | |
81 | - // colProps: { | |
82 | - // span: 8, | |
83 | - // }, | |
84 | - // slot: 'add', | |
85 | - // }, | |
86 | - // ], | |
87 | - labelWidth: 100, | |
88 | - actionColOptions: { span: 24 }, | |
89 | - }); | |
90 | - const [register, { closeModal }] = useModalInner(async (data) => { | |
91 | - isUpdate.value = !!data?.isUpdate; | |
92 | - if (!unref(isUpdate)) { | |
93 | - resetFields(); | |
94 | - getIsWhereType.value = 100; | |
95 | - } | |
96 | - if (unref(isUpdate)) { | |
97 | - setFieldsValue({ | |
98 | - ...data.record, | |
99 | - }); | |
100 | - } | |
101 | - }); | |
102 | - | |
103 | - const handleSubmit = () => { | |
104 | - let mapGetKeyAndValArr = []; | |
105 | - getValue.value = getFieldsValue(); | |
106 | - if (!unref(isUpdate)) { | |
107 | - getKeyAndValArr.value.push(getValue.value); | |
108 | - } | |
109 | - mapGetKeyAndValArr = getKeyAndValArr.value.map((m: any, index) => { | |
110 | - return { | |
111 | - key: { | |
112 | - id: index, | |
113 | - type: m.type, | |
114 | - key: m.key1, | |
115 | - }, | |
116 | - valueType: m.type1, | |
117 | - value: m.value1, | |
118 | - predicate: { | |
119 | - type: m.type1, | |
120 | - operation: m.operation, | |
121 | - value: { | |
122 | - defaultValue: m.value1, | |
123 | - }, | |
124 | - }, | |
125 | - }; | |
126 | - }); | |
127 | - if (!unref(isUpdate)) { | |
128 | - getValue.value.id = getKeyAndValArr.value.length - 1; | |
129 | - } | |
130 | - | |
131 | - emit('success', mapGetKeyAndValArr, getValue.value, unref(isUpdate)); | |
132 | - closeModal(); | |
133 | - }; | |
134 | - const handleCancel = () => { | |
135 | - return; | |
136 | - }; | |
137 | - const n = ref(1); | |
138 | - | |
139 | - function add() { | |
140 | - appendSchemaByField( | |
141 | - { | |
142 | - field: `field${n.value}a`, | |
143 | - component: 'Input', | |
144 | - label: '字段' + n.value, | |
145 | - colProps: { | |
146 | - span: 8, | |
147 | - }, | |
148 | - required: true, | |
149 | - }, | |
150 | - '' | |
151 | - ); | |
152 | - appendSchemaByField( | |
153 | - { | |
154 | - field: `field${n.value}b`, | |
155 | - component: 'Input', | |
156 | - label: '字段' + n.value, | |
157 | - colProps: { | |
158 | - span: 8, | |
159 | - }, | |
160 | - required: true, | |
161 | - }, | |
162 | - '' | |
163 | - ); | |
164 | - | |
165 | - appendSchemaByField( | |
166 | - { | |
167 | - field: `${n.value}`, | |
168 | - component: 'Input', | |
169 | - label: ' ', | |
170 | - colProps: { | |
171 | - span: 8, | |
172 | - }, | |
173 | - slot: 'add', | |
174 | - }, | |
175 | - '' | |
176 | - ); | |
177 | - n.value++; | |
178 | - } | |
179 | - | |
180 | - function del(field) { | |
181 | - removeSchemaByFiled([`field${field}a`, `field${field}b`, `${field}`]); | |
182 | - n.value--; | |
183 | - } | |
184 | - | |
185 | - watch(isWhereType, (v) => { | |
186 | - switch (v) { | |
187 | - case 'STRING': | |
188 | - getIsWhereType.value = v; | |
189 | - break; | |
190 | - case 'NUMERIC': | |
191 | - getIsWhereType.value = v; | |
192 | - break; | |
193 | - case 'BOOLEAN': | |
194 | - getIsWhereType.value = v; | |
195 | - break; | |
196 | - case 'COMPLEX': | |
197 | - getIsWhereType.value = v; | |
198 | - break; | |
199 | - default: | |
200 | - getIsWhereType.value = 100; | |
201 | - } | |
202 | - }); | |
203 | - const [registerModal, { openModal }] = useModal(); | |
204 | - //复合器弹窗 | |
205 | - const addPlusIfEdit = ref(1); | |
206 | - const handleAdd = () => { | |
207 | - openModal(true, { | |
208 | - isUpdate: false, | |
209 | - addPlusIfEdit: addPlusIfEdit.value++, | |
210 | - }); | |
211 | - }; | |
212 | - const handleEdit = () => { | |
213 | - openModal(true, { | |
214 | - isUpdate: true, | |
215 | - }); | |
216 | - }; | |
217 | - | |
218 | - return { | |
219 | - getIsWhereType, | |
220 | - registerModal, | |
221 | - handleEdit, | |
222 | - handleAdd, | |
223 | - n, | |
224 | - add, | |
225 | - del, | |
226 | - registerFilter, | |
227 | - registerForm, | |
228 | - handleCancel, | |
229 | - handleSubmit, | |
230 | - register, | |
231 | - getTitle, | |
232 | - }; | |
233 | - }, | |
234 | - }); | |
235 | -</script> |
src/views/device/profiles/step/cpns/alarmruleconditions/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div class="key-style"> | |
3 | - <BasicModal | |
4 | - v-bind="$attrs" | |
5 | - width="55rem" | |
6 | - @register="register" | |
7 | - :title="getTitle" | |
8 | - @ok="handleSubmit" | |
9 | - @cancel="handleCancel" | |
10 | - > | |
11 | - <CollapseContainer title="键名筛选器" class="border mb-8"> | |
12 | - <div class="table-style"> | |
13 | - <BasicTable | |
14 | - :showIndexColumn="false" | |
15 | - :dataSource="getTableApiData.value" | |
16 | - @register="registerTable" | |
17 | - > | |
18 | - <template #toolbar> | |
19 | - <a-button type="primary" @click="handleAddKey">新增键名筛选器</a-button> | |
20 | - </template> | |
21 | - <template #action="{ record }"> | |
22 | - <TableAction | |
23 | - :actions="[ | |
24 | - { | |
25 | - label: '编辑', | |
26 | - icon: 'clarity:note-edit-line', | |
27 | - onClick: handleEdit.bind(null, record), | |
28 | - }, | |
29 | - { | |
30 | - label: '删除', | |
31 | - icon: 'ant-design:delete-outlined', | |
32 | - color: 'error', | |
33 | - popConfirm: { | |
34 | - title: '是否确认删除', | |
35 | - confirm: handleDelete.bind(null, record), | |
36 | - }, | |
37 | - }, | |
38 | - ]" | |
39 | - /> | |
40 | - </template> | |
41 | - </BasicTable> | |
42 | - </div> | |
43 | - </CollapseContainer> | |
44 | - <!-- <CollapseContainer title="筛选器预览" class="border mb-8">--> | |
45 | - <!-- <!– <p v-for="(item, index) in detailData" :key="index">{{ item }}</p> –>--> | |
46 | - <!-- <Description--> | |
47 | - <!-- v-for="(item, index) in detailData"--> | |
48 | - <!-- :key="index"--> | |
49 | - <!-- :column="3"--> | |
50 | - <!-- :data="item"--> | |
51 | - <!-- :schema="schema"--> | |
52 | - <!-- />--> | |
53 | - <!-- </CollapseContainer>--> | |
54 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | |
55 | - </BasicModal> | |
56 | - <KeyValueModal @register="registerModal" @success="handleSuccess" /> | |
57 | - </div> | |
58 | -</template> | |
59 | -<script lang="ts"> | |
60 | - import { defineComponent, ref, computed, unref, reactive, nextTick } from 'vue'; | |
61 | - import { BasicModal } from '/@/components/Modal'; | |
62 | - import { BasicForm, useForm } from '/@/components/Form'; | |
63 | - import { formSchema, keyColumns, DescDetailSchema } from './config'; | |
64 | - import { CollapseContainer } from '/@/components/Container/index'; | |
65 | - import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |
66 | - import { useModal } from '/@/components/Modal'; | |
67 | - import KeyValueModal from './cpns/index.vue'; | |
68 | - import { Description, DescItem } from '/@/components/Description/index'; | |
69 | - const schema: DescItem[] = [ | |
70 | - { | |
71 | - field: 'key1', | |
72 | - label: '键名', | |
73 | - }, | |
74 | - { | |
75 | - field: 'operation', | |
76 | - label: '操作', | |
77 | - render: (_, data) => { | |
78 | - const findDay = [ | |
79 | - { label: '等于', value: 'EQUAL' }, | |
80 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
81 | - { label: '开始于', value: 'STARTS_WITH' }, | |
82 | - { label: '结束于', value: 'ENDS_WITH' }, | |
83 | - { label: '包含', value: 'CONTAINS' }, | |
84 | - { label: '不包含', value: 'NOT_CONTAINS' }, | |
85 | - { label: '等于', value: 'EQUAL' }, | |
86 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
87 | - { label: '大于', value: 'GREATER' }, | |
88 | - { label: '小于', value: 'LESS' }, | |
89 | - { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
90 | - { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
91 | - ]; | |
92 | - const findRuleByValue = findDay.find((f) => { | |
93 | - if (f.value == data.operation) { | |
94 | - return f.label; | |
95 | - } | |
96 | - }); | |
97 | - return findRuleByValue?.label; | |
98 | - }, | |
99 | - }, | |
100 | - { | |
101 | - field: 'value1', | |
102 | - label: '值', | |
103 | - }, | |
104 | - ]; | |
105 | - | |
106 | - export default defineComponent({ | |
107 | - name: 'DetailTemplate', | |
108 | - components: { | |
109 | - KeyValueModal, | |
110 | - BasicModal, | |
111 | - BasicForm, | |
112 | - CollapseContainer, | |
113 | - BasicTable, | |
114 | - TableAction, | |
115 | - Description, | |
116 | - }, | |
117 | - props: ['getFatherData'], | |
118 | - emits: ['success', 'register', 'getAllFieldsRule', 'getLastAllFieldsRule'], | |
119 | - setup(props, { emit }) { | |
120 | - let getKeyAndValueChildData = ref<[]>([]); | |
121 | - const getTableApiData: any = ref([]); | |
122 | - const detailData: any = ref([]); | |
123 | - const currentIndex = ref(0); | |
124 | - const lastValues: any = ref(null); | |
125 | - const isUpdate = ref(true); | |
126 | - const watchCurrentAlarmConditionValue = reactive({ | |
127 | - key: 0, | |
128 | - data: {}, | |
129 | - }); | |
130 | - | |
131 | - const [registerForm, { getFieldsValue, resetFields }] = useForm({ | |
132 | - labelWidth: 120, | |
133 | - schemas: formSchema, | |
134 | - }); | |
135 | - const [registerModal, { openModal }] = useModal(); | |
136 | - const getTitle = computed(() => (!unref(isUpdate) ? '添加报警规则条件' : '编辑报警规则条件')); | |
137 | - const [register, { closeModal, openModal: openCondition }] = useModal(); | |
138 | - const [registerTable, { reload, setTableData: setFunc }] = useTable({ | |
139 | - title: '键名筛选器', | |
140 | - columns: keyColumns, | |
141 | - bordered: true, | |
142 | - showIndexColumn: false, | |
143 | - pagination: false, | |
144 | - autoCreateKey: true, | |
145 | - actionColumn: { | |
146 | - width: 200, | |
147 | - title: '操作', | |
148 | - dataIndex: 'action', | |
149 | - slots: { customRender: 'action' }, | |
150 | - }, | |
151 | - }); | |
152 | - const getFieldsValueFunc = () => { | |
153 | - return watchCurrentAlarmConditionValue.data; | |
154 | - }; | |
155 | - const handleSubmit = () => { | |
156 | - lastValues.value = getFieldsValue(); | |
157 | - watchCurrentAlarmConditionValue.key = currentIndex.value; | |
158 | - let allTableDatas = []; | |
159 | - getTableApiData.value.forEach((tableObj) => { | |
160 | - let key = { type: tableObj.type, key: tableObj.key1 }; | |
161 | - let predicate = { | |
162 | - operation: tableObj.operation, | |
163 | - type: tableObj.type1, | |
164 | - value: { | |
165 | - defaultValue: tableObj.value1, | |
166 | - }, | |
167 | - }; | |
168 | - allTableDatas.push({ | |
169 | - key: key, | |
170 | - predicate: predicate, | |
171 | - value: tableObj.value1, | |
172 | - valueType: tableObj.type1, | |
173 | - }); | |
174 | - }); | |
175 | - watchCurrentAlarmConditionValue.data = allTableDatas; | |
176 | - emit('getAllFieldsRule', watchCurrentAlarmConditionValue, lastValues.value); | |
177 | - closeModal(); | |
178 | - }; | |
179 | - const resetDataFunc = (j, currentAlarmCondition, update) => { | |
180 | - isUpdate.value = update; | |
181 | - openCondition(true); | |
182 | - currentIndex.value = j; | |
183 | - resetFields(); | |
184 | - getTableApiData.value = []; | |
185 | - getTableApiData.value.length = 0; | |
186 | - detailData.value = []; | |
187 | - detailData.value.length = 0; | |
188 | - console.log('father', props.getFatherData); | |
189 | - let index = 0; | |
190 | - if (currentAlarmCondition.data.length != undefined) { | |
191 | - for (let i in currentAlarmCondition.data) { | |
192 | - let obj = { | |
193 | - id: index, | |
194 | - key1: currentAlarmCondition.data[i].key.key, | |
195 | - type: currentAlarmCondition.data[i].key.type, | |
196 | - operation: currentAlarmCondition.data[i].predicate.operation, | |
197 | - value1: currentAlarmCondition.data[i].value, | |
198 | - type1: currentAlarmCondition.data[i].valueType, | |
199 | - }; | |
200 | - getTableApiData.value.push(obj); | |
201 | - index++; | |
202 | - } | |
203 | - } | |
204 | - nextTick(() => { | |
205 | - setFunc(getTableApiData.value); | |
206 | - }); | |
207 | - }; | |
208 | - | |
209 | - const handleCancel = () => {}; | |
210 | - const handleAddKey = () => { | |
211 | - setTimeout(() => { | |
212 | - openModal(true, { | |
213 | - isUpdate: false, | |
214 | - }); | |
215 | - }, 10); | |
216 | - }; | |
217 | - const handleEdit = (record: Recordable) => { | |
218 | - openModal(true, { | |
219 | - isUpdate: true, | |
220 | - record, | |
221 | - }); | |
222 | - reload(); | |
223 | - }; | |
224 | - const handleDelete = (record: Recordable) => { | |
225 | - let newGetTableApiData = []; | |
226 | - getTableApiData.value.forEach((currentTable) => { | |
227 | - if (currentTable.id != record.id) { | |
228 | - newGetTableApiData.push(currentTable as never); | |
229 | - } | |
230 | - }); | |
231 | - getTableApiData.value = newGetTableApiData; | |
232 | - setFunc(getTableApiData.value); | |
233 | - reload(); | |
234 | - }; | |
235 | - const handleSuccess = (v, v1, isUpdate) => { | |
236 | - if (isUpdate) { | |
237 | - getTableApiData.value.forEach((tableValue) => { | |
238 | - if (tableValue.id == v1.id) { | |
239 | - tableValue.key1 = v1.key1; | |
240 | - tableValue.operation = v1.operation; | |
241 | - tableValue.type = v1.type; | |
242 | - tableValue.type1 = v1.type1; | |
243 | - tableValue.value1 = v1.value1; | |
244 | - } | |
245 | - }); | |
246 | - } else { | |
247 | - getTableApiData.value.push(v1); | |
248 | - } | |
249 | - getKeyAndValueChildData.value = v; | |
250 | - setFunc(getTableApiData.value); | |
251 | - reload(); | |
252 | - }; | |
253 | - return { | |
254 | - handleCancel, | |
255 | - schema, | |
256 | - detailData, | |
257 | - getTableApiData, | |
258 | - resetDataFunc, | |
259 | - DescDetailSchema, | |
260 | - handleSuccess, | |
261 | - handleEdit, | |
262 | - handleDelete, | |
263 | - registerModal, | |
264 | - registerTable, | |
265 | - handleAddKey, | |
266 | - registerForm, | |
267 | - handleSubmit, | |
268 | - register, | |
269 | - getTitle, | |
270 | - currentIndex, | |
271 | - getFieldsValueFunc, | |
272 | - }; | |
273 | - }, | |
274 | - }); | |
275 | -</script> | |
276 | -<style lang="less" scoped> | |
277 | - :deep .ant-table-body { | |
278 | - overflow-y: auto !important; | |
279 | - min-height: 90px !important; | |
280 | - height: 0px !important; | |
281 | - } | |
282 | -</style> |
src/views/device/profiles/step/cpns/alarmseverity/config.ts
deleted
100644 → 0
1 | -import { FormSchema } from '/@/components/Form'; | |
2 | -import { ref } from 'vue'; | |
3 | - | |
4 | -const isWhereType = ref(''); | |
5 | - | |
6 | -export const formSchema: FormSchema[] = [ | |
7 | - { | |
8 | - field: 'default', | |
9 | - component: 'Select', | |
10 | - label: '报警严重程度:', | |
11 | - required: true, | |
12 | - colProps: { | |
13 | - span: 17, | |
14 | - }, | |
15 | - componentProps() { | |
16 | - return { | |
17 | - placeholder: '请选择严重程度', | |
18 | - options: [ | |
19 | - { | |
20 | - value: 'CRITICAL', | |
21 | - label: '危险', | |
22 | - }, | |
23 | - { | |
24 | - value: 'MAJOR', | |
25 | - label: '重要', | |
26 | - }, | |
27 | - { | |
28 | - value: 'MINOR', | |
29 | - label: '次要', | |
30 | - }, | |
31 | - { | |
32 | - value: 'WARNING', | |
33 | - label: '警告', | |
34 | - }, | |
35 | - { | |
36 | - value: 'INDETERMINATE', | |
37 | - label: '不确定', | |
38 | - }, | |
39 | - ], | |
40 | - onChange: (v) => { | |
41 | - isWhereType.value = v ? v : 'INDETERMINATE'; | |
42 | - }, | |
43 | - }; | |
44 | - }, | |
45 | - }, | |
46 | -]; |
src/views/device/profiles/step/cpns/alarmseverity/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div> | |
3 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | |
4 | - </div> | |
5 | -</template> | |
6 | -<script lang="ts"> | |
7 | - import { defineComponent, ref } from 'vue'; | |
8 | - import { BasicForm, useForm } from '/@/components/Form'; | |
9 | - import { formSchema } from './config'; | |
10 | - | |
11 | - export default defineComponent({ | |
12 | - name: 'DetailTemplate', | |
13 | - components: { | |
14 | - BasicForm, | |
15 | - }, | |
16 | - props: ['AlarmSeverityCpnData'], | |
17 | - emits: ['success', 'register', 'getAllFields'], | |
18 | - setup(props) { | |
19 | - const fieldValue: any = ref({}); | |
20 | - const [registerForm, { resetFields, getFieldsValue, setFieldsValue, updateSchema }] = useForm( | |
21 | - { | |
22 | - labelWidth: 120, | |
23 | - schemas: formSchema, | |
24 | - } | |
25 | - ); | |
26 | - const resetFieldsFunc = () => { | |
27 | - resetFields(); | |
28 | - }; | |
29 | - const getFieldsValueFunc = () => { | |
30 | - fieldValue.value = getFieldsValue(); | |
31 | - return fieldValue.value; | |
32 | - }; | |
33 | - const item = [ | |
34 | - { | |
35 | - value: 'CRITICAL', | |
36 | - label: '危险', | |
37 | - }, | |
38 | - { | |
39 | - value: 'MAJOR', | |
40 | - label: '重要', | |
41 | - }, | |
42 | - { | |
43 | - value: 'MINOR', | |
44 | - label: '次要', | |
45 | - }, | |
46 | - { | |
47 | - value: 'WARNING', | |
48 | - label: '警告', | |
49 | - }, | |
50 | - { | |
51 | - value: 'INDETERMINATE', | |
52 | - label: '不确定', | |
53 | - }, | |
54 | - ]; | |
55 | - const updateSchemaSelectDisableFunc = () => { | |
56 | - updateSchema({ | |
57 | - field: 'default', | |
58 | - componentProps: ({ formModel }) => { | |
59 | - item.forEach((f: any) => { | |
60 | - if (f.value == formModel.default) { | |
61 | - f.disabled = true; | |
62 | - } | |
63 | - }); | |
64 | - return { | |
65 | - options: item, | |
66 | - }; | |
67 | - }, | |
68 | - }); | |
69 | - }; | |
70 | - const updateSchemaSelectEnableFunc = () => { | |
71 | - updateSchema({ | |
72 | - field: 'default', | |
73 | - componentProps: ({ formModel }) => { | |
74 | - console.log(formModel); | |
75 | - return { | |
76 | - disabled: false, | |
77 | - options: item, | |
78 | - }; | |
79 | - }, | |
80 | - }); | |
81 | - }; | |
82 | - const setFieldsValueFunc = () => { | |
83 | - if (props.AlarmSeverityCpnData != 1) { | |
84 | - let newArr = Object.keys(props.AlarmSeverityCpnData); | |
85 | - setTimeout(() => { | |
86 | - newArr.forEach((f) => { | |
87 | - setFieldsValue({ default: f }); | |
88 | - }); | |
89 | - }, 10); | |
90 | - } | |
91 | - }; | |
92 | - setFieldsValueFunc(); | |
93 | - return { | |
94 | - resetFieldsFunc, | |
95 | - updateSchemaSelectDisableFunc, | |
96 | - getFieldsValueFunc, | |
97 | - registerForm, | |
98 | - setFieldsValueFunc, | |
99 | - updateSchemaSelectEnableFunc, | |
100 | - item, | |
101 | - }; | |
102 | - }, | |
103 | - }); | |
104 | -</script> |
src/views/device/profiles/step/cpns/detailtemplate/config.ts
deleted
100644 → 0
1 | -import { FormSchema } from '/@/components/Table'; | |
2 | - | |
3 | -export const formSchema: FormSchema[] = [ | |
4 | - { | |
5 | - field: 'alarmDetails', | |
6 | - label: '报警详细信息:', | |
7 | - colProps: { span: 17 }, | |
8 | - component: 'Input', | |
9 | - componentProps: { | |
10 | - maxLength: 255, | |
11 | - placeholder: '请输入报警详细信息', | |
12 | - }, | |
13 | - }, | |
14 | -]; |
src/views/device/profiles/step/cpns/detailtemplate/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <div> | |
3 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | |
4 | - </div> | |
5 | -</template> | |
6 | -<script lang="ts"> | |
7 | - import { defineComponent, ref } from 'vue'; | |
8 | - import { BasicForm, useForm } from '/@/components/Form'; | |
9 | - import { formSchema } from './config'; | |
10 | - | |
11 | - export default defineComponent({ | |
12 | - name: 'DetailTemplate', | |
13 | - components: { | |
14 | - BasicForm, | |
15 | - }, | |
16 | - props: ['DetailTemplateCpnData'], | |
17 | - emits: ['success', 'register', 'getAllFields'], | |
18 | - setup(props) { | |
19 | - const fieldValue: any = ref({}); | |
20 | - const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ | |
21 | - labelWidth: 120, | |
22 | - schemas: formSchema, | |
23 | - }); | |
24 | - const getFieldsValueFunc = () => { | |
25 | - fieldValue.value = getFieldsValue(); | |
26 | - return fieldValue.value; | |
27 | - }; | |
28 | - const setFieldsValueFunc = () => { | |
29 | - if (props.DetailTemplateCpnData != 1) { | |
30 | - let openEditRuleConditObj: any = {}; | |
31 | - for (let i in props.DetailTemplateCpnData) { | |
32 | - if (i == 'CRITICAL') { | |
33 | - openEditRuleConditObj = props.DetailTemplateCpnData[i]; | |
34 | - } else if (i == 'MAJOR') { | |
35 | - openEditRuleConditObj = props.DetailTemplateCpnData[i]; | |
36 | - } else if (i == 'MINOR') { | |
37 | - openEditRuleConditObj = props.DetailTemplateCpnData[i]; | |
38 | - } else if (i == 'WARNING') { | |
39 | - openEditRuleConditObj = props.DetailTemplateCpnData[i]; | |
40 | - } else if (i == 'INDETERMINATE') { | |
41 | - openEditRuleConditObj = props.DetailTemplateCpnData[i]; | |
42 | - } | |
43 | - } | |
44 | - setTimeout(() => { | |
45 | - setFieldsValue({ | |
46 | - alarmDetails: openEditRuleConditObj?.alarmDetails, | |
47 | - }); | |
48 | - }, 10); | |
49 | - } | |
50 | - }; | |
51 | - setFieldsValueFunc(); | |
52 | - | |
53 | - const resetFieldsFunc = () => { | |
54 | - resetFields(); | |
55 | - }; | |
56 | - return { | |
57 | - resetFieldsFunc, | |
58 | - getFieldsValueFunc, | |
59 | - registerForm, | |
60 | - setFieldsValueFunc, | |
61 | - }; | |
62 | - }, | |
63 | - }); | |
64 | -</script> |
src/views/device/profiles/step/cpns/enablerule/config.ts
deleted
100644 → 0
1 | -import { FormSchema } from '/@/components/Table'; | |
2 | - | |
3 | -/** | |
4 | - * 所使用的枚举值 | |
5 | - */ | |
6 | - | |
7 | -export enum TriggerEnum { | |
8 | - IS_DEVICE_ACT = 'ANY_TIME', | |
9 | - IS_TIME_ACT = 'SPECIFIC_TIME', | |
10 | - IS_SCENE_ACT = 'CUSTOM', | |
11 | -} | |
12 | - | |
13 | -export const isShiDu = (type: string) => { | |
14 | - return type === TriggerEnum.IS_DEVICE_ACT; | |
15 | -}; | |
16 | -export const isWenDu = (type: string) => { | |
17 | - return type === TriggerEnum.IS_TIME_ACT; | |
18 | -}; | |
19 | - | |
20 | -export const isTimeAll = (type: string) => { | |
21 | - return type === TriggerEnum.IS_SCENE_ACT; | |
22 | -}; | |
23 | - | |
24 | -export const formSchema: FormSchema[] = [ | |
25 | - { | |
26 | - field: 'type', | |
27 | - label: '报警日程表', | |
28 | - colProps: { span: 12 }, | |
29 | - required: true, | |
30 | - component: 'Select', | |
31 | - defaultValue: 'ANY_TIME', | |
32 | - componentProps: { | |
33 | - placeholder: '请选择报警日程表', | |
34 | - options: [ | |
35 | - { label: '始终启用', value: 'ANY_TIME' }, | |
36 | - { label: '定时启用', value: 'SPECIFIC_TIME' }, | |
37 | - { label: '自定义启用', value: 'CUSTOM' }, | |
38 | - ], | |
39 | - }, | |
40 | - }, | |
41 | - { | |
42 | - field: 'timezone', | |
43 | - label: '时区', | |
44 | - colProps: { span: 12 }, | |
45 | - required: true, | |
46 | - component: 'Select', | |
47 | - defaultValue: 'Asia/Shanghai (UTC+08:00)', | |
48 | - componentProps: { | |
49 | - placeholder: '请选择时区', | |
50 | - options: [ | |
51 | - { label: 'Asia/Shanghai (UTC+08:00)', value: 'Asia/Shanghai' }, | |
52 | - { label: 'Africa/Accra (UTC+00:00)', value: 'Africa/Accra' }, | |
53 | - { label: 'Africa/Addis Ababa (UTC+03:00)', value: 'Africa/Addis Ababa' }, | |
54 | - { label: 'Africa/Asmara (UTC+03:00)', value: 'Africa/Asmara' }, | |
55 | - ], | |
56 | - }, | |
57 | - ifShow: ({ values }) => | |
58 | - isWenDu(Reflect.get(values, 'type')) || isTimeAll(Reflect.get(values, 'type')), | |
59 | - }, | |
60 | - | |
61 | - { | |
62 | - field: 'daysOfWeek1', | |
63 | - component: 'CheckboxGroup', | |
64 | - label: '天', | |
65 | - colProps: { | |
66 | - span: 8, | |
67 | - }, | |
68 | - componentProps: { | |
69 | - options: [ | |
70 | - { | |
71 | - label: '星期一', | |
72 | - value: '1', | |
73 | - }, | |
74 | - ], | |
75 | - }, | |
76 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
77 | - }, | |
78 | - { | |
79 | - field: 'startsOn1', | |
80 | - component: 'TimePicker', | |
81 | - label: '开始时间选择', | |
82 | - componentProps: { | |
83 | - valueFormat: 'HH:mm:ss', | |
84 | - }, | |
85 | - colProps: { | |
86 | - span: 8, | |
87 | - }, | |
88 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
89 | - }, | |
90 | - { | |
91 | - field: 'endsOn1', | |
92 | - component: 'TimePicker', | |
93 | - label: '结束时间选择', | |
94 | - componentProps: { | |
95 | - valueFormat: 'HH:mm:ss', | |
96 | - }, | |
97 | - colProps: { | |
98 | - span: 8, | |
99 | - }, | |
100 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
101 | - }, | |
102 | - | |
103 | - { | |
104 | - field: 'daysOfWeek2', | |
105 | - component: 'CheckboxGroup', | |
106 | - label: '天', | |
107 | - colProps: { | |
108 | - span: 8, | |
109 | - }, | |
110 | - componentProps: { | |
111 | - options: [ | |
112 | - { | |
113 | - label: '星期二', | |
114 | - value: '2', | |
115 | - }, | |
116 | - ], | |
117 | - }, | |
118 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
119 | - }, | |
120 | - { | |
121 | - field: 'startsOn2', | |
122 | - component: 'TimePicker', | |
123 | - label: '开始时间选择', | |
124 | - componentProps: { | |
125 | - valueFormat: 'HH:mm:ss', | |
126 | - }, | |
127 | - colProps: { | |
128 | - span: 8, | |
129 | - }, | |
130 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
131 | - }, | |
132 | - { | |
133 | - field: 'endsOn2', | |
134 | - component: 'TimePicker', | |
135 | - label: '结束时间选择', | |
136 | - componentProps: { | |
137 | - valueFormat: 'HH:mm:ss', | |
138 | - }, | |
139 | - colProps: { | |
140 | - span: 8, | |
141 | - }, | |
142 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
143 | - }, | |
144 | - { | |
145 | - field: 'daysOfWeek3', | |
146 | - component: 'CheckboxGroup', | |
147 | - label: '天', | |
148 | - colProps: { | |
149 | - span: 8, | |
150 | - }, | |
151 | - componentProps: { | |
152 | - options: [ | |
153 | - { | |
154 | - label: '星期三', | |
155 | - value: '3', | |
156 | - }, | |
157 | - ], | |
158 | - }, | |
159 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
160 | - }, | |
161 | - { | |
162 | - field: 'startsOn3', | |
163 | - component: 'TimePicker', | |
164 | - label: '开始时间选择', | |
165 | - componentProps: { | |
166 | - valueFormat: 'HH:mm:ss', | |
167 | - }, | |
168 | - colProps: { | |
169 | - span: 8, | |
170 | - }, | |
171 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
172 | - }, | |
173 | - { | |
174 | - field: 'endsOn3', | |
175 | - component: 'TimePicker', | |
176 | - label: '结束时间选择', | |
177 | - componentProps: { | |
178 | - valueFormat: 'HH:mm:ss', | |
179 | - }, | |
180 | - colProps: { | |
181 | - span: 8, | |
182 | - }, | |
183 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
184 | - }, | |
185 | - { | |
186 | - field: 'daysOfWeek4', | |
187 | - component: 'CheckboxGroup', | |
188 | - label: '天', | |
189 | - colProps: { | |
190 | - span: 8, | |
191 | - }, | |
192 | - componentProps: { | |
193 | - options: [ | |
194 | - { | |
195 | - label: '星期四', | |
196 | - value: '4', | |
197 | - }, | |
198 | - ], | |
199 | - }, | |
200 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
201 | - }, | |
202 | - { | |
203 | - field: 'startsOn4', | |
204 | - component: 'TimePicker', | |
205 | - label: '开始时间选择', | |
206 | - componentProps: { | |
207 | - valueFormat: 'HH:mm:ss', | |
208 | - }, | |
209 | - colProps: { | |
210 | - span: 8, | |
211 | - }, | |
212 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
213 | - }, | |
214 | - { | |
215 | - field: 'endsOn4', | |
216 | - component: 'TimePicker', | |
217 | - label: '结束时间选择', | |
218 | - componentProps: { | |
219 | - valueFormat: 'HH:mm:ss', | |
220 | - }, | |
221 | - colProps: { | |
222 | - span: 8, | |
223 | - }, | |
224 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
225 | - }, | |
226 | - { | |
227 | - field: 'daysOfWeek5', | |
228 | - component: 'CheckboxGroup', | |
229 | - label: '天', | |
230 | - colProps: { | |
231 | - span: 8, | |
232 | - }, | |
233 | - componentProps: { | |
234 | - options: [ | |
235 | - { | |
236 | - label: '星期五', | |
237 | - value: '5', | |
238 | - }, | |
239 | - ], | |
240 | - }, | |
241 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
242 | - }, | |
243 | - { | |
244 | - field: 'startsOn5', | |
245 | - component: 'TimePicker', | |
246 | - label: '开始时间选择', | |
247 | - componentProps: { | |
248 | - valueFormat: 'HH:mm:ss', | |
249 | - }, | |
250 | - colProps: { | |
251 | - span: 8, | |
252 | - }, | |
253 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
254 | - }, | |
255 | - { | |
256 | - field: 'endsOn5', | |
257 | - component: 'TimePicker', | |
258 | - label: '结束时间选择', | |
259 | - componentProps: { | |
260 | - valueFormat: 'HH:mm:ss', | |
261 | - }, | |
262 | - colProps: { | |
263 | - span: 8, | |
264 | - }, | |
265 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
266 | - }, | |
267 | - { | |
268 | - field: 'daysOfWeek6', | |
269 | - component: 'CheckboxGroup', | |
270 | - label: '天', | |
271 | - colProps: { | |
272 | - span: 8, | |
273 | - }, | |
274 | - componentProps: { | |
275 | - options: [ | |
276 | - { | |
277 | - label: '星期六', | |
278 | - value: '6', | |
279 | - }, | |
280 | - ], | |
281 | - }, | |
282 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
283 | - }, | |
284 | - { | |
285 | - field: 'startsOn6', | |
286 | - component: 'TimePicker', | |
287 | - label: '开始时间选择', | |
288 | - componentProps: { | |
289 | - valueFormat: 'HH:mm:ss', | |
290 | - }, | |
291 | - colProps: { | |
292 | - span: 8, | |
293 | - }, | |
294 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
295 | - }, | |
296 | - { | |
297 | - field: 'endsOn6', | |
298 | - component: 'TimePicker', | |
299 | - label: '结束时间选择', | |
300 | - componentProps: { | |
301 | - valueFormat: 'HH:mm:ss', | |
302 | - }, | |
303 | - colProps: { | |
304 | - span: 8, | |
305 | - }, | |
306 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
307 | - }, | |
308 | - { | |
309 | - field: 'daysOfWeek7', | |
310 | - component: 'CheckboxGroup', | |
311 | - label: '天', | |
312 | - colProps: { | |
313 | - span: 8, | |
314 | - }, | |
315 | - componentProps: { | |
316 | - options: [ | |
317 | - { | |
318 | - label: '星期七', | |
319 | - value: '7', | |
320 | - }, | |
321 | - ], | |
322 | - }, | |
323 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
324 | - }, | |
325 | - { | |
326 | - field: 'startsOn7', | |
327 | - component: 'TimePicker', | |
328 | - label: '开始时间选择', | |
329 | - componentProps: { | |
330 | - valueFormat: 'HH:mm:ss', | |
331 | - }, | |
332 | - colProps: { | |
333 | - span: 8, | |
334 | - }, | |
335 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
336 | - }, | |
337 | - { | |
338 | - field: 'endsOn7', | |
339 | - component: 'TimePicker', | |
340 | - label: '结束时间选择', | |
341 | - componentProps: { | |
342 | - valueFormat: 'HH:mm:ss', | |
343 | - }, | |
344 | - colProps: { | |
345 | - span: 8, | |
346 | - }, | |
347 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')), | |
348 | - }, | |
349 | - | |
350 | - { | |
351 | - field: 'daysOfWeek', | |
352 | - component: 'CheckboxGroup', | |
353 | - label: '天', | |
354 | - colProps: { | |
355 | - span: 24, | |
356 | - }, | |
357 | - rules: [ | |
358 | - { | |
359 | - message: '每周至少选择一天', | |
360 | - trigger: 'blur', | |
361 | - }, | |
362 | - ], | |
363 | - componentProps: { | |
364 | - options: [ | |
365 | - { | |
366 | - label: '星期一', | |
367 | - value: '1', | |
368 | - }, | |
369 | - { | |
370 | - label: '星期二', | |
371 | - value: '2', | |
372 | - }, | |
373 | - { | |
374 | - label: '星期三', | |
375 | - value: '3', | |
376 | - }, | |
377 | - { | |
378 | - label: '星期四', | |
379 | - value: '4', | |
380 | - }, | |
381 | - { | |
382 | - label: '星期五', | |
383 | - value: '5', | |
384 | - }, | |
385 | - { | |
386 | - label: '星期六', | |
387 | - value: '6', | |
388 | - }, | |
389 | - { | |
390 | - label: '星期七', | |
391 | - value: '7', | |
392 | - }, | |
393 | - ], | |
394 | - }, | |
395 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), | |
396 | - }, | |
397 | - { | |
398 | - field: 'startsOn', | |
399 | - component: 'TimePicker', | |
400 | - label: '开始时间选择', | |
401 | - colProps: { | |
402 | - span: 12, | |
403 | - }, | |
404 | - componentProps: { | |
405 | - valueFormat: 'HH:mm:ss', | |
406 | - }, | |
407 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), | |
408 | - }, | |
409 | - { | |
410 | - field: 'endsOn', | |
411 | - component: 'TimePicker', | |
412 | - label: '结束时间选择', | |
413 | - colProps: { | |
414 | - span: 12, | |
415 | - }, | |
416 | - componentProps: { | |
417 | - valueFormat: 'HH:mm:ss', | |
418 | - }, | |
419 | - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), | |
420 | - }, | |
421 | -]; |
src/views/device/profiles/step/cpns/enablerule/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <BasicModal | |
3 | - v-bind="$attrs" | |
4 | - width="55rem" | |
5 | - @register="register" | |
6 | - :title="getTitle" | |
7 | - @ok="handleSubmit" | |
8 | - > | |
9 | - <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | |
10 | - </BasicModal> | |
11 | -</template> | |
12 | -<script lang="ts"> | |
13 | - import { defineComponent, ref, computed, unref } from 'vue'; | |
14 | - import { BasicModal, useModalInner } from '/@/components/Modal'; | |
15 | - import { BasicForm, useForm } from '/@/components/Form'; | |
16 | - import { formSchema } from './config'; | |
17 | - | |
18 | - export default defineComponent({ | |
19 | - name: 'DetailTemplate', | |
20 | - components: { | |
21 | - BasicModal, | |
22 | - BasicForm, | |
23 | - }, | |
24 | - emits: ['success', 'register', 'getAllFieldsEnab'], | |
25 | - setup(_, { emit }) { | |
26 | - const isUpdate = ref(true); | |
27 | - const [registerForm, { getFieldsValue, resetFields }] = useForm({ | |
28 | - labelWidth: 120, | |
29 | - schemas: formSchema, | |
30 | - }); | |
31 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增报警日程表' : '编辑报警日程表')); | |
32 | - const [register, { closeModal }] = useModalInner((data) => { | |
33 | - isUpdate.value = !!data?.isUpdate; | |
34 | - }); | |
35 | - const resetDataFunc = () => { | |
36 | - resetFields(); | |
37 | - }; | |
38 | - const handleSubmit = () => { | |
39 | - const values = getFieldsValue(); | |
40 | - emit('getAllFieldsEnab', values); | |
41 | - closeModal(); | |
42 | - }; | |
43 | - const getFieldsValueFunc = () => { | |
44 | - const val = getFieldsValue(); | |
45 | - return val; | |
46 | - }; | |
47 | - return { | |
48 | - resetDataFunc, | |
49 | - registerForm, | |
50 | - handleSubmit, | |
51 | - register, | |
52 | - getTitle, | |
53 | - getFieldsValueFunc, | |
54 | - }; | |
55 | - }, | |
56 | - }); | |
57 | -</script> |
1 | 1 | import { FormSchema } from '/@/components/Form'; |
2 | 2 | import { deviceConfigGetRuleChain } from '/@/api/device/deviceConfigApi'; |
3 | 3 | import { findDictItemByCode } from '/@/api/system/dict'; |
4 | -import { alarmContactGetPage } from '/@/api/device/deviceConfigApi'; | |
4 | + | |
5 | +enum EnumMQTT { | |
6 | + IS_DEFAULT = 'DEFAULT', | |
7 | + IS_MQTT = 'MQTT', | |
8 | + IS_PROTOBUF = 'PROTOBUF', | |
9 | + IS_COAP = 'COAP', | |
10 | + IS_LWM2M = 'LWM2M', | |
11 | + IS_SNMP = 'SNMP', | |
12 | + IS_PSM = 'PSM', | |
13 | + IS_DRX = 'E_DRX', | |
14 | + IS_EFENTO_NBIOT = 'EFENTO', | |
15 | +} | |
16 | + | |
17 | +const isMqtt = (type: string) => { | |
18 | + return type === EnumMQTT.IS_MQTT; | |
19 | +}; | |
20 | +const isProtobuf = (type: string) => { | |
21 | + return type === EnumMQTT.IS_PROTOBUF; | |
22 | +}; | |
23 | + | |
24 | +const isNBIOt = (type: string) => { | |
25 | + return type === EnumMQTT.IS_COAP; | |
26 | +}; | |
27 | + | |
28 | +const isPsm = (type: string) => { | |
29 | + return type === EnumMQTT.IS_PSM; | |
30 | +}; | |
31 | + | |
32 | +const isDrx = (type: string) => { | |
33 | + return type === EnumMQTT.IS_DRX; | |
34 | +}; | |
35 | + | |
36 | +const isEfentoNb = (type: string) => { | |
37 | + return type === EnumMQTT.IS_EFENTO_NBIOT; | |
38 | +}; | |
5 | 39 | |
6 | 40 | export const step1Schemas: FormSchema[] = [ |
7 | 41 | { |
... | ... | @@ -20,7 +54,6 @@ export const step1Schemas: FormSchema[] = [ |
20 | 54 | placeholder: '请输入配置名称', |
21 | 55 | }, |
22 | 56 | }, |
23 | - //规则链(string) | |
24 | 57 | { |
25 | 58 | field: 'defaultRuleChainId', |
26 | 59 | label: '规则链', |
... | ... | @@ -74,127 +107,309 @@ export const step2Schemas: FormSchema[] = [ |
74 | 107 | label: '传输方式', |
75 | 108 | defaultValue: 'DEFAULT', |
76 | 109 | componentProps: { |
77 | - options: [{ label: '默认', value: 'DEFAULT' }], | |
110 | + options: [ | |
111 | + { label: '默认', value: 'DEFAULT' }, | |
112 | + { label: 'MQTT', value: 'MQTT' }, | |
113 | + { label: 'CoAP', value: 'COAP' }, | |
114 | + ], | |
78 | 115 | }, |
116 | + colProps: { span: 11 }, | |
79 | 117 | }, |
80 | -]; | |
81 | - | |
82 | -export const step3Schemas: FormSchema[] = [ | |
83 | 118 | { |
84 | - field: 'alarmType', | |
119 | + field: 'deviceTelemetryTopic', | |
85 | 120 | component: 'Input', |
121 | + label: '筛选器', | |
86 | 122 | required: true, |
87 | - label: '报警类型', | |
88 | - colProps: { | |
89 | - span: 12, | |
90 | - }, | |
123 | + defaultValue: 'v1/devices/me/telemetry', | |
91 | 124 | componentProps: { |
92 | - maxLength: 255, | |
93 | - placeholder: '请输入报警类型', | |
125 | + placeholder: '请输入遥测数据 topic 筛选器', | |
94 | 126 | }, |
127 | + colProps: { span: 11 }, | |
128 | + ifShow: ({ values }) => isMqtt(values.transportType), | |
95 | 129 | }, |
96 | -]; | |
97 | - | |
98 | -export const step3ViewHighSetting: FormSchema[] = [ | |
99 | 130 | { |
100 | - field: 'propagate', | |
101 | - component: 'Checkbox', | |
102 | - label: '传递报警', | |
131 | + field: 'deviceAttributesTopic', | |
132 | + component: 'Input', | |
133 | + required: true, | |
134 | + label: 'topic filter', | |
135 | + defaultValue: 'v1/devices/me/attributes', | |
136 | + componentProps: { | |
137 | + placeholder: '请输入Attributes topic 筛选器', | |
138 | + }, | |
139 | + colProps: { span: 11 }, | |
140 | + ifShow: ({ values }) => isMqtt(values.transportType), | |
103 | 141 | }, |
104 | 142 | { |
105 | - field: 'propagateRelationTypes', | |
106 | - component: 'Input', | |
107 | - label: '关联类型', | |
108 | - colProps: { | |
109 | - span: 11, | |
143 | + field: 'desc', | |
144 | + component: 'InputTextArea', | |
145 | + label: '描述', | |
146 | + defaultValue: `支持单[+]和多级[#]通配符。[+] is suitable for any topic filter level。例如:v1/devices/+/telemetry or +/devices/+/attributes。[#]可以替换 topic filter 本身,并且必须是 topic 的最后一个符号。例如:# or v1/devices/me/#。 | |
147 | + `, | |
148 | + componentProps: { | |
149 | + autoSize: { | |
150 | + maxRows: 10, | |
151 | + }, | |
152 | + placeholder: '请输入Attributes topic 筛选器', | |
110 | 153 | }, |
154 | + colProps: { span: 24 }, | |
155 | + ifShow: ({ values }) => isMqtt(values.transportType), | |
156 | + }, | |
157 | + { | |
158 | + field: 'transportPayloadType', | |
159 | + component: 'Select', | |
160 | + label: '设备Payload', | |
161 | + defaultValue: 'JSON', | |
111 | 162 | componentProps: { |
112 | - maxLength: 255, | |
113 | - placeholder: '请输入关联类型', | |
163 | + options: [ | |
164 | + { label: 'JSON', value: 'JSON' }, | |
165 | + { label: 'PROTOBUF', value: 'PROTOBUF' }, | |
166 | + ], | |
114 | 167 | }, |
168 | + colProps: { span: 11 }, | |
169 | + ifShow: ({ values }) => isMqtt(values.transportType), | |
115 | 170 | }, |
116 | -]; | |
117 | - | |
118 | -export const step3HighSetting: FormSchema[] = [ | |
119 | 171 | { |
120 | - field: 'propagate', | |
172 | + field: 'useJsonPayloadFormatForDefaultDownlinkTopics', | |
173 | + label: '', | |
174 | + colProps: { span: 14 }, | |
175 | + defaultValue: false, | |
121 | 176 | component: 'Checkbox', |
177 | + renderComponentContent: `启用后,平台将默认使用Protobuf有效载荷格式。如果解析失败,平台将尝试使用JSON有效负载格式。用于固件更新期间的向后兼容性。例如,固件的初始版本使用Json,而新版本使用Protobuf。在设备组的固件更新过程中,需要同时支持Protobuf和JSON。兼容性模式会导致性能轻微下降,因此建议在所有设备更新后禁用此模式。`, | |
178 | + ifShow: ({ values }) => | |
179 | + isProtobuf(values.transportPayloadType) && !isNBIOt(values.transportType), | |
180 | + }, | |
181 | + { | |
182 | + field: 'enableCompatibilityWithJsonPayloadFormat', | |
122 | 183 | label: '', |
123 | - slot: 'checkBox', | |
184 | + colProps: { span: 14 }, | |
185 | + defaultValue: false, | |
186 | + component: 'Checkbox', | |
187 | + renderComponentContent: `启用后,平台将使用Json有效负载格式通过以下主题推送属性和RPC:v1/devices/me/attributes/response/$request_id、v1/devices/me/attributes、v1/devices/me/RPC/request/$request_id、,v1/devices/me/rpc/response/$request id。此设置不影响使用新(v2)主题发送的属性和rpc订阅:v2/a/res/$request id、v2/a、v2/r/req/$request id、v2/r/res/$request id。其中,$request id是整数请求标识符。`, | |
188 | + ifShow: ({ values }) => | |
189 | + isProtobuf(values.transportPayloadType) && | |
190 | + !!values.useJsonPayloadFormatForDefaultDownlinkTopics && | |
191 | + !isNBIOt(values.transportType), | |
124 | 192 | }, |
125 | 193 | { |
126 | - field: 'propagateRelationTypes', | |
127 | - component: 'Input', | |
128 | - label: '关联类型', | |
129 | - colProps: { | |
130 | - span: 11, | |
194 | + field: 'coapDeviceType', | |
195 | + component: 'Select', | |
196 | + label: 'CoAP类型', | |
197 | + defaultValue: 'DEFAULT', | |
198 | + componentProps: { | |
199 | + options: [ | |
200 | + { label: '默认', value: 'DEFAULT' }, | |
201 | + { label: 'Efento NB-IoT', value: 'EFENTO' }, | |
202 | + ], | |
131 | 203 | }, |
204 | + colProps: { span: 11 }, | |
205 | + ifShow: ({ values }) => isNBIOt(values.transportType), | |
206 | + }, | |
207 | + { | |
208 | + field: 'transportPayloadType', | |
209 | + component: 'Select', | |
210 | + label: 'Payload', | |
211 | + defaultValue: 'JSON', | |
132 | 212 | componentProps: { |
133 | - maxLength: 255, | |
134 | - placeholder: '请输入关联类型', | |
213 | + options: [ | |
214 | + { label: 'JSON', value: 'JSON' }, | |
215 | + { label: 'PROTOBUF', value: 'PROTOBUF' }, | |
216 | + ], | |
135 | 217 | }, |
136 | - ifShow: ({ values }) => !!values.propagate, | |
218 | + colProps: { span: 11 }, | |
219 | + ifShow: ({ values }) => isNBIOt(values.transportType) && !isEfentoNb(values.coapDeviceType), | |
137 | 220 | }, |
138 | -]; | |
139 | - | |
140 | -export const dashboardFormScheme: FormSchema[] = [ | |
141 | 221 | { |
142 | - field: 'dashboardId', | |
222 | + field: 'powerMode', | |
143 | 223 | component: 'Select', |
144 | - label: 'Mobile :', | |
145 | - colProps: { | |
146 | - span: 17, | |
224 | + label: 'Power Mode', | |
225 | + defaultValue: 'DRX', | |
226 | + componentProps: { | |
227 | + options: [ | |
228 | + { label: 'Power Saving Mode', value: 'PSM' }, | |
229 | + { label: 'Discontinuous Reception', value: 'DRX' }, | |
230 | + { | |
231 | + label: 'Extended Discontinuous Reception', | |
232 | + value: 'E_DRX', | |
233 | + }, | |
234 | + ], | |
147 | 235 | }, |
236 | + colProps: { span: 11 }, | |
237 | + ifShow: ({ values }) => isNBIOt(values.transportType), | |
238 | + }, | |
239 | + { | |
240 | + field: 'psmActivityTimer', | |
241 | + component: 'InputNumber', | |
242 | + label: 'Timer', | |
243 | + required: true, | |
244 | + defaultValue: '10', | |
148 | 245 | componentProps: { |
149 | - placeholder: '请选择Mobile dashboard', | |
150 | - options: [{ label: 'DASHBOARD', value: 'DASHBOARD' }], | |
246 | + placeholder: '请输入PSM Activity Timer', | |
151 | 247 | }, |
248 | + colProps: { span: 11 }, | |
249 | + ifShow: ({ values }) => isNBIOt(values.transportType) && isPsm(values.powerMode), | |
152 | 250 | }, |
153 | -]; | |
154 | - | |
155 | -export const alertContactsSchemas: FormSchema[] = [ | |
156 | 251 | { |
157 | - field: 'alarmContactId', | |
158 | - label: '告警通知联系人', | |
159 | - component: 'ApiSelect', | |
252 | + field: 'unit', | |
253 | + component: 'Select', | |
254 | + label: '时间单位', | |
255 | + defaultValue: 'second', | |
256 | + componentProps: { | |
257 | + options: [ | |
258 | + { label: 'Milliseconds', value: 'Milliseconds' }, | |
259 | + { label: '秒', value: 'second' }, | |
260 | + { label: '分钟', value: 'minute' }, | |
261 | + { label: '小时', value: 'hour' }, | |
262 | + ], | |
263 | + }, | |
264 | + colProps: { span: 11 }, | |
265 | + ifShow: ({ values }) => isNBIOt(values.transportType) && isPsm(values.powerMode), | |
266 | + }, | |
267 | + { | |
268 | + field: 'edrxCycle', | |
269 | + component: 'InputNumber', | |
270 | + label: 'eDRX cycle', | |
160 | 271 | required: true, |
272 | + defaultValue: '81', | |
161 | 273 | componentProps: { |
162 | - mode: 'multiple', | |
163 | - placeholder: '请选择告警通知联系人', | |
164 | - api: alarmContactGetPage, | |
165 | - labelField: 'username', | |
166 | - valueField: 'id', | |
167 | - resultField: 'items', | |
274 | + placeholder: '请输入PSM Activity Timer', | |
168 | 275 | }, |
276 | + colProps: { span: 11 }, | |
277 | + ifShow: ({ values }) => isNBIOt(values.transportType) && isDrx(values.powerMode), | |
169 | 278 | }, |
170 | 279 | { |
171 | - field: 'messageMode', | |
172 | - label: '告警通知方式', | |
173 | - component: 'ApiSelect', | |
280 | + field: 'unit', | |
281 | + component: 'Select', | |
282 | + label: '时间单位', | |
283 | + defaultValue: 'second', | |
284 | + componentProps: { | |
285 | + options: [ | |
286 | + { label: 'Milliseconds', value: 'Milliseconds' }, | |
287 | + { label: '秒', value: 'second' }, | |
288 | + { label: '分钟', value: 'minute' }, | |
289 | + { label: '小时', value: 'hour' }, | |
290 | + ], | |
291 | + }, | |
292 | + colProps: { span: 11 }, | |
293 | + ifShow: ({ values }) => isNBIOt(values.transportType) && isDrx(values.powerMode), | |
294 | + }, | |
295 | + { | |
296 | + field: 'pagingTransmissionWindow', | |
297 | + component: 'InputNumber', | |
298 | + label: 'Paging', | |
174 | 299 | required: true, |
300 | + defaultValue: '10', | |
175 | 301 | componentProps: { |
176 | - mode: 'multiple', | |
177 | - placeholder: '请选择告警通知方式', | |
178 | - api: findDictItemByCode, | |
179 | - params: { | |
180 | - dictCode: 'message_type', | |
302 | + placeholder: '请输入Paging Transmission Window', | |
303 | + }, | |
304 | + colProps: { span: 11 }, | |
305 | + ifShow: ({ values }) => isNBIOt(values.transportType) && isDrx(values.powerMode), | |
306 | + }, | |
307 | + { | |
308 | + field: 'unit', | |
309 | + component: 'Select', | |
310 | + label: '时间单位', | |
311 | + defaultValue: 'second', | |
312 | + componentProps: { | |
313 | + options: [ | |
314 | + { label: 'Milliseconds', value: 'Milliseconds' }, | |
315 | + { label: '秒', value: 'second' }, | |
316 | + { label: '分钟', value: 'minute' }, | |
317 | + { label: '小时', value: 'hour' }, | |
318 | + ], | |
319 | + }, | |
320 | + colProps: { span: 11 }, | |
321 | + ifShow: ({ values }) => isNBIOt(values.transportType) && isDrx(values.powerMode), | |
322 | + }, | |
323 | + { | |
324 | + field: 'deviceTelemetryProtoSchema', | |
325 | + label: '遥测数据', | |
326 | + colProps: { span: 22 }, | |
327 | + component: 'InputTextArea', | |
328 | + componentProps: { | |
329 | + autoSize: { | |
330 | + maxRows: 10, | |
181 | 331 | }, |
182 | - labelField: 'itemText', | |
183 | - valueField: 'itemValue', | |
184 | 332 | }, |
333 | + defaultValue: ` | |
334 | + syntax ="proto3"; | |
335 | + package telemetry; | |
336 | + | |
337 | + message SensorDataReading { | |
338 | + optional double temperature = 1; | |
339 | + optional double humidity = 2; | |
340 | + InnerObject innerObject = 3; | |
341 | + message InnerObject { | |
342 | + optional string key1 = 1; | |
343 | + optional bool key2 = 2; | |
344 | + optional double key3 = 3; | |
345 | + optional int32 key4 = 4; | |
346 | + optional string key5 = 5; | |
347 | + } | |
348 | + } | |
349 | + `, | |
350 | + ifShow: ({ values }) => isProtobuf(values.transportPayloadType), | |
185 | 351 | }, |
186 | -]; | |
352 | + { | |
353 | + field: 'deviceAttributesProtoSchema', | |
354 | + label: 'Attributes', | |
355 | + colProps: { span: 22 }, | |
356 | + component: 'InputTextArea', | |
357 | + componentProps: { | |
358 | + autoSize: { | |
359 | + maxRows: 10, | |
360 | + }, | |
361 | + }, | |
362 | + defaultValue: ` | |
363 | + syntax ="proto3"; | |
364 | + package attributes; | |
187 | 365 | |
188 | -export const formChangeDetailSchema: FormSchema[] = [ | |
366 | + message SensorConfiguration { | |
367 | + optional string firmwareVersion = 1; | |
368 | + optional string serialNumber = 2; | |
369 | + } | |
370 | + `, | |
371 | + ifShow: ({ values }) => isProtobuf(values.transportPayloadType), | |
372 | + }, | |
189 | 373 | { |
190 | - field: 'alarmDetails', | |
191 | - label: '报警详细信息:', | |
192 | - colProps: { span: 13 }, | |
193 | - component: 'Input', | |
194 | - defaultValue: '', | |
374 | + field: 'deviceRpcRequestProtoSchema', | |
375 | + label: 'RPC 请求 ', | |
376 | + colProps: { span: 22 }, | |
377 | + component: 'InputTextArea', | |
195 | 378 | componentProps: { |
196 | - placeholder: '', | |
197 | - maxLength: 255, | |
379 | + autoSize: { | |
380 | + maxRows: 10, | |
381 | + }, | |
382 | + }, | |
383 | + defaultValue: ` | |
384 | + syntax ="proto3"; | |
385 | + package rpc; | |
386 | + | |
387 | + message RpcRequestMsg { | |
388 | + optional string method = 1; | |
389 | + optional int32 requestId = 2; | |
390 | + optional string params = 3; | |
391 | + } | |
392 | + `, | |
393 | + ifShow: ({ values }) => isProtobuf(values.transportPayloadType), | |
394 | + }, | |
395 | + { | |
396 | + field: 'deviceRpcResponseProtoSchema', | |
397 | + label: 'RPC 响应', | |
398 | + colProps: { span: 22 }, | |
399 | + component: 'InputTextArea', | |
400 | + componentProps: { | |
401 | + autoSize: { | |
402 | + maxRows: 10, | |
403 | + }, | |
198 | 404 | }, |
405 | + defaultValue: ` | |
406 | + syntax ="proto3"; | |
407 | + package rpc; | |
408 | + | |
409 | + message RpcResponseMsg { | |
410 | + optional string payload = 1; | |
411 | + } | |
412 | + `, | |
413 | + ifShow: ({ values }) => isProtobuf(values.transportPayloadType), | |
199 | 414 | }, |
200 | 415 | ]; | ... | ... |
src/views/device/profiles/step/index.t.ts
deleted
100644 → 0
1 | -interface IConfiguration { | |
2 | - type?: string; | |
3 | -} | |
4 | -interface ITansportConfiguration { | |
5 | - type?: string; | |
6 | -} | |
7 | -interface provisionConfigurationD { | |
8 | - provisionDeviceSecret?: string; | |
9 | -} | |
10 | -type ICreateRule = {}; | |
11 | -type IClearRule = { | |
12 | - id: string; | |
13 | - alarmDetails: string; | |
14 | - dashboardId: { | |
15 | - id: string; | |
16 | - entityType: string; | |
17 | - }; | |
18 | - propagate: string; | |
19 | - propagateRelationTypes: string[]; | |
20 | - schedule: { | |
21 | - type: string; | |
22 | - }; | |
23 | - condition: object; | |
24 | -}; | |
25 | -interface IAlarms { | |
26 | - id: string; | |
27 | - alarmType: string; | |
28 | - createRules: ICreateRule; | |
29 | - propagate: boolean; | |
30 | - propagateRelationTypes: string[]; | |
31 | -} | |
32 | - | |
33 | -export interface IProfileData { | |
34 | - configuration?: IConfiguration; | |
35 | - transportConfiguration?: ITansportConfiguration; | |
36 | - provisionConfiguration?: provisionConfigurationD; | |
37 | - alarms?: IAlarms[]; | |
38 | - clearRule?: IClearRule[]; | |
39 | -} | |
40 | - | |
41 | -export interface IAddAlarms { | |
42 | - id: string; | |
43 | - alarmType: string; | |
44 | - createRules: []; | |
45 | - clearRule: {}; | |
46 | - propagate: boolean; | |
47 | - propagateRelationTypes: string[]; | |
48 | -} |