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

export const good_type = [
  {
    value: "0",
    label: "未关联开票类目"
  },
  {
    value: "1",
    label: "已关联"
  }
];

export const stock_type = [
  {
    value: "0",
    label: "库存"
  },
  {
    value: "1",
    label: "非库存"
  }
];

//类目新增校验规则
export const cost_rules = {
  cat_code: [{ required: true, trigger: "change", message: "请选择类目" }],
  inv_good_name: [
    { required: true, trigger: "change", message: "请选择商品名称" }
  ],
  tax: [{ required: true, trigger: "change", message: "请选择税率" }]
};

export const good_detail_columns = [
  {
    field: "spuCode",
    label: "商品编号"
  },
  {
    field: "good_name",
    label: "商品名称"
  },
  {
    field: "companyNo",
    label: "业务公司编号"
  },
  {
    field: "supplierNo",
    label: "供应商编号"
  },
  {
    field: "is_stock",
    label: "是否库存",
    render(stock) {
      return h(ElTag, null, {
        default: () => stock_type.find(s => s.value === stock)?.label
      });
    }
  },
  {
    field: "craft_desc",
    label: "工艺描述"
  },
  {
    field: "good_img",
    label: "商品图",
    render(imgSrc) {
      return imgSrc.split(",").map(src =>
        h(ElImage, {
          src,
          previewTeleported: true,
          previewSrcList: [src],
          style: {
            height: "20px"
          }
        })
      );
    }
  },
  {
    field: "creater",
    label: "创建人"
  },
  {
    field: "cat_name",
    label: "分类名称"
  },
  {
    field: "unit_name",
    label: "单位名称"
  },
  {
    field: "status",
    label: "是否关联开票类目",
    render(status) {
      return h(ElTag, null, {
        default: () => good_type.find(s => s.value === status)?.label
      });
    }
  },
  {
    field: "inv_cat_name",
    label: "类目名称"
  },
  {
    field: "inv_cat_code",
    label: "类目编号"
  },
  {
    field: "inv_tax",
    label: "类目税率额"
  },
  {
    field: "inv_good_name",
    label: "开票商品名称"
  },
  {
    field: "inv_good_name",
    label: "开票商品名称"
  },
  {
    field: "addtime",
    label: "申请时间"
  },
  {
    field: "after_sales",
    label: "售后"
  }
];
