bee-front-components 1.0.0
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/config/config.ts +28 -0
- package/lib/assets/images/empty.png +0 -0
- package/lib/components/BaseModal/index.d.ts +41 -0
- package/lib/components/BaseModal/index.js +133 -0
- package/lib/components/BaseModal/index.module.less +66 -0
- package/lib/components/Buttons/Button.d.ts +17 -0
- package/lib/components/Buttons/Button.js +34 -0
- package/lib/components/Buttons/ButtonPermission.d.ts +18 -0
- package/lib/components/Buttons/ButtonPermission.js +34 -0
- package/lib/components/Buttons/index.d.ts +3 -0
- package/lib/components/Buttons/index.js +3 -0
- package/lib/components/Buttons/index.module.less +21 -0
- package/lib/components/ContentHeader/index.d.ts +17 -0
- package/lib/components/ContentHeader/index.js +22 -0
- package/lib/components/ContentHeader/index.module.less +14 -0
- package/lib/components/Empty/index.d.ts +17 -0
- package/lib/components/Empty/index.js +23 -0
- package/lib/components/Empty/index.module.less +15 -0
- package/lib/components/ExcelExport/index.d.ts +28 -0
- package/lib/components/ExcelExport/index.js +60 -0
- package/lib/components/ExcelExport/index.module.less +61 -0
- package/lib/components/Modal/index.d.ts +26 -0
- package/lib/components/Modal/index.js +191 -0
- package/lib/components/Modal/index.module.less +79 -0
- package/lib/components/PageHeader/index.d.ts +43 -0
- package/lib/components/PageHeader/index.js +72 -0
- package/lib/components/PageHeader/index.module.less +38 -0
- package/lib/components/PdfViewer/index.d.ts +49 -0
- package/lib/components/PdfViewer/index.js +699 -0
- package/lib/components/QueryBar/TableQueryBar.d.ts +32 -0
- package/lib/components/QueryBar/TableQueryBar.js +115 -0
- package/lib/components/QueryBar/index.d.ts +25 -0
- package/lib/components/QueryBar/index.js +102 -0
- package/lib/components/QueryBar/index.module.less +58 -0
- package/lib/components/RemainDay/index.d.ts +22 -0
- package/lib/components/RemainDay/index.js +47 -0
- package/lib/components/RemainDay/index.module.less +42 -0
- package/lib/components/Scanner/hooks/useKeyboardScanner.d.ts +14 -0
- package/lib/components/Scanner/hooks/useKeyboardScanner.js +95 -0
- package/lib/components/Scanner/index.d.ts +60 -0
- package/lib/components/Scanner/index.js +318 -0
- package/lib/components/Scanner/index.module.less +264 -0
- package/lib/components/Scanner/utils/device.d.ts +2 -0
- package/lib/components/Scanner/utils/device.js +18 -0
- package/lib/components/StatusTab/index.d.ts +36 -0
- package/lib/components/StatusTab/index.js +118 -0
- package/lib/components/StatusTab/index.module.less +20 -0
- package/lib/components/StatusTag/index.d.ts +32 -0
- package/lib/components/StatusTag/index.js +142 -0
- package/lib/components/StatusTag/index.module.less +37 -0
- package/lib/components/StepProgress/index.d.ts +36 -0
- package/lib/components/StepProgress/index.js +84 -0
- package/lib/components/StepProgress/index.module.less +180 -0
- package/lib/components/Table/index.d.ts +44 -0
- package/lib/components/Table/index.js +135 -0
- package/lib/components/Table/index.module.less +24 -0
- package/lib/components/TableOperationColumn/index.d.ts +45 -0
- package/lib/components/TableOperationColumn/index.js +205 -0
- package/lib/components/TableOperationColumn/index.module.less +22 -0
- package/lib/components/Tabs/TabGroup.d.ts +9 -0
- package/lib/components/Tabs/TabGroup.js +12 -0
- package/lib/components/Tabs/TabPane.d.ts +9 -0
- package/lib/components/Tabs/TabPane.js +12 -0
- package/lib/components/Tabs/Tabs.d.ts +23 -0
- package/lib/components/Tabs/Tabs.js +42 -0
- package/lib/components/Tabs/index.d.ts +4 -0
- package/lib/components/Tabs/index.js +4 -0
- package/lib/components/Tabs/index.module.less +20 -0
- package/lib/components/Upload/BatchUpload/index.d.ts +42 -0
- package/lib/components/Upload/BatchUpload/index.js +140 -0
- package/lib/components/Upload/BatchUpload/index.module.less +10 -0
- package/lib/components/Upload/DraggerUpload/index.d.ts +42 -0
- package/lib/components/Upload/DraggerUpload/index.js +142 -0
- package/lib/components/Upload/DraggerUpload/index.module.less +30 -0
- package/lib/components/Upload/FileUpload.d.ts +36 -0
- package/lib/components/Upload/FileUpload.js +122 -0
- package/lib/components/Upload/index.d.ts +4 -0
- package/lib/components/Upload/index.js +4 -0
- package/lib/components/VipFlag/index.d.ts +10 -0
- package/lib/components/VipFlag/index.js +23 -0
- package/lib/components/VipFlag/index.module.less +20 -0
- package/lib/typings/blank.d.ts +0 -0
- package/lib/typings.d.ts +3 -0
- package/lib/utils/const.d.ts +21 -0
- package/lib/utils/const.js +22 -0
- package/lib/utils/index.d.ts +95 -0
- package/lib/utils/index.js +319 -0
- package/lib/utils/menuTab.d.ts +60 -0
- package/lib/utils/menuTab.js +122 -0
- package/lib/utils/utils.d.ts +61 -0
- package/lib/utils/utils.js +270 -0
- package/package.json +41 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import _Table from "@hzero-front-ui/c7n-ui/lib/TablePro";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
const _excluded = ["dataSet", "columns", "className", "optBtns", "renderColumn", "isShowDivider", "dividerClass", "customizedCode", "extra", "customHeader", "isShowCollapseBtn"];
|
|
5
|
+
/**
|
|
6
|
+
* @name 通用表格组件
|
|
7
|
+
* @param {string} className 该组件自定义类名
|
|
8
|
+
* @param {ButtonItemProps[]} optBtns 操作栏中按钮集合
|
|
9
|
+
* @param {object} renderColumn 自定义操作栏配置
|
|
10
|
+
* @param {boolean} isShowDivider 是否显示分割线
|
|
11
|
+
* @param {string} dividerClass 分割线自定义样式
|
|
12
|
+
* @param {string} customizedCode 该组件自定义表格列的唯一性标识
|
|
13
|
+
* @param {React.ReactNode} extra 表格头部额外内容(默认置于右侧)
|
|
14
|
+
* @param {React.ReactNode} customHeader 自定义表格头部操作区域
|
|
15
|
+
* @param {...args} 其他剩余参数 同choerodon UI组件中的Table使用方式
|
|
16
|
+
* @author lichen
|
|
17
|
+
*/
|
|
18
|
+
import React, { useMemo } from "react";
|
|
19
|
+
import classNames from "classnames";
|
|
20
|
+
import { TableAutoHeightType } from "choerodon-ui/pro/lib/table/interface";
|
|
21
|
+
import { ColumnLock } from "choerodon-ui/pro/lib/table/enum";
|
|
22
|
+
import { isMobileDevice } from "../Scanner/utils/device";
|
|
23
|
+
import StatusTag from "../StatusTag";
|
|
24
|
+
import Empty from "../Empty";
|
|
25
|
+
import TableQueryBar from "../QueryBar/TableQueryBar";
|
|
26
|
+
import TableOperationColumn from "../TableOperationColumn";
|
|
27
|
+
import styles from "./index.module.less?modules";
|
|
28
|
+
|
|
29
|
+
// 自定义DataSet中的Fields配置信息
|
|
30
|
+
|
|
31
|
+
const Table = props => {
|
|
32
|
+
const dataSet = props.dataSet,
|
|
33
|
+
columns = props.columns,
|
|
34
|
+
className = props.className,
|
|
35
|
+
_props$optBtns = props.optBtns,
|
|
36
|
+
optBtns = _props$optBtns === void 0 ? [] : _props$optBtns,
|
|
37
|
+
renderColumn = props.renderColumn,
|
|
38
|
+
_props$isShowDivider = props.isShowDivider,
|
|
39
|
+
isShowDivider = _props$isShowDivider === void 0 ? true : _props$isShowDivider,
|
|
40
|
+
dividerClass = props.dividerClass,
|
|
41
|
+
customizedCode = props.customizedCode,
|
|
42
|
+
extra = props.extra,
|
|
43
|
+
customHeader = props.customHeader,
|
|
44
|
+
_props$isShowCollapse = props.isShowCollapseBtn,
|
|
45
|
+
isShowCollapseBtn = _props$isShowCollapse === void 0 ? true : _props$isShowCollapse,
|
|
46
|
+
args = _objectWithoutProperties(props, _excluded);
|
|
47
|
+
// 根据dataSet生成相应的Columns配置信息
|
|
48
|
+
const customerColumns = useMemo(() => {
|
|
49
|
+
var _dataSet$props;
|
|
50
|
+
if (columns !== undefined) {
|
|
51
|
+
return columns;
|
|
52
|
+
}
|
|
53
|
+
// 存储最终columns配置项,传入的DataSet中的Fields属性
|
|
54
|
+
const tableColumns = [],
|
|
55
|
+
oriFields = (dataSet === null || dataSet === void 0 ? void 0 : (_dataSet$props = dataSet.props) === null || _dataSet$props === void 0 ? void 0 : _dataSet$props.fields) || [];
|
|
56
|
+
for (const field of oriFields) {
|
|
57
|
+
// 如果当前配置项中不包含信息或hideInTable为true时,不写入配置项
|
|
58
|
+
if (!field || field !== null && field !== void 0 && field.hideInTable) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const currentColumns = field !== null && field !== void 0 && field.statusType ? {
|
|
62
|
+
...field,
|
|
63
|
+
renderer: ({
|
|
64
|
+
value,
|
|
65
|
+
text
|
|
66
|
+
}) => /*#__PURE__*/React.createElement(StatusTag, {
|
|
67
|
+
value: value,
|
|
68
|
+
text: text,
|
|
69
|
+
showType: field.statusType
|
|
70
|
+
})
|
|
71
|
+
} : {
|
|
72
|
+
...field
|
|
73
|
+
};
|
|
74
|
+
tableColumns.push({
|
|
75
|
+
...currentColumns,
|
|
76
|
+
...(renderColumn === null || renderColumn === void 0 ? void 0 : renderColumn[(field === null || field === void 0 ? void 0 : field.name) || ""])
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 如果optBtns或optColumn不为空则将显示操作栏
|
|
81
|
+
if ((optBtns === null || optBtns === void 0 ? void 0 : optBtns.length) > 0 || renderColumn !== null && renderColumn !== void 0 && renderColumn.operation) {
|
|
82
|
+
// 先以自定义操作栏为最高优先级
|
|
83
|
+
const optColumns = {
|
|
84
|
+
name: "operation",
|
|
85
|
+
title: "操作",
|
|
86
|
+
width: 180,
|
|
87
|
+
lock: "right",
|
|
88
|
+
renderer: () => /*#__PURE__*/React.createElement(TableOperationColumn, {
|
|
89
|
+
buttons: optBtns
|
|
90
|
+
}),
|
|
91
|
+
...(renderColumn === null || renderColumn === void 0 ? void 0 : renderColumn.operation)
|
|
92
|
+
};
|
|
93
|
+
tableColumns.push(optColumns);
|
|
94
|
+
}
|
|
95
|
+
return tableColumns;
|
|
96
|
+
}, [dataSet, columns, renderColumn, optBtns]);
|
|
97
|
+
|
|
98
|
+
// 根据当前运行设备及分页配置设置表格分页属性
|
|
99
|
+
const tableDataSet = useMemo(() => {
|
|
100
|
+
const isMobile = isMobileDevice();
|
|
101
|
+
const defPageSize = isMobile ? 5 : 20; // PC默认每页20条 移动端默认每页5条
|
|
102
|
+
const pageSize = (dataSet === null || dataSet === void 0 ? void 0 : dataSet.pageSize) === 10 ? defPageSize : dataSet === null || dataSet === void 0 ? void 0 : dataSet.pageSize; // 有可能从外部传入 内部默认为10 因此取变更之后的值
|
|
103
|
+
return Object.assign(dataSet, {
|
|
104
|
+
pageSize
|
|
105
|
+
});
|
|
106
|
+
}, [dataSet]);
|
|
107
|
+
return /*#__PURE__*/React.createElement(_Table, _extends({
|
|
108
|
+
className: classNames(styles.defaultTable, className),
|
|
109
|
+
dataSet: tableDataSet,
|
|
110
|
+
columns: customerColumns,
|
|
111
|
+
autoHeight: {
|
|
112
|
+
type: TableAutoHeightType.maxHeight,
|
|
113
|
+
diff: 64
|
|
114
|
+
},
|
|
115
|
+
rowNumber: true,
|
|
116
|
+
rowNumberColumnProps: {
|
|
117
|
+
width: 60,
|
|
118
|
+
title: "序号",
|
|
119
|
+
rowNumberIndex: 1
|
|
120
|
+
},
|
|
121
|
+
parityRow: false,
|
|
122
|
+
renderEmpty: () => /*#__PURE__*/React.createElement(Empty, null)
|
|
123
|
+
}, args, {
|
|
124
|
+
queryBar: obj => /*#__PURE__*/React.createElement(TableQueryBar, _extends({}, obj, {
|
|
125
|
+
isShowDivider: isShowDivider,
|
|
126
|
+
dividerClass: dividerClass,
|
|
127
|
+
extra: extra,
|
|
128
|
+
customHeader: customHeader,
|
|
129
|
+
isShowCollapseBtn: isShowCollapseBtn
|
|
130
|
+
})),
|
|
131
|
+
customizable: !!customizedCode,
|
|
132
|
+
customizedCode: customizedCode
|
|
133
|
+
}));
|
|
134
|
+
};
|
|
135
|
+
export default Table;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// 表格通用样式
|
|
2
|
+
.defaultTable {
|
|
3
|
+
.flex(column, flex-start, stretch, nowrap);
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
:global {
|
|
7
|
+
.c7n-spin-nested-loading {
|
|
8
|
+
flex: 1;
|
|
9
|
+
.c7n-spin-container {
|
|
10
|
+
height: 100%;
|
|
11
|
+
.c7n-pro-table,
|
|
12
|
+
.c7n-pro-table-content {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.c7n-pro-table:not(.c7n-pro-table-bordered) .c7n-pro-table-tbody .c7n-pro-table-row {
|
|
18
|
+
border-bottom: 0.01rem solid #e6e6e6;
|
|
19
|
+
}
|
|
20
|
+
.c7n-pro-table table {
|
|
21
|
+
border-collapse: collapse;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* 操作列按钮项属性
|
|
4
|
+
*/
|
|
5
|
+
export interface ButtonItemProps {
|
|
6
|
+
/**
|
|
7
|
+
* 按钮文本
|
|
8
|
+
*/
|
|
9
|
+
text: string;
|
|
10
|
+
/**
|
|
11
|
+
* 按钮权限编码
|
|
12
|
+
*/
|
|
13
|
+
permissionCode?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 按钮是否隐藏
|
|
16
|
+
*/
|
|
17
|
+
hidden?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 按钮是否禁用
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 按钮点击事件
|
|
24
|
+
*/
|
|
25
|
+
onClick?: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 操作列属性
|
|
29
|
+
*/
|
|
30
|
+
interface TableOperationColumnProps {
|
|
31
|
+
/**
|
|
32
|
+
* 操作列按钮项数组
|
|
33
|
+
*/
|
|
34
|
+
buttons: ButtonItemProps[];
|
|
35
|
+
/**
|
|
36
|
+
* 操作列按钮宽度
|
|
37
|
+
*/
|
|
38
|
+
buttonWidth?: number;
|
|
39
|
+
/**
|
|
40
|
+
* 操作列触发方式
|
|
41
|
+
*/
|
|
42
|
+
trigger?: "click" | "hover";
|
|
43
|
+
}
|
|
44
|
+
declare const TableOperationColumn: React.FunctionComponent<TableOperationColumnProps>;
|
|
45
|
+
export default TableOperationColumn;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import _Popover from "@hzero-front-ui/c7n-ui/lib/Popover";
|
|
2
|
+
import _Icon from "choerodon-ui/pro/lib/icon";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import React from "react";
|
|
5
|
+
/**
|
|
6
|
+
* 操作列组件
|
|
7
|
+
*/
|
|
8
|
+
import { FuncType } from "choerodon-ui/pro/lib/button/enum";
|
|
9
|
+
import { observer } from "mobx-react-lite";
|
|
10
|
+
import { throttle } from "lodash";
|
|
11
|
+
import { useEffect, useRef, useState } from "react";
|
|
12
|
+
import request from "utils/request";
|
|
13
|
+
import { Button } from "../Buttons";
|
|
14
|
+
import styles from "./index.module.less?modules";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 操作列按钮项属性
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 操作列属性
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 操作列属性
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// 检查权限
|
|
29
|
+
async function checkPermissions(data) {
|
|
30
|
+
return request("/iam/hzero/v1/menus/check-permissions", {
|
|
31
|
+
method: "POST",
|
|
32
|
+
data
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 权限结果类型
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const permissionResultCache = new Map();
|
|
41
|
+
const inFlightRequests = new Map();
|
|
42
|
+
|
|
43
|
+
// 操作按钮点击节流间隔(毫秒),防止快速重复点击触发多次操作
|
|
44
|
+
const CLICK_THROTTLE = 300;
|
|
45
|
+
const TableOperationColumn = observer(props => {
|
|
46
|
+
const buttons = props.buttons,
|
|
47
|
+
buttonWidth = props.buttonWidth,
|
|
48
|
+
_props$trigger = props.trigger,
|
|
49
|
+
trigger = _props$trigger === void 0 ? "hover" : _props$trigger;
|
|
50
|
+
const _useState = useState(new Map()),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
internalPermissionMap = _useState2[0],
|
|
53
|
+
setInternalPermissionMap = _useState2[1];
|
|
54
|
+
// 节流点击:300ms 内的重复点击直接忽略,防止快速连点触发多次操作(leading 首击立即执行)
|
|
55
|
+
const throttledClick = useRef(throttle(item => {
|
|
56
|
+
var _item$onClick;
|
|
57
|
+
return (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item);
|
|
58
|
+
}, CLICK_THROTTLE, {
|
|
59
|
+
leading: true,
|
|
60
|
+
trailing: false
|
|
61
|
+
})).current;
|
|
62
|
+
const _useState3 = useState(false),
|
|
63
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
+
visible = _useState4[0],
|
|
65
|
+
setVisible = _useState4[1];
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!buttons || !Array.isArray(buttons) || buttons.length === 0) return;
|
|
68
|
+
let cancelled = false;
|
|
69
|
+
const permissionCodes = buttons.map(item => item.permissionCode).filter(code => !!code);
|
|
70
|
+
const uncachedCodes = permissionCodes.filter(code => !permissionResultCache.has(code));
|
|
71
|
+
if (uncachedCodes.length === 0) {
|
|
72
|
+
const map = new Map();
|
|
73
|
+
permissionCodes.forEach(code => {
|
|
74
|
+
const cached = permissionResultCache.get(code);
|
|
75
|
+
if (cached !== undefined) map.set(code, cached);
|
|
76
|
+
});
|
|
77
|
+
if (!cancelled) {
|
|
78
|
+
setInternalPermissionMap(map);
|
|
79
|
+
}
|
|
80
|
+
return () => {
|
|
81
|
+
cancelled = true;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const key = uncachedCodes.sort().join(",");
|
|
85
|
+
if (inFlightRequests.has(key)) {
|
|
86
|
+
var _inFlightRequests$get;
|
|
87
|
+
(_inFlightRequests$get = inFlightRequests.get(key)) === null || _inFlightRequests$get === void 0 ? void 0 : _inFlightRequests$get.then(res => {
|
|
88
|
+
res.forEach(item => {
|
|
89
|
+
permissionResultCache.set(item.code, {
|
|
90
|
+
approve: item.approve,
|
|
91
|
+
controllerType: item.controllerType
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
const map = new Map();
|
|
95
|
+
permissionCodes.forEach(code => {
|
|
96
|
+
const cached = permissionResultCache.get(code);
|
|
97
|
+
if (cached !== undefined) map.set(code, cached);
|
|
98
|
+
});
|
|
99
|
+
if (!cancelled) {
|
|
100
|
+
setInternalPermissionMap(map);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return () => {
|
|
104
|
+
cancelled = true;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const requestPromise = checkPermissions(uncachedCodes);
|
|
108
|
+
inFlightRequests.set(key, requestPromise);
|
|
109
|
+
requestPromise.then(res => {
|
|
110
|
+
inFlightRequests.delete(key);
|
|
111
|
+
res.forEach(item => {
|
|
112
|
+
permissionResultCache.set(item.code, {
|
|
113
|
+
approve: item.approve,
|
|
114
|
+
controllerType: item.controllerType
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
const map = new Map();
|
|
118
|
+
permissionCodes.forEach(code => {
|
|
119
|
+
const cached = permissionResultCache.get(code);
|
|
120
|
+
if (cached !== undefined) map.set(code, cached);
|
|
121
|
+
});
|
|
122
|
+
if (!cancelled) {
|
|
123
|
+
setInternalPermissionMap(map);
|
|
124
|
+
}
|
|
125
|
+
}).catch(() => {
|
|
126
|
+
inFlightRequests.delete(key);
|
|
127
|
+
});
|
|
128
|
+
return () => {
|
|
129
|
+
cancelled = true;
|
|
130
|
+
};
|
|
131
|
+
}, [buttons]);
|
|
132
|
+
if (!buttons || !Array.isArray(buttons) || buttons.length === 0) return null;
|
|
133
|
+
const finalPermissionMap = internalPermissionMap;
|
|
134
|
+
|
|
135
|
+
/** 判断按钮是否被禁用 */
|
|
136
|
+
const isButtonDisabled = item => {
|
|
137
|
+
if (item.disabled) return true;
|
|
138
|
+
if (item.permissionCode && finalPermissionMap.has(item.permissionCode)) {
|
|
139
|
+
const perm = finalPermissionMap.get(item.permissionCode);
|
|
140
|
+
if ((perm === null || perm === void 0 ? void 0 : perm.controllerType) === "disabled" && !perm.approve) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return false;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/** 过滤可见按钮 */
|
|
148
|
+
const visibleButtons = buttons.filter(item => {
|
|
149
|
+
if (item.hidden) return false;
|
|
150
|
+
if (item.permissionCode && finalPermissionMap.has(item.permissionCode)) {
|
|
151
|
+
const perm = finalPermissionMap.get(item.permissionCode);
|
|
152
|
+
// hidden 类型:approve=false 时隐藏
|
|
153
|
+
if ((perm === null || perm === void 0 ? void 0 : perm.controllerType) === "hidden") {
|
|
154
|
+
return perm.approve;
|
|
155
|
+
}
|
|
156
|
+
// disabled 类型:按钮显示,但禁用
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
// 权限码存在但结果未返回时,隐藏按钮(安全考虑)
|
|
160
|
+
if (item.permissionCode && !finalPermissionMap.has(item.permissionCode)) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
});
|
|
165
|
+
const content = visibleButtons.slice(2).map(item => /*#__PURE__*/React.createElement("div", {
|
|
166
|
+
key: item.text,
|
|
167
|
+
className: `${styles.popoverItem} ${isButtonDisabled(item) ? styles.disabled : ""}`,
|
|
168
|
+
onClick: isButtonDisabled(item) ? undefined : () => {
|
|
169
|
+
setVisible(false);
|
|
170
|
+
throttledClick(item);
|
|
171
|
+
}
|
|
172
|
+
}, item.text));
|
|
173
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
174
|
+
className: styles.operationColumn
|
|
175
|
+
}, (visibleButtons.length > 3 ? visibleButtons.slice(0, 2) : visibleButtons).map(item => /*#__PURE__*/React.createElement(Button, {
|
|
176
|
+
key: item.text,
|
|
177
|
+
disabled: isButtonDisabled(item),
|
|
178
|
+
onClick: () => throttledClick(item),
|
|
179
|
+
funcType: "link",
|
|
180
|
+
style: {
|
|
181
|
+
marginRight: 8,
|
|
182
|
+
textAlign: "left",
|
|
183
|
+
...(buttonWidth ? {
|
|
184
|
+
width: buttonWidth
|
|
185
|
+
} : {})
|
|
186
|
+
}
|
|
187
|
+
}, item.text)), visibleButtons.length > 3 && /*#__PURE__*/React.createElement(_Popover, {
|
|
188
|
+
visible: visible,
|
|
189
|
+
onVisibleChange: setVisible,
|
|
190
|
+
content: content,
|
|
191
|
+
trigger: trigger,
|
|
192
|
+
placement: "bottom",
|
|
193
|
+
overlayStyle: {
|
|
194
|
+
minWidth: 64
|
|
195
|
+
}
|
|
196
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
197
|
+
funcType: "link"
|
|
198
|
+
}, "\u66F4\u591A", /*#__PURE__*/React.createElement(_Icon, {
|
|
199
|
+
type: "expand_more",
|
|
200
|
+
style: {
|
|
201
|
+
marginLeft: 2
|
|
202
|
+
}
|
|
203
|
+
}))));
|
|
204
|
+
});
|
|
205
|
+
export default TableOperationColumn;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.operationColumn {
|
|
2
|
+
width: auto;
|
|
3
|
+
.flex(@justify: flex-start, @wrap: nowrap);
|
|
4
|
+
}
|
|
5
|
+
.popoverItem {
|
|
6
|
+
padding: 0.08rem 0.1rem;
|
|
7
|
+
font-size: @fontSize;
|
|
8
|
+
line-height: 0.16rem;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
color: @primaryColor;
|
|
11
|
+
&:hover {
|
|
12
|
+
background: @primaryLightColor;
|
|
13
|
+
border-radius: @borderRadius;
|
|
14
|
+
}
|
|
15
|
+
&.disabled {
|
|
16
|
+
color: rgba(0, 0, 0, 0.25);
|
|
17
|
+
cursor: not-allowed;
|
|
18
|
+
&:hover {
|
|
19
|
+
background: transparent;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 通用标签页TabGroup组件
|
|
3
|
+
* @param {...TabGroupProps} TabGroupProps参数 同choerodon UI组件中的TabGroup使用方式
|
|
4
|
+
* @author lichen
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
import type { TabGroupProps } from "choerodon-ui/lib/tabs";
|
|
8
|
+
declare const TabGroup: React.FC<TabGroupProps>;
|
|
9
|
+
export default TabGroup;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _Tabs from "@hzero-front-ui/c7n-ui/lib/TabsPro";
|
|
2
|
+
/**
|
|
3
|
+
* @name 通用标签页TabGroup组件
|
|
4
|
+
* @param {...TabGroupProps} TabGroupProps参数 同choerodon UI组件中的TabGroup使用方式
|
|
5
|
+
* @author lichen
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
const CustomTabGroup = _Tabs.TabGroup;
|
|
9
|
+
const TabGroup = props => {
|
|
10
|
+
return /*#__PURE__*/React.createElement(CustomTabGroup, props);
|
|
11
|
+
};
|
|
12
|
+
export default TabGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 通用标签页TabPane组件
|
|
3
|
+
* @param {...TabPaneProps} TabPaneProps参数 同choerodon UI组件中的TabPane使用方式
|
|
4
|
+
* @author lichen
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
import type { TabPaneProps } from "choerodon-ui/lib/tabs";
|
|
8
|
+
declare const TabPane: React.FC<TabPaneProps>;
|
|
9
|
+
export default TabPane;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _Tabs from "@hzero-front-ui/c7n-ui/lib/TabsPro";
|
|
2
|
+
/**
|
|
3
|
+
* @name 通用标签页TabPane组件
|
|
4
|
+
* @param {...TabPaneProps} TabPaneProps参数 同choerodon UI组件中的TabPane使用方式
|
|
5
|
+
* @author lichen
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
const CustomTabPane = _Tabs.TabPane;
|
|
9
|
+
const TabPane = props => {
|
|
10
|
+
return /*#__PURE__*/React.createElement(CustomTabPane, props);
|
|
11
|
+
};
|
|
12
|
+
export default TabPane;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 通用标签页组件
|
|
3
|
+
* @param {string} className 该组件自定义类名
|
|
4
|
+
* @param {string} tabBarClass 自定义标签类名
|
|
5
|
+
* @param {string} tabBarWrapClass 自定义标签外层区域类名
|
|
6
|
+
* @param {boolean} isShowDivider 是否显示分割线
|
|
7
|
+
* @param {...args} 其他剩余参数 同choerodon UI组件中的Tabs使用方式
|
|
8
|
+
* @author lichen
|
|
9
|
+
*/
|
|
10
|
+
import React from "react";
|
|
11
|
+
import type { TabsProps } from "choerodon-ui/lib/tabs";
|
|
12
|
+
interface IProps extends TabsProps {
|
|
13
|
+
/** 自定义类名 */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** 自定义标签外层区域类名 */
|
|
16
|
+
tabBarWrapClass?: string;
|
|
17
|
+
/** 自定义标签类名 */
|
|
18
|
+
tabBarClass?: string;
|
|
19
|
+
/** 是否显示分割线 */
|
|
20
|
+
isShowDivider?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare const Tabs: React.FC<Omit<IProps, "tabBarStyle">>;
|
|
23
|
+
export default Tabs;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _Tabs from "@hzero-front-ui/c7n-ui/lib/TabsPro";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
const _excluded = ["className", "tabBarClass", "tabBarWrapClass", "isShowDivider", "children"];
|
|
5
|
+
/**
|
|
6
|
+
* @name 通用标签页组件
|
|
7
|
+
* @param {string} className 该组件自定义类名
|
|
8
|
+
* @param {string} tabBarClass 自定义标签类名
|
|
9
|
+
* @param {string} tabBarWrapClass 自定义标签外层区域类名
|
|
10
|
+
* @param {boolean} isShowDivider 是否显示分割线
|
|
11
|
+
* @param {...args} 其他剩余参数 同choerodon UI组件中的Tabs使用方式
|
|
12
|
+
* @author lichen
|
|
13
|
+
*/
|
|
14
|
+
import React from "react";
|
|
15
|
+
import classNames from "classnames";
|
|
16
|
+
import styles from "./index.module.less?modules";
|
|
17
|
+
const Tabs = props => {
|
|
18
|
+
const className = props.className,
|
|
19
|
+
tabBarClass = props.tabBarClass,
|
|
20
|
+
tabBarWrapClass = props.tabBarWrapClass,
|
|
21
|
+
_props$isShowDivider = props.isShowDivider,
|
|
22
|
+
isShowDivider = _props$isShowDivider === void 0 ? true : _props$isShowDivider,
|
|
23
|
+
children = props.children,
|
|
24
|
+
args = _objectWithoutProperties(props, _excluded);
|
|
25
|
+
return /*#__PURE__*/React.createElement(_Tabs, _extends({
|
|
26
|
+
className: classNames(styles.defaultTabs, className),
|
|
27
|
+
inkBarStyle: {
|
|
28
|
+
bottom: "0.01rem"
|
|
29
|
+
},
|
|
30
|
+
renderTabBar: (tabBar, DefaultTabBar) => /*#__PURE__*/React.createElement(DefaultTabBar, _extends({
|
|
31
|
+
className: classNames(styles.defTabBarBox, {
|
|
32
|
+
[styles.borderBtm]: isShowDivider
|
|
33
|
+
}, tabBarWrapClass)
|
|
34
|
+
}, tabBar), node => {
|
|
35
|
+
const nodeProps = node.props;
|
|
36
|
+
return /*#__PURE__*/React.cloneElement(node, {
|
|
37
|
+
className: classNames(nodeProps.className, styles.tabBar, tabBarClass)
|
|
38
|
+
});
|
|
39
|
+
})
|
|
40
|
+
}, args), children);
|
|
41
|
+
};
|
|
42
|
+
export default Tabs;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Tabs页签通用样式
|
|
2
|
+
.defaultTabs {
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
.defTabBarBox {
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0 0.24rem;
|
|
8
|
+
}
|
|
9
|
+
.borderBtm {
|
|
10
|
+
border-bottom: 0.01rem solid @borderColor !important;
|
|
11
|
+
}
|
|
12
|
+
.tabBar {
|
|
13
|
+
padding: 0.16rem 0 0.14rem !important;
|
|
14
|
+
}
|
|
15
|
+
:global {
|
|
16
|
+
.c7n-tabs-content {
|
|
17
|
+
height: calc(100% - 0.51rem);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name 基于Upload组件进行多文件上传
|
|
3
|
+
* @param {string} className 自定义类名
|
|
4
|
+
* @param {string} accept 允许上传的文件类型 默认.doc和.pdf
|
|
5
|
+
* @param {string} bucketName 文件上传后存储的桶名 默认public
|
|
6
|
+
* @param {string} directory 文件上传后存储的文件夹路径 默认/files
|
|
7
|
+
* @param {string} fileList 上传的文件列表 用于受控时文件回显
|
|
8
|
+
* @param {ReactNode} uploadTip 自定义上传提示文案
|
|
9
|
+
* @param {function} uploadCallback 上传之后的回调
|
|
10
|
+
* @param {string} children 自定义上传按钮
|
|
11
|
+
* @author lichen
|
|
12
|
+
*/
|
|
13
|
+
import React from "react";
|
|
14
|
+
import type { UploadProps } from "choerodon-ui/lib/upload/Upload";
|
|
15
|
+
import type { UploadFile } from "choerodon-ui/lib/upload/interface";
|
|
16
|
+
interface IProps extends Omit<UploadProps, "directory"> {
|
|
17
|
+
/** 自定义类名 */
|
|
18
|
+
className?: string;
|
|
19
|
+
/** 允许上传的文件类型 默认.doc和.pdf */
|
|
20
|
+
accept?: string;
|
|
21
|
+
/** 文件上传后存储的桶名 默认public */
|
|
22
|
+
bucketName?: string;
|
|
23
|
+
/** 文件上传后存储的文件夹路径 默认/files */
|
|
24
|
+
directory?: string;
|
|
25
|
+
/** 上传的文件列表 用于受控时文件回显 */
|
|
26
|
+
fileList?: UploadFile[];
|
|
27
|
+
/** 文件上传之后的回调 */
|
|
28
|
+
uploadCallback?: (urls: string[]) => void;
|
|
29
|
+
/** 自定义上传提示文案 */
|
|
30
|
+
uploadTip?: React.ReactNode;
|
|
31
|
+
/** 自定义上传按钮 */
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/** 对外暴露字段 */
|
|
35
|
+
export interface IBatchUploadRef {
|
|
36
|
+
/** 上传的所有文件路径 */
|
|
37
|
+
filesPath: string[];
|
|
38
|
+
/** 上传的所有文件对象 */
|
|
39
|
+
filesList: UploadFile[];
|
|
40
|
+
}
|
|
41
|
+
declare const BatchUpload: React.ForwardRefExoticComponent<IProps & React.RefAttributes<IBatchUploadRef>>;
|
|
42
|
+
export default BatchUpload;
|