zmdms-webui 1.9.1 → 1.9.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/dist/es/dynamicsetting/dynamicDrawer.js +0 -3
- package/dist/es/dynamicsetting/index.css +1 -1
- package/dist/es/dynamicsetting/sortable.js +1 -1
- package/dist/es/node_modules/clsx/dist/clsx.m.js +3 -0
- package/dist/es/node_modules/react-contexify/dist/index.js +7 -0
- package/dist/es/table/components/TableMenu.js +57 -0
- package/dist/es/table/excel.js +45 -2
- package/dist/es/table/hooks.js +44 -9
- package/dist/es/table/interface.d.ts +8 -0
- package/dist/es/table/table.js +14 -3
- package/dist/es/table/useSummary.js +7 -1
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/dist/index.es.css +1 -0
- package/package.json +2 -1
|
@@ -97,9 +97,6 @@ var DynamicDrawer = function (props, ref) {
|
|
|
97
97
|
// 子元素拖拽
|
|
98
98
|
var onChildMoveItem = useCallback(function (pIndex, pKey) {
|
|
99
99
|
return function (dragIndex, hoverIndex) {
|
|
100
|
-
if (!isDimensionPriority(dragIndex, hoverIndex)) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
100
|
// 由于对于固定列,不能进行拖拽排序,所以需要找出所有包含固定列的属性出来
|
|
104
101
|
setTempDynamicList(function (preDynamicList) {
|
|
105
102
|
var newDynamicList = preDynamicList.map(function (item) { return (__assign({}, item)); }) || [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.zt-sortable{cursor:move;font-size:13px;line-height:
|
|
1
|
+
.zt-sortable-new{cursor:move;font-size:13px;line-height:1.5;overflow:hidden;padding:8px 0;text-align:left}.zt-sortable-new .zt-sortable--item{align-items:center;display:flex;justify-content:space-between;padding:0 16px}.zt-sortable-new .zt-sortable--children{display:flex}.zt-sortable-new .zt-sortable--children .zt-sortable-new{border-bottom:none;padding:8px 26px}.zt-sortable-new.no-move{cursor:no-drop}.zt-sortable-new .zt-checkbox{font-size:13px}.zt-sortable-new:hover{background-color:#ebf3fe}.ztxk-dynamic--more{cursor:pointer;height:20px}.ant-dropdown-show-arrow.ztxk-dynamic--more--drop{padding-top:0}.ztxk-dynamic--more--drop.ant-dropdown-placement-bottomRight>.ant-dropdown-arrow{top:-5px}.dynamic-drawer .ant-drawer-header{padding:10px 12px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div{align-items:center;color:#768696;display:flex;font-size:16px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div .search-drawer--title-text{font-size:14px;margin-left:10px}.dynamic-drawer .ant-drawer-header .ant-drawer-title>div .search-drawer--title-text>span{font-size:13px}.dynamic-drawer .ant-drawer-body{padding:0}.dynamic-drawer .ant-drawer-body .ant-checkbox-group{width:100%}.dynamic-drawer .ant-drawer-footer{border-top:none;display:flex;justify-content:space-between;padding:0}.dynamic-drawer .ant-drawer-footer>button{border:none;border-radius:0;height:40px;width:33%}.dynamic-drawer-section-title{background:#f5f5f5;border-radius:6px;font-size:14px;font-weight:700;padding:4px}
|
|
@@ -8,7 +8,7 @@ import { useDrag } from '../node_modules/react-dnd/dist/hooks/useDrag/useDrag.js
|
|
|
8
8
|
var Sortable = function (_a) {
|
|
9
9
|
var type = _a.type, onMoveItem = _a.onMoveItem, index = _a.index, id = _a.id, children = _a.children, style = _a.style, className = _a.className;
|
|
10
10
|
var ref = useRef(null);
|
|
11
|
-
var classes = classNames("zt-sortable", className, {});
|
|
11
|
+
var classes = classNames("zt-sortable-new", className, {});
|
|
12
12
|
/**
|
|
13
13
|
* @description 定义可放置对象
|
|
14
14
|
*/
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
2
|
+
|
|
3
|
+
export { clsx, clsx as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React__default, { createContext, useReducer, useRef, useState, useEffect, useContext, Children, cloneElement } from 'react';
|
|
2
|
+
import { clsx } from '../../clsx/dist/clsx.m.js';
|
|
3
|
+
import { flushSync } from 'react-dom';
|
|
4
|
+
|
|
5
|
+
var Y=createContext({}),F=()=>useContext(Y),$=t=>React__default.createElement(Y.Provider,{...t});function le(){let t=new Map;return {on(e,r){return t.has(e)?t.get(e).add(r):t.set(e,new Set([r])),this},off(e,r){return t.has(e)&&t.get(e).delete(r),this},emit(e,r){return t.has(e)&&t.get(e).forEach(f=>{f(r);}),this}}}var R=le();var B=()=>useRef(new Map).current;var z=()=>{},U=["resize","contextmenu","click","scroll","blur"];var A={show({event:t,id:e,props:r,position:f}){t.preventDefault&&t.preventDefault(),R.emit(0).emit(e,{event:t.nativeEvent||t,props:r,position:f});},hideAll(){R.emit(0);}};function Fe(t){return {show(e){A.show({...t,...e});},hideAll(){A.hideAll();}}}function G(){let t=new Map,e,r,f,s,i=!1;function P(n){s=Array.from(n.values()),e=-1,f=!0;}function v(){s[e].node.focus();}let x=()=>e>=0&&s[e].isSubmenu,w=()=>Array.from(s[e].submenuRefTracker.values());function m(){return e===-1?(b(),!1):!0}function b(){e+1<s.length?e++:e+1===s.length&&(e=0),i&&a(),v();}function E(){e===-1||e===0?e=s.length-1:e-1<s.length&&e--,i&&a(),v();}function T(){if(m()&&x()){let n=w(),{node:c,setSubmenuPosition:h}=s[e];return t.set(c,{isRoot:f,focusedIndex:e,parentNode:r||c,items:s}),h(),c.classList.add("contexify_submenu-isOpen"),r=c,n.length>0?(e=0,s=n):i=!0,f=!1,v(),!0}return !1}function a(){if(m()&&!f){let n=t.get(r);r.classList.remove("contexify_submenu-isOpen"),s=n.items,r=n.parentNode,n.isRoot&&(f=!0,t.clear()),i||(e=n.focusedIndex,v());}}function y(n){function c(h){for(let o of h)o.isSubmenu&&o.submenuRefTracker&&c(Array.from(o.submenuRefTracker.values())),o.keyMatcher&&o.keyMatcher(n);}c(s);}return {init:P,moveDown:b,moveUp:E,openSubmenu:T,closeSubmenu:a,matchKeys:y}}function I(t){return typeof t=="function"}function V(t){return typeof t=="string"}function _(t,e){return Children.map(Children.toArray(t).filter(Boolean),r=>cloneElement(r,e))}function J(t){let e={x:t.clientX,y:t.clientY},r=t.changedTouches;return r&&(e.x=r[0].clientX,e.y=r[0].clientY),(!e.x||e.x<0)&&(e.x=0),(!e.y||e.y<0)&&(e.y=0),e}function k(t,e){return I(t)?t(e):t}function be(t,e){return {...t,...I(e)?e(t):e}}var it=({id:t,theme:e,style:r,className:f,children:s,animation:i="fade",preventDefaultOnKeydown:P=!0,disableBoundariesCheck:v=!1,onVisibilityChange:x,...w})=>{let[m,b]=useReducer(be,{x:0,y:0,visible:!1,triggerEvent:{},propsFromTrigger:null,willLeave:!1}),E=useRef(null),T=B(),[a]=useState(()=>G()),y=useRef(),n=useRef();useEffect(()=>(R.on(t,h).on(0,o),()=>{R.off(t,h).off(0,o);}),[t,i,v]),useEffect(()=>{m.visible?a.init(T):T.clear();},[m.visible,a,T]);function c(u,p){if(E.current&&!v){let{innerWidth:d,innerHeight:C}=window,{offsetWidth:K,offsetHeight:O}=E.current;u+K>d&&(u-=u+K-d),p+O>C&&(p-=p+O-C);}return {x:u,y:p}}useEffect(()=>{m.visible&&b(c(m.x,m.y));},[m.visible]),useEffect(()=>{function u(d){P&&d.preventDefault();}function p(d){switch(d.key){case"Enter":case" ":a.openSubmenu()||o();break;case"Escape":o();break;case"ArrowUp":u(d),a.moveUp();break;case"ArrowDown":u(d),a.moveDown();break;case"ArrowRight":u(d),a.openSubmenu();break;case"ArrowLeft":u(d),a.closeSubmenu();break;default:a.matchKeys(d);break}}if(m.visible){window.addEventListener("keydown",p);for(let d of U)window.addEventListener(d,o);}return ()=>{window.removeEventListener("keydown",p);for(let d of U)window.removeEventListener(d,o);}},[m.visible,a,P]);function h({event:u,props:p,position:d}){u.stopPropagation();let C=d||J(u),{x:K,y:O}=c(C.x,C.y);flushSync(()=>{b({visible:!0,willLeave:!1,x:K,y:O,triggerEvent:u,propsFromTrigger:p});}),clearTimeout(n.current),!y.current&&I(x)&&(x(!0),y.current=!0);}function o(u){u!=null&&(u.button===2||u.ctrlKey)&&u.type!=="contextmenu"||(i&&(V(i)||"exit"in i&&i.exit)?b(p=>({willLeave:p.visible})):b(p=>({visible:p.visible?!1:p.visible})),n.current=setTimeout(()=>{I(x)&&x(!1),y.current=!1;}));}function M(){m.willLeave&&m.visible&&flushSync(()=>b({visible:!1,willLeave:!1}));}function S(){return V(i)?clsx({[`${"contexify_willEnter-"}${i}`]:g&&!D,[`${"contexify_willLeave-"}${i} ${"contexify_willLeave-"}'disabled'`]:g&&D}):i&&"enter"in i&&"exit"in i?clsx({[`${"contexify_willEnter-"}${i.enter}`]:i.enter&&g&&!D,[`${"contexify_willLeave-"}${i.exit} ${"contexify_willLeave-"}'disabled'`]:i.exit&&g&&D}):null}let{visible:g,triggerEvent:l,propsFromTrigger:L,x:oe,y:ie,willLeave:D}=m,ae=clsx("contexify",f,{[`${"contexify_theme-"}${e}`]:e},S());return React__default.createElement($,{value:T},g&&React__default.createElement("div",{...w,className:ae,onAnimationEnd:M,style:{...r,left:oe,top:ie,opacity:1},ref:E,role:"menu"},_(s,{propsFromTrigger:L,triggerEvent:l})))};var pt=({id:t,children:e,className:r,style:f,triggerEvent:s,data:i,propsFromTrigger:P,keyMatcher:v,onClick:x=z,disabled:w=!1,hidden:m=!1,closeOnClick:b=!0,handlerEvent:E="onClick",...T})=>{let a=useRef(),y=F(),n={id:t,data:i,triggerEvent:s,props:P},c=k(w,n),h=k(m,n);function o(l){n.event=l,l.stopPropagation(),c||(b?M():x(n));}function M(){let l=a.current;l.focus(),l.addEventListener("animationend",()=>setTimeout(A.hideAll),{once:!0}),l.classList.add("contexify_item-feedback"),x(n);}function S(l){l&&!c&&(a.current=l,y.set(l,{node:l,isSubmenu:!1,keyMatcher:!c&&I(v)&&(L=>{v(L)&&(L.stopPropagation(),L.preventDefault(),n.event=L,M());})}));}function g(l){(l.key==="Enter"||l.key===" ")&&(l.stopPropagation(),n.event=l,M());}return h?null:React__default.createElement("div",{...T,[E]:o,className:clsx("contexify_item",r,{[`${"contexify_item-disabled"}`]:c}),style:f,onKeyDown:g,ref:S,tabIndex:-1,role:"menuitem","aria-disabled":c},React__default.createElement("div",{className:"contexify_itemContent"},e))};
|
|
6
|
+
|
|
7
|
+
export { pt as Item, it as Menu, A as contextMenu, Fe as useContextMenu };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { Menu as it, Item as pt } from '../../node_modules/react-contexify/dist/index.js';
|
|
5
|
+
import screenfull from '../../node_modules/screenfull/index.js';
|
|
6
|
+
import { useLatest } from 'ahooks';
|
|
7
|
+
|
|
8
|
+
var TableMenu = function (_a) {
|
|
9
|
+
var menuId = _a.menuId, tableRef = _a.tableRef, isFullscreenHandle = _a.isFullscreenHandle;
|
|
10
|
+
var _b = useState(false), isFull = _b[0], setIsFull = _b[1];
|
|
11
|
+
var isFullscreenHandleRef = useLatest(isFullscreenHandle);
|
|
12
|
+
function onMenuItemClick(e) {
|
|
13
|
+
var data = e.data;
|
|
14
|
+
switch (data) {
|
|
15
|
+
case "fullscreen": {
|
|
16
|
+
if (screenfull.isEnabled) {
|
|
17
|
+
var realScreenFull = screenfull;
|
|
18
|
+
if (tableRef === null || tableRef === void 0 ? void 0 : tableRef.current) {
|
|
19
|
+
realScreenFull.toggle(tableRef.current);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
realScreenFull.toggle();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// 全屏
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (screenfull.isEnabled) {
|
|
32
|
+
var realScreenFull_1 = screenfull;
|
|
33
|
+
var callback_1 = function () {
|
|
34
|
+
var _a;
|
|
35
|
+
var isFull = realScreenFull_1.isFullscreen;
|
|
36
|
+
(_a = isFullscreenHandleRef.current) === null || _a === void 0 ? void 0 : _a.call(isFullscreenHandleRef, isFull);
|
|
37
|
+
setIsFull(isFull);
|
|
38
|
+
// 如果是全屏状态,那么修改表格背景
|
|
39
|
+
if (tableRef && tableRef.current) {
|
|
40
|
+
if (isFull) {
|
|
41
|
+
tableRef.current.style.backgroundColor = "#fff";
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
tableRef.current.style.removeProperty("background-color");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
realScreenFull_1.on("change", callback_1);
|
|
49
|
+
return function () {
|
|
50
|
+
realScreenFull_1.off("change", callback_1);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}, [tableRef, isFullscreenHandleRef]);
|
|
54
|
+
return (jsx(Fragment, { children: jsx(it, __assign({ id: menuId }, { children: jsx(pt, __assign({ data: "fullscreen", onClick: onMenuItemClick }, { children: isFull ? "退出全屏" : "全屏" })) })) }));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { TableMenu as default };
|
package/dist/es/table/excel.js
CHANGED
|
@@ -3,12 +3,13 @@ import { x as xlsx_minExports } from '../node_modules/xlsx-js-style/dist/xlsx.mi
|
|
|
3
3
|
import { useMergeKeys } from './hooks.js';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { useMemoizedFn } from 'ahooks';
|
|
6
|
-
import { MERGE_ROW_SPANS } from './constant.js';
|
|
6
|
+
import { IS_SUMMARY, MERGE_ROW_SPANS } from './constant.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* 导出Excel,支持维度合并和小计
|
|
10
10
|
*/
|
|
11
11
|
function exportToExcelWithMerge(records, columns, mergeKeys, summaryKeys, fileName, sheetName, columnHeaders, summaryConfig) {
|
|
12
|
+
var _a;
|
|
12
13
|
if (fileName === void 0) { fileName = "export.xlsx"; }
|
|
13
14
|
if (sheetName === void 0) { sheetName = "Sheet1"; }
|
|
14
15
|
if (!records || records.length === 0) {
|
|
@@ -29,6 +30,8 @@ function exportToExcelWithMerge(records, columns, mergeKeys, summaryKeys, fileNa
|
|
|
29
30
|
if (col.isSummary) {
|
|
30
31
|
var total = 0;
|
|
31
32
|
for (var i = 0; i < processedData.length; i++) {
|
|
33
|
+
if (processedData[i][IS_SUMMARY])
|
|
34
|
+
continue;
|
|
32
35
|
var v = processedData[i][key];
|
|
33
36
|
var n = typeof v === "number" ? v : Number(v);
|
|
34
37
|
if (!isNaN(n))
|
|
@@ -48,7 +51,7 @@ function exportToExcelWithMerge(records, columns, mergeKeys, summaryKeys, fileNa
|
|
|
48
51
|
return "";
|
|
49
52
|
});
|
|
50
53
|
// 生成用于样式应用的数据(追加一条 __is_summary__ 行)
|
|
51
|
-
var summaryDataObj_1 = {
|
|
54
|
+
var summaryDataObj_1 = (_a = {}, _a[IS_SUMMARY] = true, _a);
|
|
52
55
|
Object.keys(sumsByKey_1).forEach(function (k) {
|
|
53
56
|
summaryDataObj_1[k] = sumsByKey_1[k];
|
|
54
57
|
});
|
|
@@ -56,6 +59,8 @@ function exportToExcelWithMerge(records, columns, mergeKeys, summaryKeys, fileNa
|
|
|
56
59
|
}
|
|
57
60
|
// 5. 创建工作表(带末尾合计行)
|
|
58
61
|
var worksheet = createWorksheetWithMerge(__assign(__assign({}, excelData), { summaryRow: summaryRow }), mergeKeys);
|
|
62
|
+
// 5.1 根据 columns 的 fixed 与表头行数设置冻结窗格(左列 + 表头行)
|
|
63
|
+
setWorksheetFreeze(worksheet, excelData.leafColumns, excelData.headerRowCount);
|
|
59
64
|
// 6. 添加样式(合计行高亮)
|
|
60
65
|
applyExcelStyles(worksheet, dataForStyles, mergeKeys, summaryKeys, excelData.leafColumns, excelData.headerRowCount);
|
|
61
66
|
// 7. 添加工作表到工作簿
|
|
@@ -68,6 +73,44 @@ function exportToExcelWithMerge(records, columns, mergeKeys, summaryKeys, fileNa
|
|
|
68
73
|
fileName: fileName,
|
|
69
74
|
};
|
|
70
75
|
}
|
|
76
|
+
function setWorksheetFreeze(worksheet, leafColumns, headerRowCount) {
|
|
77
|
+
try {
|
|
78
|
+
// 计算左侧固定列数量
|
|
79
|
+
var leftFrozenCount = leafColumns.filter(function (col) { return (col === null || col === void 0 ? void 0 : col.fixed) === "left"; }).length;
|
|
80
|
+
var ySplit = headerRowCount || 0;
|
|
81
|
+
var xSplit = leftFrozenCount || 0;
|
|
82
|
+
console.log("Freeze info:", {
|
|
83
|
+
ySplit: ySplit,
|
|
84
|
+
xSplit: xSplit,
|
|
85
|
+
headerRowCount: headerRowCount,
|
|
86
|
+
leftFrozenCount: leftFrozenCount,
|
|
87
|
+
});
|
|
88
|
+
if (ySplit > 0 || xSplit > 0) {
|
|
89
|
+
// 方法1:使用标准的 !freeze 属性(推荐)
|
|
90
|
+
// worksheet["!freeze"] = {
|
|
91
|
+
// xSplit,
|
|
92
|
+
// ySplit,
|
|
93
|
+
// };
|
|
94
|
+
// 方法2:如果方法1不生效,尝试使用 !panes 属性
|
|
95
|
+
worksheet["!panes"] = {
|
|
96
|
+
x: xSplit,
|
|
97
|
+
y: ySplit,
|
|
98
|
+
topLeftCell: xlsx_minExports.utils.encode_cell({ r: ySplit, c: xSplit }),
|
|
99
|
+
};
|
|
100
|
+
// 方法3:直接设置冻结信息到工作表
|
|
101
|
+
// if (!worksheet["!freeze"]) {
|
|
102
|
+
// worksheet["!freeze"] = {};
|
|
103
|
+
// }
|
|
104
|
+
// worksheet["!freeze"].xSplit = xSplit;
|
|
105
|
+
// worksheet["!freeze"].ySplit = ySplit;
|
|
106
|
+
console.log("Freeze set:", worksheet["!freeze"]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
console.error("设置冻结窗格失败:", e);
|
|
111
|
+
// 不影响导出,继续执行
|
|
112
|
+
}
|
|
113
|
+
}
|
|
71
114
|
/**
|
|
72
115
|
* 准备Excel数据(支持分组表头,构建多行表头与合并范围)
|
|
73
116
|
*/
|
package/dist/es/table/hooks.js
CHANGED
|
@@ -33,7 +33,7 @@ function useEditChange(dataSourceRef, onTableChange) {
|
|
|
33
33
|
* @returns 排序相关方法
|
|
34
34
|
*/
|
|
35
35
|
function useMoveRowChange(dataSourceRef, onTableChange, options) {
|
|
36
|
-
var isMove = options.isMove, refreshScuCell = options.refreshScuCell, currentPage = options.currentPage, extraOnRow = options.extraOnRow, fixedRowsCount = options.fixedRowsCount, fixedRowsConfig = options.fixedRowsConfig;
|
|
36
|
+
var isMove = options.isMove, refreshScuCell = options.refreshScuCell, currentPage = options.currentPage, extraOnRow = options.extraOnRow, fixedRowsCount = options.fixedRowsCount, fixedRowsConfig = options.fixedRowsConfig, menuShow = options.menuShow;
|
|
37
37
|
var moveRow = useCallback(function (dI, hI) {
|
|
38
38
|
var _a;
|
|
39
39
|
// 内部分页时,获取数据真正的行数
|
|
@@ -63,6 +63,14 @@ function useMoveRowChange(dataSourceRef, onTableChange, options) {
|
|
|
63
63
|
index: index,
|
|
64
64
|
moveRow: moveRow,
|
|
65
65
|
};
|
|
66
|
+
var defaultOnRow = extraOnRow === null || extraOnRow === void 0 ? void 0 : extraOnRow(record, index);
|
|
67
|
+
var onContextMenuCapture = function (e) {
|
|
68
|
+
var _a;
|
|
69
|
+
(_a = defaultOnRow === null || defaultOnRow === void 0 ? void 0 : defaultOnRow.onContextMenuCapture) === null || _a === void 0 ? void 0 : _a.call(defaultOnRow, e);
|
|
70
|
+
menuShow === null || menuShow === void 0 ? void 0 : menuShow({
|
|
71
|
+
event: e,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
66
74
|
// 确定固定行数量和行高
|
|
67
75
|
var fixedCount = (fixedRowsConfig === null || fixedRowsConfig === void 0 ? void 0 : fixedRowsConfig.count) || fixedRowsCount;
|
|
68
76
|
var rowHeight = (fixedRowsConfig === null || fixedRowsConfig === void 0 ? void 0 : fixedRowsConfig.rowHeight) || 36; // 默认行高36px
|
|
@@ -76,18 +84,25 @@ function useMoveRowChange(dataSourceRef, onTableChange, options) {
|
|
|
76
84
|
borderBottom: "1px solid #f0f0f0",
|
|
77
85
|
zIndex: 10,
|
|
78
86
|
};
|
|
79
|
-
return __assign(__assign({}, baseProps), { style: customStyle
|
|
87
|
+
return __assign(__assign(__assign(__assign({}, defaultOnRow), { onContextMenuCapture: onContextMenuCapture }), baseProps), { style: customStyle
|
|
80
88
|
? __assign(__assign({}, defaultStyle), customStyle) : defaultStyle });
|
|
81
89
|
}
|
|
82
90
|
return baseProps;
|
|
83
|
-
}, [moveRow, fixedRowsCount, fixedRowsConfig]);
|
|
84
|
-
var defaultOnRow = useMemoizedFn(function (record) {
|
|
91
|
+
}, [moveRow, fixedRowsCount, fixedRowsConfig, menuShow, extraOnRow]);
|
|
92
|
+
var defaultOnRow = useMemoizedFn(function (record, index) {
|
|
85
93
|
var extra = extraOnRow === null || extraOnRow === void 0 ? void 0 : extraOnRow(record);
|
|
94
|
+
var onContextMenuCapture = function (e) {
|
|
95
|
+
var _a;
|
|
96
|
+
(_a = extra === null || extra === void 0 ? void 0 : extra.onContextMenuCapture) === null || _a === void 0 ? void 0 : _a.call(extra, e);
|
|
97
|
+
menuShow === null || menuShow === void 0 ? void 0 : menuShow({
|
|
98
|
+
event: e,
|
|
99
|
+
});
|
|
100
|
+
};
|
|
86
101
|
var summaryStyle = __assign({ background: "#ebf3fe", fontWeight: "bold" }, extra === null || extra === void 0 ? void 0 : extra.style);
|
|
87
102
|
if (record[IS_SUMMARY]) {
|
|
88
|
-
return __assign(__assign({}, extra), { style: summaryStyle });
|
|
103
|
+
return __assign(__assign({}, extra), { onContextMenuCapture: onContextMenuCapture, style: summaryStyle });
|
|
89
104
|
}
|
|
90
|
-
return {};
|
|
105
|
+
return __assign(__assign({}, extra), { onContextMenuCapture: onContextMenuCapture });
|
|
91
106
|
});
|
|
92
107
|
return {
|
|
93
108
|
onRow: isMove || fixedRowsCount || fixedRowsConfig ? onRow : defaultOnRow,
|
|
@@ -338,13 +353,31 @@ function useCalcScrollY(isAutoScrollY, subHeight, id) {
|
|
|
338
353
|
}, [isAutoScrollY, subHeight, id]);
|
|
339
354
|
return tableHeight;
|
|
340
355
|
}
|
|
356
|
+
// 扁平化多级表头,获取叶子列
|
|
357
|
+
function getLeafColumns(columns) {
|
|
358
|
+
var leafColumns = [];
|
|
359
|
+
var walk = function (nodes) {
|
|
360
|
+
var _a;
|
|
361
|
+
(_a = nodes === null || nodes === void 0 ? void 0 : nodes.forEach) === null || _a === void 0 ? void 0 : _a.call(nodes, function (n) {
|
|
362
|
+
if (Array.isArray(n === null || n === void 0 ? void 0 : n.children) && n.children.length > 0) {
|
|
363
|
+
walk(n.children);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
leafColumns.push(n);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
walk(columns);
|
|
371
|
+
return leafColumns;
|
|
372
|
+
}
|
|
341
373
|
/**
|
|
342
374
|
* 获取合并key值
|
|
343
375
|
*/
|
|
344
376
|
var useMergeKeys = function (columns, isAutoMerge) {
|
|
345
377
|
var mergeKeys = useMemo(function () {
|
|
346
378
|
if (isAutoMerge) {
|
|
347
|
-
|
|
379
|
+
var leafColumns = getLeafColumns(columns);
|
|
380
|
+
return Array.from(new Set(leafColumns
|
|
348
381
|
.filter(function (item) { return item.isMerge && item.key !== MERGE_INDEX; })
|
|
349
382
|
.map(function (item) { return (item.mergeKey || item.key); })));
|
|
350
383
|
}
|
|
@@ -362,11 +395,13 @@ function useAutoMerge(dataSource, columns, _a) {
|
|
|
362
395
|
var firstMergeKey = mergeKeys === null || mergeKeys === void 0 ? void 0 : mergeKeys[0];
|
|
363
396
|
// 需要合计的字段
|
|
364
397
|
var summaryKeys = useMemo(function () {
|
|
365
|
-
|
|
398
|
+
var leafColumns = getLeafColumns(columns);
|
|
399
|
+
return leafColumns.filter(function (item) { return item.isSummary; }).map(function (item) { return item.key; });
|
|
366
400
|
}, [columns]);
|
|
367
401
|
// 开启维度合并的维度字段
|
|
368
402
|
var dimensionSummaryKeys = useMemo(function () {
|
|
369
|
-
|
|
403
|
+
var leafColumns = getLeafColumns(columns);
|
|
404
|
+
return leafColumns
|
|
370
405
|
.filter(function (item) { return item.isDimensionSum; })
|
|
371
406
|
.map(function (item) { return item.key; });
|
|
372
407
|
}, [columns]);
|
|
@@ -497,6 +497,14 @@ interface ITableProps<RecordType> extends Omit<TableProps<RecordType>, "columns"
|
|
|
497
497
|
* 目前index的话会自动加个序号
|
|
498
498
|
*/
|
|
499
499
|
mode?: "index";
|
|
500
|
+
/**
|
|
501
|
+
* 是否开启右键功能
|
|
502
|
+
*/
|
|
503
|
+
isContextMenu?: boolean;
|
|
504
|
+
/**
|
|
505
|
+
* 全屏后的一些事件
|
|
506
|
+
*/
|
|
507
|
+
isFullscreenHandle?: (isFullscreen: boolean) => void;
|
|
500
508
|
}
|
|
501
509
|
interface IFields {
|
|
502
510
|
/**
|
package/dist/es/table/table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { memo, useMemo, useRef, useCallback, useImperativeHandle } from 'react';
|
|
3
|
+
import { memo, useState, useMemo, useRef, useCallback, useImperativeHandle } from 'react';
|
|
4
4
|
import { Table as Table$1 } from 'antd';
|
|
5
5
|
import { BasicBodyRow, MoveBodyRow } from './components/EnhanceBodyRow.js';
|
|
6
6
|
import EnhanceCell from './components/EnhanceBodyCell.js';
|
|
@@ -23,6 +23,8 @@ import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.
|
|
|
23
23
|
import useTableValidate, { tableValidate } from './useTableValidate.js';
|
|
24
24
|
import TitleDirectionColumn from './components/TitleDirectionColumn.js';
|
|
25
25
|
import { useExcelExport } from './excel.js';
|
|
26
|
+
import TableMenu from './components/TableMenu.js';
|
|
27
|
+
import { useContextMenu as Fe } from '../node_modules/react-contexify/dist/index.js';
|
|
26
28
|
import DynamicSetting from '../dynamicsetting/dynamicSetting.js';
|
|
27
29
|
import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js';
|
|
28
30
|
|
|
@@ -39,10 +41,16 @@ import { DndProvider } from '../node_modules/react-dnd/dist/core/DndProvider.js'
|
|
|
39
41
|
// completed: 实现从execl复制到表格中的功能
|
|
40
42
|
var Table = function (props) {
|
|
41
43
|
// console.log("表格渲染");
|
|
42
|
-
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _o = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _o === void 0 ? 65 : _o, _p = props.isAutoScrollY, isAutoScrollY = _p === void 0 ? false : _p, tableId = props.tableId, extraOnRow = props.onRow, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, headerAlign = props.headerAlign, isDimensionDynamic = props.isDimensionDynamic, isAutoMerge = props.isAutoMerge, mode = props.mode, rowSelection = props.rowSelection, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "isRemeberFilter", "isOrderUpdateData", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "hiddenAddBtnHandle", "isTheadTitleAdd", "addMode", "addCallback", "isDel", "delPopTitle", "hiddenDelBtnHandle", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "innerPaginationConfig", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn", "isResizableTitleEllipsis", "isRealTimeValidate", "isMarginTop", "isMarginBottom", "scroll", "addAndDelProps", "autoScrollYMarginBottom", "isAutoScrollY", "tableId", "onRow", "fixedRowsCount", "fixedRowsConfig", "headerAlign", "isDimensionDynamic", "isAutoMerge", "mode", "rowSelection"]);
|
|
44
|
+
var className = props.className, _a = props.bordered, bordered = _a === void 0 ? true : _a, _b = props.pagination, pagination = _b === void 0 ? false : _b, isFlex = props.isFlex; props.tablePreferences; var dynamicKey = props.dynamicKey, dynamicVersion = props.dynamicVersion, isRemeberFilter = props.isRemeberFilter, _c = props.isOrderUpdateData, isOrderUpdateData = _c === void 0 ? true : _c, hiddenDynamicIcon = props.hiddenDynamicIcon, _columns = props.columns, dataSource = props.dataSource, onTableChange = props.onTableChange, isEdit = props.isEdit, isMove = props.isMove, isAdd = props.isAdd, hiddenAddBtnHandle = props.hiddenAddBtnHandle, _d = props.isTheadTitleAdd, isTheadTitleAdd = _d === void 0 ? true : _d, addMode = props.addMode, addCallback = props.addCallback, isDel = props.isDel, delPopTitle = props.delPopTitle, hiddenDelBtnHandle = props.hiddenDelBtnHandle, _e = props.isDelAll, isDelAll = _e === void 0 ? true : _e, isAddAndDelAuto = props.isAddAndDelAuto, summaryConfig = props.summaryConfig, _f = props.summaryFixed, summaryFixed = _f === void 0 ? true : _f, isInnerPagination = props.isInnerPagination, _g = props.innerPaginationPageSize, innerPaginationPageSize = _g === void 0 ? 30 : _g, _h = props.innerPaginationPosition, innerPaginationPosition = _h === void 0 ? INNER_TABLE_PAGINATION_POSITION : _h, _j = props.innerPaginationPageSizeOptions, innerPaginationPageSizeOptions = _j === void 0 ? INNER_TABLE_PAGINATION_PAGESIZEOPTIONS : _j, innerPaginationConfig = props.innerPaginationConfig, tableRefHandle = props.tableRefHandle, tableName = props.tableName, serviceOrder = props.serviceOrder, differences = props.differences, virtualKey = props.virtualKey, _k = props.isResizableColumn, isResizableColumn = _k === void 0 ? true : _k, _l = props.isResizableTitleEllipsis, isResizableTitleEllipsis = _l === void 0 ? true : _l, _m = props.isRealTimeValidate, isRealTimeValidate = _m === void 0 ? true : _m, isMarginTop = props.isMarginTop, isMarginBottom = props.isMarginBottom, scroll = props.scroll, addAndDelProps = props.addAndDelProps, _o = props.autoScrollYMarginBottom, autoScrollYMarginBottom = _o === void 0 ? 65 : _o, _p = props.isAutoScrollY, isAutoScrollY = _p === void 0 ? false : _p, tableId = props.tableId, extraOnRow = props.onRow, fixedRowsCount = props.fixedRowsCount, fixedRowsConfig = props.fixedRowsConfig, headerAlign = props.headerAlign, isDimensionDynamic = props.isDimensionDynamic, isAutoMerge = props.isAutoMerge, mode = props.mode, rowSelection = props.rowSelection, isContextMenu = props.isContextMenu, isFullscreenHandle = props.isFullscreenHandle, resetProps = __rest(props, ["className", "bordered", "pagination", "isFlex", "tablePreferences", "dynamicKey", "dynamicVersion", "isRemeberFilter", "isOrderUpdateData", "hiddenDynamicIcon", "columns", "dataSource", "onTableChange", "isEdit", "isMove", "isAdd", "hiddenAddBtnHandle", "isTheadTitleAdd", "addMode", "addCallback", "isDel", "delPopTitle", "hiddenDelBtnHandle", "isDelAll", "isAddAndDelAuto", "summaryConfig", "summaryFixed", "isInnerPagination", "innerPaginationPageSize", "innerPaginationPosition", "innerPaginationPageSizeOptions", "innerPaginationConfig", "tableRefHandle", "tableName", "serviceOrder", "differences", "virtualKey", "isResizableColumn", "isResizableTitleEllipsis", "isRealTimeValidate", "isMarginTop", "isMarginBottom", "scroll", "addAndDelProps", "autoScrollYMarginBottom", "isAutoScrollY", "tableId", "onRow", "fixedRowsCount", "fixedRowsConfig", "headerAlign", "isDimensionDynamic", "isAutoMerge", "mode", "rowSelection", "isContextMenu", "isFullscreenHandle"]);
|
|
43
45
|
var classes = classNames("ztxk-table", className, {
|
|
44
46
|
"ztxk-table--flex": isFlex,
|
|
45
47
|
});
|
|
48
|
+
var menuId = useState(isContextMenu
|
|
49
|
+
? "menuId-" + Math.floor(Math.random() * 100000000)
|
|
50
|
+
: undefined)[0];
|
|
51
|
+
var menuShow = Fe({
|
|
52
|
+
id: menuId,
|
|
53
|
+
}).show;
|
|
46
54
|
// 针对SCU和增减行 做特殊处理
|
|
47
55
|
var _q = useScuRfresh(), refreshScuCell = _q.refreshScuCell, getRefreshScuCell = _q.getRefreshScuCell;
|
|
48
56
|
// 做一些前置处理
|
|
@@ -104,6 +112,7 @@ var Table = function (props) {
|
|
|
104
112
|
fixedRowsCount: fixedRowsCount,
|
|
105
113
|
fixedRowsConfig: fixedRowsConfig,
|
|
106
114
|
virtualKey: virtualKey,
|
|
115
|
+
menuShow: menuShow,
|
|
107
116
|
}).onRow;
|
|
108
117
|
// 内部表格新增删除事件
|
|
109
118
|
var onAddAndDel = useAddAndDelChange(dataSourceRef, onTableChange, {
|
|
@@ -302,6 +311,8 @@ var Table = function (props) {
|
|
|
302
311
|
(_b = (_a = dynamicSettingRef.current) === null || _a === void 0 ? void 0 : _a.updateList) === null || _b === void 0 ? void 0 : _b.call(_a, list);
|
|
303
312
|
},
|
|
304
313
|
exportExcel: exportExcel,
|
|
314
|
+
/** 获取表格容器 */
|
|
315
|
+
getContainer: function () { return tableRef.current; },
|
|
305
316
|
};
|
|
306
317
|
});
|
|
307
318
|
// 表格
|
|
@@ -325,7 +336,7 @@ var Table = function (props) {
|
|
|
325
336
|
overflow: "hidden",
|
|
326
337
|
marginTop: isMarginTop ? 10 : 0,
|
|
327
338
|
marginBottom: isMarginBottom ? 10 : 0,
|
|
328
|
-
}, ref: tableRef, id: tableId }, { children: [isMove ? (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: SingleTable }))) : (SingleTable), dynamicKey ? (jsx(DynamicSetting, { parentDynamicKey: TABLE_DYNAMIC_KEY, dynamicKey: dynamicKey, defaultList: defaultDynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef, hiddenOperationIcon: true, isMore: true, isFixed: true, isDimensionDynamic: isDimensionDynamic })) : null] })));
|
|
339
|
+
}, ref: tableRef, id: tableId }, { children: [isMove ? (jsx(DndProvider, __assign({ backend: HTML5Backend, context: window }, { children: SingleTable }))) : (SingleTable), dynamicKey ? (jsx(DynamicSetting, { parentDynamicKey: TABLE_DYNAMIC_KEY, dynamicKey: dynamicKey, defaultList: defaultDynamicList, onCurrentListChange: onCurrentListChange, ref: dynamicSettingRef, hiddenOperationIcon: true, isMore: true, isFixed: true, isDimensionDynamic: isDimensionDynamic })) : null, menuId ? (jsx(TableMenu, { menuId: menuId, tableRef: tableRef, isFullscreenHandle: isFullscreenHandle })) : null] })));
|
|
329
340
|
};
|
|
330
341
|
var MemoTable = memo(Table);
|
|
331
342
|
MemoTable.displayName = "ZTXK_WEBUI_Table";
|
|
@@ -241,7 +241,13 @@ function getSubtotalObj(fields, dataSource) {
|
|
|
241
241
|
});
|
|
242
242
|
Object.keys(summaryTotalObj).forEach(function (key) {
|
|
243
243
|
if (summaryTotalObj[key] !== undefined) {
|
|
244
|
-
|
|
244
|
+
var value = summaryTotalObj[key];
|
|
245
|
+
var isNumericLike = function (v) {
|
|
246
|
+
return typeof v === "number" || (typeof v === "string" && !isNaN(Number(v)));
|
|
247
|
+
};
|
|
248
|
+
if (isNumericLike(value)) {
|
|
249
|
+
summaryTotalObj[key] = addThousedSeparator(value);
|
|
250
|
+
}
|
|
245
251
|
}
|
|
246
252
|
});
|
|
247
253
|
return {
|