...
|
...
|
@@ -88,24 +88,39 @@ |
88
|
88
|
unref(jsonInstance).set({});
|
89
|
89
|
};
|
90
|
90
|
const handleOk = async () => {
|
|
91
|
+ disable.value = true;
|
91
|
92
|
try {
|
92
|
|
- disable.value = true;
|
93
|
93
|
// 验证
|
94
|
94
|
const valid = await validate();
|
95
|
95
|
if (!valid) return;
|
96
|
96
|
// 收集表单数据
|
97
|
97
|
const field = getFieldsValue();
|
|
98
|
+ let passStatus = false;
|
98
|
99
|
if (field.valueType === 'json') {
|
99
|
100
|
const getJson = unref(jsonInstance).get();
|
|
101
|
+ if (Object.prototype.isPrototypeOf(getJson) && Object.keys(getJson).length === 0) {
|
|
102
|
+ createMessage.error('命令内容不能为空');
|
|
103
|
+ passStatus = true;
|
|
104
|
+ }
|
|
105
|
+ if (getJson === '') {
|
|
106
|
+ passStatus = true;
|
|
107
|
+ createMessage.error('命令内容不能为空');
|
|
108
|
+ }
|
100
|
109
|
jsonData.value.params = getJson;
|
101
|
110
|
} else {
|
102
|
111
|
jsonData.value.params = field.commandText;
|
|
112
|
+ if (!jsonData.value.params) {
|
|
113
|
+ createMessage.error('命令内容不能为空');
|
|
114
|
+ passStatus = true;
|
|
115
|
+ }
|
|
116
|
+ if (jsonData.value.params == '""' || jsonData.value.params == "''") {
|
|
117
|
+ createMessage.error('命令内容不能为空');
|
|
118
|
+ passStatus = true;
|
|
119
|
+ }
|
103
|
120
|
}
|
104
|
121
|
jsonData.value.persistent = true;
|
105
|
|
- // jsonData.value.additionalInfo = {
|
106
|
|
- // cmdType: 'API',
|
107
|
|
- // };
|
108
|
122
|
jsonData.value.method = 'methodThingskit';
|
|
123
|
+ if (passStatus) return;
|
109
|
124
|
commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value)
|
110
|
125
|
.then((res) => {
|
111
|
126
|
if (!res) return;
|
...
|
...
|
@@ -126,8 +141,8 @@ |
126
|
141
|
}, 300);
|
127
|
142
|
});
|
128
|
143
|
} catch (e) {
|
|
144
|
+ } finally {
|
129
|
145
|
//这里捕获json插件的错误
|
130
|
|
- createMessage.error('请填写正确的json格式数据');
|
131
|
146
|
disable.value = false;
|
132
|
147
|
}
|
133
|
148
|
};
|
...
|
...
|
|