|
|
@ -5,6 +5,8 @@ import ajax from "@/services" |
|
|
|
import "./index.scss"; |
|
|
|
|
|
|
|
const isDev = window.location.href.indexOf('localhost') > -1 |
|
|
|
let testTemp = [] |
|
|
|
|
|
|
|
function OrgnizationMgm() { |
|
|
|
|
|
|
|
const [editStatus, setEditStatus] = useState(false) |
|
|
@ -52,8 +54,8 @@ function OrgnizationMgm() { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const getRoleTree = () => { |
|
|
|
ajax.getOrgRoleNodeList().then((e) => { |
|
|
|
const getRoleTree = (id) => { |
|
|
|
ajax.getOrgRoleNodeList({id: id}).then((e) => { |
|
|
|
if (e.status == 20000) { |
|
|
|
setRoleTree(e.data) |
|
|
|
} |
|
|
@ -63,8 +65,10 @@ function OrgnizationMgm() { |
|
|
|
const getOrgTree = () => { |
|
|
|
ajax.getOrgTree().then((e) => { |
|
|
|
if (e.status == 20000) { |
|
|
|
setOrgTree(e.data) |
|
|
|
handleTreeClick(undefined, {node: e.data[0]}) |
|
|
|
testTemp = e.data |
|
|
|
recursionTree(testTemp) |
|
|
|
setOrgTree(testTemp) |
|
|
|
handleTreeClick(undefined, {node: testTemp[0]}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
@ -166,15 +170,28 @@ function OrgnizationMgm() { |
|
|
|
} |
|
|
|
|
|
|
|
const handleTreeClick = (e, {node}) => { |
|
|
|
|
|
|
|
// 第三层级不予配置 |
|
|
|
if (node.level > 2) { |
|
|
|
setActiveOrg({}) |
|
|
|
message.error('不允许配置') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
getRoleTree(node.id) |
|
|
|
let ids = node.ids.split("-").filter(item => item != "undefined") |
|
|
|
ids.push(node.id) |
|
|
|
ajaxGetOrgDetail(node.id).then((data) => { |
|
|
|
setActiveOrg({ |
|
|
|
id: node.id, |
|
|
|
ids: ids, |
|
|
|
key: node.key, |
|
|
|
name: node.name, |
|
|
|
level: node.level, |
|
|
|
img_url: node.img_url, |
|
|
|
control_area: node.control_area, |
|
|
|
...data |
|
|
|
...data, |
|
|
|
role_auth: data.role_auth ? data.role_auth.map((id) => Number(id)) : [] |
|
|
|
}) |
|
|
|
baseForm.setFieldsValue({ |
|
|
|
platform: data.platform, |
|
|
@ -183,7 +200,7 @@ function OrgnizationMgm() { |
|
|
|
img_url: data.img_url |
|
|
|
}) |
|
|
|
setImgUrl(data.img_url) |
|
|
|
setRoleCheckedKeys(data.role_auth) |
|
|
|
setRoleCheckedKeys(data.role_auth ? data.role_auth.map((id) => Number(id)) : []) |
|
|
|
}).catch(err => { |
|
|
|
message.error(err) |
|
|
|
}) |
|
|
@ -220,12 +237,22 @@ function OrgnizationMgm() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const recursionTree = (treeData, pid) => { |
|
|
|
treeData.map((item) => { |
|
|
|
item.ids += '-' + pid |
|
|
|
if (item.children) { |
|
|
|
recursionTree(item.children, item.id) |
|
|
|
} |
|
|
|
return item |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleAreaTreeChange = (checkedKeys) => { |
|
|
|
baseForm.setFieldValue('control_area', checkedKeys.join(',')) |
|
|
|
} |
|
|
|
|
|
|
|
const handleRoleTreeChange = (checkedKeys) => { |
|
|
|
const handleRoleTreeChange = (checkedKeys, _) => { |
|
|
|
setRoleCheckedKeys(checkedKeys) |
|
|
|
} |
|
|
|
|
|
|
@ -249,7 +276,8 @@ function OrgnizationMgm() { |
|
|
|
const handleConfirm = () => { |
|
|
|
ajaxOrgDetailSave(Object.assign({}, baseForm.getFieldsValue(), { |
|
|
|
id: activeOrg.id, |
|
|
|
role: roleCheckedKeys.join(',') |
|
|
|
role: roleCheckedKeys.join(','), |
|
|
|
control_area: baseForm.getFieldValue('control_area').join(',') |
|
|
|
})).then((msg) => { |
|
|
|
message.success(msg) |
|
|
|
setEditStatus(false) |
|
|
@ -345,7 +373,7 @@ function OrgnizationMgm() { |
|
|
|
</Upload> |
|
|
|
</Form.Item> |
|
|
|
{ |
|
|
|
activeOrg.level > 2 ? <> |
|
|
|
activeOrg.level > 1 ? <> |
|
|
|
<Form.Item label="管辖范围" name="control_type"> |
|
|
|
<Select disabled={!editStatus}> |
|
|
|
<Option value={1}>按区管理</Option> |
|
|
@ -371,7 +399,7 @@ function OrgnizationMgm() { |
|
|
|
</div> |
|
|
|
), |
|
|
|
}, |
|
|
|
activeOrg.level > 2 ? { |
|
|
|
activeOrg.level > 1 ? { |
|
|
|
label: `功能配置`, |
|
|
|
key: '2', |
|
|
|
children: ( |
|
|
@ -381,10 +409,9 @@ function OrgnizationMgm() { |
|
|
|
<Tree |
|
|
|
disabled={!editStatus} |
|
|
|
checkable |
|
|
|
defaultCheckedKeys={roleCheckedKeys || []} |
|
|
|
treeData={roleTree} |
|
|
|
onCheck={handleRoleTreeChange} |
|
|
|
// checkedKeys={roleCheckedKeys} |
|
|
|
checkedKeys={roleCheckedKeys} |
|
|
|
fieldNames={{ |
|
|
|
title: 'name', |
|
|
|
key: 'id' |
|
|
@ -395,12 +422,12 @@ function OrgnizationMgm() { |
|
|
|
), |
|
|
|
} : undefined |
|
|
|
] |
|
|
|
}, [JSON.stringify(activeOrg), editStatus, imgUrl]) |
|
|
|
}, [JSON.stringify(activeOrg), editStatus, imgUrl, roleCheckedKeys]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
getOrgTree() |
|
|
|
getAreaTree() |
|
|
|
getRoleTree() |
|
|
|
// getRoleTree() |
|
|
|
}, []) |
|
|
|
|
|
|
|
const treeTitleRender = ({name, children, level, pid, id, virtually_code, lng_lat, code}) => { |
|
|
@ -437,18 +464,22 @@ function OrgnizationMgm() { |
|
|
|
<Tabs |
|
|
|
defaultActiveKey="1" |
|
|
|
onChange={(v) => setTabActive(v)} |
|
|
|
items={tabRender} |
|
|
|
items={Object.keys(activeOrg).length ? (activeOrg.level < 3 ? tabRender : null) : null } |
|
|
|
/> |
|
|
|
<div className="form-confirm"> |
|
|
|
{ |
|
|
|
!editStatus ? ( |
|
|
|
<Button type="primary" className="yisa-btn" onClick={() => handleEdit()}>编辑</Button> |
|
|
|
) : <> |
|
|
|
<Button type="primary" className="yisa-btn" onClick={() => handleConfirm()}>确认</Button> |
|
|
|
<Button type="ghost" className="yisa-btn" onClick={() => handleCancel()}>取消</Button> |
|
|
|
</> |
|
|
|
} |
|
|
|
</div> |
|
|
|
{ |
|
|
|
Object.keys(activeOrg).length ? ( |
|
|
|
<div className="form-confirm"> |
|
|
|
{ |
|
|
|
!editStatus ? ( |
|
|
|
<Button type="primary" className="yisa-btn" onClick={() => handleEdit()}>编辑</Button> |
|
|
|
) : <> |
|
|
|
<Button type="primary" className="yisa-btn" onClick={() => handleConfirm()}>确认</Button> |
|
|
|
<Button type="ghost" className="yisa-btn" onClick={() => handleCancel()}>取消</Button> |
|
|
|
</> |
|
|
|
} |
|
|
|
</div> |
|
|
|
) : null |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<Modal |
|
|
|