@qmlight/web-platform-components 1.0.1 → 1.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.
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef, useLayoutEffect } from
|
|
2
|
-
import { DcpButton, DcpModal, Collapse, Spin } from
|
|
3
|
-
import { PlusOutlined } from
|
|
1
|
+
import React, { useState, useEffect, useRef, useLayoutEffect } from "react";
|
|
2
|
+
import { DcpButton, DcpModal, Collapse, Spin } from "dcp-design-react";
|
|
3
|
+
import { PlusOutlined } from "@/icons";
|
|
4
4
|
import {
|
|
5
5
|
getAllCustomGroups,
|
|
6
6
|
createCustomGroups,
|
|
7
7
|
deleteCustomGroup,
|
|
8
8
|
getUsersByCustomGroup,
|
|
9
|
-
} from
|
|
10
|
-
import TabList from
|
|
11
|
-
import
|
|
12
|
-
import { Message } from
|
|
13
|
-
import CustomModal from
|
|
14
|
-
import { EditOutlined, DeleteOutlined } from
|
|
9
|
+
} from "../../api/tabList";
|
|
10
|
+
import TabList from "../tabList";
|
|
11
|
+
import "./style.less";
|
|
12
|
+
import { Message } from "@/utils";
|
|
13
|
+
import CustomModal from "./customModal";
|
|
14
|
+
import { EditOutlined, DeleteOutlined } from "@/icons";
|
|
15
15
|
const { Panel } = Collapse;
|
|
16
16
|
const CustomOrg = (props) => {
|
|
17
17
|
const {
|
|
@@ -26,7 +26,7 @@ const CustomOrg = (props) => {
|
|
|
26
26
|
const [dataSource, setData] = useState<any>([]);
|
|
27
27
|
const [itemKeys, setItemKeys] = useState<any[]>([]);
|
|
28
28
|
const [actionInfo, setAcitonInfo] = useState<any>({
|
|
29
|
-
type:
|
|
29
|
+
type: "add",
|
|
30
30
|
visible: false,
|
|
31
31
|
});
|
|
32
32
|
const [fetchParams, setFetchParams] = useState({});
|
|
@@ -36,7 +36,7 @@ const CustomOrg = (props) => {
|
|
|
36
36
|
const userList = React.useRef<any[]>([]);
|
|
37
37
|
const dataList = React.useRef<any>([]);
|
|
38
38
|
const [loading, setLoading] = useState(false);
|
|
39
|
-
const [loaingChild, setLoadingChild] = useState(
|
|
39
|
+
const [loaingChild, setLoadingChild] = useState("");
|
|
40
40
|
const getData = async (flag?) => {
|
|
41
41
|
setLoading(true);
|
|
42
42
|
const res = await getAllCustomGroups({}).finally(() => {
|
|
@@ -47,18 +47,21 @@ const CustomOrg = (props) => {
|
|
|
47
47
|
return {
|
|
48
48
|
...item,
|
|
49
49
|
key: item.id,
|
|
50
|
-
orgtype:
|
|
50
|
+
orgtype: "customOrg",
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
if (mode) {
|
|
55
55
|
userList.current = list;
|
|
56
|
+
setData(list);
|
|
57
|
+
dataList.current = list;
|
|
56
58
|
onDataChange && onDataChange(list);
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
61
|
if (flag) {
|
|
60
62
|
dataList.current = list.map((item) => {
|
|
61
|
-
const field =
|
|
63
|
+
const field =
|
|
64
|
+
dataList.current.find((items) => items.id === item.id) || {};
|
|
62
65
|
return {
|
|
63
66
|
...item,
|
|
64
67
|
...field,
|
|
@@ -67,8 +70,6 @@ const CustomOrg = (props) => {
|
|
|
67
70
|
setData(dataList.current);
|
|
68
71
|
return;
|
|
69
72
|
} else {
|
|
70
|
-
setData(list);
|
|
71
|
-
dataList.current = list;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
const firstId = list.find((_, index) => index === 0).id;
|
|
@@ -119,18 +120,19 @@ const CustomOrg = (props) => {
|
|
|
119
120
|
setItemKeys(selectedKeys || []);
|
|
120
121
|
}, [selectedKeys]);
|
|
121
122
|
const itemSelect = (value, checked) => {
|
|
122
|
-
if (mode ===
|
|
123
|
+
if (mode === "multiple") {
|
|
123
124
|
onItemSelect && onItemSelect(value, checked);
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
127
|
setItemKeys([value]);
|
|
127
128
|
const field = userList.current.find((item) => item.id === value);
|
|
128
|
-
onValueChange &&
|
|
129
|
+
onValueChange &&
|
|
130
|
+
onValueChange({ ...field, value: field.id, label: field.title });
|
|
129
131
|
};
|
|
130
132
|
const onItemAction = async (act, item) => {
|
|
131
|
-
if (act ===
|
|
133
|
+
if (act === "edit") {
|
|
132
134
|
setAcitonInfo({
|
|
133
|
-
type:
|
|
135
|
+
type: "edit",
|
|
134
136
|
data: {
|
|
135
137
|
id: item.id,
|
|
136
138
|
title: item.title,
|
|
@@ -140,10 +142,10 @@ const CustomOrg = (props) => {
|
|
|
140
142
|
});
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
|
-
if (act ===
|
|
145
|
+
if (act === "del") {
|
|
144
146
|
const res = await deleteCustomGroup({ id: item.id });
|
|
145
147
|
if (res.code === 200) {
|
|
146
|
-
Message(
|
|
148
|
+
Message("删除成功", "success");
|
|
147
149
|
|
|
148
150
|
getData(true);
|
|
149
151
|
}
|
|
@@ -152,7 +154,7 @@ const CustomOrg = (props) => {
|
|
|
152
154
|
|
|
153
155
|
const onClose = (id?) => {
|
|
154
156
|
setAcitonInfo({
|
|
155
|
-
type:
|
|
157
|
+
type: "add",
|
|
156
158
|
visible: false,
|
|
157
159
|
});
|
|
158
160
|
if (!mode && id) {
|
|
@@ -163,12 +165,12 @@ const CustomOrg = (props) => {
|
|
|
163
165
|
};
|
|
164
166
|
const actionHandle = (e, flag, info) => {
|
|
165
167
|
e.stopPropagation();
|
|
166
|
-
if (flag ===
|
|
167
|
-
onItemAction(
|
|
168
|
+
if (flag === "edit") {
|
|
169
|
+
onItemAction("edit", info);
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
170
|
-
if (flag ===
|
|
171
|
-
onItemAction(
|
|
172
|
+
if (flag === "del") {
|
|
173
|
+
onItemAction("del", info);
|
|
172
174
|
}
|
|
173
175
|
};
|
|
174
176
|
|
|
@@ -181,7 +183,7 @@ const CustomOrg = (props) => {
|
|
|
181
183
|
icon={<PlusOutlined />}
|
|
182
184
|
onClick={() => {
|
|
183
185
|
setAcitonInfo({
|
|
184
|
-
type:
|
|
186
|
+
type: "add",
|
|
185
187
|
visible: true,
|
|
186
188
|
});
|
|
187
189
|
}}
|
|
@@ -197,7 +199,9 @@ const CustomOrg = (props) => {
|
|
|
197
199
|
setActiveKeys(val);
|
|
198
200
|
if (val.length) {
|
|
199
201
|
const newId = val[val.length - 1];
|
|
200
|
-
const userFlag = dataList.current.find(
|
|
202
|
+
const userFlag = dataList.current.find(
|
|
203
|
+
(item) => item.id === newId,
|
|
204
|
+
)?.userList;
|
|
201
205
|
if (!userFlag) {
|
|
202
206
|
getUserData(newId);
|
|
203
207
|
}
|
|
@@ -212,11 +216,11 @@ const CustomOrg = (props) => {
|
|
|
212
216
|
extra={
|
|
213
217
|
<div className="item-action">
|
|
214
218
|
<EditOutlined
|
|
215
|
-
onClick={(e) => actionHandle(e,
|
|
219
|
+
onClick={(e) => actionHandle(e, "edit", item)}
|
|
216
220
|
style={{ marginRight: 8, fontSize: 14 }}
|
|
217
221
|
/>
|
|
218
222
|
<DeleteOutlined
|
|
219
|
-
onClick={(e) => actionHandle(e,
|
|
223
|
+
onClick={(e) => actionHandle(e, "del", item)}
|
|
220
224
|
style={{ marginRight: 8, fontSize: 14 }}
|
|
221
225
|
/>
|
|
222
226
|
</div>
|
|
@@ -227,7 +231,9 @@ const CustomOrg = (props) => {
|
|
|
227
231
|
onItemSelect={itemSelect}
|
|
228
232
|
selectedKeys={itemKeys}
|
|
229
233
|
// loading={item.id === loaingChild}
|
|
230
|
-
dataSource={item.userList?.filter(
|
|
234
|
+
dataSource={item.userList?.filter(
|
|
235
|
+
(items) => !targetKeys.includes(items.id),
|
|
236
|
+
)}
|
|
231
237
|
/>
|
|
232
238
|
</Panel>
|
|
233
239
|
);
|
|
@@ -235,15 +241,17 @@ const CustomOrg = (props) => {
|
|
|
235
241
|
</Collapse>
|
|
236
242
|
</div>
|
|
237
243
|
)}
|
|
238
|
-
{mode ===
|
|
244
|
+
{mode === "multiple" && (
|
|
239
245
|
<div className="custom-org-page-list">
|
|
240
246
|
<TabList
|
|
241
247
|
onDoubleClickChange={onDoubleClickChange}
|
|
242
248
|
onItemSelect={itemSelect}
|
|
243
249
|
selectedKeys={itemKeys}
|
|
244
|
-
type={
|
|
250
|
+
type={"edit"}
|
|
245
251
|
onItemAction={onItemAction}
|
|
246
|
-
dataSource={dataSource.filter(
|
|
252
|
+
dataSource={dataSource.filter(
|
|
253
|
+
(item) => !targetKeys.includes(item.id),
|
|
254
|
+
)}
|
|
247
255
|
/>
|
|
248
256
|
</div>
|
|
249
257
|
)}
|
|
@@ -254,11 +262,11 @@ const CustomOrg = (props) => {
|
|
|
254
262
|
visible={actionInfo.visible}
|
|
255
263
|
onClose={() =>
|
|
256
264
|
setAcitonInfo({
|
|
257
|
-
type:
|
|
265
|
+
type: "add",
|
|
258
266
|
visible: false,
|
|
259
267
|
})
|
|
260
268
|
}
|
|
261
|
-
wrapClassName={
|
|
269
|
+
wrapClassName={"search-assistance-modal"}
|
|
262
270
|
>
|
|
263
271
|
<CustomModal
|
|
264
272
|
actionInfo={actionInfo}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from
|
|
2
|
-
import TabList from
|
|
3
|
-
import { getUsersByConditions, getOrgsByConditions } from
|
|
4
|
-
import { Pagination } from
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
+
import TabList from "../tabList";
|
|
3
|
+
import { getUsersByConditions, getOrgsByConditions } from "../../api/tabList";
|
|
4
|
+
import { Pagination } from "dcp-design-react";
|
|
5
5
|
|
|
6
6
|
const SearchPageIndex = (props) => {
|
|
7
7
|
const {
|
|
@@ -27,16 +27,17 @@ const SearchPageIndex = (props) => {
|
|
|
27
27
|
setItemKeys(selectedKeys || []);
|
|
28
28
|
}, [selectedKeys]);
|
|
29
29
|
const itemSelect = (value, checked) => {
|
|
30
|
-
if (mode ===
|
|
30
|
+
if (mode === "multiple") {
|
|
31
31
|
onItemSelect && onItemSelect(value, checked);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
setItemKeys([value]);
|
|
35
35
|
const field = dataSource.find((item) => item.id === value);
|
|
36
|
-
onValueChange &&
|
|
36
|
+
onValueChange &&
|
|
37
|
+
onValueChange({ ...field, value: field.id, label: field.userName });
|
|
37
38
|
};
|
|
38
39
|
const fetchHandleApi = async (params) => {
|
|
39
|
-
if (type !==
|
|
40
|
+
if (type !== "org") {
|
|
40
41
|
return getUsersByConditions(params);
|
|
41
42
|
}
|
|
42
43
|
return getOrgsByConditions(params);
|
|
@@ -74,7 +75,7 @@ const SearchPageIndex = (props) => {
|
|
|
74
75
|
useEffect(() => {
|
|
75
76
|
if (fetchParams.currentPage) {
|
|
76
77
|
if (fetchParams.name) {
|
|
77
|
-
getData({ ...fetchParams
|
|
78
|
+
getData({ ...fetchParams });
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|