Commit d0f93b3eeac7f38d4bc909f4f4114cb71beb1b7b
1 parent
406279a5
fix:DEFECT-503 修复设备下发命令,输入非json数据,点确认,界面卡住,点重置无效问题
Showing
1 changed file
with
39 additions
and
29 deletions
... | ... | @@ -72,37 +72,47 @@ |
72 | 72 | |
73 | 73 | const handleCancel = () => { |
74 | 74 | resetFields(); |
75 | + unref(jsonInstance).set({}); | |
75 | 76 | }; |
76 | 77 | const handleOk = async () => { |
77 | - disable.value = true; | |
78 | - // 验证 | |
79 | - const valid = await validate(); | |
80 | - if (!valid) return; | |
81 | - // 收集表单数据 | |
82 | - const field = getFieldsValue(); | |
83 | - jsonData.value = unref(jsonInstance).get(); | |
84 | - jsonData.value.persistent = true; | |
85 | - jsonData.value.additionalInfo = { | |
86 | - cmdType: 'API', | |
87 | - }; | |
88 | - commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value) | |
89 | - .then((res) => { | |
90 | - if (!res) return; | |
91 | - createMessage.success('命令下发成功'); | |
92 | - disable.value = true; | |
93 | - // 请求 | |
94 | - handleCancel(); | |
95 | - }) | |
96 | - .catch((e) => { | |
97 | - if (e?.message) { | |
98 | - createMessage.error(e?.message); | |
99 | - } | |
100 | - }) | |
101 | - .finally(() => { | |
102 | - setTimeout(() => { | |
103 | - disable.value = false; | |
104 | - }, 300); | |
105 | - }); | |
78 | + try { | |
79 | + disable.value = true; | |
80 | + // 验证 | |
81 | + const valid = await validate(); | |
82 | + if (!valid) return; | |
83 | + // 收集表单数据 | |
84 | + const field = getFieldsValue(); | |
85 | + const getJson = unref(jsonInstance).get(); | |
86 | + jsonData.value.persistent = true; | |
87 | + jsonData.value.additionalInfo = { | |
88 | + cmdType: 'API', | |
89 | + }; | |
90 | + jsonData.value.method = 'setGpio'; | |
91 | + jsonData.value.params = { ...getJson }; | |
92 | + commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value) | |
93 | + .then((res) => { | |
94 | + if (!res) return; | |
95 | + createMessage.success('命令下发成功'); | |
96 | + disable.value = true; | |
97 | + // 请求 | |
98 | + handleCancel(); | |
99 | + }) | |
100 | + .catch((e) => { | |
101 | + if (e?.message) { | |
102 | + createMessage.error(e?.message); | |
103 | + } | |
104 | + handleCancel(); | |
105 | + }) | |
106 | + .finally(() => { | |
107 | + setTimeout(() => { | |
108 | + disable.value = false; | |
109 | + }, 300); | |
110 | + }); | |
111 | + } catch (e) { | |
112 | + //这里捕获json插件的错误 | |
113 | + createMessage.error('请填写正确的json格式数据'); | |
114 | + disable.value = false; | |
115 | + } | |
106 | 116 | }; |
107 | 117 | return { |
108 | 118 | registerForm, | ... | ... |