export default function useColumns() {
  const FormColumns = [
    {
      item: { key: "code", title: "编码", },
      attr: {
        is: "el-input",
        clearable: true,
        disabled: true,
        placeholder: "编码后端自动生成",
      },
    },
    {
      item: { key: "goalName", title: "目标名称", },
      attr: {
        is: "el-input",
        clearable: true,
        disabled: true,
        placeholder: "目标名称后端自动生成",
      },
    },
    {
      item: { key: "documentDate", title: "单据日期", required: true, },
      attr: {
        is: "el-date-picker",
        type: "date",
        format: "yyyy-MM-dd",
        placeholder: "选择日期",
      },
    },
    {
      item: { key: "annual", title: "年度", required: true, },
      attr: {
        is: "el-date-picker",
        type: "year",
        format: "yyyy",
        placeholder: "选择年度",
      },
    },
    {
      item: { key: "custom", title: "客户", required: true, },
      attr: {
        is: "el-popover-select-v2",
        valueKey: "name",
        referName: "CUSTOMER_PARAM",
        dataMapping: {
          customCode: 'code',
        },
        placeholder: "请输入客户",
      },
    },
    {
      item: { key: "saleZone", title: "销售区域", required: true, },
      attr: {
        is: "el-popover-select-v2",
        valueKey: "name",
        referName: "MK_SALESAREA_PARAM",
        dataMapping: {
          saleZoneCode: 'code',
        },
        placeholder: "请输入销售区域",
      },
    },
    {
      item: { key: "creator", title: "制单人", required: true, },
      attr: {
        is: "el-popover-select-v2",
        valueKey: "name",
        referName: "CONTACTS_PARAM",
        dataMapping: {
          creatorCode: 'code',
        },
        placeholder: "请输入制单人",
      },
    },
    {
      item: { key: "dept", title: "部门", required: true, },
      attr: {
        is: "el-popover-select-v2",
        valueKey: "name",
        referName: "DEPT_PARAM",
        dataMapping: {
          deptId: 'id',
        },
        placeholder: "请输入部门",
      },
    },
    {
      item: { key: "goalTotal", title: "目标合计（元）", },
      attr: {
        is: "el-input-number",
        placeholder: "目标合计自动计算",
        disabled: true,
        precision: 2,
        controlsPosition: "right",
      },
    },
    {
      item: { key: "notes", title: "备注", },
      attr: {
        is: "el-input",
        placeholder: "请输入备注",
        clearable: true,
      },
    },
    {
      item: { key: "status", title: "单据状态", },
      attr: {
        is: "el-select",
        dictName: "sys_status",
        disabled: true,
      },
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      span: item.span || 6
    },
  }));

  const TabColumns = [
    {
      item: { key: "annualGoalMergeDetails", title: "年销售目标填报明细", },
      attr: { value: [] },
      TableColumns: [
        {
          item: { key: "oneLevelClassify", title: "一级分类", },
          attr: {},
        },
        {
          item: { key: "twoLevelClassify", title: "二级分类", },
          attr: {},
        },
        {
          item: { key: "material", title: "物料", },
          attr: {
            is: "el-popover-select-v2",
            valueKey: "name",
            referName: "MATERIAL_PARAM",
            dataMapping: {
              materialCode: 'code',
              oneLevelClassify: 'oneClass',
              // oneLevelClassifyCode: 'oneClass',
              twoLevelClassify: 'twoClass',
              // twoLevelClassifyCode: 'twoClass',
            },
            placeholder: "请输入物料",
          },
        },
        {
          item: { key: "totalGoal", title: "合计（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            disabled: true,
            isSummary: true,
            // formatter: (prop) => {
            //   const month = ['januaryGoal', 'februaryGoal', 'marchGoal', 'aprilGoal', 'mayGoal', 'juneGoal',
            //     'julyGoal', 'augustGoal', 'septemberGoal', 'octoberGoal', 'novemberGoal', 'decemberGoal'];

            //   return month.reduce((sum, item) => {
            //     return sum += (prop[item] ? prop[item] : 0) * 1
            //   }, 0).toFixed(2);
            // },
          },
        },
        {
          item: { key: "januaryGoal", title: "一月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "februaryGoal", title: "二月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "marchGoal", title: "三月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "aprilGoal", title: "四月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "mayGoal", title: "五月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "juneGoal", title: "六月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "julyGoal", title: "七月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "augustGoal", title: "八月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "septemberGoal", title: "九月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "octoberGoal", title: "十月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "novemberGoal", title: "十一月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },
        {
          item: { key: "decemberGoal", title: "十二月（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            isSummary: true,
            controlsPosition: "right",
          },
        },

      ],
    },
  ];
  return { FormColumns, TabColumns }
}