vue2-client 1.17.17 → 1.17.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -166,12 +166,28 @@ export default {
|
|
|
166
166
|
// 使用 $nextTick 确保 DOM 更新完成
|
|
167
167
|
await this.$nextTick()
|
|
168
168
|
|
|
169
|
+
// 确保组件完全就绪后再执行 changeFunc
|
|
170
|
+
if (newRef && newRef[0]) {
|
|
171
|
+
// 等待组件完全就绪(包括内部异步初始化)
|
|
172
|
+
await this.waitForComponentFullyReady(newRef[0], newKey)
|
|
173
|
+
} else {
|
|
174
|
+
// 如果没有组件实例,等待一个 tick 确保 DOM 更新
|
|
175
|
+
await this.$nextTick()
|
|
176
|
+
}
|
|
177
|
+
|
|
169
178
|
result = executeStrFunctionByContext(this, this.config.changeFunc, args)
|
|
170
179
|
|
|
171
180
|
if (result && result.noChange) {
|
|
172
181
|
console.info('不切换页签作为按钮使用')
|
|
182
|
+
// 如果返回 noChange,恢复原来的 activeKey
|
|
183
|
+
if (this.activeKey === newKey) {
|
|
184
|
+
this.activeKey = oldKey
|
|
185
|
+
}
|
|
173
186
|
} else {
|
|
174
|
-
|
|
187
|
+
// 确保 activeKey 已更新(如果还没更新的话)
|
|
188
|
+
if (this.activeKey !== newKey) {
|
|
189
|
+
this.activeKey = newKey
|
|
190
|
+
}
|
|
175
191
|
// 确保回调在组件完全就绪后执行
|
|
176
192
|
if (result && result.callback && typeof result.callback === 'function') {
|
|
177
193
|
await this.$nextTick()
|
|
@@ -214,6 +230,96 @@ export default {
|
|
|
214
230
|
checkComponent()
|
|
215
231
|
})
|
|
216
232
|
},
|
|
233
|
+
// 等待组件完全就绪(包括内部异步初始化)
|
|
234
|
+
waitForComponentFullyReady (component, index) {
|
|
235
|
+
return new Promise((resolve) => {
|
|
236
|
+
if (!component) {
|
|
237
|
+
resolve()
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
let attempts = 0
|
|
242
|
+
const maxAttempts = 60 // 最多等待3秒
|
|
243
|
+
const checkInterval = 50
|
|
244
|
+
|
|
245
|
+
const checkReady = () => {
|
|
246
|
+
attempts++
|
|
247
|
+
|
|
248
|
+
// 1. 检查组件是否有 loading 状态,确保不在加载中
|
|
249
|
+
if (component.loading === true) {
|
|
250
|
+
if (attempts < maxAttempts) {
|
|
251
|
+
setTimeout(checkReady, checkInterval)
|
|
252
|
+
return
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 2. 检查组件是否有 loaded 状态(如 XAddNativeForm)
|
|
257
|
+
if (component.loaded === false) {
|
|
258
|
+
if (attempts < maxAttempts) {
|
|
259
|
+
setTimeout(checkReady, checkInterval)
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 3. 检查组件是否有 realQueryConfig(如 XFormTable)
|
|
265
|
+
const tab = this.config.data[index]
|
|
266
|
+
const isFormTableType = tab?.slotType === 'x-form-table' ||
|
|
267
|
+
tab?.slotType === 'XFormTable' ||
|
|
268
|
+
tab?.slotType?.toLowerCase() === 'xformtable'
|
|
269
|
+
if (isFormTableType && component.realQueryConfig === undefined && !component.loadError) {
|
|
270
|
+
if (attempts < maxAttempts) {
|
|
271
|
+
setTimeout(checkReady, checkInterval)
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 4. 检查关键方法是否存在(如 setForm、setFormWithKey)
|
|
277
|
+
const hasSetForm = typeof component.setForm === 'function'
|
|
278
|
+
const hasSetFormWithKey = typeof component.setFormWithKey === 'function'
|
|
279
|
+
const hasSetFormWithNoKey = typeof component.setFormWithNoKey === 'function'
|
|
280
|
+
|
|
281
|
+
// 5. 如果组件有这些方法,确保表单对象存在
|
|
282
|
+
if (hasSetForm || hasSetFormWithKey || hasSetFormWithNoKey) {
|
|
283
|
+
// 检查组件是否有 form 对象
|
|
284
|
+
if (component.form && Object.keys(component.form).length > 0) {
|
|
285
|
+
// 表单已初始化,等待 DOM 渲染完成
|
|
286
|
+
this.$nextTick(() => {
|
|
287
|
+
// 额外等待一个 tick,确保所有子组件也渲染完成
|
|
288
|
+
this.$nextTick(() => {
|
|
289
|
+
resolve()
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
return
|
|
293
|
+
} else if (component.loaded !== false) {
|
|
294
|
+
// 如果没有 form 对象但 loaded 不为 false,可能还在初始化
|
|
295
|
+
if (attempts < maxAttempts) {
|
|
296
|
+
setTimeout(checkReady, checkInterval)
|
|
297
|
+
return
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 6. 如果以上都通过,或者超时,等待 DOM 渲染完成
|
|
303
|
+
if (attempts >= 3 || attempts >= maxAttempts) {
|
|
304
|
+
// 至少等待几次检查,确保有时间初始化
|
|
305
|
+
this.$nextTick(() => {
|
|
306
|
+
this.$nextTick(() => {
|
|
307
|
+
resolve()
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
return
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// 继续等待
|
|
314
|
+
setTimeout(checkReady, checkInterval)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 首次检查前等待一个 tick
|
|
318
|
+
this.$nextTick(() => {
|
|
319
|
+
checkReady()
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
},
|
|
217
323
|
initConfig () {
|
|
218
324
|
if (this.configName) {
|
|
219
325
|
this.getConfig()
|