<Table
offsetHeight={299}
getList={(params, updateRows, updateCount) => {
StatisticsPropertyAreaServer.list({"id":this.state.selectedQuestionnaireName.id}, (json,index) => {
//updateRows(json.success);
//console.log('josn',json.success)
let itemData = json.success;
let arr=[],list1 = [],indexs = 0;
itemData.map((item)=> {
if(arr.length === 0){
list1[indexs] = [];
arr.push(item.id);
list1[indexs].push(item);
} else if(arr.indexOf(item.id) >= 0){
list1[indexs].push(item);
} else {
indexs++;
list1[indexs] = [];
arr.push(item.id);
list1[indexs].push(item);
}
});
let arrList = [];
if(list1.length >= 1) {
list1.map((item1,idx)=> {
let list = [];
item1 && item1.length > 0 && item1.map((item2,idx2)=>{
let name = 'name'+idx2;
let value = item2.districtName + '('+ (item2.percent *100).toFixed(2) +'%)';
list.push({name,value,newNane: item2.name});
});
let listItem = {};
listItem.newName = list[0].newNane;
list.map((item)=>{
listItem[item.name] = item.value;
});
arrList.push(listItem);
})
}
//console.log(arrList);
//
updateRows(arrList);
});
}}
columns={[
{header: "问题", width: 200, accessor: ({newName}) => (
<span>{newName}</span>
)},
{header: "第一名", accessor: ({name0}) => (
<span>{name0}</span>
)},
{header: "第二名", accessor: ({name1}) => (
<span>{name1}</span>
)},
{header: "第三名", accessor: ({name2}) => (
<span>{name2}</span>
)},
{header: "第四名", accessor: ({name3}) => (
<span>{name3}</span>
)},
{header: "第五名", accessor: ({name4}) => (
<span>{name4}</span>
)},
{header: "最后第五", accessor: ({name5}) => (
<span>{name5}</span>
)},
{header: "最后第四", accessor: ({name6}) => (
<span>{name6}</span>
)},
{header: "最后第三", accessor: ({name7}) => (
<span>{name7}</span>
)},
{header: "最后第二", accessor: ({name8}) => (
<span>{name8}</span>
)},
{header: "最后第一", accessor: ({name9}) => (
<span>{name9}</span>
)},
]}
params={{
...this.state.params,
// classificationId: this.state.selectedClassification.id,
// districtId: this.props.district.id
}}
ref={table => this.table = table}/>
-----------------------------------------一维数组转二维数组--------------------------------------------------
["狂发有","咯哦哦对"] 转成 [["狂","发","有"],["咯","哦","哦","对"]]
arr.map(item => departmentX.push(item.split('')));