@veltra/desktop 1.2.7 → 1.2.8
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 +2 -2
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/batch-edit/batch-edit-form.js +2 -6
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/use-edit.js +17 -1
- package/dist/components/batch-edit/use-edit.js.map +1 -1
- package/dist/components/empty/empty.vue.d.ts +1 -1
- package/dist/components/input/input.vue.d.ts +4 -4
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +1 -1
- package/dist/components/progress-nodes/progress-nodes.vue.d.ts +1 -1
- package/dist/components/scroll/scroll.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/tree/tree.vue.d.ts +1 -1
- package/dist/components/tree-select/tree-select.vue.d.ts +1 -1
- package/dist/components/watermark/watermark.vue.d.ts +1 -1
- package/dist/types/batch-edit.d.ts +1 -1
- package/package.json +6 -6
- package/src/components/batch-edit/batch-edit-form.vue +2 -9
- package/src/components/batch-edit/use-edit.ts +25 -3
- package/src/types/batch-edit.ts +1 -1
|
@@ -7,10 +7,10 @@ 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
|
-
|
|
10
|
+
max: number;
|
|
11
11
|
size: "small" | "default" | "large";
|
|
12
|
+
text: boolean;
|
|
12
13
|
circle: boolean;
|
|
13
|
-
max: number;
|
|
14
14
|
loading: boolean;
|
|
15
15
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
16
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -13,8 +13,8 @@ declare const __VLS_base: import("vue").DefineComponent<ActionProps, {}, {}, {},
|
|
|
13
13
|
onRun?: (() => any) | undefined;
|
|
14
14
|
}>, {
|
|
15
15
|
type: ButtonType;
|
|
16
|
-
text: boolean;
|
|
17
16
|
size: import("@veltra/utils").ComponentSize;
|
|
17
|
+
text: boolean;
|
|
18
18
|
circle: boolean;
|
|
19
19
|
loading: boolean;
|
|
20
20
|
inDropdown: boolean;
|
|
@@ -31,10 +31,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
31
31
|
const isQuick = computed(() => props.mode === "quick");
|
|
32
32
|
const isNormal = computed(() => props.mode !== "quick");
|
|
33
33
|
const isQuickUpdate = computed(() => isQuick.value && state.type === "update");
|
|
34
|
-
const formModel = computed(() => {
|
|
35
|
-
if (isQuick.value && state.type === "update" && state.row) return state.row.data;
|
|
36
|
-
return props.model;
|
|
37
|
-
});
|
|
38
34
|
const headerInfo = computed(() => {
|
|
39
35
|
if (props.readonly) return {
|
|
40
36
|
icon: View,
|
|
@@ -65,7 +61,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
65
61
|
return `${state.type}-${state.row?.uid ?? "create"}-${state.parentRow?.uid ?? "root"}`;
|
|
66
62
|
});
|
|
67
63
|
return (_ctx, _cache) => {
|
|
68
|
-
return unref(state).visible &&
|
|
64
|
+
return unref(state).visible && unref(props).model ? (openBlock(), createElementBlock("aside", {
|
|
69
65
|
key: 0,
|
|
70
66
|
class: normalizeClass(unref(cls).e("form"))
|
|
71
67
|
}, [
|
|
@@ -105,7 +101,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
105
101
|
default: withCtx(() => [createVNode(unref(form_default), {
|
|
106
102
|
ref_key: "formComponentRef",
|
|
107
103
|
ref: formComponentRef,
|
|
108
|
-
model:
|
|
104
|
+
model: unref(props).model,
|
|
109
105
|
readonly: unref(props).readonly,
|
|
110
106
|
"label-width": unref(props).labelWidth
|
|
111
107
|
}, {
|
|
@@ -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.visible &&
|
|
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.visible && props.model\">\n <header :class=\"cls.e('form-header')\">\n <span :class=\"[cls.e('form-icon'), bem.is(headerInfo.tone)]\">\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 <span v-if=\"headerInfo.chip\" :class=\"cls.e('form-chip')\">\n {{ headerInfo.chip }}\n </span>\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 >\n <slot\n v-bind=\"{\n row: state.row,\n depth: state.depth,\n indexes: insertIndexes,\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')\" v-if=\"props.readonly\">只读模式</span>\n <span :class=\"cls.e('form-hint')\" v-else-if=\"isQuickUpdate\">\n 实时编辑\n <span :class=\"{ [bem.is('concealed')]: !focused }\"> · <u-kbd>Esc</u-kbd> 关闭</span>\n </span>\n <span :class=\"cls.e('form-hint')\" v-else>\n <span :class=\"{ [bem.is('concealed')]: !focused }\">\n <u-kbd>Ctrl + S</u-kbd> 保存 · <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\n v-if=\"\n !props.readonly && ((isNormal && (creatable || updatable)) || (isQuick && creatable))\n \"\n :type=\"state.type === 'create' ? 'success' : 'primary'\"\n :loading=\"state.loading\"\n @click=\"handleSave\"\n >\n 保存\n </u-button>\n </div>\n </footer>\n </aside>\n</template>\n\n<script lang=\"ts\" setup>\nimport { AddChild, Close, EditPen, Plus, View } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, inject, shallowRef, toRef, type Component } 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'\n\ndefineOptions({ name: 'BatchEditForm' })\n\nconst batchEditCtx = inject(BatchEditDIKey)!\n\nconst {\n cls,\n props,\n state,\n insertIndexes,\n handleSave,\n handleClose,\n staticFeatures,\n dynamicFeatures\n} = 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\nconst creatable = computed(() => {\n return (\n state.type === 'create' &&\n (staticFeatures.value.has('create') || dynamicFeatures.value.create?.(state.row))\n )\n})\n\nconst updatable = computed(() => {\n return (\n state.type === 'update' &&\n (staticFeatures.value.has('update') || dynamicFeatures.value.update?.(state.row))\n )\n})\n\nconst isQuick = computed(() => props.mode === 'quick')\nconst isNormal = computed(() => props.mode !== 'quick')\nconst isQuickUpdate = computed(() => isQuick.value && state.type === 'update')\n\ninterface HeaderInfo {\n icon: Component\n title: string\n chip?: string\n tone: 'create' | 'update' | 'view' | 'child'\n}\n\nconst headerInfo = computed<HeaderInfo>(() => {\n if (props.readonly) {\n return {\n icon: View,\n title: '查看详情',\n chip: state.row ? `第 ${state.row.index + 1} 行` : undefined,\n tone: 'view'\n }\n }\n if (state.parentRow) {\n return {\n icon: AddChild,\n title: '新增子级',\n chip: `归属于第 ${state.parentRow.index + 1} 行`,\n tone: 'child'\n }\n }\n if (state.type === 'create') {\n return { icon: Plus, title: '新增', tone: 'create' }\n }\n return {\n icon: EditPen,\n title: '编辑',\n chip: state.row ? `第 ${state.row.index + 1} 行` : undefined,\n tone: 'update'\n }\n})\n\n/** 通过 row 切换 / 类型切换驱动表单内容淡出淡入 */\nconst bodyKey = computed(() => {\n return `${state.type}-${state.row?.uid ?? 'create'}-${state.parentRow?.uid ?? 'root'}`\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;EAyFA,MAAM,eAAe,OAAO,cAAc;EAE1C,MAAM,EACJ,KACA,OACA,OACA,eACA,YACA,aACA,gBACA,oBACE;EAEJ,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,MAAM,YAAY,eAAe;GAC/B,OACE,MAAM,SAAS,aACd,eAAe,MAAM,IAAI,QAAQ,KAAK,gBAAgB,MAAM,SAAS,MAAM,GAAG;EAEnF,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,OACE,MAAM,SAAS,aACd,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AAA,WAAA;;4BAAiB,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAJ,QAAI,EAAA,CAAA,EAAA,CAAA;;oCAE3C,MAAA,KAAA,EAAM,aAAc,SAAA,UAAa,UAAA,SAAa,UAAA,UAAgB,QAAA,SAAW,UAAA,UAAA,UAAA,GAD/F,YASW,MAAA,WAAA,GAAA;;KALR,MAAM,MAAA,KAAA,EAAM,SAAI,WAAA,YAAA;KAChB,SAAS,MAAA,KAAA,EAAM;KACf,SAAO,MAAA,UAAA;;4BAGV,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFC,QAED,EAAA,CAAA,EAAA,CAAA"}
|
|
@@ -50,9 +50,25 @@ function useEdit(options) {
|
|
|
50
50
|
if (row) {
|
|
51
51
|
state.type = "update";
|
|
52
52
|
state.visible = true;
|
|
53
|
-
|
|
53
|
+
setFormData(row.data);
|
|
54
54
|
} else state.visible = false;
|
|
55
55
|
}, { flush: "sync" });
|
|
56
|
+
/**
|
|
57
|
+
* quick + update:model 实时写回 row.data,让表格显示同步更新。
|
|
58
|
+
* normal 模式不写回,需等待保存。
|
|
59
|
+
*
|
|
60
|
+
* 监听源仅限 props.model(deep 遍历仅作用于 model,不触及 row 树);
|
|
61
|
+
* mode/type/row 在回调中读取但不作为依赖,避免行切换等场景误触发。
|
|
62
|
+
*/
|
|
63
|
+
watch(() => props.model, (model) => {
|
|
64
|
+
const { row, type } = state;
|
|
65
|
+
if (props.mode !== "quick" || type !== "update" || !row || !model) return;
|
|
66
|
+
const data = row.data;
|
|
67
|
+
Object.keys(model).forEach((key) => {
|
|
68
|
+
const next = o(model).get(key);
|
|
69
|
+
if (o(data).get(key) !== next) o(data).set(key, next);
|
|
70
|
+
});
|
|
71
|
+
}, { deep: true });
|
|
56
72
|
const childrenKey = computed(() => {
|
|
57
73
|
return typeof props.tree === "string" ? props.tree : "children";
|
|
58
74
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-edit.js","names":[],"sources":["../../../src/components/batch-edit/use-edit.ts"],"sourcesContent":["import { last, o, safeRun } from '@cat-kit/core'\nimport { computed, nextTick, shallowReactive, shallowRef, watch, type ShallowRef } from 'vue'\n\nimport type { TableRow, BatchEditEmits, BatchEditProps } from '../../types'\nimport type { FormExposed } from '../../types/form'\n\n/** 按索引路径在原始数据树中定位节点(等价于历史 Forest.visit 路径访问) */\nfunction visitDataByIndexPath<T extends Record<string, unknown>>(\n roots: T[],\n indexPath: number[],\n childrenKey: string\n): T | undefined {\n if (!indexPath.length) return undefined\n let currentList: T[] | undefined = roots\n let node: T | undefined\n for (let i = 0; i < indexPath.length; i++) {\n const idx = indexPath[i]!\n if (!currentList) return undefined\n node = currentList[idx]\n if (node === undefined) return undefined\n if (i < indexPath.length - 1) {\n const next = node[childrenKey]\n currentList = Array.isArray(next) ? (next as T[]) : undefined\n }\n }\n return node\n}\n\ninterface Options {\n props: BatchEditProps\n emit: BatchEditEmits\n formRef: ShallowRef<FormExposed | undefined>\n}\n\nexport interface BatchEditStates {\n /** 层级 */\n depth?: number\n visible: boolean\n type: 'create' | 'update'\n loading: boolean\n row?: TableRow\n /** 父级,只在添加子级时会有值 */\n parentRow?: TableRow\n}\n\nexport interface EditReturned {\n state: BatchEditStates\n insertIndexes: ShallowRef<number[]>\n handleSave: () => Promise<void>\n handleClose: () => void\n handleCreate: () => Promise<void>\n handleEdit: (row: TableRow) => void\n handleCopy: (row: TableRow) => Promise<void>\n handleDelete: (row: TableRow) => Promise<void>\n handleInsertToNext: (row: TableRow) => Promise<void>\n handleInsertToPrev: (row: TableRow) => Promise<void>\n handleInsertChild: (row: TableRow) => Promise<void>\n}\n\nfunction snapshotData(data?: Record<string, any>) {\n return safeRun(() => JSON.parse(JSON.stringify(data ?? {})), {})\n}\n\nfunction replaceModelData(model: Record<string, any>, data: Record<string, any>) {\n for (const key of Object.keys(model)) {\n delete model[key]\n }\n Object.assign(model, data)\n}\n\nexport function useEdit(options: Options): EditReturned {\n const { props, emit, formRef } = options\n\n /** 组件状态 */\n const state = shallowReactive<BatchEditStates>({\n depth: undefined,\n visible: false,\n type: 'create',\n loading: false\n })\n\n const insertIndexes = shallowRef<number[]>([])\n\n function snapshotModelData() {\n return snapshotData(props.model)\n }\n\n function setFormData(formData?: Record<string, any>) {\n if (!props.model) return\n replaceModelData(props.model, snapshotData(formData))\n }\n\n const isQuickMode = () => props.mode === 'quick'\n\n async function runBeforeCreate(data: Record<string, any>) {\n await props.beforeCreate?.(data, state.parentRow?.data)\n }\n\n watch(\n () => state.row,\n (row) => {\n if (row) {\n state.type = 'update'\n state.visible = true\n if (!isQuickMode()) {\n setFormData(row.data)\n }\n } else {\n state.visible = false\n }\n },\n { flush: 'sync' }\n )\n\n const childrenKey = computed(() => {\n return typeof props.tree === 'string' ? props.tree : 'children'\n })\n\n /**\n * 插入数据\n * @param item 数据\n */\n function insert(item: Record<string, any>) {\n const data = [...(props.data ?? [])]\n\n const parent = visitDataByIndexPath(\n data ?? [],\n insertIndexes.value.slice(0, -1),\n childrenKey.value\n )\n\n if (parent) {\n const children = parent[childrenKey.value]\n if (!children) {\n parent[childrenKey.value] = [item]\n } else {\n children.splice(last(insertIndexes.value), 0, item)\n }\n } else {\n data.splice(last(insertIndexes.value), 0, item)\n }\n\n emit('update:data', data)\n\n return item\n }\n\n function getInsertData(): Record<string, any> {\n return snapshotModelData()\n }\n\n async function runCreate(cb: () => void, initialData?: Record<string, any>) {\n state.parentRow = undefined\n if (state.row) {\n state.row.isCurrent = false\n }\n state.row = undefined\n state.type = 'create'\n cb()\n\n await nextTick()\n\n setFormData(initialData)\n\n if (isQuickMode() && props.model) {\n await runBeforeCreate(props.model)\n }\n\n state.visible = true\n }\n\n /**\n * 点击新增按钮\n */\n async function handleCreate() {\n const { data } = props\n await runCreate(() => {\n state.depth = 1\n insertIndexes.value = [data?.length ?? 0]\n })\n }\n\n async function handleInsertToPrev(row: TableRow) {\n await runCreate(() => {\n state.depth = row.depth\n insertIndexes.value = [...row.indexes]\n })\n }\n\n async function handleInsertToNext(row: TableRow) {\n await runCreate(() => {\n state.depth = row.depth\n insertIndexes.value = [...row.indexes.slice(0, -1), row.index + 1]\n })\n }\n\n async function handleInsertChild(row: TableRow) {\n await runCreate(() => {\n state.parentRow = row\n state.depth = row.depth + 1\n row.expanded = true\n\n insertIndexes.value = [...row.indexes, row.children?.length ?? 0]\n })\n }\n\n /** 编辑指定行(等同于点击行) */\n function handleEdit(row: TableRow) {\n state.type = 'update'\n state.row = row\n state.depth = row.depth\n }\n\n /** 复制指定行:在其下方以 create 模式打开表单,并预填副本数据 */\n async function handleCopy(row: TableRow) {\n await runCreate(() => {\n state.depth = row.depth\n insertIndexes.value = [...row.indexes.slice(0, -1), row.index + 1]\n }, row.data)\n }\n\n function runWithLoading<Arg extends any[]>(fn: (...args: Arg) => Promise<void> | void) {\n return async (...args: Arg) => {\n state.loading = true\n if (state.row) {\n state.row.operating = true\n }\n try {\n await fn.apply(null, args)\n } catch (error) {\n console.error(error)\n }\n state.loading = false\n if (state.row) {\n state.row.operating = false\n }\n }\n }\n\n /** 保存 */\n const handleSave = runWithLoading(async () => {\n const { model, saveMethod } = props\n\n if (!model) return\n\n if (isQuickMode() && state.type === 'update') return\n\n formRef.value?.clearValidate()\n const valid = await formRef.value?.validate()\n\n if (!valid) return\n\n // quick + create:仅校验 + insert\n if (isQuickMode() && state.type === 'create') {\n insert(getInsertData())\n return\n }\n\n let item = getInsertData()\n\n // normal + create:beforeCreate → saveMethod → insert\n if (state.type === 'create') {\n await runBeforeCreate(item)\n if (saveMethod) {\n const result = await saveMethod(item, state.type, state.parentRow?.data)\n if (result) {\n item = result\n }\n }\n insert(item)\n return\n }\n\n // normal + update\n if (saveMethod) {\n const result = await saveMethod(item, state.type, state.parentRow?.data)\n if (result) {\n item = result\n }\n }\n\n const { row } = state\n row &&\n Object.keys(item).forEach((key) => {\n o(row.data).set(key, o(item).get(key))\n })\n })\n\n const handleDelete = runWithLoading(async (row: TableRow) => {\n const { deleteMethod } = props\n\n if (deleteMethod) {\n await deleteMethod([row.data])\n }\n\n const data = [...(props.data ?? [])]\n\n const parent = visitDataByIndexPath(data, row.indexes.slice(0, -1), childrenKey.value)\n\n if (parent) {\n const children = parent[childrenKey.value]\n if (children) {\n children.splice(row.index, 1)\n } else {\n console.error('行路径不正确')\n }\n } else {\n data.splice(row.index, 1)\n }\n\n if (state.row === row) {\n state.row = undefined\n state.depth = undefined\n }\n\n emit('update:data', data)\n })\n\n function handleClose() {\n state.visible = false\n if (state.row) {\n state.row.isCurrent = false\n }\n state.row = undefined\n state.parentRow = undefined\n state.depth = undefined\n insertIndexes.value = []\n }\n\n return {\n state,\n insertIndexes,\n handleDelete,\n handleInsertChild,\n handleInsertToNext,\n handleInsertToPrev,\n handleCreate,\n handleEdit,\n handleCopy,\n handleClose,\n handleSave\n }\n}\n"],"mappings":";;;;AAOA,SAAS,qBACP,OACA,WACA,aACe;CACf,IAAI,CAAC,UAAU,QAAQ,OAAO,KAAA;CAC9B,IAAI,cAA+B;CACnC,IAAI;CACJ,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EACzC,MAAM,MAAM,UAAU;EACtB,IAAI,CAAC,aAAa,OAAO,KAAA;EACzB,OAAO,YAAY;EACnB,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;EAC/B,IAAI,IAAI,UAAU,SAAS,GAAG;GAC5B,MAAM,OAAO,KAAK;GAClB,cAAc,MAAM,QAAQ,IAAI,IAAK,OAAe,KAAA;EACtD;CACF;CACA,OAAO;AACT;AAiCA,SAAS,aAAa,MAA4B;CAChD,OAAO,cAAc,KAAK,MAAM,KAAK,UAAU,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACjE;AAEA,SAAS,iBAAiB,OAA4B,MAA2B;CAC/E,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GACjC,OAAO,MAAM;CAEf,OAAO,OAAO,OAAO,IAAI;AAC3B;AAEA,SAA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EnC,MAAM,SAAS,qBAAqB,MAAM,IAAI,QAAQ,MAAM,GAAG,EAAE,GAAG,YAAY,KAAK;EAErF,IAAI,QAAQ;GACV,MAAM,WAAW,OAAO,YAAY;GACpC,IAAI,UACF,SAAS,OAAO,IAAI,OAAO,CAAC;QAE5B,QAAQ,MAAM,QAAQ;EAE1B,OACE,KAAK,OAAO,IAAI,OAAO,CAAC;EAG1B,IAAI,MAAM,QAAQ,KAAK;GACrB,MAAM,MAAM,KAAA;GACZ,MAAM,QAAQ,KAAA;EAChB;EAEA,KAAK,eAAe,IAAI;CAC1B,CAAC;CAED,SAAS,cAAc;EACrB,MAAM,UAAU;EAChB,IAAI,MAAM,KACR,MAAM,IAAI,YAAY;EAExB,MAAM,MAAM,KAAA;EACZ,MAAM,YAAY,KAAA;EAClB,MAAM,QAAQ,KAAA;EACd,cAAc,QAAQ,CAAC;CACzB;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-edit.js","names":[],"sources":["../../../src/components/batch-edit/use-edit.ts"],"sourcesContent":["import { last, o, safeRun } from '@cat-kit/core'\nimport { computed, nextTick, shallowReactive, shallowRef, watch, type ShallowRef } from 'vue'\n\nimport type { TableRow, BatchEditEmits, BatchEditProps } from '../../types'\nimport type { FormExposed } from '../../types/form'\n\n/** 按索引路径在原始数据树中定位节点(等价于历史 Forest.visit 路径访问) */\nfunction visitDataByIndexPath<T extends Record<string, unknown>>(\n roots: T[],\n indexPath: number[],\n childrenKey: string\n): T | undefined {\n if (!indexPath.length) return undefined\n let currentList: T[] | undefined = roots\n let node: T | undefined\n for (let i = 0; i < indexPath.length; i++) {\n const idx = indexPath[i]!\n if (!currentList) return undefined\n node = currentList[idx]\n if (node === undefined) return undefined\n if (i < indexPath.length - 1) {\n const next = node[childrenKey]\n currentList = Array.isArray(next) ? (next as T[]) : undefined\n }\n }\n return node\n}\n\ninterface Options {\n props: BatchEditProps\n emit: BatchEditEmits\n formRef: ShallowRef<FormExposed | undefined>\n}\n\nexport interface BatchEditStates {\n /** 层级 */\n depth?: number\n visible: boolean\n type: 'create' | 'update'\n loading: boolean\n row?: TableRow\n /** 父级,只在添加子级时会有值 */\n parentRow?: TableRow\n}\n\nexport interface EditReturned {\n state: BatchEditStates\n insertIndexes: ShallowRef<number[]>\n handleSave: () => Promise<void>\n handleClose: () => void\n handleCreate: () => Promise<void>\n handleEdit: (row: TableRow) => void\n handleCopy: (row: TableRow) => Promise<void>\n handleDelete: (row: TableRow) => Promise<void>\n handleInsertToNext: (row: TableRow) => Promise<void>\n handleInsertToPrev: (row: TableRow) => Promise<void>\n handleInsertChild: (row: TableRow) => Promise<void>\n}\n\nfunction snapshotData(data?: Record<string, any>) {\n return safeRun(() => JSON.parse(JSON.stringify(data ?? {})), {})\n}\n\nfunction replaceModelData(model: Record<string, any>, data: Record<string, any>) {\n for (const key of Object.keys(model)) {\n delete model[key]\n }\n Object.assign(model, data)\n}\n\nexport function useEdit(options: Options): EditReturned {\n const { props, emit, formRef } = options\n\n /** 组件状态 */\n const state = shallowReactive<BatchEditStates>({\n depth: undefined,\n visible: false,\n type: 'create',\n loading: false\n })\n\n const insertIndexes = shallowRef<number[]>([])\n\n function snapshotModelData() {\n return snapshotData(props.model)\n }\n\n function setFormData(formData?: Record<string, any>) {\n if (!props.model) return\n replaceModelData(props.model, snapshotData(formData))\n }\n\n const isQuickMode = () => props.mode === 'quick'\n\n async function runBeforeCreate(data: Record<string, any>) {\n await props.beforeCreate?.(data, state.parentRow?.data)\n }\n\n watch(\n () => state.row,\n (row) => {\n if (row) {\n state.type = 'update'\n state.visible = true\n // 所有模式下都回填 model,保证表单内条件字段(依赖 model)能响应当前编辑行\n setFormData(row.data)\n } else {\n state.visible = false\n }\n },\n { flush: 'sync' }\n )\n\n /**\n * quick + update:model 实时写回 row.data,让表格显示同步更新。\n * normal 模式不写回,需等待保存。\n *\n * 监听源仅限 props.model(deep 遍历仅作用于 model,不触及 row 树);\n * mode/type/row 在回调中读取但不作为依赖,避免行切换等场景误触发。\n */\n watch(\n () => props.model,\n (model) => {\n const { row, type } = state\n if (props.mode !== 'quick' || type !== 'update' || !row || !model) return\n const data = row.data\n Object.keys(model).forEach((key) => {\n const next = o(model).get(key)\n if (o(data).get(key) !== next) {\n o(data).set(key, next)\n }\n })\n },\n { deep: true }\n )\n\n const childrenKey = computed(() => {\n return typeof props.tree === 'string' ? props.tree : 'children'\n })\n\n /**\n * 插入数据\n * @param item 数据\n */\n function insert(item: Record<string, any>) {\n const data = [...(props.data ?? [])]\n\n const parent = visitDataByIndexPath(\n data ?? [],\n insertIndexes.value.slice(0, -1),\n childrenKey.value\n )\n\n if (parent) {\n const children = parent[childrenKey.value]\n if (!children) {\n parent[childrenKey.value] = [item]\n } else {\n children.splice(last(insertIndexes.value), 0, item)\n }\n } else {\n data.splice(last(insertIndexes.value), 0, item)\n }\n\n emit('update:data', data)\n\n return item\n }\n\n function getInsertData(): Record<string, any> {\n return snapshotModelData()\n }\n\n async function runCreate(cb: () => void, initialData?: Record<string, any>) {\n state.parentRow = undefined\n if (state.row) {\n state.row.isCurrent = false\n }\n state.row = undefined\n state.type = 'create'\n cb()\n\n await nextTick()\n\n setFormData(initialData)\n\n if (isQuickMode() && props.model) {\n await runBeforeCreate(props.model)\n }\n\n state.visible = true\n }\n\n /**\n * 点击新增按钮\n */\n async function handleCreate() {\n const { data } = props\n await runCreate(() => {\n state.depth = 1\n insertIndexes.value = [data?.length ?? 0]\n })\n }\n\n async function handleInsertToPrev(row: TableRow) {\n await runCreate(() => {\n state.depth = row.depth\n insertIndexes.value = [...row.indexes]\n })\n }\n\n async function handleInsertToNext(row: TableRow) {\n await runCreate(() => {\n state.depth = row.depth\n insertIndexes.value = [...row.indexes.slice(0, -1), row.index + 1]\n })\n }\n\n async function handleInsertChild(row: TableRow) {\n await runCreate(() => {\n state.parentRow = row\n state.depth = row.depth + 1\n row.expanded = true\n\n insertIndexes.value = [...row.indexes, row.children?.length ?? 0]\n })\n }\n\n /** 编辑指定行(等同于点击行) */\n function handleEdit(row: TableRow) {\n state.type = 'update'\n state.row = row\n state.depth = row.depth\n }\n\n /** 复制指定行:在其下方以 create 模式打开表单,并预填副本数据 */\n async function handleCopy(row: TableRow) {\n await runCreate(() => {\n state.depth = row.depth\n insertIndexes.value = [...row.indexes.slice(0, -1), row.index + 1]\n }, row.data)\n }\n\n function runWithLoading<Arg extends any[]>(fn: (...args: Arg) => Promise<void> | void) {\n return async (...args: Arg) => {\n state.loading = true\n if (state.row) {\n state.row.operating = true\n }\n try {\n await fn.apply(null, args)\n } catch (error) {\n console.error(error)\n }\n state.loading = false\n if (state.row) {\n state.row.operating = false\n }\n }\n }\n\n /** 保存 */\n const handleSave = runWithLoading(async () => {\n const { model, saveMethod } = props\n\n if (!model) return\n\n if (isQuickMode() && state.type === 'update') return\n\n formRef.value?.clearValidate()\n const valid = await formRef.value?.validate()\n\n if (!valid) return\n\n // quick + create:仅校验 + insert\n if (isQuickMode() && state.type === 'create') {\n insert(getInsertData())\n return\n }\n\n let item = getInsertData()\n\n // normal + create:beforeCreate → saveMethod → insert\n if (state.type === 'create') {\n await runBeforeCreate(item)\n if (saveMethod) {\n const result = await saveMethod(item, state.type, state.parentRow?.data)\n if (result) {\n item = result\n }\n }\n insert(item)\n return\n }\n\n // normal + update\n if (saveMethod) {\n const result = await saveMethod(item, state.type, state.parentRow?.data)\n if (result) {\n item = result\n }\n }\n\n const { row } = state\n row &&\n Object.keys(item).forEach((key) => {\n o(row.data).set(key, o(item).get(key))\n })\n })\n\n const handleDelete = runWithLoading(async (row: TableRow) => {\n const { deleteMethod } = props\n\n if (deleteMethod) {\n await deleteMethod([row.data])\n }\n\n const data = [...(props.data ?? [])]\n\n const parent = visitDataByIndexPath(data, row.indexes.slice(0, -1), childrenKey.value)\n\n if (parent) {\n const children = parent[childrenKey.value]\n if (children) {\n children.splice(row.index, 1)\n } else {\n console.error('行路径不正确')\n }\n } else {\n data.splice(row.index, 1)\n }\n\n if (state.row === row) {\n state.row = undefined\n state.depth = undefined\n }\n\n emit('update:data', data)\n })\n\n function handleClose() {\n state.visible = false\n if (state.row) {\n state.row.isCurrent = false\n }\n state.row = undefined\n state.parentRow = undefined\n state.depth = undefined\n insertIndexes.value = []\n }\n\n return {\n state,\n insertIndexes,\n handleDelete,\n handleInsertChild,\n handleInsertToNext,\n handleInsertToPrev,\n handleCreate,\n handleEdit,\n handleCopy,\n handleClose,\n handleSave\n }\n}\n"],"mappings":";;;;AAOA,SAAS,qBACP,OACA,WACA,aACe;CACf,IAAI,CAAC,UAAU,QAAQ,OAAO,KAAA;CAC9B,IAAI,cAA+B;CACnC,IAAI;CACJ,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;EACzC,MAAM,MAAM,UAAU;EACtB,IAAI,CAAC,aAAa,OAAO,KAAA;EACzB,OAAO,YAAY;EACnB,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;EAC/B,IAAI,IAAI,UAAU,SAAS,GAAG;GAC5B,MAAM,OAAO,KAAK;GAClB,cAAc,MAAM,QAAQ,IAAI,IAAK,OAAe,KAAA;EACtD;CACF;CACA,OAAO;AACT;AAiCA,SAAS,aAAa,MAA4B;CAChD,OAAO,cAAc,KAAK,MAAM,KAAK,UAAU,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACjE;AAEA,SAAS,iBAAiB,OAA4B,MAA2B;CAC/E,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GACjC,OAAO,MAAM;CAEf,OAAO,OAAO,OAAO,IAAI;AAC3B;AAEA,SAAgB,QAAQ,SAAgC;CACtD,MAAM,EAAE,OAAO,MAAM,YAAY;;CAGjC,MAAM,QAAQ,gBAAiC;EAC7C,OAAO,KAAA;EACP,SAAS;EACT,MAAM;EACN,SAAS;CACX,CAAC;CAED,MAAM,gBAAgB,WAAqB,CAAC,CAAC;CAE7C,SAAS,oBAAoB;EAC3B,OA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AkB;EAC3D,MAAM,EAAE,iBAAiB;EAEzB,IAAI,cACF,MAAM,aAAa,CAAC,IAAI,IAAI,CAAC;EAG/B,MAAM,OAAO,CAAC,GAAI,MAAM,QAAQ,CAAC,CAAE;EAEnC,MAAM,SAAS,qBAAqB,MAAM,IAAI,QAAQ,MAAM,GAAG,EAAE,GAAG,YAAY,KAAK;EAErF,IAAI,QAAQ;GACV,MAAM,WAAW,OAAO,YAAY;GACpC,IAAI,UACF,SAAS,OAAO,IAAI,OAAO,CAAC;QAE5B,QAAQ,MAAM,QAAQ;EAE1B,OACE,KAAK,OAAO,IAAI,OAAO,CAAC;EAG1B,IAAI,MAAM,QAAQ,KAAK;GACrB,MAAM,MAAM,KAAA;GACZ,MAAM,QAAQ,KAAA;EAChB;EAEA,KAAK,eAAe,IAAI;CAC1B,CAAC;CAED,SAAS,cAAc;EACrB,MAAM,UAAU;EAChB,IAAI,MAAM,KACR,MAAM,IAAI,YAAY;EAExB,MAAM,MAAM,KAAA;EACZ,MAAM,YAAY,KAAA;EAClB,MAAM,QAAQ,KAAA;EACd,cAAc,QAAQ,CAAC;CACzB;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EmptyProps } from "../../types/empty.js";
|
|
2
2
|
//#region src/components/empty/empty.vue.d.ts
|
|
3
3
|
declare const __VLS_export: import("vue").DefineComponent<EmptyProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EmptyProps> & Readonly<{}>, {
|
|
4
|
-
text: string;
|
|
5
4
|
size: number;
|
|
5
|
+
text: string;
|
|
6
6
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
7
|
declare const _default: typeof __VLS_export;
|
|
8
8
|
//#endregion
|
|
@@ -17,19 +17,19 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, _Inpu
|
|
|
17
17
|
"update:modelValue": (value: string) => any;
|
|
18
18
|
clear: () => any;
|
|
19
19
|
change: (value: string) => any;
|
|
20
|
-
focus: (value?: string | undefined) => any;
|
|
21
|
-
blur: (value?: string | undefined) => any;
|
|
22
20
|
"suffix:click": (value?: string | undefined) => any;
|
|
23
21
|
"prefix:click": (value?: string | undefined) => any;
|
|
22
|
+
focus: (value?: string | undefined) => any;
|
|
23
|
+
blur: (value?: string | undefined) => any;
|
|
24
24
|
"native:input": (ev: Event) => any;
|
|
25
25
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
26
26
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
27
27
|
onClear?: (() => any) | undefined;
|
|
28
28
|
onChange?: ((value: string) => any) | undefined;
|
|
29
|
-
onFocus?: ((value?: string | undefined) => any) | undefined;
|
|
30
|
-
onBlur?: ((value?: string | undefined) => any) | undefined;
|
|
31
29
|
"onSuffix:click"?: ((value?: string | undefined) => any) | undefined;
|
|
32
30
|
"onPrefix:click"?: ((value?: string | undefined) => any) | undefined;
|
|
31
|
+
onFocus?: ((value?: string | undefined) => any) | undefined;
|
|
32
|
+
onBlur?: ((value?: string | undefined) => any) | undefined;
|
|
33
33
|
"onNative:input"?: ((ev: Event) => any) | undefined;
|
|
34
34
|
}>, {
|
|
35
35
|
placeholder: string;
|
|
@@ -21,9 +21,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
21
21
|
onClear?: (() => any) | undefined;
|
|
22
22
|
onChange?: ((checked: Record<string, any>[]) => any) | undefined;
|
|
23
23
|
}>, {
|
|
24
|
+
expandAll: boolean;
|
|
24
25
|
labelKey: string;
|
|
25
26
|
valueKey: string;
|
|
26
|
-
expandAll: boolean;
|
|
27
27
|
placeholder: string;
|
|
28
28
|
clearable: boolean;
|
|
29
29
|
filterable: boolean;
|
|
@@ -19,9 +19,9 @@ declare const __VLS_base: import("vue").DefineComponent<ProgressNodesProps, {},
|
|
|
19
19
|
"onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
|
|
20
20
|
onClick?: ((node: Record<string, any>, index: number) => any) | undefined;
|
|
21
21
|
}>, {
|
|
22
|
-
colorType: import("@veltra/utils").ColorType;
|
|
23
22
|
labelKey: string;
|
|
24
23
|
valueKey: string;
|
|
24
|
+
colorType: import("@veltra/utils").ColorType;
|
|
25
25
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
26
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
27
27
|
declare const _default: typeof __VLS_export;
|
|
@@ -5,11 +5,11 @@ type __VLS_Slots = {
|
|
|
5
5
|
content(): any;
|
|
6
6
|
};
|
|
7
7
|
declare const __VLS_base: import("vue").DefineComponent<ScrollProps, _ScrollExposed, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
8
|
-
resize: (targets: HTMLElement[]) => any;
|
|
9
8
|
scroll: (position: Required<ScrollPosition>) => any;
|
|
9
|
+
resize: (targets: HTMLElement[]) => any;
|
|
10
10
|
}, string, import("vue").PublicProps, Readonly<ScrollProps> & Readonly<{
|
|
11
|
-
onResize?: ((targets: HTMLElement[]) => any) | undefined;
|
|
12
11
|
onScroll?: ((position: Required<ScrollPosition>) => any) | undefined;
|
|
12
|
+
onResize?: ((targets: HTMLElement[]) => any) | undefined;
|
|
13
13
|
}>, {
|
|
14
14
|
tag: string;
|
|
15
15
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -15,12 +15,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
15
15
|
"update:modelValue": (value: string | undefined) => any;
|
|
16
16
|
} & {
|
|
17
17
|
"update:modelValue": (value: string) => any;
|
|
18
|
-
click: (item: TabItem, index: number) => any;
|
|
19
18
|
close: (item: TabItem, index: number) => any;
|
|
19
|
+
click: (item: TabItem, index: number) => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
21
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
22
|
-
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
23
22
|
onClose?: ((item: TabItem, index: number) => any) | undefined;
|
|
23
|
+
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
closable: boolean;
|
|
26
26
|
position: "top" | "bottom";
|
|
@@ -15,12 +15,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
15
15
|
"update:modelValue": (value: string | undefined) => any;
|
|
16
16
|
} & {
|
|
17
17
|
"update:modelValue": (value: string) => any;
|
|
18
|
-
click: (item: TabItem, index: number) => any;
|
|
19
18
|
close: (item: TabItem, index: number) => any;
|
|
19
|
+
click: (item: TabItem, index: number) => any;
|
|
20
20
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
21
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
22
|
-
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
23
22
|
onClose?: ((item: TabItem, index: number) => any) | undefined;
|
|
23
|
+
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
25
|
closable: boolean;
|
|
26
26
|
position: "left" | "right";
|
|
@@ -10,12 +10,12 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
10
10
|
"update:modelValue": (value: string | undefined) => any;
|
|
11
11
|
} & {
|
|
12
12
|
"update:modelValue": (value: string) => any;
|
|
13
|
-
click: (item: TabItem, index: number) => any;
|
|
14
13
|
close: (item: TabItem, index: number) => any;
|
|
14
|
+
click: (item: TabItem, index: number) => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
16
16
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
17
|
-
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
18
17
|
onClose?: ((item: TabItem, index: number) => any) | undefined;
|
|
18
|
+
onClick?: ((item: TabItem, index: number) => any) | undefined;
|
|
19
19
|
}>, {
|
|
20
20
|
closable: boolean;
|
|
21
21
|
position: "left" | "right" | "top" | "bottom";
|
|
@@ -19,9 +19,9 @@ declare const __VLS_base: import("vue").DefineComponent<TreeProps, _TreeExposed,
|
|
|
19
19
|
"onNode-contextmenu"?: ((event: MouseEvent, node: TreeNode<Record<string, any>>) => any) | undefined;
|
|
20
20
|
"onSelected-synced"?: ((selected?: Record<string, any> | undefined) => any) | undefined;
|
|
21
21
|
}>, {
|
|
22
|
+
expandOnClickNode: boolean;
|
|
22
23
|
labelKey: string;
|
|
23
24
|
valueKey: string;
|
|
24
|
-
expandOnClickNode: boolean;
|
|
25
25
|
childrenKey: string;
|
|
26
26
|
data: Record<string, any>[];
|
|
27
27
|
checkStrictly: boolean;
|
|
@@ -23,9 +23,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
23
23
|
onChange?: ((value?: string | number | undefined, selectedData?: Record<string, any> | undefined) => any) | undefined;
|
|
24
24
|
"onUpdate:text"?: ((text?: string | undefined) => any) | undefined;
|
|
25
25
|
}>, {
|
|
26
|
+
expandAll: boolean;
|
|
26
27
|
labelKey: string;
|
|
27
28
|
valueKey: string;
|
|
28
|
-
expandAll: boolean;
|
|
29
29
|
placeholder: string;
|
|
30
30
|
clearable: boolean;
|
|
31
31
|
filterable: boolean;
|
|
@@ -5,8 +5,8 @@ type __VLS_Slots = {} & {
|
|
|
5
5
|
default?: (props: typeof __VLS_7) => any;
|
|
6
6
|
};
|
|
7
7
|
declare const __VLS_base: import("vue").DefineComponent<WatermarkProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<WatermarkProps> & Readonly<{}>, {
|
|
8
|
-
route: number;
|
|
9
8
|
fontSize: number;
|
|
9
|
+
route: number;
|
|
10
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
11
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
12
12
|
declare const _default: typeof __VLS_export;
|
|
@@ -26,7 +26,7 @@ interface BatchEditProps extends TableProps {
|
|
|
26
26
|
/**
|
|
27
27
|
* 编辑模式
|
|
28
28
|
* @default 'normal'
|
|
29
|
-
* @description `quick`
|
|
29
|
+
* @description `quick` 模式下编辑行时表单实时写回 `row.data`(经 `model` 中转),且不调用 `saveMethod`
|
|
30
30
|
*/
|
|
31
31
|
mode?: BatchEditMode;
|
|
32
32
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/desktop",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src"
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"@cat-kit/core": ">=1.1.6",
|
|
69
69
|
"@cat-kit/excel": ">=1.0.0",
|
|
70
70
|
"@cat-kit/fe": "^1.1.6",
|
|
71
|
-
"@veltra/compositions": "1.2.
|
|
72
|
-
"@veltra/directives": "1.2.
|
|
73
|
-
"@veltra/icons": "1.2.
|
|
74
|
-
"@veltra/styles": "1.2.
|
|
75
|
-
"@veltra/utils": "1.2.
|
|
71
|
+
"@veltra/compositions": "1.2.8",
|
|
72
|
+
"@veltra/directives": "1.2.8",
|
|
73
|
+
"@veltra/icons": "1.2.8",
|
|
74
|
+
"@veltra/styles": "1.2.8",
|
|
75
|
+
"@veltra/utils": "1.2.8",
|
|
76
76
|
"vue": ">=3.5.0"
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<aside :class="cls.e('form')" v-if="state.visible &&
|
|
2
|
+
<aside :class="cls.e('form')" v-if="state.visible && props.model">
|
|
3
3
|
<header :class="cls.e('form-header')">
|
|
4
4
|
<span :class="[cls.e('form-icon'), bem.is(headerInfo.tone)]">
|
|
5
5
|
<u-icon>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<transition name="fade" appear mode="out-in">
|
|
28
28
|
<u-form
|
|
29
29
|
ref="formComponentRef"
|
|
30
|
-
:model="
|
|
30
|
+
:model="props.model"
|
|
31
31
|
:readonly="props.readonly"
|
|
32
32
|
:label-width="props.labelWidth"
|
|
33
33
|
>
|
|
@@ -129,13 +129,6 @@ const isQuick = computed(() => props.mode === 'quick')
|
|
|
129
129
|
const isNormal = computed(() => props.mode !== 'quick')
|
|
130
130
|
const isQuickUpdate = computed(() => isQuick.value && state.type === 'update')
|
|
131
131
|
|
|
132
|
-
const formModel = computed(() => {
|
|
133
|
-
if (isQuick.value && state.type === 'update' && state.row) {
|
|
134
|
-
return state.row.data
|
|
135
|
-
}
|
|
136
|
-
return props.model
|
|
137
|
-
})
|
|
138
|
-
|
|
139
132
|
interface HeaderInfo {
|
|
140
133
|
icon: Component
|
|
141
134
|
title: string
|
|
@@ -102,9 +102,8 @@ export function useEdit(options: Options): EditReturned {
|
|
|
102
102
|
if (row) {
|
|
103
103
|
state.type = 'update'
|
|
104
104
|
state.visible = true
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
105
|
+
// 所有模式下都回填 model,保证表单内条件字段(依赖 model)能响应当前编辑行
|
|
106
|
+
setFormData(row.data)
|
|
108
107
|
} else {
|
|
109
108
|
state.visible = false
|
|
110
109
|
}
|
|
@@ -112,6 +111,29 @@ export function useEdit(options: Options): EditReturned {
|
|
|
112
111
|
{ flush: 'sync' }
|
|
113
112
|
)
|
|
114
113
|
|
|
114
|
+
/**
|
|
115
|
+
* quick + update:model 实时写回 row.data,让表格显示同步更新。
|
|
116
|
+
* normal 模式不写回,需等待保存。
|
|
117
|
+
*
|
|
118
|
+
* 监听源仅限 props.model(deep 遍历仅作用于 model,不触及 row 树);
|
|
119
|
+
* mode/type/row 在回调中读取但不作为依赖,避免行切换等场景误触发。
|
|
120
|
+
*/
|
|
121
|
+
watch(
|
|
122
|
+
() => props.model,
|
|
123
|
+
(model) => {
|
|
124
|
+
const { row, type } = state
|
|
125
|
+
if (props.mode !== 'quick' || type !== 'update' || !row || !model) return
|
|
126
|
+
const data = row.data
|
|
127
|
+
Object.keys(model).forEach((key) => {
|
|
128
|
+
const next = o(model).get(key)
|
|
129
|
+
if (o(data).get(key) !== next) {
|
|
130
|
+
o(data).set(key, next)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
},
|
|
134
|
+
{ deep: true }
|
|
135
|
+
)
|
|
136
|
+
|
|
115
137
|
const childrenKey = computed(() => {
|
|
116
138
|
return typeof props.tree === 'string' ? props.tree : 'children'
|
|
117
139
|
})
|
package/src/types/batch-edit.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface BatchEditProps extends TableProps {
|
|
|
39
39
|
/**
|
|
40
40
|
* 编辑模式
|
|
41
41
|
* @default 'normal'
|
|
42
|
-
* @description `quick`
|
|
42
|
+
* @description `quick` 模式下编辑行时表单实时写回 `row.data`(经 `model` 中转),且不调用 `saveMethod`
|
|
43
43
|
*/
|
|
44
44
|
mode?: BatchEditMode
|
|
45
45
|
/**
|