fast-element-plus 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +2 -0
- package/README.zh.md +2 -0
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.mjs.map +1 -1
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/index.mjs.map +1 -1
- package/dist/components/button/src/button.d.ts +1 -1
- package/dist/components/button/src/button.mjs +5 -3
- package/dist/components/button/src/button.mjs.map +1 -1
- package/dist/components/contextMenu/src/contextMenu.d.ts +4 -4
- package/dist/components/contextMenu/src/contextMenu.type.d.ts +3 -3
- package/dist/components/dialog/index.d.ts +1 -1
- package/dist/components/dialog/index.mjs.map +1 -1
- package/dist/components/dialog/src/dialog.d.ts +7 -7
- package/dist/components/dialog/src/dialog.mjs +35 -29
- package/dist/components/dialog/src/dialog.mjs.map +1 -1
- package/dist/components/drawer/index.d.ts +2 -2
- package/dist/components/drawer/index.mjs.map +1 -1
- package/dist/components/drawer/src/drawer.d.ts +7 -7
- package/dist/components/drawer/src/drawer.mjs +36 -29
- package/dist/components/drawer/src/drawer.mjs.map +1 -1
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/form/index.mjs.map +1 -1
- package/dist/components/form/src/form.d.ts +5 -2
- package/dist/components/form/src/form.mjs.map +1 -1
- package/dist/components/formItemTip/index.d.ts +1 -1
- package/dist/components/formItemTip/index.mjs.map +1 -1
- package/dist/components/icon/index.d.ts +2 -2
- package/dist/components/icon/index.mjs.map +1 -1
- package/dist/components/image/index.d.ts +1 -1
- package/dist/components/image/index.mjs.map +1 -1
- package/dist/components/inputDialogPage/index.d.ts +1 -1
- package/dist/components/inputDialogPage/index.mjs.map +1 -1
- package/dist/components/inputDialogPage/src/inputDialogPage.d.ts +16 -16
- package/dist/components/inputDialogPage/src/inputDialogPage.mjs +5 -3
- package/dist/components/inputDialogPage/src/inputDialogPage.mjs.map +1 -1
- package/dist/components/layoutGrid/src/layoutGrid.mjs.map +1 -1
- package/dist/components/layoutGrid/src/layoutGridItem.mjs.map +1 -1
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/index.mjs.map +1 -1
- package/dist/components/select/src/select.d.ts +15 -14
- package/dist/components/select/src/select.mjs.map +1 -1
- package/dist/components/select/src/select.type.d.ts +4 -4
- package/dist/components/select/src/selectOption.d.ts +5 -5
- package/dist/components/selectPage/index.d.ts +1 -1
- package/dist/components/selectPage/index.mjs.map +1 -1
- package/dist/components/selectPage/src/selectPage.d.ts +10 -10
- package/dist/components/selectPage/src/selectPage.mjs.map +1 -1
- package/dist/components/selectV2/index.d.ts +2 -2
- package/dist/components/selectV2/index.mjs.map +1 -1
- package/dist/components/selectV2/src/selectV2.d.ts +28 -36
- package/dist/components/selectV2/src/selectV2.mjs.map +1 -1
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.mjs.map +1 -1
- package/dist/components/table/src/page.type.d.ts +3 -1
- package/dist/components/table/src/page.type.mjs.map +1 -1
- package/dist/components/table/src/table.d.ts +39 -40
- package/dist/components/table/src/table.mjs +12 -6
- package/dist/components/table/src/table.mjs.map +1 -1
- package/dist/components/table/src/table.state.d.ts +5 -5
- package/dist/components/table/src/table.type.d.ts +13 -10
- package/dist/components/table/src/table.type.mjs.map +1 -1
- package/dist/components/table/src/tableColumn.d.ts +3 -4
- package/dist/components/table/src/tableColumn.mjs +2 -2
- package/dist/components/table/src/tableColumn.mjs.map +1 -1
- package/dist/components/table/src/tableColumnSettingDialog.d.ts +1 -1
- package/dist/components/table/src/tableColumnSettingDialog.mjs +2 -2
- package/dist/components/table/src/tableColumnSettingDialog.mjs.map +1 -1
- package/dist/components/table/src/tableSearchForm.d.ts +1 -1
- package/dist/components/table/src/tableSearchForm.mjs +3 -1
- package/dist/components/table/src/tableSearchForm.mjs.map +1 -1
- package/dist/components/table/src/tableSearchFormItem.mjs.map +1 -1
- package/dist/components/table/src/useTable.d.ts +6 -6
- package/dist/components/table/src/useTable.mjs +5 -3
- package/dist/components/table/src/useTable.mjs.map +1 -1
- package/dist/components/table/utils/table.d.ts +3 -2
- package/dist/components/table/utils/table.mjs +6 -8
- package/dist/components/table/utils/table.mjs.map +1 -1
- package/dist/components/tree/index.d.ts +1 -1
- package/dist/components/tree/index.mjs.map +1 -1
- package/dist/components/tree/src/tree.d.ts +33 -31
- package/dist/components/tree/src/tree.mjs +8 -6
- package/dist/components/tree/src/tree.mjs.map +1 -1
- package/dist/components/tree/src/tree.props.d.ts +1 -4
- package/dist/components/tree/src/tree.type.d.ts +4 -4
- package/dist/components/treeSelect/index.d.ts +1 -1
- package/dist/components/treeSelect/index.mjs.map +1 -1
- package/dist/components/treeSelect/src/treeSelect.d.ts +32 -31
- package/dist/components/treeSelect/src/treeSelect.mjs.map +1 -1
- package/dist/components/upload/index.d.ts +1 -1
- package/dist/components/upload/index.mjs.map +1 -1
- package/dist/components/uploadImage/index.d.ts +1 -1
- package/dist/components/uploadImage/index.mjs.map +1 -1
- package/dist/components/uploadImages/index.d.ts +2 -2
- package/dist/components/uploadImages/index.mjs.map +1 -1
- package/dist/directives/click-icon-copy/index.mjs.map +1 -1
- package/dist/index.global.min.js +4 -4
- package/dist/index.global.min.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useGlobalSize } from "element-plus";
|
|
2
|
-
import {
|
|
2
|
+
import type { TableInstance } from "element-plus";
|
|
3
|
+
import type { ExtractPropTypes, InjectionKey, Ref, SetupContext } from "vue";
|
|
4
|
+
import type { makeSlots } from "../../../utils";
|
|
3
5
|
import type { PagedInput } from "./page.type";
|
|
4
6
|
import type { FaTableSlots, faTableEmits, faTableProps } from "./table";
|
|
5
|
-
import type {
|
|
7
|
+
import type { DefaultRow, FaTableState } from "./table.state";
|
|
6
8
|
import type { FaTableColumnCtx, FaTableEnumColumnCtx } from "./table.type";
|
|
7
|
-
import type { TableInstance } from "element-plus";
|
|
8
|
-
import type { ExtractPropTypes, InjectionKey, Ref, SetupContext } from "vue";
|
|
9
9
|
/** FaTable 状态的依赖注入键。 */
|
|
10
10
|
export declare const tableStateKey: InjectionKey<FaTableState>;
|
|
11
11
|
/** FaTable 枚举映射的依赖注入键。 */
|
|
@@ -25,9 +25,9 @@ interface TableComposable {
|
|
|
25
25
|
tableSearch: () => Promise<void>;
|
|
26
26
|
tableReset: () => Promise<void>;
|
|
27
27
|
doRender: () => Promise<void>;
|
|
28
|
-
doLoading: (loadingFunction: () => void | Promise<void>, loadingText?: string) => void
|
|
28
|
+
doLoading: (loadingFunction: () => void | Promise<void>, loadingText?: string) => Promise<void>;
|
|
29
29
|
handleCustomCellClick: (emitName: string, context: {
|
|
30
|
-
row:
|
|
30
|
+
row: DefaultRow;
|
|
31
31
|
column: FaTableColumnCtx;
|
|
32
32
|
$index: number;
|
|
33
33
|
}) => void;
|
|
@@ -364,12 +364,14 @@ const useTable = (props, slots, emit) => {
|
|
|
364
364
|
state.tableData = [];
|
|
365
365
|
await renderTable();
|
|
366
366
|
};
|
|
367
|
-
const doLoading = (loadingFunction, loadingText = "加载中...") => {
|
|
367
|
+
const doLoading = async (loadingFunction, loadingText = "加载中...") => {
|
|
368
368
|
state.loading = true;
|
|
369
369
|
state.loadingText = loadingText;
|
|
370
|
-
|
|
370
|
+
try {
|
|
371
|
+
await callOptionalFunction(loadingFunction);
|
|
372
|
+
} finally {
|
|
371
373
|
state.loading = false;
|
|
372
|
-
}
|
|
374
|
+
}
|
|
373
375
|
};
|
|
374
376
|
const handleCustomCellClick = (emitName, { row, column, $index }) => {
|
|
375
377
|
emit("customCellClick", emitName, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTable.mjs","names":[],"sources":["../../../../src/components/table/src/useTable.ts"],"sourcesContent":["import { computed, nextTick, provide, reactive, ref, watch } from \"vue\";\nimport { dayjs, useGlobalSize } from \"element-plus\";\nimport { isArray, isFunction } from \"lodash-unified\";\nimport { callOptionalFunction, debounce, type makeSlots } from \"../../../utils\";\nimport { tableUtil } from \"../utils/table\";\nimport { getTableDefaultSlots } from \"./table.type\";\nimport type { PagedInput, PagedResult } from \"./page.type\";\nimport type { FaTableSlots, faTableEmits, faTableProps } from \"./table\";\nimport type { FaTableRow, FaTableState } from \"./table.state\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx } from \"./table.type\";\nimport type { TableInstance } from \"element-plus\";\nimport type { ExtractPropTypes, InjectionKey, Ref, SetupContext } from \"vue\";\n\n/** FaTable 状态的依赖注入键。 */\nexport const tableStateKey: InjectionKey<FaTableState> = Symbol(\"tableState\");\n/** FaTable 枚举映射的依赖注入键。 */\nexport const enumMapKey: InjectionKey<Map<string, FaTableEnumColumnCtx[]>> = Symbol(\"enumMap\");\n\ntype TableSetupContext = SetupContext<typeof faTableEmits, ReturnType<typeof makeSlots<FaTableSlots>>>;\n\ninterface TableComposable {\n\t_globalSize: ReturnType<typeof useGlobalSize>;\n\tstate: FaTableState;\n\telementRef: Ref<HTMLElement | undefined>;\n\ttableRef: Ref<TableInstance | undefined>;\n\thandleTableColumnAutoWidth: () => void;\n\tgetRequestParam: () => PagedInput;\n\tloadTableColumns: () => void;\n\thandleSizeChange: (pageSize: number) => void;\n\thandlePaginationChange: (value: number) => void;\n\tdefaultSearchTime: () => void;\n\ttableSearch: () => Promise<void>;\n\ttableReset: () => Promise<void>;\n\tdoRender: () => Promise<void>;\n\tdoLoading: (loadingFunction: () => void | Promise<void>, loadingText?: string) => void;\n\thandleCustomCellClick: (emitName: string, context: { row: FaTableRow; column: FaTableColumnCtx; $index: number }) => void;\n}\n\n/**\n * 创建 FaTable 的状态和操作方法。\n *\n * @param props - FaTable 的 Props。\n * @param slots - FaTable 的插槽。\n * @param emit - FaTable 的事件触发器。\n * @returns FaTable 的状态、引用和操作方法。\n */\nexport const useTable = (\n\tprops: ExtractPropTypes<typeof faTableProps>,\n\tslots: TableSetupContext[\"slots\"],\n\temit: TableSetupContext[\"emit\"]\n): TableComposable => {\n\tconst _globalSize = useGlobalSize();\n\n\tconst elementRef = ref<HTMLElement>();\n\tconst tableRef = ref<TableInstance>();\n\n\t/**\n\t * 定义 enumMap 存储 enum 值(避免异步请求无法格式化单元格内容 || 无法填充搜索下拉选择)\n\t */\n\tconst enumMap = reactive(new Map<string, FaTableEnumColumnCtx[]>());\n\tprovide(enumMapKey, enumMap);\n\n\tconst state: FaTableState = reactive({\n\t\tloading: false,\n\t\tloadingText: \"加载中...\",\n\t\torgColumns: [],\n\t\ttableColumns: computed(() => state.orgColumns.filter((f) => f.prop && !f.pureSearch)),\n\t\tsearchColumns: computed(() =>\n\t\t\tstate.orgColumns\n\t\t\t\t.filter((item) => item.pureSearch === true || item.search !== undefined)\n\t\t\t\t.sort((a, b) => {\n\t\t\t\t\treturn (a.search?.order ?? 0) - (b.search?.order ?? 0);\n\t\t\t\t})\n\t\t),\n\t\tspanColumns: computed(() => [\n\t\t\t...state.orgColumns.flatMap((column) => (column.spanProp ? [{ prop: column.prop ?? \"\", spanProp: column.spanProp }] : [])),\n\t\t\t...(props.props.span\n\t\t\t\t? [\n\t\t\t\t\t\t{ prop: \"__table-index\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-selection\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-operation\", spanProp: props.props.span },\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t]),\n\t\ttableData: [],\n\t\ttableSpanData: computed(() => {\n\t\t\tif (state.spanColumns?.length > 0 && state.tableData?.length > 0) {\n\t\t\t\tconst result: Record<string, number[]> = {};\n\t\t\t\tconst spanIndexes: Record<string, number> = {};\n\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\tresult[item.prop] = new Array<number>(state.tableData.length).fill(1, 0, 1).fill(0, 1);\n\t\t\t\t\tspanIndexes[item.prop] = 0;\n\t\t\t\t});\n\t\t\t\tfor (let i = 1; i < state.tableData.length; i++) {\n\t\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\t\tconst currentRow = state.tableData[i];\n\t\t\t\t\t\tconst previousRow = state.tableData[i - 1];\n\t\t\t\t\t\tconst spanValues = result[item.prop];\n\t\t\t\t\t\tconst spanIndex = spanIndexes[item.prop];\n\t\t\t\t\t\tif (currentRow === undefined || previousRow === undefined || spanValues === undefined || spanIndex === undefined) return;\n\t\t\t\t\t\tif (currentRow[item.spanProp] === previousRow[item.spanProp]) {\n\t\t\t\t\t\t\tspanValues[spanIndex] = (spanValues[spanIndex] ?? 0) + 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tspanIndexes[item.prop] = i;\n\t\t\t\t\t\t\tspanValues[i] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn {};\n\t\t}),\n\t\ttablePagination: {\n\t\t\tpageIndex: 1,\n\t\t\tpageSize: 20,\n\t\t\ttotalRows: 0,\n\t\t},\n\t\tinitParam: {},\n\t\tsearchParam: {},\n\t\tsearchValueUpdate: \"\",\n\t\tsearchForm: props.searchForm,\n\t\tselected: false,\n\t\tselectedList: [],\n\t\tselectedListIds: computed(() =>\n\t\t\tstate.selectedList.flatMap((item) => {\n\t\t\t\tconst rowKey = isFunction(props.rowKey) ? props.rowKey(item) : tableUtil.handleRowAccordingToProp(item, props.rowKey);\n\t\t\t\treturn typeof rowKey === \"string\" || typeof rowKey === \"number\" ? [rowKey] : [];\n\t\t\t})\n\t\t),\n\t\tindeterminateSelectedListIds: [],\n\t\toperationColumnWidth: computed(() => {\n\t\t\tconst findAutoCol = state.autoColumnWidth.find((f) => f.prop === \"__table-operation\");\n\t\t\tif (findAutoCol) {\n\t\t\t\treturn `${findAutoCol.width}px`;\n\t\t\t}\n\t\t\tswitch (_globalSize.value) {\n\t\t\t\tcase \"large\":\n\t\t\t\tcase \"default\":\n\t\t\t\t\treturn \"54px\";\n\t\t\t\tcase \"small\":\n\t\t\t\t\treturn \"42px\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"auto\";\n\t\t\t}\n\t\t}),\n\t\timagePreview: false,\n\t\tpreviewList: [],\n\t\ttableWidth: 0,\n\t\ttableHeight: 0,\n\t\tautoColumnWidth: [],\n\t});\n\tlet requestVersion = 0;\n\n\tprovide(tableStateKey, state);\n\n\tconst handleTableColumnAutoWidth = (): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tstate.autoColumnWidth = [];\n\t\tconst autoWidthColumns = state.tableColumns.filter((f) => f.autoWidth);\n\t\tif (slots?.operation) {\n\t\t\t// 操作列自动宽度\n\t\t\tautoWidthColumns.push({\n\t\t\t\tprop: \"__table-operation\",\n\t\t\t});\n\t\t}\n\t\tif (autoWidthColumns.length > 0) {\n\t\t\t// padding24/16 + border1\n\t\t\tconst otherWidth = _globalSize.value === \"default\" ? 25 : 17;\n\t\t\tvoid nextTick(() => {\n\t\t\t\tconst tableDom = document.querySelector(`.fa-table__${props.tableKey}`);\n\t\t\t\tif (tableDom) {\n\t\t\t\t\tautoWidthColumns.forEach((item) => {\n\t\t\t\t\t\tconst headerColumnDom = tableDom.querySelector(`.__fa-table__auto-width-column__cell-header__${item?.prop}`);\n\t\t\t\t\t\tconst cellColumnDoms = tableDom.querySelectorAll(`.__fa-table__auto-width-column__cell__${item?.prop}`);\n\t\t\t\t\t\tlet maxWidth = 0;\n\t\t\t\t\t\tif (headerColumnDom) {\n\t\t\t\t\t\t\tmaxWidth = Math.ceil(headerColumnDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (item?.sortable) {\n\t\t\t\t\t\t\t\tmaxWidth += 24;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcellColumnDoms.forEach((cellDom) => {\n\t\t\t\t\t\t\tconst curWidth = Math.ceil(cellDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (curWidth > maxWidth) {\n\t\t\t\t\t\t\t\tmaxWidth = curWidth;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst findInfo = state.autoColumnWidth.find((f) => f.prop === item?.prop);\n\t\t\t\t\t\tif (findInfo) {\n\t\t\t\t\t\t\tfindInfo.width = Math.max(findInfo.width, maxWidth);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (item.prop) {\n\t\t\t\t\t\t\t\tstate.autoColumnWidth.push({\n\t\t\t\t\t\t\t\t\tprop: item.prop,\n\t\t\t\t\t\t\t\t\twidth: maxWidth,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}).finally(() => {\n\t\t\t\tstate.loading = false;\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tstate.loading = false;\n\t};\n\n\tconst handleTableData = (data: FaTableRow[]): FaTableRow[] => {\n\t\tif (props.treeData) {\n\t\t\tconst result: FaTableRow[] = [];\n\t\t\tdata.forEach((row) => {\n\t\t\t\tconst rowList = row[props.props.children ?? \"children\"];\n\t\t\t\tif (isArray(rowList)) {\n\t\t\t\t\t// 如果 rowList 是数组,遍历并合并每个子项\n\t\t\t\t\tconst childRows: unknown[] = rowList;\n\t\t\t\t\tchildRows.forEach((childRow) => {\n\t\t\t\t\t\tresult.push(typeof childRow === \"object\" && childRow !== null ? { ...row, ...childRow } : row);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(typeof rowList === \"object\" && rowList !== null ? { ...row, ...rowList } : row);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t} else {\n\t\t\treturn data;\n\t\t}\n\t};\n\n\tconst getRequestParam = (): PagedInput => {\n\t\tconst params = { ...state.searchParam, ...(props.pagination ? state.tablePagination : {}) };\n\t\t// 删除总条数\n\t\tdelete params.totalRows;\n\t\treturn params;\n\t};\n\n\tconst loadData = async (): Promise<void> => {\n\t\tconst currentRequestVersion = ++requestVersion;\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tif (props.requestApi) {\n\t\t\tconst params = getRequestParam();\n\t\t\temit(\"refresh\", params);\n\t\t\tlet pageData: FaTableRow[];\n\t\t\ttry {\n\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t// 数据回调\n\t\t\t\tprops.dataCallback?.(resData);\n\t\t\t\t// 解析 API 接口返回的分页数据(如果有分页更新分页信息)\n\t\t\t\tif (props.pagination) {\n\t\t\t\t\tif (isArray(resData)) {\n\t\t\t\t\t\tpageData = resData;\n\t\t\t\t\t\tstate.tablePagination.totalRows = resData.length;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst pageRes = resData as PagedResult;\n\t\t\t\t\t\tpageData = pageRes.rows ?? [];\n\t\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\t\tpageIndex: pageRes.pageIndex ?? state.tablePagination.pageIndex,\n\t\t\t\t\t\t\tpageSize: pageRes.pageSize ?? state.tablePagination.pageSize,\n\t\t\t\t\t\t\ttotalRows: pageRes.totalRows ?? pageData.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpageData = resData as FaTableRow[];\n\t\t\t\t\t// 更新分页信息\n\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\t\tpageSize: 0,\n\t\t\t\t\t\ttotalRows: pageData.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tstate.tableData = handleTableData(pageData);\n\t\t\t} catch (error) {\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\tstate.tableData = [];\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tif (currentRequestVersion === requestVersion) state.loading = false;\n\t\t\t}\n\t\t} else {\n\t\t\temit(\"refresh\", { searchValue: state.searchParam.searchValue });\n\t\t\tlet _value = handleTableData([...props.data]);\n\t\t\t_value = _value.filter((f) => {\n\t\t\t\tconst searchValue = state.searchParam.searchValue;\n\t\t\t\tif (typeof searchValue !== \"string\" || searchValue.length === 0) return true;\n\t\t\t\treturn state.tableColumns.some((col) => {\n\t\t\t\t\tconst value = tableUtil.handleRowAccordingToProp(f, col.prop ?? \"\");\n\t\t\t\t\tconst text =\n\t\t\t\t\t\ttypeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\"\n\t\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\treturn text.toLowerCase().includes(searchValue.toLowerCase());\n\t\t\t\t});\n\t\t\t});\n\t\t\tif (isArray(state.searchParam.sortList) && state.searchParam.sortList.length > 0) {\n\t\t\t\t_value = _value.sort(tableUtil.arrayDynamicSort(state.searchParam.sortList));\n\t\t\t}\n\t\t\tif (props.pagination) {\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t\tconst pageStart = (state.tablePagination.pageIndex - 1) * state.tablePagination.pageSize;\n\t\t\t\tconst pageEnd = pageStart + state.tablePagination.pageSize;\n\t\t\t\tstate.tableData = _value.slice(pageStart, pageEnd);\n\t\t\t} else {\n\t\t\t\tstate.tableData = _value;\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\tpageSize: 0,\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstate.loading = false;\n\t\t}\n\t\thandleTableColumnAutoWidth();\n\t};\n\n\tconst cloneColumns = (columns: FaTableColumnCtx[]): FaTableColumnCtx[] =>\n\t\tcolumns.map((column) => ({\n\t\t\t...column,\n\t\t\t...(column.search && { search: { ...column.search, ...(column.search.props && { props: { ...column.search.props } }) } }),\n\t\t\t...(column._children && { _children: cloneColumns(column._children) }),\n\t\t}));\n\n\tconst loadTableColumns = (): void => {\n\t\tlet columns: FaTableColumnCtx[] = props.columns ? cloneColumns(props.columns) : [];\n\t\t// 默认值处理\n\t\tcolumns.forEach((col) => {\n\t\t\t// 处理搜索项的 key 和 label\n\t\t\tif (col.pureSearch || col.search) {\n\t\t\t\tcol.search ??= { el: \"\" };\n\t\t\t\tcol.search.key ??= col.prop;\n\t\t\t\tcol.search.label ??= col.label;\n\t\t\t\t// 处理默认值\n\t\t\t\tif (col.search.key && col.search.defaultValue !== undefined) {\n\t\t\t\t\tstate.searchParam[col.search.key] = col.search.defaultValue;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// 排序\n\t\tcolumns = columns.sort((a, b) => {\n\t\t\treturn (a.order ?? 0) - (b.order ?? 0);\n\t\t});\n\n\t\t// TODO:这里的扁平化暂时没用到\n\t\tstate.orgColumns = tableUtil.flatColumns(columns, enumMap);\n\t};\n\n\tconst handleSizeChange = (pageSize: number): void => {\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tstate.tablePagination.pageSize = pageSize;\n\t\temit(\"sizeChange\", pageSize);\n\t\temit(\"paginationChange\", 1, pageSize);\n\t\tvoid loadData();\n\t};\n\tconst handlePaginationChange = (val: number): void => {\n\t\tstate.tablePagination.pageIndex = val;\n\t\temit(\"paginationChange\", val, state.tablePagination.pageSize);\n\t\tvoid loadData();\n\t};\n\n\tconst updatedTotalParam = (): void => {\n\t\t// 处理查询参数,可以给查询参数加自定义前缀操作\n\t\tconst newSearchParam: Record<string, unknown> = {};\n\t\t// 防止手动清空输入框携带参数(这里可以自定义查询参数前缀)\n\t\tfor (const key in state.searchParam) {\n\t\t\t// * 某些情况下参数为 false/0 也应该携带参数\n\t\t\tif (state.searchParam[key] || state.searchParam[key] === false || state.searchParam[key] === 0) {\n\t\t\t\tnewSearchParam[key] = state.searchParam[key];\n\t\t\t}\n\t\t\t// 处理某些情况下如果为空字符串,其实是不需要传到后端的\n\t\t\telse if (!state.searchParam[key]) {\n\t\t\t\tdelete state.searchParam[key];\n\t\t\t}\n\t\t}\n\t\tObject.assign(state.searchParam, newSearchParam);\n\t};\n\n\tconst defaultSearchTime = (): void => {\n\t\tif (props.hideSearchTime) {\n\t\t\tstate.searchParam.searchTimeList = undefined;\n\t\t} else {\n\t\t\tconst end = new Date();\n\t\t\tconst start = new Date();\n\t\t\tif (props.futureSearchTime) {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.searchParam.searchTimeList = [dayjs(start).format(\"YYYY-MM-DD 00:00:00\"), dayjs(end).format(\"YYYY-MM-DD 23:59:59\")];\n\t\t}\n\t};\n\n\tconst tableSearch = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tupdatedTotalParam();\n\t\tawait loadData();\n\t};\n\tconst renderTable = debounce((): Promise<void> => {\n\t\tloadTableColumns();\n\t\treturn tableSearch();\n\t}, 300);\n\n\tconst tableReset = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\t// 清除搜索条件\n\t\tstate.searchParam = {};\n\t\tdefaultSearchTime();\n\t\t// 重置搜索表单的时候,如果有默认搜索参数,则重置默认的搜索参数\n\t\tif (typeof state.initParam === \"object\" && state.initParam !== null) {\n\t\t\tObject.assign(state.searchParam, state.initParam);\n\t\t}\n\t\temit(\"reset\", state.searchParam);\n\t\tawait loadData();\n\t};\n\n\tconst doRender = async (): Promise<void> => {\n\t\tstate.orgColumns = [];\n\t\tstate.autoColumnWidth = [];\n\t\tstate.tableData = [];\n\t\tawait renderTable();\n\t};\n\n\tconst doLoading = (loadingFunction: () => void | Promise<void>, loadingText = \"加载中...\"): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = loadingText;\n\t\tvoid callOptionalFunction(loadingFunction).finally(() => {\n\t\t\tstate.loading = false;\n\t\t});\n\t};\n\n\tconst handleCustomCellClick = (\n\t\temitName: string,\n\t\t{ row, column, $index }: { row: FaTableRow; column: FaTableColumnCtx; $index: number }\n\t): void => {\n\t\temit(\"customCellClick\", emitName, { row, column, $index, ...getTableDefaultSlots(state) });\n\t};\n\n\twatch(\n\t\t() => props.tableKey,\n\t\t() => doRender()\n\t);\n\n\twatch(\n\t\t() => props.searchForm,\n\t\t(newValue) => {\n\t\t\tstate.searchForm = newValue;\n\t\t}\n\t);\n\n\treturn {\n\t\t_globalSize,\n\t\tstate,\n\t\telementRef,\n\t\ttableRef,\n\t\thandleTableColumnAutoWidth,\n\t\tgetRequestParam,\n\t\tloadTableColumns,\n\t\thandleSizeChange,\n\t\thandlePaginationChange,\n\t\tdefaultSearchTime,\n\t\ttableSearch,\n\t\ttableReset,\n\t\tdoRender,\n\t\tdoLoading,\n\t\thandleCustomCellClick,\n\t};\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,gBAA4C,OAAO,YAAY;;AAE5E,MAAa,aAAgE,OAAO,SAAS;;;;;;;;;AA8B7F,MAAa,YACZ,OACA,OACA,SACqB;CACrB,MAAM,cAAc,cAAc;CAElC,MAAM,aAAa,IAAiB;CACpC,MAAM,WAAW,IAAmB;;;;CAKpC,MAAM,UAAU,yBAAS,IAAI,IAAoC,CAAC;CAClE,QAAQ,YAAY,OAAO;CAE3B,MAAM,QAAsB,SAAS;EACpC,SAAS;EACT,aAAa;EACb,YAAY,CAAC;EACb,cAAc,eAAe,MAAM,WAAW,QAAQ,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC;EACpF,eA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AAY,MAAM,cAAc,MAC9D,OAAO,OAAO,MAAM,aAAa,MAAM,SAAS;EAEjD,KAAK,SAAS,MAAM,WAAW;EAC/B,MAAM,SAAS;CAChB;CAEA,MAAM,WAAW,YAA2B;EAC3C,MAAM,aAAa,CAAC;EACpB,MAAM,kBAAkB,CAAC;EACzB,MAAM,YAAY,CAAC;EACnB,MAAM,YAAY;CACnB;CAEA,MAAM,aAAa,iBAA6C,cAAc,aAAmB;EAChG,MAAM,UAAU;EAChB,MAAM,cAAc;EACpB,qBAA0B,eAAe,CAAC,CAAC,cAAc;GACxD,MAAM,UAAU;EACjB,CAAC;CACF;CAEA,MAAM,yBACL,UACA,EAAE,KAAK,QAAQ,aACL;EACV,KAAK,mBAAmB,UAAU;GAAE;GAAK;GAAQ;GAAQ,GAAG,qBAAqB,KAAK;EAAE,CAAC;CAC1F;CAEA,YACO,MAAM,gBACN,SAAS,CAChB;CAEA,YACO,MAAM,aACX,aAAa;EACb,MAAM,aAAa;CACpB,CACD;CAEA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"useTable.mjs","names":[],"sources":["../../../../src/components/table/src/useTable.ts"],"sourcesContent":["import { computed, nextTick, provide, reactive, ref, watch } from \"vue\";\nimport { dayjs, useGlobalSize } from \"element-plus\";\nimport { isArray, isFunction } from \"lodash-unified\";\nimport { callOptionalFunction, debounce } from \"../../../utils\";\nimport { tableUtil } from \"../utils/table\";\nimport { getTableDefaultSlots } from \"./table.type\";\nimport type { TableInstance } from \"element-plus\";\nimport type { ExtractPropTypes, InjectionKey, Ref, SetupContext } from \"vue\";\nimport type { makeSlots } from \"../../../utils\";\nimport type { PagedInput, PagedResult } from \"./page.type\";\nimport type { FaTableSlots, faTableEmits, faTableProps } from \"./table\";\nimport type { DefaultRow, FaTableState } from \"./table.state\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx } from \"./table.type\";\n\n/** FaTable 状态的依赖注入键。 */\nexport const tableStateKey: InjectionKey<FaTableState> = Symbol(\"tableState\");\n/** FaTable 枚举映射的依赖注入键。 */\nexport const enumMapKey: InjectionKey<Map<string, FaTableEnumColumnCtx[]>> = Symbol(\"enumMap\");\n\ntype TableSetupContext = SetupContext<typeof faTableEmits, ReturnType<typeof makeSlots<FaTableSlots>>>;\n\ninterface TableComposable {\n\t_globalSize: ReturnType<typeof useGlobalSize>;\n\tstate: FaTableState;\n\telementRef: Ref<HTMLElement | undefined>;\n\ttableRef: Ref<TableInstance | undefined>;\n\thandleTableColumnAutoWidth: () => void;\n\tgetRequestParam: () => PagedInput;\n\tloadTableColumns: () => void;\n\thandleSizeChange: (pageSize: number) => void;\n\thandlePaginationChange: (value: number) => void;\n\tdefaultSearchTime: () => void;\n\ttableSearch: () => Promise<void>;\n\ttableReset: () => Promise<void>;\n\tdoRender: () => Promise<void>;\n\tdoLoading: (loadingFunction: () => void | Promise<void>, loadingText?: string) => Promise<void>;\n\thandleCustomCellClick: (emitName: string, context: { row: DefaultRow; column: FaTableColumnCtx; $index: number }) => void;\n}\n\n/**\n * 创建 FaTable 的状态和操作方法。\n *\n * @param props - FaTable 的 Props。\n * @param slots - FaTable 的插槽。\n * @param emit - FaTable 的事件触发器。\n * @returns FaTable 的状态、引用和操作方法。\n */\nexport const useTable = (\n\tprops: ExtractPropTypes<typeof faTableProps>,\n\tslots: TableSetupContext[\"slots\"],\n\temit: TableSetupContext[\"emit\"]\n): TableComposable => {\n\tconst _globalSize = useGlobalSize();\n\n\tconst elementRef = ref<HTMLElement>();\n\tconst tableRef = ref<TableInstance>();\n\n\t/**\n\t * 定义 enumMap 存储 enum 值(避免异步请求无法格式化单元格内容 || 无法填充搜索下拉选择)\n\t */\n\tconst enumMap = reactive(new Map<string, FaTableEnumColumnCtx[]>());\n\tprovide(enumMapKey, enumMap);\n\n\tconst state: FaTableState = reactive({\n\t\tloading: false,\n\t\tloadingText: \"加载中...\",\n\t\torgColumns: [],\n\t\ttableColumns: computed(() => state.orgColumns.filter((f) => f.prop && !f.pureSearch)),\n\t\tsearchColumns: computed(() =>\n\t\t\tstate.orgColumns\n\t\t\t\t.filter((item) => item.pureSearch === true || item.search !== undefined)\n\t\t\t\t.sort((a, b) => {\n\t\t\t\t\treturn (a.search?.order ?? 0) - (b.search?.order ?? 0);\n\t\t\t\t})\n\t\t),\n\t\tspanColumns: computed(() => [\n\t\t\t...state.orgColumns.flatMap((column) => (column.spanProp ? [{ prop: column.prop ?? \"\", spanProp: column.spanProp }] : [])),\n\t\t\t...(props.props.span\n\t\t\t\t? [\n\t\t\t\t\t\t{ prop: \"__table-index\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-selection\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-operation\", spanProp: props.props.span },\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t]),\n\t\ttableData: [],\n\t\ttableSpanData: computed(() => {\n\t\t\tif (state.spanColumns?.length > 0 && state.tableData?.length > 0) {\n\t\t\t\tconst result: Record<string, number[]> = {};\n\t\t\t\tconst spanIndexes: Record<string, number> = {};\n\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\tresult[item.prop] = new Array<number>(state.tableData.length).fill(1, 0, 1).fill(0, 1);\n\t\t\t\t\tspanIndexes[item.prop] = 0;\n\t\t\t\t});\n\t\t\t\tfor (let i = 1; i < state.tableData.length; i++) {\n\t\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\t\tconst currentRow = state.tableData[i];\n\t\t\t\t\t\tconst previousRow = state.tableData[i - 1];\n\t\t\t\t\t\tconst spanValues = result[item.prop];\n\t\t\t\t\t\tconst spanIndex = spanIndexes[item.prop];\n\t\t\t\t\t\tif (currentRow === undefined || previousRow === undefined || spanValues === undefined || spanIndex === undefined) return;\n\t\t\t\t\t\tif (currentRow[item.spanProp] === previousRow[item.spanProp]) {\n\t\t\t\t\t\t\tspanValues[spanIndex] = (spanValues[spanIndex] ?? 0) + 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tspanIndexes[item.prop] = i;\n\t\t\t\t\t\t\tspanValues[i] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn {};\n\t\t}),\n\t\ttablePagination: {\n\t\t\tpageIndex: 1,\n\t\t\tpageSize: 20,\n\t\t\ttotalRows: 0,\n\t\t},\n\t\tinitParam: {},\n\t\tsearchParam: {},\n\t\tsearchValueUpdate: \"\",\n\t\tsearchForm: props.searchForm,\n\t\tselected: false,\n\t\tselectedList: [],\n\t\tselectedListIds: computed(() =>\n\t\t\tstate.selectedList.flatMap((item) => {\n\t\t\t\tconst rowKey: unknown = isFunction(props.rowKey) ? props.rowKey(item) : tableUtil.handleRowAccordingToProp(item, props.rowKey);\n\t\t\t\treturn typeof rowKey === \"string\" || typeof rowKey === \"number\" ? [rowKey] : [];\n\t\t\t})\n\t\t),\n\t\tindeterminateSelectedListIds: [],\n\t\toperationColumnWidth: computed(() => {\n\t\t\tconst findAutoCol = state.autoColumnWidth.find((f) => f.prop === \"__table-operation\");\n\t\t\tif (findAutoCol) {\n\t\t\t\treturn `${findAutoCol.width}px`;\n\t\t\t}\n\t\t\tswitch (_globalSize.value) {\n\t\t\t\tcase \"large\":\n\t\t\t\tcase \"default\":\n\t\t\t\t\treturn \"54px\";\n\t\t\t\tcase \"small\":\n\t\t\t\t\treturn \"42px\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"auto\";\n\t\t\t}\n\t\t}),\n\t\timagePreview: false,\n\t\tpreviewList: [],\n\t\ttableWidth: 0,\n\t\ttableHeight: 0,\n\t\tautoColumnWidth: [],\n\t});\n\tlet requestVersion = 0;\n\n\tprovide(tableStateKey, state);\n\n\tconst handleTableColumnAutoWidth = (): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tstate.autoColumnWidth = [];\n\t\tconst autoWidthColumns = state.tableColumns.filter((f) => f.autoWidth);\n\t\tif (slots?.operation) {\n\t\t\t// 操作列自动宽度\n\t\t\tautoWidthColumns.push({\n\t\t\t\tprop: \"__table-operation\",\n\t\t\t});\n\t\t}\n\t\tif (autoWidthColumns.length > 0) {\n\t\t\t// padding24/16 + border1\n\t\t\tconst otherWidth = _globalSize.value === \"default\" ? 25 : 17;\n\t\t\tvoid nextTick(() => {\n\t\t\t\tconst tableDom = document.querySelector(`.fa-table__${props.tableKey}`);\n\t\t\t\tif (tableDom) {\n\t\t\t\t\tautoWidthColumns.forEach((item) => {\n\t\t\t\t\t\tconst headerColumnDom = tableDom.querySelector(`.__fa-table__auto-width-column__cell-header__${item?.prop}`);\n\t\t\t\t\t\tconst cellColumnDoms = tableDom.querySelectorAll(`.__fa-table__auto-width-column__cell__${item?.prop}`);\n\t\t\t\t\t\tlet maxWidth = 0;\n\t\t\t\t\t\tif (headerColumnDom) {\n\t\t\t\t\t\t\tmaxWidth = Math.ceil(headerColumnDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (item?.sortable) {\n\t\t\t\t\t\t\t\tmaxWidth += 24;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcellColumnDoms.forEach((cellDom) => {\n\t\t\t\t\t\t\tconst curWidth = Math.ceil(cellDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (curWidth > maxWidth) {\n\t\t\t\t\t\t\t\tmaxWidth = curWidth;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst findInfo = state.autoColumnWidth.find((f) => f.prop === item?.prop);\n\t\t\t\t\t\tif (findInfo) {\n\t\t\t\t\t\t\tfindInfo.width = Math.max(findInfo.width, maxWidth);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (item.prop) {\n\t\t\t\t\t\t\t\tstate.autoColumnWidth.push({\n\t\t\t\t\t\t\t\t\tprop: item.prop,\n\t\t\t\t\t\t\t\t\twidth: maxWidth,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}).finally(() => {\n\t\t\t\tstate.loading = false;\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tstate.loading = false;\n\t};\n\n\tconst handleTableData = (data: DefaultRow[]): DefaultRow[] => {\n\t\tif (props.treeData) {\n\t\t\tconst result: DefaultRow[] = [];\n\t\t\tdata.forEach((row) => {\n\t\t\t\tconst rowList: unknown = row[props.props.children ?? \"children\"];\n\t\t\t\tif (isArray(rowList)) {\n\t\t\t\t\t// 如果 rowList 是数组,遍历并合并每个子项\n\t\t\t\t\tconst childRows: unknown[] = rowList;\n\t\t\t\t\tchildRows.forEach((childRow) => {\n\t\t\t\t\t\tresult.push(typeof childRow === \"object\" && childRow !== null ? { ...row, ...childRow } : row);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(typeof rowList === \"object\" && rowList !== null ? { ...row, ...rowList } : row);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t} else {\n\t\t\treturn data;\n\t\t}\n\t};\n\n\tconst getRequestParam = (): PagedInput => {\n\t\tconst params = { ...state.searchParam, ...(props.pagination ? state.tablePagination : {}) };\n\t\t// 删除总条数\n\t\tdelete params.totalRows;\n\t\treturn params;\n\t};\n\n\tconst loadData = async (): Promise<void> => {\n\t\tconst currentRequestVersion = ++requestVersion;\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tif (props.requestApi) {\n\t\t\tconst params = getRequestParam();\n\t\t\temit(\"refresh\", params);\n\t\t\tlet pageData: DefaultRow[];\n\t\t\ttry {\n\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t// 数据回调\n\t\t\t\tprops.dataCallback?.(resData);\n\t\t\t\t// 解析 API 接口返回的分页数据(如果有分页更新分页信息)\n\t\t\t\tif (props.pagination) {\n\t\t\t\t\tif (isArray(resData)) {\n\t\t\t\t\t\tpageData = resData;\n\t\t\t\t\t\tstate.tablePagination.totalRows = resData.length;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst pageRes = resData as PagedResult;\n\t\t\t\t\t\tpageData = pageRes.rows ?? [];\n\t\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\t\tpageIndex: pageRes.pageIndex ?? state.tablePagination.pageIndex,\n\t\t\t\t\t\t\tpageSize: pageRes.pageSize ?? state.tablePagination.pageSize,\n\t\t\t\t\t\t\ttotalRows: pageRes.totalRows ?? pageData.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpageData = resData as DefaultRow[];\n\t\t\t\t\t// 更新分页信息\n\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\t\tpageSize: 0,\n\t\t\t\t\t\ttotalRows: pageData.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tstate.tableData = handleTableData(pageData);\n\t\t\t} catch (error) {\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\tstate.tableData = [];\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tif (currentRequestVersion === requestVersion) state.loading = false;\n\t\t\t}\n\t\t} else {\n\t\t\temit(\"refresh\", { searchValue: state.searchParam.searchValue });\n\t\t\tlet _value = handleTableData([...props.data]);\n\t\t\t_value = _value.filter((f) => {\n\t\t\t\tconst searchValue = state.searchParam.searchValue;\n\t\t\t\tif (typeof searchValue !== \"string\" || searchValue.length === 0) return true;\n\t\t\t\treturn state.tableColumns.some((col) => {\n\t\t\t\t\tconst value: unknown = tableUtil.handleRowAccordingToProp(f, col.prop ?? \"\");\n\t\t\t\t\tconst text =\n\t\t\t\t\t\ttypeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\"\n\t\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\treturn text.toLowerCase().includes(searchValue.toLowerCase());\n\t\t\t\t});\n\t\t\t});\n\t\t\tif (isArray(state.searchParam.sortList) && state.searchParam.sortList.length > 0) {\n\t\t\t\t_value = _value.sort(tableUtil.arrayDynamicSort(state.searchParam.sortList));\n\t\t\t}\n\t\t\tif (props.pagination) {\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t\tconst pageStart = (state.tablePagination.pageIndex - 1) * state.tablePagination.pageSize;\n\t\t\t\tconst pageEnd = pageStart + state.tablePagination.pageSize;\n\t\t\t\tstate.tableData = _value.slice(pageStart, pageEnd);\n\t\t\t} else {\n\t\t\t\tstate.tableData = _value;\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\tpageSize: 0,\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstate.loading = false;\n\t\t}\n\t\thandleTableColumnAutoWidth();\n\t};\n\n\tconst cloneColumns = (columns: FaTableColumnCtx[]): FaTableColumnCtx[] =>\n\t\tcolumns.map((column) => ({\n\t\t\t...column,\n\t\t\t...(column.search && { search: { ...column.search, ...(column.search.props && { props: { ...column.search.props } }) } }),\n\t\t\t...(column._children && { _children: cloneColumns(column._children) }),\n\t\t}));\n\n\tconst loadTableColumns = (): void => {\n\t\tlet columns: FaTableColumnCtx[] = props.columns ? cloneColumns(props.columns) : [];\n\t\t// 默认值处理\n\t\tcolumns.forEach((col) => {\n\t\t\t// 处理搜索项的 key 和 label\n\t\t\tif (col.pureSearch || col.search) {\n\t\t\t\tcol.search ??= { el: \"\" };\n\t\t\t\tcol.search.key ??= col.prop;\n\t\t\t\tcol.search.label ??= col.label;\n\t\t\t\t// 处理默认值\n\t\t\t\tif (col.search.key && col.search.defaultValue !== undefined) {\n\t\t\t\t\tstate.searchParam[col.search.key] = col.search.defaultValue;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// 排序\n\t\tcolumns = columns.sort((a, b) => {\n\t\t\treturn (a.order ?? 0) - (b.order ?? 0);\n\t\t});\n\n\t\t// TODO:这里的扁平化暂时没用到\n\t\tstate.orgColumns = tableUtil.flatColumns(columns, enumMap);\n\t};\n\n\tconst handleSizeChange = (pageSize: number): void => {\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tstate.tablePagination.pageSize = pageSize;\n\t\temit(\"sizeChange\", pageSize);\n\t\temit(\"paginationChange\", 1, pageSize);\n\t\tvoid loadData();\n\t};\n\tconst handlePaginationChange = (val: number): void => {\n\t\tstate.tablePagination.pageIndex = val;\n\t\temit(\"paginationChange\", val, state.tablePagination.pageSize);\n\t\tvoid loadData();\n\t};\n\n\tconst updatedTotalParam = (): void => {\n\t\t// 处理查询参数,可以给查询参数加自定义前缀操作\n\t\tconst newSearchParam: Record<string, unknown> = {};\n\t\t// 防止手动清空输入框携带参数(这里可以自定义查询参数前缀)\n\t\tfor (const key in state.searchParam) {\n\t\t\t// * 某些情况下参数为 false/0 也应该携带参数\n\t\t\tif (state.searchParam[key] || state.searchParam[key] === false || state.searchParam[key] === 0) {\n\t\t\t\tnewSearchParam[key] = state.searchParam[key];\n\t\t\t}\n\t\t\t// 处理某些情况下如果为空字符串,其实是不需要传到后端的\n\t\t\telse if (!state.searchParam[key]) {\n\t\t\t\tdelete state.searchParam[key];\n\t\t\t}\n\t\t}\n\t\tObject.assign(state.searchParam, newSearchParam);\n\t};\n\n\tconst defaultSearchTime = (): void => {\n\t\tif (props.hideSearchTime) {\n\t\t\tstate.searchParam.searchTimeList = undefined;\n\t\t} else {\n\t\t\tconst end = new Date();\n\t\t\tconst start = new Date();\n\t\t\tif (props.futureSearchTime) {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.searchParam.searchTimeList = [dayjs(start).format(\"YYYY-MM-DD 00:00:00\"), dayjs(end).format(\"YYYY-MM-DD 23:59:59\")];\n\t\t}\n\t};\n\n\tconst tableSearch = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tupdatedTotalParam();\n\t\tawait loadData();\n\t};\n\tconst renderTable = debounce((): Promise<void> => {\n\t\tloadTableColumns();\n\t\treturn tableSearch();\n\t}, 300);\n\n\tconst tableReset = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\t// 清除搜索条件\n\t\tstate.searchParam = {};\n\t\tdefaultSearchTime();\n\t\t// 重置搜索表单的时候,如果有默认搜索参数,则重置默认的搜索参数\n\t\tif (typeof state.initParam === \"object\" && state.initParam !== null) {\n\t\t\tObject.assign(state.searchParam, state.initParam);\n\t\t}\n\t\temit(\"reset\", state.searchParam);\n\t\tawait loadData();\n\t};\n\n\tconst doRender = async (): Promise<void> => {\n\t\tstate.orgColumns = [];\n\t\tstate.autoColumnWidth = [];\n\t\tstate.tableData = [];\n\t\tawait renderTable();\n\t};\n\n\tconst doLoading = async (loadingFunction: () => void | Promise<void>, loadingText = \"加载中...\"): Promise<void> => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = loadingText;\n\t\ttry {\n\t\t\tawait callOptionalFunction(loadingFunction);\n\t\t} finally {\n\t\t\tstate.loading = false;\n\t\t}\n\t};\n\n\tconst handleCustomCellClick = (\n\t\temitName: string,\n\t\t{ row, column, $index }: { row: DefaultRow; column: FaTableColumnCtx; $index: number }\n\t): void => {\n\t\temit(\"customCellClick\", emitName, { row, column, $index, ...getTableDefaultSlots(state) });\n\t};\n\n\twatch(\n\t\t() => props.tableKey,\n\t\t() => doRender()\n\t);\n\n\twatch(\n\t\t() => props.searchForm,\n\t\t(newValue) => {\n\t\t\tstate.searchForm = newValue;\n\t\t}\n\t);\n\n\treturn {\n\t\t_globalSize,\n\t\tstate,\n\t\telementRef,\n\t\ttableRef,\n\t\thandleTableColumnAutoWidth,\n\t\tgetRequestParam,\n\t\tloadTableColumns,\n\t\thandleSizeChange,\n\t\thandlePaginationChange,\n\t\tdefaultSearchTime,\n\t\ttableSearch,\n\t\ttableReset,\n\t\tdoRender,\n\t\tdoLoading,\n\t\thandleCustomCellClick,\n\t};\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,gBAA4C,OAAO,YAAY;;AAE5E,MAAa,aAAgE,OAAO,SAAS;;;;;;;;;AA8B7F,MAAa,YACZ,OACA,OACA,SACqB;CACrB,MAAM,cAAc,cAAc;CAElC,MAAM,aAAa,IAAiB;CACpC,MAAM,WAAW,IAAmB;;;;CAKpC,MAAM,UAAU,yBAAS,IAAI,IAAoC,CAAC;CAClE,QAAQ,YAAY,OAAO;CAE3B,MAAM,QAAsB,SAAS;EACpC,SAAS;EACT,aAAa;EACb,YAAY,CAAC;EACb,cAAc,eAAe,MAAM,WAAW,QAAQ,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC;EACpF,eAAe,eACd,MAAM,WACJ,QAAQ,SAAS,KAAK,eAAe,QAAQ,KAAK,WAAW,KAAA,CAAS,CAAC,CACvE,MAAM,GAAG,MAAM;GACf,QAAQ,EAAE,QAAQ,SAAS,MAAM,EAAE,QAAQ,SAAS;EACrD,CAAC,CACH;EACA,aAAa,eAAe,CAC3B,GAAG,MAAM,WAAW,SAAS,WAAY,OAAO,WAAW,CAAC;GAAE,MAAM,OAAO,QAAQ;GAAI,UAAU,OAAO;EAAS,CAAC,IAAI,CAAC,CAAE,GACzH,GAAI,MA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ACH,MAAM,qBAAqB,eAAe;EAC3C,UAAU;GACT,MAAM,UAAU;EACjB;CACD;CAEA,MAAM,yBACL,UACA,EAAE,KAAK,QAAQ,aACL;EACV,KAAK,mBAAmB,UAAU;GAAE;GAAK;GAAQ;GAAQ,GAAG,qBAAqB,KAAK;EAAE,CAAC;CAC1F;CAEA,YACO,MAAM,gBACN,SAAS,CAChB;CAEA,YACO,MAAM,aACX,aAAa;EACb,MAAM,aAAa;CACpB,CACD;CAEA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PagedSortInput } from "../src/page.type";
|
|
2
|
+
import type { DefaultRow } from "../src/table.state";
|
|
2
3
|
import type { FaTableColumnCtx, FaTableEnumColumnCtx, FaTableEnumColumnType } from "../src/table.type";
|
|
3
4
|
/**
|
|
4
5
|
* 表格工具类
|
|
@@ -14,7 +15,7 @@ export declare const tableUtil: {
|
|
|
14
15
|
* @param {Object} row 当前行数据
|
|
15
16
|
* @param {String} prop 当前 prop
|
|
16
17
|
*/
|
|
17
|
-
handleRowAccordingToProp(row:
|
|
18
|
+
handleRowAccordingToProp(row: DefaultRow, prop: string): unknown;
|
|
18
19
|
/**
|
|
19
20
|
* @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop
|
|
20
21
|
* @param {String} prop 当前 prop
|
|
@@ -34,7 +35,7 @@ export declare const tableUtil: {
|
|
|
34
35
|
/**
|
|
35
36
|
* 数组动态排序
|
|
36
37
|
*/
|
|
37
|
-
arrayDynamicSort(sortList: PagedSortInput[]): (a:
|
|
38
|
+
arrayDynamicSort(sortList: PagedSortInput[]): (a: DefaultRow, b: DefaultRow) => number;
|
|
38
39
|
/**
|
|
39
40
|
* 设置枚举
|
|
40
41
|
*/
|
|
@@ -68,14 +68,12 @@ const tableUtil = {
|
|
|
68
68
|
const comparison = bValue.localeCompare(aValue, "zh-CN");
|
|
69
69
|
if (comparison !== 0) return comparison;
|
|
70
70
|
}
|
|
71
|
-
} else if (
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (aValue < bValue) return 1;
|
|
78
|
-
}
|
|
71
|
+
} else if (order === "ascending") {
|
|
72
|
+
if (aValue < bValue) return -1;
|
|
73
|
+
if (aValue > bValue) return 1;
|
|
74
|
+
} else if (order === "descending") {
|
|
75
|
+
if (aValue > bValue) return -1;
|
|
76
|
+
if (aValue < bValue) return 1;
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
return 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.mjs","names":[],"sources":["../../../../src/components/table/utils/table.ts"],"sourcesContent":["import { isArray, isFunction, isString } from \"lodash-unified\";\nimport type { PagedSortInput } from \"../src/page.type\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx, FaTableEnumColumnType } from \"../src/table.type\";\n\n/**\n * 表格工具类\n */\nexport const tableUtil = {\n\t/**\n\t * @description 处理无数据情况\n\t * @param {String} callValue 需要处理的值\n\t */\n\tformatValue(callValue: unknown): unknown {\n\t\t// 如果当前值为数组,使用 / 拼接(根据需求自定义)\n\t\tif (isArray(callValue)) return callValue.length ? callValue.join(` , `) : null;\n\t\treturn callValue;\n\t},\n\t/**\n\t * @description 处理 prop 为多级嵌套的情况(列如: prop:user.name)\n\t * @param {Object} row 当前行数据\n\t * @param {String} prop 当前 prop\n\t */\n\thandleRowAccordingToProp(row:
|
|
1
|
+
{"version":3,"file":"table.mjs","names":[],"sources":["../../../../src/components/table/utils/table.ts"],"sourcesContent":["import { isArray, isFunction, isString } from \"lodash-unified\";\nimport type { PagedSortInput } from \"../src/page.type\";\nimport type { DefaultRow } from \"../src/table.state\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx, FaTableEnumColumnType } from \"../src/table.type\";\n\n/**\n * 表格工具类\n */\nexport const tableUtil = {\n\t/**\n\t * @description 处理无数据情况\n\t * @param {String} callValue 需要处理的值\n\t */\n\tformatValue(callValue: unknown): unknown {\n\t\t// 如果当前值为数组,使用 / 拼接(根据需求自定义)\n\t\tif (isArray(callValue)) return callValue.length ? callValue.join(` , `) : null;\n\t\treturn callValue;\n\t},\n\t/**\n\t * @description 处理 prop 为多级嵌套的情况(列如: prop:user.name)\n\t * @param {Object} row 当前行数据\n\t * @param {String} prop 当前 prop\n\t */\n\thandleRowAccordingToProp(row: DefaultRow, prop: string): unknown {\n\t\tlet value: unknown = row;\n\t\tfor (const item of prop.split(\".\")) {\n\t\t\tif (typeof value !== \"object\" || value === null) return undefined;\n\t\t\tvalue = (value as Record<string, unknown>)[item];\n\t\t}\n\t\treturn value;\n\t},\n\t/**\n\t * @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop\n\t * @param {String} prop 当前 prop\n\t */\n\thandleProp(prop: string): string {\n\t\tconst propArr = prop.split(\".\");\n\t\tif (propArr.length === 1) return prop;\n\t\treturn propArr.at(-1) ?? prop;\n\t},\n\t/**\n\t * @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值,会自动识别格式化)\n\t * @param {String} callValue 当前单元格值\n\t * @param {Array} enumData 字典列表\n\t * @param {Array} fieldNames 指定 label && value 的 key 值\n\t * @param {String} type 过滤类型(目前只有 tag)\n\t */\n\tfilterEnum(callValue: unknown, enumData: FaTableEnumColumnCtx[], fieldNames?: { label: string; value: string }, type?: \"tag\"): unknown {\n\t\tconst value = fieldNames?.value ?? \"value\";\n\t\tconst label = fieldNames?.label ?? \"label\";\n\t\tlet filterData: FaTableEnumColumnCtx | undefined;\n\t\tif (isArray(enumData)) {\n\t\t\tfilterData = enumData.find((item) => item[value] === callValue);\n\t\t}\n\t\tif (type === \"tag\") {\n\t\t\treturn filterData?.type ?? \"info\";\n\t\t}\n\t\treturn filterData ? filterData[label] : null;\n\t},\n\t/**\n\t * 数组动态排序\n\t */\n\tarrayDynamicSort(sortList: PagedSortInput[]): (a: DefaultRow, b: DefaultRow) => number {\n\t\treturn (a, b) => {\n\t\t\tif (sortList && sortList.length > 0) {\n\t\t\t\tfor (const condition of sortList) {\n\t\t\t\t\tconst property = condition.enField;\n\t\t\t\t\tconst order = condition.mode;\n\t\t\t\t\tif (!property) continue;\n\n\t\t\t\t\tconst aValue: unknown = a[property];\n\t\t\t\t\tconst bValue: unknown = b[property];\n\n\t\t\t\t\tif (typeof aValue === \"string\" && typeof bValue === \"string\") {\n\t\t\t\t\t\tif (order === \"ascending\") {\n\t\t\t\t\t\t\tconst comparison = aValue.localeCompare(bValue, \"zh-CN\");\n\t\t\t\t\t\t\tif (comparison !== 0) {\n\t\t\t\t\t\t\t\treturn comparison;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (order === \"descending\") {\n\t\t\t\t\t\t\tconst comparison = bValue.localeCompare(aValue, \"zh-CN\");\n\t\t\t\t\t\t\tif (comparison !== 0) {\n\t\t\t\t\t\t\t\treturn comparison;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (order === \"ascending\") {\n\t\t\t\t\t\t\tif ((aValue as string) < (bValue as string)) return -1;\n\t\t\t\t\t\t\tif ((aValue as string) > (bValue as string)) return 1;\n\t\t\t\t\t\t} else if (order === \"descending\") {\n\t\t\t\t\t\t\tif ((aValue as string) > (bValue as string)) return -1;\n\t\t\t\t\t\t\tif ((aValue as string) < (bValue as string)) return 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t};\n\t},\n\t/**\n\t * 设置枚举\n\t */\n\tsetEnumMap(columnEnum: FaTableEnumColumnType, prop: string, enumMap: Map<string, FaTableEnumColumnCtx[]>): void {\n\t\tif (!columnEnum) return;\n\t\tif (isFunction(columnEnum)) {\n\t\t\tenumMap.set(prop, columnEnum());\n\t\t} else if (isArray(columnEnum)) {\n\t\t\tenumMap.set(prop, columnEnum);\n\t\t}\n\t},\n\t/**\n\t * 扁平化 columns\n\t */\n\tflatColumns(columns: FaTableColumnCtx[], enumMap?: Map<string, FaTableEnumColumnCtx[]>): FaTableColumnCtx[] {\n\t\tconst flatArr: FaTableColumnCtx[] = [];\n\t\tcolumns.forEach((col) => {\n\t\t\tif (col._children?.length) {\n\t\t\t\tflatArr.push(...this.flatColumns(col._children));\n\t\t\t}\n\n\t\t\tflatArr.push(col);\n\n\t\t\t// 给每一项 column 添加 show && filterEnum 默认属性\n\t\t\tcol.show ??= true;\n\t\t\t// col.filterEnum = col.filterEnum ?? col.tag ?? false;\n\n\t\t\tlet enumKey = col.prop ?? col.search?.key;\n\n\t\t\tif (col.enum && isString(col.enum)) {\n\t\t\t\tenumKey = col.enum;\n\t\t\t}\n\n\t\t\t// 设置 enumMap\n\t\t\tif (col.enum && enumKey && enumMap) this.setEnumMap(col.enum, enumKey, enumMap);\n\t\t});\n\t\treturn flatArr.filter((item) => !item._children?.length);\n\t},\n};\n"],"mappings":";;;;;AAQA,MAAa,YAAY;;;;;CAKxB,YAAY,WAA6B;EAExC,IAAI,QAAQ,SAAS,GAAG,OAAO,UAAU,SAAS,UAAU,KAAK,KAAK,IAAI;EAC1E,OAAO;CACR;;;;;;CAMA,yBAAyB,KAAiB,MAAuB;EAChE,IAAI,QAAiB;EACrB,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;GACnC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,KAAA;GACxD,QAAS,MAAkC;EAC5C;EACA,OAAO;CACR;;;;;CAKA,WAAW,MAAsB;EAChC,MAAM,UAAU,KAAK,MAAM,GAAG;EAC9B,IAAI,QAAQ,WAAW,GAAG,OAAO;EACjC,OAAO,QAAQ,GAAG,EAAE,KAAK;CAC1B;;;;;;;;CAQA,WAAW,WAAoB,UAAkC,YAA+C,MAAuB;EACtI,MAAM,QAAQ,YAAY,SAAS;EACnC,MAAM,QAAQ,YA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SAAS,CAAC;GAGhD,QAAQ,KAAK,GAAG;GAGhB,IAAI,SAAS;GAGb,IAAI,UAAU,IAAI,QAAQ,IAAI,QAAQ;GAEtC,IAAI,IAAI,QAAQ,SAAS,IAAI,IAAI,GAChC,UAAU,IAAI;GAIf,IAAI,IAAI,QAAQ,WAAW,SAAS,KAAK,WAAW,IAAI,MAAM,SAAS,OAAO;EAC/E,CAAC;EACD,OAAO,QAAQ,QAAQ,SAAS,CAAC,KAAK,WAAW,MAAM;CACxD;AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Tree, { faTreeEmits, faTreeProps } from "./src/tree";
|
|
2
|
-
import type { TSXWithInstall } from "../../utils";
|
|
3
2
|
import type { ExtractPropTypes } from "vue";
|
|
3
|
+
import type { TSXWithInstall } from "../../utils";
|
|
4
4
|
/** 支持远程加载、筛选和节点操作的树组件。 */
|
|
5
5
|
export declare const FaTree: TSXWithInstall<typeof Tree>;
|
|
6
6
|
export default FaTree;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Tree"],"sources":["../../../src/components/tree/index.ts"],"sourcesContent":["import { withInstall } from \"../../utils\";\nimport Tree, { faTreeEmits, faTreeProps } from \"./src/tree\";\nimport type {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["Tree"],"sources":["../../../src/components/tree/index.ts"],"sourcesContent":["import { withInstall } from \"../../utils\";\nimport Tree, { faTreeEmits, faTreeProps } from \"./src/tree\";\nimport type { ExtractPropTypes } from \"vue\";\nimport type { TSXWithInstall } from \"../../utils\";\n\n/** 支持远程加载、筛选和节点操作的树组件。 */\nexport const FaTree: TSXWithInstall<typeof Tree> = withInstall(Tree);\nexport default FaTree;\n\nexport { faTreeProps, faTreeEmits };\nexport type { FaTreeSlots } from \"./src/tree\";\nexport * from \"./src/tree.type\";\n\n/** FaTree 暴露的组件实例类型。 */\nexport type FaTreeInstance = InstanceType<typeof Tree>;\n\n/** FaTree 的完整 Props 类型。 */\nexport type FaTreeProps = ExtractPropTypes<typeof faTreeProps>;\n\n/** FaTree 的 Emits 类型。 */\nexport type FaTreeEmits = typeof faTreeEmits;\n"],"mappings":";;;;AAMA,MAAa,SAAsC,YAAYA,YAAI"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { FilterValue, TreeNodeData } from "element-plus";
|
|
2
|
+
import type { ComponentInternalInstance } from "vue";
|
|
3
|
+
import type { PagedInput } from "../../table";
|
|
1
4
|
import type { FilterNodeMethodFunction, TreeNode } from "./tree.props";
|
|
2
5
|
import type { ElTreeOutput } from "./tree.type";
|
|
3
|
-
import type { ComponentInternalInstance } from "vue";
|
|
4
6
|
/** FaTree 的运行时 Props 定义。 */
|
|
5
7
|
export declare const faTreeProps: {
|
|
6
8
|
/** 树节点筛选方法。 */
|
|
@@ -59,19 +61,19 @@ export declare const faTreeProps: {
|
|
|
59
61
|
/** @description 全部值 */
|
|
60
62
|
allValue: {
|
|
61
63
|
type: import("vue").PropType<string | number | boolean | object | null>;
|
|
62
|
-
default:
|
|
64
|
+
default: undefined;
|
|
63
65
|
};
|
|
64
66
|
/** @description 树形数据 */
|
|
65
67
|
data: {
|
|
66
|
-
type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue>[]>;
|
|
68
|
+
type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue, any>[]>;
|
|
67
69
|
default: () => ElTreeOutput[];
|
|
68
70
|
};
|
|
69
71
|
/** @description 请求api */
|
|
70
72
|
requestApi: {
|
|
71
|
-
type: import("vue").PropType<(params?:
|
|
73
|
+
type: import("vue").PropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>;
|
|
72
74
|
};
|
|
73
75
|
/** 初始化参数 */
|
|
74
|
-
initParam: import("vue").PropType<
|
|
76
|
+
initParam: import("vue").PropType<string | number | PagedInput>;
|
|
75
77
|
emptyText: {
|
|
76
78
|
readonly type: import("vue").PropType<string>;
|
|
77
79
|
readonly required: false;
|
|
@@ -146,7 +148,7 @@ export declare const faTreeProps: {
|
|
|
146
148
|
/** FaTree 的运行时 Emits 定义。 */
|
|
147
149
|
export declare const faTreeEmits: {
|
|
148
150
|
/** @description v-model 回调 */
|
|
149
|
-
"update:modelValue": (value: string | number | boolean | object | null) => boolean;
|
|
151
|
+
"update:modelValue": (value: string | number | boolean | object | null | undefined) => boolean;
|
|
150
152
|
/** @description v-model:label 回调 */
|
|
151
153
|
"update:label": (value: string) => boolean;
|
|
152
154
|
/** @description 数据改变 */
|
|
@@ -240,19 +242,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
240
242
|
/** @description 全部值 */
|
|
241
243
|
allValue: {
|
|
242
244
|
type: import("vue").PropType<string | number | boolean | object | null>;
|
|
243
|
-
default:
|
|
245
|
+
default: undefined;
|
|
244
246
|
};
|
|
245
247
|
/** @description 树形数据 */
|
|
246
248
|
data: {
|
|
247
|
-
type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue>[]>;
|
|
249
|
+
type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue, any>[]>;
|
|
248
250
|
default: () => ElTreeOutput[];
|
|
249
251
|
};
|
|
250
252
|
/** @description 请求api */
|
|
251
253
|
requestApi: {
|
|
252
|
-
type: import("vue").PropType<(params?:
|
|
254
|
+
type: import("vue").PropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>;
|
|
253
255
|
};
|
|
254
256
|
/** 初始化参数 */
|
|
255
|
-
initParam: import("vue").PropType<
|
|
257
|
+
initParam: import("vue").PropType<string | number | PagedInput>;
|
|
256
258
|
emptyText: {
|
|
257
259
|
readonly type: import("vue").PropType<string>;
|
|
258
260
|
readonly required: false;
|
|
@@ -325,15 +327,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
325
327
|
};
|
|
326
328
|
}>, {
|
|
327
329
|
/** @description 过滤所有树节点,过滤后的节点将被隐藏 */
|
|
328
|
-
filter: import("vue").ComputedRef<((value:
|
|
330
|
+
filter: import("vue").ComputedRef<((value: FilterValue) => void) | undefined>;
|
|
329
331
|
/** @description 获取节点的唯一标识。 */
|
|
330
332
|
getNodeKey: import("vue").ComputedRef<((node: import("element-plus/es/components/tree/src/model/node.mjs").default) => any) | undefined>;
|
|
331
333
|
/** @description 获取指定节点的路径数据。 */
|
|
332
|
-
getNodePath: import("vue").ComputedRef<((data: import("element-plus").TreeKey |
|
|
334
|
+
getNodePath: import("vue").ComputedRef<((data: import("element-plus").TreeKey | TreeNodeData) => TreeNodeData[]) | undefined>;
|
|
333
335
|
/** @description 为节点设置新数据,只有当设置 node-key 属性的时候才可用 */
|
|
334
336
|
updateKeyChildren: import("vue").ComputedRef<((key: import("element-plus").TreeKey, data: import("element-plus").TreeData) => void) | undefined>;
|
|
335
337
|
/** @description 如果节点可以被选中,(show-checkbox 为 true), 本方法将返回当前选中节点的数组 */
|
|
336
|
-
getCheckedNodes: import("vue").ComputedRef<((leafOnly?: boolean, includeHalfChecked?: boolean) =>
|
|
338
|
+
getCheckedNodes: import("vue").ComputedRef<((leafOnly?: boolean, includeHalfChecked?: boolean) => TreeNodeData[]) | undefined>;
|
|
337
339
|
/** @description 设置目前勾选的节点,使用此方法必须提前设置 node-key 属性 */
|
|
338
340
|
setCheckedNodes: import("vue").ComputedRef<((nodes: import("element-plus/es/components/tree/src/model/node.mjs").default[], leafOnly?: boolean) => void) | undefined>;
|
|
339
341
|
/** @description 若节点可用被选中 (show-checkbox 为 true), 它将返回当前选中节点 key 的数组 */
|
|
@@ -341,36 +343,36 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
341
343
|
/** @description 设置目前选中的节点,使用此方法必须设置 node-key 属性 */
|
|
342
344
|
setCheckedKeys: import("vue").ComputedRef<((keys: import("element-plus").TreeKey[], leafOnly?: boolean) => void) | undefined>;
|
|
343
345
|
/** @description 设置节点是否被选中, 使用此方法必须设置 node-key 属性 */
|
|
344
|
-
setChecked: import("vue").ComputedRef<((data: import("element-plus").TreeKey |
|
|
346
|
+
setChecked: import("vue").ComputedRef<((data: import("element-plus").TreeKey | TreeNodeData, checked: boolean, deep?: boolean) => void) | undefined>;
|
|
345
347
|
/** @description 如果节点可用被选中 (show-checkbox 为 true), 它将返回当前半选中的节点组成的数组 */
|
|
346
|
-
getHalfCheckedNodes: import("vue").ComputedRef<(() =>
|
|
348
|
+
getHalfCheckedNodes: import("vue").ComputedRef<(() => TreeNodeData[]) | undefined>;
|
|
347
349
|
/** @description 若节点可被选中(show-checkbox 为 true),则返回目前半选中的节点的 key 所组成的数组 */
|
|
348
350
|
getHalfCheckedKeys: import("vue").ComputedRef<(() => import("element-plus").TreeKey[]) | undefined>;
|
|
349
351
|
/** @description 返回当前被选中节点的数据 (如果没有则返回 null) */
|
|
350
352
|
getCurrentKey: import("vue").ComputedRef<(() => import("element-plus").TreeKey | null) | undefined>;
|
|
351
353
|
/** @description 返回当前被选中节点的数据 (如果没有则返回 null) */
|
|
352
|
-
getCurrentNode: import("vue").ComputedRef<(() =>
|
|
354
|
+
getCurrentNode: import("vue").ComputedRef<(() => TreeNodeData | null) | undefined>;
|
|
353
355
|
/** @description 通过 key 设置某个节点的当前选中状态,使用此方法必须设置 node-key 属性 */
|
|
354
356
|
setCurrentKey: import("vue").ComputedRef<((key?: import("element-plus").TreeKey | null, shouldAutoExpandParent?: boolean) => void) | undefined>;
|
|
355
357
|
/** @description 设置节点为选中状态,使用此方法必须设置 node-key 属性 */
|
|
356
358
|
setCurrentNode: import("vue").ComputedRef<((node: import("element-plus/es/components/tree/src/model/node.mjs").default, shouldAutoExpandParent?: boolean) => void) | undefined>;
|
|
357
359
|
/** @description 根据 data 或者 key 拿到 Tree 组件中的 node */
|
|
358
|
-
getNode: import("vue").ComputedRef<((data: import("element-plus").TreeKey |
|
|
360
|
+
getNode: import("vue").ComputedRef<((data: import("element-plus").TreeKey | TreeNodeData) => import("element-plus/es/components/tree/src/model/node.mjs").default) | undefined>;
|
|
359
361
|
/** @description 删除 Tree 中的一个节点,使用此方法必须设置 node-key 属性 */
|
|
360
|
-
remove: import("vue").ComputedRef<((data:
|
|
362
|
+
remove: import("vue").ComputedRef<((data: TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
|
|
361
363
|
/** @description 为 Tree 中的一个节点追加一个子节点 */
|
|
362
|
-
append: import("vue").ComputedRef<((data:
|
|
364
|
+
append: import("vue").ComputedRef<((data: TreeNodeData, parentNode: TreeNodeData | import("element-plus").TreeKey | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
|
|
363
365
|
/** @description 在 Tree 中给定节点前插入一个节点 */
|
|
364
|
-
insertBefore: import("vue").ComputedRef<((data:
|
|
366
|
+
insertBefore: import("vue").ComputedRef<((data: TreeNodeData, refNode: import("element-plus").TreeKey | TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
|
|
365
367
|
/** @description 在 Tree 中给定节点后插入一个节点 */
|
|
366
|
-
insertAfter: import("vue").ComputedRef<((data:
|
|
368
|
+
insertAfter: import("vue").ComputedRef<((data: TreeNodeData, refNode: import("element-plus").TreeKey | TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
|
|
367
369
|
/** @description 加载状态 */
|
|
368
370
|
loading: import("vue").ComputedRef<boolean>;
|
|
369
371
|
/** @description 刷新 */
|
|
370
372
|
refresh: () => Promise<void>;
|
|
371
373
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
372
374
|
/** @description v-model 回调 */
|
|
373
|
-
"update:modelValue": (value: string | number | boolean | object | null) => boolean;
|
|
375
|
+
"update:modelValue": (value: string | number | boolean | object | null | undefined) => boolean;
|
|
374
376
|
/** @description v-model:label 回调 */
|
|
375
377
|
"update:label": (value: string) => boolean;
|
|
376
378
|
/** @description 数据改变 */
|
|
@@ -448,19 +450,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
448
450
|
/** @description 全部值 */
|
|
449
451
|
allValue: {
|
|
450
452
|
type: import("vue").PropType<string | number | boolean | object | null>;
|
|
451
|
-
default:
|
|
453
|
+
default: undefined;
|
|
452
454
|
};
|
|
453
455
|
/** @description 树形数据 */
|
|
454
456
|
data: {
|
|
455
|
-
type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue>[]>;
|
|
457
|
+
type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue, any>[]>;
|
|
456
458
|
default: () => ElTreeOutput[];
|
|
457
459
|
};
|
|
458
460
|
/** @description 请求api */
|
|
459
461
|
requestApi: {
|
|
460
|
-
type: import("vue").PropType<(params?:
|
|
462
|
+
type: import("vue").PropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>;
|
|
461
463
|
};
|
|
462
464
|
/** 初始化参数 */
|
|
463
|
-
initParam: import("vue").PropType<
|
|
465
|
+
initParam: import("vue").PropType<string | number | PagedInput>;
|
|
464
466
|
emptyText: {
|
|
465
467
|
readonly type: import("vue").PropType<string>;
|
|
466
468
|
readonly required: false;
|
|
@@ -532,12 +534,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
532
534
|
__epPropKey: true;
|
|
533
535
|
};
|
|
534
536
|
}>> & Readonly<{
|
|
535
|
-
onChange?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
|
|
536
|
-
"onUpdate:modelValue"?: ((value: string | number | boolean | object | null) => any) | undefined;
|
|
537
|
+
onChange?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue, any>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
|
|
538
|
+
"onUpdate:modelValue"?: ((value: string | number | boolean | object | null | undefined) => any) | undefined;
|
|
537
539
|
"onCurrent-change"?: ((data: any, node: import("element-plus/es/components/tree/src/model/node.mjs").default | null) => any) | undefined;
|
|
538
540
|
"onUpdate:label"?: ((value: string) => any) | undefined;
|
|
539
|
-
onDataChangeCallBack?: ((data: ElTreeOutput<import("./tree.type").ElTreeValue>[]) => any) | undefined;
|
|
540
|
-
"onNode-click"?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
|
|
541
|
+
onDataChangeCallBack?: ((data: ElTreeOutput<import("./tree.type").ElTreeValue, any>[]) => any) | undefined;
|
|
542
|
+
"onNode-click"?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue, any>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
|
|
541
543
|
"onCheck-change"?: ((data: any, checked: boolean, indeterminate: boolean) => any) | undefined;
|
|
542
544
|
"onNode-contextmenu"?: ((evt: Event, data: any, node: import("element-plus/es/components/tree/src/model/node.mjs").default, nodeInstance: ComponentInternalInstance | null) => any) | undefined;
|
|
543
545
|
"onNode-collapse"?: ((data: any, node: import("element-plus/es/components/tree/src/model/node.mjs").default, nodeInstance: ComponentInternalInstance | null) => any) | undefined;
|
|
@@ -550,7 +552,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
550
552
|
"onNode-drag-enter"?: ((draggingNode: import("element-plus/es/components/tree/src/model/node.mjs").default, dropNode: import("element-plus/es/components/tree/src/model/node.mjs").default, evt: DragEvent) => any) | undefined;
|
|
551
553
|
"onNode-drag-over"?: ((draggingNode: import("element-plus/es/components/tree/src/model/node.mjs").default, dropNode: import("element-plus/es/components/tree/src/model/node.mjs").default, evt: DragEvent) => any) | undefined;
|
|
552
554
|
}>, {
|
|
553
|
-
data: ElTreeOutput<import("./tree.type").ElTreeValue>[];
|
|
555
|
+
data: ElTreeOutput<import("./tree.type").ElTreeValue, any>[];
|
|
554
556
|
props: import("element-plus").TreeOptionProps;
|
|
555
557
|
disabled: boolean;
|
|
556
558
|
modelValue: string | number | boolean | object | null;
|
|
@@ -8,7 +8,7 @@ import { withDefineType } from "../../../utils/vue/with.mjs";
|
|
|
8
8
|
import { computed, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, onMounted, reactive, ref, resolveDirective, watch, withDirectives } from "vue";
|
|
9
9
|
import { Expand, Fold } from "@element-plus/icons-vue";
|
|
10
10
|
import { ElIcon, ElInput, ElScrollbar, ElTree, treeEmits, treeProps, useGlobalSize } from "element-plus";
|
|
11
|
-
import { isArray, isBoolean, isNull, isNumber, isObject, isString } from "lodash-unified";
|
|
11
|
+
import { isArray, isBoolean, isNull, isNumber, isObject, isString, isUndefined } from "lodash-unified";
|
|
12
12
|
import { useVModel } from "@vueuse/core";
|
|
13
13
|
//#region src/components/tree/src/tree.tsx
|
|
14
14
|
/** FaTree 的运行时 Props 定义。 */
|
|
@@ -78,7 +78,7 @@ const faTreeProps = {
|
|
|
78
78
|
Boolean,
|
|
79
79
|
Object
|
|
80
80
|
]),
|
|
81
|
-
default:
|
|
81
|
+
default: void 0
|
|
82
82
|
},
|
|
83
83
|
/** @description 树形数据 */
|
|
84
84
|
data: {
|
|
@@ -98,7 +98,7 @@ const faTreeProps = {
|
|
|
98
98
|
const faTreeEmits = {
|
|
99
99
|
...treeEmits,
|
|
100
100
|
/** @description v-model 回调 */
|
|
101
|
-
"update:modelValue": (value) => isString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isNull(value),
|
|
101
|
+
"update:modelValue": (value) => isString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isNull(value) || isUndefined(value),
|
|
102
102
|
/** @description v-model:label 回调 */
|
|
103
103
|
"update:label": (value) => isString(value) || isNull(value),
|
|
104
104
|
/** @description 数据改变 */
|
|
@@ -187,7 +187,9 @@ var tree_default = defineComponent({
|
|
|
187
187
|
};
|
|
188
188
|
const handleFilterNode = (value, data, child) => {
|
|
189
189
|
if (!value) return true;
|
|
190
|
-
|
|
190
|
+
const isAll = data["all"];
|
|
191
|
+
const dataLabel = data["label"];
|
|
192
|
+
let parentNode = child.parent, labels = isAll ? [dataLabel] : [child.label], level = 1;
|
|
191
193
|
while (level < child.level && parentNode) {
|
|
192
194
|
labels = [...labels, parentNode.label];
|
|
193
195
|
parentNode = parentNode.parent;
|
|
@@ -205,7 +207,7 @@ var tree_default = defineComponent({
|
|
|
205
207
|
else if (node.expanded && props.collapseOnClickNode) node.collapse();
|
|
206
208
|
}
|
|
207
209
|
if (!data["all"] && (node.key === void 0 || node.key === null)) return;
|
|
208
|
-
state.value = data["all"] ? props.allValue
|
|
210
|
+
state.value = data["all"] ? props.allValue : node.key ?? null;
|
|
209
211
|
selectedLabel.value = node.label;
|
|
210
212
|
emit("update:modelValue", state.value);
|
|
211
213
|
emit("change", data, node, instance, event);
|
|
@@ -218,7 +220,7 @@ var tree_default = defineComponent({
|
|
|
218
220
|
}, { deep: true });
|
|
219
221
|
});
|
|
220
222
|
watch(() => props.modelValue, (newValue) => {
|
|
221
|
-
state.value = newValue
|
|
223
|
+
state.value = newValue;
|
|
222
224
|
if (typeof newValue === "string" || typeof newValue === "number") treeRef.value?.setCurrentKey(newValue);
|
|
223
225
|
});
|
|
224
226
|
const elTreeProps = useProps(props, treeProps, [
|