import UserAPI from "@/api/onlineShop/goodsGroupconfig";

import RoleAPI from "@/api/system/role";
import type { UserPageQuery } from "@/api/system/user";
import type { IContentConfig } from "@/components/CURD/types";

const contentConfig: IContentConfig<UserPageQuery> = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  pagination: {
    background: true,
    layout: "prev,pager,next,jumper,total,sizes",
    pageSize: 20,
    pageSizes: [10, 20, 30, 50],
  },
  indexActionData: {},
  indexAction: function (params) {
    return UserAPI.getPage(params);
  },
  deleteAction: UserAPI.deleteByIds,
  // importAction(file) {
  //   return UserAPI.import(1, file);
  // },
  // exportAction: UserAPI.export,
  // importTemplate: UserAPI.downloadTemplate,
  modifyAction: function (params) {
    let obj = { ...params }
    return UserAPI.updates(obj);
  },
  importsAction(data) {
    // 模拟导入数据
    console.log("importsAction", data);
    return Promise.resolve();
  },
  exportsAction: async function (params) {
    // 模拟获取到的是全量数据
    const res = await UserAPI.getPage(params);
    console.log("exportsAction", res.list);
    return res.list;
  },
  pk: "id",
  toolbar: [
    {
      icon: "Plus",
      text: "新增",
      type: "success",
      name: "custom1",
      auth: "import",
    },
  ],
  cols: [
    { label: "排序", align: "center", prop: "sort", },
    { label: "分组名称", align: "center", prop: "name", },
    {
      label: "售卖时间管控",
      slotName: "timemanagement",
      templet: "custom",
      align: "center",
    },
    {
      label: "状态",
      align: "center",
      prop: "status",
      templet: "switch",
      slotName: "status",
    },
    {
      label: "操作",
      align: "center",
      fixed: "right",
      width: 280,
      templet: "tool",
      operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}],
    },
  ],
};

export default contentConfig;
