@qin-ui/antd-vue-pro 2.5.1 → 2.5.3
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 +2 -2
- package/es/antd-vue-pro.css +6 -6
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +59 -11
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItems/index.vue.d.ts +16 -0
- package/es/components/form/components/BaseFormItems/index.vue.d.ts.map +1 -0
- package/es/components/form/components/index.d.ts +6 -6
- package/es/components/form/components/index.d.ts.map +1 -1
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts +13 -3
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
- package/es/components/form/utils/fieldKey.d.ts +12 -0
- package/es/components/form/utils/fieldKey.d.ts.map +1 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/index.js +318 -161
- package/es/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/form/components/BaseField/index.vue +30 -9
- package/src/components/form/components/BaseFormItem/index.vue +153 -186
- package/src/components/form/components/BaseFormItems/index.vue +186 -0
- package/src/components/form/components/ProForm/index.vue +5 -5
- package/src/components/form/components/index.ts +6 -6
- package/src/components/form/hooks/useGroupFieldAttrs.ts +114 -88
- package/src/components/form/utils/fieldKey.ts +63 -0
- package/src/components/table/components/ProTable.vue +24 -1
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./antd-vue-pro.css";
|
|
2
|
-
import { defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, inject, computed, toValue, ref, createCommentVNode, createSlots, renderList, createVNode,
|
|
3
|
-
import { Transfer, TreeSelect, Slider, Switch, RadioGroup, CheckboxGroup, TimePicker, RangePicker, DatePicker, Cascader, Select, InputNumber, InputPassword, InputSearch, Textarea, Input,
|
|
4
|
-
import { useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, useReactiveAttrs, cloneDeep, getObject, InjectionFormSlotsKey, isPlainObject, resolveFieldIdentity, isObjectItem,
|
|
2
|
+
import { defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, inject, computed, toValue, ref, onBeforeUnmount, createCommentVNode, createSlots, renderList, createVNode, watch, h, toRaw, unref, provide, useSlots, shallowRef, onUpdated, triggerRef, createElementVNode, withModifiers, normalizeStyle, nextTick, mergeModels, useModel, getCurrentInstance, onMounted, normalizeClass, guardReactiveProps } from "vue";
|
|
3
|
+
import { Transfer, TreeSelect, Slider, Switch, RadioGroup, CheckboxGroup, TimePicker, RangePicker, DatePicker, Cascader, Select, InputNumber, InputPassword, InputSearch, Textarea, Input, FormItem, Col, Row, Form, Space, Button, theme, Dropdown, Menu, MenuItem, Checkbox, MenuDivider, Table } from "ant-design-vue";
|
|
4
|
+
import { useForm as useForm$1, resolveLocaleName, zhTW, enUS, zhCN, format, useReactiveAttrs, cloneDeep, getObject, InjectionFormSlotsKey, isPlainObject, resolveFieldIdentity, toPath, isObjectItem, InjectionFormKey, createFormProxy, omitBy, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, pick, isPromise, useTable as useTable$1, omit } from "@qin-ui/pro-components-core";
|
|
5
5
|
import { enUS as enUS2, useFormData, zhCN as zhCN2, zhTW as zhTW2 } from "@qin-ui/pro-components-core";
|
|
6
6
|
import { useConfigContextInject } from "ant-design-vue/es/config-provider/context";
|
|
7
7
|
import { useInjectFormItemContext, useProvideFormItemContext } from "ant-design-vue/es/form/FormItemContext";
|
|
@@ -154,7 +154,7 @@ const ensureInjectConfig = (key) => {
|
|
|
154
154
|
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
155
155
|
return created;
|
|
156
156
|
};
|
|
157
|
-
const _sfc_main$
|
|
157
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
158
158
|
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
159
159
|
__name: "index",
|
|
160
160
|
props: {
|
|
@@ -172,7 +172,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
const _sfc_main$
|
|
175
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
176
176
|
...{ name: "SlotComponent", inheritAttrs: false },
|
|
177
177
|
__name: "index",
|
|
178
178
|
props: {
|
|
@@ -265,7 +265,7 @@ const useLocale = () => {
|
|
|
265
265
|
};
|
|
266
266
|
return { t, lang };
|
|
267
267
|
};
|
|
268
|
-
const _sfc_main$
|
|
268
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
269
269
|
...{ name: "BaseField", inheritAttrs: false },
|
|
270
270
|
__name: "index",
|
|
271
271
|
props: {
|
|
@@ -278,6 +278,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
278
278
|
// 原始值直接传递,引用值克隆快照
|
|
279
279
|
typeof val === "object" && val !== null ? cloneDeep(val) : val
|
|
280
280
|
);
|
|
281
|
+
const isSameValue = (a, b) => a === b || a !== a && b !== b;
|
|
281
282
|
const props = __props;
|
|
282
283
|
const { t } = useLocale();
|
|
283
284
|
const form = useForm(false);
|
|
@@ -291,9 +292,21 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
291
292
|
},
|
|
292
293
|
clearValidate: formItemContext.clearValidate
|
|
293
294
|
});
|
|
295
|
+
let pendingChange = false;
|
|
296
|
+
let pendingChangeValue;
|
|
294
297
|
const triggerFormItemChange = (value2) => {
|
|
295
|
-
|
|
298
|
+
pendingChangeValue = value2;
|
|
299
|
+
if (pendingChange) return;
|
|
300
|
+
pendingChange = true;
|
|
301
|
+
queueMicrotask(() => {
|
|
302
|
+
if (!pendingChange) return;
|
|
303
|
+
pendingChange = false;
|
|
304
|
+
emit("field-value-change", pendingChangeValue);
|
|
305
|
+
});
|
|
296
306
|
};
|
|
307
|
+
onBeforeUnmount(() => {
|
|
308
|
+
pendingChange = false;
|
|
309
|
+
});
|
|
297
310
|
const attrs = useReactiveAttrs();
|
|
298
311
|
const pickerVal = attrs.picker;
|
|
299
312
|
const injectConfigKey = typeof props.component === "string" ? [props.component, pickerVal].filter(Boolean).join(".") : "";
|
|
@@ -315,12 +328,17 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
315
328
|
let newVal = val;
|
|
316
329
|
const { valueFormatter } = groupedAttrs.value;
|
|
317
330
|
const setFormatter = typeof valueFormatter === "function" ? valueFormatter : typeof valueFormatter === "object" && typeof (valueFormatter == null ? void 0 : valueFormatter.set) === "function" ? valueFormatter.set : void 0;
|
|
331
|
+
const oldVal = (_a = form.getFormData) == null ? void 0 : _a.call(form, props.path);
|
|
318
332
|
if (setFormatter) {
|
|
319
|
-
|
|
320
|
-
|
|
333
|
+
newVal = setFormatter(
|
|
334
|
+
val,
|
|
335
|
+
setFormatter.length > 1 ? cloneDeepIfObject(oldVal) : void 0
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
if (!isSameValue(newVal, oldVal)) {
|
|
339
|
+
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
340
|
+
triggerFormItemChange(newVal);
|
|
321
341
|
}
|
|
322
|
-
(_b = form.setFormData) == null ? void 0 : _b.call(form, props.path, newVal);
|
|
323
|
-
triggerFormItemChange(newVal);
|
|
324
342
|
const { onUpdateValue } = groupedAttrs.value;
|
|
325
343
|
if (typeof onUpdateValue === "function") {
|
|
326
344
|
onUpdateValue(val);
|
|
@@ -378,7 +396,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
378
396
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
379
397
|
});
|
|
380
398
|
return (_ctx, _cache) => {
|
|
381
|
-
return openBlock(), createBlock(_sfc_main$
|
|
399
|
+
return openBlock(), createBlock(_sfc_main$f, {
|
|
382
400
|
component: groupedAttrs.value.componentContainer,
|
|
383
401
|
path: props.path
|
|
384
402
|
}, {
|
|
@@ -394,7 +412,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
394
412
|
return {
|
|
395
413
|
name,
|
|
396
414
|
fn: withCtx((scoped) => [
|
|
397
|
-
createVNode(_sfc_main$
|
|
415
|
+
createVNode(_sfc_main$e, mergeProps({
|
|
398
416
|
path: props.path
|
|
399
417
|
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
400
418
|
])
|
|
@@ -407,8 +425,206 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
407
425
|
};
|
|
408
426
|
}
|
|
409
427
|
});
|
|
428
|
+
const formItemPropKeys = Object.keys(formItemProps()).concat([
|
|
429
|
+
"formItemContainer"
|
|
430
|
+
]);
|
|
431
|
+
const gridItemPropKeys = Object.keys(colProps());
|
|
432
|
+
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
433
|
+
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
434
|
+
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
435
|
+
const groupField = (field, rawInject) => {
|
|
436
|
+
let gridItemProps2 = {};
|
|
437
|
+
let formItemProps2 = {};
|
|
438
|
+
const componentProps = { slots: {} };
|
|
439
|
+
const formItemSlots = {};
|
|
440
|
+
if (isPlainObject(field)) {
|
|
441
|
+
const { path: _path, name: _name, fields, formItemClass, formItemStyle, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, formItemContainer, ...rest } = field;
|
|
442
|
+
const { class: injectClassName, style: injectStyle, span: injectSpan, xs, sm, md, lg, xl, xxl, formItemContainer: injectFormItemContainer, ...injectRest } = rawInject;
|
|
443
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, xxl, span: injectSpan };
|
|
444
|
+
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
445
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
446
|
+
formItemProps2 = mergeProps(
|
|
447
|
+
injectRest,
|
|
448
|
+
{ class: injectClassName, style: injectStyle },
|
|
449
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
450
|
+
formItemDataAttrs
|
|
451
|
+
);
|
|
452
|
+
Object.keys(rest).forEach((k) => {
|
|
453
|
+
if (gridItemPropKeySet.has(k)) {
|
|
454
|
+
gridItemProps2[k] = rest[k];
|
|
455
|
+
} else if (formItemPropKeySet.has(k)) {
|
|
456
|
+
formItemProps2[k] = rest[k];
|
|
457
|
+
} else {
|
|
458
|
+
componentProps[k] = rest[k];
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
462
|
+
Object.keys(slots).forEach((k) => {
|
|
463
|
+
if (formItemSlotKeySet.has(k)) {
|
|
464
|
+
formItemSlots[k] = slots[k];
|
|
465
|
+
} else {
|
|
466
|
+
componentProps.slots[k] = slots[k];
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
if (formItemSlots.label && formItemProps2.label !== void 0) {
|
|
470
|
+
delete formItemProps2.label;
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
path: resolveFieldIdentity(field),
|
|
474
|
+
gridItemProps: gridItemProps2,
|
|
475
|
+
formItemProps: formItemProps2,
|
|
476
|
+
formItemSlots,
|
|
477
|
+
componentProps,
|
|
478
|
+
formItemContainer: container,
|
|
479
|
+
rawField: field
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
path: resolveFieldIdentity(field),
|
|
484
|
+
gridItemProps: gridItemProps2,
|
|
485
|
+
formItemProps: formItemProps2,
|
|
486
|
+
formItemSlots,
|
|
487
|
+
componentProps,
|
|
488
|
+
rawField: field
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
function useGroupedField(field) {
|
|
492
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
493
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
494
|
+
return computed(
|
|
495
|
+
() => groupField(toValue(field), toValue(injectFormItemProps) || {})
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
const _sfc_main$c = defineComponent({
|
|
499
|
+
name: "BaseFormItem",
|
|
500
|
+
inheritAttrs: false,
|
|
501
|
+
props: {
|
|
502
|
+
/** 字段配置 */
|
|
503
|
+
field: { type: Object, required: true },
|
|
504
|
+
/** 是否启用网格布局 */
|
|
505
|
+
grid: {
|
|
506
|
+
type: [Boolean, Object],
|
|
507
|
+
default: void 0
|
|
508
|
+
},
|
|
509
|
+
/** 上层下发的禁用状态 */
|
|
510
|
+
disabled: { type: Boolean, default: void 0 },
|
|
511
|
+
/** FormItem 实例登记回调 */
|
|
512
|
+
setFormItemRef: {
|
|
513
|
+
type: Function,
|
|
514
|
+
default: void 0
|
|
515
|
+
},
|
|
516
|
+
/** 控件实例登记回调 */
|
|
517
|
+
setComponentRef: {
|
|
518
|
+
type: Function,
|
|
519
|
+
default: void 0
|
|
520
|
+
}
|
|
521
|
+
},
|
|
522
|
+
setup(props) {
|
|
523
|
+
const grouped = useGroupedField(() => props.field);
|
|
524
|
+
const enableGrid = computed(() => !!props.grid);
|
|
525
|
+
const componentKey = computed(() => {
|
|
526
|
+
const field = props.field;
|
|
527
|
+
const component = toValue(field.component);
|
|
528
|
+
if (typeof component !== "string") return "component-object";
|
|
529
|
+
return `string:${component}:${toValue(field.picker) ?? ""}`;
|
|
530
|
+
});
|
|
531
|
+
let formItemInstance;
|
|
532
|
+
const setItemRef = (el) => {
|
|
533
|
+
var _a;
|
|
534
|
+
formItemInstance = el;
|
|
535
|
+
(_a = props.setFormItemRef) == null ? void 0 : _a.call(
|
|
536
|
+
props,
|
|
537
|
+
props.field,
|
|
538
|
+
el,
|
|
539
|
+
() => grouped.value.formItemProps
|
|
540
|
+
);
|
|
541
|
+
};
|
|
542
|
+
const setFieldRef = (el) => {
|
|
543
|
+
var _a;
|
|
544
|
+
(_a = props.setComponentRef) == null ? void 0 : _a.call(props, props.field, el);
|
|
545
|
+
};
|
|
546
|
+
watch(
|
|
547
|
+
() => props.field,
|
|
548
|
+
(next, prev) => {
|
|
549
|
+
var _a, _b;
|
|
550
|
+
if (!prev || prev === next) return;
|
|
551
|
+
(_a = props.setFormItemRef) == null ? void 0 : _a.call(props, prev, null, () => grouped.value.formItemProps);
|
|
552
|
+
(_b = props.setComponentRef) == null ? void 0 : _b.call(props, prev, null);
|
|
553
|
+
},
|
|
554
|
+
{ flush: "pre" }
|
|
555
|
+
);
|
|
556
|
+
const onFieldValueChange = () => {
|
|
557
|
+
var _a, _b;
|
|
558
|
+
if (((_a = grouped.value.formItemProps) == null ? void 0 : _a.autoLink) === false) return;
|
|
559
|
+
(_b = formItemInstance == null ? void 0 : formItemInstance.onFieldChange) == null ? void 0 : _b.call(formItemInstance);
|
|
560
|
+
};
|
|
561
|
+
const withContainer = (node, component, containerProps) => component ? h(component, containerProps, { default: () => node }) : node;
|
|
562
|
+
const renderFormItemSlots = (groupedField) => {
|
|
563
|
+
const slots = {};
|
|
564
|
+
Object.entries(groupedField.formItemSlots).forEach(([name, slot]) => {
|
|
565
|
+
slots[name] = (scope) => h(_sfc_main$e, {
|
|
566
|
+
path: groupedField.path,
|
|
567
|
+
component: slot,
|
|
568
|
+
...scope || {}
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
slots.default = () => {
|
|
572
|
+
const field = props.field;
|
|
573
|
+
if (field.fields) {
|
|
574
|
+
return h(_sfc_main$b, {
|
|
575
|
+
grid: field.grid ?? props.grid,
|
|
576
|
+
fields: field.fields,
|
|
577
|
+
disabled: toValue(field.disabled)
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
return h(_sfc_main$d, {
|
|
581
|
+
key: componentKey.value,
|
|
582
|
+
ref: setFieldRef,
|
|
583
|
+
...groupedField.componentProps,
|
|
584
|
+
path: groupedField.path,
|
|
585
|
+
onFieldValueChange
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
return slots;
|
|
589
|
+
};
|
|
590
|
+
return () => {
|
|
591
|
+
const groupedField = grouped.value;
|
|
592
|
+
let node = h(
|
|
593
|
+
FormItem,
|
|
594
|
+
{
|
|
595
|
+
...groupedField.formItemProps,
|
|
596
|
+
ref: setItemRef,
|
|
597
|
+
name: toPath(groupedField.path),
|
|
598
|
+
path: groupedField.path
|
|
599
|
+
},
|
|
600
|
+
renderFormItemSlots(groupedField)
|
|
601
|
+
);
|
|
602
|
+
node = withContainer(node, groupedField.formItemContainer, {
|
|
603
|
+
path: groupedField.path
|
|
604
|
+
});
|
|
605
|
+
node = withContainer(
|
|
606
|
+
node,
|
|
607
|
+
enableGrid.value ? Col : void 0,
|
|
608
|
+
groupedField.gridItemProps
|
|
609
|
+
);
|
|
610
|
+
return node;
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
});
|
|
410
614
|
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
411
615
|
let fieldKeySeed = 0;
|
|
616
|
+
const rowKeyMap = /* @__PURE__ */ new WeakMap();
|
|
617
|
+
let rowKeySeed = 0;
|
|
618
|
+
const getRowKey = (row) => {
|
|
619
|
+
const raw = toRaw(row);
|
|
620
|
+
let key = rowKeyMap.get(raw);
|
|
621
|
+
if (key === void 0) {
|
|
622
|
+
key = ++rowKeySeed;
|
|
623
|
+
rowKeyMap.set(raw, key);
|
|
624
|
+
}
|
|
625
|
+
return key;
|
|
626
|
+
};
|
|
627
|
+
const isIndexSegment = (segment) => /^(?:0|[1-9]\d*)$/.test(segment);
|
|
412
628
|
const getFieldKey = (field) => {
|
|
413
629
|
if (field === null || typeof field !== "object")
|
|
414
630
|
return `raw_${String(field)}`;
|
|
@@ -420,82 +636,35 @@ const getFieldKey = (field) => {
|
|
|
420
636
|
}
|
|
421
637
|
return key;
|
|
422
638
|
};
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
formItemDataAttrs
|
|
451
|
-
);
|
|
452
|
-
Object.keys(rest).forEach((k) => {
|
|
453
|
-
if (gridItemPropKeySet.has(k)) {
|
|
454
|
-
gridItemProps2[k] = rest[k];
|
|
455
|
-
} else if (formItemPropKeySet.has(k)) {
|
|
456
|
-
formItemProps2[k] = rest[k];
|
|
457
|
-
} else {
|
|
458
|
-
componentProps[k] = rest[k];
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
Object.assign(componentProps, componentDataAttrs);
|
|
462
|
-
Object.keys(slots).forEach((k) => {
|
|
463
|
-
if (formItemSlotKeySet.has(k)) {
|
|
464
|
-
formItemSlots[k] = slots[k];
|
|
465
|
-
} else {
|
|
466
|
-
componentProps.slots[k] = slots[k];
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
if (formItemSlots.label && formItemProps2.label !== void 0) {
|
|
470
|
-
delete formItemProps2.label;
|
|
471
|
-
}
|
|
472
|
-
const raw2 = resolveFieldIdentity(field);
|
|
473
|
-
return {
|
|
474
|
-
path: raw2,
|
|
475
|
-
gridItemProps: gridItemProps2,
|
|
476
|
-
formItemProps: formItemProps2,
|
|
477
|
-
formItemSlots,
|
|
478
|
-
componentProps,
|
|
479
|
-
formItemContainer: container,
|
|
480
|
-
rawField: field,
|
|
481
|
-
renderKey: getFieldKey(field)
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
const raw = resolveFieldIdentity(field);
|
|
485
|
-
return {
|
|
486
|
-
path: raw,
|
|
487
|
-
gridItemProps: gridItemProps2,
|
|
488
|
-
formItemProps: formItemProps2,
|
|
489
|
-
formItemSlots,
|
|
490
|
-
componentProps,
|
|
491
|
-
rawField: field,
|
|
492
|
-
renderKey: getFieldKey(field)
|
|
493
|
-
};
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
}
|
|
639
|
+
const getFieldDataKey = (field, rawFormData) => {
|
|
640
|
+
const path = resolveFieldIdentity(field);
|
|
641
|
+
if (!path || rawFormData === null || rawFormData === void 0) {
|
|
642
|
+
return getFieldKey(field);
|
|
643
|
+
}
|
|
644
|
+
const segments = toPath(path);
|
|
645
|
+
let node = rawFormData;
|
|
646
|
+
const rowIds = [];
|
|
647
|
+
let lastRowIndex = -1;
|
|
648
|
+
for (let i = 0; i < segments.length; i++) {
|
|
649
|
+
if (Array.isArray(node)) {
|
|
650
|
+
const segment = segments[i];
|
|
651
|
+
if (!isIndexSegment(segment)) break;
|
|
652
|
+
const element = node[Number(segment)];
|
|
653
|
+
if (element === null || typeof element !== "object") break;
|
|
654
|
+
rowIds.push(getRowKey(toRaw(element)));
|
|
655
|
+
lastRowIndex = i;
|
|
656
|
+
node = element;
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
if (node === null || typeof node !== "object") break;
|
|
660
|
+
node = node[segments[i]];
|
|
661
|
+
}
|
|
662
|
+
if (lastRowIndex === -1) return getFieldKey(field);
|
|
663
|
+
const rest = segments.slice(lastRowIndex + 1).join(".");
|
|
664
|
+
return `data:${rowIds.join("/")}:${rest}`;
|
|
665
|
+
};
|
|
497
666
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
498
|
-
...{ name: "
|
|
667
|
+
...{ name: "BaseFormItems", inheritAttrs: false },
|
|
499
668
|
__name: "index",
|
|
500
669
|
props: {
|
|
501
670
|
grid: { type: [Boolean, Object], default: void 0 },
|
|
@@ -512,6 +681,20 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
512
681
|
)
|
|
513
682
|
)
|
|
514
683
|
);
|
|
684
|
+
const injectedForm = inject(InjectionFormKey, void 0);
|
|
685
|
+
const renderedFields = computed(() => {
|
|
686
|
+
const rawFormData = (injectedForm == null ? void 0 : injectedForm.formData) ? toRaw(injectedForm.formData) : void 0;
|
|
687
|
+
const seen = /* @__PURE__ */ new Map();
|
|
688
|
+
return validFields.value.map((field) => {
|
|
689
|
+
const baseKey = getFieldDataKey(field, rawFormData);
|
|
690
|
+
const count = seen.get(baseKey) ?? 0;
|
|
691
|
+
seen.set(baseKey, count + 1);
|
|
692
|
+
return {
|
|
693
|
+
field,
|
|
694
|
+
key: count === 0 ? baseKey : `${String(baseKey)}#${count}`
|
|
695
|
+
};
|
|
696
|
+
});
|
|
697
|
+
});
|
|
515
698
|
useProviderDisabled(computed(() => props.disabled));
|
|
516
699
|
const config = INJECT_CONFIG["pro-form"];
|
|
517
700
|
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
@@ -545,20 +728,14 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
545
728
|
}
|
|
546
729
|
}
|
|
547
730
|
};
|
|
548
|
-
const
|
|
549
|
-
var _a, _b;
|
|
550
|
-
if (((_a = item.formItemProps) == null ? void 0 : _a.autoLink) === false) return;
|
|
551
|
-
const instance = formItemInstanceMap.get(toRaw(item.rawField));
|
|
552
|
-
(_b = instance == null ? void 0 : instance.onFieldChange) == null ? void 0 : _b.call(instance);
|
|
553
|
-
};
|
|
554
|
-
const setFormItemRef = (field, el, formItemProps2) => {
|
|
731
|
+
const setFormItemRef = (field, el, getFormItemProps) => {
|
|
555
732
|
if (!field || typeof field !== "object") return;
|
|
556
733
|
const raw = toRaw(field);
|
|
557
734
|
if (el) {
|
|
558
735
|
formItemInstanceMap.set(raw, el);
|
|
559
736
|
defineFieldAccessors(raw, {
|
|
560
737
|
getFormItemRef: () => formItemInstanceMap.get(raw),
|
|
561
|
-
getFormItemComputedProps:
|
|
738
|
+
getFormItemComputedProps: getFormItemProps
|
|
562
739
|
});
|
|
563
740
|
} else {
|
|
564
741
|
formItemInstanceMap.delete(raw);
|
|
@@ -587,69 +764,31 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
587
764
|
delete raw.getComponentComputedProps;
|
|
588
765
|
}
|
|
589
766
|
};
|
|
590
|
-
const groupedFields = useGroupFieldAttrs(validFields);
|
|
591
767
|
return (_ctx, _cache) => {
|
|
592
|
-
|
|
593
|
-
return openBlock(), createBlock(_sfc_main$e, mergeProps({
|
|
594
|
-
component: enableGrid.value ? unref(Row) : void 0
|
|
595
|
-
}, computedGridProps.value), {
|
|
768
|
+
return enableGrid.value ? (openBlock(), createBlock(unref(Row), normalizeProps(mergeProps({ key: 0 }, computedGridProps.value)), {
|
|
596
769
|
default: withCtx(() => [
|
|
597
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
598
|
-
return openBlock(), createBlock(_sfc_main$
|
|
599
|
-
key: item.
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}, {
|
|
607
|
-
default: withCtx(() => [
|
|
608
|
-
createVNode(unref(FormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
609
|
-
ref_for: true,
|
|
610
|
-
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
611
|
-
name: unref(toPath)(item.path),
|
|
612
|
-
path: item.path
|
|
613
|
-
}), createSlots({
|
|
614
|
-
default: withCtx(() => [
|
|
615
|
-
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
616
|
-
key: 0,
|
|
617
|
-
grid: item.rawField.grid ?? props.grid,
|
|
618
|
-
fields: item.rawField.fields,
|
|
619
|
-
disabled: toValue(item.rawField.disabled)
|
|
620
|
-
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(_sfc_main$c, mergeProps({
|
|
621
|
-
key: 1,
|
|
622
|
-
ref_for: true,
|
|
623
|
-
ref: (el) => setComponentRef(item.rawField, el)
|
|
624
|
-
}, { ref_for: true }, item.componentProps, {
|
|
625
|
-
path: item.path,
|
|
626
|
-
onFieldValueChange: ($event) => onFieldValueChange(item)
|
|
627
|
-
}), null, 16, ["path", "onFieldValueChange"]))
|
|
628
|
-
]),
|
|
629
|
-
_: 2
|
|
630
|
-
}, [
|
|
631
|
-
renderList(item.formItemSlots, (slot, name) => {
|
|
632
|
-
return {
|
|
633
|
-
name,
|
|
634
|
-
fn: withCtx((scoped) => [
|
|
635
|
-
createVNode(_sfc_main$d, mergeProps({
|
|
636
|
-
path: item.path,
|
|
637
|
-
component: slot
|
|
638
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
639
|
-
])
|
|
640
|
-
};
|
|
641
|
-
})
|
|
642
|
-
]), 1040, ["name", "path"])
|
|
643
|
-
]),
|
|
644
|
-
_: 2
|
|
645
|
-
}, 1032, ["component", "path"])
|
|
646
|
-
]),
|
|
647
|
-
_: 2
|
|
648
|
-
}, 1040, ["component"]);
|
|
770
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(renderedFields.value, (item) => {
|
|
771
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
772
|
+
key: item.key,
|
|
773
|
+
field: item.field,
|
|
774
|
+
grid: props.grid,
|
|
775
|
+
disabled: props.disabled,
|
|
776
|
+
"set-form-item-ref": setFormItemRef,
|
|
777
|
+
"set-component-ref": setComponentRef
|
|
778
|
+
}, null, 8, ["field", "grid", "disabled"]);
|
|
649
779
|
}), 128))
|
|
650
780
|
]),
|
|
651
781
|
_: 1
|
|
652
|
-
}, 16,
|
|
782
|
+
}, 16)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(renderedFields.value, (item) => {
|
|
783
|
+
return openBlock(), createBlock(_sfc_main$c, {
|
|
784
|
+
key: item.key,
|
|
785
|
+
field: item.field,
|
|
786
|
+
grid: props.grid,
|
|
787
|
+
disabled: props.disabled,
|
|
788
|
+
"set-form-item-ref": setFormItemRef,
|
|
789
|
+
"set-component-ref": setComponentRef
|
|
790
|
+
}, null, 8, ["field", "grid", "disabled"]);
|
|
791
|
+
}), 128));
|
|
653
792
|
};
|
|
654
793
|
}
|
|
655
794
|
});
|
|
@@ -1424,10 +1563,28 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1424
1563
|
showTotal: ((_c = injectAttrs.value.pagination) == null ? void 0 : _c.showTotal) ?? ((total) => t("pagination.total", { total }))
|
|
1425
1564
|
};
|
|
1426
1565
|
});
|
|
1566
|
+
let warnedPaginationShadow = false;
|
|
1567
|
+
const warnPaginationShadow = (keys) => {
|
|
1568
|
+
if (warnedPaginationShadow) return;
|
|
1569
|
+
warnedPaginationShadow = true;
|
|
1570
|
+
console.warn(
|
|
1571
|
+
`[ProTable] 显式 :pagination 的 ${keys.join(" / ")} 覆盖了 table.pageParam,翻页或修改页大小后分页不会更新;请移除显式值或在回调中同步更新绑定。`
|
|
1572
|
+
);
|
|
1573
|
+
};
|
|
1427
1574
|
const onTableChange = (...args) => {
|
|
1428
|
-
var _a, _b, _c;
|
|
1575
|
+
var _a, _b, _c, _d;
|
|
1429
1576
|
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, args[0]);
|
|
1430
|
-
|
|
1577
|
+
const nextPagination = computedPagination.value;
|
|
1578
|
+
if (((_c = props.table) == null ? void 0 : _c.pageParam) && nextPagination !== false) {
|
|
1579
|
+
const shadowed = ["current", "pageSize"].filter(
|
|
1580
|
+
(key) => {
|
|
1581
|
+
var _a2;
|
|
1582
|
+
return ((_a2 = args[0]) == null ? void 0 : _a2[key]) !== void 0 && nextPagination[key] !== args[0][key];
|
|
1583
|
+
}
|
|
1584
|
+
);
|
|
1585
|
+
if (shadowed.length) warnPaginationShadow(shadowed);
|
|
1586
|
+
}
|
|
1587
|
+
(_d = attrs.onChange ?? injectProps.value.onChange) == null ? void 0 : _d(...args);
|
|
1431
1588
|
_search();
|
|
1432
1589
|
};
|
|
1433
1590
|
const searchFormVisible = computed(() => {
|
|
@@ -1470,7 +1627,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1470
1627
|
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1471
1628
|
style: normalizeStyle(unref(attrs).style)
|
|
1472
1629
|
}, [
|
|
1473
|
-
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$
|
|
1630
|
+
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$f, {
|
|
1474
1631
|
key: 0,
|
|
1475
1632
|
component: computedSearchFormConfig.value.container
|
|
1476
1633
|
}, {
|
|
@@ -1493,7 +1650,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1493
1650
|
}),
|
|
1494
1651
|
_: 3
|
|
1495
1652
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
1496
|
-
createVNode(_sfc_main$
|
|
1653
|
+
createVNode(_sfc_main$f, { component: computedTableContainer.value }, {
|
|
1497
1654
|
default: withCtx(() => [
|
|
1498
1655
|
createElementVNode("div", _hoisted_1, [
|
|
1499
1656
|
_ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
@@ -1549,7 +1706,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1549
1706
|
};
|
|
1550
1707
|
}
|
|
1551
1708
|
});
|
|
1552
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1709
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-05315c95"]]);
|
|
1553
1710
|
function useTable(params) {
|
|
1554
1711
|
return useTable$1(params);
|
|
1555
1712
|
}
|
|
@@ -1646,12 +1803,12 @@ const index = {
|
|
|
1646
1803
|
}
|
|
1647
1804
|
};
|
|
1648
1805
|
export {
|
|
1649
|
-
_sfc_main$
|
|
1806
|
+
_sfc_main$f as ContainerFragment,
|
|
1650
1807
|
LOCALE_INJECT_KEY,
|
|
1651
1808
|
_sfc_main as ProComponentProvider,
|
|
1652
1809
|
_sfc_main$a as ProForm,
|
|
1653
1810
|
ProTable,
|
|
1654
|
-
_sfc_main$
|
|
1811
|
+
_sfc_main$e as SlotComponent,
|
|
1655
1812
|
index as default,
|
|
1656
1813
|
enUS2 as enUS,
|
|
1657
1814
|
useFields,
|