import React, { Component } from "react";
import { WeaLocaleProvider } from "ecCom";
import Content from "./content";
import "./index.less";

const getLabel = WeaLocaleProvider.getLabel;

class Index extends Component {
  render() {
    return (
      <div className="pbpc-content">
        <div className="weapp-salary-sp weapp-salary-payroll-pc-preview"><Content {...this.props}/></div>
      </div>
    );
  }
}

export default Index;

export const dealTemplate = (itemTypeList, type) => {
  let cloneItemTypeList = _.cloneDeep(itemTypeList);
  let showData = [], onlyOneGrup = false;
  cloneItemTypeList.forEach((group) => {
    const { items, groupName, groupId } = group;
    if (items.length !== 0) {
      items.forEach((item) => {
        item.salaryItemValue = !_.isNil(item.salaryItemValue) ? item.salaryItemValue : "";
      });
      if (items.length % 2 && type === "pc") items.push({});
      // 未分类不展示标题
      // if (!groupId.includes("222222222222222222")) {
        showData.push({ groupId, groupName, items });
      // } else {
      //   showData.push({ items });
      // }
    }
  });
  if (cloneItemTypeList.length === 1) {
    onlyOneGrup = true;
    // 只有一个分组的时候不展示分组名
    cloneItemTypeList[0].name = "";
  }
  return { onlyOneGrup, showData };
};
