import { ContentConfig } from "/@/components/PageContent";
import {
  httpList,
  httpAdd,
  httpUpdate,
  httpStatus
} from "/@/api/parameter/finance";

import dayjs from "dayjs";
import { h } from "vue";
import { ElImage, ElTag } from "element-plus";

const columns = [
  {
    type: "selection",
    width: 55,
    hide: ({ checkList }) => !checkList.includes("勾选列")
  },
  {
    label: "序号",
    type: "index",
    width: 70,
    hide: ({ checkList }) => !checkList.includes("序号列")
  },
  {
    label: "业务企业编码",
    prop: "companyNo",
    width: 120
  },
  {
    label: "业务企业名称",
    prop: "company_name",
    width: 120
  },
  {
    label: "业务企业地址",
    prop: "company_address",
    width: 120
  },
  {
    label: "企业纳税号",
    prop: "company_license",
    width: 120
  },
  {
    label: "开户银行账户",
    prop: "bank_name",
    width: 120
  },
  {
    label: "开户银行账户",
    prop: "bankNo",
    width: 120
  },
  {
    label: "联系人",
    prop: "contector"
  },
  {
    label: "企业联系方式",
    prop: "mobile",
    width: 120
  },
  {
    label: "营业执照",
    prop: "company_img",
    width: 100,
    cellRenderer: ({ row }) =>
      h(ElImage, {
        src: row.company_img,
        previewSrcList: [row.company_img],
        previewTeleported: true
      })
  },
  {
    label: "进项设置",
    prop: "input_ticket",
    width: 100,
    cellRenderer: ({ row }) =>
      String(row.input_ticket) === "1" ? "金税" : "人工"
  },
  {
    label: "销项设置",
    prop: "out_ticket",
    width: 100,
    cellRenderer: ({ row }) =>
      String(row.out_ticket) === "1" ? "金税" : "人工"
  },
  {
    label: "作废人",
    prop: "voider"
  },
  {
    label: "开票人",
    prop: "payee"
  },
  {
    label: "复核人",
    prop: "drawer"
  },
  {
    label: "归属地",
    prop: "reviewer"
  },
  {
    label: "最大面额",
    prop: "denomination",
    width: 120
  },
  {
    label: "支持发票类型",
    prop: "invoiceType",
    width: 120
  },
  {
    label: "状态",
    prop: "status",
    cellRenderer: ({ row, props }) =>
      h(
        ElTag,
        {
          size: props.size,
          type: String(row.status) === "1" ? "success" : "danger"
        },
        {
          default: () => (row.status + "" === "0" ? "禁用" : "启用")
        }
      )
  },
  {
    label: "创建时间",
    prop: "addTime",
    width: 150,
    formatter: ({ createTime }) =>
      dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
  },
  {
    label: "操作",
    fixed: "right",
    width: 120,
    slot: "operation"
  }
];

const contentConfig: ContentConfig = {
  title: "业务公司发票",
  statusProp: "companyNo",
  columns,
  apis: {
    httpList,
    httpAdd,
    httpUpdate,
    httpStatus
  }
};

export default contentConfig;
