@veltra/desktop 1.2.8 → 1.2.10
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/components/action/action-group.vue.d.ts +1 -1
- package/dist/components/auto-complete/auto-complete.vue.d.ts +2 -2
- package/dist/components/batch-edit/batch-edit-form.js +40 -74
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/batch-edit-list.js +17 -29
- package/dist/components/batch-edit/batch-edit-list.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.js +37 -60
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.vue.d.ts +3 -14
- package/dist/components/batch-edit/di.js.map +1 -1
- package/dist/components/batch-edit/form-action-header.js +25 -0
- package/dist/components/batch-edit/form-action-header.js.map +1 -0
- package/dist/components/batch-edit/style2.css +0 -13
- package/dist/components/batch-edit/use-edit-state.js +44 -0
- package/dist/components/batch-edit/use-edit-state.js.map +1 -0
- package/dist/components/batch-edit/use-handlers.js +146 -0
- package/dist/components/batch-edit/use-handlers.js.map +1 -0
- package/dist/components/batch-edit/use-shortcut-key.js +44 -0
- package/dist/components/batch-edit/use-shortcut-key.js.map +1 -0
- package/dist/components/cascade/cascade.vue.d.ts +2 -2
- package/dist/components/date-picker/date-picker.vue.d.ts +2 -2
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +2 -2
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/form/form.vue.d.ts +5 -1
- package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js +8 -2
- package/dist/components/form/form.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/form-item/form-item.js.map +1 -1
- package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/multi-select/multi-select.vue.d.ts +2 -2
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +3 -3
- package/dist/components/number-input/number-input.vue.d.ts +2 -2
- package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
- package/dist/components/password-input/password-input.vue.d.ts +1 -1
- package/dist/components/progress-nodes/progress-nodes.vue.d.ts +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
- package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
- package/dist/components/tabs/tabs.vue.d.ts +2 -2
- package/dist/components/textarea/textarea.vue.d.ts +2 -2
- package/dist/components/tree/tree.vue.d.ts +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +3 -3
- package/dist/components/watermark/watermark.vue.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/types/batch-edit.d.ts +38 -12
- package/dist/types/form.d.ts +4 -1
- package/dist/types/index.d.ts +3 -3
- package/package.json +6 -6
- package/src/components/batch-edit/batch-edit-form.vue +39 -79
- package/src/components/batch-edit/batch-edit-list.vue +13 -29
- package/src/components/batch-edit/batch-edit.vue +27 -92
- package/src/components/batch-edit/di.ts +6 -5
- package/src/components/batch-edit/form-action-header.ts +21 -0
- package/src/components/batch-edit/style.scss +0 -14
- package/src/components/batch-edit/use-dialog-effect.ts +21 -0
- package/src/components/batch-edit/use-edit-state.ts +61 -0
- package/src/components/batch-edit/use-handlers.ts +226 -0
- package/src/components/batch-edit/use-shortcut-key.ts +58 -0
- package/src/components/form/form.vue +10 -3
- package/src/components/form-item/form-item.vue +4 -2
- package/src/types/batch-edit.ts +43 -22
- package/src/types/form.ts +4 -0
- package/dist/components/batch-edit/use-edit.js +0 -231
- package/dist/components/batch-edit/use-edit.js.map +0 -1
- package/src/components/batch-edit/use-edit.ts +0 -365
|
@@ -7,9 +7,9 @@ type __VLS_Slots = {
|
|
|
7
7
|
};
|
|
8
8
|
declare const __VLS_base: import("vue").DefineComponent<ActionGroupProps, _ActionGroupExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ActionGroupProps> & Readonly<{}>, {
|
|
9
9
|
type: import("@veltra/utils").ColorType;
|
|
10
|
-
max: number;
|
|
11
10
|
size: "small" | "default" | "large";
|
|
12
11
|
text: boolean;
|
|
12
|
+
max: number;
|
|
13
13
|
circle: boolean;
|
|
14
14
|
loading: boolean;
|
|
15
15
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -22,10 +22,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, _Auto
|
|
|
22
22
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
23
23
|
onSelect?: ((value: string) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
-
placeholder: string;
|
|
26
|
-
clearable: boolean;
|
|
27
25
|
disabled: boolean;
|
|
28
26
|
readonly: boolean;
|
|
27
|
+
placeholder: string;
|
|
28
|
+
clearable: boolean;
|
|
29
29
|
allowCustom: boolean;
|
|
30
30
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
31
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -4,16 +4,18 @@ import form_default from "../form/form.js";
|
|
|
4
4
|
import _sfc_main$3 from "../button/button.js";
|
|
5
5
|
import _sfc_main$4 from "../kbd/kbd.js";
|
|
6
6
|
import { BatchEditDIKey } from "./di.js";
|
|
7
|
-
import {
|
|
7
|
+
import { FORM_ACTION_HEADER_MAP } from "./form-action-header.js";
|
|
8
|
+
import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, normalizeClass, normalizeProps, openBlock, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toRef, unref, withCtx } from "vue";
|
|
8
9
|
import { bem } from "@veltra/utils";
|
|
9
|
-
import {
|
|
10
|
+
import { Close } from "@veltra/icons/normal";
|
|
11
|
+
import { o } from "@cat-kit/core";
|
|
10
12
|
//#region src/components/batch-edit/batch-edit-form.vue
|
|
11
13
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
12
14
|
name: "BatchEditForm",
|
|
13
15
|
__name: "batch-edit-form",
|
|
14
16
|
setup(__props, { expose: __expose }) {
|
|
15
17
|
const batchEditCtx = inject(BatchEditDIKey);
|
|
16
|
-
const { cls, props, state,
|
|
18
|
+
const { cls, props, state, handleClose, handleSave, staticFeatures, dynamicFeatures } = batchEditCtx;
|
|
17
19
|
const focused = toRef(batchEditCtx, "focused");
|
|
18
20
|
const formComponentRef = shallowRef();
|
|
19
21
|
__expose({
|
|
@@ -22,58 +24,42 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
22
24
|
clearValidate: () => formComponentRef.value?.clearValidate(),
|
|
23
25
|
reset: () => formComponentRef.value?.reset()
|
|
24
26
|
});
|
|
27
|
+
function handleFieldChange(field, value) {
|
|
28
|
+
if (state.row && props.quickEdit) o(state.row.data).set(field, value);
|
|
29
|
+
}
|
|
25
30
|
const creatable = computed(() => {
|
|
26
|
-
|
|
31
|
+
if (state.formActionType !== "create") return false;
|
|
32
|
+
return staticFeatures.value.has("create") || dynamicFeatures.value.create?.(state.row);
|
|
33
|
+
});
|
|
34
|
+
const creatableChild = computed(() => {
|
|
35
|
+
if (state.formActionType !== "createChild") return false;
|
|
36
|
+
return staticFeatures.value.has("createChild") || dynamicFeatures.value.createChild?.(state.row);
|
|
27
37
|
});
|
|
28
38
|
const updatable = computed(() => {
|
|
29
|
-
|
|
39
|
+
if (state.formActionType !== "update") return false;
|
|
40
|
+
return staticFeatures.value.has("update") || dynamicFeatures.value.update?.(state.row);
|
|
30
41
|
});
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (props.readonly) return {
|
|
36
|
-
icon: View,
|
|
37
|
-
title: "查看详情",
|
|
38
|
-
chip: state.row ? `第 ${state.row.index + 1} 行` : void 0,
|
|
39
|
-
tone: "view"
|
|
40
|
-
};
|
|
41
|
-
if (state.parentRow) return {
|
|
42
|
-
icon: AddChild,
|
|
43
|
-
title: "新增子级",
|
|
44
|
-
chip: `归属于第 ${state.parentRow.index + 1} 行`,
|
|
45
|
-
tone: "child"
|
|
46
|
-
};
|
|
47
|
-
if (state.type === "create") return {
|
|
48
|
-
icon: Plus,
|
|
49
|
-
title: "新增",
|
|
50
|
-
tone: "create"
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
icon: EditPen,
|
|
54
|
-
title: "编辑",
|
|
55
|
-
chip: state.row ? `第 ${state.row.index + 1} 行` : void 0,
|
|
56
|
-
tone: "update"
|
|
57
|
-
};
|
|
42
|
+
const showSaveBtn = computed(() => {
|
|
43
|
+
if (props.readonly) return false;
|
|
44
|
+
if (props.quickEdit && state.formActionType === "update") return false;
|
|
45
|
+
return creatable.value || updatable.value || creatableChild.value;
|
|
58
46
|
});
|
|
47
|
+
const headerInfo = computed(() => FORM_ACTION_HEADER_MAP[state.formActionType]);
|
|
59
48
|
/** 通过 row 切换 / 类型切换驱动表单内容淡出淡入 */
|
|
60
49
|
const bodyKey = computed(() => {
|
|
61
|
-
return `${state.
|
|
50
|
+
return `${state.formActionType}-${state.row?.uid ?? "create"}-${state.parentRow?.uid ?? "root"}`;
|
|
62
51
|
});
|
|
63
52
|
return (_ctx, _cache) => {
|
|
64
|
-
return unref(state).
|
|
53
|
+
return unref(state).formVisible && !!unref(props).model ? (openBlock(), createElementBlock("aside", {
|
|
65
54
|
key: 0,
|
|
66
55
|
class: normalizeClass(unref(cls).e("form"))
|
|
67
56
|
}, [
|
|
68
57
|
createElementVNode("header", { class: normalizeClass(unref(cls).e("form-header")) }, [
|
|
69
|
-
createElementVNode("span", { class: normalizeClass([unref(cls).e("form-icon"), unref(bem).is(
|
|
58
|
+
createElementVNode("span", { class: normalizeClass([unref(cls).e("form-icon"), unref(bem).is(unref(state).formActionType)]) }, [createVNode(unref(_sfc_main$1), null, {
|
|
70
59
|
default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(headerInfo.value.icon)))]),
|
|
71
60
|
_: 1
|
|
72
61
|
})], 2),
|
|
73
|
-
createElementVNode("div", { class: normalizeClass(unref(cls).e("form-title")) }, [createElementVNode("h3", { class: normalizeClass(unref(cls).e("form-title-text")) }, toDisplayString(headerInfo.value.title), 3),
|
|
74
|
-
key: 0,
|
|
75
|
-
class: normalizeClass(unref(cls).e("form-chip"))
|
|
76
|
-
}, toDisplayString(headerInfo.value.chip), 3)) : createCommentVNode("v-if", true)], 2),
|
|
62
|
+
createElementVNode("div", { class: normalizeClass(unref(cls).e("form-title")) }, [createElementVNode("h3", { class: normalizeClass(unref(cls).e("form-title-text")) }, toDisplayString(headerInfo.value.title), 3)], 2),
|
|
77
63
|
createVNode(unref(_sfc_main$3), {
|
|
78
64
|
class: normalizeClass(unref(cls).e("form-close")),
|
|
79
65
|
icon: unref(Close),
|
|
@@ -103,12 +89,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
103
89
|
ref: formComponentRef,
|
|
104
90
|
model: unref(props).model,
|
|
105
91
|
readonly: unref(props).readonly,
|
|
106
|
-
"label-width": unref(props).labelWidth
|
|
92
|
+
"label-width": unref(props).labelWidth,
|
|
93
|
+
"onField:change": handleFieldChange
|
|
107
94
|
}, {
|
|
108
95
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
|
|
109
96
|
row: unref(state).row,
|
|
110
97
|
depth: unref(state).depth,
|
|
111
|
-
indexes: unref(
|
|
98
|
+
indexes: unref(state).indexPath,
|
|
112
99
|
index: unref(state).row?.index
|
|
113
100
|
})))]),
|
|
114
101
|
_: 3
|
|
@@ -121,53 +108,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
121
108
|
})]),
|
|
122
109
|
_: 3
|
|
123
110
|
}, 8, ["class"])),
|
|
124
|
-
createElementVNode("footer", { class: normalizeClass(unref(cls).e("form-footer")) }, [unref(props).readonly ? (openBlock(), createElementBlock("span", {
|
|
125
|
-
key: 0,
|
|
126
|
-
|
|
127
|
-
}, "只读模式", 2)) : isQuickUpdate.value ? (openBlock(), createElementBlock("span", {
|
|
128
|
-
key: 1,
|
|
129
|
-
class: normalizeClass(unref(cls).e("form-hint"))
|
|
130
|
-
}, [_cache[3] || (_cache[3] = createTextVNode(" 实时编辑 ", -1)), createElementVNode("span", { class: normalizeClass({ [unref(bem).is("concealed")]: !focused.value }) }, [
|
|
131
|
-
_cache[1] || (_cache[1] = createTextVNode(" · ", -1)),
|
|
132
|
-
createVNode(unref(_sfc_main$4), null, {
|
|
133
|
-
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Esc", -1)])]),
|
|
111
|
+
createElementVNode("footer", { class: normalizeClass(unref(cls).e("form-footer")) }, [createElementVNode("span", { class: normalizeClass(unref(cls).e("form-hint")) }, [unref(props).readonly ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createTextVNode(" 只读模式 ")], 64)) : createCommentVNode("v-if", true), createElementVNode("span", { class: normalizeClass({ [unref(bem).is("concealed")]: !focused.value }) }, [
|
|
112
|
+
!(unref(state).formActionType === "update" && unref(props).quickEdit) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode(unref(_sfc_main$4), null, {
|
|
113
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Ctrl + S", -1)])]),
|
|
134
114
|
_: 1
|
|
135
|
-
}),
|
|
136
|
-
_cache[2] || (_cache[2] = createTextVNode(" 关闭", -1))
|
|
137
|
-
], 2)], 2)) : (openBlock(), createElementBlock("span", {
|
|
138
|
-
key: 2,
|
|
139
|
-
class: normalizeClass(unref(cls).e("form-hint"))
|
|
140
|
-
}, [createElementVNode("span", { class: normalizeClass({ [unref(bem).is("concealed")]: !focused.value }) }, [
|
|
141
|
-
createVNode(unref(_sfc_main$4), null, {
|
|
142
|
-
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("Ctrl + S", -1)])]),
|
|
143
|
-
_: 1
|
|
144
|
-
}),
|
|
145
|
-
_cache[6] || (_cache[6] = createTextVNode(" 保存 · ", -1)),
|
|
115
|
+
}), _cache[1] || (_cache[1] = createTextVNode(" 保存 · ", -1))], 64)) : createCommentVNode("v-if", true),
|
|
146
116
|
createVNode(unref(_sfc_main$4), null, {
|
|
147
|
-
default: withCtx(() => [..._cache[
|
|
117
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("Esc", -1)])]),
|
|
148
118
|
_: 1
|
|
149
119
|
}),
|
|
150
|
-
_cache[
|
|
151
|
-
], 2)], 2)
|
|
120
|
+
_cache[3] || (_cache[3] = createTextVNode(" 关闭 ", -1))
|
|
121
|
+
], 2)], 2), createElementVNode("div", { class: normalizeClass(unref(cls).e("form-actions")) }, [createVNode(unref(_sfc_main$3), {
|
|
152
122
|
text: "",
|
|
153
123
|
loading: unref(state).loading,
|
|
154
124
|
onClick: unref(handleClose)
|
|
155
125
|
}, {
|
|
156
|
-
default: withCtx(() => [..._cache[
|
|
126
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode(" 取消 ", -1)])]),
|
|
157
127
|
_: 1
|
|
158
|
-
}, 8, ["loading", "onClick"]),
|
|
128
|
+
}, 8, ["loading", "onClick"]), showSaveBtn.value ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
159
129
|
key: 0,
|
|
160
|
-
type:
|
|
130
|
+
type: "primary",
|
|
161
131
|
loading: unref(state).loading,
|
|
162
132
|
onClick: unref(handleSave)
|
|
163
133
|
}, {
|
|
164
|
-
default: withCtx(() => [..._cache[
|
|
134
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode(" 保存 ", -1)])]),
|
|
165
135
|
_: 1
|
|
166
|
-
}, 8, [
|
|
167
|
-
"type",
|
|
168
|
-
"loading",
|
|
169
|
-
"onClick"
|
|
170
|
-
])) : createCommentVNode("v-if", true)], 2)], 2)
|
|
136
|
+
}, 8, ["loading", "onClick"])) : createCommentVNode("v-if", true)], 2)], 2)
|
|
171
137
|
], 2)) : createCommentVNode("v-if", true);
|
|
172
138
|
};
|
|
173
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-edit-form.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-form.vue"],"sourcesContent":["<template>\n <aside :class=\"cls.e('form')\" v-if=\"state.
|
|
1
|
+
{"version":3,"file":"batch-edit-form.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-form.vue"],"sourcesContent":["<template>\n <aside :class=\"cls.e('form')\" v-if=\"state.formVisible && !!props.model\">\n <header :class=\"cls.e('form-header')\">\n <span :class=\"[cls.e('form-icon'), bem.is(state.formActionType)]\">\n <u-icon>\n <component :is=\"headerInfo.icon\" />\n </u-icon>\n </span>\n <div :class=\"cls.e('form-title')\">\n <h3 :class=\"cls.e('form-title-text')\">{{ headerInfo.title }}</h3>\n </div>\n <u-button\n :class=\"cls.e('form-close')\"\n :icon=\"Close\"\n text\n circle\n size=\"small\"\n title=\"关闭\"\n @click=\"handleClose\"\n />\n </header>\n\n <u-scroll always :class=\"cls.e('form-body')\" :key=\"bodyKey\">\n <transition name=\"fade\" appear mode=\"out-in\">\n <u-form\n ref=\"formComponentRef\"\n :model=\"props.model\"\n :readonly=\"props.readonly\"\n :label-width=\"props.labelWidth\"\n @field:change=\"handleFieldChange\"\n >\n <slot\n v-bind=\"{\n row: state.row,\n depth: state.depth,\n indexes: state.indexPath,\n index: state.row?.index\n }\"\n />\n </u-form>\n </transition>\n </u-scroll>\n\n <footer :class=\"cls.e('form-footer')\">\n <span :class=\"cls.e('form-hint')\">\n <template v-if=\"props.readonly\"> 只读模式 </template>\n\n <span :class=\"{ [bem.is('concealed')]: !focused }\">\n <template v-if=\"!(state.formActionType === 'update' && props.quickEdit)\">\n <u-kbd>Ctrl + S</u-kbd> 保存 ·\n </template>\n <u-kbd>Esc</u-kbd> 关闭\n </span>\n </span>\n\n <div :class=\"cls.e('form-actions')\">\n <u-button text :loading=\"state.loading\" @click=\"handleClose\"> 取消 </u-button>\n <u-button v-if=\"showSaveBtn\" type=\"primary\" :loading=\"state.loading\" @click=\"handleSave\">\n 保存\n </u-button>\n </div>\n </footer>\n </aside>\n</template>\n\n<script lang=\"ts\" setup>\nimport { o } from '@cat-kit/core'\nimport { Close } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, inject, shallowRef, toRef } from 'vue'\n\nimport type { _FormExposed, FormExposed } from '../../types/form'\nimport { UButton } from '../button'\nimport { UForm } from '../form'\nimport { UIcon } from '../icon'\nimport { UKbd } from '../kbd'\nimport { UScroll } from '../scroll'\nimport { BatchEditDIKey } from './di'\nimport { FORM_ACTION_HEADER_MAP } from './form-action-header'\n\ndefineOptions({ name: 'BatchEditForm' })\n\nconst batchEditCtx = inject(BatchEditDIKey)!\n\nconst { cls, props, state, handleClose, handleSave, staticFeatures, dynamicFeatures } = batchEditCtx\n\nconst focused = toRef(batchEditCtx, 'focused')\n\nconst formComponentRef = shallowRef<FormExposed>()\n\ndefineExpose<_FormExposed>({\n el: toRef(() => formComponentRef.value?.el),\n validate: () => formComponentRef.value?.validate() ?? Promise.resolve(true),\n clearValidate: () => formComponentRef.value?.clearValidate(),\n reset: () => formComponentRef.value?.reset()\n})\n\nfunction handleFieldChange(field: string, value: any) {\n if (state.row && props.quickEdit) {\n o(state.row.data).set(field, value)\n }\n}\n\nconst creatable = computed(() => {\n if (state.formActionType !== 'create') return false\n return staticFeatures.value.has('create') || dynamicFeatures.value.create?.(state.row)\n})\n\nconst creatableChild = computed(() => {\n if (state.formActionType !== 'createChild') return false\n return staticFeatures.value.has('createChild') || dynamicFeatures.value.createChild?.(state.row)\n})\n\nconst updatable = computed(() => {\n if (state.formActionType !== 'update') return false\n return staticFeatures.value.has('update') || dynamicFeatures.value.update?.(state.row)\n})\n\nconst showSaveBtn = computed(() => {\n if (props.readonly) return false\n if (props.quickEdit && state.formActionType === 'update') return false\n return creatable.value || updatable.value || creatableChild.value\n})\n\nconst headerInfo = computed(() => FORM_ACTION_HEADER_MAP[state.formActionType])\n\n/** 通过 row 切换 / 类型切换驱动表单内容淡出淡入 */\nconst bodyKey = computed(() => {\n return `${state.formActionType}-${state.row?.uid ?? 'create'}-${state.parentRow?.uid ?? 'root'}`\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;EAkFA,MAAM,eAAe,OAAO,cAAc;EAE1C,MAAM,EAAE,KAAK,OAAO,OAAO,aAAa,YAAY,gBAAgB,oBAAoB;EAExF,MAAM,UAAU,MAAM,cAAc,SAAS;EAE7C,MAAM,mBAAmB,WAAwB;EAEjD,SAA2B;GACzB,IAAI,YAAY,iBAAiB,OAAO,EAAE;GAC1C,gBAAgB,iBAAiB,OAAO,SAAS,KAAK,QAAQ,QAAQ,IAAI;GAC1E,qBAAqB,iBAAiB,OAAO,cAAc;GAC3D,aAAa,iBAAiB,OAAO,MAAM;EAC7C,CAAC;EAED,SAAS,kBAAkB,OAAe,OAAY;GACpD,IAAI,MAAM,OAAO,MAAM,WACrB,EAAE,MAAM,IAAI,IAAI,EAAE,IAAI,OAAO,KAAK;EAEtC;EAEA,MAAM,YAAY,eAAe;GAC/B,IAAI,MAAM,mBAAmB,UAAU,OAAO;GAC9C,OAAO,eAAe,MAAM,IAAI,QAAQ,KAAK,gBAAgB,MAAM,SAAS,MAAM,GAAG;EACvF,CAAC;EAED,MAAM,iBAAiB,eAAe;GACpC,IAAI,MAAM,mBAAmB,eAAe,OAAO;GACnD,OAAO,eAAe,MAAM,IAAI,aAAa,KAAK,gBAAgB,MAAM,cAAc,MAAM,GAAG;EACjG,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,IAAI,MAAM,mBAAmB,UAAU,OAAO;GAC9C,OAAO,eAAe,MAAM,IAAI,QAAQ,KAAK,gBAAg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Q,EAAA,CAAA,EAAA,CAAA;;mDAAQ,UACzB,EAAA,EAAA,GAAA,EAAA,KAAA,mBAAA,QAAA,IAAA;KACA,YAAkB,MAAA,WAAA,GAAA,MAAA;6BAAR,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAH,OAAG,EAAA,CAAA,EAAA,CAAA;;;+CAAQ,QACpB,EAAA;gBAGF,mBAKM,OAAA,EALA,OAAK,eAAE,MAAA,GAAA,EAAI,EAAC,cAAA,CAAA,EAAA,GAAA,CAChB,YAA4E,MAAA,WAAA,GAAA;KAAlE,MAAA;KAAM,SAAS,MAAA,KAAA,EAAM;KAAU,SAAO,MAAA,WAAA;;4BAAiB,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAJ,QAAI,EAAA,CAAA,EAAA,CAAA;;mCACjD,YAAA,SAAA,UAAA,GAAhB,YAEW,MAAA,WAAA,GAAA;;KAFkB,MAAK;KAAW,SAAS,MAAA,KAAA,EAAM;KAAU,SAAO,MAAA,UAAA;;4BAE7E,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFyF,QAEzF,EAAA,CAAA,EAAA,CAAA"}
|
|
@@ -3,9 +3,8 @@ import _sfc_main$2 from "../table/table.js";
|
|
|
3
3
|
import { BatchEditDIKey } from "./di.js";
|
|
4
4
|
import _sfc_main$3 from "../action/action.js";
|
|
5
5
|
import action_group_default from "../action/action-group.js";
|
|
6
|
-
import { computed, createBlock, createCommentVNode, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, openBlock,
|
|
7
|
-
import {
|
|
8
|
-
import { AddChild, Copy, Delete, InsertToNext, InsertToPrev, Plus } from "@veltra/icons/normal";
|
|
6
|
+
import { computed, createBlock, createCommentVNode, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeProps, normalizeClass, openBlock, unref, withCtx, withModifiers } from "vue";
|
|
7
|
+
import { AddChild, Delete, InsertToNext, InsertToPrev, Plus } from "@veltra/icons/normal";
|
|
9
8
|
import { o } from "@cat-kit/core";
|
|
10
9
|
//#region src/components/batch-edit/batch-edit-list.vue
|
|
11
10
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -13,7 +12,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
13
12
|
__name: "batch-edit-list",
|
|
14
13
|
props: { slots: {} },
|
|
15
14
|
setup(__props) {
|
|
16
|
-
const { cls, state,
|
|
15
|
+
const { cls, state, props, emit, staticFeatures, dynamicFeatures, handleCreate, handleDelete, handleInsertToNext, handleInsertToPrev, handleInsertChild } = inject(BatchEditDIKey);
|
|
17
16
|
const tableProps = computed(() => {
|
|
18
17
|
return o(props).omit([
|
|
19
18
|
"model",
|
|
@@ -36,8 +35,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
36
35
|
"create",
|
|
37
36
|
"delete",
|
|
38
37
|
"createChild",
|
|
39
|
-
"update"
|
|
40
|
-
"copy"
|
|
38
|
+
"update"
|
|
41
39
|
])) return props.columns;
|
|
42
40
|
return (props.columns ?? []).concat({
|
|
43
41
|
name: "操作",
|
|
@@ -49,27 +47,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
49
47
|
});
|
|
50
48
|
});
|
|
51
49
|
function handleUpdateCurrentRow(row) {
|
|
52
|
-
if (allowed("update", row))
|
|
53
|
-
if (row) state.type = "update";
|
|
54
|
-
state.row = row;
|
|
55
|
-
state.depth = row?.depth;
|
|
56
|
-
}
|
|
50
|
+
if (allowed("update", row)) state.row = row;
|
|
57
51
|
}
|
|
58
52
|
function canDelete(row) {
|
|
59
53
|
return !props.readonly && allowed("delete", row);
|
|
60
54
|
}
|
|
55
|
+
const showCreateBtn = computed(() => {
|
|
56
|
+
if (props.readonly) return false;
|
|
57
|
+
const hasFeature = staticFeatures.value.has("create") || dynamicFeatures.value.create?.();
|
|
58
|
+
const createActionVisible = state.formActionType === "create" && state.formVisible;
|
|
59
|
+
return hasFeature && !createActionVisible;
|
|
60
|
+
});
|
|
61
61
|
return (_ctx, _cache) => {
|
|
62
62
|
return openBlock(), createBlock(unref(_sfc_main$2), mergeProps(tableProps.value, {
|
|
63
63
|
slots: __props.slots,
|
|
64
|
-
class: [unref(cls).e("table")
|
|
64
|
+
class: [unref(cls).e("table")],
|
|
65
65
|
columns: columns.value,
|
|
66
66
|
"highlight-current": "",
|
|
67
67
|
current: unref(state).row,
|
|
68
68
|
"onUpdate:current": handleUpdateCurrentRow,
|
|
69
69
|
"onUpdate:checked": _cache[1] || (_cache[1] = ($event) => unref(emit)("update:checked", $event)),
|
|
70
|
-
"onUpdate:selected": _cache[2] || (_cache[2] = ($event) => unref(emit)("update:selected", $event))
|
|
71
|
-
ref_key: "tableRef",
|
|
72
|
-
ref: tableRef
|
|
70
|
+
"onUpdate:selected": _cache[2] || (_cache[2] = ($event) => unref(emit)("update:selected", $event))
|
|
73
71
|
}), createSlots({
|
|
74
72
|
"column:__action__": withCtx(({ row }) => [createVNode(unref(action_group_default), {
|
|
75
73
|
class: normalizeClass(unref(cls).e("row-actions")),
|
|
@@ -96,14 +94,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
96
94
|
title: "添加子级",
|
|
97
95
|
onRun: ($event) => unref(handleInsertChild)(row)
|
|
98
96
|
}, null, 8, ["icon", "onRun"])) : createCommentVNode("v-if", true),
|
|
99
|
-
allowed("copy", row) ? (openBlock(), createBlock(unref(_sfc_main$3), {
|
|
100
|
-
key: 3,
|
|
101
|
-
icon: unref(Copy),
|
|
102
|
-
title: "复制此行",
|
|
103
|
-
onRun: ($event) => unref(handleCopy)(row)
|
|
104
|
-
}, null, 8, ["icon", "onRun"])) : createCommentVNode("v-if", true),
|
|
105
97
|
canDelete(row) ? (openBlock(), createBlock(unref(_sfc_main$3), mergeProps({
|
|
106
|
-
key:
|
|
98
|
+
key: 3,
|
|
107
99
|
icon: unref(Delete),
|
|
108
100
|
type: "danger",
|
|
109
101
|
title: "删除",
|
|
@@ -113,11 +105,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
113
105
|
_: 2
|
|
114
106
|
}, 1032, ["class"])]),
|
|
115
107
|
_: 2
|
|
116
|
-
}, [
|
|
117
|
-
name: "empty",
|
|
118
|
-
fn: withCtx(() => [_cache[3] || (_cache[3] = createTextVNode(toDisplayString(null), -1))]),
|
|
119
|
-
key: "0"
|
|
120
|
-
} : void 0, !unref(props).readonly && (unref(staticFeatures).has("create") || unref(dynamicFeatures).create?.()) && (unref(state).type === "create" && !unref(state).visible || unref(state).type === "update") ? {
|
|
108
|
+
}, [showCreateBtn.value ? {
|
|
121
109
|
name: "append",
|
|
122
110
|
fn: withCtx(() => [createElementVNode("div", { class: normalizeClass(unref(cls).e("add")) }, [createVNode(unref(_sfc_main$1), {
|
|
123
111
|
class: normalizeClass(unref(cls).e("add-btn")),
|
|
@@ -127,7 +115,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
127
115
|
plain: "",
|
|
128
116
|
onClick: withModifiers(unref(handleCreate), ["stop"])
|
|
129
117
|
}, {
|
|
130
|
-
default: withCtx(() => [..._cache[
|
|
118
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [createTextVNode(" 新增一行 ", -1)])]),
|
|
131
119
|
_: 1
|
|
132
120
|
}, 8, [
|
|
133
121
|
"class",
|
|
@@ -135,7 +123,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
135
123
|
"loading",
|
|
136
124
|
"onClick"
|
|
137
125
|
])], 2)]),
|
|
138
|
-
key: "
|
|
126
|
+
key: "0"
|
|
139
127
|
} : void 0]), 1040, [
|
|
140
128
|
"slots",
|
|
141
129
|
"class",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-edit-list.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-list.vue"],"sourcesContent":["<template>\n <u-table\n v-bind=\"tableProps\"\n :slots=\"slots\"\n :class=\"[cls.e('table')
|
|
1
|
+
{"version":3,"file":"batch-edit-list.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit-list.vue"],"sourcesContent":["<template>\n <u-table\n v-bind=\"tableProps\"\n :slots=\"slots\"\n :class=\"[cls.e('table')]\"\n :columns=\"columns\"\n highlight-current\n :current=\"state.row\"\n @update:current=\"handleUpdateCurrentRow\"\n @update:checked=\"emit('update:checked', $event)\"\n @update:selected=\"emit('update:selected', $event)\"\n >\n <template #column:__action__=\"{ row }\">\n <u-action-group :class=\"cls.e('row-actions')\" :max=\"5\" @click.stop circle>\n <u-action\n v-if=\"allowed('create', row)\"\n :icon=\"InsertToPrev\"\n title=\"在上方插入\"\n @run=\"handleInsertToPrev(row)\"\n />\n <u-action\n v-if=\"allowed('create', row)\"\n :icon=\"InsertToNext\"\n title=\"在下方插入\"\n @run=\"handleInsertToNext(row)\"\n />\n <u-action\n v-if=\"!!props.tree && allowed('createChild', row)\"\n :icon=\"AddChild\"\n title=\"添加子级\"\n @run=\"handleInsertChild(row)\"\n />\n <u-action\n v-if=\"canDelete(row)\"\n :icon=\"Delete\"\n type=\"danger\"\n title=\"删除\"\n @run=\"handleDelete(row)\"\n v-bind=\"props.actionsProps?.delete\"\n />\n </u-action-group>\n </template>\n\n <!-- 新增按钮 -->\n <template #append v-if=\"showCreateBtn\">\n <div :class=\"cls.e('add')\">\n <u-button\n :class=\"cls.e('add-btn')\"\n :icon=\"Plus\"\n :loading=\"state.loading\"\n type=\"primary\"\n plain\n @click.stop=\"handleCreate\"\n >\n 新增一行\n </u-button>\n </div>\n </template>\n </u-table>\n</template>\n\n<script setup lang=\"ts\">\nimport { o } from '@cat-kit/core'\nimport { AddChild, Delete, InsertToNext, InsertToPrev, Plus } from '@veltra/icons/normal'\nimport { computed, inject, type Slots } from 'vue'\n\nimport type { BatchEditFeature, TableRow } from '../../types'\nimport { UAction, UActionGroup } from '../action'\nimport { UButton } from '../button'\nimport { UTable } from '../table'\nimport { BatchEditDIKey } from './di'\n\ndefineOptions({ name: 'BatchEditList' })\n\ndefineProps<{ slots: Slots }>()\n\nconst {\n cls,\n state,\n props,\n emit,\n staticFeatures,\n dynamicFeatures,\n handleCreate,\n handleDelete,\n handleInsertToNext,\n handleInsertToPrev,\n handleInsertChild\n} = inject(BatchEditDIKey)!\n\nconst tableProps = computed(() => {\n return o(props as Record<string, any>).omit([\n 'model',\n 'columns',\n 'cols',\n 'readonly',\n 'deleteMethod',\n 'saveMethod',\n 'features',\n 'mode',\n 'beforeCreate'\n ])\n})\n\nconst hasNot = (value: BatchEditFeature[]) => value.every((v) => !staticFeatures.value.has(v))\n\nconst allowed = (feature: BatchEditFeature, row?: TableRow) => {\n return staticFeatures.value.has(feature) || !!dynamicFeatures.value[feature]?.(row)\n}\n\nconst columns = computed(() => {\n if (props.readonly || hasNot(['create', 'delete', 'createChild', 'update'])) return props.columns\n\n return (props.columns ?? []).concat({\n name: '操作',\n key: '__action__',\n align: 'center',\n width: 180,\n fixed: 'right',\n resizable: false\n })\n})\n\nfunction handleUpdateCurrentRow(row?: TableRow) {\n if (allowed('update', row)) {\n state.row = row\n }\n}\n\nfunction canDelete(row: TableRow) {\n return !props.readonly && allowed('delete', row)\n}\n\nconst showCreateBtn = computed(() => {\n if (props.readonly) return false\n\n const hasFeature = staticFeatures.value.has('create') || dynamicFeatures.value.create?.()\n const createActionVisible = state.formActionType === 'create' && state.formVisible\n return hasFeature && !createActionVisible\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;EA4EA,MAAM,EACJ,KACA,OACA,OACA,MACA,gBACA,iBACA,cACA,cACA,oBACA,oBACA,sBACE,OAAO,cAAc;EAEzB,MAAM,aAAa,eAAe;GAChC,OAAO,EAAE,KAA4B,EAAE,KAAK;IAC1C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACF,CAAC;EACH,CAAC;EAED,MAAM,UAAU,UAA8B,MAAM,OAAO,MAAM,CAAC,eAAe,MAAM,IAAI,CAAC,CAAC;EAE7F,MAAM,WAAW,SAA2B,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1,12 @@
|
|
|
1
1
|
import _sfc_main$1 from "../layout/layout.js";
|
|
2
|
-
import { DialogDIKey } from "../dialog/di.js";
|
|
3
2
|
import { BatchEditDIKey } from "./di.js";
|
|
4
3
|
import _sfc_main$2 from "./batch-edit-form.js";
|
|
5
4
|
import _sfc_main$3 from "./batch-edit-list.js";
|
|
6
|
-
import {
|
|
5
|
+
import { useEditState } from "./use-edit-state.js";
|
|
7
6
|
import { useFeatures } from "./use-features.js";
|
|
8
|
-
import {
|
|
7
|
+
import { useHandlers } from "./use-handlers.js";
|
|
8
|
+
import { useShortcutKey } from "./use-shortcut-key.js";
|
|
9
|
+
import { computed, createBlock, createCommentVNode, createVNode, defineComponent, guardReactiveProps, normalizeClass, normalizeProps, openBlock, provide, renderSlot, unref, useSlots, useTemplateRef, withCtx } from "vue";
|
|
9
10
|
import { bem } from "@veltra/utils";
|
|
10
11
|
//#region src/components/batch-edit/batch-edit.vue
|
|
11
12
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -16,7 +17,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16
17
|
title: {},
|
|
17
18
|
cols: { default: () => ["1fr", "420px"] },
|
|
18
19
|
readonly: { type: Boolean },
|
|
19
|
-
|
|
20
|
+
quickEdit: { type: Boolean },
|
|
20
21
|
beforeCreate: {},
|
|
21
22
|
labelWidth: {},
|
|
22
23
|
deleteMethod: {},
|
|
@@ -59,91 +60,67 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
59
60
|
const emit = __emit;
|
|
60
61
|
const slots = useSlots();
|
|
61
62
|
const cls = bem("batch-edit");
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
63
|
+
const formRef = useTemplateRef("form");
|
|
64
|
+
const { state, resetState } = useEditState({
|
|
65
|
+
props,
|
|
66
|
+
formRef
|
|
67
|
+
});
|
|
65
68
|
const { staticFeatures, dynamicFeatures } = useFeatures({ props });
|
|
66
|
-
const
|
|
69
|
+
const handlers = useHandlers({
|
|
67
70
|
props,
|
|
68
71
|
emit,
|
|
72
|
+
state,
|
|
73
|
+
resetState,
|
|
69
74
|
formRef
|
|
70
75
|
});
|
|
71
|
-
const {
|
|
76
|
+
const { handleFocusIn, handleFocusOut, handleKeydown, focused } = useShortcutKey({
|
|
77
|
+
props,
|
|
78
|
+
onSave: handlers.handleSave,
|
|
79
|
+
onClose: handlers.handleClose,
|
|
80
|
+
state
|
|
81
|
+
});
|
|
82
|
+
const cols = computed(() => {
|
|
83
|
+
return state.formVisible ? props.cols : void 0;
|
|
84
|
+
});
|
|
72
85
|
provide(BatchEditDIKey, {
|
|
73
86
|
cls,
|
|
74
87
|
props,
|
|
75
88
|
emit,
|
|
76
|
-
|
|
89
|
+
state,
|
|
77
90
|
staticFeatures,
|
|
78
91
|
dynamicFeatures,
|
|
79
92
|
focused,
|
|
80
|
-
...
|
|
81
|
-
});
|
|
82
|
-
const dialogCtx = inject(DialogDIKey, void 0);
|
|
83
|
-
dialogCtx && watch(dialogCtx.visible, (visible) => {
|
|
84
|
-
!visible && editCtx.handleClose();
|
|
85
|
-
});
|
|
86
|
-
const cols = computed(() => {
|
|
87
|
-
return !!state.row || state.visible ? props.cols : void 0;
|
|
93
|
+
...handlers
|
|
88
94
|
});
|
|
89
|
-
function handleFocusIn() {
|
|
90
|
-
focused.value = true;
|
|
91
|
-
}
|
|
92
|
-
function handleFocusOut(e) {
|
|
93
|
-
if (!e.currentTarget.contains(e.relatedTarget)) focused.value = false;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* 键盘快捷键(仅组件获焦时生效):
|
|
97
|
-
* - Esc 关闭表单
|
|
98
|
-
* - ⌘/Ctrl + S 保存(快速编辑模式下编辑行时除外)
|
|
99
|
-
*/
|
|
100
|
-
function handleKeydown(e) {
|
|
101
|
-
if (!focused.value) return;
|
|
102
|
-
if (props.readonly && e.key !== "Escape") return;
|
|
103
|
-
if (e.key === "Escape") {
|
|
104
|
-
if (state.visible) {
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
handleClose();
|
|
107
|
-
}
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (!(e.metaKey || e.ctrlKey)) return;
|
|
111
|
-
if (e.key.toLowerCase() === "s" && state.visible) {
|
|
112
|
-
if (props.mode === "quick" && state.type === "update") return;
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
handleSave();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
95
|
return (_ctx, _cache) => {
|
|
118
96
|
return openBlock(), createBlock(unref(_sfc_main$1), {
|
|
119
97
|
class: normalizeClass(unref(cls).b),
|
|
120
98
|
cols: cols.value,
|
|
121
|
-
rows: "minmax(0, 1fr)",
|
|
99
|
+
rows: "minmax(0, 1fr) ",
|
|
122
100
|
gap: "8px",
|
|
123
101
|
resizable: "",
|
|
124
102
|
tabindex: "-1",
|
|
125
|
-
onFocusin: handleFocusIn,
|
|
126
|
-
onFocusout: handleFocusOut,
|
|
127
|
-
onKeydownCapture: handleKeydown
|
|
103
|
+
onFocusin: unref(handleFocusIn),
|
|
104
|
+
onFocusout: unref(handleFocusOut),
|
|
105
|
+
onKeydownCapture: unref(handleKeydown)
|
|
128
106
|
}, {
|
|
129
107
|
default: withCtx(() => [
|
|
130
108
|
createCommentVNode(" 编辑列表 "),
|
|
131
|
-
createVNode(_sfc_main$3, {
|
|
132
|
-
slots,
|
|
133
|
-
ref_key: "tableRef",
|
|
134
|
-
ref: tableRef
|
|
135
|
-
}, null, 512),
|
|
109
|
+
createVNode(_sfc_main$3, { slots }),
|
|
136
110
|
createCommentVNode(" 编辑表单 "),
|
|
137
|
-
createVNode(_sfc_main$2, {
|
|
138
|
-
ref_key: "formRef",
|
|
139
|
-
ref: formRef
|
|
140
|
-
}, {
|
|
111
|
+
createVNode(_sfc_main$2, { ref: "form" }, {
|
|
141
112
|
default: withCtx((scoped) => [renderSlot(_ctx.$slots, "form", normalizeProps(guardReactiveProps(scoped)))]),
|
|
142
113
|
_: 3
|
|
143
114
|
}, 512)
|
|
144
115
|
]),
|
|
145
116
|
_: 3
|
|
146
|
-
}, 8, [
|
|
117
|
+
}, 8, [
|
|
118
|
+
"class",
|
|
119
|
+
"cols",
|
|
120
|
+
"onFocusin",
|
|
121
|
+
"onFocusout",
|
|
122
|
+
"onKeydownCapture"
|
|
123
|
+
]);
|
|
147
124
|
};
|
|
148
125
|
}
|
|
149
126
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout\n :class=\"cls.b\"\n :cols=\"cols\"\n rows=\"minmax(0, 1fr)\"\n gap=\"8px\"\n resizable\n tabindex=\"-1\"\n @focusin=\"handleFocusIn\"\n @focusout=\"handleFocusOut\"\n @keydown.capture=\"handleKeydown\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\"
|
|
1
|
+
{"version":3,"file":"batch-edit.js","names":[],"sources":["../../../src/components/batch-edit/batch-edit.vue"],"sourcesContent":["<template>\n <u-layout\n :class=\"cls.b\"\n :cols=\"cols\"\n rows=\"minmax(0, 1fr) \"\n gap=\"8px\"\n resizable\n tabindex=\"-1\"\n @focusin=\"handleFocusIn\"\n @focusout=\"handleFocusOut\"\n @keydown.capture=\"handleKeydown\"\n >\n <!-- 编辑列表 -->\n <BatchEditList :slots=\"slots\" />\n\n <!-- 编辑表单 -->\n <BatchEditForm ref=\"form\" v-slot=\"scoped\">\n <slot name=\"form\" v-bind=\"scoped\" />\n </BatchEditForm>\n </u-layout>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, provide, useTemplateRef } from 'vue'\n\nimport type { BatchEditEmits, BatchEditProps, BatchEditSlots, FormExposed } from '../../types'\nimport { ULayout } from '../layout'\nimport BatchEditForm from './batch-edit-form.vue'\nimport BatchEditList from './batch-edit-list.vue'\nimport { BatchEditDIKey } from './di'\nimport { useEditState } from './use-edit-state'\nimport { useFeatures } from './use-features'\nimport { useHandlers } from './use-handlers'\nimport { useShortcutKey } from './use-shortcut-key'\n\ndefineOptions({ name: 'BatchEdit' })\n\nconst props = withDefaults(defineProps<BatchEditProps>(), { cols: () => ['1fr', '420px'] })\n\nconst emit = defineEmits<BatchEditEmits>()\n\nconst slots = defineSlots<BatchEditSlots>()\n\nconst cls = bem('batch-edit')\n\nconst formRef = useTemplateRef<FormExposed>('form')\n\nconst { state, resetState } = useEditState({ props, formRef })\n\nconst { staticFeatures, dynamicFeatures } = useFeatures({ props })\n\nconst handlers = useHandlers({ props, emit, state, resetState, formRef })\n\n// 快捷键处理\nconst { handleFocusIn, handleFocusOut, handleKeydown, focused } = useShortcutKey({\n props,\n onSave: handlers.handleSave,\n onClose: handlers.handleClose,\n state\n})\n\nconst cols = computed(() => {\n return state.formVisible ? props.cols : undefined\n})\n\nprovide(BatchEditDIKey, {\n cls,\n props,\n emit,\n state,\n staticFeatures,\n dynamicFeatures,\n focused,\n ...handlers\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,QAAQ,SAAA;EAEd,MAAM,MAAM,IAAI,YAAY;EAE5B,MAAM,UAAU,eAA4B,MAAM;EAElD,MAAM,EAAE,OAAO,eAAe,aAAa;GAAE;GAAO;EAAQ,CAAC;EAE7D,MAAM,EAAE,gBAAgB,oBAAoB,YAAY,EAAE,MAAM,CAAC;EAEjE,MAAM,WAAW,YAAY;GAAE;GAAO;GAAM;GAAO;GAAY;EAAQ,CAAC;EAGxE,MAAM,EAAE,eAAe,gBAAgB,eAAe,YAAY,eAAe;GAC/E;GACA,QAAQ,SAAS;GACjB,SAAS,SAAS;GAClB;EACF,CAAC;EAED,MAAM,OAAO,eAAe;GAC1B,OAAO,MAAM,cAAc,MAAM,OAAO,KAAA;EAC1C,CAAC;EAED,QAAQ,gBAAgB;GACtB;GACA;GACA;GACA;GACA;GACA;GACA;GACA,GAAG;EACL,CAAC;;uBA1EC,YAkBW,MAAA,WAAA,GAAA;IAjBR,OAAK,eAAE,MAAA,GAAA,EAAI,CAAC;IACZ,MAAM,KAAA;IACP,MAAK;IACL,KAAI;IACJ,WAAA;IACA,UAAS;IACR,WAAS,MAAA,aAAA;IACT,YAAU,MAAA,cAAA;sBACO,MAAA,aAAA;;2BAEL;KAAb,mBAAA,QAAA;KACA,YAAgC,aAAA,EAAT,MAAK,CAAA;KAE5B,mBAAA,QAAA;KACA,YAEgB,aAAA,EAFD,KAAI,OAAM,GAAA;wBAAS,WAAM,CACtC,WAAoC,KAAA,QAAA,QAAA,eAAA,mBAAV,MAAM,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import { TableColumn,
|
|
2
|
-
import {
|
|
1
|
+
import { TableColumn, TableRow } from "../../types/table.js";
|
|
2
|
+
import { BatchEditProps, BatchEditSlots } from "../../types/batch-edit.js";
|
|
3
3
|
//#region src/components/batch-edit/batch-edit.vue.d.ts
|
|
4
|
-
type __VLS_Slots =
|
|
5
|
-
form?: (props: {
|
|
6
|
-
/** 当前编辑的层级 */depth?: number; /** 当前编辑的行 */
|
|
7
|
-
row?: TableRow; /** 当前编辑的行索引 */
|
|
8
|
-
index?: number; /** 操作的目标行索引路径 */
|
|
9
|
-
indexes?: number[];
|
|
10
|
-
}) => any;
|
|
11
|
-
header?: () => any;
|
|
12
|
-
} & Partial<{
|
|
13
|
-
[key: `column:${string}`]: (props: TableColumnSlotsScope) => any;
|
|
14
|
-
}>;
|
|
4
|
+
type __VLS_Slots = BatchEditSlots;
|
|
15
5
|
declare const __VLS_base: import("vue").DefineComponent<BatchEditProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
16
6
|
"update:selected": (value: Record<string, any> | undefined) => any;
|
|
17
7
|
"update:checked": (value: Record<string, any>[]) => any;
|
|
@@ -32,7 +22,6 @@ declare const __VLS_base: import("vue").DefineComponent<BatchEditProps, {}, {},
|
|
|
32
22
|
"onRow-click"?: ((row: TableRow, ev: MouseEvent) => any) | undefined;
|
|
33
23
|
}>, {
|
|
34
24
|
cols: string | [string, string];
|
|
35
|
-
mode: BatchEditMode;
|
|
36
25
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
37
26
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
38
27
|
declare const _default: typeof __VLS_export;
|