@baishuyun/ui-business 2.0.4 → 3.0.2
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/README.md +188 -1
- package/dist/DeptsMember/{DeptsMember-Ct8CJLvk.js → DeptsMember-pFjdAocd.js} +62 -62
- package/dist/DeptsMember/{TabGroup-LsBzSRvu.js → TabGroup-CznMwTOD.js} +35 -35
- package/dist/DeptsMember/index.js +2 -2
- package/dist/DeptsMember/subcomponents/Entity/Department/index.js +73 -61
- package/dist/DeptsMember/subcomponents/Entity/Member/index.js +205 -187
- package/dist/components/DeptsMember/subcomponents/TagIcon/TagIcon.d.ts +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -7
- package/dist/services/apiService.d.ts +16 -11
- package/dist/vendors/services/apiService.js +11 -86
- package/dist/vendors/services/corp/outsider.service.js +4 -4
- package/dist/vendors/services/data/department.service.js +2 -2
- package/dist/vendors/services/data/member.service.js +6 -6
- package/dist/vendors/services/data/member_limit.service.js +3 -3
- package/dist/vendors/services/data/outsider.service.js +4 -4
- package/dist/vendors/services/team/team.services.js +3 -3
- package/package.json +2 -2
- package/dist/vendors/axios.js +0 -1720
package/README.md
CHANGED
|
@@ -67,4 +67,191 @@ src/
|
|
|
67
67
|
|
|
68
68
|
## 许可证
|
|
69
69
|
|
|
70
|
-
MIT
|
|
70
|
+
MIT
|
|
71
|
+
|
|
72
|
+
## API Service 配置指南
|
|
73
|
+
|
|
74
|
+
本组件库采用依赖注入架构,**要求业务项目传入自己的 Axios 实例**。这种设计确保了:
|
|
75
|
+
|
|
76
|
+
- 🔒 **统一认证体系**:组件库请求使用业务项目的认证逻辑
|
|
77
|
+
- 🎯 **完全请求控制**:业务项目可以感知和控制所有请求
|
|
78
|
+
- 🛡️ **统一错误处理**:所有请求使用相同的错误处理逻辑
|
|
79
|
+
- 📊 **统一状态管理**:Loading 状态、请求监控等统一管理
|
|
80
|
+
|
|
81
|
+
## 基本用法
|
|
82
|
+
|
|
83
|
+
### 1. 创建业务 Axios 实例
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// src/api/request.ts
|
|
87
|
+
import axios from 'axios';
|
|
88
|
+
import { message } from 'antd';
|
|
89
|
+
|
|
90
|
+
const request = axios.create({
|
|
91
|
+
baseURL: process.env.REACT_APP_API_BASE_URL,
|
|
92
|
+
timeout: 10000,
|
|
93
|
+
withCredentials: true,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// 请求拦截器
|
|
97
|
+
request.interceptors.request.use(
|
|
98
|
+
(config) => {
|
|
99
|
+
// 添加认证 Token
|
|
100
|
+
const token = localStorage.getItem('access_token');
|
|
101
|
+
if (token) {
|
|
102
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
103
|
+
}
|
|
104
|
+
return config;
|
|
105
|
+
},
|
|
106
|
+
(error) => Promise.reject(error)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// 响应拦截器
|
|
110
|
+
request.interceptors.response.use(
|
|
111
|
+
(response) => response,
|
|
112
|
+
(error) => {
|
|
113
|
+
// 统一错误处理
|
|
114
|
+
if (error.response?.status === 401) {
|
|
115
|
+
message.error('登录已过期,请重新登录');
|
|
116
|
+
// 跳转到登录页
|
|
117
|
+
window.location.href = '/login';
|
|
118
|
+
} else {
|
|
119
|
+
message.error(error.response?.data?.message || '请求失败');
|
|
120
|
+
}
|
|
121
|
+
return Promise.reject(error);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
export default request;
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 2. 注入到组件库
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// src/main.ts 或 src/App.tsx
|
|
132
|
+
import { setApiServiceProvider } from '@baishuyun/ui-business';
|
|
133
|
+
import request from './api/request';
|
|
134
|
+
|
|
135
|
+
// 注入业务项目的 Axios 实例
|
|
136
|
+
setApiServiceProvider({
|
|
137
|
+
axiosInstance: request,
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## 高级配置
|
|
142
|
+
|
|
143
|
+
### 多环境配置
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// src/api/config.ts
|
|
147
|
+
const API_CONFIG = {
|
|
148
|
+
development: {
|
|
149
|
+
baseURL: 'http://localhost:3000/api',
|
|
150
|
+
timeout: 10000,
|
|
151
|
+
},
|
|
152
|
+
production: {
|
|
153
|
+
baseURL: 'https://api.example.com',
|
|
154
|
+
timeout: 5000,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const config = API_CONFIG[process.env.NODE_ENV as keyof typeof API_CONFIG];
|
|
159
|
+
|
|
160
|
+
const request = axios.create(config);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 请求重试机制
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// 添加请求重试逻辑
|
|
167
|
+
request.interceptors.response.use(
|
|
168
|
+
(response) => response,
|
|
169
|
+
async (error) => {
|
|
170
|
+
const config = error.config;
|
|
171
|
+
|
|
172
|
+
// 重试逻辑
|
|
173
|
+
if (!config._retry && error.response?.status >= 500) {
|
|
174
|
+
config._retry = true;
|
|
175
|
+
config._retryCount = (config._retryCount || 0) + 1;
|
|
176
|
+
|
|
177
|
+
if (config._retryCount <= 3) {
|
|
178
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
179
|
+
return request(config);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return Promise.reject(error);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Loading 状态管理
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// src/api/loading.ts
|
|
192
|
+
let loadingCount = 0;
|
|
193
|
+
|
|
194
|
+
const showLoading = () => {
|
|
195
|
+
if (loadingCount === 0) {
|
|
196
|
+
// 显示全局 loading
|
|
197
|
+
}
|
|
198
|
+
loadingCount++;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const hideLoading = () => {
|
|
202
|
+
loadingCount--;
|
|
203
|
+
if (loadingCount === 0) {
|
|
204
|
+
// 隐藏全局 loading
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// 在拦截器中使用
|
|
209
|
+
request.interceptors.request.use((config) => {
|
|
210
|
+
showLoading();
|
|
211
|
+
return config;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
request.interceptors.response.use(
|
|
215
|
+
(response) => {
|
|
216
|
+
hideLoading();
|
|
217
|
+
return response;
|
|
218
|
+
},
|
|
219
|
+
(error) => {
|
|
220
|
+
hideLoading();
|
|
221
|
+
return Promise.reject(error);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 动态配置
|
|
227
|
+
|
|
228
|
+
可以在运行时动态更换 Axios 实例:
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// 切换到不同的 API 环境
|
|
232
|
+
const switchToTestEnv = () => {
|
|
233
|
+
const testRequest = axios.create({
|
|
234
|
+
baseURL: 'https://test-api.example.com',
|
|
235
|
+
// 其他配置...
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
setApiServiceProvider({ axiosInstance: testRequest });
|
|
239
|
+
};
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## 注意事项
|
|
243
|
+
|
|
244
|
+
- ⚠️ **必须在使用组件库之前调用** `setApiServiceProvider`
|
|
245
|
+
- 📍 **推荐在应用入口文件**(如 `main.ts` 或 `App.tsx`)中进行配置
|
|
246
|
+
- 🔧 **Axios 实例应包含完整业务逻辑**(拦截器、错误处理、认证等)
|
|
247
|
+
- 🚫 **组件库不再提供内置的 HTTP 配置**,完全依赖外部注入
|
|
248
|
+
|
|
249
|
+
## 错误处理
|
|
250
|
+
|
|
251
|
+
如果未设置 API 服务提供者,组件库会抛出明确的错误提示:
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
Error: API 服务提供者未设置。请先调用 setApiServiceProvider() 设置 Axios 实例。
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
确保在使用任何组件库功能之前完成配置。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as f, Fragment as K } from "react/jsx-runtime";
|
|
2
2
|
import { c as w } from "../vendors/clsx.js";
|
|
3
|
-
import { u as D, a as C, b as ne, E as p, M as ce, T as de, P as pe, G as $, c as me, D as ue } from "./TabGroup-
|
|
3
|
+
import { u as D, a as C, b as ne, E as p, M as ce, T as de, P as pe, G as $, c as me, D as ue } from "./TabGroup-CznMwTOD.js";
|
|
4
4
|
import { Avatar as G, Button as V, Spin as ae } from "antd";
|
|
5
5
|
import { forwardRef as he, useRef as T, useImperativeHandle as fe, useState as k, useEffect as A, useMemo as z, useCallback as be } from "react";
|
|
6
6
|
import { Icon as S, Tree as se } from "bsy-react-ui";
|
|
@@ -18,10 +18,10 @@ import { g as Se } from "../vendors/services/data/member_limit.service.js";
|
|
|
18
18
|
import { g as Re } from "../vendors/services/data/member.service.js";
|
|
19
19
|
import { produce as Te } from "immer";
|
|
20
20
|
const Q = he(
|
|
21
|
-
(a,
|
|
21
|
+
(a, i) => {
|
|
22
22
|
const {
|
|
23
23
|
isMeasure: n = !1,
|
|
24
|
-
showEllipsisButton:
|
|
24
|
+
showEllipsisButton: l = !1,
|
|
25
25
|
onToggle: u,
|
|
26
26
|
hiddenCount: t = 0,
|
|
27
27
|
previewCount: d = 0
|
|
@@ -29,7 +29,7 @@ const Q = he(
|
|
|
29
29
|
dockcorp: m("department.externalContactGroup"),
|
|
30
30
|
dockcorpdept: m("department.contact")
|
|
31
31
|
}, N = (c) => v?.(h.filter((E) => E._id !== c));
|
|
32
|
-
return fe(
|
|
32
|
+
return fe(i, () => ({
|
|
33
33
|
measureRef: x.current,
|
|
34
34
|
ellipsisButtonRef: y.current
|
|
35
35
|
})), /* @__PURE__ */ e(
|
|
@@ -86,7 +86,7 @@ const Q = he(
|
|
|
86
86
|
E
|
|
87
87
|
);
|
|
88
88
|
}),
|
|
89
|
-
|
|
89
|
+
l && !n && /* @__PURE__ */ e("li", { ref: y, className: "entity-list__more", "data-button": "ellipsis-button", children: /* @__PURE__ */ f(
|
|
90
90
|
"div",
|
|
91
91
|
{
|
|
92
92
|
role: "button",
|
|
@@ -105,7 +105,7 @@ const Q = he(
|
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
107
|
), De = () => {
|
|
108
|
-
const { value: a = [], type:
|
|
108
|
+
const { value: a = [], type: i } = C(), { t: n } = D(), [l, u] = k(0), [t, { toggle: d }] = ye(!1), [m, h] = k(!1), [v, o] = k(null), b = T(null), x = T(null), y = [p.DEPARMENT, p.USER].includes(i) ? ce : de;
|
|
109
109
|
A(() => {
|
|
110
110
|
t && h(!0);
|
|
111
111
|
}, [t]);
|
|
@@ -117,7 +117,7 @@ const Q = he(
|
|
|
117
117
|
const g = () => {
|
|
118
118
|
requestAnimationFrame(() => {
|
|
119
119
|
if (c(!1), !b.current || !x.current) return;
|
|
120
|
-
const O = b.current.clientWidth, R = x.current.querySelectorAll(".measure-list li"),
|
|
120
|
+
const O = b.current.clientWidth, R = x.current.querySelectorAll(".measure-list li"), ie = x.current.querySelector(
|
|
121
121
|
'[data-button="ellipsis-button"]'
|
|
122
122
|
);
|
|
123
123
|
if (R.length === 0) {
|
|
@@ -137,9 +137,9 @@ const Q = he(
|
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
139
|
j = P, I = 0;
|
|
140
|
-
const
|
|
140
|
+
const le = ie?.offsetWidth || me;
|
|
141
141
|
for (let M = j; M < R.length; M++) {
|
|
142
|
-
const q = R[M].clientWidth + $, oe =
|
|
142
|
+
const q = R[M].clientWidth + $, oe = le;
|
|
143
143
|
if (I + q + oe < O)
|
|
144
144
|
I += q, U = M + 1;
|
|
145
145
|
else {
|
|
@@ -147,12 +147,12 @@ const Q = he(
|
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
l !== U && u(U);
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
153
|
g();
|
|
154
154
|
}, [a]);
|
|
155
|
-
const E = a.length -
|
|
155
|
+
const E = a.length - l, r = N && !t, s = z(() => t && x?.current?.querySelector('[data-role="measure-list"]')?.clientHeight || y, [y, t]);
|
|
156
156
|
return /* @__PURE__ */ e(
|
|
157
157
|
"div",
|
|
158
158
|
{
|
|
@@ -188,7 +188,7 @@ const Q = he(
|
|
|
188
188
|
children: /* @__PURE__ */ e(
|
|
189
189
|
Q,
|
|
190
190
|
{
|
|
191
|
-
previewCount: t ? a.length :
|
|
191
|
+
previewCount: t ? a.length : l,
|
|
192
192
|
showEllipsisButton: r,
|
|
193
193
|
hiddenCount: E,
|
|
194
194
|
onToggle: () => {
|
|
@@ -236,9 +236,9 @@ const Q = he(
|
|
|
236
236
|
}
|
|
237
237
|
);
|
|
238
238
|
}, Ce = (a) => {
|
|
239
|
-
const [
|
|
239
|
+
const [i, n] = re(a, {
|
|
240
240
|
defaultValue: a.tabs.length ? a.tabs[0].value : void 0
|
|
241
|
-
}), [
|
|
241
|
+
}), [l, u] = k(""), t = T(/* @__PURE__ */ new Map()), [d, m] = k({
|
|
242
242
|
width: 0,
|
|
243
243
|
transform: "translateX(0)"
|
|
244
244
|
}), h = T(_e((o) => a.onSearch?.(o), 250)).current;
|
|
@@ -256,8 +256,8 @@ const Q = he(
|
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
258
|
return A(() => {
|
|
259
|
-
|
|
260
|
-
}, [
|
|
259
|
+
i && v(i);
|
|
260
|
+
}, [i]), A(() => {
|
|
261
261
|
const o = a.tabs.length ? a.tabs[0].value : void 0;
|
|
262
262
|
o && v(o);
|
|
263
263
|
}, [a.tabs]), /* @__PURE__ */ f("div", { className: "tab-bar flex justify-between px-[10px] border-b border-[#e0e0e0] relative", children: [
|
|
@@ -280,8 +280,8 @@ const Q = he(
|
|
|
280
280
|
},
|
|
281
281
|
onClick: () => n(o.value),
|
|
282
282
|
className: w("tab-bar__list-item cursor-pointer relative py-1", {
|
|
283
|
-
"text-[#0265ff]":
|
|
284
|
-
"hover:text-[#0265ff]":
|
|
283
|
+
"text-[#0265ff]": i === o.value,
|
|
284
|
+
"hover:text-[#0265ff]": i !== o.value
|
|
285
285
|
}),
|
|
286
286
|
children: o.label
|
|
287
287
|
},
|
|
@@ -293,7 +293,7 @@ const Q = he(
|
|
|
293
293
|
"input",
|
|
294
294
|
{
|
|
295
295
|
type: "text",
|
|
296
|
-
value:
|
|
296
|
+
value: l,
|
|
297
297
|
onChange: (o) => {
|
|
298
298
|
u(o.target.value), h(o.target.value);
|
|
299
299
|
},
|
|
@@ -314,25 +314,25 @@ const Q = he(
|
|
|
314
314
|
] }) })
|
|
315
315
|
] });
|
|
316
316
|
}, Ie = (a) => {
|
|
317
|
-
const { containerHeight:
|
|
317
|
+
const { containerHeight: i } = C();
|
|
318
318
|
return /* @__PURE__ */ e(
|
|
319
319
|
"div",
|
|
320
320
|
{
|
|
321
321
|
className: w("tab-panel"),
|
|
322
322
|
style: {
|
|
323
|
-
height:
|
|
323
|
+
height: i + "px"
|
|
324
324
|
},
|
|
325
325
|
children: a.children
|
|
326
326
|
}
|
|
327
327
|
);
|
|
328
328
|
}, Pe = {
|
|
329
329
|
"selection-tabs": "_selection-tabs_88491_1"
|
|
330
|
-
}, Z = ({ avatarurl: a, randomColor:
|
|
330
|
+
}, Z = ({ avatarurl: a, randomColor: i, name: n, extra: l }) => /* @__PURE__ */ f("div", { className: "flex flex-1 gap-[6px] items-center overflow-hidden ml-[-16px]", children: [
|
|
331
331
|
a ? /* @__PURE__ */ e(G, { src: a, size: 20, style: { flexShrink: 0 } }) : /* @__PURE__ */ e(
|
|
332
332
|
G,
|
|
333
333
|
{
|
|
334
334
|
style: {
|
|
335
|
-
backgroundColor:
|
|
335
|
+
backgroundColor: i,
|
|
336
336
|
fontSize: "12px",
|
|
337
337
|
lineHeight: "13px",
|
|
338
338
|
width: "20px",
|
|
@@ -343,9 +343,9 @@ const Q = he(
|
|
|
343
343
|
}
|
|
344
344
|
),
|
|
345
345
|
/* @__PURE__ */ e("span", { className: "text-sm select-none text-ellipsis whitespace-nowrap overflow-hidden", children: n }),
|
|
346
|
-
|
|
346
|
+
l
|
|
347
347
|
] }), ee = (a) => {
|
|
348
|
-
const { type:
|
|
348
|
+
const { type: i, dispatch: n, value: l, containerHeight: u } = C(), { t } = D(), { data: d, loading: m } = H(
|
|
349
349
|
() => Ee({
|
|
350
350
|
groupLimit: [],
|
|
351
351
|
memberLimit: [],
|
|
@@ -414,7 +414,7 @@ const Q = he(
|
|
|
414
414
|
})
|
|
415
415
|
}
|
|
416
416
|
].filter((r) => r.children.length), _ = y.map((r) => r.value), N = v || m, c = (r) => {
|
|
417
|
-
if (p.USER ===
|
|
417
|
+
if (p.USER === i) {
|
|
418
418
|
const s = J(r, y);
|
|
419
419
|
s && n({
|
|
420
420
|
type: "insertOnly",
|
|
@@ -423,7 +423,7 @@ const Q = he(
|
|
|
423
423
|
}
|
|
424
424
|
});
|
|
425
425
|
}
|
|
426
|
-
if (p.USER_GROUP ===
|
|
426
|
+
if (p.USER_GROUP === i) {
|
|
427
427
|
const s = J(r, y);
|
|
428
428
|
n({
|
|
429
429
|
type: "addOne",
|
|
@@ -433,7 +433,7 @@ const Q = he(
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
}, E = (r) => {
|
|
436
|
-
p.USER !==
|
|
436
|
+
p.USER !== i && n({
|
|
437
437
|
type: "deleteOne",
|
|
438
438
|
payload: r
|
|
439
439
|
});
|
|
@@ -443,8 +443,8 @@ const Q = he(
|
|
|
443
443
|
se,
|
|
444
444
|
{
|
|
445
445
|
data: y,
|
|
446
|
-
checkType:
|
|
447
|
-
defaultSelectedKeys:
|
|
446
|
+
checkType: i === p.USER ? "radio" : "checkbox",
|
|
447
|
+
defaultSelectedKeys: l?.map((r) => r._id),
|
|
448
448
|
defaultExpandedKeys: _,
|
|
449
449
|
switcherIcon: (r) => /* @__PURE__ */ e(
|
|
450
450
|
S,
|
|
@@ -465,7 +465,7 @@ const Q = he(
|
|
|
465
465
|
!y.length && !N && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("span", { className: "text-[#999]", children: t("member.noAvailable") }) })
|
|
466
466
|
] });
|
|
467
467
|
}, te = (a) => {
|
|
468
|
-
const { type:
|
|
468
|
+
const { type: i, value: n, dispatch: l, containerHeight: u } = C(), { t } = D(), { data: d, loading: m } = H(
|
|
469
469
|
() => Re({
|
|
470
470
|
departmentLimit: [],
|
|
471
471
|
key: a.wd
|
|
@@ -482,7 +482,7 @@ const Q = he(
|
|
|
482
482
|
children: o.filter((s) => s.status === 1 && s.name?.includes(a.wd)).map((s) => ({
|
|
483
483
|
...s,
|
|
484
484
|
title: /* @__PURE__ */ f(K, { children: [
|
|
485
|
-
/* @__PURE__ */ e(ne, { type: "group" }),
|
|
485
|
+
/* @__PURE__ */ e(ne, { type: "group", size: 16 }),
|
|
486
486
|
/* @__PURE__ */ e("span", { className: "text-sm select-none text-ellipsis whitespace-nowrap overflow-hidden", children: s.name })
|
|
487
487
|
] })
|
|
488
488
|
}))
|
|
@@ -506,8 +506,8 @@ const Q = he(
|
|
|
506
506
|
].filter((s) => s.children.length), N = _.map((s) => s._id), c = (s, g) => {
|
|
507
507
|
if (!g)
|
|
508
508
|
return;
|
|
509
|
-
if (
|
|
510
|
-
|
|
509
|
+
if (i === p.DEPARMENT) {
|
|
510
|
+
l({
|
|
511
511
|
type: "insertOnly",
|
|
512
512
|
payload: {
|
|
513
513
|
...g,
|
|
@@ -517,7 +517,7 @@ const Q = he(
|
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
519
|
const L = o.some((O) => O._id === g._id);
|
|
520
|
-
|
|
520
|
+
l({
|
|
521
521
|
type: "addOne",
|
|
522
522
|
payload: {
|
|
523
523
|
...g,
|
|
@@ -526,7 +526,7 @@ const Q = he(
|
|
|
526
526
|
}
|
|
527
527
|
});
|
|
528
528
|
}, E = (s) => {
|
|
529
|
-
|
|
529
|
+
l({
|
|
530
530
|
type: "deleteOne",
|
|
531
531
|
payload: s
|
|
532
532
|
});
|
|
@@ -536,7 +536,7 @@ const Q = he(
|
|
|
536
536
|
se,
|
|
537
537
|
{
|
|
538
538
|
data: _,
|
|
539
|
-
checkType:
|
|
539
|
+
checkType: i === p.DEPARMENT ? "radio" : "checkbox",
|
|
540
540
|
selectedKeys: n?.map((s) => s._id),
|
|
541
541
|
fieldNames: {
|
|
542
542
|
title: "title",
|
|
@@ -563,22 +563,22 @@ const Q = he(
|
|
|
563
563
|
!_.length && !r && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("span", { className: "text-[#999]", children: t("department.noAvailable") }) })
|
|
564
564
|
] });
|
|
565
565
|
}, Me = () => {
|
|
566
|
-
const { type: a } = C(), { t:
|
|
566
|
+
const { type: a } = C(), { t: i } = D(), [n, l] = k(), u = Ne(), t = we(), d = {
|
|
567
567
|
[p.USER]: {
|
|
568
568
|
raw: /* @__PURE__ */ e(ee, { wd: n }),
|
|
569
|
-
placeholder:
|
|
569
|
+
placeholder: i("tabs.searchMember")
|
|
570
570
|
},
|
|
571
571
|
[p.USER_GROUP]: {
|
|
572
572
|
raw: /* @__PURE__ */ e(ee, { wd: n }),
|
|
573
|
-
placeholder:
|
|
573
|
+
placeholder: i("tabs.searchMember")
|
|
574
574
|
},
|
|
575
575
|
[p.DEPARMENT]: {
|
|
576
576
|
raw: /* @__PURE__ */ e(te, { wd: n }),
|
|
577
|
-
placeholder:
|
|
577
|
+
placeholder: i("tabs.searchDepartment")
|
|
578
578
|
},
|
|
579
579
|
[p.DEPARMENT_GROUP]: {
|
|
580
580
|
raw: /* @__PURE__ */ e(te, { wd: n }),
|
|
581
|
-
placeholder:
|
|
581
|
+
placeholder: i("tabs.searchDepartment")
|
|
582
582
|
}
|
|
583
583
|
}, h = z(() => ({
|
|
584
584
|
[p.USER]: u,
|
|
@@ -586,13 +586,13 @@ const Q = he(
|
|
|
586
586
|
[p.DEPARMENT]: t,
|
|
587
587
|
[p.DEPARMENT_GROUP]: t
|
|
588
588
|
}), [u, t])[a], [v, o] = k(h[0].value), b = (c) => {
|
|
589
|
-
o(c),
|
|
589
|
+
o(c), l(void 0);
|
|
590
590
|
}, x = h.find((c) => c.value === v)?.view, y = (c) => {
|
|
591
591
|
if (!c.trim().length) {
|
|
592
|
-
|
|
592
|
+
l(void 0);
|
|
593
593
|
return;
|
|
594
594
|
}
|
|
595
|
-
|
|
595
|
+
l(c);
|
|
596
596
|
}, _ = n ? d[a]?.raw : x, N = d[a]?.placeholder;
|
|
597
597
|
return /* @__PURE__ */ f("div", { className: w(Pe["selection-tabs"]), children: [
|
|
598
598
|
/* @__PURE__ */ e(
|
|
@@ -607,22 +607,22 @@ const Q = he(
|
|
|
607
607
|
),
|
|
608
608
|
/* @__PURE__ */ e(Ie, { children: _ })
|
|
609
609
|
] });
|
|
610
|
-
}, Ae = (a,
|
|
611
|
-
switch (
|
|
610
|
+
}, Ae = (a, i) => Te(a, (n) => {
|
|
611
|
+
switch (i.type) {
|
|
612
612
|
case "addOne": {
|
|
613
|
-
const
|
|
614
|
-
~n.findIndex((t) => t._id ===
|
|
613
|
+
const l = i.payload;
|
|
614
|
+
~n.findIndex((t) => t._id === l._id) || n.push(l);
|
|
615
615
|
break;
|
|
616
616
|
}
|
|
617
617
|
case "addMany": {
|
|
618
|
-
|
|
619
|
-
~n.findIndex((t) => t._id ===
|
|
618
|
+
i.payload.forEach((l) => {
|
|
619
|
+
~n.findIndex((t) => t._id === l._id) || n.push(l);
|
|
620
620
|
});
|
|
621
621
|
break;
|
|
622
622
|
}
|
|
623
623
|
case "removeMany": {
|
|
624
|
-
const
|
|
625
|
-
n.filter((t) =>
|
|
624
|
+
const l = i.payload;
|
|
625
|
+
n.filter((t) => l.includes(t._id)).forEach((t) => {
|
|
626
626
|
const d = n.findIndex((m) => m._id === t._id);
|
|
627
627
|
~d && n.splice(d, 1);
|
|
628
628
|
});
|
|
@@ -633,22 +633,22 @@ const Q = he(
|
|
|
633
633
|
break;
|
|
634
634
|
}
|
|
635
635
|
case "insertOnly": {
|
|
636
|
-
const
|
|
637
|
-
n.length && (n.length = 0), n.push(
|
|
636
|
+
const l = i.payload;
|
|
637
|
+
n.length && (n.length = 0), n.push(l);
|
|
638
638
|
break;
|
|
639
639
|
}
|
|
640
640
|
case "deleteOne": {
|
|
641
|
-
const
|
|
641
|
+
const l = i.payload, u = n.findIndex((t) => t._id === l);
|
|
642
642
|
~u && n.splice(u, 1);
|
|
643
643
|
break;
|
|
644
644
|
}
|
|
645
645
|
// 插入新元素 & 删除旧元素
|
|
646
646
|
case "deleteAndInsert": {
|
|
647
|
-
const { newItems:
|
|
647
|
+
const { newItems: l, oldIds: u } = i.payload;
|
|
648
648
|
u.forEach((t) => {
|
|
649
649
|
const d = n.findIndex((m) => m._id === t);
|
|
650
650
|
~d && n.splice(d, 1);
|
|
651
|
-
}),
|
|
651
|
+
}), l.forEach((t) => {
|
|
652
652
|
~n.findIndex((m) => m._id === t._id) || n.push(t);
|
|
653
653
|
});
|
|
654
654
|
}
|
|
@@ -656,14 +656,14 @@ const Q = he(
|
|
|
656
656
|
}), Oe = {
|
|
657
657
|
"depts-member-selector": "_depts-member-selector_d4xq4_1"
|
|
658
658
|
}, tt = (a) => {
|
|
659
|
-
const { onCancel:
|
|
659
|
+
const { onCancel: i, onConfirm: n, onChange: l, defaultValue: u, type: t = "user" } = a, { t: d } = D(), [m, h] = re(a, {
|
|
660
660
|
defaultValue: u || []
|
|
661
661
|
}), v = be(
|
|
662
662
|
(b) => {
|
|
663
663
|
const x = Ae(m, b);
|
|
664
|
-
h(x),
|
|
664
|
+
h(x), l?.(x);
|
|
665
665
|
},
|
|
666
|
-
[h, m,
|
|
666
|
+
[h, m, l]
|
|
667
667
|
), o = z(() => ({
|
|
668
668
|
type: t,
|
|
669
669
|
value: m,
|
|
@@ -691,7 +691,7 @@ const Q = he(
|
|
|
691
691
|
}
|
|
692
692
|
) }),
|
|
693
693
|
/* @__PURE__ */ f("div", { className: "flex-1 flex justify-end", children: [
|
|
694
|
-
/* @__PURE__ */ e(V, { onClick:
|
|
694
|
+
/* @__PURE__ */ e(V, { onClick: i, className: "btn-cancel", children: d("common.cancel") }),
|
|
695
695
|
/* @__PURE__ */ e(V, { type: "primary", className: "ml-3", onClick: () => n?.(m), children: d("common.confirm") })
|
|
696
696
|
] })
|
|
697
697
|
] })
|