|
|
@@ -7,7 +7,7 @@ import { connect } from 'dva'
|
|
|
import { ModalForm, ProFormText, ProFormSelect } from '@ant-design/pro-form'
|
|
|
|
|
|
const RoleMenu = props => {
|
|
|
- const { dispatch, departments = [], shouldUpdate } = props
|
|
|
+ const { dispatch, departments = [], parentId } = props
|
|
|
const [state, setState] = useState({
|
|
|
params: {},
|
|
|
visible: false
|
|
|
@@ -18,7 +18,7 @@ const RoleMenu = props => {
|
|
|
})
|
|
|
const handleAddDepartment = async values => {
|
|
|
setAddDepartment({ ...addDepartment, loading: true })
|
|
|
- const { code = -1 } = await apiaddDepartment({ ...values })
|
|
|
+ const { code = -1 } = await apiaddDepartment({ ...values, parentId })
|
|
|
if (code === consts.RET_CODE.SUCCESS) {
|
|
|
message.success('新增成功')
|
|
|
setState({ ...state, data: values })
|
|
|
@@ -31,6 +31,9 @@ const RoleMenu = props => {
|
|
|
payload: 'department'
|
|
|
})
|
|
|
}
|
|
|
+ useEffect(() => {
|
|
|
+ setState({ ...state, params: { ...state.params, parentId } })
|
|
|
+ }, [parentId])
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (!departments.length) {
|
|
|
@@ -53,13 +56,14 @@ const RoleMenu = props => {
|
|
|
创建部门
|
|
|
</Button>
|
|
|
}
|
|
|
- onFinish={handleAddDepartment}>
|
|
|
+ onFinish={handleAddDepartment}
|
|
|
+ parentId={{ parentId }}>
|
|
|
<ProFormText name="backstageMenuId" hidden />
|
|
|
<ProFormText name="name" label="新增部门" rules={[{ message: '请输入部门名称' }]} />
|
|
|
<ProFormSelect
|
|
|
width="md"
|
|
|
options={departments.map(item => ({ label: item.name, value: item.id }))}
|
|
|
- name="unusedMode"
|
|
|
+ name="parentId"
|
|
|
label="上级部门"
|
|
|
/>
|
|
|
</ModalForm>
|