Showing
14 changed files
with
89 additions
and
24 deletions
... | ... | @@ -136,13 +136,19 @@ |
136 | 136 | const handlePreview = (record: ConfigurationCenterItemsModal) => { |
137 | 137 | if (!unref(getPreviewFlag)) return; |
138 | 138 | window.open( |
139 | - `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}&lightbox=1` | |
139 | + `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${ | |
140 | + record!.id | |
141 | + }&lightbox=1&organizationId=${record.organizationId}` | |
140 | 142 | ); |
141 | 143 | }; |
142 | 144 | |
143 | 145 | const handleDesign = (record: ConfigurationCenterItemsModal) => { |
144 | 146 | if (!unref(getDesignFlag)) return; |
145 | - window.open(`${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${record!.id}`); | |
147 | + window.open( | |
148 | + `${configurationPrefix}/${isDev ? '?dev=1&' : '?'}configurationId=${ | |
149 | + record!.id | |
150 | + }&organizationId=${record.organizationId}` | |
151 | + ); | |
146 | 152 | }; |
147 | 153 | |
148 | 154 | const handleDelete = async (record: ConfigurationCenterItemsModal) => { |
... | ... | @@ -165,6 +171,7 @@ |
165 | 171 | searchParams.set('configurationId', record.id); |
166 | 172 | searchParams.set('publicId', record.publicId || ''); |
167 | 173 | searchParams.set('lightbox', '1'); |
174 | + searchParams.set('organizationId', record!.organizationId || ''); | |
168 | 175 | return `${origin}${configurationPrefix}/?${searchParams.toString()}`; |
169 | 176 | }; |
170 | 177 | ... | ... |
... | ... | @@ -31,9 +31,9 @@ |
31 | 31 | import { CredentialsEnum } from '../mqtt/enum'; |
32 | 32 | |
33 | 33 | const credentialsFile = reactive({ |
34 | - caCertFileName: '', | |
35 | - certFileName: '', | |
36 | - privateKeyFileName: '', | |
34 | + caCertFileName: undefined, | |
35 | + certFileName: undefined, | |
36 | + privateKeyFileName: undefined, | |
37 | 37 | }); |
38 | 38 | |
39 | 39 | const [register, { validateFields, setFieldsValue, resetFields }] = useForm({ |
... | ... | @@ -50,6 +50,11 @@ |
50 | 50 | const getValue = async () => { |
51 | 51 | const values = await validateFields(); |
52 | 52 | if (!values) return; |
53 | + // if (values.type == 'anonymous' || values.type == 'basic') { | |
54 | + // credentialsFile.caCertFileName = undefined; | |
55 | + // credentialsFile.certFileName = undefined; | |
56 | + // credentialsFile.privateKeyFileName = undefined; | |
57 | + // } | |
53 | 58 | const credentials = { |
54 | 59 | type: values['type'], |
55 | 60 | ...credentialsFile, | ... | ... |
... | ... | @@ -51,10 +51,16 @@ |
51 | 51 | const getValue = async () => { |
52 | 52 | const values = await validateFields(); |
53 | 53 | if (!values) return; |
54 | + if (values.type == 'anonymous' || values.type == 'basic') { | |
55 | + credentialsFile.caCertFileName = undefined; | |
56 | + credentialsFile.certFileName = undefined; | |
57 | + credentialsFile.privateKeyFileName = undefined; | |
58 | + } | |
54 | 59 | const credentials = { |
55 | 60 | type: values['type'], |
56 | 61 | ...credentialsFile, |
57 | 62 | }; |
63 | + | |
58 | 64 | const mergeValues = { |
59 | 65 | ...values, |
60 | 66 | ...{ credentials }, |
... | ... | @@ -67,7 +73,12 @@ |
67 | 73 | if (credentials) { |
68 | 74 | for (let i in credentials) Reflect.set(credentialsFile, i, credentials[i]); |
69 | 75 | } |
70 | - setFieldsValue({ ...value, type: credentials.type }); | |
76 | + setFieldsValue({ | |
77 | + ...value, | |
78 | + type: credentials.type, | |
79 | + username: credentials.username, | |
80 | + password: credentials.password, | |
81 | + }); | |
71 | 82 | }; |
72 | 83 | |
73 | 84 | const resetValue = () => resetFields(); | ... | ... |
... | ... | @@ -18,7 +18,7 @@ class MqttFormPartialConfig { |
18 | 18 | return [ |
19 | 19 | { label: 'Anonymous', value: 'anonymous' }, |
20 | 20 | { label: 'Basic', value: 'basic' }, |
21 | - { label: 'PEM', value: 'pem' }, | |
21 | + { label: 'PEM', value: 'cert.PEM' }, | |
22 | 22 | ]; |
23 | 23 | } |
24 | 24 | } |
... | ... | @@ -138,9 +138,21 @@ export const modeMqttForm: FormSchema[] = [ |
138 | 138 | label: '凭据类型', |
139 | 139 | colProps: { span: 12 }, |
140 | 140 | defaultValue: MqttFormPartialConfig.type, |
141 | - componentProps: { | |
142 | - placeholder: '请选择Credentials', | |
143 | - options: MqttFormPartialConfig.getType(), | |
141 | + componentProps: ({ formActionType }) => { | |
142 | + const { setFieldsValue } = formActionType; | |
143 | + return { | |
144 | + placeholder: '请选择Credentials', | |
145 | + options: MqttFormPartialConfig.getType(), | |
146 | + onChange(e) { | |
147 | + if (e) { | |
148 | + console.log('执行'); | |
149 | + setFieldsValue({ | |
150 | + password: undefined, | |
151 | + username: undefined, | |
152 | + }); | |
153 | + } | |
154 | + }, | |
155 | + }; | |
144 | 156 | }, |
145 | 157 | }, |
146 | 158 | { | ... | ... |
... | ... | @@ -128,8 +128,9 @@ |
128 | 128 | : undefined, |
129 | 129 | appendClientIdSuffix: getDataFlowParams.appendClientIdSuffix || undefined, |
130 | 130 | type: undefined, |
131 | + username: undefined, | |
132 | + password: undefined, | |
131 | 133 | }; |
132 | - | |
133 | 134 | const rest = isRabbitmq(getDataFlowMethod?.type) |
134 | 135 | ? await postAddConvertApi({ ...restData.data, ...data }) |
135 | 136 | : await postAddConvertApi({ ...restData.data, ...data, configuration }); | ... | ... |
... | ... | @@ -755,6 +755,18 @@ export const actionSchema: FormSchema[] = [ |
755 | 755 | component: 'Select', |
756 | 756 | label: '', |
757 | 757 | show: ({ values }) => isAlarmOut(values.outTarget), |
758 | + // dynamicRules: (params) => { | |
759 | + // const { outTarget } = params.values; | |
760 | + // return [ | |
761 | + // { | |
762 | + // required: outTarget == 'MSG_NOTIFY' ? true : false, | |
763 | + // validator: (_, value) => { | |
764 | + // if (!value) return Promise.reject('请选择告警配置'); | |
765 | + // Promise.resolve(); | |
766 | + // }, | |
767 | + // }, | |
768 | + // ]; | |
769 | + // }, | |
758 | 770 | componentProps: { |
759 | 771 | placeholder: '请选择告警等级', |
760 | 772 | options: [ | ... | ... |
... | ... | @@ -273,6 +273,10 @@ |
273 | 273 | if (validate.device == 'PART' && validate.deviceId == undefined) |
274 | 274 | return createMessage.error('请选择设备'); |
275 | 275 | } |
276 | + if (type === 'MSG_NOTIFY') { | |
277 | + if (!validate.alarm_config) return createMessage.error('请选择告警配置'); | |
278 | + if (!validate.alarm_level) return createMessage.error('请选择告警等级'); | |
279 | + } | |
276 | 280 | //ft-add-2022-11-22 |
277 | 281 | //TODO-fengtao-设备验证 |
278 | 282 | const value = getFieldsValue(); | ... | ... |
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | import { BasicForm, useForm } from '/@/components/Form'; |
3 | 3 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
4 | 4 | import { formSchemas } from './config'; |
5 | - import { ref } from 'vue'; | |
5 | + import { nextTick, ref } from 'vue'; | |
6 | 6 | import { composeData, parseData } from './util'; |
7 | 7 | import { createTask, updateTask } from '/@/api/task'; |
8 | 8 | import { ModalParamsType } from '/#/utils'; |
... | ... | @@ -33,7 +33,10 @@ |
33 | 33 | modalMode.value = mode; |
34 | 34 | dataSource.value = record; |
35 | 35 | formMode.value = mode; |
36 | - resetFields(); | |
36 | + resetFields().then(async () => { | |
37 | + await nextTick(); | |
38 | + clearValidate(); | |
39 | + }); | |
37 | 40 | if (record && mode === DataActionModeEnum.UPDATE) { |
38 | 41 | const res = parseData(record); |
39 | 42 | setFieldsValue({ ...res }); |
... | ... | @@ -41,13 +44,14 @@ |
41 | 44 | } |
42 | 45 | ); |
43 | 46 | |
44 | - const [registerForm, { getFieldsValue, validate, setFieldsValue, resetFields }] = useForm({ | |
45 | - schemas: formSchemas, | |
46 | - showActionButtonGroup: false, | |
47 | - layout: 'inline', | |
48 | - baseColProps: { span: 24 }, | |
49 | - labelWidth: 140, | |
50 | - }); | |
47 | + const [registerForm, { getFieldsValue, validate, setFieldsValue, resetFields, clearValidate }] = | |
48 | + useForm({ | |
49 | + schemas: formSchemas, | |
50 | + showActionButtonGroup: false, | |
51 | + layout: 'inline', | |
52 | + baseColProps: { span: 24 }, | |
53 | + labelWidth: 140, | |
54 | + }); | |
51 | 55 | |
52 | 56 | const loading = ref(false); |
53 | 57 | const { createMessage } = useMessage(); | ... | ... |
... | ... | @@ -124,7 +124,6 @@ export const parseData = (result: TaskRecordType): Required<FormValueType> => { |
124 | 124 | TaskRecordType['executeTarget'] |
125 | 125 | >; |
126 | 126 | const { type: executeTimeType, period, periodType, time, pollUnit } = executeTime; |
127 | - console.log(pushWay === PushWayEnum.MQTT ? JSON.stringify(rpcCommand, null, 2) : rpcCommand); | |
128 | 127 | return { |
129 | 128 | name, |
130 | 129 | targetType, | ... | ... |
... | ... | @@ -188,7 +188,9 @@ |
188 | 188 | if (hasDetailPermission) { |
189 | 189 | const boardId = encode(record.id); |
190 | 190 | const boardName = encode(record.name); |
191 | - router.push(`/visual/board/detail/${boardId}/${boardName}`); | |
191 | + const organizationId = encode(record?.organizationId); | |
192 | + | |
193 | + router.push(`/visual/board/detail/${boardId}/${boardName}/${organizationId}`); | |
192 | 194 | } else createMessage.warning('没有权限'); |
193 | 195 | }; |
194 | 196 | ... | ... |
... | ... | @@ -90,6 +90,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
90 | 90 | const isUpdate = unref(mode) === DataActionModeEnum.UPDATE; |
91 | 91 | const selectWidgetKeys = useSelectWidgetKeys(); |
92 | 92 | const category = unref(selectWidgetKeys).categoryKey; |
93 | + | |
93 | 94 | return [ |
94 | 95 | { |
95 | 96 | field: DataSourceField.IS_GATEWAY_DEVICE, |
... | ... | @@ -191,6 +192,9 @@ export const commonDataSourceSchemas = (): FormSchema[] => { |
191 | 192 | }); |
192 | 193 | }, |
193 | 194 | showCreate: false, |
195 | + apiTreeSelectProps: { | |
196 | + params: { organizationId: location?.pathname?.split('/')?.pop() || '' }, | |
197 | + }, | |
194 | 198 | getPopupContainer: () => document.body, |
195 | 199 | }; |
196 | 200 | }, | ... | ... |