@qmlight/web-platform-components 1.0.2 → 1.0.5

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.
@@ -24,7 +24,15 @@ const TreeData = (props) => {
24
24
  const [itemKeys, setItemKeys] = useState<any[]>([]);
25
25
  const timer = useRef<any>(null);
26
26
  useEffect(() => {
27
- setItemKeys(selectedKeys || []);
27
+ if (selectedKeys) {
28
+ const treeList = getTreeList(treeData.current, []);
29
+ const newList = treeList
30
+ .filter((item) => selectedKeys.includes(item.id))
31
+ .map((item) => item.newId);
32
+ setItemKeys(newList || []);
33
+ }
34
+
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
28
36
  }, [selectedKeys]);
29
37
  const updateTreeData = (list, key, children) =>
30
38
  list.map((node) => {
@@ -90,10 +98,16 @@ const TreeData = (props) => {
90
98
  hasChildren: true,
91
99
  };
92
100
  const { newId, ...newParams } = params;
93
- console.log(newParams);
94
- const res = await (field.hasChildren
95
- ? getTreeDataList({ ...fetchParams, ...newParams })
96
- : getOrgPerson({ id: params.id }));
101
+ const res = await getTreeDataList({ ...fetchParams, ...newParams });
102
+ const resPer: any = await (type === 'default' && params.id
103
+ ? getOrgPerson({ id: params.id })
104
+ : new Promise((resolve) => {
105
+ resolve({
106
+ code: 200,
107
+ data: [],
108
+ message: '',
109
+ });
110
+ }));
97
111
 
98
112
  if (res.code === 200) {
99
113
  if (!params['id']) {
@@ -103,7 +117,9 @@ const TreeData = (props) => {
103
117
  ...item,
104
118
  checkable: getCheckAble(item),
105
119
  parentId: params.id,
120
+
106
121
  newId: item.id,
122
+
107
123
  isLeaf: getIsLeft(field.hasChildren, item.hasChildren),
108
124
  };
109
125
  });
@@ -125,22 +141,15 @@ const TreeData = (props) => {
125
141
  data: list,
126
142
  };
127
143
  } else {
128
- const resPer: any = await (type === 'default' && field.hasChildren
129
- ? getOrgPerson({ id: params.id })
130
- : new Promise((resolve) => {
131
- resolve({
132
- code: 200,
133
- data: [],
134
- message: '',
135
- });
136
- }));
137
144
  const person = resPer?.data?.map((item) => {
138
145
  return {
139
146
  ...item,
140
147
  isLeaf: true,
148
+ id: item.code,
141
149
  parentId: params.id,
142
- newId: `${params.id}_${item.id}`,
143
- checkable: getCheckAble(item),
150
+ oldId: item.id,
151
+ newId: `${params.id}_${item.code}`,
152
+ checkable: getCheckAble({ ...item, id: item.code }),
144
153
  };
145
154
  });
146
155
 
@@ -149,7 +158,7 @@ const TreeData = (props) => {
149
158
  ...item,
150
159
  isLeaf: getIsLeft(field.hasChildren, item.hasChildren),
151
160
  parentId: params.id,
152
- newId: field.hasChildren ? item.id : `${params.id}_${item.id}`,
161
+ newId: field.hasChildren ? item.id : `${params.id}_${item.code}`,
153
162
  checkable: getCheckAble(item),
154
163
  };
155
164
  });
@@ -215,9 +224,7 @@ const TreeData = (props) => {
215
224
  };
216
225
  useEffect(() => {
217
226
  if (searchTreeRef.current) {
218
- console.log(targetKeys);
219
227
  const treeList = getTreeList(treeData.current, []);
220
- console.log(treeList);
221
228
  treeList.forEach((item) => {
222
229
  if (item.orgtype === 0) {
223
230
  searchTreeRef.current.UPDATE_RECORD(item.id, {
@@ -314,7 +321,7 @@ const TreeData = (props) => {
314
321
  }}
315
322
  // checkStrictly={true}
316
323
  value={itemKeys}
317
- checkStrategy={'SHOW_PARENT'}
324
+ checkStrategy={type === 'default' ? 'SHOW_CHILD' : 'SHOW_PARENT'}
318
325
  onCheckChange={(node: any) => {
319
326
  clearTimeout(timer.current);
320
327
  timer.current = setTimeout(async () => {
@@ -4,9 +4,32 @@ import {
4
4
  getUsersByConditions,
5
5
  getOrgsByConditions,
6
6
  } from '../../SearchAssistanceSelect/src/SearchAssistanceComponent/api/tabList';
7
+ const items = [
8
+ {
9
+ label: '常用组',
10
+ key: '1',
11
+ },
12
+ // {
13
+ // label: '同部门',
14
+ // key: '2',
15
+ // },
16
+ // {
17
+ // label: '我的下属',
18
+ // key: '3',
19
+ // },
20
+ {
21
+ label: '组织结构',
22
+ key: '4',
23
+ type: 'default',
24
+ },
25
+ {
26
+ label: '自定义组',
27
+ key: '7',
28
+ type: 'customOrg',
29
+ },
30
+ ];
7
31
  const SearchAssistanceSelect = (props) => {
8
- const { value, onChange, option, $$form, modalVisible, type, mode, items, title, customData } =
9
- props;
32
+ const { value, onChange, option, $$form, modalVisible, type, mode, title, customData } = props;
10
33
  const getTypeCondtions = (type) => {
11
34
  switch (type) {
12
35
  case 'org':
@@ -28,7 +51,7 @@ const SearchAssistanceSelect = (props) => {
28
51
  },
29
52
  {
30
53
  label: '按列表',
31
- key: '5',
54
+ key: '9',
32
55
  type: 'org',
33
56
  },
34
57
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qmlight/web-platform-components",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "A platform components for React",
5
5
  "keywords": [
6
6
  "React",