import CONFIG from "@/config";

export default function useColumns() {
  const TableColumns = [
    {
      item: { key: "priceCode", title: "价格编码" },
      attr: {},
    },
    {
      item: { key: "supplierName", title: "供应商" },
      attr: {},
    },
    {
      item: { key: "puOrgName", title: "采购组织" },
      attr: {},
    },
    {
      item: { key: "currencyName", title: "币种" },
      attr: {},
    },
    {
      item: { key: "explainStr", title: "价格合理性说明" },
      attr: {},
    },
    {
      item: { key: "buyerName", title: "采购员" },
      attr: {},
    },
    {
      item: { key: "puDeptName", title: "采购部门" },
      attr: {},
    },
    {
      item: { key: "createByName", title: "创建人" },
      attr: {},
    },
    {
      item: { key: "source", title: "来源单据号" },
      attr: {},
    },
    {
      item: { key: "isEffective", title: "是否已推价格" },
      attr: {
        is: "el-dict-tag",
        dictName: "is_effective",
      },
    },
    {
      item: { key: "effectiveDate", title: "生效日期" },
      attr: {},
    },
    {
      item: { key: "file", title: "附件" },
      attr: { is: "el-file-preview" },
    },
    {
      item: { key: "sourceType", title: "来源单据类型" },
      attr: {},
    },
    {
      item: { key: "status", title: "单据状态" },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_status",
      },
    },
  ];

  const TabColumns = [
    {
      item: {
        title: "物料信息表",
        key: "priceApplyItems",
      },
      attr: {
        value: [],
      },
      TableColumns: [
        {
          item: { key: "materialName", title: "物料名称" },
          attr: {},
        },
        { item: { key: "materialCode", title: "物料编码" }, attr: {} },
        { item: { key: "manufacturerName", title: "生产厂家" }, attr: {} },
        { item: { key: "specification", title: "规格" }, attr: {} },
        { item: { key: "model", title: "型号" }, attr: {} },
        {
          item: { key: "unitName", title: "单位" },
          attr: {},
        },
        {
          item: { key: "puUnitName", title: "采购单位" },
          attr: {},
        },
        {
          item: { key: "conversionRate", title: "采购换算率" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { key: "tax", title: "税率%" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { key: "taxPrice", title: "含税单价" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { key: "price", title: "无税单价" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { key: "currencyName", title: "币种" },
          attr: {},
        },
        {
          item: { key: "periodBegin", title: "价格有效期（起）" },
          attr: {},
        },
        {
          item: { key: "periodEnd", title: "价格有效期（止）" },
          attr: {},
        },
        {
          item: { key: "customerName", title: "客户" },
          attr: {},
        },
        { item: { key: "recentlyPrice", title: "最近价格" }, attr: {} },
        {
          item: { key: "isApprovalFirst", title: "首次报批" },
          attr: {
            is: "el-dict-tag",
            dictName: "is_effective",
          },
        },
        {
          item: { key: "isPriceAdjustment", title: "价格调整" },
          attr: {
            is: "el-dict-tag",
            dictName: "is_effective",
          },
        },
        {
          item: { key: "priceType", title: "价格类型" },
          attr: {
            is: "el-dict-tag",
            dictName: "sys_price_type",
          },
        },
        {
          item: { key: "isDistributionPrice", title: "配送价" },
          attr: {
            is: "el-dict-tag",
            dictName: "is_effective",
          },
        },
        { item: { key: "createByName", title: "创建人名称" }, attr: {} },
        { item: { key: "updateByName", title: "更新人名称" }, attr: {} },
      ],
    },
  ];

  return { TableColumns, TabColumns };
}
