@qin-ui/element-plus-pro 1.3.4 → 1.3.5
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/api.json +1 -1
- package/es/components/component-provider/types/index.d.ts +2 -2
- package/es/components/component-provider/types/index.d.ts.map +1 -1
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts +1 -1
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -1
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -1
- package/es/element-plus-pro.css +12 -12
- package/es/index.js +336 -274
- package/es/index.js.map +1 -1
- package/package.json +4 -3
- package/src/components/component-provider/types/index.ts +2 -2
- package/src/components/form/components/BaseField/index.vue +11 -7
- package/src/components/form/components/BaseFormItem/index.vue +58 -8
- package/src/components/form/components/ProForm/index.vue +17 -10
- package/src/components/form/hooks/useGroupFieldAttrs.ts +6 -14
- package/src/components/table/components/ColumnControl.vue +4 -2
- package/src/components/table/components/ProTable.vue +24 -16
- package/src/components/table/components/SearchForm.vue +4 -3
- package/src/components/table/components/TableColumnRenderer.vue +22 -9
- package/tsconfig.json +23 -0
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./element-plus-pro.css";
|
|
2
|
-
import { inject, computed, toValue,
|
|
3
|
-
import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput,
|
|
4
|
-
import {
|
|
2
|
+
import { inject, computed, toValue, defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, ref, useAttrs, createCommentVNode, createSlots, renderList, createVNode, resolveComponent, unref, toRaw, provide, useSlots, shallowRef, onUpdated, triggerRef, withModifiers, createElementVNode, normalizeStyle, useModel, watch, mergeModels, onMounted, resolveDirective, normalizeClass, withDirectives, guardReactiveProps, nextTick } from "vue";
|
|
3
|
+
import { ElTable, ElPagination, ElCol, ElFormItem, useFormDisabled, ElTransfer, ElTreeSelect, ElSlider, ElSwitch, ElRadioGroup, ElCheckboxGroup, ElTimeSelect, ElTimePicker, ElDatePicker, ElCascader, ElSelect, ElAutocomplete, ElInputNumber, ElInput, localeContextKey, useLocale as useLocale$1, ElRow, ElForm, ElSpace, ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElCheckbox, ElTableColumn, ElLoading } from "element-plus";
|
|
4
|
+
import { useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, cloneDeep, InjectionFormSlotsKey, isPlainObject, getObject, normalizePathKey, createFormProxy, InjectionFormKey, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, get, pick, isPromise, useTable as useTable$1 } from "@qin-ui/pro-components-core";
|
|
5
5
|
import { useFormData } from "@qin-ui/pro-components-core";
|
|
6
6
|
const _tableProps = ElTable.props || {};
|
|
7
7
|
const _paginationProps = ElPagination.props || {};
|
|
@@ -201,6 +201,38 @@ const ensureInjectConfig = (key) => {
|
|
|
201
201
|
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
202
202
|
return created;
|
|
203
203
|
};
|
|
204
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
205
|
+
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
206
|
+
__name: "index",
|
|
207
|
+
props: {
|
|
208
|
+
component: { type: [Object, Function] }
|
|
209
|
+
},
|
|
210
|
+
setup(__props) {
|
|
211
|
+
return (_ctx, _cache) => {
|
|
212
|
+
return __props.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), {
|
|
213
|
+
default: withCtx(() => [
|
|
214
|
+
renderSlot(_ctx.$slots, "default")
|
|
215
|
+
]),
|
|
216
|
+
_: 3
|
|
217
|
+
}, 16)) : renderSlot(_ctx.$slots, "default", { key: 1 });
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
222
|
+
...{ name: "SlotComponent", inheritAttrs: false },
|
|
223
|
+
__name: "index",
|
|
224
|
+
props: {
|
|
225
|
+
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
226
|
+
},
|
|
227
|
+
setup(__props) {
|
|
228
|
+
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
229
|
+
return (_ctx, _cache) => {
|
|
230
|
+
return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
231
|
+
createTextVNode(toDisplayString(__props.component), 1)
|
|
232
|
+
], 64));
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
});
|
|
204
236
|
const FORM_ITEM_SLOT_KEYS = ["label", "error"];
|
|
205
237
|
const componentMap = {
|
|
206
238
|
"input": ElInput,
|
|
@@ -218,220 +250,6 @@ const componentMap = {
|
|
|
218
250
|
"tree-select": ElTreeSelect,
|
|
219
251
|
"transfer": ElTransfer
|
|
220
252
|
};
|
|
221
|
-
const formItemPropKeys = Object.keys(formItemProps()).filter(
|
|
222
|
-
(k) => k !== "disabled"
|
|
223
|
-
);
|
|
224
|
-
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
225
|
-
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
226
|
-
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
227
|
-
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
228
|
-
function useGroupFieldAttrs(validFields) {
|
|
229
|
-
const config = INJECT_CONFIG["pro-form-item"];
|
|
230
|
-
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
231
|
-
return computed(() => {
|
|
232
|
-
const rawInjectProps = toValue(injectFormItemProps) || {};
|
|
233
|
-
return validFields.value.map((field) => {
|
|
234
|
-
let gridItemProps2 = {};
|
|
235
|
-
let formItemProps2 = {};
|
|
236
|
-
const componentProps = { slots: {} };
|
|
237
|
-
const formItemSlots = {};
|
|
238
|
-
if (isPlainObject(field)) {
|
|
239
|
-
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
240
|
-
const {
|
|
241
|
-
class: injectClassName,
|
|
242
|
-
style: injectStyle,
|
|
243
|
-
span: injectSpan,
|
|
244
|
-
formItemContainer: injectFormItemContainer,
|
|
245
|
-
xs,
|
|
246
|
-
sm,
|
|
247
|
-
md,
|
|
248
|
-
lg,
|
|
249
|
-
xl,
|
|
250
|
-
...injectRest
|
|
251
|
-
} = rawInjectProps;
|
|
252
|
-
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
253
|
-
gridItemProps2 = fields ? { span: span ?? 24 } : initGridItemProps;
|
|
254
|
-
formItemProps2 = mergeProps(
|
|
255
|
-
injectRest,
|
|
256
|
-
{ class: injectClassName, style: injectStyle },
|
|
257
|
-
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
258
|
-
formItemDataAttrs
|
|
259
|
-
);
|
|
260
|
-
const container = formItemContainer ?? injectFormItemContainer;
|
|
261
|
-
Object.keys(rest).forEach((k) => {
|
|
262
|
-
if (gridItemPropKeySet.has(k)) {
|
|
263
|
-
gridItemProps2[k] = rest[k];
|
|
264
|
-
} else if (formItemPropKeySet.has(k)) {
|
|
265
|
-
formItemProps2[k] = rest[k];
|
|
266
|
-
} else {
|
|
267
|
-
componentProps[k] = rest[k];
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
Object.assign(componentProps, componentDataAttrs);
|
|
271
|
-
Object.keys(slots).forEach((k) => {
|
|
272
|
-
if (formItemSlotKeySet.has(k)) {
|
|
273
|
-
formItemSlots[k] = slots[k];
|
|
274
|
-
} else {
|
|
275
|
-
componentProps.slots[k] = slots[k];
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
const raw2 = toValue(name) ?? toValue(path);
|
|
279
|
-
return {
|
|
280
|
-
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
281
|
-
gridItemProps: gridItemProps2,
|
|
282
|
-
formItemProps: formItemProps2,
|
|
283
|
-
formItemSlots,
|
|
284
|
-
componentProps,
|
|
285
|
-
container,
|
|
286
|
-
rawField: field
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
290
|
-
return {
|
|
291
|
-
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
292
|
-
gridItemProps: gridItemProps2,
|
|
293
|
-
formItemProps: formItemProps2,
|
|
294
|
-
formItemSlots,
|
|
295
|
-
componentProps,
|
|
296
|
-
rawField: field
|
|
297
|
-
};
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
302
|
-
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
303
|
-
__name: "index",
|
|
304
|
-
props: {
|
|
305
|
-
grid: { type: [Boolean, Object], default: void 0 },
|
|
306
|
-
fields: { default: () => [] }
|
|
307
|
-
},
|
|
308
|
-
setup(__props) {
|
|
309
|
-
const props = __props;
|
|
310
|
-
const validFields = computed(
|
|
311
|
-
() => (
|
|
312
|
-
// hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
|
|
313
|
-
(props.fields ?? []).filter((field) => !toValue(field.hidden))
|
|
314
|
-
)
|
|
315
|
-
);
|
|
316
|
-
const config = INJECT_CONFIG["pro-form"];
|
|
317
|
-
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
318
|
-
const injectGrid = computed(() => {
|
|
319
|
-
var _a;
|
|
320
|
-
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
321
|
-
});
|
|
322
|
-
const enableGrid = computed(() => {
|
|
323
|
-
if (props.grid !== void 0) return !!props.grid;
|
|
324
|
-
return !!injectGrid.value;
|
|
325
|
-
});
|
|
326
|
-
const computedGridProps = computed(() => {
|
|
327
|
-
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
328
|
-
});
|
|
329
|
-
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
330
|
-
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
331
|
-
const setFormItemRef = (field, el, formItemProps2) => {
|
|
332
|
-
if (!field || typeof field !== "object") return;
|
|
333
|
-
const raw = toRaw(field);
|
|
334
|
-
if (el) {
|
|
335
|
-
formItemInstanceMap.set(raw, el);
|
|
336
|
-
raw.getFormItemRef = () => formItemInstanceMap.get(raw);
|
|
337
|
-
raw.getFormItemComputedProps = () => formItemProps2;
|
|
338
|
-
} else {
|
|
339
|
-
formItemInstanceMap.delete(raw);
|
|
340
|
-
delete raw.getFormItemRef;
|
|
341
|
-
delete raw.getFormItemComputedProps;
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
const setComponentRef = (field, el) => {
|
|
345
|
-
if (!field || typeof field !== "object") return;
|
|
346
|
-
const raw = toRaw(field);
|
|
347
|
-
if (el) {
|
|
348
|
-
componentInstanceMap.set(raw, el);
|
|
349
|
-
raw.getComponentRef = () => {
|
|
350
|
-
var _a;
|
|
351
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
352
|
-
};
|
|
353
|
-
raw.getComponentComputedProps = () => {
|
|
354
|
-
var _a;
|
|
355
|
-
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
356
|
-
};
|
|
357
|
-
} else {
|
|
358
|
-
componentInstanceMap.delete(raw);
|
|
359
|
-
delete raw.getComponentRef;
|
|
360
|
-
delete raw.getComponentComputedProps;
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
const groupedFields = useGroupFieldAttrs(validFields);
|
|
364
|
-
return (_ctx, _cache) => {
|
|
365
|
-
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
366
|
-
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
367
|
-
component: enableGrid.value ? unref(ElRow) : void 0
|
|
368
|
-
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
369
|
-
default: withCtx(() => [
|
|
370
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item, index2) => {
|
|
371
|
-
return openBlock(), createBlock(unref(_sfc_main$d), mergeProps({
|
|
372
|
-
key: item.path || index2,
|
|
373
|
-
component: enableGrid.value ? unref(ElCol) : void 0
|
|
374
|
-
}, { ref_for: true }, item.gridItemProps), {
|
|
375
|
-
default: withCtx(() => [
|
|
376
|
-
createVNode(unref(_sfc_main$d), {
|
|
377
|
-
component: item.container,
|
|
378
|
-
path: item.path
|
|
379
|
-
}, {
|
|
380
|
-
default: withCtx(() => [
|
|
381
|
-
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
382
|
-
ref_for: true,
|
|
383
|
-
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
384
|
-
prop: unref(normalizePathKey)(item.path),
|
|
385
|
-
path: item.path
|
|
386
|
-
}), createSlots({
|
|
387
|
-
default: withCtx(() => [
|
|
388
|
-
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
389
|
-
key: 0,
|
|
390
|
-
grid: item.rawField.grid ?? props.grid,
|
|
391
|
-
fields: item.rawField.fields
|
|
392
|
-
}, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(unref(_sfc_main$e), mergeProps({
|
|
393
|
-
key: 1,
|
|
394
|
-
ref_for: true,
|
|
395
|
-
ref: (el) => setComponentRef(item.rawField, el)
|
|
396
|
-
}, { ref_for: true }, item.componentProps, {
|
|
397
|
-
path: item.path
|
|
398
|
-
}), null, 16, ["path"]))
|
|
399
|
-
]),
|
|
400
|
-
_: 2
|
|
401
|
-
}, [
|
|
402
|
-
renderList(item.formItemSlots, (slot, name) => {
|
|
403
|
-
return {
|
|
404
|
-
name,
|
|
405
|
-
fn: withCtx((scoped) => [
|
|
406
|
-
createVNode(unref(_sfc_main$c), mergeProps({
|
|
407
|
-
path: item.path,
|
|
408
|
-
component: slot
|
|
409
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
410
|
-
])
|
|
411
|
-
};
|
|
412
|
-
})
|
|
413
|
-
]), 1040, ["prop", "path"])
|
|
414
|
-
]),
|
|
415
|
-
_: 2
|
|
416
|
-
}, 1032, ["component", "path"])
|
|
417
|
-
]),
|
|
418
|
-
_: 2
|
|
419
|
-
}, 1040, ["component"]);
|
|
420
|
-
}), 128))
|
|
421
|
-
]),
|
|
422
|
-
_: 1
|
|
423
|
-
}, 16, ["component"]);
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
const _export_sfc = (sfc, props) => {
|
|
428
|
-
const target = sfc.__vccOpts || sfc;
|
|
429
|
-
for (const [key, val] of props) {
|
|
430
|
-
target[key] = val;
|
|
431
|
-
}
|
|
432
|
-
return target;
|
|
433
|
-
};
|
|
434
|
-
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-42bb0876"]]);
|
|
435
253
|
function useForm(...args) {
|
|
436
254
|
return useForm$1(...args);
|
|
437
255
|
}
|
|
@@ -550,7 +368,7 @@ const useLocale = () => {
|
|
|
550
368
|
};
|
|
551
369
|
return { t, lang };
|
|
552
370
|
};
|
|
553
|
-
const _sfc_main$
|
|
371
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
554
372
|
...{ name: "BaseField", inheritAttrs: false },
|
|
555
373
|
__name: "index",
|
|
556
374
|
props: {
|
|
@@ -558,6 +376,10 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
558
376
|
path: { default: "" }
|
|
559
377
|
},
|
|
560
378
|
setup(__props, { expose: __expose }) {
|
|
379
|
+
const cloneDeepIfObject = (val) => (
|
|
380
|
+
// 原始值直接传递,引用值克隆快照
|
|
381
|
+
typeof val === "object" && val !== null ? cloneDeep(val) : val
|
|
382
|
+
);
|
|
561
383
|
const props = __props;
|
|
562
384
|
const { t } = useLocale();
|
|
563
385
|
const form = useForm(false);
|
|
@@ -583,7 +405,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
583
405
|
const { valueFormatter } = groupedAttrs.value;
|
|
584
406
|
const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
|
|
585
407
|
if (setFormatter) {
|
|
586
|
-
const oldVal = setFormatter.length > 1 ?
|
|
408
|
+
const oldVal = setFormatter.length > 1 ? cloneDeepIfObject((_a = form.getFormData) == null ? void 0 : _a.call(form, props.path)) : void 0;
|
|
587
409
|
newVal = setFormatter(val, oldVal);
|
|
588
410
|
}
|
|
589
411
|
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
@@ -625,14 +447,14 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
625
447
|
onUpdateValue
|
|
626
448
|
};
|
|
627
449
|
});
|
|
628
|
-
const
|
|
450
|
+
const injectedFormSlots = inject(InjectionFormSlotsKey, void 0);
|
|
629
451
|
const customComponents = inject(INJECT_COMPONENTS, {});
|
|
630
452
|
const is = computed(() => {
|
|
631
|
-
var _a;
|
|
632
|
-
const teleportSlot = props.path && (
|
|
453
|
+
var _a, _b;
|
|
454
|
+
const teleportSlot = props.path && ((_a = injectedFormSlots == null ? void 0 : injectedFormSlots.value) == null ? void 0 : _a[props.path]);
|
|
633
455
|
if (teleportSlot) return teleportSlot;
|
|
634
456
|
if (typeof props.component === "string") {
|
|
635
|
-
const resolved = ((
|
|
457
|
+
const resolved = ((_b = toValue(customComponents)) == null ? void 0 : _b[props.component]) || componentMap[props.component];
|
|
636
458
|
if (resolved) return resolved;
|
|
637
459
|
warnUnknownComponent(props.component);
|
|
638
460
|
return props.component;
|
|
@@ -644,7 +466,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
644
466
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
645
467
|
});
|
|
646
468
|
return (_ctx, _cache) => {
|
|
647
|
-
return openBlock(), createBlock(
|
|
469
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
648
470
|
component: groupedAttrs.value.componentContainer,
|
|
649
471
|
path: props.path
|
|
650
472
|
}, {
|
|
@@ -660,7 +482,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
660
482
|
return {
|
|
661
483
|
name,
|
|
662
484
|
fn: withCtx((scoped) => [
|
|
663
|
-
createVNode(
|
|
485
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
664
486
|
path: props.path
|
|
665
487
|
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
666
488
|
])
|
|
@@ -673,38 +495,244 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
673
495
|
};
|
|
674
496
|
}
|
|
675
497
|
});
|
|
676
|
-
const
|
|
677
|
-
|
|
498
|
+
const formItemPropKeys = Object.keys(formItemProps()).filter(
|
|
499
|
+
(k) => k !== "disabled"
|
|
500
|
+
);
|
|
501
|
+
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
502
|
+
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
503
|
+
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
504
|
+
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
505
|
+
function useGroupFieldAttrs(validFields) {
|
|
506
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
507
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
508
|
+
return computed(() => {
|
|
509
|
+
const rawInjectProps = toValue(injectFormItemProps) || {};
|
|
510
|
+
return validFields.value.map((field) => {
|
|
511
|
+
let gridItemProps2 = {};
|
|
512
|
+
let formItemProps2 = {};
|
|
513
|
+
const componentProps = { slots: {} };
|
|
514
|
+
const formItemSlots = {};
|
|
515
|
+
if (isPlainObject(field)) {
|
|
516
|
+
const { path, name, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
517
|
+
const { class: injectClassName, style: injectStyle, span: injectSpan, formItemContainer: injectFormItemContainer, xs, sm, md, lg, xl, ...injectRest } = rawInjectProps;
|
|
518
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
519
|
+
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
520
|
+
formItemProps2 = mergeProps(
|
|
521
|
+
injectRest,
|
|
522
|
+
{ class: injectClassName, style: injectStyle },
|
|
523
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
524
|
+
formItemDataAttrs
|
|
525
|
+
);
|
|
526
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
527
|
+
Object.keys(rest).forEach((k) => {
|
|
528
|
+
if (gridItemPropKeySet.has(k)) {
|
|
529
|
+
gridItemProps2[k] = rest[k];
|
|
530
|
+
} else if (formItemPropKeySet.has(k)) {
|
|
531
|
+
formItemProps2[k] = rest[k];
|
|
532
|
+
} else {
|
|
533
|
+
componentProps[k] = rest[k];
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
537
|
+
Object.keys(slots).forEach((k) => {
|
|
538
|
+
if (formItemSlotKeySet.has(k)) {
|
|
539
|
+
formItemSlots[k] = slots[k];
|
|
540
|
+
} else {
|
|
541
|
+
componentProps.slots[k] = slots[k];
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
const raw2 = toValue(name) ?? toValue(path);
|
|
545
|
+
return {
|
|
546
|
+
path: Array.isArray(raw2) ? raw2.join(".") : raw2 || "",
|
|
547
|
+
gridItemProps: gridItemProps2,
|
|
548
|
+
formItemProps: formItemProps2,
|
|
549
|
+
formItemSlots,
|
|
550
|
+
componentProps,
|
|
551
|
+
container,
|
|
552
|
+
rawField: field
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
const raw = toValue(field == null ? void 0 : field.name) ?? toValue(field == null ? void 0 : field.path);
|
|
556
|
+
return {
|
|
557
|
+
path: Array.isArray(raw) ? raw.join(".") : raw || "",
|
|
558
|
+
gridItemProps: gridItemProps2,
|
|
559
|
+
formItemProps: formItemProps2,
|
|
560
|
+
formItemSlots,
|
|
561
|
+
componentProps,
|
|
562
|
+
rawField: field
|
|
563
|
+
};
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
568
|
+
...{ name: "BaseFormItem", inheritAttrs: false },
|
|
678
569
|
__name: "index",
|
|
679
570
|
props: {
|
|
680
|
-
|
|
571
|
+
grid: { type: [Boolean, Object], default: void 0 },
|
|
572
|
+
fields: { default: () => [] }
|
|
681
573
|
},
|
|
682
574
|
setup(__props) {
|
|
575
|
+
let fieldKeySeed = 0;
|
|
576
|
+
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
577
|
+
const getFieldKey = (field) => {
|
|
578
|
+
const raw = toRaw(field);
|
|
579
|
+
let key = fieldKeyMap.get(raw);
|
|
580
|
+
if (key === void 0) {
|
|
581
|
+
key = ++fieldKeySeed;
|
|
582
|
+
fieldKeyMap.set(raw, key);
|
|
583
|
+
}
|
|
584
|
+
return key;
|
|
585
|
+
};
|
|
586
|
+
const props = __props;
|
|
587
|
+
const validFields = computed(
|
|
588
|
+
() => (
|
|
589
|
+
// hidden 支持 Ref/ComputedRef/getter 等响应式形态(统一使用 toValue 取值)
|
|
590
|
+
(props.fields ?? []).filter((field) => !toValue(field.hidden))
|
|
591
|
+
)
|
|
592
|
+
);
|
|
593
|
+
const config = INJECT_CONFIG["pro-form"];
|
|
594
|
+
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
595
|
+
const injectGrid = computed(() => {
|
|
596
|
+
var _a;
|
|
597
|
+
return (_a = toValue(injectFormConfig)) == null ? void 0 : _a.grid;
|
|
598
|
+
});
|
|
599
|
+
const enableGrid = computed(() => {
|
|
600
|
+
if (props.grid !== void 0) return !!props.grid;
|
|
601
|
+
return !!injectGrid.value;
|
|
602
|
+
});
|
|
603
|
+
const computedGridProps = computed(() => {
|
|
604
|
+
return enableGrid.value ? { ...getObject(injectGrid.value), ...getObject(props.grid) } : {};
|
|
605
|
+
});
|
|
606
|
+
const formItemInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
607
|
+
const componentInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
608
|
+
const warnedFrozenFields = /* @__PURE__ */ new WeakSet();
|
|
609
|
+
const defineFieldAccessors = (raw, accessors) => {
|
|
610
|
+
try {
|
|
611
|
+
for (const [key, getter] of Object.entries(accessors)) {
|
|
612
|
+
Object.defineProperty(raw, key, {
|
|
613
|
+
value: getter,
|
|
614
|
+
enumerable: false,
|
|
615
|
+
configurable: true,
|
|
616
|
+
writable: true
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
} catch {
|
|
620
|
+
if (!warnedFrozenFields.has(raw)) {
|
|
621
|
+
warnedFrozenFields.add(raw);
|
|
622
|
+
console.warn(
|
|
623
|
+
"[pro-components] 字段配置对象不可写(如被 Object.freeze),getFormItemRef / getComponentRef 等实例访问器挂载失败。"
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
const setFormItemRef = (field, el, formItemProps2) => {
|
|
629
|
+
if (!field || typeof field !== "object") return;
|
|
630
|
+
const raw = toRaw(field);
|
|
631
|
+
if (el) {
|
|
632
|
+
formItemInstanceMap.set(raw, el);
|
|
633
|
+
defineFieldAccessors(raw, {
|
|
634
|
+
getFormItemRef: () => formItemInstanceMap.get(raw),
|
|
635
|
+
getFormItemComputedProps: () => formItemProps2
|
|
636
|
+
});
|
|
637
|
+
} else {
|
|
638
|
+
formItemInstanceMap.delete(raw);
|
|
639
|
+
delete raw.getFormItemRef;
|
|
640
|
+
delete raw.getFormItemComputedProps;
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
const setComponentRef = (field, el) => {
|
|
644
|
+
if (!field || typeof field !== "object") return;
|
|
645
|
+
const raw = toRaw(field);
|
|
646
|
+
if (el) {
|
|
647
|
+
componentInstanceMap.set(raw, el);
|
|
648
|
+
defineFieldAccessors(raw, {
|
|
649
|
+
getComponentRef: () => {
|
|
650
|
+
var _a;
|
|
651
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentRef();
|
|
652
|
+
},
|
|
653
|
+
getComponentComputedProps: () => {
|
|
654
|
+
var _a;
|
|
655
|
+
return (_a = componentInstanceMap.get(raw)) == null ? void 0 : _a.getComponentComputedProps();
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
} else {
|
|
659
|
+
componentInstanceMap.delete(raw);
|
|
660
|
+
delete raw.getComponentRef;
|
|
661
|
+
delete raw.getComponentComputedProps;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const groupedFields = useGroupFieldAttrs(validFields);
|
|
683
665
|
return (_ctx, _cache) => {
|
|
684
|
-
|
|
666
|
+
const _component_BaseFormItem = resolveComponent("BaseFormItem");
|
|
667
|
+
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
668
|
+
component: enableGrid.value ? unref(ElRow) : void 0
|
|
669
|
+
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
685
670
|
default: withCtx(() => [
|
|
686
|
-
|
|
671
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(groupedFields), (item) => {
|
|
672
|
+
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
673
|
+
key: item.path || getFieldKey(item.rawField),
|
|
674
|
+
component: enableGrid.value ? unref(ElCol) : void 0
|
|
675
|
+
}, { ref_for: true }, item.gridItemProps), {
|
|
676
|
+
default: withCtx(() => [
|
|
677
|
+
createVNode(_sfc_main$f, {
|
|
678
|
+
component: item.container,
|
|
679
|
+
path: item.path
|
|
680
|
+
}, {
|
|
681
|
+
default: withCtx(() => [
|
|
682
|
+
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
683
|
+
ref_for: true,
|
|
684
|
+
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
685
|
+
prop: unref(normalizePathKey)(item.path),
|
|
686
|
+
path: item.path
|
|
687
|
+
}), createSlots({
|
|
688
|
+
default: withCtx(() => [
|
|
689
|
+
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
690
|
+
key: 0,
|
|
691
|
+
grid: item.rawField.grid ?? props.grid,
|
|
692
|
+
fields: item.rawField.fields
|
|
693
|
+
}, null, 8, ["grid", "fields"])) : (openBlock(), createBlock(_sfc_main$d, mergeProps({
|
|
694
|
+
key: 1,
|
|
695
|
+
ref_for: true,
|
|
696
|
+
ref: (el) => setComponentRef(item.rawField, el)
|
|
697
|
+
}, { ref_for: true }, item.componentProps, {
|
|
698
|
+
path: item.path
|
|
699
|
+
}), null, 16, ["path"]))
|
|
700
|
+
]),
|
|
701
|
+
_: 2
|
|
702
|
+
}, [
|
|
703
|
+
renderList(item.formItemSlots, (slot, name) => {
|
|
704
|
+
return {
|
|
705
|
+
name,
|
|
706
|
+
fn: withCtx((scoped) => [
|
|
707
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
708
|
+
path: item.path,
|
|
709
|
+
component: slot
|
|
710
|
+
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
711
|
+
])
|
|
712
|
+
};
|
|
713
|
+
})
|
|
714
|
+
]), 1040, ["prop", "path"])
|
|
715
|
+
]),
|
|
716
|
+
_: 2
|
|
717
|
+
}, 1032, ["component", "path"])
|
|
718
|
+
]),
|
|
719
|
+
_: 2
|
|
720
|
+
}, 1040, ["component"]);
|
|
721
|
+
}), 128))
|
|
687
722
|
]),
|
|
688
|
-
_:
|
|
689
|
-
}, 16
|
|
723
|
+
_: 1
|
|
724
|
+
}, 16, ["component"]);
|
|
690
725
|
};
|
|
691
726
|
}
|
|
692
727
|
});
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
component: { type: [Object, Function, String, Number, Boolean, null] }
|
|
698
|
-
},
|
|
699
|
-
setup(__props) {
|
|
700
|
-
const isRenderable = (c) => c !== null && c !== void 0 && (typeof c === "function" || typeof c === "object");
|
|
701
|
-
return (_ctx, _cache) => {
|
|
702
|
-
return isRenderable(__props.component) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), null, 16)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
703
|
-
createTextVNode(toDisplayString(__props.component), 1)
|
|
704
|
-
], 64));
|
|
705
|
-
};
|
|
728
|
+
const _export_sfc = (sfc, props) => {
|
|
729
|
+
const target = sfc.__vccOpts || sfc;
|
|
730
|
+
for (const [key, val] of props) {
|
|
731
|
+
target[key] = val;
|
|
706
732
|
}
|
|
707
|
-
|
|
733
|
+
return target;
|
|
734
|
+
};
|
|
735
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-6f664240"]]);
|
|
708
736
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
709
737
|
...{ name: "ProForm", inheritAttrs: false },
|
|
710
738
|
__name: "index",
|
|
@@ -714,9 +742,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
714
742
|
},
|
|
715
743
|
setup(__props) {
|
|
716
744
|
const props = __props;
|
|
717
|
-
|
|
745
|
+
let fallbackForm;
|
|
718
746
|
const currentForm = computed(
|
|
719
|
-
() => props.form ?? fallbackForm
|
|
747
|
+
() => props.form ?? (fallbackForm ?? (fallbackForm = useForm()))
|
|
720
748
|
);
|
|
721
749
|
const formProxy = createFormProxy(() => currentForm.value);
|
|
722
750
|
provide(InjectionFormKey, formProxy);
|
|
@@ -736,6 +764,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
736
764
|
let formInstanceCounter = 0;
|
|
737
765
|
const formInstanceKeyMap = /* @__PURE__ */ new WeakMap();
|
|
738
766
|
const getFormKey = (f) => {
|
|
767
|
+
if (f == null) return 0;
|
|
739
768
|
if (!formInstanceKeyMap.has(f)) {
|
|
740
769
|
formInstanceKeyMap.set(f, ++formInstanceCounter);
|
|
741
770
|
}
|
|
@@ -754,7 +783,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
754
783
|
return mergeProps(injectAttrs.value, camelizeProperties(attrs));
|
|
755
784
|
});
|
|
756
785
|
const slots = useSlots();
|
|
757
|
-
|
|
786
|
+
const formSlotsRef = shallowRef(slots);
|
|
787
|
+
onUpdated(() => {
|
|
788
|
+
triggerRef(formSlotsRef);
|
|
789
|
+
});
|
|
790
|
+
provide(InjectionFormSlotsKey, formSlotsRef);
|
|
758
791
|
return (_ctx, _cache) => {
|
|
759
792
|
return openBlock(), createBlock(unref(ElForm), mergeProps({
|
|
760
793
|
key: formKey.value,
|
|
@@ -766,7 +799,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
766
799
|
}, ["prevent"]))
|
|
767
800
|
}), {
|
|
768
801
|
default: withCtx(() => [
|
|
769
|
-
createVNode(
|
|
802
|
+
createVNode(BaseFormItem, {
|
|
770
803
|
fields: fields.value,
|
|
771
804
|
grid: props.grid
|
|
772
805
|
}, null, 8, ["fields", "grid"]),
|
|
@@ -849,9 +882,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
849
882
|
emit("search");
|
|
850
883
|
};
|
|
851
884
|
return (_ctx, _cache) => {
|
|
852
|
-
return openBlock(), createBlock(
|
|
885
|
+
return openBlock(), createBlock(_sfc_main$b, mergeProps(layoutProps.value, {
|
|
853
886
|
form: props.form,
|
|
854
|
-
class: "pro-table_search-form transition"
|
|
887
|
+
class: "pro-table_search-form transition",
|
|
888
|
+
onSubmit: withModifiers(onSearch, ["prevent"])
|
|
855
889
|
}), {
|
|
856
890
|
default: withCtx(() => [
|
|
857
891
|
createVNode(unref(ElSpace), {
|
|
@@ -885,8 +919,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
885
919
|
key: 1,
|
|
886
920
|
class: "pro-table_search-form_search-button",
|
|
887
921
|
type: "primary",
|
|
888
|
-
"native-type": "submit"
|
|
889
|
-
onClick: onSearch
|
|
922
|
+
"native-type": "submit"
|
|
890
923
|
}, {
|
|
891
924
|
default: withCtx(() => [
|
|
892
925
|
createTextVNode(toDisplayString(unref(t)("table.query")), 1)
|
|
@@ -930,7 +963,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
|
930
963
|
};
|
|
931
964
|
}
|
|
932
965
|
});
|
|
933
|
-
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-
|
|
966
|
+
const SearchForm = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-746ff159"]]);
|
|
934
967
|
const _sfc_main$8 = {};
|
|
935
968
|
const _hoisted_1$4 = { class: "pro-table_search-form-container" };
|
|
936
969
|
function _sfc_render$3(_ctx, _cache) {
|
|
@@ -1085,11 +1118,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1085
1118
|
);
|
|
1086
1119
|
},
|
|
1087
1120
|
set(val) {
|
|
1121
|
+
const checkedSet = new Set(val);
|
|
1088
1122
|
checkedColumnsOptions.value.forEach((item) => {
|
|
1089
1123
|
var _a;
|
|
1090
|
-
if (item.disabled) return;
|
|
1124
|
+
if (item.disabled || item.checked === checkedSet.has(item.value)) return;
|
|
1091
1125
|
(_a = props.table) == null ? void 0 : _a.setColumn(item.value, {
|
|
1092
|
-
hidden: !
|
|
1126
|
+
hidden: !checkedSet.has(item.value)
|
|
1093
1127
|
});
|
|
1094
1128
|
});
|
|
1095
1129
|
}
|
|
@@ -1204,7 +1238,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1204
1238
|
};
|
|
1205
1239
|
}
|
|
1206
1240
|
});
|
|
1207
|
-
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
1241
|
+
const ColumnControl = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-55e837c0"]]);
|
|
1208
1242
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1209
1243
|
...{ name: "TableColumnRenderer" },
|
|
1210
1244
|
__name: "TableColumnRenderer",
|
|
@@ -1213,9 +1247,21 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1213
1247
|
},
|
|
1214
1248
|
setup(__props) {
|
|
1215
1249
|
const props = __props;
|
|
1216
|
-
|
|
1250
|
+
let columnKeySeed = 0;
|
|
1251
|
+
const columnKeyMap = /* @__PURE__ */ new WeakMap();
|
|
1252
|
+
const getStableColumnKey = (column) => {
|
|
1253
|
+
const raw = toRaw(column);
|
|
1254
|
+
let key = columnKeyMap.get(raw);
|
|
1255
|
+
if (key === void 0) {
|
|
1256
|
+
key = ++columnKeySeed;
|
|
1257
|
+
columnKeyMap.set(raw, key);
|
|
1258
|
+
}
|
|
1259
|
+
return key;
|
|
1260
|
+
};
|
|
1261
|
+
const getColumnKey = (column) => {
|
|
1217
1262
|
const rawKey = column.key ?? column.prop;
|
|
1218
|
-
if (rawKey === void 0 || rawKey === null)
|
|
1263
|
+
if (rawKey === void 0 || rawKey === null)
|
|
1264
|
+
return getStableColumnKey(column);
|
|
1219
1265
|
return normalizePathKey(rawKey);
|
|
1220
1266
|
};
|
|
1221
1267
|
const getCellValue = (row, column) => {
|
|
@@ -1239,9 +1285,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1239
1285
|
};
|
|
1240
1286
|
return (_ctx, _cache) => {
|
|
1241
1287
|
const _component_TableColumnRenderer = resolveComponent("TableColumnRenderer", true);
|
|
1242
|
-
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column
|
|
1288
|
+
return openBlock(true), createElementBlock(Fragment, null, renderList(normalizedColumns.value, (column) => {
|
|
1243
1289
|
return openBlock(), createElementBlock(Fragment, {
|
|
1244
|
-
key: getColumnKey(column
|
|
1290
|
+
key: getColumnKey(column)
|
|
1245
1291
|
}, [
|
|
1246
1292
|
column.children && column.children.length > 0 ? (openBlock(), createBlock(unref(ElTableColumn), mergeProps({
|
|
1247
1293
|
key: 0,
|
|
@@ -1260,7 +1306,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
1260
1306
|
default: withCtx((scope) => {
|
|
1261
1307
|
var _a;
|
|
1262
1308
|
return [
|
|
1263
|
-
createVNode(
|
|
1309
|
+
createVNode(_sfc_main$e, {
|
|
1264
1310
|
component: (_a = column.render) == null ? void 0 : _a.call(column, {
|
|
1265
1311
|
...scope,
|
|
1266
1312
|
column,
|
|
@@ -1379,11 +1425,27 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1379
1425
|
const size = useModel(__props, "size");
|
|
1380
1426
|
const loading = useModel(__props, "loading");
|
|
1381
1427
|
let searchSequence = 0;
|
|
1428
|
+
let warnedSearchConfig = false;
|
|
1429
|
+
const warnSearchConfig = (reason) => {
|
|
1430
|
+
if (warnedSearchConfig) return;
|
|
1431
|
+
warnedSearchConfig = true;
|
|
1432
|
+
console.warn(`[ProTable] ${reason}`);
|
|
1433
|
+
};
|
|
1382
1434
|
const _search = async () => {
|
|
1383
1435
|
var _a;
|
|
1384
|
-
|
|
1436
|
+
if (props.search && attrs.onSearch) {
|
|
1437
|
+
warnSearchConfig(
|
|
1438
|
+
"同时配置了 :search prop 与 @search 监听,@search 监听不会被执行,请仅保留其一。"
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1385
1441
|
const searchPromise = (_a = props.search || attrs.onSearch) == null ? void 0 : _a();
|
|
1386
|
-
if (!isPromise(searchPromise))
|
|
1442
|
+
if (!isPromise(searchPromise)) {
|
|
1443
|
+
warnSearchConfig(
|
|
1444
|
+
"search 未返回 Promise,本次查询不参与 loading 竞态管理(在途请求的 loading 状态保持不变)。"
|
|
1445
|
+
);
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
const seq = ++searchSequence;
|
|
1387
1449
|
loading.value = true;
|
|
1388
1450
|
try {
|
|
1389
1451
|
await searchPromise;
|
|
@@ -1453,9 +1515,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1453
1515
|
return source;
|
|
1454
1516
|
});
|
|
1455
1517
|
const computedDataSource = computed(() => {
|
|
1456
|
-
var _a
|
|
1518
|
+
var _a;
|
|
1457
1519
|
const attrsData = attrsTableProps.value.data;
|
|
1458
|
-
return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.
|
|
1520
|
+
return props.data ?? attrsData ?? toValue((_a = props.table) == null ? void 0 : _a.data) ?? [];
|
|
1459
1521
|
});
|
|
1460
1522
|
const computedTableProps = computed(() => {
|
|
1461
1523
|
const merged = {
|
|
@@ -1550,7 +1612,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1550
1612
|
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1551
1613
|
style: normalizeStyle(unref(attrs).style)
|
|
1552
1614
|
}, [
|
|
1553
|
-
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(
|
|
1615
|
+
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$f, {
|
|
1554
1616
|
key: 0,
|
|
1555
1617
|
component: computedSearchFormConfig.value.container
|
|
1556
1618
|
}, {
|
|
@@ -1570,7 +1632,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1570
1632
|
]),
|
|
1571
1633
|
_: 3
|
|
1572
1634
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
1573
|
-
createVNode(
|
|
1635
|
+
createVNode(_sfc_main$f, { component: computedTableContainer.value }, {
|
|
1574
1636
|
default: withCtx(() => [
|
|
1575
1637
|
createElementVNode("div", _hoisted_1, [
|
|
1576
1638
|
_ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
@@ -1580,13 +1642,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1580
1642
|
renderSlot(_ctx.$slots, "toolbar", {}, void 0, true)
|
|
1581
1643
|
])) : createCommentVNode("", true),
|
|
1582
1644
|
computedControl.value.sizeControl ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
1583
|
-
createVNode(
|
|
1645
|
+
createVNode(SizeControl, {
|
|
1584
1646
|
size: size.value,
|
|
1585
1647
|
"onUpdate:size": _cache[0] || (_cache[0] = ($event) => size.value = $event)
|
|
1586
1648
|
}, null, 8, ["size"])
|
|
1587
1649
|
])) : createCommentVNode("", true),
|
|
1588
1650
|
computedControl.value.columnControl ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
1589
|
-
createVNode(
|
|
1651
|
+
createVNode(ColumnControl, {
|
|
1590
1652
|
columns: normalizedRawColumns.value.filter((item) => item.key !== "__INDEX__"),
|
|
1591
1653
|
table: props.table,
|
|
1592
1654
|
"column-control": columnControlConfig.value
|
|
@@ -1630,7 +1692,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1630
1692
|
};
|
|
1631
1693
|
}
|
|
1632
1694
|
});
|
|
1633
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1695
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-6ec2beda"]]);
|
|
1634
1696
|
function useTable(params = {}) {
|
|
1635
1697
|
const { data, columns, ...rest } = params;
|
|
1636
1698
|
const coreTable = useTable$1({
|
|
@@ -1725,12 +1787,12 @@ const index = {
|
|
|
1725
1787
|
}
|
|
1726
1788
|
};
|
|
1727
1789
|
export {
|
|
1728
|
-
_sfc_main$
|
|
1790
|
+
_sfc_main$f as ContainerFragment,
|
|
1729
1791
|
LOCALE_INJECT_KEY,
|
|
1730
1792
|
_sfc_main as ProComponentProvider,
|
|
1731
1793
|
_sfc_main$b as ProForm,
|
|
1732
1794
|
ProTable,
|
|
1733
|
-
_sfc_main$
|
|
1795
|
+
_sfc_main$e as SlotComponent,
|
|
1734
1796
|
index as default,
|
|
1735
1797
|
enUS,
|
|
1736
1798
|
useFields,
|