import React from "react"; import Taro from "@tarojs/taro"; import { Popup, Button, Cell, Icon, Empty } from "@antmjs/vantui"; import { ScrollView, View } from "@tarojs/components"; import { getSysOrg } from "@/services/sysorg"; import VABC from "@/components/VABC"; import Tree from "@/components/Tree"; import { arr2Tree } from "@/utils/array"; const wrapperStyle = { width: "90vw", height: "100vh", paddingBottom: "env(safe-area-inset-bottom)", }; export default function OrgTree(props) { const { show, onCancel, onChange } = props; const [dict, setDict] = React.useState([]); const [checked, setChecked] = React.useState(); const onSubmit = () => { if (!checked) return; onChange(checked?.orgId, checked); }; const onCheck = (e, it) => { // e.stopPropagation(); // e.preventDefault(); setChecked(it); }; React.useEffect(() => { getSysOrg({ pageSize: 500, isResponsible: 1, parentId: props.parentId, }).then((res) => { const [treeData] = arr2Tree(res.records || [], "orgPId", "orgId"); console.log("-------treeData-------", treeData); setDict(treeData); }); }, [props.parentId]); return ( } style={wrapperStyle} > {dict.length == 0 ? ( ) : ( ( {checked?.orgId == it.orgId ? ( ) : ( )} } renderIcon={ it.children?.length > 0 ? ( ) : ( ) } onClick={(e) => onCheck(e, it)} /> )} /> )} ); }