/*
 * Author: 黎永顺
 * name: 已发补发列表
 * Description:
 * Date: 2022/12/14
 */
import React, { Component } from "react";
import { WeaHelpfulTip, WeaInputNumber, WeaTable } from "ecCom";

class IssuedAndReissueTable extends Component {
  render() {
    const { dataSource, onChangeIssueReissueValue } = this.props;
    const columns = [
      {
        dataIndex: "salaryItemName",
        title: "薪资项目",
        render: (text) => {
          return <span className="tdEllipsis" title={text}>{text}</span>;
        }
      },
      {
        dataIndex: "resultValue",
        title: <span>
          <span style={{ marginRight: 8 }}>项目值</span>
          <WeaHelpfulTip
            title="若薪资项目有公式，手动编辑项目值后，需点击锁定图标输入值才生效；点击锁定图标，解锁手动编辑的项目值，公式生效，点击保存按照公式重新核算；重新核算后，不显示解锁图标。"
            placement="bottom"
            width={200}
          />
        </span>,
        render: (text, record) => {
          const { canEdit, pattern } = record, { viewAttr } = this.props;
          return <WeaInputNumber
            disabled={!canEdit}
            min={0}
            viewAttr={viewAttr}
            precision={pattern || 2}
            value={text || 0}
            onChange={(value) => onChangeIssueReissueValue(record.salaryItemName, value, "issuedAndReissueItems")}
          />;
        }
      },
      {
        dataIndex: "itemFormulaContent",
        title: <span>
          <span style={{ marginRight: 8 }}>核算公式</span>
          <WeaHelpfulTip
            title="若薪资项目有公式，且项目值手动编辑修改过并点击锁定图标，则公式失效；若解除锁定，则项目公式重新生效；"
            placement="bottom"
            width={200}
          />
        </span>,
        render: (text, record) => {
          return <span className="tdEllipsis" title={text}>{_.isNil(text) ? "输入" : text}</span>;
        }
      }
    ];
    return (
      <WeaTable
        rowKey="id"
        dataSource={dataSource}
        columns={columns}
        pagination={false}
      />
    );
  }
}

export default IssuedAndReissueTable;
