import { ref } from "vue";
import dayjs from "dayjs";
import { GOOD_OPTIONS } from "/@/config/status";
import { renderImage, renderStatus } from "/@/utils/column-helper";
// import { send_status_list } from "/@/utils/status";
export function useColumns() {
  const columns = ref([
    {
      type: "selection",
      width: 30
    },
    {
      label: "商品编号",
      prop: "good_code",
      width: 160,
      showOverflowTooltip: true
    },
    {
      label: "商品类型",
      prop: "type",
      width: 85,
      showOverflowTooltip: true,
      ...renderStatus(GOOD_OPTIONS, "type")
    },
    {
      label: "图片",
      prop: "good_cover_img",
      width: 60,
      showOverflowTooltip: true,
      ...renderImage("good_cover_img")
    },
    {
      label: "商品名称",
      prop: "good_name",
      minWidth: 160
    },
    {
      label: "单位",
      prop: "unit",
      width: 80,
      showOverflowTooltip: true
    },
    {
      label: "起订量",
      prop: "moq",
      width: 80,
      showOverflowTooltip: true
    },
    {
      label: "步长",
      prop: "step",
      width: 80,
      showOverflowTooltip: true
    },
    {
      label: "售价",
      prop: "price",
      width: 110,
      showOverflowTooltip: true
    }
  ]);

  return {
    columns
  };
}

export const order_detail_columns = [
  {
    field: "sequenceNo",
    label: "确认单编号"
  },
  {
    field: "ownerName",
    label: "销售员"
  },
  {
    field: "department",
    label: "平台名称"
  },
  {
    field: "companyName",
    label: "业务公司名称"
  },
  {
    field: "customerName",
    label: "客户名称"
  },
  {
    field: "goodNum",
    label: "商品数量"
  },
  {
    field: "goodPrice",
    label: "商品单价"
  },
  {
    field: "goodName",
    label: "商品名称"
  },

  {
    field: "inv_fee",
    label: "开票中"
  },
  {
    field: "ainv_fee",
    label: "已开票"
  },
  {
    field: "winv_num",
    label: "未开票数量"
  },
  {
    field: "winv_fee",
    label: "未开票"
  }
];

/**
 * @invoice_addr 公司注册地址
 * @invoice_people  法人
 * @invoice_mobile 联系方式
 * @invoice_code 纳税识别号
 * @invoice_bank 开户行
 * @invoice_bankNo 开户账户
 */
export const convertInvoiceTitle = (title: Record<string, string>) => {
  const { company_address, mobile, company_license, bank_name, bankNo } = title;

  return {
    invoice_addr: company_address,
    invoice_mobile: mobile,
    invoice_code: company_license,
    invoice_bank: bank_name,
    invoice_bankNo: bankNo
  };
};

export const convertInvoiceTitleData = (title: Record<string, string>) => {
  const {
    invoice_addr,
    invoice_mobile,
    invoice_code,
    invoice_bank,
    invoice_bankNo
  } = title;

  return {
    invoice_code,
    addrAndmobile: invoice_addr + " " + invoice_mobile,
    bankAndBankNo: invoice_bank + " " + invoice_bankNo
  };
};

export const invoice_columns = [
  {
    label: "纳税人识别号",
    field: "invoice_code"
  },
  {
    label: "地址、电话",
    field: "addrAndmobile"
  },
  {
    label: "开户行及账号",
    field: "bankAndBankNo"
  }
];
