import React from "react";
import { WeaDialog, WeaTable } from "ecCom";

export default class LedgerSalaryItemPreviewModal extends React.Component {
  getColumns = () => {
    const { empFields, itemGroups } = this.props;
    let columns = [];
    empFields.map(item => {
      columns.push({
        title: item.fieldName,
        dataIndex: item.fieldId,
        width: 150
      });
    });
    _.map(_.filter(itemGroups, it => !_.isEmpty(it.items)), child => {
      let columnItem = {
        title: child.name,
        children: _.filter(child.items, t => t.itemHide !== "1").map(i => {
          return {
            title: i.name,
            dataIndex: i.id,
            width: 150
          };
        })
      };
      columnItem.children.length > 0 && columns.push(columnItem);
    });
    return { columns };
  };

  render() {
    const { onCancel, visible } = this.props;
    return (
      <WeaDialog
        visible={visible}
        title="预览"
        style={{ width: "80vw", height: 200 }}
        onCancel={onCancel}
      >
        <WeaTable columns={this.getColumns().columns} dataSource={[]} scroll={{ x: 1200 }}/>
      </WeaDialog>
    );
  }
}
