Closed xyzdata closed 7 years ago
嗯,开发过程中,确实有对dva项目的目录结构进行了细微调整,只是components中放的并不是你所的reducers。建议你先学习下dva,可能对项目的目录结构就会有些理解了,谢谢。
由于你使用了封装的 <DropOption />
组件, 我不知道如何将 table 的 record 数据,传递给 modal !
{
title: '操作',
key: 'operation',
width: 100,
render: (text, record) => {
return(
<DropOption
onMenuClick={e => handleMenuClick(record, e)}
menuOptions={[
{key: '1', name: '更新'},
{key: '2', name: '删除'}
]}
datas={record}
/>
)
}
}
onMenuClick
将 record 数据传递给了 List 的 onEditItem(record);
onMenuClick={e => handleMenuClick(record, e)}
const handleMenuClick = (record, e) => {
if (e.key === '1') {
onEditItem(record);
} else if (e.key === '2') {
confirm({
title: '确定删除此记录吗?',
onOk () {
onDeleteItem(record.id);
}
});
}
};
// table props
const listProps = {
dataSource: list,
loading: loading.effects['user/query'],
pagination,
location,
isMotion,
onChange (page) {
const { query, pathname } = location;
dispatch(routerRedux.push({
pathname,
query: {
...query,
page: page.current,
pageSize: page.pageSize
}
}))
},
onDeleteItem (id) {
console.log(`id`, id);
dispatch({
type: 'user/delete',
payload: id
})
},
onEditItem (item) {
console.log(`item`, item);
dispatch({
type: 'user/showModal',
payload: {
modalType: 'update',
currentItem: item
}
})
},
rowSelection: {
selectedRowKeys,
onChange: (keys) => {
dispatch({
type: 'user/updateState',
payload: {
selectedRowKeys: keys
}
})
}
}
};
dataSource: list,
// modal props
const modalProps = {
item:`
${
modalType === 'create'
? {}
: currentItem
}
`,
visible: modalVisible,
maskClosable: false,
confirmLoading: loading.effects['user/update'],
title: `
${modalType === 'create'
? '创建 User'
: '更新 User'}
`,
dataSource: list,
wrapClassName: 'vertical-center-modal',
onOk(data) {
console.log(` onOk(data) =`, data);
dispatch({type: `user/${modalType}`, payload: data});
},
onCancel() {
dispatch({type: 'user/hideModal'});
}
};
Anybody can help ?
找半天,才发现 reducers 都被放到了components 中, route 里面放了 UI components!
反正我看得一头雾水,不知道能否提供一个该项目的源码学习的项目路径图?
PS: redux 刚刚使用,不对之处还望指正!