/*
 * Author: 黎永顺
 * name: 导入-步骤3
 * Description:
 * Date: 2023/8/11
 */
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTable } from "ecCom";
import successImg from "../../importModal/success.svg";
import MoveInResult from "./moveInResult";

const getLabel = WeaLocaleProvider.getLabel;

class ImpStep3 extends Component {
  render() {
    const { importResult } = this.props;
    return (
      <div className="weapp-batch-impsteps-picker-content-imp-step3">
        {
          importResult.results ? <MoveInResult dataSource={importResult.results}/> :
            <React.Fragment>
              {
                !_.isEmpty(importResult) ?
                  <div className="weapp-batch-impsteps-picker-spinText">
                    <p><img src={successImg} alt=""/></p>
                    {
                      importResult.successCount &&
                      <p>
                        <span>{getLabel(389249, "已导入")}</span>
                        <span style={{ color: "green" }}> {importResult.successCount}</span>&nbsp;&nbsp;
                        <span>{`${getLabel(30690, "条数据")},${getLabel(25009, "失败")}`}</span>
                        <span
                          style={{ color: "red" }}> {importResult.errorCount}&nbsp;&nbsp;</span>{getLabel(30690, "条数据")}
                      </p>
                    }
                  </div> :
                  <div className="weapp-batch-impsteps-picker-spinText">
                    <p>{getLabel(111, "导入失败")}</p>
                  </div>
              }
              {
                !_.isEmpty(importResult) && (!_.isEmpty(importResult.errorNotice) || !_.isEmpty(importResult.errorData)) &&
                <WeaTable
                  columns={[
                    {
                      title: getLabel(25700, "错误信息"),
                      dataIndex: "message"
                    }
                  ]}
                  dataSource={importResult.errorData || importResult.errorNotice} pagination={false}
                  scroll={{ y: `calc(100vh - 387px)` }}
                />
              }
            </React.Fragment>
        }
      </div>
    );
  }
}

export default ImpStep3;
