import { ref } from "vue";
import { cg_order_source_options } from "/@/utils/status";

const good_type = [
  {
    value: "1",
    label: "库存"
  },
  {
    value: "2",
    label: "非库存"
  },
  {
    value: "3",
    label: "咨询"
  }
];

export function useColumns() {
  const columns = ref([
    {
      type: "selection",
      width: 55,
      hide: ({ checkList }) => !checkList.includes("勾选列")
    },
    {
      label: "序号",
      type: "index",
      width: 70,
      hide: ({ checkList }) => !checkList.includes("序号列")
    },

    {
      label: "采购单编号",
      prop: "sequenceNo",
      width: "175px"
    },
    {
      label: "状态",
      prop: "cgdType",
      width: 95,
      cellRenderer: ({ row, props }) => (
        <el-tag size={props.size} type="" effect="plain">
          {row.status === "0" ? "未对账" : "对账"}
        </el-tag>
      )
    },
    {
      label: "发货状态",
      prop: "cgdSource",
      width: 95,
      cellRenderer: ({ row, props }) => (
        <el-tag size={props.size} type="" effect="plain">
          {(send_status.find(item => item.value == row.sendStatus + "") || {})
            .label || "--"}
        </el-tag>
      )
    },
    {
      label: "订单来源",
      prop: "cgdSource",
      width: 95,
      cellRenderer: ({ row, props }) => (
        <el-tag size={props.size} type="" effect="plain">
          {(
            cg_order_source_options.find(
              item => item.value == row.cgdSource + ""
            ) || {}
          ).label || "--"}
        </el-tag>
      )
    },
    {
      label: "商品来源",
      prop: "cgdType",
      width: 95,
      cellRenderer: ({ row, props }) => (
        <el-tag size={props.size} type="" effect="plain">
          {(good_type.find(item => item.value == row.cgdType + "") || {})
            .label || "--"}
        </el-tag>
      )
    },
    {
      label: "商品编号",
      prop: "goodNo",
      width: "175px"
    },
    {
      label: "商品名称",
      prop: "goodName",
      width: "180px"
    },
    {
      label: "业务公司编号",
      prop: "companyNo",
      width: "175px"
    },
    {
      label: "业务公司名称",
      prop: "companyName",
      width: "120px"
    },
    {
      label: "供应商编号",
      prop: "supplierNo",
      width: "175px"
    },
    {
      label: "供应商名称",
      prop: "supplierName",
      width: "175px"
    },
    {
      label: "备库单",
      prop: "bkCode",
      width: "175px"
    },
    {
      label: "采购员",
      prop: "ownerName",
      width: 75
    },

    {
      label: "创建时间",
      prop: "addtime",
      width: 155
    },
    {
      label: "操作",
      fixed: "right",
      width: 55,
      slot: "operation"
    }
  ]);

  return {
    columns
  };
}

export const cgd_status = [
  {
    value: "0",
    label: "未对账"
  },
  {
    value: "1",
    label: "对账"
  }
];

export const cgd_type = [
  {
    value: "1",
    label: "库存"
  },
  {
    value: "2",
    label: "非库存"
  },
  {
    value: "3",
    label: "咨询"
  }
];

export const product_type = [
  {
    value: "1",
    label: "正常商品"
  },
  {
    value: "2",
    label: "赠品"
  },
  {
    value: "3",
    label: "样品"
  }
];

export const send_type = [
  {
    value: "1",
    label: "包邮"
  },
  {
    value: "2",
    label: "自提"
  }
];

export const pay_status = [
  {
    value: "1",
    label: "未付款"
  },
  {
    value: "2",
    label: "部分付款"
  },
  {
    value: "3",
    label: "已付款"
  }
];

export const inv_status = [
  {
    value: "1",
    label: "未回票"
  },
  {
    value: "2",
    label: "部分回票"
  },
  {
    value: "3",
    label: "已回票"
  }
];

export const send_status = [
  {
    value: "1",
    label: "未发货"
  },
  {
    value: "2",
    label: "部分发货"
  },
  {
    value: "3",
    label: "已发货"
  }
];
