import React, { Component } from "react";
import { WeaTable } from "ecCom";
import "./index.less";

class Index extends Component {

  render() {
    const { columns, xWidth = 1440 } = this.props;
    const unifiedColumns = _.map(columns, (item, index) => {
      if (index === 0 || index === 2) {
        return { ...item, fixed: "left", width: 150 };
      } else if (index === 1) {
        return { ...item, fixed: "left", width: 176 };
      }
      if (item.dataIndex === "operate") {
        return { ...item, fixed: "right", width: item.width || "120px" };
      }
      return { ...item, width: "33%" };
    });
    return (
      <WeaTable className="unifiedTable" {...this.props} columns={unifiedColumns} scroll={{ x: xWidth }}/>
    );
  }
}

export default Index;
