import CONFIG from "@/config";

export default function useColumns() {
  const TableColumns = [
    {
      item: { key: "year", title: "年度", require: true },
      attr: {
        is: "el-date-picker",
        type: "year",
        valueFormat: "yyyy-MM-dd",
      },
    },
    {
      item: { key: "name", title: "模板名称", require: true },
      attr: { is: "el-input" },
    },
    {
      item: { key: "startTime", title: "开始日期", require: true },
      attr: {
        is: "el-date-picker",
        valueFormat: "yyyy-MM-dd",
      },
    },
    {
      item: { key: "deadlineTime", title: "结束日期", require: true },
      attr: {
        is: "el-date-picker",
        valueFormat: "yyyy-MM-dd",
      },
    },
    {
      item: { key: "cycle", title: "周期", require: true },
      attr: {
        is: "el-select",
        dictName: "mk_periodic_unit",
      },
    },
    {
      item: { key: "unfold", title: "按列展开"},
      attr: {
        is: "el-select",
        dictName: "mk_expansion_mode",
        clearable: true,
      },
    },
  ].map(({ item, attr }) => ({
    attr,
    item: { ...item, hidden: true, span: item.span || 6 },
  }));

  const TabColumns = [
    {
      item: {
        title: "指标",
        key: "indexs",
      },
      attr: {
        value: [],
      },
      TableColumns: [
        {
          item: { key: "target", title: "指标", width: 'auto' },
          attr: {
            is: "el-select",
            dictName: "mk_index_type",
          },
        },
      ],
    },
    {
      item: {
        title: "维度",
        key: "dimensionalitys"
      },
      attr: {
        value: [],
      },
      TableColumns: [
        {
          item: { key: "dimensionality", title: "维度", width: 'auto' },
          attr: {
            is: "el-select",
            dictName: "mk_dimensionality",
          },
        },
      ],
    },
    {
      item: {
        title: "周期",
        key: "cycles",
      },
      attr: {
        value: [],
      },
      TableColumns: [
        {
          item: { key: "name", title: "周期名称", require: true },
          attr: { is: "el-input" },
        },
        {
          item: {
            key: "startTime",
            title: "周期开始日期",
            require: true,
          },
          attr: {
            is: "el-date-picker",
            // valueFormat: "yyyy-MM-dd",
            // value: new Date(),
          },
        },
        {
          item: {
            key: "deadlineTime",
            title: "周期结束日期",
            require: true,
            width: 'auto'
          },
          attr: {
            is: "el-date-picker",
            // valueFormat: "yyyy-MM-dd",
            // value: new Date(),
          },
        },
      ],
    },
  ];

  return { TableColumns, TabColumns };
}
