Commit 1240432c150c76da7b05367445a3b930f4eab789

Authored by fengwotao
2 parents d87e0d92 207a2613

Merge branch 'main_dev' into ft

@@ -7,6 +7,7 @@ export interface ConfigurationCenterItemsModal { @@ -7,6 +7,7 @@ export interface ConfigurationCenterItemsModal {
7 creator: string; 7 creator: string;
8 remark: string; 8 remark: string;
9 publicId?: string; 9 publicId?: string;
  10 + organizationId?: string;
10 } 11 }
11 export type queryPageParams = BasicPageParams & { 12 export type queryPageParams = BasicPageParams & {
12 name?: Nullable<string>; 13 name?: Nullable<string>;
@@ -56,7 +56,10 @@ @@ -56,7 +56,10 @@
56 return unref(orgList); 56 return unref(orgList);
57 } 57 }
58 }, 58 },
59 - params: { ...params, _t: unref(timespan) }, 59 + params: {
  60 + ...params,
  61 + _t: unref(timespan),
  62 + },
60 onChange: (...args: any[]) => { 63 onChange: (...args: any[]) => {
61 emit('change', ...args); 64 emit('change', ...args);
62 }, 65 },
@@ -136,13 +136,19 @@ @@ -136,13 +136,19 @@
136 const handlePreview = (record: ConfigurationCenterItemsModal) => { 136 const handlePreview = (record: ConfigurationCenterItemsModal) => {
137 if (!unref(getPreviewFlag)) return; 137 if (!unref(getPreviewFlag)) return;
138 window.open( 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 const handleDesign = (record: ConfigurationCenterItemsModal) => { 145 const handleDesign = (record: ConfigurationCenterItemsModal) => {
144 if (!unref(getDesignFlag)) return; 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 const handleDelete = async (record: ConfigurationCenterItemsModal) => { 154 const handleDelete = async (record: ConfigurationCenterItemsModal) => {
@@ -165,6 +171,7 @@ @@ -165,6 +171,7 @@
165 searchParams.set('configurationId', record.id); 171 searchParams.set('configurationId', record.id);
166 searchParams.set('publicId', record.publicId || ''); 172 searchParams.set('publicId', record.publicId || '');
167 searchParams.set('lightbox', '1'); 173 searchParams.set('lightbox', '1');
  174 + searchParams.set('organizationId', record!.organizationId || '');
168 return `${origin}${configurationPrefix}/?${searchParams.toString()}`; 175 return `${origin}${configurationPrefix}/?${searchParams.toString()}`;
169 }; 176 };
170 177
@@ -31,9 +31,9 @@ @@ -31,9 +31,9 @@
31 import { CredentialsEnum } from '../mqtt/enum'; 31 import { CredentialsEnum } from '../mqtt/enum';
32 32
33 const credentialsFile = reactive({ 33 const credentialsFile = reactive({
34 - caCertFileName: '',  
35 - certFileName: '',  
36 - privateKeyFileName: '', 34 + caCertFileName: undefined,
  35 + certFileName: undefined,
  36 + privateKeyFileName: undefined,
37 }); 37 });
38 38
39 const [register, { validateFields, setFieldsValue, resetFields }] = useForm({ 39 const [register, { validateFields, setFieldsValue, resetFields }] = useForm({
@@ -50,6 +50,11 @@ @@ -50,6 +50,11 @@
50 const getValue = async () => { 50 const getValue = async () => {
51 const values = await validateFields(); 51 const values = await validateFields();
52 if (!values) return; 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 const credentials = { 58 const credentials = {
54 type: values['type'], 59 type: values['type'],
55 ...credentialsFile, 60 ...credentialsFile,
@@ -51,10 +51,16 @@ @@ -51,10 +51,16 @@
51 const getValue = async () => { 51 const getValue = async () => {
52 const values = await validateFields(); 52 const values = await validateFields();
53 if (!values) return; 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 const credentials = { 59 const credentials = {
55 type: values['type'], 60 type: values['type'],
56 ...credentialsFile, 61 ...credentialsFile,
57 }; 62 };
  63 +
58 const mergeValues = { 64 const mergeValues = {
59 ...values, 65 ...values,
60 ...{ credentials }, 66 ...{ credentials },
@@ -67,7 +73,12 @@ @@ -67,7 +73,12 @@
67 if (credentials) { 73 if (credentials) {
68 for (let i in credentials) Reflect.set(credentialsFile, i, credentials[i]); 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 const resetValue = () => resetFields(); 84 const resetValue = () => resetFields();
@@ -18,7 +18,7 @@ class MqttFormPartialConfig { @@ -18,7 +18,7 @@ class MqttFormPartialConfig {
18 return [ 18 return [
19 { label: 'Anonymous', value: 'anonymous' }, 19 { label: 'Anonymous', value: 'anonymous' },
20 { label: 'Basic', value: 'basic' }, 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,9 +138,21 @@ export const modeMqttForm: FormSchema[] = [
138 label: '凭据类型', 138 label: '凭据类型',
139 colProps: { span: 12 }, 139 colProps: { span: 12 },
140 defaultValue: MqttFormPartialConfig.type, 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 {
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 export enum CredentialsEnum { 6 export enum CredentialsEnum {
7 IS_ANONYMOUS = 'anonymous', 7 IS_ANONYMOUS = 'anonymous',
8 IS_BASIC = 'basic', 8 IS_BASIC = 'basic',
9 - IS_PEM = 'pem', 9 + IS_PEM = 'cert.PEM',
10 } 10 }
11 11
12 export const isBasic = (type: string) => { 12 export const isBasic = (type: string) => {
@@ -128,8 +128,9 @@ @@ -128,8 +128,9 @@
128 : undefined, 128 : undefined,
129 appendClientIdSuffix: getDataFlowParams.appendClientIdSuffix || undefined, 129 appendClientIdSuffix: getDataFlowParams.appendClientIdSuffix || undefined,
130 type: undefined, 130 type: undefined,
  131 + username: undefined,
  132 + password: undefined,
131 }; 133 };
132 -  
133 const rest = isRabbitmq(getDataFlowMethod?.type) 134 const rest = isRabbitmq(getDataFlowMethod?.type)
134 ? await postAddConvertApi({ ...restData.data, ...data }) 135 ? await postAddConvertApi({ ...restData.data, ...data })
135 : await postAddConvertApi({ ...restData.data, ...data, configuration }); 136 : await postAddConvertApi({ ...restData.data, ...data, configuration });
@@ -755,6 +755,18 @@ export const actionSchema: FormSchema[] = [ @@ -755,6 +755,18 @@ export const actionSchema: FormSchema[] = [
755 component: 'Select', 755 component: 'Select',
756 label: '', 756 label: '',
757 show: ({ values }) => isAlarmOut(values.outTarget), 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 componentProps: { 770 componentProps: {
759 placeholder: '请选择告警等级', 771 placeholder: '请选择告警等级',
760 options: [ 772 options: [
@@ -273,6 +273,10 @@ @@ -273,6 +273,10 @@
273 if (validate.device == 'PART' && validate.deviceId == undefined) 273 if (validate.device == 'PART' && validate.deviceId == undefined)
274 return createMessage.error('请选择设备'); 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 //ft-add-2022-11-22 280 //ft-add-2022-11-22
277 //TODO-fengtao-设备验证 281 //TODO-fengtao-设备验证
278 const value = getFieldsValue(); 282 const value = getFieldsValue();
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 import { BasicForm, useForm } from '/@/components/Form'; 2 import { BasicForm, useForm } from '/@/components/Form';
3 import { BasicModal, useModalInner } from '/@/components/Modal'; 3 import { BasicModal, useModalInner } from '/@/components/Modal';
4 import { formSchemas } from './config'; 4 import { formSchemas } from './config';
5 - import { ref } from 'vue'; 5 + import { nextTick, ref } from 'vue';
6 import { composeData, parseData } from './util'; 6 import { composeData, parseData } from './util';
7 import { createTask, updateTask } from '/@/api/task'; 7 import { createTask, updateTask } from '/@/api/task';
8 import { ModalParamsType } from '/#/utils'; 8 import { ModalParamsType } from '/#/utils';
@@ -33,7 +33,10 @@ @@ -33,7 +33,10 @@
33 modalMode.value = mode; 33 modalMode.value = mode;
34 dataSource.value = record; 34 dataSource.value = record;
35 formMode.value = mode; 35 formMode.value = mode;
36 - resetFields(); 36 + resetFields().then(async () => {
  37 + await nextTick();
  38 + clearValidate();
  39 + });
37 if (record && mode === DataActionModeEnum.UPDATE) { 40 if (record && mode === DataActionModeEnum.UPDATE) {
38 const res = parseData(record); 41 const res = parseData(record);
39 setFieldsValue({ ...res }); 42 setFieldsValue({ ...res });
@@ -41,13 +44,14 @@ @@ -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 const loading = ref(false); 56 const loading = ref(false);
53 const { createMessage } = useMessage(); 57 const { createMessage } = useMessage();
@@ -124,7 +124,6 @@ export const parseData = (result: TaskRecordType): Required<FormValueType> => { @@ -124,7 +124,6 @@ export const parseData = (result: TaskRecordType): Required<FormValueType> => {
124 TaskRecordType['executeTarget'] 124 TaskRecordType['executeTarget']
125 >; 125 >;
126 const { type: executeTimeType, period, periodType, time, pollUnit } = executeTime; 126 const { type: executeTimeType, period, periodType, time, pollUnit } = executeTime;
127 - console.log(pushWay === PushWayEnum.MQTT ? JSON.stringify(rpcCommand, null, 2) : rpcCommand);  
128 return { 127 return {
129 name, 128 name,
130 targetType, 129 targetType,
@@ -188,7 +188,9 @@ @@ -188,7 +188,9 @@
188 if (hasDetailPermission) { 188 if (hasDetailPermission) {
189 const boardId = encode(record.id); 189 const boardId = encode(record.id);
190 const boardName = encode(record.name); 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 } else createMessage.warning('没有权限'); 194 } else createMessage.warning('没有权限');
193 }; 195 };
194 196
@@ -90,6 +90,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => { @@ -90,6 +90,7 @@ export const commonDataSourceSchemas = (): FormSchema[] => {
90 const isUpdate = unref(mode) === DataActionModeEnum.UPDATE; 90 const isUpdate = unref(mode) === DataActionModeEnum.UPDATE;
91 const selectWidgetKeys = useSelectWidgetKeys(); 91 const selectWidgetKeys = useSelectWidgetKeys();
92 const category = unref(selectWidgetKeys).categoryKey; 92 const category = unref(selectWidgetKeys).categoryKey;
  93 +
93 return [ 94 return [
94 { 95 {
95 field: DataSourceField.IS_GATEWAY_DEVICE, 96 field: DataSourceField.IS_GATEWAY_DEVICE,
@@ -191,6 +192,9 @@ export const commonDataSourceSchemas = (): FormSchema[] => { @@ -191,6 +192,9 @@ export const commonDataSourceSchemas = (): FormSchema[] => {
191 }); 192 });
192 }, 193 },
193 showCreate: false, 194 showCreate: false,
  195 + apiTreeSelectProps: {
  196 + params: { organizationId: location?.pathname?.split('/')?.pop() || '' },
  197 + },
194 getPopupContainer: () => document.body, 198 getPopupContainer: () => document.body,
195 }; 199 };
196 }, 200 },