提交 fa77557e authored 作者: chscls@163.com's avatar chscls@163.com

树型菜单

上级 b44b8a49
...@@ -289,7 +289,14 @@ class TreeList extends React.Component { ...@@ -289,7 +289,14 @@ class TreeList extends React.Component {
objId: this.state.objId objId: this.state.objId
}, },
callback: () => { callback: () => {
this.getPage(); this.getPage({parentId: this.state.parentId},null,null, (list) => {
const treeData = this.refesh(this.state.parentId, list, this.state.treeData)
this.setState({
modalVisible: false,
treeData
});
})
}, },
}); });
}; };
...@@ -322,7 +329,6 @@ class TreeList extends React.Component { ...@@ -322,7 +329,6 @@ class TreeList extends React.Component {
showMobileDiv, showMobileDiv,
}) })
} }
console.log(showMobileDiv)
} }
//渲染值 //渲染值
componentDidMount() { componentDidMount() {
...@@ -560,18 +566,18 @@ class TreeList extends React.Component { ...@@ -560,18 +566,18 @@ class TreeList extends React.Component {
} }
sqlBs16=Base16Encode(this.props.sql) sqlBs16=Base16Encode(this.props.sql)
getPage = (params, values,callPage) => { getPage = (params, values,callPage,callback) => {
if(this.columns==null||this.columns.length==0){ if(this.columns==null||this.columns.length==0){
return; return;
} }
const { dispatch } = this.props; const { dispatch ,json:{treeParentIdName}} = this.props;
const pagination = this.state.data.pagination; const pagination = this.state.data.pagination;
if (params == null) { if (params == null) {
params = { params = {
pageNo: pagination.current ? pagination.current : 1, // pageNo: pagination.current ? pagination.current : 1,
pageSize: pagination.pageSize ? pagination.pageSize : (this.props.pageSize||10), //pageSize: pagination.pageSize ? pagination.pageSize : (this.props.pageSize||10),
query: JSON.stringify(values!=null?values:this.state.formValues), query: JSON.stringify(values!=null?values:this.state.formValues),
}; };
} }
...@@ -598,19 +604,28 @@ class TreeList extends React.Component { ...@@ -598,19 +604,28 @@ class TreeList extends React.Component {
}else{ }else{
dispatch({ dispatch({
type: 'formList/fetch', type: 'formList/tree',
payload: { payload: {
custom:this.custom, custom:this.custom,
...params, ...params,
parentIdName: treeParentIdName,
sql:this.sqlBs16, sql:this.sqlBs16,
dataObjId: this.state.objId, dataObjId: this.state.objId,
}, },
callback:(data)=>{ callback:(list)=>{
const data={
list:list,
pagination:false
}
if(!this.state.isReady){ if(!this.state.isReady){
this.setState({data,isReady:true}) this.setState({data,parentId:params.parentId,isReady:true},()=>{
if(callback) callback(list)
})
}else{ }else{
this.setState({data}) this.setState({data,parentId:params.parentId},()=>{
if(callback) callback(list)
})
} }
...@@ -641,9 +656,11 @@ class TreeList extends React.Component { ...@@ -641,9 +656,11 @@ class TreeList extends React.Component {
}; };
handleAdd = (fields, isAdd) => { handleAdd = (fields, isAdd) => {
const {json:{treeParentIdName}}=this.props
let params = { let params = {
...fields, ...fields,
}; };
params[treeParentIdName]=this.state.parentId
this.props.dispatch({ this.props.dispatch({
type: 'formList/add', type: 'formList/add',
payload: { payload: {
...@@ -655,10 +672,15 @@ class TreeList extends React.Component { ...@@ -655,10 +672,15 @@ class TreeList extends React.Component {
}, },
callback: () => { callback: () => {
message.success('操作成功'); message.success('操作成功');
this.getPage({parentId: this.state.parentId},null,null, (list) => {
const treeData = this.refesh(this.state.parentId, list, this.state.treeData)
this.setState({ this.setState({
modalVisible: false, modalVisible: false,
treeData
}); });
this.getPage(); })
}, },
}); });
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论