@qin-ui/element-plus-pro 1.4.1 → 1.4.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/components/form/components/BaseField/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +60 -9
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -1
- package/es/components/form/components/BaseFormItems/index.vue.d.ts +13 -0
- package/es/components/form/components/BaseFormItems/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -1
- 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 +10 -2
- package/es/components/form/hooks/useGroupFieldAttrs.d.ts.map +1 -1
- package/es/components/form/utils/disabled.d.ts +28 -0
- package/es/components/form/utils/disabled.d.ts.map +1 -0
- 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 +1 -1
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -1
- package/es/element-plus-pro.css +8 -7
- package/es/index.js +301 -153
- package/es/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/form/components/BaseField/index.vue +6 -8
- package/src/components/form/components/BaseField/utils/index.ts +3 -0
- package/src/components/form/components/BaseFormItem/index.vue +145 -175
- package/src/components/form/components/BaseFormItems/index.vue +183 -0
- package/src/components/form/components/ProForm/index.vue +18 -5
- package/src/components/form/components/index.ts +6 -6
- package/src/components/form/hooks/useGroupFieldAttrs.ts +104 -79
- package/src/components/form/utils/disabled.ts +37 -0
- package/src/components/form/utils/fieldKey.ts +64 -0
- package/src/components/table/components/ProTable.vue +15 -1
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./element-plus-pro.css";
|
|
2
|
-
import { inject, computed, toValue, provide, defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, ref, createCommentVNode, createSlots, renderList, createVNode,
|
|
2
|
+
import { inject, computed, toValue, provide, defineComponent, createBlock, renderSlot, openBlock, resolveDynamicComponent, normalizeProps, mergeProps, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, ref, createCommentVNode, createSlots, renderList, createVNode, watch, h, toRaw, unref, useSlots, shallowRef, onUpdated, triggerRef, withModifiers, createElementVNode, normalizeStyle, nextTick, mergeModels, useModel, onMounted, resolveDirective, normalizeClass, withDirectives, guardReactiveProps, effect, stop, Comment, Text } from "vue";
|
|
3
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, useSize, 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, useReactiveAttrs, cloneDeep, getObject, InjectionFormSlotsKey, isPlainObject, resolveFieldIdentity,
|
|
4
|
+
import { useForm as useForm$1, zhCN as zhCN$1, zhTW as zhTW$1, enUS as enUS$1, resolveLocaleName, format, useReactiveAttrs, cloneDeep, getObject, InjectionFormSlotsKey, isPlainObject, resolveFieldIdentity, normalizePathKey, toPath, isObjectItem, InjectionFormKey, createFormProxy, omitBy, camelizeProperties, useFields as useFields$1, useFormRef as useFormRef$1, useSearchFormExpand, get, pick, isPromise, useTable as useTable$1, omit } 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 || {};
|
|
@@ -216,7 +216,7 @@ const ensureInjectConfig = (key) => {
|
|
|
216
216
|
DYNAMIC_INJECT_CONFIG[key] = created;
|
|
217
217
|
return created;
|
|
218
218
|
};
|
|
219
|
-
const _sfc_main$
|
|
219
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
220
220
|
...{ name: "ContainerFragment", inheritAttrs: false },
|
|
221
221
|
__name: "index",
|
|
222
222
|
props: {
|
|
@@ -233,7 +233,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
|
-
const _sfc_main$
|
|
236
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
237
237
|
...{ name: "SlotComponent", inheritAttrs: false },
|
|
238
238
|
__name: "index",
|
|
239
239
|
props: {
|
|
@@ -289,6 +289,8 @@ const PLACEHOLDER_KEYS = {
|
|
|
289
289
|
"date-picker.week": "date-picker.placeholder",
|
|
290
290
|
"date-picker.month": "date-picker.placeholder",
|
|
291
291
|
"date-picker.months": "date-picker.placeholder",
|
|
292
|
+
"date-picker.quarter": "date-picker.placeholder",
|
|
293
|
+
"date-picker.quarters": "date-picker.placeholder",
|
|
292
294
|
"date-picker.year": "date-picker.placeholder",
|
|
293
295
|
"date-picker.years": "date-picker.placeholder",
|
|
294
296
|
"date-picker.datetime": "date-picker.placeholder",
|
|
@@ -299,6 +301,7 @@ const RANGE_PLACEHOLDER_KEYS = {
|
|
|
299
301
|
"date-picker.daterange": ["date-picker.start", "date-picker.end"],
|
|
300
302
|
"date-picker.monthrange": ["date-picker.startMonth", "date-picker.endMonth"],
|
|
301
303
|
"date-picker.yearrange": ["date-picker.startYear", "date-picker.endYear"],
|
|
304
|
+
"date-picker.quarterrange": ["date-picker.start", "date-picker.end"],
|
|
302
305
|
"date-picker.datetimerange": ["date-picker.startTime", "date-picker.endTime"]
|
|
303
306
|
};
|
|
304
307
|
const getPlaceholderProps = (key, injectProps, t) => {
|
|
@@ -331,6 +334,9 @@ function warnUnknownComponent(name) {
|
|
|
331
334
|
`[pro-components] 未识别的组件类型 "${name}",已降级为原生元素渲染。如为自定义组件请在 componentMap 或 ProComponentProvider 中注册。`
|
|
332
335
|
);
|
|
333
336
|
}
|
|
337
|
+
const normalizeDisabled = (value) => value === "" || value === "disabled" ? true : Boolean(value);
|
|
338
|
+
const resolveDisabled = (value) => value === void 0 || value === null ? void 0 : normalizeDisabled(value);
|
|
339
|
+
const resolveEffectiveDisabled = (explicit, inherited, fallback) => resolveDisabled(explicit) ?? (normalizeDisabled(inherited) || normalizeDisabled(fallback));
|
|
334
340
|
const zhCN = {
|
|
335
341
|
...zhCN$1,
|
|
336
342
|
// 日期/时间选择器占位符(对应 INJECT_CONFIG 中 date-picker.* 的占位默认值)
|
|
@@ -389,7 +395,7 @@ const useLocale = () => {
|
|
|
389
395
|
};
|
|
390
396
|
return { t, lang };
|
|
391
397
|
};
|
|
392
|
-
const _sfc_main$
|
|
398
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
393
399
|
...{ name: "BaseField", inheritAttrs: false },
|
|
394
400
|
__name: "index",
|
|
395
401
|
props: {
|
|
@@ -455,8 +461,11 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
455
461
|
t
|
|
456
462
|
);
|
|
457
463
|
const modelPropName = attrs.modelProp ?? initProps.modelProp ?? "modelValue";
|
|
458
|
-
const
|
|
459
|
-
|
|
464
|
+
const effectiveDisabled = resolveEffectiveDisabled(
|
|
465
|
+
attrs.disabled,
|
|
466
|
+
parentDisabled.value,
|
|
467
|
+
initProps.disabled
|
|
468
|
+
);
|
|
460
469
|
const mergedProps = mergeProps(
|
|
461
470
|
initProps,
|
|
462
471
|
attrs,
|
|
@@ -493,7 +502,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
493
502
|
getComponentComputedProps: () => groupedAttrs.value.attrs
|
|
494
503
|
});
|
|
495
504
|
return (_ctx, _cache) => {
|
|
496
|
-
return openBlock(), createBlock(_sfc_main$
|
|
505
|
+
return openBlock(), createBlock(_sfc_main$g, {
|
|
497
506
|
component: groupedAttrs.value.componentContainer,
|
|
498
507
|
path: props.path
|
|
499
508
|
}, {
|
|
@@ -509,7 +518,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
509
518
|
return {
|
|
510
519
|
name,
|
|
511
520
|
fn: withCtx((scoped) => [
|
|
512
|
-
createVNode(_sfc_main$
|
|
521
|
+
createVNode(_sfc_main$f, mergeProps({
|
|
513
522
|
path: props.path
|
|
514
523
|
}, scoped, { component: slot }), null, 16, ["path", "component"])
|
|
515
524
|
])
|
|
@@ -522,6 +531,191 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
522
531
|
};
|
|
523
532
|
}
|
|
524
533
|
});
|
|
534
|
+
const formItemPropKeys = Object.keys(formItemProps());
|
|
535
|
+
const gridItemPropKeys = Object.keys(gridItemProps());
|
|
536
|
+
const gridItemPropKeySet = new Set(gridItemPropKeys);
|
|
537
|
+
const formItemPropKeySet = new Set(formItemPropKeys);
|
|
538
|
+
const formItemSlotKeySet = new Set(FORM_ITEM_SLOT_KEYS);
|
|
539
|
+
const groupField = (field, rawInjectProps) => {
|
|
540
|
+
let gridItemProps2 = {};
|
|
541
|
+
let formItemProps2 = {};
|
|
542
|
+
const componentProps = { slots: {} };
|
|
543
|
+
const formItemSlots = {};
|
|
544
|
+
if (isPlainObject(field)) {
|
|
545
|
+
const { path: _path, prop: _prop, fields, formItemClass, formItemStyle, formItemContainer, hidden, span, getFormItemRef, getComponentRef, getFormItemComputedProps, getComponentComputedProps, slots = {}, formItemDataAttrs = {}, componentDataAttrs = {}, extraProps, ...rest } = field;
|
|
546
|
+
const { class: injectClassName, style: injectStyle, span: injectSpan, formItemContainer: injectFormItemContainer, xs, sm, md, lg, xl, ...injectRest } = rawInjectProps;
|
|
547
|
+
const initGridItemProps = span || span === 0 ? { span } : { xs, sm, md, lg, xl, span: injectSpan };
|
|
548
|
+
gridItemProps2 = fields ? { ...initGridItemProps, span: span ?? 24 } : initGridItemProps;
|
|
549
|
+
formItemProps2 = mergeProps(
|
|
550
|
+
injectRest,
|
|
551
|
+
{ class: injectClassName, style: injectStyle },
|
|
552
|
+
{ class: toValue(formItemClass), style: toValue(formItemStyle) },
|
|
553
|
+
formItemDataAttrs
|
|
554
|
+
);
|
|
555
|
+
const container = formItemContainer ?? injectFormItemContainer;
|
|
556
|
+
Object.keys(rest).forEach((k) => {
|
|
557
|
+
if (gridItemPropKeySet.has(k)) {
|
|
558
|
+
gridItemProps2[k] = rest[k];
|
|
559
|
+
} else if (formItemPropKeySet.has(k)) {
|
|
560
|
+
formItemProps2[k] = rest[k];
|
|
561
|
+
} else {
|
|
562
|
+
componentProps[k] = rest[k];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
Object.assign(componentProps, componentDataAttrs);
|
|
566
|
+
Object.keys(slots).forEach((k) => {
|
|
567
|
+
if (formItemSlotKeySet.has(k)) {
|
|
568
|
+
formItemSlots[k] = slots[k];
|
|
569
|
+
} else {
|
|
570
|
+
componentProps.slots[k] = slots[k];
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
return {
|
|
574
|
+
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
575
|
+
gridItemProps: gridItemProps2,
|
|
576
|
+
formItemProps: formItemProps2,
|
|
577
|
+
formItemSlots,
|
|
578
|
+
componentProps,
|
|
579
|
+
container,
|
|
580
|
+
rawField: field
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
585
|
+
gridItemProps: gridItemProps2,
|
|
586
|
+
formItemProps: formItemProps2,
|
|
587
|
+
formItemSlots,
|
|
588
|
+
componentProps,
|
|
589
|
+
rawField: field
|
|
590
|
+
};
|
|
591
|
+
};
|
|
592
|
+
function useGroupedField(field) {
|
|
593
|
+
const config = INJECT_CONFIG["pro-form-item"];
|
|
594
|
+
const injectFormItemProps = inject(config.injectionKey, config.default);
|
|
595
|
+
return computed(
|
|
596
|
+
() => groupField(toValue(field), toValue(injectFormItemProps) || {})
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
const _sfc_main$d = defineComponent({
|
|
600
|
+
name: "BaseFormItem",
|
|
601
|
+
inheritAttrs: false,
|
|
602
|
+
props: {
|
|
603
|
+
/** 字段配置 */
|
|
604
|
+
field: { type: Object, required: true },
|
|
605
|
+
/** 是否启用网格布局 */
|
|
606
|
+
grid: {
|
|
607
|
+
type: [Boolean, Object],
|
|
608
|
+
default: void 0
|
|
609
|
+
},
|
|
610
|
+
/** 上层下发的禁用状态 */
|
|
611
|
+
disabled: { type: Boolean, default: void 0 },
|
|
612
|
+
/** FormItem 实例登记回调 */
|
|
613
|
+
setFormItemRef: {
|
|
614
|
+
type: Function,
|
|
615
|
+
default: void 0
|
|
616
|
+
},
|
|
617
|
+
/** 控件实例登记回调 */
|
|
618
|
+
setComponentRef: {
|
|
619
|
+
type: Function,
|
|
620
|
+
default: void 0
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
setup(props) {
|
|
624
|
+
const grouped = useGroupedField(() => props.field);
|
|
625
|
+
const enableGrid = computed(() => !!props.grid);
|
|
626
|
+
const componentKey = computed(() => {
|
|
627
|
+
const field = props.field;
|
|
628
|
+
const component = toValue(field.component);
|
|
629
|
+
if (typeof component !== "string") return "component-object";
|
|
630
|
+
return `string:${component}:${toValue(field.type) ?? ""}`;
|
|
631
|
+
});
|
|
632
|
+
const effectiveDisabled = computed(
|
|
633
|
+
() => toValue(props.field.disabled) ?? props.disabled
|
|
634
|
+
);
|
|
635
|
+
const setItemRef = (el) => {
|
|
636
|
+
var _a;
|
|
637
|
+
(_a = props.setFormItemRef) == null ? void 0 : _a.call(
|
|
638
|
+
props,
|
|
639
|
+
props.field,
|
|
640
|
+
el,
|
|
641
|
+
() => grouped.value.formItemProps
|
|
642
|
+
);
|
|
643
|
+
};
|
|
644
|
+
const setFieldRef = (el) => {
|
|
645
|
+
var _a;
|
|
646
|
+
(_a = props.setComponentRef) == null ? void 0 : _a.call(props, props.field, el);
|
|
647
|
+
};
|
|
648
|
+
watch(
|
|
649
|
+
() => props.field,
|
|
650
|
+
(next, prev) => {
|
|
651
|
+
var _a, _b;
|
|
652
|
+
if (!prev || prev === next) return;
|
|
653
|
+
(_a = props.setFormItemRef) == null ? void 0 : _a.call(props, prev, null, () => grouped.value.formItemProps);
|
|
654
|
+
(_b = props.setComponentRef) == null ? void 0 : _b.call(props, prev, null);
|
|
655
|
+
},
|
|
656
|
+
{ flush: "pre" }
|
|
657
|
+
);
|
|
658
|
+
const withContainer = (node, component, containerProps) => component ? h(component, containerProps, { default: () => node }) : node;
|
|
659
|
+
const renderFormItemSlots = (groupedField) => {
|
|
660
|
+
const slots = {};
|
|
661
|
+
Object.entries(groupedField.formItemSlots).forEach(([name, slot]) => {
|
|
662
|
+
slots[name] = (scope) => h(_sfc_main$f, {
|
|
663
|
+
path: groupedField.path,
|
|
664
|
+
component: slot,
|
|
665
|
+
...scope || {}
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
slots.default = () => {
|
|
669
|
+
const field = props.field;
|
|
670
|
+
if (field.fields) {
|
|
671
|
+
return h(_sfc_main$c, {
|
|
672
|
+
grid: field.grid ?? props.grid,
|
|
673
|
+
fields: field.fields,
|
|
674
|
+
disabled: effectiveDisabled.value
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
return h(_sfc_main$e, {
|
|
678
|
+
key: componentKey.value,
|
|
679
|
+
ref: setFieldRef,
|
|
680
|
+
...groupedField.componentProps,
|
|
681
|
+
path: groupedField.path,
|
|
682
|
+
disabled: effectiveDisabled.value
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
return slots;
|
|
686
|
+
};
|
|
687
|
+
return () => {
|
|
688
|
+
const groupedField = grouped.value;
|
|
689
|
+
let node = h(
|
|
690
|
+
ElFormItem,
|
|
691
|
+
{
|
|
692
|
+
...groupedField.formItemProps,
|
|
693
|
+
ref: setItemRef,
|
|
694
|
+
prop: normalizePathKey(groupedField.path),
|
|
695
|
+
path: groupedField.path
|
|
696
|
+
},
|
|
697
|
+
renderFormItemSlots(groupedField)
|
|
698
|
+
);
|
|
699
|
+
node = withContainer(node, groupedField.container, {
|
|
700
|
+
path: groupedField.path
|
|
701
|
+
});
|
|
702
|
+
node = withContainer(
|
|
703
|
+
node,
|
|
704
|
+
enableGrid.value ? ElCol : void 0,
|
|
705
|
+
groupedField.gridItemProps
|
|
706
|
+
);
|
|
707
|
+
return node;
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
const _export_sfc = (sfc, props) => {
|
|
712
|
+
const target = sfc.__vccOpts || sfc;
|
|
713
|
+
for (const [key, val] of props) {
|
|
714
|
+
target[key] = val;
|
|
715
|
+
}
|
|
716
|
+
return target;
|
|
717
|
+
};
|
|
718
|
+
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-6e6641b4"]]);
|
|
525
719
|
const fieldKeyMap = /* @__PURE__ */ new WeakMap();
|
|
526
720
|
let fieldKeySeed = 0;
|
|
527
721
|
const getFieldKey = (field) => {
|
|
@@ -535,75 +729,47 @@ const getFieldKey = (field) => {
|
|
|
535
729
|
}
|
|
536
730
|
return key;
|
|
537
731
|
};
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
const
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
formItemSlots[k] = slots[k];
|
|
578
|
-
} else {
|
|
579
|
-
componentProps.slots[k] = slots[k];
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
return {
|
|
583
|
-
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
584
|
-
gridItemProps: gridItemProps2,
|
|
585
|
-
formItemProps: formItemProps2,
|
|
586
|
-
formItemSlots,
|
|
587
|
-
componentProps,
|
|
588
|
-
container,
|
|
589
|
-
rawField: field,
|
|
590
|
-
renderKey: getFieldKey(field)
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
return {
|
|
594
|
-
path: resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS),
|
|
595
|
-
gridItemProps: gridItemProps2,
|
|
596
|
-
formItemProps: formItemProps2,
|
|
597
|
-
formItemSlots,
|
|
598
|
-
componentProps,
|
|
599
|
-
rawField: field,
|
|
600
|
-
renderKey: getFieldKey(field)
|
|
601
|
-
};
|
|
602
|
-
});
|
|
603
|
-
});
|
|
604
|
-
}
|
|
732
|
+
const rowKeyMap = /* @__PURE__ */ new WeakMap();
|
|
733
|
+
let rowKeySeed = 0;
|
|
734
|
+
const getRowKey = (row) => {
|
|
735
|
+
const raw = toRaw(row);
|
|
736
|
+
let key = rowKeyMap.get(raw);
|
|
737
|
+
if (key === void 0) {
|
|
738
|
+
key = ++rowKeySeed;
|
|
739
|
+
rowKeyMap.set(raw, key);
|
|
740
|
+
}
|
|
741
|
+
return key;
|
|
742
|
+
};
|
|
743
|
+
const isIndexSegment = (segment) => /^(?:0|[1-9]\d*)$/.test(segment);
|
|
744
|
+
const getFieldDataKey = (field, rawFormData) => {
|
|
745
|
+
const path = resolveFieldIdentity(field, ELEMENT_FIELD_IDENTITY_KEYS);
|
|
746
|
+
if (!path || rawFormData === null || rawFormData === void 0) {
|
|
747
|
+
return getFieldKey(field);
|
|
748
|
+
}
|
|
749
|
+
const segments = toPath(path);
|
|
750
|
+
let node = rawFormData;
|
|
751
|
+
const rowIds = [];
|
|
752
|
+
let lastRowIndex = -1;
|
|
753
|
+
for (let i = 0; i < segments.length; i++) {
|
|
754
|
+
if (Array.isArray(node)) {
|
|
755
|
+
const segment = segments[i];
|
|
756
|
+
if (!isIndexSegment(segment)) break;
|
|
757
|
+
const element = node[Number(segment)];
|
|
758
|
+
if (element === null || typeof element !== "object") break;
|
|
759
|
+
rowIds.push(getRowKey(toRaw(element)));
|
|
760
|
+
lastRowIndex = i;
|
|
761
|
+
node = element;
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
if (node === null || typeof node !== "object") break;
|
|
765
|
+
node = node[segments[i]];
|
|
766
|
+
}
|
|
767
|
+
if (lastRowIndex === -1) return getFieldKey(field);
|
|
768
|
+
const rest = segments.slice(lastRowIndex + 1).join(".");
|
|
769
|
+
return `data:${rowIds.join("/")}:${rest}`;
|
|
770
|
+
};
|
|
605
771
|
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
606
|
-
...{ name: "
|
|
772
|
+
...{ name: "BaseFormItems", inheritAttrs: false },
|
|
607
773
|
__name: "index",
|
|
608
774
|
props: {
|
|
609
775
|
grid: { type: [Boolean, Object], default: void 0 },
|
|
@@ -621,6 +787,20 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
621
787
|
)
|
|
622
788
|
)
|
|
623
789
|
);
|
|
790
|
+
const injectedForm = inject(InjectionFormKey, void 0);
|
|
791
|
+
const renderedFields = computed(() => {
|
|
792
|
+
const rawFormData = (injectedForm == null ? void 0 : injectedForm.formData) ? toRaw(injectedForm.formData) : void 0;
|
|
793
|
+
const seen = /* @__PURE__ */ new Map();
|
|
794
|
+
return validFields.value.map((field) => {
|
|
795
|
+
const baseKey = getFieldDataKey(field, rawFormData);
|
|
796
|
+
const count = seen.get(baseKey) ?? 0;
|
|
797
|
+
seen.set(baseKey, count + 1);
|
|
798
|
+
return {
|
|
799
|
+
field,
|
|
800
|
+
key: count === 0 ? baseKey : `${String(baseKey)}#${count}`
|
|
801
|
+
};
|
|
802
|
+
});
|
|
803
|
+
});
|
|
624
804
|
const config = INJECT_CONFIG["pro-form"];
|
|
625
805
|
const injectFormConfig = inject(config.injectionKey, config.default);
|
|
626
806
|
const injectGrid = computed(() => {
|
|
@@ -653,14 +833,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
653
833
|
}
|
|
654
834
|
}
|
|
655
835
|
};
|
|
656
|
-
const setFormItemRef = (field, el,
|
|
836
|
+
const setFormItemRef = (field, el, getFormItemProps) => {
|
|
657
837
|
if (!field || typeof field !== "object") return;
|
|
658
838
|
const raw = toRaw(field);
|
|
659
839
|
if (el) {
|
|
660
840
|
formItemInstanceMap.set(raw, el);
|
|
661
841
|
defineFieldAccessors(raw, {
|
|
662
842
|
getFormItemRef: () => formItemInstanceMap.get(raw),
|
|
663
|
-
getFormItemComputedProps:
|
|
843
|
+
getFormItemComputedProps: getFormItemProps
|
|
664
844
|
});
|
|
665
845
|
} else {
|
|
666
846
|
formItemInstanceMap.delete(raw);
|
|
@@ -689,79 +869,34 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
689
869
|
delete raw.getComponentComputedProps;
|
|
690
870
|
}
|
|
691
871
|
};
|
|
692
|
-
const groupedFields = useGroupFieldAttrs(validFields);
|
|
693
872
|
return (_ctx, _cache) => {
|
|
694
|
-
|
|
695
|
-
return openBlock(), createBlock(_sfc_main$f, mergeProps({
|
|
696
|
-
component: enableGrid.value ? unref(ElRow) : void 0
|
|
697
|
-
}, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
873
|
+
return enableGrid.value ? (openBlock(), createBlock(unref(ElRow), mergeProps({ key: 0 }, computedGridProps.value, { style: { "width": "100%" } }), {
|
|
698
874
|
default: withCtx(() => [
|
|
699
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
700
|
-
return openBlock(), createBlock(
|
|
701
|
-
key: item.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}, {
|
|
709
|
-
default: withCtx(() => [
|
|
710
|
-
createVNode(unref(ElFormItem), mergeProps({ ref_for: true }, item.formItemProps, {
|
|
711
|
-
ref_for: true,
|
|
712
|
-
ref: (el) => setFormItemRef(item.rawField, el, item.formItemProps),
|
|
713
|
-
prop: unref(normalizePathKey)(item.path),
|
|
714
|
-
path: item.path
|
|
715
|
-
}), createSlots({
|
|
716
|
-
default: withCtx(() => [
|
|
717
|
-
item.rawField.fields ? (openBlock(), createBlock(_component_BaseFormItem, {
|
|
718
|
-
key: 0,
|
|
719
|
-
grid: item.rawField.grid ?? props.grid,
|
|
720
|
-
fields: item.rawField.fields,
|
|
721
|
-
disabled: toValue(item.rawField.disabled)
|
|
722
|
-
}, null, 8, ["grid", "fields", "disabled"])) : (openBlock(), createBlock(_sfc_main$d, mergeProps({
|
|
723
|
-
key: 1,
|
|
724
|
-
ref_for: true,
|
|
725
|
-
ref: (el) => setComponentRef(item.rawField, el)
|
|
726
|
-
}, { ref_for: true }, item.componentProps, {
|
|
727
|
-
path: item.path
|
|
728
|
-
}), null, 16, ["path"]))
|
|
729
|
-
]),
|
|
730
|
-
_: 2
|
|
731
|
-
}, [
|
|
732
|
-
renderList(item.formItemSlots, (slot, name) => {
|
|
733
|
-
return {
|
|
734
|
-
name,
|
|
735
|
-
fn: withCtx((scoped) => [
|
|
736
|
-
createVNode(_sfc_main$e, mergeProps({
|
|
737
|
-
path: item.path,
|
|
738
|
-
component: slot
|
|
739
|
-
}, { ref_for: true }, scoped), null, 16, ["path", "component"])
|
|
740
|
-
])
|
|
741
|
-
};
|
|
742
|
-
})
|
|
743
|
-
]), 1040, ["prop", "path"])
|
|
744
|
-
]),
|
|
745
|
-
_: 2
|
|
746
|
-
}, 1032, ["component", "path"])
|
|
747
|
-
]),
|
|
748
|
-
_: 2
|
|
749
|
-
}, 1040, ["component"]);
|
|
875
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(renderedFields.value, (item) => {
|
|
876
|
+
return openBlock(), createBlock(BaseFormItem, {
|
|
877
|
+
key: item.key,
|
|
878
|
+
field: item.field,
|
|
879
|
+
grid: props.grid,
|
|
880
|
+
disabled: props.disabled,
|
|
881
|
+
"set-form-item-ref": setFormItemRef,
|
|
882
|
+
"set-component-ref": setComponentRef
|
|
883
|
+
}, null, 8, ["field", "grid", "disabled"]);
|
|
750
884
|
}), 128))
|
|
751
885
|
]),
|
|
752
886
|
_: 1
|
|
753
|
-
}, 16,
|
|
887
|
+
}, 16)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(renderedFields.value, (item) => {
|
|
888
|
+
return openBlock(), createBlock(BaseFormItem, {
|
|
889
|
+
key: item.key,
|
|
890
|
+
field: item.field,
|
|
891
|
+
grid: props.grid,
|
|
892
|
+
disabled: props.disabled,
|
|
893
|
+
"set-form-item-ref": setFormItemRef,
|
|
894
|
+
"set-component-ref": setComponentRef
|
|
895
|
+
}, null, 8, ["field", "grid", "disabled"]);
|
|
896
|
+
}), 128));
|
|
754
897
|
};
|
|
755
898
|
}
|
|
756
899
|
});
|
|
757
|
-
const _export_sfc = (sfc, props) => {
|
|
758
|
-
const target = sfc.__vccOpts || sfc;
|
|
759
|
-
for (const [key, val] of props) {
|
|
760
|
-
target[key] = val;
|
|
761
|
-
}
|
|
762
|
-
return target;
|
|
763
|
-
};
|
|
764
|
-
const BaseFormItem = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-dea0b53c"]]);
|
|
765
900
|
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
766
901
|
...{ name: "ProForm", inheritAttrs: false },
|
|
767
902
|
__name: "index",
|
|
@@ -812,6 +947,12 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
812
947
|
omitBy(camelizeProperties(attrs), (value) => value === void 0)
|
|
813
948
|
);
|
|
814
949
|
});
|
|
950
|
+
const outerDisabled = useDisabledContext();
|
|
951
|
+
const formDisabled = computed(() => {
|
|
952
|
+
const explicit = resolveDisabled(toValue(formAttrs.value.disabled));
|
|
953
|
+
if (explicit !== void 0) return explicit;
|
|
954
|
+
return outerDisabled.value ? true : void 0;
|
|
955
|
+
});
|
|
815
956
|
const slots = useSlots();
|
|
816
957
|
const formSlotsRef = shallowRef(slots);
|
|
817
958
|
onUpdated(() => {
|
|
@@ -829,10 +970,11 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
829
970
|
}, ["prevent"]))
|
|
830
971
|
}), {
|
|
831
972
|
default: withCtx(() => [
|
|
832
|
-
createVNode(
|
|
973
|
+
createVNode(_sfc_main$c, {
|
|
833
974
|
fields: fields.value,
|
|
834
|
-
grid: props.grid
|
|
835
|
-
|
|
975
|
+
grid: props.grid,
|
|
976
|
+
disabled: formDisabled.value
|
|
977
|
+
}, null, 8, ["fields", "grid", "disabled"]),
|
|
836
978
|
renderSlot(_ctx.$slots, "default")
|
|
837
979
|
]),
|
|
838
980
|
_: 3
|
|
@@ -1337,7 +1479,7 @@ const renderColumn = (column, ancestors = /* @__PURE__ */ new Set()) => {
|
|
|
1337
1479
|
}
|
|
1338
1480
|
if (typeof column.render === "function") {
|
|
1339
1481
|
return h(ElTableColumn, vnodeProps, {
|
|
1340
|
-
default: (scope) => h(_sfc_main$
|
|
1482
|
+
default: (scope) => h(_sfc_main$f, {
|
|
1341
1483
|
component: column.render({
|
|
1342
1484
|
...scope,
|
|
1343
1485
|
column,
|
|
@@ -1623,15 +1765,21 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1623
1765
|
};
|
|
1624
1766
|
});
|
|
1625
1767
|
const showPagination = computed(() => computedPagination.value !== false);
|
|
1768
|
+
let sizeChangeWindow = false;
|
|
1626
1769
|
const onCurrentChange = (current) => {
|
|
1627
1770
|
var _a, _b;
|
|
1771
|
+
if (sizeChangeWindow) return;
|
|
1628
1772
|
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { current });
|
|
1629
1773
|
_search();
|
|
1630
1774
|
};
|
|
1631
1775
|
const onSizeChange = (pageSize) => {
|
|
1632
1776
|
var _a, _b;
|
|
1777
|
+
sizeChangeWindow = true;
|
|
1633
1778
|
(_b = (_a = props.table) == null ? void 0 : _a.setPageParam) == null ? void 0 : _b.call(_a, { pageSize, current: 1 });
|
|
1634
1779
|
_search();
|
|
1780
|
+
nextTick(() => {
|
|
1781
|
+
sizeChangeWindow = false;
|
|
1782
|
+
});
|
|
1635
1783
|
};
|
|
1636
1784
|
const onPaginationChange = (currentPage, pageSize) => {
|
|
1637
1785
|
var _a;
|
|
@@ -1678,7 +1826,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1678
1826
|
class: normalizeClass(["pro-table", unref(attrs).class]),
|
|
1679
1827
|
style: normalizeStyle(unref(attrs).style)
|
|
1680
1828
|
}, [
|
|
1681
|
-
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$
|
|
1829
|
+
searchFormVisible.value || _ctx.$slots["search-form"] ? (openBlock(), createBlock(_sfc_main$g, {
|
|
1682
1830
|
key: 0,
|
|
1683
1831
|
component: computedSearchFormConfig.value.container
|
|
1684
1832
|
}, {
|
|
@@ -1698,7 +1846,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1698
1846
|
]),
|
|
1699
1847
|
_: 3
|
|
1700
1848
|
}, 8, ["component"])) : createCommentVNode("", true),
|
|
1701
|
-
createVNode(_sfc_main$
|
|
1849
|
+
createVNode(_sfc_main$g, { component: computedTableContainer.value }, {
|
|
1702
1850
|
default: withCtx(() => [
|
|
1703
1851
|
createElementVNode("div", _hoisted_1, [
|
|
1704
1852
|
_ctx.$slots["button-bar"] ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
@@ -1759,7 +1907,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
1759
1907
|
};
|
|
1760
1908
|
}
|
|
1761
1909
|
});
|
|
1762
|
-
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
1910
|
+
const ProTable = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-9774f05e"]]);
|
|
1763
1911
|
function useTable(params = {}) {
|
|
1764
1912
|
const { data, columns, ...rest } = params;
|
|
1765
1913
|
const coreTable = useTable$1({
|
|
@@ -1867,12 +2015,12 @@ const index = {
|
|
|
1867
2015
|
}
|
|
1868
2016
|
};
|
|
1869
2017
|
export {
|
|
1870
|
-
_sfc_main$
|
|
2018
|
+
_sfc_main$g as ContainerFragment,
|
|
1871
2019
|
LOCALE_INJECT_KEY,
|
|
1872
2020
|
_sfc_main as ProComponentProvider,
|
|
1873
2021
|
_sfc_main$b as ProForm,
|
|
1874
2022
|
ProTable,
|
|
1875
|
-
_sfc_main$
|
|
2023
|
+
_sfc_main$f as SlotComponent,
|
|
1876
2024
|
index as default,
|
|
1877
2025
|
enUS,
|
|
1878
2026
|
useFields,
|