import { ContentConfig } from "/@/components/PageContent";
import { httpList } from "/@/api/interest/dataShare";
import { renderStatus } from "/@/utils/column-helper";
import { STATUS_OPTIONS } from "/@/config/status";
import { shareTypeOptions } from "./_options";

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    prop: "menu_list",
    label: "菜单数据",
    width: 210,
    cellRenderer({ row }) {
      return row.menu_list.map(({ menu_name }) => menu_name).join(",");
    }
  },
  {
    prop: "source_nickname",
    label: "数据源用户",
    width: 110
  },
  {
    prop: "source_group_title",
    label: "数据源用户组",
    width: 270
  },
  {
    prop: "nickname",
    label: "数据共享用户",
    width: 110
  },
  {
    prop: "group_title",
    label: "数据共享用户组",
    width: 270
  },
  {
    prop: "type",
    label: "数据权限",
    width: "140",
    ...renderStatus(shareTypeOptions, "type")
  },
  {
    prop: "addtime",
    width: "145px",
    label: "创建时间"
  },
  {
    prop: "status",
    label: "状态",
    width: "80px",
    ...renderStatus(STATUS_OPTIONS)
  },
  {
    label: "操作",
    fixed: "right",
    width: 60,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "数据共享",
  columns,
  apis: {
    httpList
  }
};

export default contentConfig;
