import { DescItem } from '/@/components/Description/index';
import { BasicColumn } from '/@/components/Table/src/types/table';
import { Button } from '/@/components/Button';
// import { h } from 'vue';
// import { Time } from '/@/components/Time';
import { Badge } from 'ant-design-vue';

function renderOrderStatusLabel(type: number): string {
  switch (type) {
    case 0:
      return '待付款';
    case 101:
      return '已取消';
    case 201:
      return '已付款';
    case 1:
      return '已发货';
    case 2:
      return '已收货';
    case 501:
      return '完成';
    default:
      return '';
  }
}

function formatDayTime(val) {
  if (val) {
    const date = new Date(val);
    const Y = date.getFullYear();
    let M = date.getMonth() + 1;
    let D = date.getDate();

    if (M < 10) {
      M = '0' + M;
    }
    if (D < 10) {
      D = '0' + D;
    }

    return Y + '-' + M + '-' + D;
  } else {
    return '';
  }
}
export const personData = {
  b1: '付小小',
  b2: '18100000000',
  b3: '菜鸟仓储',
  b4: '浙江省杭州市西湖区万塘路18号',
  b5: '无',
};
export const goodsSchema: DescItem[] = [
  // {
  //   field: 'goodsList',
  //   label: '商品信息',
  // },
  {
    field: 'payStatus',
    label: '付款状态',
    render: (curVal, _) => {
      return `${renderOrderStatusLabel(curVal) || ''}`;
    },
  },
  {
    field: 'nickName',
    label: '会员昵称',
  },
  {
    field: 'payTime',
    label: '付款时间',
    render: (curVal, _) => {
      return `${formatDayTime(curVal)}`;
    },
  },
  {
    field: 'brandName',
    label: '产品型号',
  },
  {
    field: 'addTime',
    label: '下单时间',
    render: (curVal, _) => {
      return `${formatDayTime(curVal)}`;
    },
  },
  {
    field: 'goodsPrice',
    label: '商品总价',
  },
];

export const refundSchema: DescItem[] = [
  {
    field: 'orderSn',
    label: '订单号',
  },
  {
    field: 'orderStatus',
    label: '订单状态',
  },
  {
    field: 'a3',
    label: '发货状态',
  },
  {
    field: 'payId',
    label: '支付单号',
  },
  {
    field: 'payTime',
    label: '支付时间',
    render: (curVal, _) => {
      return `${formatDayTime(curVal)}`;
    },
  },
  {
    field: 'consignee',
    label: '收货人',
  },
  {
    field: 'address',
    label: '收货地址',
  },
  {
    field: 'mobile',
    label: '联系电话',
  },
  {
    field: 'shippingName',
    label: '快递公司',
  },
  {
    field: 'shippingNo',
    label: '快递单号',
  },
  {
    field: 'shippingFee',
    label: '快递费用',
  },
];
export const personSchema: DescItem[] = [
  {
    field: 'userName',
    label: '用户姓名',
  },
  {
    field: 'mobile',
    label: '联系电话',
  },
  {
    field: 'city',
    label: '取货地址',
    render: (curVal, _) => {
      return `${curVal} ${_.address}`;
    },
  },
];

export const refundTableSchema: BasicColumn[] = [
  {
    title: '商品编号',
    width: 150,
    dataIndex: 't1',
    customRender: ({ record }) => {
      return (
        <Button type="link" size="small">
          {() => record.t1}
        </Button>
      );
    },
  },
  {
    title: '商品名称',
    width: 150,
    dataIndex: 't2',
  },
  {
    title: '商品条码',
    width: 150,
    dataIndex: 't3',
  },
  {
    title: '单价	',
    width: 150,
    dataIndex: 't4',
  },
  {
    title: '数量（件）	',
    width: 150,
    dataIndex: 't5',
  },
  {
    title: '金额',
    width: 150,
    dataIndex: 't6',
  },
];
export const refundTimeTableSchema: BasicColumn[] = [
  {
    title: '时间',
    width: 150,
    dataIndex: 't1',
  },
  {
    title: '当前进度',
    width: 150,
    dataIndex: 't2',
  },
  {
    title: '状态',
    width: 150,
    dataIndex: 't3',
    customRender: ({ record }) => {
      return <Badge status="success" text={record.t3} />;
    },
  },
  {
    title: '操作员ID	',
    width: 150,
    dataIndex: 't4',
  },
  {
    title: '耗时',
    width: 150,
    dataIndex: 't5',
  },
];

export const refundTableData: any[] = [
  {
    t1: 1234561,
    t2: '矿泉水 550ml',
    t3: '12421432143214321',
    t4: '2.00',
    t5: 1,
    t6: 2.0,
  },
  {
    t1: 1234562,
    t2: '矿泉水 550ml',
    t3: '12421432143214321',
    t4: '2.00',
    t5: 2,
    t6: 2.0,
  },
  {
    t1: 1234562,
    t2: '矿泉水 550ml',
    t3: '12421432143214321',
    t4: '2.00',
    t5: 2,
    t6: 2.0,
  },
  {
    t1: 1234562,
    t2: '矿泉水 550ml',
    t3: '12421432143214321',
    t4: '2.00',
    t5: 2,
    t6: 2.0,
  },
];

export const refundTimeTableData: any[] = [
  {
    t1: '2017-10-01 14:10',
    t2: '联系客户',
    t3: '进行中',
    t4: '取货员 ID1234',
    t5: '5mins',
  },
  {
    t1: '2017-10-01 14:10',
    t2: '取货员出发',
    t3: '成功',
    t4: '取货员 ID1234',
    t5: '5mins',
  },
  {
    t1: '2017-10-01 14:10',
    t2: '取货员接单',
    t3: '成功',
    t4: '系统',
    t5: '5mins',
  },
  {
    t1: '2017-10-01 14:10',
    t2: '申请审批通过',
    t3: '成功',
    t4: '用户',
    t5: '1h',
  },
];
