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: "120px"
    },
    {
      label: "商品单号",
      prop: "goodNo",
      width: "120px"
    },
    {
      label: "商品名称",
      prop: "goodName",
      width: "120px"
    },
    {
      label: "业务公司编号",
      prop: "companyNo",
      width: "120px"
    },
    {
      label: "业务公司名称",
      prop: "companyName",
      width: "120px"
    },
    {
      label: "供应商编号",
      prop: "supplierNo",
      width: "120px"
    },
    {
      label: "供应商名称",
      prop: "supplierName",
      width: "120px"
    },
    {
      label: "备库编号",
      prop: "bkCode",
      width: "120px"
    },
    {
      label: "确认单编号",
      width: "120px",
      prop: "goodNo"
    },
    {
      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">
          {(
            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: "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 cgd_source = [
  {
    value: "1",
    label: "直接下单"
  },
  {
    value: "2",
    label: "咨询"
  },
  {
    value: "3",
    label: "项目"
  },
  {
    value: "4",
    label: "平台"
  },
  {
    value: "5",
    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: "已回票"
  }
];
