export default function useColumns() {
  const FormColumns = [
    {
      item: { key: "code", title: "编码" },
      attr: {
        is: "el-input",
        placeholder: "编码后端自动生成",
        disabled: true,
      },
    },
    {
      item: { key: "goalName", title: "目标名称" },
      attr: {
        is: "el-input",
        placeholder: "目标名称后端自动生成",
        disabled: true,
      },
    },
    {
      item: { key: "documentDate", title: "单据日期", required: true, },
      attr: {
        is: "el-date-picker",
        type: "date",
        placeholder: "选择单据日期",
        valueFormat: "yyyy-MM-dd",
      },
    },
    {
      item: { key: "annual", title: "年度", required: true, },
      attr: {
        is: "el-date-picker",
        type: "year",
        placeholder: "选择年度",
        valueFormat: "yyyy",
      },
    },
    {
      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: "status", title: "单据状态" },
      attr: {
        is: "el-select",
        dictName: "sys_status",
        disabled: true,
      },
    },
    {
      item: { key: "goalTotal", title: "目标合计（元）" },
      attr: {
        is: "el-input-number",
        min: 0,
        step: 0.1,
        precision: 2,
        disabled: true,
        placeholder: "目标值汇总自动计算",
      },
    },
    {
      item: { key: "goalCategory", title: "目标类型", required: true, },
      attr: {
        is: "el-select",
        dictName: "annualSale_type",
        placeholder: "请选择",
      },
    },
    {
      item: { key: "saleZone", title: "销售区域" },
      attr: {
        is: "el-popover-select-v2",
        valueKey: "name",
        referName: "MK_SALESAREA_PARAM",
        dataMapping: {
          saleZoneCode: 'code',
        },
        placeholder: "请输入销售区域",
      }
    },
    {
      item: { key: "oneLevelClassify", title: "一级分类" },
      attr: {
        is: "el-popover-tree-select",
        referName: "MATERIALCLASSIFY_PARAM",
        placeholder: "请输入一级分类",
        valueKey: "name",
        onlyFinal: false,
        defaultProps: {
          label: function (data, node) {
            return data.code + "-" + data.name;
          },
          children: "children",
        },
        dataMapping: {
          oneLevelClassifyCode: "code",
        },
      }
    },
    {
      item: { key: "twoLevelClassify", title: "二级分类" },
      attr: {
        is: "el-popover-tree-select",
        referName: "MATERIALCLASSIFY_PARAM",
        placeholder: "请输入二级分类",
        valueKey: "name",
        onlyFinal: false,
        defaultProps: {
          label: function (data, node) {
            return data.code + "-" + data.name;
          },
          children: "children",
        },
        dataMapping: {
          twoLevelClassifyCode: "code",
        },
      }
    },
    {
      item: { key: "notes", title: "备注" },
      attr: {
        is: "el-input",
        placeholder: "请输入备注",
      },
    },

  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      span: item.span || 6,
    }
  }));

  const TabColumns = [
    // 年销售目标合并明细
    {
      item: { key: "annualGoalMergeDetailsList", title: "年销售目标合并明细" },
      attr: { value: [], },
      TableColumns: [
        {
          item: { key: "saleOrg", title: "销售组织" },
          attr: {},
        },
        {
          item: { key: "saleZone", title: "销售区域" },
          attr: {},
        },
        {
          item: { key: "custom", title: "客户" },
          attr: {},
        },
        {
          item: { key: "creator", title: "负责人" },
          attr: {},
        },
        {
          item: { key: "oneLevelClassify", title: "一级分类" },
          attr: {},
        },
        {
          item: { key: "twoLevelClassify", title: "二级分类" },
          attr: {},
        },
        {
          item: { key: "totalGoal", title: "合计（元）", },
          attr: {
            is: "el-input-number",
            min: 0,
            step: 0.1,
            precision: 2,
            disabled: true,
            isSummary: true,
          },
        },
        {
          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",
          },
        },
      ],
    },
    // 区域目标汇总（年）
    {
      item: { key: "areaDetailList", title: "区域目标汇总(年)" },
      attr: { value: [], },
      TableColumns: [
        {
          item: { key: "saleOrg", title: "销售组织" },
          attr: {},
        },
        {
          item: { key: "saleZone", title: "销售区域" },
          attr: {},
        },
        {
          item: { key: "creator", title: "负责人" },
          attr: {},
        },
        {
          item: { key: "totalGoal", title: "合计（元）" },
          attr: {},
        },
        {
          item: { key: "januaryGoal", title: "一月（元）" },
          attr: {},
        },
        {
          item: { key: "februaryGoal", title: "二月（元）" },
          attr: {},
        },
        {
          item: { key: "marchGoal", title: "三月（元）" },
          attr: {},
        },
        {
          item: { key: "aprilGoal", title: "四月（元）" },
          attr: {},
        },
        {
          item: { key: "mayGoal", title: "五月（元）" },
          attr: {},
        },
        {
          item: { key: "juneGoal", title: "六月（元）" },
          attr: {},
        },
        {
          item: { key: "julyGoal", title: "七月（元）" },
          attr: {},
        },
        {
          item: { key: "augustGoal", title: "八月（元）" },
          attr: {},
        },
        {
          item: { key: "septemberGoal", title: "九月（元）" },
          attr: {},
        },
        {
          item: { key: "octoberGoal", title: "十月（元）" },
          attr: {},
        },
        {
          item: { key: "novemberGoal", title: "十一月（元）" },
          attr: {},
        },
        {
          item: { key: "decemberGoal", title: "十二月（元）" },
          attr: {},
        },
      ],
    },
    // 客户目标汇总（年）
    {
      item: { key: "customerDetailList", title: "客户目标汇总(年)" },
      attr: { value: [], },
      TableColumns: [
        {
          item: { key: "saleOrg", title: "销售组织" },
          attr: {},
        },
        {
          item: { key: "saleZone", title: "销售区域" },
          attr: {},
        },
        {
          item: { key: "custom", title: "客户" },
          attr: {},
        },
        {
          item: { key: "totalGoal", title: "合计（元）" },
          attr: {},
        },
        {
          item: { key: "januaryGoal", title: "一月（元）" },
          attr: {},
        },
        {
          item: { key: "februaryGoal", title: "二月（元）" },
          attr: {},
        },
        {
          item: { key: "marchGoal", title: "三月（元）" },
          attr: {},
        },
        {
          item: { key: "aprilGoal", title: "四月（元）" },
          attr: {},
        },
        {
          item: { key: "mayGoal", title: "五月（元）" },
          attr: {},
        },
        {
          item: { key: "juneGoal", title: "六月（元）" },
          attr: {},
        },
        {
          item: { key: "julyGoal", title: "七月（元）" },
          attr: {},
        },
        {
          item: { key: "augustGoal", title: "八月（元）" },
          attr: {},
        },
        {
          item: { key: "septemberGoal", title: "九月（元）" },
          attr: {},
        },
        {
          item: { key: "octoberGoal", title: "十月（元）" },
          attr: {},
        },
        {
          item: { key: "novemberGoal", title: "十一月（元）" },
          attr: {},
        },
        {
          item: { key: "decemberGoal", title: "十二月（元）" },
          attr: {},
        },
      ],
    },
  ];
  return { FormColumns, TabColumns }
}