|
63 | 63 | :type="type" |
64 | 64 | :send-message="sendMessage" |
65 | 65 | :open-chat-id="openChatId" |
66 | | - :check-input-param="checkInputParam" |
| 66 | + :validate="validate" |
67 | 67 | :chat-management="ChatManagement" |
68 | 68 | v-model:chat-id="chartOpenId" |
69 | 69 | v-model:loading="loading" |
@@ -216,30 +216,39 @@ function UserFormCancel() { |
216 | 216 | userFormRef.value?.render(form_data.value) |
217 | 217 | showUserInput.value = false |
218 | 218 | } |
219 | | -const checkInputParam = () => { |
220 | | - return userFormRef.value?.checkInputParam() || false |
| 219 | +
|
| 220 | +const validate = () => { |
| 221 | + return userFormRef.value?.validate() || Promise.reject(false) |
221 | 222 | } |
222 | 223 |
|
223 | 224 | function sendMessage(val: string, other_params_data?: any, chat?: chatType) { |
224 | 225 | if (isUserInput.value) { |
225 | | - if (!userFormRef.value?.checkInputParam()) { |
226 | | - showUserInput.value = true |
227 | | - return |
228 | | - } else { |
229 | | - let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}') |
230 | | - const newData = Object.keys(form_data.value).reduce((result: any, key: string) => { |
231 | | - result[key] = Object.prototype.hasOwnProperty.call(userFormData, key) |
232 | | - ? userFormData[key] |
233 | | - : form_data.value[key] |
234 | | - return result |
235 | | - }, {}) |
236 | | - localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData)) |
237 | | - showUserInput.value = false |
| 226 | + userFormRef.value |
| 227 | + ?.validate() |
| 228 | + .then((ok) => { |
| 229 | + let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}') |
| 230 | + const newData = Object.keys(form_data.value).reduce((result: any, key: string) => { |
| 231 | + result[key] = Object.prototype.hasOwnProperty.call(userFormData, key) |
| 232 | + ? userFormData[key] |
| 233 | + : form_data.value[key] |
| 234 | + return result |
| 235 | + }, {}) |
| 236 | + localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData)) |
| 237 | + showUserInput.value = false |
| 238 | + if (!loading.value && props.applicationDetails?.name) { |
| 239 | + handleDebounceClick(val, other_params_data, chat) |
| 240 | + } |
| 241 | + }) |
| 242 | + .catch((e) => { |
| 243 | + showUserInput.value = true |
| 244 | + return |
| 245 | + }) |
| 246 | + } else { |
| 247 | + showUserInput.value = false |
| 248 | + if (!loading.value && props.applicationDetails?.name) { |
| 249 | + handleDebounceClick(val, other_params_data, chat) |
238 | 250 | } |
239 | 251 | } |
240 | | - if (!loading.value && props.applicationDetails?.name) { |
241 | | - handleDebounceClick(val, other_params_data, chat) |
242 | | - } |
243 | 252 | } |
244 | 253 |
|
245 | 254 | const handleDebounceClick = debounce((val, other_params_data?: any, chat?: chatType) => { |
@@ -268,7 +277,6 @@ const openChatId: () => Promise<string> = () => { |
268 | 277 | }) |
269 | 278 | } else { |
270 | 279 | if (isWorkFlow(obj.type)) { |
271 | | - console.log(obj) |
272 | 280 | const submitObj = { |
273 | 281 | work_flow: obj.work_flow, |
274 | 282 | user_id: obj.user |
|
0 commit comments