leisure-core 0.6.65 → 0.6.66

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.
@@ -211,6 +211,10 @@ export default {
211
211
  type: Boolean,
212
212
  default: true,
213
213
  },
214
+ autoOpenDetail: {
215
+ type: [Boolean, Object, String],
216
+ default: false,
217
+ },
214
218
  },
215
219
  watch: {
216
220
  searchParam: {
@@ -231,6 +235,33 @@ export default {
231
235
  },
232
236
  immediate: false,
233
237
  },
238
+ tableData: {
239
+ handler(newVal) {
240
+ if (
241
+ this.autoOpenDetail &&
242
+ !this.autoOpened &&
243
+ newVal &&
244
+ newVal.length
245
+ ) {
246
+ this.$nextTick(() => {
247
+ this.tryAutoOpenDetail();
248
+ });
249
+ }
250
+ },
251
+ immediate: false, // 避免在 mounted 之前触发
252
+ deep: false,
253
+ },
254
+ autoOpenDetail: {
255
+ handler() {
256
+ this.autoOpened = false; // 重置标记,允许重新自动打开
257
+ if (this.tableData && this.tableData.length) {
258
+ this.$nextTick(() => {
259
+ this.tryAutoOpenDetail();
260
+ });
261
+ }
262
+ },
263
+ immediate: true,
264
+ },
234
265
  },
235
266
  data() {
236
267
  return {
@@ -243,6 +274,8 @@ export default {
243
274
  },
244
275
  showDialog: false,
245
276
  handleStatus: 0, //处理状态 0:详情 1:新增 2:编辑
277
+
278
+ autoOpened: false, // 防止重复打开
246
279
  componentMap: {
247
280
  url: {
248
281
  component: "le-url",
@@ -346,6 +379,48 @@ export default {
346
379
  this.$emit("detailCurrentRow", row);
347
380
  this.showDialog = true;
348
381
  },
382
+ openFirstDetail() {
383
+ if (this.tableData && this.tableData.length > 0) {
384
+ const firstRow = this.tableData[0];
385
+ this.detail(firstRow);
386
+ }
387
+ },
388
+ resetAutoOpenFlag() {
389
+ this.autoOpened = false;
390
+ },
391
+ tryAutoOpenDetail() {
392
+ if (this.autoOpened) return;
393
+ const config = this.autoOpenDetail;
394
+ if (!config) return;
395
+
396
+ let targetRow = null;
397
+ if (config === true || config === "first") {
398
+ if (this.tableData && this.tableData.length) {
399
+ targetRow = this.tableData[0];
400
+ } else {
401
+ console.warn("le-list: 表格数据为空,无法自动打开第一行详情");
402
+ return;
403
+ }
404
+ } else if (typeof config === "object" && config !== null) {
405
+ // 传入的对象即视为行数据
406
+ if (Object.keys(config).length) {
407
+ targetRow = config;
408
+ } else {
409
+ console.warn("le-list: 自动打开配置的行数据为空对象");
410
+ return;
411
+ }
412
+ }
413
+
414
+ if (targetRow) {
415
+ // 使用双重 nextTick 确保表格完全渲染后再打开弹窗,消除闪烁
416
+ this.$nextTick(() => {
417
+ setTimeout(() => {
418
+ this.detail(targetRow);
419
+ this.autoOpened = true;
420
+ }, 50); // 极短延迟,平滑过渡
421
+ });
422
+ }
423
+ },
349
424
  addItem() {
350
425
  this.handleStatus = 1;
351
426
  this.$emit("handleStatus", this.handleStatus);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leisure-core",
3
- "version": "0.6.65",
3
+ "version": "0.6.66",
4
4
  "description": "leisure-core是京心数据基于vue2.x开发的一套后台管理系统桌面端组件库,封装了大量实用的UI控件模板,非常方便开发者快速搭建前端应用",
5
5
  "private": false,
6
6
  "author": "北方乐逍遥(zcx7878)",