import OrderApi from "@/api/order/order";
import type { editRequest } from "@/api/system/version";
import type { IContentConfig } from "@/components/CURD/types";
import { returnOptionsLabel } from "./config";
const contentConfig: IContentConfig = {
  pageName: "sys:user",
  table: {
    border: true,
    highlightCurrentRow: true,
  },
  pagination: {
    background: true,
    layout: "prev,pager,next,jumper,total,sizes",
    pageSize: 10,
    pageSizes: [10, 20, 30, 50],
  },
  async indexAction(params) {
    console.log(params);
    if (params.createAt) {
      params.startTime = params.createAt[0];
      params.endTime = params.createAt[1];
      delete params.createAt;
    }

    const res = await OrderApi.getList(params)
    console.log('OrderApi.getList', res);

    res.records.map(item => {
      item.payLoading = false
      item.printStatus = JSON.parse(item.printStatus || '[]')
    })
    return res;
  },
  indexActionData: {},
  // deleteAction: OrderApi.delete,
  // modifyAction: function (data) {
  //   // return OrderApi.edit(data);
  // },
  pk: "id",
  toolbar: [],
  defaultToolbar: ["refresh", "filter", "search"],
  cols: [
    { type: "selection", width: 50, align: "center" },
    // { label: "id", align: "center", prop: "id", width: 100, show: true },
    {
      label: "平台类型",
      align: "center",
      prop: "platformType",
      templet: "custom",
      slotName: "options",
    },
    {
      label: "订单号信息",
      align: "center",
      prop: "orderNo",
      templet: "custom",
      slotName: "orderNo",
    },
    {
      label: "商品信息",
      align: "center",
      templet: "custom",
      prop: "goods",
      slotName: "goods",
      width: 240,
    },
    {
      label: "台桌信息",
      align: "center",
      templet: "custom",
      slotName: "table",
      width: 150,
    },
    {
      label: "订单商品总价",
      align: "center",
      prop: "originAmount",
      templet: "custom",
      slotName: "originAmount",
      width: 120,
      hidden: true,
    },
    {
      label: "支付金额",
      align: "center",
      prop: "payAmount",
      width: 120,
    },
    {
      label: "支付方式",
      align: "center",
      prop: "payType",
      width: 120,
      templet: "custom",
      slotName: "payType",
    },
    {
      label: "订单金额 (扣除各类折扣)",
      align: "center",
      prop: "orderAmount",
      width: 120,
      hidden: true,
    },
    {
      label: "用餐模式",
      align: "center",
      prop: "dineMode",
      width: 120,
      templet: "custom",
      slotName: "options",
    },
    {
      label: "打印状态",
      align: "center",
      prop: "printStatus",
      width: 120,
      templet: "custom",
      slotName: "printStatus",
    },
    {
      label: "状态",
      align: "center",
      prop: "status",
      width: 120,
      templet: "custom",
      slotName: "state",
    },
    {
      label: "备注",
      align: "center",
      prop: "remark",
    },
    {
      label: "创建时间",
      align: "center",
      prop: "createTime",
    },
    {
      label: "操作",
      align: "center",
      fixed: "right",
      width: 180,
      templet: "custom",
      slotName: "operate",
    },
  ],
};

export default contentConfig;
