Commit 6a601e832665913dc01ebe47306b78816378f25d
Merge branch 'fix/DEFECT-1529' into 'main_dev'
fix: 修改告警配置新增联系人成功但是显示无效参数 See merge request yunteng/thingskit-front!839
Showing
2 changed files
with
14 additions
and
3 deletions
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | mode="multiple" | 16 | mode="multiple" |
17 | v-model:value="model[field]" | 17 | v-model:value="model[field]" |
18 | :options="alarmContactOptions.map((item) => ({ value: item.value, label: item.label }))" | 18 | :options="alarmContactOptions.map((item) => ({ value: item.value, label: item.label }))" |
19 | + @change="handleChange" | ||
19 | > | 20 | > |
20 | <template #dropdownRender="{ menuNode: menu }"> | 21 | <template #dropdownRender="{ menuNode: menu }"> |
21 | <v-nodes :vnodes="menu" /> | 22 | <v-nodes :vnodes="menu" /> |
@@ -82,6 +83,7 @@ | @@ -82,6 +83,7 @@ | ||
82 | const [registerAlarmContactDrawer, { openDrawer }] = useDrawer(); | 83 | const [registerAlarmContactDrawer, { openDrawer }] = useDrawer(); |
83 | async function handleSuccess() { | 84 | async function handleSuccess() { |
84 | //获取告警联系人 | 85 | //获取告警联系人 |
86 | + if (!unref(orgId)) return; | ||
85 | const res = await byOrgIdGetAlarmContact(orgId.value); | 87 | const res = await byOrgIdGetAlarmContact(orgId.value); |
86 | if (res) { | 88 | if (res) { |
87 | alarmContactOptions.value = res.map((m) => { | 89 | alarmContactOptions.value = res.map((m) => { |
@@ -91,6 +93,10 @@ | @@ -91,6 +93,10 @@ | ||
91 | alarmContactOptions.value = []; | 93 | alarmContactOptions.value = []; |
92 | } | 94 | } |
93 | } | 95 | } |
96 | + | ||
97 | + const handleChange = () => { | ||
98 | + validateFields(['alarmContactId']); | ||
99 | + }; | ||
94 | // 新增或编辑 | 100 | // 新增或编辑 |
95 | const handleOpenAlarmContact = () => { | 101 | const handleOpenAlarmContact = () => { |
96 | openDrawer(true, { | 102 | openDrawer(true, { |
@@ -100,7 +106,10 @@ | @@ -100,7 +106,10 @@ | ||
100 | const isUpdate = ref(true); | 106 | const isUpdate = ref(true); |
101 | let allData: any = reactive({}); | 107 | let allData: any = reactive({}); |
102 | const editId = ref(''); | 108 | const editId = ref(''); |
103 | - const [registerForm, { validate, setFieldsValue, resetFields, updateSchema }] = useForm({ | 109 | + const [ |
110 | + registerForm, | ||
111 | + { validate, setFieldsValue, resetFields, updateSchema, validateFields }, | ||
112 | + ] = useForm({ | ||
104 | labelWidth: 120, | 113 | labelWidth: 120, |
105 | schemas: formSchema, | 114 | schemas: formSchema, |
106 | showActionButtonGroup: false, | 115 | showActionButtonGroup: false, |
@@ -191,6 +200,7 @@ | @@ -191,6 +200,7 @@ | ||
191 | handleOpenAlarmContact, | 200 | handleOpenAlarmContact, |
192 | registerAlarmContactDrawer, | 201 | registerAlarmContactDrawer, |
193 | handleSuccess, | 202 | handleSuccess, |
203 | + handleChange, | ||
194 | }; | 204 | }; |
195 | }, | 205 | }, |
196 | }); | 206 | }); |
@@ -86,6 +86,7 @@ | @@ -86,6 +86,7 @@ | ||
86 | const deviceIdKeys = Object.keys(details); | 86 | const deviceIdKeys = Object.keys(details); |
87 | const detailObject = deviceIdKeys.map((key) => ({ label: key, value: details[key] })); | 87 | const detailObject = deviceIdKeys.map((key) => ({ label: key, value: details[key] })); |
88 | const dataFormat = await handleAlarmDetailFormat(deviceIdKeys); | 88 | const dataFormat = await handleAlarmDetailFormat(deviceIdKeys); |
89 | + console.log(detailObject, dataFormat, 'dataFormat'); | ||
89 | const dataFormats = detailObject.reduce((acc: any, curr: any) => { | 90 | const dataFormats = detailObject.reduce((acc: any, curr: any) => { |
90 | dataFormat.forEach((item) => { | 91 | dataFormat.forEach((item) => { |
91 | if (item.tbDeviceId === curr.label) { | 92 | if (item.tbDeviceId === curr.label) { |
@@ -130,10 +131,10 @@ | @@ -130,10 +131,10 @@ | ||
130 | const handleAlarmDetailFormat = async (keys: string[]) => { | 131 | const handleAlarmDetailFormat = async (keys: string[]) => { |
131 | const temp: any = []; | 132 | const temp: any = []; |
132 | for (let item of keys) { | 133 | for (let item of keys) { |
133 | - if (item === 'key' || item === 'data') return; //旧数据则终止 | 134 | + if (item === 'key' || item === 'data') return []; //旧数据则终止 |
134 | const deviceDetailRes = await getDeviceDetail(item); | 135 | const deviceDetailRes = await getDeviceDetail(item); |
135 | const { deviceProfileId } = deviceDetailRes; | 136 | const { deviceProfileId } = deviceDetailRes; |
136 | - if (!deviceProfileId) return; | 137 | + if (!deviceProfileId) return []; |
137 | const attributeRes = await getAttribute(deviceProfileId); | 138 | const attributeRes = await getAttribute(deviceProfileId); |
138 | const dataFormat: any = handleDataFormat(deviceDetailRes, attributeRes); | 139 | const dataFormat: any = handleDataFormat(deviceDetailRes, attributeRes); |
139 | temp.push(dataFormat); | 140 | temp.push(dataFormat); |