Showing
15 changed files
with
56 additions
and
101 deletions
... | ... | @@ -206,10 +206,7 @@ export const step1Schemas: FormSchema[] = [ |
206 | 206 | }, |
207 | 207 | ifShow: ({ values }) => { |
208 | 208 | return ( |
209 | - values?.transportType === TransportTypeEnum.TCP && | |
210 | - (values.deviceType === DeviceTypeEnum.SENSOR || | |
211 | - values.deviceType === DeviceTypeEnum.GATEWAY) && | |
212 | - values?.codeType === TaskTypeEnum.CUSTOM | |
209 | + values?.transportType === TransportTypeEnum.TCP && values?.codeType === TaskTypeEnum.CUSTOM | |
213 | 210 | ); |
214 | 211 | }, |
215 | 212 | }, | ... | ... |
... | ... | @@ -263,6 +263,7 @@ |
263 | 263 | class="!text-lg" |
264 | 264 | icon="ant-design:form-outlined" |
265 | 265 | @click.stop="handleUpdate(item)" |
266 | + :disabled="item.name == 'default'" | |
266 | 267 | /> |
267 | 268 | </Tooltip> |
268 | 269 | <AuthDropDown |
... | ... | @@ -286,7 +287,7 @@ |
286 | 287 | onConfirm: handleDelete.bind(null, [item.id]), |
287 | 288 | disabled: item.default, |
288 | 289 | }, |
289 | - disabled: item.default, | |
290 | + disabled: item.default || item.name == 'default', | |
290 | 291 | }, |
291 | 292 | ]" |
292 | 293 | /> | ... | ... |
src/views/rule/chain/chainDetail/component/Attribute.vue
deleted
100644 → 0
src/views/rule/chain/chainDetail/component/Warn.vue
deleted
100644 → 0
src/views/rule/chain/chainDetail/index.ts
deleted
100644 → 0
src/views/rule/chain/chainDetail/index.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <BasicDrawer | |
3 | - v-bind="$attrs" | |
4 | - isDetail | |
5 | - @register="register" | |
6 | - destroyOnClose | |
7 | - @close="closeDrawer" | |
8 | - :title="deviceDetail.alias || deviceDetail.name" | |
9 | - width="80%" | |
10 | - > | |
11 | - <Tabs v-model:activeKey="activeKey" :size="size"> | |
12 | - <TabPane key="1" tab="详情"> | |
13 | - <div>详情</div> | |
14 | - </TabPane> | |
15 | - <TabPane key="2" tab="属性"> | |
16 | - <Attribute /> | |
17 | - </TabPane> | |
18 | - <TabPane key="3" tab="最新遥测数据"><div>最新遥测数据</div></TabPane> | |
19 | - <TabPane key="4" tab="警告"> | |
20 | - <div>警告</div> | |
21 | - </TabPane> | |
22 | - <TabPane key="5" tab="事件"> | |
23 | - <div>事件</div> | |
24 | - </TabPane> | |
25 | - <!-- 网关设备并且场家是TBox --> | |
26 | - <TabPane key="6" tab="关联"> | |
27 | - <div>关联</div> | |
28 | - </TabPane> | |
29 | - <!-- 网关设备并且是TBox --> | |
30 | - | |
31 | - <TabPane key="7" tab="审计日志"> | |
32 | - <div>审计日志</div> | |
33 | - </TabPane> | |
34 | - </Tabs> | |
35 | - </BasicDrawer> | |
36 | -</template> | |
37 | -<script lang="ts" setup> | |
38 | - import { ref } from 'vue'; | |
39 | - import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | |
40 | - | |
41 | - import { Tabs, TabPane } from 'ant-design-vue'; | |
42 | - import { DeviceRecord } from '/@/api/device/model/deviceModel'; | |
43 | - | |
44 | - import Attribute from './component/Attribute.vue'; | |
45 | - | |
46 | - // defineProps({}); | |
47 | - | |
48 | - // defineEmits([]); | |
49 | - | |
50 | - const activeKey = ref('1'); | |
51 | - const size = ref('small'); | |
52 | - const deviceDetail = ref<DeviceRecord>({} as unknown as DeviceRecord); | |
53 | - // 详情回显 | |
54 | - const [register] = useDrawerInner(async (data) => { | |
55 | - console.log(data, 'data'); | |
56 | - }); | |
57 | - const closeDrawer = () => { | |
58 | - activeKey.value = '1'; | |
59 | - }; | |
60 | -</script> |
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <Authority> |
6 | 6 | <a-button type="primary" @click="handleAdd"> 新增规则链 </a-button> |
7 | 7 | </Authority> |
8 | - <Upload :show-upload-list="false" :customRequest="handleImport"> | |
8 | + <Upload :show-upload-list="false" accept=".json," :customRequest="handleImport"> | |
9 | 9 | <Button type="primary" :loading="importLoading"> 导入规则链 </Button> |
10 | 10 | </Upload> |
11 | 11 | <Authority> |
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | ifShow: !record.root, |
65 | 65 | popConfirm: { |
66 | 66 | title: '是否确认删除', |
67 | - confirm: handleDeleteOrBatchDelete.bind(null, record), | |
67 | + confirm: handleDeleteOrBatchDelete.bind(null, record.id.id), | |
68 | 68 | }, |
69 | 69 | }, |
70 | 70 | ]" |
... | ... | @@ -113,7 +113,7 @@ |
113 | 113 | |
114 | 114 | const isEmptyObject = (value: any) => isObject(value) && !Object.keys(value).length; |
115 | 115 | const importLoading = ref<boolean>(false); |
116 | - const hasBatchDelete = ref<boolean>(false); | |
116 | + const hasBatchDelete = ref<boolean>(true); | |
117 | 117 | |
118 | 118 | const beforeFetch = (params) => { |
119 | 119 | Reflect.set(params, 'page', params.page - 1); |
... | ... | @@ -148,8 +148,11 @@ |
148 | 148 | labelWidth: 120, |
149 | 149 | schemas: searchFormSchema, |
150 | 150 | }, |
151 | + resizeHeightOffset: 40, | |
152 | + canResize: true, | |
151 | 153 | fetchSetting: { |
152 | 154 | pageField: 'page', |
155 | + totalField: 'totalElements', | |
153 | 156 | listField: 'data', |
154 | 157 | }, |
155 | 158 | beforeFetch: (params) => beforeFetch(params), |
... | ... | @@ -208,6 +211,7 @@ |
208 | 211 | }); |
209 | 212 | const { ruleChain, metadata } = data as any; |
210 | 213 | |
214 | + // 创建规则链 | |
211 | 215 | const value = await createRuleChine(ruleChain); |
212 | 216 | const { id } = value; |
213 | 217 | |
... | ... | @@ -215,6 +219,7 @@ |
215 | 219 | ruleChainId: id, |
216 | 220 | ...metadata, |
217 | 221 | }; |
222 | + // 导入规则链详情nodes的东西 | |
218 | 223 | const rules = await importRuleChine(values); |
219 | 224 | |
220 | 225 | rules |
... | ... | @@ -239,9 +244,17 @@ |
239 | 244 | const { firstNodeIndex, nodes, connections, ruleChainConnections } = await exportRuleChine( |
240 | 245 | record.id.id |
241 | 246 | ); |
247 | + | |
248 | + const node = nodes.map((item) => { | |
249 | + return { | |
250 | + ...item, | |
251 | + id: undefined, | |
252 | + ruleChainId: undefined, | |
253 | + }; | |
254 | + }); | |
242 | 255 | const value = { |
243 | 256 | ruleChain: { additionalInfo, name, type, firstRuleNodeId, root, debugMode, configuration }, |
244 | - metadata: { firstNodeIndex, nodes, connections, ruleChainConnections }, | |
257 | + metadata: { firstNodeIndex, nodes: node, connections, ruleChainConnections }, | |
245 | 258 | }; |
246 | 259 | exportJSONFile(value, name); |
247 | 260 | }; |
... | ... | @@ -257,26 +270,25 @@ |
257 | 270 | setProps({ |
258 | 271 | loading: false, |
259 | 272 | }); |
273 | + reload(); | |
260 | 274 | } |
261 | - reload(); | |
262 | 275 | }; |
263 | 276 | |
264 | - const handleDeleteOrBatchDelete = async (record: Recordable | null) => { | |
277 | + const handleDeleteOrBatchDelete = async (id: string | null) => { | |
265 | 278 | setProps({ |
266 | 279 | loading: true, |
267 | 280 | }); |
268 | 281 | try { |
269 | - if (!record) { | |
282 | + if (!id) { | |
270 | 283 | const ids = getSelectRowKeys(); |
271 | 284 | await Promise.all(ids.map((item) => deleteRuleChine(item))); |
272 | 285 | return; |
273 | 286 | } |
274 | - await deleteRuleChine(record.id.id); | |
287 | + await deleteRuleChine(id); | |
275 | 288 | } finally { |
276 | 289 | setProps({ |
277 | 290 | loading: false, |
278 | 291 | }); |
279 | - | |
280 | 292 | createMessage.success('删除成功'); |
281 | 293 | clearSelectedRowKeys(); |
282 | 294 | reload(); | ... | ... |
... | ... | @@ -212,6 +212,7 @@ |
212 | 212 | return { |
213 | 213 | value: item.id, |
214 | 214 | label: item.name, |
215 | + status: item.status, | |
215 | 216 | }; |
216 | 217 | }); |
217 | 218 | deviceList.value = editEntryIdData.value; |
... | ... | @@ -576,7 +577,11 @@ |
576 | 577 | setFields(skipUnwrap.conditionItemRefs, true); |
577 | 578 | setFields(skipUnwrap.actionItemRefs, true); |
578 | 579 | const data = await getOrganizationAlarmConfig({ organizationId: newValue }); |
579 | - alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | |
580 | + alarmConfigList.value = data.map((item) => ({ | |
581 | + label: item.name, | |
582 | + value: item.id, | |
583 | + status: item.status, | |
584 | + })); | |
580 | 585 | setEditAlarmConfig(skipUnwrap.actionItemRefs, alarmConfigList); |
581 | 586 | // setFields(skipUnwrap.actionItemRefs, true); |
582 | 587 | // console.log(unref(organizationIdRef)); |
... | ... | @@ -587,7 +592,7 @@ |
587 | 592 | const data = await getOrganizationAlarmConfig({ |
588 | 593 | organizationId: isUpdate.value ? provideOrgid.value : addOrgId.value, |
589 | 594 | }); |
590 | - const res = data.map((item) => ({ label: item.name, value: item.id })); | |
595 | + const res = data.map((item) => ({ label: item.name, value: item.id, status: item.status })); | |
591 | 596 | isUpdate.value ? (editAlarmConfigData.value = res) : (alarmConfigList.value = res); |
592 | 597 | unref(skipUnwrap.actionItemRefs)?.map((item: any) => { |
593 | 598 | if (isUpdate.value) { | ... | ... |
... | ... | @@ -143,7 +143,7 @@ |
143 | 143 | } |
144 | 144 | if (predicateIsRequired) return createMessage.error('请填写条件筛选'); |
145 | 145 | //TODO-fengtao-设备、属性、条件筛选验证 |
146 | - return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; | |
146 | + return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value?.scheduleData }; | |
147 | 147 | }; |
148 | 148 | |
149 | 149 | //TODO-fengtao | ... | ... |
... | ... | @@ -361,10 +361,10 @@ |
361 | 361 | }; |
362 | 362 | //FT add 2022-10-27 |
363 | 363 | const updateEditFieldAlarmConfig = (alarmConfigList) => { |
364 | - alarmConfigOptions.value = alarmConfigList.value; | |
364 | + alarmConfigOptions.value = alarmConfigList.value.filter((item) => item.status); | |
365 | 365 | }; |
366 | 366 | const updateFieldAlarmConfig = (alarmConfigList) => { |
367 | - alarmConfigOptions.value = alarmConfigList.value; | |
367 | + alarmConfigOptions.value = alarmConfigList.value.filter((item) => item.status); | |
368 | 368 | }; |
369 | 369 | //FT add 2022-10-27 |
370 | 370 | ... | ... |
... | ... | @@ -2,18 +2,19 @@ |
2 | 2 | import { Button, Spin } from 'ant-design-vue'; |
3 | 3 | import { BasicForm, useForm } from '/@/components/Form'; |
4 | 4 | import { BasicModal, useModal } from '/@/components/Modal'; |
5 | - import { formSchemas } from './config'; | |
5 | + import { formSchemas, FormFieldsEnum } from './config'; | |
6 | 6 | import { ref } from 'vue'; |
7 | 7 | import { unref } from 'vue'; |
8 | 8 | import { composeModbusModalData } from './util'; |
9 | 9 | import { ModbusCommandValueType } from './type'; |
10 | 10 | import { genModbusCommand } from '/@/api/task'; |
11 | + import { isNullOrUnDef } from '/@/utils/is'; | |
11 | 12 | |
12 | 13 | const emit = defineEmits(['update:value']); |
13 | 14 | |
14 | 15 | const [registerModal] = useModal(); |
15 | 16 | |
16 | - const [registerForm, { getFieldsValue }] = useForm({ | |
17 | + const [registerForm, { getFieldsValue, validate }] = useForm({ | |
17 | 18 | schemas: formSchemas, |
18 | 19 | showActionButtonGroup: false, |
19 | 20 | rowProps: { gutter: 10 }, |
... | ... | @@ -25,8 +26,12 @@ |
25 | 26 | const loading = ref(false); |
26 | 27 | const handleGetValue = async () => { |
27 | 28 | try { |
29 | + await validate(); | |
28 | 30 | const value = getFieldsValue(); |
29 | 31 | const record = composeModbusModalData(value as ModbusCommandValueType); |
32 | + | |
33 | + if (record[FormFieldsEnum.REGISTER_VALUES]?.some((item) => isNullOrUnDef(item))) return; | |
34 | + | |
30 | 35 | loading.value = true; |
31 | 36 | const result = await genModbusCommand(record); |
32 | 37 | commandValue.value = result; |
... | ... | @@ -46,7 +51,7 @@ |
46 | 51 | return arr.reduce((prev, next) => `${prev} ${next.join('')}`, ''); |
47 | 52 | }; |
48 | 53 | |
49 | - const handleOk = () => { | |
54 | + const handleOk = async () => { | |
50 | 55 | emit('update:value', unref(commandValue)); |
51 | 56 | }; |
52 | 57 | </script> | ... | ... |
... | ... | @@ -282,7 +282,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
282 | 282 | }, |
283 | 283 | componentProps: ({ formActionType, formModel }) => { |
284 | 284 | const { setFieldsValue } = formActionType; |
285 | - const { codeType } = formModel || {}; | |
285 | + const { codeType, deviceType, transportType } = formModel || {}; | |
286 | 286 | return { |
287 | 287 | // api: findDictItemByCode, |
288 | 288 | api: async (params: Recordable) => { |
... | ... | @@ -293,6 +293,14 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
293 | 293 | (item) => item.itemValue == CommandTypeEnum.ATTRIBUTE.toString() |
294 | 294 | ); |
295 | 295 | } |
296 | + | |
297 | + // TCP网关子 --> 不能要服务命令类型 | |
298 | + if (deviceType == 'SENSOR' && transportType == 'TCP') { | |
299 | + return record.filter( | |
300 | + (item) => item.itemValue == CommandTypeEnum.ATTRIBUTE.toString() | |
301 | + ); | |
302 | + } | |
303 | + | |
296 | 304 | if (codeType == TaskTypeEnum.MODBUS_RTU) { |
297 | 305 | // setFieldsValue({ [DataSourceField.COMMAND_TYPE]: undefined }); |
298 | 306 | return record.filter( |
... | ... | @@ -304,7 +312,6 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
304 | 312 | ); |
305 | 313 | } |
306 | 314 | } catch (error) { |
307 | - console.log(error); | |
308 | 315 | return []; |
309 | 316 | } |
310 | 317 | }, | ... | ... |