282 lines
7.4 KiB
JavaScript
282 lines
7.4 KiB
JavaScript
![]() |
import React, {PureComponent} from 'react';
|
||
|
import {Divider,Button,Form,Card,Tabs,Table,Tooltip,Input,Select,Row,Col,message,Modal,Pagination,Spin} from 'antd';
|
||
|
// import './index.less';
|
||
|
import { connect } from "dva";
|
||
|
import { routerRedux } from 'dva/router';
|
||
|
import { getRoomId } from '@/utils/session';
|
||
|
import { getURLInformation } from '@/utils/CommonUtils';
|
||
|
|
||
|
@connect(({ bidev,loading }) => ({
|
||
|
...bidev
|
||
|
// preListLoading:loading.effects['bidev/fetchpreList'],
|
||
|
}))
|
||
|
class BPR extends PureComponent {
|
||
|
state={
|
||
|
tableloading:false,
|
||
|
preListLoading:false,
|
||
|
total:"",//供应商数量
|
||
|
page:"",//总页数
|
||
|
pageList:[],//供应商分页对应列表
|
||
|
currentPage:"",
|
||
|
dataSource:"",//当前页面数据源
|
||
|
ret:[],
|
||
|
supplierlist:[],
|
||
|
columns:[
|
||
|
{
|
||
|
title: '序号',
|
||
|
dataIndex: 'no',
|
||
|
key: 'no',
|
||
|
rowSpan :2,
|
||
|
render:(text,record,index)=>{
|
||
|
return (index+1)
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
title: '详审类型',
|
||
|
dataIndex: 'preType',
|
||
|
rowSpan :2,
|
||
|
render: (text, record, index) => {
|
||
|
if(record.colLength){
|
||
|
return { children: <>{text}</>, props: { colSpan: record.colLength }}
|
||
|
}else{
|
||
|
return { children: <>{text}</>, props: { rowSpan: record.rowLength }}
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
title: '详审因素',
|
||
|
dataIndex: 'rate',
|
||
|
rowSpan :2,
|
||
|
render: (text, record, index) => {
|
||
|
if(record.colLength){
|
||
|
return { children: <>{text}</>, props: { colSpan: 0 }}
|
||
|
}else{
|
||
|
return { children: <>{text}</> }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
componentDidMount(){
|
||
|
this.setState({
|
||
|
tableloading:true
|
||
|
})
|
||
|
const paramst={
|
||
|
assessRoomId:getRoomId(),
|
||
|
reviewTurnId:getURLInformation('turnId')
|
||
|
}
|
||
|
this.props.dispatch({
|
||
|
type:"bidev/fetchPreSupplierList",
|
||
|
payload:{...paramst},
|
||
|
callback:(response,txt)=>{
|
||
|
// let response=this.preSupplierList;
|
||
|
// let txt="success"
|
||
|
if(txt="success"){
|
||
|
if(response.data.length>0){
|
||
|
let rt=response.data.length;
|
||
|
// 生成供应商分页对应列表
|
||
|
let pageList=[];
|
||
|
let z=1; //供应商数量计算器
|
||
|
let itemt=[];
|
||
|
let key=1; //页数计算器
|
||
|
let page=Math.ceil(rt/3); //页数
|
||
|
for(let t of response.data){
|
||
|
itemt.push(t.supplierRegisterId)
|
||
|
if(z==rt || z%3==0){
|
||
|
let item2={
|
||
|
key:key,
|
||
|
value:itemt
|
||
|
}
|
||
|
pageList.push(item2)
|
||
|
itemt=[];
|
||
|
key++;
|
||
|
}
|
||
|
z++;
|
||
|
}
|
||
|
// console.log(pageList)
|
||
|
// 专家分页初始化
|
||
|
this.setState({
|
||
|
total:rt, //供应商数量
|
||
|
page:page, //页数
|
||
|
currentPage:1,//当前页数
|
||
|
pageList:pageList, //供应商分页对应列表
|
||
|
supplierlist:response.data
|
||
|
})
|
||
|
// 初始化完成
|
||
|
this.fetchColumns(response.data,pageList,1)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
async fetchColumns(supplierlist,pageList,currentPage){
|
||
|
// 推入专家columns
|
||
|
// 表columns初始化
|
||
|
const { columns }=this.state;
|
||
|
let columnst=columns;
|
||
|
let newList=[];
|
||
|
let prepageList=[];
|
||
|
// console.log(pageList)
|
||
|
for(let t of pageList){
|
||
|
if(t.key==currentPage){
|
||
|
prepageList=t.value;
|
||
|
}
|
||
|
}
|
||
|
// console.log(newList)
|
||
|
// 第一页
|
||
|
for(let res of supplierlist){
|
||
|
if(res.supplierRegisterId==prepageList[0] || res.supplierRegisterId==prepageList[1] || res.supplierRegisterId==prepageList[2]){
|
||
|
newList.push(res)
|
||
|
}
|
||
|
}
|
||
|
// console.log(newList)
|
||
|
for(let t of newList){
|
||
|
const dataIndex=t.supplierRegisterId;
|
||
|
let childrenlist=[]
|
||
|
// 遍历子级columns
|
||
|
if(t.members.length>0){
|
||
|
for(let k of t.members){
|
||
|
const dataIndex2=k.userId;
|
||
|
let item2={
|
||
|
key:k.userId,
|
||
|
title:k.name,
|
||
|
dataIndex: dataIndex+"#"+dataIndex2,
|
||
|
render:(text,record,index)=>{
|
||
|
return <>{text==undefined?"-":text}</>
|
||
|
}
|
||
|
}
|
||
|
childrenlist.push(item2)
|
||
|
}
|
||
|
}
|
||
|
const item={
|
||
|
title: t.supplierRegisterName,
|
||
|
dataIndex: dataIndex,
|
||
|
key: dataIndex,
|
||
|
colSpan :t.members.length, //被合并个数
|
||
|
children:childrenlist
|
||
|
}
|
||
|
columnst.push(item)
|
||
|
}
|
||
|
// console.log(columnst)
|
||
|
await this.props.dispatch({
|
||
|
type:"bidev/save",
|
||
|
payload:{
|
||
|
columns:columnst
|
||
|
}
|
||
|
})
|
||
|
this.setState({
|
||
|
tableloading:false
|
||
|
})
|
||
|
this.fetchDataSource(prepageList)
|
||
|
}
|
||
|
|
||
|
async fetchDataSource(prepageList){
|
||
|
// console.log(prepageList)
|
||
|
this.setState({
|
||
|
preListLoading:true
|
||
|
})
|
||
|
console.log(prepageList);
|
||
|
// const params={
|
||
|
// assessRoomId:"1331563852445253632",
|
||
|
// reviewTurnId:1,
|
||
|
// supplierRegisterIds:prepageList
|
||
|
// }
|
||
|
const params={
|
||
|
reviewTurnId:getURLInformation('turnId'),
|
||
|
reviewType:2,
|
||
|
supplierRegisterIds:prepageList
|
||
|
}
|
||
|
this.props.dispatch({
|
||
|
type:"bidev/fetchPreListt",
|
||
|
payload:{...params},
|
||
|
callback:(response,txt)=>{
|
||
|
// let txt="success";
|
||
|
// response=this.preList;
|
||
|
if(txt=="success"){
|
||
|
this.handleDataSource(response)
|
||
|
this.setState({
|
||
|
preListLoading:false
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
|
||
|
handleDataSource(response){
|
||
|
let preList=response.data;
|
||
|
let row=0;
|
||
|
// 获取行数
|
||
|
for(let t of preList){
|
||
|
if(t.detailList.length>0){
|
||
|
row=row+t.detailList.length;
|
||
|
}else{
|
||
|
return message.error("数据错误!")
|
||
|
}
|
||
|
}
|
||
|
let dataSource=[];
|
||
|
let tname="";
|
||
|
let zk=1;
|
||
|
// 生成数据
|
||
|
for(let t of preList){
|
||
|
for(let k of t.detailList){
|
||
|
let tk={...k.earlyExpertMap}
|
||
|
if(tname!="" && tname==t.name){
|
||
|
tk.preType="";
|
||
|
tk.rowLength=0;
|
||
|
}else{
|
||
|
tk.preType=t.name;
|
||
|
tk.rowLength=t.detailList.length;
|
||
|
}
|
||
|
tk.key=zk;
|
||
|
tk.rate=k.scoreItem;
|
||
|
// if(k.earlyExpertMap.length>0){
|
||
|
// tk.push(k.earlyExpertMap);
|
||
|
// }
|
||
|
// console.log(k.earlyExpertMap)
|
||
|
if(tk.key==row){
|
||
|
tk.preType="是否通过初审";
|
||
|
tk.colLength=2;
|
||
|
}
|
||
|
dataSource.push(tk);
|
||
|
zk++;
|
||
|
tname=t.name;
|
||
|
}
|
||
|
}
|
||
|
console.log(dataSource)
|
||
|
this.setState({
|
||
|
dataSource:dataSource,
|
||
|
row:row
|
||
|
})
|
||
|
}
|
||
|
|
||
|
render(){
|
||
|
const { tableloading,preListLoading,dataSource,currentPage,total,pageList,supplierlist }=this.state;
|
||
|
const { columns,preList }=this.props;
|
||
|
const onChange=(page, pageSize)=>{
|
||
|
this.setState({
|
||
|
currentPage:page
|
||
|
});
|
||
|
this.fetchColumns(supplierlist,pageList,page)
|
||
|
}
|
||
|
return <>
|
||
|
<Spin spinning={tableloading}>
|
||
|
<Table
|
||
|
loading={preListLoading}
|
||
|
columns={columns}
|
||
|
dataSource={dataSource!="" && dataSource}
|
||
|
pagination={false}
|
||
|
bordered
|
||
|
/>
|
||
|
<Pagination
|
||
|
style={{float:"right",marginTop:"10px"}}
|
||
|
current={currentPage}
|
||
|
total={total!="" && total}
|
||
|
defaultPageSize={3}
|
||
|
onChange={onChange}
|
||
|
/>
|
||
|
</Spin>
|
||
|
</>
|
||
|
}
|
||
|
}
|
||
|
export default BPR;
|