@dazhicheng/ui 1.5.198 → 1.5.201
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/dist/_virtual/_plugin-vue_export-helper.js +9 -0
- package/dist/api/dataTypeContext.js +17 -0
- package/dist/assets/img/empty_images/no_data.png.js +4 -0
- package/dist/assets/img/empty_images/search.png.js +4 -0
- package/dist/assets/img/image_status/develop.png.js +4 -0
- package/dist/assets/img/image_status/loading.gif.js +4 -0
- package/dist/assets/img/image_status/loading_fail.png.js +4 -0
- package/dist/assets/img/image_status/no_network.png.js +4 -0
- package/dist/assets/img/image_status/no_permission.png.js +4 -0
- package/dist/assets/svg/action_more.svg.js +4 -0
- package/dist/assets/svg/close.svg.js +4 -0
- package/dist/assets/svg/item_error.svg.js +4 -0
- package/dist/assets/svg/paixu-jiangxu.svg.js +4 -0
- package/dist/assets/svg/paixu-moren.svg.js +4 -0
- package/dist/assets/svg/paixu-shengxu.svg.js +4 -0
- package/dist/assets/svg/quanping.svg.js +4 -0
- package/dist/assets/svg/suoxiao.svg.js +4 -0
- package/dist/components/tt-api-component/index.js +7 -0
- package/dist/components/tt-api-component/index.vue.js +7 -0
- package/dist/components/tt-api-component/index.vue2.js +199 -0
- package/dist/components/tt-area/TtArea.vue.js +7 -0
- package/dist/components/tt-area/TtArea.vue2.js +36 -0
- package/dist/components/tt-button/components/AddButton.vue.js +24 -0
- package/dist/components/tt-button/components/AddButton.vue2.js +4 -0
- package/dist/components/tt-button/index.js +9 -0
- package/dist/components/tt-button/index.vue.js +7 -0
- package/dist/components/tt-button/index.vue2.js +68 -0
- package/dist/components/tt-checkbox/index.js +7 -0
- package/dist/components/tt-checkbox/index.vue.js +77 -0
- package/dist/components/tt-checkbox/index.vue2.js +4 -0
- package/dist/components/tt-drawer/index.js +14 -0
- package/dist/components/tt-drawer/src/RenderDrawer.vue.js +156 -0
- package/dist/components/tt-drawer/src/RenderDrawer.vue3.js +5 -0
- package/dist/components/tt-drawer/src/components/DrawerFooter.vue.js +56 -0
- package/dist/components/tt-drawer/src/components/DrawerFooter.vue3.js +5 -0
- package/dist/components/tt-drawer/src/components/DrawerHeader.vue.js +7 -0
- package/dist/components/tt-drawer/src/components/DrawerHeader.vue2.js +21 -0
- package/dist/components/tt-drawer/src/hooks/useDrawerRender.js +124 -0
- package/dist/components/tt-drawer/src/hooks/useResizable.js +98 -0
- package/dist/components/tt-drawer/src/index.js +17 -0
- package/dist/components/tt-drawer/src/props.js +72 -0
- package/dist/components/tt-drawer/src/utils/drawer-api.js +191 -0
- package/dist/components/tt-empty/index.js +34 -0
- package/dist/components/tt-form/index.js +65 -0
- package/dist/components/tt-form/src/components/ExpandableArrow.vue2.js +38 -0
- package/dist/components/tt-form/src/components/ExpandableArrow.vue3.js +5 -0
- package/dist/components/tt-form/src/components/FormActions.vue2.js +177 -0
- package/dist/components/tt-form/src/components/FormActions.vue3.js +5 -0
- package/dist/components/tt-form/src/components/FormElInput.vue.js +80 -0
- package/dist/components/tt-form/src/components/FormElInput.vue2.js +4 -0
- package/dist/components/tt-form/src/components/Slot.js +28 -0
- package/dist/components/tt-form/src/config.js +57 -0
- package/dist/components/tt-form/src/form/FormControl.vue.js +16 -0
- package/dist/components/tt-form/src/form/FormControl.vue2.js +4 -0
- package/dist/components/tt-form/src/form/FormDescription.vue.js +21 -0
- package/dist/components/tt-form/src/form/FormDescription.vue2.js +4 -0
- package/dist/components/tt-form/src/form/FormItem.vue.js +20 -0
- package/dist/components/tt-form/src/form/FormItem.vue2.js +4 -0
- package/dist/components/tt-form/src/form/FormLabel.vue.js +19 -0
- package/dist/components/tt-form/src/form/FormLabel.vue2.js +4 -0
- package/dist/components/tt-form/src/form/FormMessage.vue.js +18 -0
- package/dist/components/tt-form/src/form/FormMessage.vue2.js +4 -0
- package/dist/components/tt-form/src/form/FormMessageToolTip.vue.js +30 -0
- package/dist/components/tt-form/src/form/FormMessageToolTip.vue2.js +4 -0
- package/dist/components/tt-form/src/form/RenderContent.vue.js +31 -0
- package/dist/components/tt-form/src/form/RenderContent.vue2.js +4 -0
- package/dist/components/tt-form/src/form/injectionKeys.js +4 -0
- package/dist/components/tt-form/src/form/useFormField.js +24 -0
- package/dist/components/tt-form/src/form-render/FormField.vue.js +4 -0
- package/dist/components/tt-form/src/form-render/FormField.vue2.js +346 -0
- package/dist/components/tt-form/src/form-render/FormFieldContact.js +54 -0
- package/dist/components/tt-form/src/form-render/FormLabel.vue.js +4 -0
- package/dist/components/tt-form/src/form-render/FormLabel.vue2.js +102 -0
- package/dist/components/tt-form/src/form-render/array-register/FormArrayRegister.js +195 -0
- package/dist/components/tt-form/src/form-render/array-register/props.js +47 -0
- package/dist/components/tt-form/src/form-render/array-register/utils.js +12 -0
- package/dist/components/tt-form/src/form-render/context.js +15 -0
- package/dist/components/tt-form/src/form-render/dependencies.js +51 -0
- package/dist/components/tt-form/src/form-render/expandable.js +46 -0
- package/dist/components/tt-form/src/form-render/form.vue2.js +197 -0
- package/dist/components/tt-form/src/form-render/form.vue3.js +5 -0
- package/dist/components/tt-form/src/form-render/helper.js +22 -0
- package/dist/components/tt-form/src/form-render/rootWrapperClass.js +10 -0
- package/dist/components/tt-form/src/formApi.js +790 -0
- package/dist/components/tt-form/src/group-form/GroupForm.vue2.js +223 -0
- package/dist/components/tt-form/src/group-form/GroupForm.vue3.js +5 -0
- package/dist/components/tt-form/src/group-form/GroupSection.vue2.js +278 -0
- package/dist/components/tt-form/src/group-form/GroupSection.vue3.js +5 -0
- package/dist/components/tt-form/src/group-form/LazyFormField.vue.js +153 -0
- package/dist/components/tt-form/src/group-form/LazyFormField.vue3.js +5 -0
- package/dist/components/tt-form/src/group-form/groupFormApi.js +700 -0
- package/dist/components/tt-form/src/group-form/lazyContext.js +38 -0
- package/dist/components/tt-form/src/group-form/useGroupForm.js +83 -0
- package/dist/components/tt-form/src/group-form/utils.js +106 -0
- package/dist/components/tt-form/src/hooks/useArrayRegistry.js +22 -0
- package/dist/components/tt-form/src/hooks/useFieldArray.js +137 -0
- package/dist/components/tt-form/src/hooks/useForwardPriorityValues.js +33 -0
- package/dist/components/tt-form/src/hooks/useSelectCollapse.js +81 -0
- package/dist/components/tt-form/src/index.vue2.js +149 -0
- package/dist/components/tt-form/src/index.vue3.js +5 -0
- package/dist/components/tt-form/src/shared/createContext.js +14 -0
- package/dist/components/tt-form/src/shared/global-state.js +22 -0
- package/dist/components/tt-form/src/shared/zod-defaults.js +47 -0
- package/dist/components/tt-form/src/types/forms.js +6 -0
- package/dist/components/tt-form/src/useForm.js +28 -0
- package/dist/components/tt-form/src/useFormContext.js +320 -0
- package/dist/components/tt-form/src/utils/array-path.js +18 -0
- package/dist/components/tt-form-item-error-tooltip/index.js +9 -0
- package/dist/components/tt-form-item-error-tooltip/index.vue.js +183 -0
- package/dist/components/tt-form-item-error-tooltip/index.vue3.js +5 -0
- package/dist/components/tt-icon/components/AddIcon.vue.js +28 -0
- package/dist/components/tt-icon/components/AddIcon.vue2.js +4 -0
- package/dist/components/tt-icon/components/SubIcon.vue.js +28 -0
- package/dist/components/tt-icon/components/SubIcon.vue2.js +4 -0
- package/dist/components/tt-icon/index.js +11 -0
- package/dist/components/tt-icon/index.vue.js +8 -0
- package/dist/components/tt-icon/index.vue2.js +115 -0
- package/dist/components/tt-image/index.js +9 -0
- package/dist/components/tt-image/src/components/ImageViewer.js +41 -0
- package/dist/components/tt-image/tt-image.js +55 -0
- package/dist/components/tt-loading/index.js +8 -0
- package/dist/components/tt-loading/src/directive.js +51 -0
- package/dist/components/tt-loading/src/loading.vue.js +7 -0
- package/dist/components/tt-loading/src/loading.vue2.js +75 -0
- package/dist/components/tt-loading/src/service.js +79 -0
- package/dist/components/tt-log/index.js +7 -0
- package/dist/components/tt-log/index.vue.js +30 -0
- package/dist/components/tt-log/index.vue2.js +4 -0
- package/dist/components/tt-modal/index.js +14 -0
- package/dist/components/tt-modal/src/RenderModal.vue.js +310 -0
- package/dist/components/tt-modal/src/RenderModal.vue3.js +5 -0
- package/dist/components/tt-modal/src/components/ModalFooter.vue.js +7 -0
- package/dist/components/tt-modal/src/components/ModalFooter.vue2.js +74 -0
- package/dist/components/tt-modal/src/components/ModalHeader.vue.js +7 -0
- package/dist/components/tt-modal/src/components/ModalHeader.vue2.js +22 -0
- package/dist/components/tt-modal/src/components/ModalWrapper.vue.js +48 -0
- package/dist/components/tt-modal/src/components/ModalWrapper.vue2.js +4 -0
- package/dist/components/tt-modal/src/hooks/useModalRender.js +131 -0
- package/dist/components/tt-modal/src/index.js +17 -0
- package/dist/components/tt-modal/src/props.js +75 -0
- package/dist/components/tt-modal/src/utils/modal-api.js +200 -0
- package/dist/components/tt-modal/src/utils/modal-stack.js +28 -0
- package/dist/components/tt-modal-form/hooks/useModalFormSlot.js +22 -0
- package/dist/components/tt-modal-form/index.vue.js +178 -0
- package/dist/components/tt-modal-form/index.vue2.js +4 -0
- package/dist/components/tt-modal-form/useModalForm.js +30 -0
- package/dist/components/tt-nav-anchor/index.js +8 -0
- package/dist/components/tt-nav-anchor/src/TtNavAnchor.vue.js +234 -0
- package/dist/components/tt-nav-anchor/src/TtNavAnchor.vue3.js +5 -0
- package/dist/components/tt-nav-anchor/src/constants.js +4 -0
- package/dist/components/tt-panel-select/index.js +7 -0
- package/dist/components/tt-panel-select/src/common.js +4 -0
- package/dist/components/tt-panel-select/src/components/PanelLeft.vue.js +56 -0
- package/dist/components/tt-panel-select/src/components/PanelLeft.vue2.js +4 -0
- package/dist/components/tt-panel-select/src/components/PanelMiddle.vue.js +277 -0
- package/dist/components/tt-panel-select/src/components/PanelMiddle.vue2.js +4 -0
- package/dist/components/tt-panel-select/src/components/PanelRight.vue.js +108 -0
- package/dist/components/tt-panel-select/src/components/PanelRight.vue2.js +4 -0
- package/dist/components/tt-panel-select/src/hooks/usePanelData.js +184 -0
- package/dist/components/tt-panel-select/src/hooks/usePanelSelection.js +91 -0
- package/dist/components/tt-panel-select/src/index.vue.js +386 -0
- package/dist/components/tt-panel-select/src/index.vue2.js +4 -0
- package/dist/components/tt-select/index.js +8 -0
- package/dist/components/tt-select/src/Select.vue.js +315 -0
- package/dist/components/tt-select/src/Select.vue3.js +5 -0
- package/dist/components/tt-select/src/components/SelectTable.vue.js +86 -0
- package/dist/components/tt-select/src/components/SelectTable.vue3.js +5 -0
- package/dist/components/tt-select/src/components/Table.vue.js +307 -0
- package/dist/components/tt-select/src/components/Table.vue3.js +5 -0
- package/dist/components/tt-select/src/const.js +19 -0
- package/dist/components/tt-select/src/hooks/useDataSource.js +196 -0
- package/dist/components/tt-select/src/hooks/useGrid.js +97 -0
- package/dist/components/tt-select/src/hooks/useKeyboard.js +63 -0
- package/dist/components/tt-select/src/hooks/usePagination.js +45 -0
- package/dist/components/tt-select/src/hooks/useSelect.js +100 -0
- package/dist/components/tt-select/src/hooks/useSelectTableEvent.d.ts +1 -1
- package/dist/components/tt-select/src/hooks/useSelectTableEvent.js +345 -0
- package/dist/components/tt-select/src/props.js +201 -0
- package/dist/components/tt-select/src/utils/index.js +16 -0
- package/dist/components/tt-table/index.js +33 -0
- package/dist/components/tt-table/src/Table.vue.js +623 -0
- package/dist/components/tt-table/src/Table.vue3.js +5 -0
- package/dist/components/tt-table/src/TableForm.vue.js +317 -0
- package/dist/components/tt-table/src/TableForm.vue2.js +4 -0
- package/dist/components/tt-table/src/componentMap.js +4 -0
- package/dist/components/tt-table/src/components/RowContext.js +24 -0
- package/dist/components/tt-table/src/components/TableAction.vue.js +222 -0
- package/dist/components/tt-table/src/components/TableAction.vue2.js +4 -0
- package/dist/components/tt-table/src/components/TableButtons.js +117 -0
- package/dist/components/tt-table/src/components/TableColumnModal.vue2.js +233 -0
- package/dist/components/tt-table/src/components/TableColumnModal.vue3.js +5 -0
- package/dist/components/tt-table/src/components/TableToobalTools.vue.js +87 -0
- package/dist/components/tt-table/src/components/TableToobalTools.vue2.js +4 -0
- package/dist/components/tt-table/src/emits.js +15 -0
- package/dist/components/tt-table/src/hooks/useCellArea.js +15 -0
- package/dist/components/tt-table/src/hooks/useColumns.js +275 -0
- package/dist/components/tt-table/src/hooks/useCustomColumns.js +53 -0
- package/dist/components/tt-table/src/hooks/useDataSource.js +224 -0
- package/dist/components/tt-table/src/hooks/useLeftRightSlot.js +64 -0
- package/dist/components/tt-table/src/hooks/usePagination.js +44 -0
- package/dist/components/tt-table/src/hooks/useRowSelection.js +84 -0
- package/dist/components/tt-table/src/hooks/useTableContext.js +20 -0
- package/dist/components/tt-table/src/hooks/useTableEvent.js +197 -0
- package/dist/components/tt-table/src/hooks/useTableForm.js +60 -0
- package/dist/components/tt-table/src/hooks/useTableRender.js +33 -0
- package/dist/components/tt-table/src/hooks/useTableSlot.js +17 -0
- package/dist/components/tt-table/src/props.js +482 -0
- package/dist/components/tt-table/src/toolProps.js +30 -0
- package/dist/components/tt-table/src/utils/context.js +17 -0
- package/dist/components/tt-table/src/utils/table-api.js +386 -0
- package/dist/components/tt-table/src/utils/table-form-api.js +122 -0
- package/dist/components/tt-text/index.js +7 -0
- package/dist/components/tt-text/index.vue.js +7 -0
- package/dist/components/tt-text/index.vue2.js +73 -0
- package/dist/components/tt-upload/index.js +9 -0
- package/dist/components/tt-upload/src/TtUpload.vue.js +305 -0
- package/dist/components/tt-upload/src/TtUpload.vue2.js +4 -0
- package/dist/components/tt-upload/src/typing.js +107 -0
- package/dist/directives/auto-tip/index.js +62 -0
- package/dist/directives/dialog-resize/index.js +49 -0
- package/dist/directives/dialog-resize/use-css-variable.js +44 -0
- package/dist/directives/dialog-resize/use-draggable.js +35 -0
- package/dist/directives/dialog-resize/use-fullscreen.js +38 -0
- package/dist/directives/dialog-resize/use-parse-translate.js +9 -0
- package/dist/directives/dialog-resize/use-resizer.js +37 -0
- package/dist/directives/disabled-tip/index.js +78 -0
- package/dist/directives/index.js +8 -0
- package/dist/hooks/useDataPermissionOptions.js +142 -0
- package/dist/hooks/useFormSchemasLink.js +261 -0
- package/dist/hooks/useFormat.js +44 -0
- package/dist/hooks/useLoading.js +22 -0
- package/dist/hooks/useScreenshotOss.js +69 -0
- package/dist/hooks/useSetup.js +59 -0
- package/dist/index.js +142 -60274
- package/dist/plugins/default/renderCellContent.js +58 -0
- package/dist/plugins/vxeTable/switchStatus.js +91 -0
- package/dist/plugins.js +4 -146
- package/dist/style.css +1 -1
- package/dist/utils/xhr.js +8 -0
- package/package.json +5 -3
- package/dist/index-NG5FNCLD.js +0 -3430
- package/dist/index.modern-4Cf3dcJP.js +0 -3069
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var O = (u, t, e) => t in u ? L(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
|
|
3
|
+
var h = (u, t, e) => O(u, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import R from "dayjs";
|
|
5
|
+
import "dayjs/plugin/timezone";
|
|
6
|
+
import { reactive as $, unref as y, isRef as b, toRaw as F } from "vue";
|
|
7
|
+
import { set as A, get as w, has as T, cloneDeep as E } from "lodash-es";
|
|
8
|
+
import { asFieldArrayContext as H } from "./types/forms.js";
|
|
9
|
+
import { childArrayPath as P, normalizeArrayFieldPath as g, collectArrayFieldPathAliases as C } from "./utils/array-path.js";
|
|
10
|
+
import { Store as j } from "@tanstack/vue-store";
|
|
11
|
+
import { StateHandler as Y, bindMethods as z, isFunction as S, mergeWithArrayOverride as V, createMerge as B, isObject as v, isDayjsObject as N, isDate as M } from "@dazhicheng/utils";
|
|
12
|
+
import { isFormSchema as I, shouldSeedAppendedFieldValue as k, resolveSchemaFieldInitialValue as U, resolveArrayFieldInitialValueWithRuntime as W, resolveParentItemPathFromArrayPath as q } from "./useFormContext.js";
|
|
13
|
+
function x() {
|
|
14
|
+
return {
|
|
15
|
+
actionWrapperClass: "",
|
|
16
|
+
collapsed: !1,
|
|
17
|
+
collapsedRows: 1,
|
|
18
|
+
collapseTriggerResize: !1,
|
|
19
|
+
commonConfig: {},
|
|
20
|
+
handleReset: void 0,
|
|
21
|
+
handleSubmit: void 0,
|
|
22
|
+
handleValuesChange: void 0,
|
|
23
|
+
handleCollapsedChange: void 0,
|
|
24
|
+
layout: "horizontal",
|
|
25
|
+
resetButtonOptions: {},
|
|
26
|
+
schema: [],
|
|
27
|
+
scrollToFirstError: !1,
|
|
28
|
+
showCollapseButton: !1,
|
|
29
|
+
showDefaultActions: !0,
|
|
30
|
+
submitButtonOptions: {},
|
|
31
|
+
submitOnChange: !1,
|
|
32
|
+
submitOnEnter: !1,
|
|
33
|
+
wrapperClass: "grid-cols-1"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function D(u, t = "YYYY-MM-DD") {
|
|
37
|
+
try {
|
|
38
|
+
const e = R.isDayjs(u) ? u : R(u);
|
|
39
|
+
if (!e.isValid())
|
|
40
|
+
throw new Error("Invalid date");
|
|
41
|
+
return e.tz().format(t);
|
|
42
|
+
} catch {
|
|
43
|
+
return String(u ?? "");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
class ie {
|
|
47
|
+
constructor(t = {}) {
|
|
48
|
+
// private api: Pick<TtFormProps, 'handleReset' | 'handleSubmit'>;
|
|
49
|
+
h(this, "form", {});
|
|
50
|
+
h(this, "isMounted", !1);
|
|
51
|
+
h(this, "state", null);
|
|
52
|
+
h(this, "stateHandler");
|
|
53
|
+
h(this, "store");
|
|
54
|
+
h(this, "_arrayFields", $(/* @__PURE__ */ new Map()));
|
|
55
|
+
/**
|
|
56
|
+
* 组件实例映射
|
|
57
|
+
*/
|
|
58
|
+
h(this, "componentRefMap", /* @__PURE__ */ new Map());
|
|
59
|
+
/**
|
|
60
|
+
* @description 数组字段操作集合
|
|
61
|
+
*/
|
|
62
|
+
h(this, "_arrayAction", {
|
|
63
|
+
/**
|
|
64
|
+
* @description 获取指定数组字段的操作上下文
|
|
65
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
66
|
+
* @returns 只读
|
|
67
|
+
*/
|
|
68
|
+
get: (t) => {
|
|
69
|
+
const e = this._getArrayFieldActions(t);
|
|
70
|
+
if (!e) {
|
|
71
|
+
this._warnUnregisteredArrayField("get", t);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
return e;
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* @description 在数组末尾新增一项
|
|
78
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
79
|
+
* @param value 要追加的数组项值
|
|
80
|
+
*/
|
|
81
|
+
push: (t, e) => this._mutateArrayField(
|
|
82
|
+
"push",
|
|
83
|
+
t,
|
|
84
|
+
(r) => r.push(
|
|
85
|
+
this._resolveArrayItemValue(t, e, {
|
|
86
|
+
index: y(r.fields).length,
|
|
87
|
+
arrayLength: y(r.fields).length + 1
|
|
88
|
+
})
|
|
89
|
+
)
|
|
90
|
+
),
|
|
91
|
+
/**
|
|
92
|
+
* @description 删除指定索引的项
|
|
93
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
94
|
+
* @param idx 要删除的索引位置
|
|
95
|
+
*/
|
|
96
|
+
remove: (t, e) => this._mutateArrayField("remove", t, (r) => r.remove(e)),
|
|
97
|
+
/**
|
|
98
|
+
* @description 整体替换数组值
|
|
99
|
+
* @template TValue 数组项类型
|
|
100
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
101
|
+
* @param values 新的完整数组字段
|
|
102
|
+
*/
|
|
103
|
+
replace: (t, e) => this._mutateArrayField("replace", t, (r) => r.replace(e)),
|
|
104
|
+
/**
|
|
105
|
+
* @description更新指定索引的项
|
|
106
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
107
|
+
* @param idx 要更新的索引位置
|
|
108
|
+
* @param value 更新后的数组项值
|
|
109
|
+
*/
|
|
110
|
+
update: (t, e, r) => this._mutateArrayField("update", t, (s) => s.update(e, r)),
|
|
111
|
+
/**
|
|
112
|
+
* @description 在指定索引插入一项
|
|
113
|
+
* @template TValue 数组项类型
|
|
114
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
115
|
+
* @param idx 插入位置索引
|
|
116
|
+
* @param value 要插入的数组项值
|
|
117
|
+
*/
|
|
118
|
+
insert: (t, e, r) => this._mutateArrayField(
|
|
119
|
+
"insert",
|
|
120
|
+
t,
|
|
121
|
+
(s) => s.insert(
|
|
122
|
+
e,
|
|
123
|
+
this._resolveArrayItemValue(t, r, {
|
|
124
|
+
index: e,
|
|
125
|
+
arrayLength: y(s.fields).length + 1
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
),
|
|
129
|
+
/**
|
|
130
|
+
* @description 在数组头部新增一项
|
|
131
|
+
* @template TValue 数组项类型
|
|
132
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
133
|
+
* @param value 要插入到头部的数组项值
|
|
134
|
+
*/
|
|
135
|
+
prepend: (t, e) => this._mutateArrayField(
|
|
136
|
+
"prepend",
|
|
137
|
+
t,
|
|
138
|
+
(r) => r.prepend(
|
|
139
|
+
this._resolveArrayItemValue(t, e, {
|
|
140
|
+
index: 0,
|
|
141
|
+
arrayLength: y(r.fields).length + 1
|
|
142
|
+
})
|
|
143
|
+
)
|
|
144
|
+
),
|
|
145
|
+
/**
|
|
146
|
+
* @description 将项从旧索引移动到新索引
|
|
147
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
148
|
+
* @param oldIdx 原索引位置
|
|
149
|
+
* @param newIdx 新索引位置
|
|
150
|
+
*/
|
|
151
|
+
move: (t, e, r) => this._mutateArrayField("move", t, (s) => s.move(e, r)),
|
|
152
|
+
/**
|
|
153
|
+
* @description 交换两个索引位置的项
|
|
154
|
+
* @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
|
|
155
|
+
* @param indexA 第一个索引位置
|
|
156
|
+
* @param indexB 第二个索引位置
|
|
157
|
+
*/
|
|
158
|
+
swap: (t, e, r) => this._mutateArrayField("swap", t, (s) => s.swap(e, r)),
|
|
159
|
+
/**
|
|
160
|
+
* @description 获取嵌套数组路径下的操作器
|
|
161
|
+
* @param parentPath 父数组路径(如 actions.data),或完整路径(仅传 path)
|
|
162
|
+
* @param index 父数组索引
|
|
163
|
+
* @param childField 子数组字段名(如 skills)
|
|
164
|
+
*/
|
|
165
|
+
at: (t, e, r) => this._createNestedArrayHandle(P(t, e, r))
|
|
166
|
+
});
|
|
167
|
+
// 最后一次点击提交时的表单值
|
|
168
|
+
h(this, "latestSubmissionValues", null);
|
|
169
|
+
h(this, "prevState", null);
|
|
170
|
+
h(this, "handleMultiFields", (t) => {
|
|
171
|
+
var s;
|
|
172
|
+
const e = (s = this.state) == null ? void 0 : s.arrayToStringFields;
|
|
173
|
+
if (!e || !Array.isArray(e))
|
|
174
|
+
return;
|
|
175
|
+
const r = (i, n = ",") => {
|
|
176
|
+
this.processFields(i, n, t, (a, l) => {
|
|
177
|
+
if (Array.isArray(a))
|
|
178
|
+
return a.join(l);
|
|
179
|
+
if (typeof a == "string") {
|
|
180
|
+
if (a === "")
|
|
181
|
+
return [];
|
|
182
|
+
const c = l.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
183
|
+
return a.split(new RegExp(c));
|
|
184
|
+
} else
|
|
185
|
+
return a;
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
if (e.every((i) => typeof i == "string")) {
|
|
189
|
+
const i = e[e.length - 1] || "", n = i.length === 1 ? e.slice(0, -1) : e, a = i.length === 1 ? i : ",";
|
|
190
|
+
r(n, a);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
e.forEach((i) => {
|
|
194
|
+
if (Array.isArray(i)) {
|
|
195
|
+
const [n, a = ","] = i;
|
|
196
|
+
if (!Array.isArray(n))
|
|
197
|
+
return;
|
|
198
|
+
r(n, a);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
h(this, "handleRangeTimeValue", (t) => {
|
|
203
|
+
var s;
|
|
204
|
+
const e = { ...t }, r = (s = this.state) == null ? void 0 : s.fieldMappingTime;
|
|
205
|
+
return this.handleMultiFields(e), !r || !Array.isArray(r) || r.forEach(([i, [n, a], l = "YYYY-MM-DD"]) => {
|
|
206
|
+
if (n && a && e[i] === null && (Reflect.deleteProperty(e, n), Reflect.deleteProperty(e, a)), !e[i]) {
|
|
207
|
+
Reflect.deleteProperty(e, i);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const [c, o] = e[i];
|
|
211
|
+
if (l === null)
|
|
212
|
+
e[n] = c, e[a] = o;
|
|
213
|
+
else if (S(l))
|
|
214
|
+
e[n] = l(c, n), e[a] = l(o, a);
|
|
215
|
+
else {
|
|
216
|
+
const [m, d] = Array.isArray(l) ? l : [l, l];
|
|
217
|
+
e[n] = c ? D(c, m) : void 0, e[a] = o ? D(o, d) : void 0;
|
|
218
|
+
}
|
|
219
|
+
Reflect.deleteProperty(e, i);
|
|
220
|
+
}), e;
|
|
221
|
+
});
|
|
222
|
+
h(this, "processFields", (t, e, r, s) => {
|
|
223
|
+
t.forEach((i) => {
|
|
224
|
+
const n = r[i];
|
|
225
|
+
n != null && (r[i] = s(n, e));
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
const { ...e } = t, r = x();
|
|
229
|
+
this.store = new j(
|
|
230
|
+
{
|
|
231
|
+
...r,
|
|
232
|
+
...e
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
onUpdate: () => {
|
|
236
|
+
this.prevState = this.state, this.state = this.store.state, this.updateState();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
), this.state = this.store.state, this.stateHandler = new Y(), z(this);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* 获取字段组件实例
|
|
243
|
+
* @param fieldName 字段名
|
|
244
|
+
* @returns 组件实例
|
|
245
|
+
*/
|
|
246
|
+
getFieldComponentRef(t) {
|
|
247
|
+
var r, s;
|
|
248
|
+
let e = this.componentRefMap.has(t) ? this.componentRefMap.get(t) : void 0;
|
|
249
|
+
return e && e.$.type.name === "AsyncComponentWrapper" && e.$.subTree.ref && (Array.isArray(e.$.subTree.ref) ? e.$.subTree.ref.length > 0 && b((r = e.$.subTree.ref[0]) == null ? void 0 : r.r) && (e = (s = e.$.subTree.ref[0]) == null ? void 0 : s.r.value) : b(e.$.subTree.ref.r) && (e = e.$.subTree.ref.r.value)), e;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* 获取当前聚焦的字段,如果没有聚焦的字段则返回undefined
|
|
253
|
+
*/
|
|
254
|
+
getFocusedField() {
|
|
255
|
+
for (const t of this.componentRefMap.keys()) {
|
|
256
|
+
const e = this.getFieldComponentRef(t);
|
|
257
|
+
if (e) {
|
|
258
|
+
let r = null;
|
|
259
|
+
if (e instanceof HTMLElement ? r = e : e.$el instanceof HTMLElement && (r = e.$el), !r)
|
|
260
|
+
continue;
|
|
261
|
+
if (r === document.activeElement || r.contains(document.activeElement))
|
|
262
|
+
return t;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
getLatestSubmissionValues() {
|
|
267
|
+
return this.latestSubmissionValues || {};
|
|
268
|
+
}
|
|
269
|
+
getState() {
|
|
270
|
+
return this.state;
|
|
271
|
+
}
|
|
272
|
+
async getValues() {
|
|
273
|
+
const t = await this.getForm();
|
|
274
|
+
return t.values ? this.handleRangeTimeValue(t.values) : {};
|
|
275
|
+
}
|
|
276
|
+
async isFieldValid(t) {
|
|
277
|
+
return (await this.getForm()).isFieldValid(t);
|
|
278
|
+
}
|
|
279
|
+
merge(t) {
|
|
280
|
+
const e = [this, t], r = new Proxy(t, {
|
|
281
|
+
get(s, i) {
|
|
282
|
+
return i === "merge" ? (n) => (e.push(n), r) : i === "submitAllForm" ? async (n = !0) => {
|
|
283
|
+
try {
|
|
284
|
+
const a = await Promise.all(
|
|
285
|
+
e.map(async (l) => (await l.validate()).valid ? F(await l.getValues() || {}) : void 0)
|
|
286
|
+
);
|
|
287
|
+
return n ? Object.assign({}, ...a) : a;
|
|
288
|
+
} catch {
|
|
289
|
+
}
|
|
290
|
+
} : s[i];
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
return r;
|
|
294
|
+
}
|
|
295
|
+
mount(t, e) {
|
|
296
|
+
this.isMounted || (Object.assign(this.form, t), this.stateHandler.setConditionTrue(), this.setLatestSubmissionValues({
|
|
297
|
+
...F(this.handleRangeTimeValue(this.form.values))
|
|
298
|
+
}), this.componentRefMap = e, this.isMounted = !0);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @description 为 appendFields 新增的字段写入初始值(与 useFormInitial 规则一致,不覆盖已有数据)
|
|
302
|
+
*/
|
|
303
|
+
async seedDefaultsForAppendedFields(t) {
|
|
304
|
+
var s;
|
|
305
|
+
if (!this.isMounted || !((s = this.form) != null && s.values))
|
|
306
|
+
return;
|
|
307
|
+
const e = this.form.values, r = {};
|
|
308
|
+
for (const i of t) {
|
|
309
|
+
if (!I(i) || !k(e, i))
|
|
310
|
+
continue;
|
|
311
|
+
const n = U(i);
|
|
312
|
+
n !== void 0 && (r[i.fieldName] = n);
|
|
313
|
+
}
|
|
314
|
+
Object.keys(r).length > 0 && await this.setValues(r, !0, !1);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* @description 增量追加字段到 schema 中,支持通过 position 指定插入位置
|
|
318
|
+
* @param {FormSchema[]} fields - 要插入的字段 schema 数组
|
|
319
|
+
* @param {object} [position] - 插入位置,省略则追加到末尾
|
|
320
|
+
* @param {string} [position.before] - 在指定 fieldName 之前插入
|
|
321
|
+
* @param {string} [position.after] - 在指定 fieldName 之后插入
|
|
322
|
+
* @example
|
|
323
|
+
* formApi.appendFields([{ fieldName: 'phone', component: 'ElInput', label: '手机号' }]);
|
|
324
|
+
* @example
|
|
325
|
+
* formApi.appendFields([newField], { after: 'email' });
|
|
326
|
+
* @example
|
|
327
|
+
* formApi.appendFields([newField], { before: 'name' });
|
|
328
|
+
*/
|
|
329
|
+
appendFields(t, e) {
|
|
330
|
+
var i;
|
|
331
|
+
const r = [...((i = this.state) == null ? void 0 : i.schema) ?? []], s = (e == null ? void 0 : e.before) ?? (e == null ? void 0 : e.after);
|
|
332
|
+
if (s) {
|
|
333
|
+
const n = {};
|
|
334
|
+
r.forEach((l, c) => {
|
|
335
|
+
const o = l.fieldName;
|
|
336
|
+
A(n, o, c);
|
|
337
|
+
});
|
|
338
|
+
const a = w(n, s);
|
|
339
|
+
if (typeof a == "number") {
|
|
340
|
+
r.splice(e != null && e.before ? a : a + 1, 0, ...t), this.setState({ schema: r }), this.seedDefaultsForAppendedFields(t);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
r.push(...t), this.setState({ schema: r }), this.seedDefaultsForAppendedFields(t);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* 根据字段名移除表单项
|
|
348
|
+
* @param fields
|
|
349
|
+
*/
|
|
350
|
+
async removeSchemaByFields(t) {
|
|
351
|
+
var i;
|
|
352
|
+
const e = ((i = this.state) == null ? void 0 : i.schema) ?? [], r = {};
|
|
353
|
+
t.forEach((n) => {
|
|
354
|
+
A(r, n, !0);
|
|
355
|
+
});
|
|
356
|
+
const s = e.filter((n) => !w(r, n.fieldName));
|
|
357
|
+
this.setState({
|
|
358
|
+
schema: s
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 重置表单
|
|
363
|
+
*/
|
|
364
|
+
async resetForm(t, e) {
|
|
365
|
+
return (await this.getForm()).resetForm(t, e);
|
|
366
|
+
}
|
|
367
|
+
async resetValidate() {
|
|
368
|
+
const t = await this.getForm();
|
|
369
|
+
Object.keys(t.errors.value).forEach((r) => {
|
|
370
|
+
t.setFieldError(r, void 0);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 滚动到第一个错误字段
|
|
375
|
+
* @param errors 验证错误对象
|
|
376
|
+
*/
|
|
377
|
+
scrollToFirstError(t) {
|
|
378
|
+
const e = typeof t == "string" ? t : Object.keys(t)[0];
|
|
379
|
+
if (!e)
|
|
380
|
+
return;
|
|
381
|
+
let r = document.querySelector(`[name="${e}"]`);
|
|
382
|
+
if (!r) {
|
|
383
|
+
const s = this.getFieldComponentRef(e);
|
|
384
|
+
s && s.$el instanceof HTMLElement && (r = s.$el);
|
|
385
|
+
}
|
|
386
|
+
r && r.scrollIntoView({
|
|
387
|
+
behavior: "smooth",
|
|
388
|
+
block: "center",
|
|
389
|
+
inline: "nearest"
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
async setFieldValue(t, e, r) {
|
|
393
|
+
(await this.getForm()).setFieldValue(t, e, r);
|
|
394
|
+
}
|
|
395
|
+
setLatestSubmissionValues(t) {
|
|
396
|
+
this.latestSubmissionValues = { ...F(t) };
|
|
397
|
+
}
|
|
398
|
+
setState(t) {
|
|
399
|
+
S(t) ? this.store.setState((e) => V(t(e), e)) : this.store.setState((e) => V(t, e));
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* 供子类覆盖:在 `setValues(fields, true)` 时用于白名单过滤的 fieldName 列表(默认取自 store 中的 `schema`)。
|
|
403
|
+
* @returns {string[]} 允许写入的字段名
|
|
404
|
+
*/
|
|
405
|
+
getFieldNamesForSetValuesFilter() {
|
|
406
|
+
var t;
|
|
407
|
+
return (((t = this.state) == null ? void 0 : t.schema) ?? []).map((e) => e.fieldName).filter((e) => typeof e == "string" && e.length > 0);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* 设置表单值
|
|
411
|
+
* @param fields record
|
|
412
|
+
* @param filterFields 为 true 时仅处理当前 schema 中已声明的 fieldName,并保留与现有值的深度合并规则;为 false 时原样交给 vee-validate。
|
|
413
|
+
* 配置了 `fieldMappingTime` 时,会先执行拆解→区间合并,再按本参数过滤:只要**区间主字段**在 schema(与 {@link FormApi.getFieldNamesForSetValuesFilter} 一致)中,合并后的主字段会留在 `mergedInput` 里,**默认 true 即可**。
|
|
414
|
+
* 仅当合并未发生(例如主字段不在 schema、`format` 为函数跳过)且入参里只剩**未在 schema 声明**的拆解键时,才需要传 `false` 才能把拆解字段写入 vee-validate。
|
|
415
|
+
* @param shouldValidate
|
|
416
|
+
*/
|
|
417
|
+
async setValues(t, e = !0, r = !1) {
|
|
418
|
+
const s = await this.getForm(), i = this.mergeRangeTimeFieldsForSetValues(t);
|
|
419
|
+
if (!e) {
|
|
420
|
+
s.setValues(i, r);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const n = this.getFieldNamesForSetValuesFilter(), a = new Set(n), l = { ...s.values };
|
|
424
|
+
for (const d of n)
|
|
425
|
+
T(l, d) || A(l, d, void 0);
|
|
426
|
+
const c = {};
|
|
427
|
+
for (const d of n)
|
|
428
|
+
a.has(d) && T(i, d) && A(c, d, w(i, d));
|
|
429
|
+
const o = B((d, f, p) => (f in d && (d[f] = !Array.isArray(d[f]) && v(d[f]) && !N(d[f]) && !M(d[f]) ? o(p, d[f]) : p), !0)), m = o(c, l);
|
|
430
|
+
s.setValues(m, r);
|
|
431
|
+
}
|
|
432
|
+
async submitForm(t) {
|
|
433
|
+
var s, i;
|
|
434
|
+
t == null || t.preventDefault(), t == null || t.stopPropagation(), await (await this.getForm()).submitForm();
|
|
435
|
+
const r = F(await this.getValues());
|
|
436
|
+
return await ((i = (s = this.state) == null ? void 0 : s.handleSubmit) == null ? void 0 : i.call(s, r)), r;
|
|
437
|
+
}
|
|
438
|
+
unmount() {
|
|
439
|
+
var t, e;
|
|
440
|
+
(e = (t = this.form) == null ? void 0 : t.resetForm) == null || e.call(t), this.latestSubmissionValues = null, this.isMounted = !1, this.stateHandler.reset();
|
|
441
|
+
}
|
|
442
|
+
updateSchema(t) {
|
|
443
|
+
var n;
|
|
444
|
+
const e = [...t];
|
|
445
|
+
if (!e.every((a) => Reflect.has(a, "fieldName") && a.fieldName))
|
|
446
|
+
return;
|
|
447
|
+
const s = [...((n = this.state) == null ? void 0 : n.schema) ?? []], i = {};
|
|
448
|
+
e.forEach((a) => {
|
|
449
|
+
a.fieldName && (i[a.fieldName] = a);
|
|
450
|
+
}), s.forEach((a, l) => {
|
|
451
|
+
const c = i[a.fieldName];
|
|
452
|
+
c && (s[l] = V(c, a));
|
|
453
|
+
}), this.setState({ schema: s });
|
|
454
|
+
}
|
|
455
|
+
async validate(t) {
|
|
456
|
+
var s;
|
|
457
|
+
const r = await (await this.getForm()).validate(t);
|
|
458
|
+
return Object.keys((r == null ? void 0 : r.errors) ?? {}).length > 0 && (s = this.state) != null && s.scrollToFirstError && this.scrollToFirstError(r.errors), r;
|
|
459
|
+
}
|
|
460
|
+
async validateAndSubmitForm() {
|
|
461
|
+
var s;
|
|
462
|
+
const t = await this.getForm(), { valid: e, errors: r } = await t.validate();
|
|
463
|
+
if (!e) {
|
|
464
|
+
(s = this.state) != null && s.scrollToFirstError && this.scrollToFirstError(r);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
return await this.submitForm();
|
|
468
|
+
}
|
|
469
|
+
async validateField(t, e) {
|
|
470
|
+
var i;
|
|
471
|
+
const s = await (await this.getForm()).validateField(t, e);
|
|
472
|
+
return Object.keys((s == null ? void 0 : s.errors) ?? {}).length > 0 && (i = this.state) != null && i.scrollToFirstError && this.scrollToFirstError(t), s;
|
|
473
|
+
}
|
|
474
|
+
async getForm() {
|
|
475
|
+
var t;
|
|
476
|
+
if (this.isMounted || await this.stateHandler.waitForCondition(), !((t = this.form) != null && t.meta))
|
|
477
|
+
throw new Error("<TtForm /> is not mounted");
|
|
478
|
+
return this.form;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* 将拆解字段的空值归一为 undefined,其余原样返回。
|
|
482
|
+
* 回显时不做 dayjs / formatDate 转换:接口返回的值已经是组件可用的格式(字符串、Date、dayjs 等)。
|
|
483
|
+
* @param {unknown} raw 接口或拆解字段的值
|
|
484
|
+
* @returns {unknown} 空值归一为 undefined,其余原样返回
|
|
485
|
+
*/
|
|
486
|
+
normalizeRangeValue(t) {
|
|
487
|
+
if (!(t == null || t === ""))
|
|
488
|
+
return t;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* 判断主字段是否已为「合法」日期区间 [start, end](两项均可解析为有效日期)。合法则不再用拆解字段覆盖。
|
|
492
|
+
* @param {unknown} value 主字段值
|
|
493
|
+
* @returns {boolean} 是否为合法区间
|
|
494
|
+
*/
|
|
495
|
+
isValidRangeTimePair(t) {
|
|
496
|
+
if (!Array.isArray(t) || t.length !== 2)
|
|
497
|
+
return !1;
|
|
498
|
+
const [e, r] = t, s = (i) => {
|
|
499
|
+
var a;
|
|
500
|
+
if (i == null || i === "" || i === 0)
|
|
501
|
+
return !1;
|
|
502
|
+
if (N(i)) {
|
|
503
|
+
const l = i;
|
|
504
|
+
return ((a = l.isValid) == null ? void 0 : a.call(l)) !== !1;
|
|
505
|
+
}
|
|
506
|
+
return M(i) ? !Number.isNaN(i.getTime()) : R(i).isValid();
|
|
507
|
+
};
|
|
508
|
+
return s(e) && s(r);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* 与 {@link FormApi.handleRangeTimeValue} 相反:在 `fieldMappingTime` 配置下,将拆解起止拼成区间字段。
|
|
512
|
+
* - 仅当**区间主字段**在当前 schema({@link FormApi.getFieldNamesForSetValuesFilter})中有定义时处理。
|
|
513
|
+
* - 若主字段**已是合法日期区间**,不合并,保持原有值与行为。
|
|
514
|
+
* - 否则(未赋值、0、空数组、或非合法区间等)在拆解字段有有效数据时合并,并移除拆解键。
|
|
515
|
+
* @param {Record<string, any>} fields 调用方传入的 setValues 数据
|
|
516
|
+
* @returns {Record<string, any>} 合并后的浅拷贝对象
|
|
517
|
+
*/
|
|
518
|
+
mergeRangeTimeFieldsForSetValues(t) {
|
|
519
|
+
var i;
|
|
520
|
+
const e = (i = this.state) == null ? void 0 : i.fieldMappingTime;
|
|
521
|
+
if (!e || !Array.isArray(e) || e.length === 0)
|
|
522
|
+
return t;
|
|
523
|
+
const r = new Set(this.getFieldNamesForSetValuesFilter()), s = { ...t };
|
|
524
|
+
for (const n of e) {
|
|
525
|
+
if (!Array.isArray(n) || n.length < 2)
|
|
526
|
+
continue;
|
|
527
|
+
const a = n[0], l = n[1], c = n[2];
|
|
528
|
+
if (typeof a != "string" || !a || !Array.isArray(l) || l.length < 2)
|
|
529
|
+
continue;
|
|
530
|
+
const [o, m] = l;
|
|
531
|
+
if (typeof o != "string" || typeof m != "string" || !r.has(a) || this.isValidRangeTimePair(s[a]))
|
|
532
|
+
continue;
|
|
533
|
+
const d = Object.prototype.hasOwnProperty.call(s, o), f = Object.prototype.hasOwnProperty.call(s, m);
|
|
534
|
+
if (!d && !f)
|
|
535
|
+
continue;
|
|
536
|
+
const p = s[o], _ = s[m];
|
|
537
|
+
if (!(this.isSplitTimeEmptyValue(p) && this.isSplitTimeEmptyValue(_))) {
|
|
538
|
+
if (c === null)
|
|
539
|
+
s[a] = [p, _];
|
|
540
|
+
else {
|
|
541
|
+
if (S(c))
|
|
542
|
+
continue;
|
|
543
|
+
s[a] = [this.normalizeRangeValue(p), this.normalizeRangeValue(_)];
|
|
544
|
+
}
|
|
545
|
+
Reflect.deleteProperty(s, o), Reflect.deleteProperty(s, m);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return s;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 拆解字段是否为空(与「无有效起止」一致时不参与拼区间)。
|
|
552
|
+
* @param {unknown} value 拆解字段值
|
|
553
|
+
* @returns {boolean} 是否视为空
|
|
554
|
+
*/
|
|
555
|
+
isSplitTimeEmptyValue(t) {
|
|
556
|
+
return t == null || t === "" || t === 0;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* schema 变更后若存在从上一版 schema 中消失的 fieldName,会在 {@link FormApi.updateState} 中调用。
|
|
560
|
+
* 子类(如分组表单)可覆盖以同步清理虚拟校验缓存等。
|
|
561
|
+
* @param {string[]} removedFieldNames 已从 schema 中移除的字段名
|
|
562
|
+
*/
|
|
563
|
+
onRemovedSchemaFields(t) {
|
|
564
|
+
var e, r, s, i, n, a, l, c;
|
|
565
|
+
for (const o of t)
|
|
566
|
+
(r = (e = this.form) == null ? void 0 : e.resetField) == null || r.call(e, o, {
|
|
567
|
+
value: void 0,
|
|
568
|
+
touched: !1,
|
|
569
|
+
errors: []
|
|
570
|
+
}), (i = (s = this.form) == null ? void 0 : s.setFieldValue) == null || i.call(s, o, void 0), (a = (n = this.form) == null ? void 0 : n.setFieldError) == null || a.call(n, o, void 0), (c = (l = this.form) == null ? void 0 : l.setFieldTouched) == null || c.call(l, o, !1);
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* store 更新后对比前后 `schema` 的 fieldName 集合,对已从 schema 中移除的字段清空 vee-validate 值与错误,
|
|
574
|
+
* 避免 `removeFields` / 删项后 `getValues` 仍带出旧字段。
|
|
575
|
+
*/
|
|
576
|
+
updateState() {
|
|
577
|
+
var i, n;
|
|
578
|
+
const t = ((i = this.state) == null ? void 0 : i.schema) ?? [], e = ((n = this.prevState) == null ? void 0 : n.schema) ?? [], r = /* @__PURE__ */ new Set();
|
|
579
|
+
for (const a of t) {
|
|
580
|
+
if (!Reflect.has(a, "fieldName"))
|
|
581
|
+
continue;
|
|
582
|
+
const l = a.fieldName;
|
|
583
|
+
typeof l == "string" && l.length > 0 && r.add(l);
|
|
584
|
+
}
|
|
585
|
+
const s = [];
|
|
586
|
+
for (const a of e) {
|
|
587
|
+
if (!Reflect.has(a, "fieldName"))
|
|
588
|
+
continue;
|
|
589
|
+
const l = a.fieldName;
|
|
590
|
+
typeof l != "string" || !l.length || r.has(l) || s.push(l);
|
|
591
|
+
}
|
|
592
|
+
s.length && this.onRemovedSchemaFields(s);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* @description 注册数组方法
|
|
596
|
+
* @param name 需要注册的数组字段
|
|
597
|
+
* @param actions 操作方法
|
|
598
|
+
*/
|
|
599
|
+
registerArrayField(t, e, r) {
|
|
600
|
+
!t || !e || this._arrayFields.set(g(t), { actions: e, schema: r });
|
|
601
|
+
}
|
|
602
|
+
unregisterArrayField(t, e) {
|
|
603
|
+
var s;
|
|
604
|
+
if (!t) return;
|
|
605
|
+
const r = g(t);
|
|
606
|
+
e && ((s = this._arrayFields.get(r)) == null ? void 0 : s.actions) !== e || this._arrayFields.delete(r);
|
|
607
|
+
}
|
|
608
|
+
/** @description 数组字段操作集合 */
|
|
609
|
+
get arrayAction() {
|
|
610
|
+
return this._arrayAction;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* @description 将业务传入路径规范化为数组注册表键
|
|
614
|
+
*/
|
|
615
|
+
_resolveArrayFieldPath(t) {
|
|
616
|
+
return g(t);
|
|
617
|
+
}
|
|
618
|
+
_getRegisteredArrayFieldItem(t) {
|
|
619
|
+
if (!t)
|
|
620
|
+
return;
|
|
621
|
+
const e = this._resolveArrayFieldPath(t), r = this._arrayFields.get(e);
|
|
622
|
+
if (r)
|
|
623
|
+
return r;
|
|
624
|
+
for (const s of C(t)) {
|
|
625
|
+
const i = this._arrayFields.get(g(s));
|
|
626
|
+
if (i)
|
|
627
|
+
return i;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
_getRegisteredArrayField(t) {
|
|
631
|
+
var e;
|
|
632
|
+
return (e = this._getRegisteredArrayFieldItem(t)) == null ? void 0 : e.actions;
|
|
633
|
+
}
|
|
634
|
+
_getArrayFieldActions(t) {
|
|
635
|
+
const e = this._getRegisteredArrayField(t);
|
|
636
|
+
return e ? H(e) : void 0;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* @description 获取数组字段 schema
|
|
640
|
+
*/
|
|
641
|
+
_getArrayFieldSchema(t) {
|
|
642
|
+
var i, n;
|
|
643
|
+
const e = (i = this._getRegisteredArrayFieldItem(t)) == null ? void 0 : i.schema;
|
|
644
|
+
if (e)
|
|
645
|
+
return e;
|
|
646
|
+
const r = this._resolveArrayFieldPath(t);
|
|
647
|
+
return (((n = this.state) == null ? void 0 : n.schema) ?? []).find(
|
|
648
|
+
(a) => I(a) && a.useArraySchema === !0 && !!a.fieldName && g(a.fieldName) === r
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* @description 解析数组新增项默认值
|
|
653
|
+
*/
|
|
654
|
+
_resolveArrayDefaultItemValue(t) {
|
|
655
|
+
return this._resolveArrayDefaultItemValueByMutation(t);
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* @description 按新增操作场景解析数组新增项默认值
|
|
659
|
+
*/
|
|
660
|
+
_resolveArrayDefaultItemValueByMutation(t, e, r) {
|
|
661
|
+
const s = this._getArrayFieldSchema(t);
|
|
662
|
+
if (!s)
|
|
663
|
+
return;
|
|
664
|
+
const i = this._resolveArrayFieldPath(t), n = this._getArrayFieldActions(t), a = (n == null ? void 0 : n.fields.length) ?? 0, l = (r == null ? void 0 : r.index) ?? a, c = (r == null ? void 0 : r.arrayLength) ?? a + 1, o = W(s, {
|
|
665
|
+
arrayPath: i,
|
|
666
|
+
parentItemPath: q(i),
|
|
667
|
+
form: this.form.values,
|
|
668
|
+
arrayAction: this.arrayAction,
|
|
669
|
+
row: v(e) ? e : void 0,
|
|
670
|
+
index: l,
|
|
671
|
+
arrayLength: c
|
|
672
|
+
});
|
|
673
|
+
return Array.isArray(o) ? E(o[0]) : E(o);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* @description 合并数组新增项值,优先使用 schema 默认值补齐
|
|
677
|
+
*/
|
|
678
|
+
_resolveArrayItemValue(t, e, r) {
|
|
679
|
+
const s = this._resolveArrayDefaultItemValueByMutation(t, e, r);
|
|
680
|
+
return s === void 0 ? e : e === void 0 || v(s) && v(e) ? s : e;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* @description 开发环境:数组字段未注册时输出告警与相近路径提示
|
|
684
|
+
*/
|
|
685
|
+
_warnUnregisteredArrayField(t, e) {
|
|
686
|
+
const r = this._resolveArrayFieldPath(e), s = [...this._arrayFields.keys()], i = r.split(/[[.]/)[0] ?? "";
|
|
687
|
+
s.filter((n) => i ? n.includes(i) : !0).slice(0, 8);
|
|
688
|
+
}
|
|
689
|
+
_mutateArrayField(t, e, r) {
|
|
690
|
+
const s = this._getRegisteredArrayField(e);
|
|
691
|
+
if (!s) {
|
|
692
|
+
this._warnUnregisteredArrayField(t, e);
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
r(s);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* @description 创建嵌套数组操作器(在原 inline 实现基础上支持链式 `.at`)
|
|
699
|
+
*/
|
|
700
|
+
_createNestedArrayHandle(t) {
|
|
701
|
+
const e = this._resolveArrayFieldPath(t);
|
|
702
|
+
return {
|
|
703
|
+
path: e,
|
|
704
|
+
get: () => {
|
|
705
|
+
const r = this._getArrayFieldActions(e);
|
|
706
|
+
if (!r) {
|
|
707
|
+
this._warnUnregisteredArrayField("get", e);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
return r;
|
|
711
|
+
},
|
|
712
|
+
push: (r) => this._mutateArrayField(
|
|
713
|
+
"push",
|
|
714
|
+
e,
|
|
715
|
+
(s) => s.push(
|
|
716
|
+
this._resolveArrayItemValue(e, r, {
|
|
717
|
+
index: y(s.fields).length,
|
|
718
|
+
arrayLength: y(s.fields).length + 1
|
|
719
|
+
})
|
|
720
|
+
)
|
|
721
|
+
),
|
|
722
|
+
remove: (r) => this._mutateArrayField("remove", e, (s) => s.remove(r)),
|
|
723
|
+
replace: (r) => this._mutateArrayField("replace", e, (s) => s.replace(r)),
|
|
724
|
+
update: (r, s) => this._mutateArrayField("update", e, (i) => i.update(r, s)),
|
|
725
|
+
insert: (r, s) => this._mutateArrayField(
|
|
726
|
+
"insert",
|
|
727
|
+
e,
|
|
728
|
+
(i) => i.insert(
|
|
729
|
+
r,
|
|
730
|
+
this._resolveArrayItemValue(e, s, {
|
|
731
|
+
index: r,
|
|
732
|
+
arrayLength: y(i.fields).length + 1
|
|
733
|
+
})
|
|
734
|
+
)
|
|
735
|
+
),
|
|
736
|
+
prepend: (r) => this._mutateArrayField(
|
|
737
|
+
"prepend",
|
|
738
|
+
e,
|
|
739
|
+
(s) => s.prepend(
|
|
740
|
+
this._resolveArrayItemValue(e, r, {
|
|
741
|
+
index: 0,
|
|
742
|
+
arrayLength: y(s.fields).length + 1
|
|
743
|
+
})
|
|
744
|
+
)
|
|
745
|
+
),
|
|
746
|
+
move: (r, s) => this._mutateArrayField("move", e, (i) => i.move(r, s)),
|
|
747
|
+
swap: (r, s) => this._mutateArrayField("swap", e, (i) => i.swap(r, s)),
|
|
748
|
+
at: (r, s) => this._createNestedArrayHandle(P(e, r, s))
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* @description 包装嵌套操作器,变更后执行回调(供 GroupFormApi 同步导航错误)
|
|
753
|
+
*/
|
|
754
|
+
_wrapNestedArrayHandle(t, e) {
|
|
755
|
+
return {
|
|
756
|
+
path: t.path,
|
|
757
|
+
get: t.get,
|
|
758
|
+
at: (r, s) => this._wrapNestedArrayHandle(t.at(r, s), e),
|
|
759
|
+
push: (r) => {
|
|
760
|
+
t.push(r), e();
|
|
761
|
+
},
|
|
762
|
+
remove: (r) => {
|
|
763
|
+
t.remove(r), e();
|
|
764
|
+
},
|
|
765
|
+
replace: (r) => {
|
|
766
|
+
t.replace(r), e();
|
|
767
|
+
},
|
|
768
|
+
update: (r, s) => {
|
|
769
|
+
t.update(r, s), e();
|
|
770
|
+
},
|
|
771
|
+
insert: (r, s) => {
|
|
772
|
+
t.insert(r, s), e();
|
|
773
|
+
},
|
|
774
|
+
prepend: (r) => {
|
|
775
|
+
t.prepend(r), e();
|
|
776
|
+
},
|
|
777
|
+
move: (r, s) => {
|
|
778
|
+
t.move(r, s), e();
|
|
779
|
+
},
|
|
780
|
+
swap: (r, s) => {
|
|
781
|
+
t.swap(r, s), e();
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
export {
|
|
787
|
+
ie as FormApi,
|
|
788
|
+
C as collectArrayFieldPathAliases,
|
|
789
|
+
g as normalizeArrayFieldPath
|
|
790
|
+
};
|