ztxkui 4.2.23-609 → 4.2.23-610

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.
@@ -64,24 +64,18 @@ var BTN_GROUP_CONFIG = {
64
64
  ],
65
65
  };
66
66
  var OperationBtnGroup = function (_a) {
67
- var _b, _c, _d, _e, _f;
68
- var status = _a.status, id = _a.id, callback = _a.callback, userBtns = _a.userBtns, record = _a.record, statusBtnConfig = _a.statusBtnConfig, canOperations = _a.canOperations, userId = _a.userId, compact = _a.compact, _g = _a.defaultShowNum, defaultShowNum = _g === void 0 ? 2 : _g, defaultShowMore = _a.defaultShowMore;
67
+ var _b;
68
+ var status = _a.status, id = _a.id, callback = _a.callback, userBtns = _a.userBtns, record = _a.record, statusBtnConfig = _a.statusBtnConfig, canOperations = _a.canOperations, userId = _a.userId, compact = _a.compact, _c = _a.defaultShowNum, defaultShowNum = _c === void 0 ? 2 : _c, defaultShowMore = _a.defaultShowMore;
69
69
  var isOperationBtnGroupShowMoreDefault = useBaseContext().isOperationBtnGroupShowMoreDefault;
70
70
  var isShowMore = getFinalValue(isOperationBtnGroupShowMoreDefault, defaultShowMore);
71
71
  var containerRef = useRef(null);
72
72
  // 当前按钮组
73
73
  var btnConfigs = __assign(__assign({}, BTN_GROUP_CONFIG), statusBtnConfig);
74
- var onClickHandle = function (type, id, isAuth) {
75
- if (isAuth) {
76
- callback && callback(type, id, record);
77
- }
74
+ var onClickHandle = function (type, id) {
75
+ callback && callback(type, id, record);
78
76
  };
79
- /**
80
- * @func
81
- * @desc 得到具体按钮
82
- * @param {string} type 当前按钮对应得类型
83
- */
84
- function getBtnDom(btnConfig, id) {
77
+ /** 无权限的按钮直接隐藏 */
78
+ function isShowBtn(btnConfig) {
85
79
  var isAuth = isBtnAuth(userBtns, btnConfig.authority || '');
86
80
  if (Array.isArray(canOperations) && canOperations.length > 0) {
87
81
  isAuth = !!canOperations.includes(userId || '');
@@ -89,25 +83,35 @@ var OperationBtnGroup = function (_a) {
89
83
  if (typeof canOperations === 'boolean') {
90
84
  isAuth = canOperations;
91
85
  }
86
+ return isAuth;
87
+ }
88
+ /**
89
+ * @func
90
+ * @desc 得到具体按钮
91
+ * @param {string} type 当前按钮对应得类型
92
+ */
93
+ function getBtnDom(btnConfig, id) {
92
94
  if (btnConfig.confirmMsg) {
93
- return (React.createElement(Popconfirm, { key: btnConfig.type, title: btnConfig.confirmMsg, cancelText: i18next.t('否'), okText: i18next.t('是'), onConfirm: function () { return onClickHandle(btnConfig.type, id, isAuth); } },
95
+ return (React.createElement(Popconfirm, { key: btnConfig.type, title: btnConfig.confirmMsg, cancelText: i18next.t('否'), okText: i18next.t('是'), onConfirm: function () { return onClickHandle(btnConfig.type, id); } },
94
96
  React.createElement(Button, { type: "link", style: {
95
97
  height: 28,
96
- }, disabled: !isAuth, compact: compact }, btnConfig.name)));
98
+ }, compact: compact }, btnConfig.name)));
97
99
  }
98
- return (React.createElement(Button, { key: btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.type, type: "link", onClick: function () { return onClickHandle(btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.type, id, isAuth); }, style: {
100
+ return (React.createElement(Button, { key: btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.type, type: "link", onClick: function () { return onClickHandle(btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.type, id); }, style: {
99
101
  height: 28,
100
- }, disabled: !isAuth, compact: compact }, btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.name));
102
+ }, compact: compact }, btnConfig === null || btnConfig === void 0 ? void 0 : btnConfig.name));
101
103
  }
104
+ // 当前状态下有权限的按钮
105
+ var authedBtnConfigs = (btnConfigs[status] || []).filter(isShowBtn);
102
106
  // 切割按钮显示
103
107
  var defaultBtnConfigs = isShowMore
104
- ? (_c = (_b = btnConfigs[status]) === null || _b === void 0 ? void 0 : _b.slice) === null || _c === void 0 ? void 0 : _c.call(_b, 0, defaultShowNum)
105
- : btnConfigs[status];
108
+ ? authedBtnConfigs.slice(0, defaultShowNum)
109
+ : authedBtnConfigs;
106
110
  // 其他按钮
107
111
  var otherBtnConfigs = isShowMore
108
- ? (_e = (_d = btnConfigs[status]) === null || _d === void 0 ? void 0 : _d.slice) === null || _e === void 0 ? void 0 : _e.call(_d, defaultShowNum)
112
+ ? authedBtnConfigs.slice(defaultShowNum)
109
113
  : [];
110
- var _h = useState(false), showMore = _h[0], setShowMore = _h[1];
114
+ var _d = useState(false), showMore = _d[0], setShowMore = _d[1];
111
115
  var moreBtn = function () {
112
116
  return (otherBtnConfigs === null || otherBtnConfigs === void 0 ? void 0 : otherBtnConfigs.length) ? (React.createElement(Button, { type: "link", style: {
113
117
  height: 28,
@@ -133,7 +137,7 @@ var OperationBtnGroup = function (_a) {
133
137
  operation_btn_group_popover_en: isEnglish(),
134
138
  }), content: React.createElement("div", { className: classNames({
135
139
  operation_btn_group_popover_content_en: isEnglish(),
136
- }), style: { width: ((_f = containerRef.current) === null || _f === void 0 ? void 0 : _f.offsetWidth) + "px" } }, renderBtnGroup(otherBtnConfigs)), visible: showMore, onVisibleChange: function (visible) {
140
+ }), style: { width: ((_b = containerRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) + "px" } }, renderBtnGroup(otherBtnConfigs)), visible: showMore, onVisibleChange: function (visible) {
137
141
  if (!visible) {
138
142
  setShowMore(visible);
139
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "4.2.23-609",
3
+ "version": "4.2.23-610",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",
@@ -112,4 +112,4 @@
112
112
  "react-dom": ">=16.9.0",
113
113
  "ztxkutils": ">=2.1.1"
114
114
  }
115
- }
115
+ }