|
@@ -1,69 +1,89 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import Taro from '@tarojs/taro';
|
3
|
|
-import { Popup, Button, Cell, Icon } from '@antmjs/vantui';
|
4
|
|
-import { ScrollView, View } from '@tarojs/components';
|
5
|
|
-import { getSysOrg } from '@/services/sysorg';
|
6
|
|
-import VABC from '@/components/VABC';
|
7
|
|
-import Tree from '@/components/Tree';
|
8
|
|
-import { arr2Tree } from '@/utils/array';
|
|
1
|
+import React from "react";
|
|
2
|
+import Taro from "@tarojs/taro";
|
|
3
|
+import { Popup, Button, Cell, Icon, Empty } from "@antmjs/vantui";
|
|
4
|
+import { ScrollView, View } from "@tarojs/components";
|
|
5
|
+import { getSysOrg } from "@/services/sysorg";
|
|
6
|
+import VABC from "@/components/VABC";
|
|
7
|
+import Tree from "@/components/Tree";
|
|
8
|
+import { arr2Tree } from "@/utils/array";
|
9
|
9
|
|
10
|
10
|
const wrapperStyle = {
|
11
|
|
- width: '90vw',
|
12
|
|
- height: '100vh',
|
13
|
|
- paddingBottom: 'env(safe-area-inset-bottom)',
|
14
|
|
-}
|
|
11
|
+ width: "90vw",
|
|
12
|
+ height: "100vh",
|
|
13
|
+ paddingBottom: "env(safe-area-inset-bottom)",
|
|
14
|
+};
|
15
|
15
|
|
16
|
16
|
export default function OrgTree(props) {
|
17
|
17
|
const { show, onCancel, onChange } = props;
|
18
|
18
|
|
19
|
19
|
const [dict, setDict] = React.useState([]);
|
20
|
20
|
const [checked, setChecked] = React.useState();
|
21
|
|
-
|
|
21
|
+
|
22
|
22
|
const onSubmit = () => {
|
23
|
23
|
if (!checked) return;
|
24
|
|
- onChange(checked?.orgId, checked)
|
25
|
|
- }
|
|
24
|
+ onChange(checked?.orgId, checked);
|
|
25
|
+ };
|
26
|
26
|
|
27
|
27
|
const onCheck = (e, it) => {
|
28
|
28
|
// e.stopPropagation();
|
29
|
29
|
// e.preventDefault();
|
30
|
30
|
setChecked(it);
|
31
|
|
- }
|
32
|
|
-
|
|
31
|
+ };
|
|
32
|
+
|
33
|
33
|
React.useEffect(() => {
|
34
|
|
- getSysOrg({pageSize: 500, isResponsible: 1, parentId: props.parentId }).then(res => {
|
35
|
|
- const [treeData] = arr2Tree(res.records || [], 'orgPId', 'orgId');
|
36
|
|
- console.log('-------treeData-------', treeData)
|
|
34
|
+ getSysOrg({
|
|
35
|
+ pageSize: 500,
|
|
36
|
+ isResponsible: 1,
|
|
37
|
+ parentId: props.parentId,
|
|
38
|
+ }).then((res) => {
|
|
39
|
+ const [treeData] = arr2Tree(res.records || [], "orgPId", "orgId");
|
|
40
|
+ console.log("-------treeData-------", treeData);
|
37
|
41
|
setDict(treeData);
|
38
|
|
- })
|
|
42
|
+ });
|
39
|
43
|
}, [props.parentId]);
|
40
|
44
|
|
41
|
45
|
return (
|
42
|
|
- <Popup position="right" show={show} onClose={onCancel} >
|
|
46
|
+ <Popup position="right" show={show} onClose={onCancel}>
|
43
|
47
|
<VABC
|
44
|
|
- footer={(
|
45
|
|
- <View style={{ padding: '8px 2em' }}>
|
46
|
|
- <Button block type="primary" disabled={!checked} onClick={onSubmit}>确定</Button>
|
|
48
|
+ footer={
|
|
49
|
+ <View style={{ padding: "8px 2em" }}>
|
|
50
|
+ <Button block type="primary" disabled={!checked} onClick={onSubmit}>
|
|
51
|
+ 确定
|
|
52
|
+ </Button>
|
47
|
53
|
</View>
|
48
|
|
- )}
|
|
54
|
+ }
|
49
|
55
|
style={wrapperStyle}
|
50
|
56
|
>
|
51
|
|
- <ScrollView scrollY style={{ height: '100%' }}>
|
52
|
|
- <Tree
|
53
|
|
- data={dict}
|
54
|
|
- renderTitle={(it) => (
|
55
|
|
- <Cell
|
56
|
|
- title={it.name}
|
57
|
|
- value={(
|
58
|
|
- <View>
|
59
|
|
- { checked?.orgId == it.orgId ? <Icon name="success" color="#1A7565" /> : <View style={{ width: '100%', minHeight: '10px' }} /> }
|
60
|
|
- </View>
|
61
|
|
- )}
|
62
|
|
- renderIcon={it.children?.length > 0 ? <Icon name="arrow" /> : <View style={{ minWidth: '16px' }} />}
|
63
|
|
- onClick={e => onCheck(e, it)}
|
64
|
|
- />
|
65
|
|
- )}
|
66
|
|
- />
|
|
57
|
+ <ScrollView scrollY style={{ height: "100%" }}>
|
|
58
|
+ {dict.length == 0 ? (
|
|
59
|
+ <Empty description="暂无数据" />
|
|
60
|
+ ) : (
|
|
61
|
+ <Tree
|
|
62
|
+ data={dict}
|
|
63
|
+ renderTitle={(it) => (
|
|
64
|
+ <Cell
|
|
65
|
+ title={it.name}
|
|
66
|
+ value={
|
|
67
|
+ <View>
|
|
68
|
+ {checked?.orgId == it.orgId ? (
|
|
69
|
+ <Icon name="success" color="#1A7565" />
|
|
70
|
+ ) : (
|
|
71
|
+ <View style={{ width: "100%", minHeight: "10px" }} />
|
|
72
|
+ )}
|
|
73
|
+ </View>
|
|
74
|
+ }
|
|
75
|
+ renderIcon={
|
|
76
|
+ it.children?.length > 0 ? (
|
|
77
|
+ <Icon name="arrow" />
|
|
78
|
+ ) : (
|
|
79
|
+ <View style={{ minWidth: "16px" }} />
|
|
80
|
+ )
|
|
81
|
+ }
|
|
82
|
+ onClick={(e) => onCheck(e, it)}
|
|
83
|
+ />
|
|
84
|
+ )}
|
|
85
|
+ />
|
|
86
|
+ )}
|
67
|
87
|
</ScrollView>
|
68
|
88
|
</VABC>
|
69
|
89
|
</Popup>
|