import CONFIG from "@/config";

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

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

        {
          item: { width: 100, key: "isChannel", title: "是否渠道变更" },
          attr: {
            is: "el-dict-tag",
            dictName: "is_effective",
          },
        },
        {
          item: { width: 100, key: "brandReplacement", title: "是否品牌替换" },
          attr: {
            is: "el-dict-tag",
            dictName: "is_effective",
          },
        },
        {
          item: { width: 100, key: "priceDiffer", title: "单价差" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },

        {
          item: { width: 100, key: "increase", title: "涨幅" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },

        {
          item: { width: 100, key: "yPurchaseQuantity", title: "预计年采购量" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "yAffectedAmount", title: "预计年影响量" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },

        {
          item: { width: 100, key: "supplierName", title: "供应商名称" },
          attr: {},
        },
        {
          item: { width: 100, key: "bidPrice", title: "中标价" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "unitPrice", title: "单价" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "profit", title: "利润比" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },

        {
          item: { width: 100, key: "supplierName1", title: "供应商名称1" },
          attr: {},
        },
        {
          item: { width: 100, key: "bidPrice1", title: "中标价1" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "unitPrice1", title: "单价1" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "profit1", title: "利润比1" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },

        {
          item: { width: 100, key: "supplierName2", title: "供应商名称2" },
          attr: {},
        },
        {
          item: { width: 100, key: "bidPrice2", title: "中标价2" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "unitPrice2", title: "单价2" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },
        {
          item: { width: 100, key: "profit2", title: "利润比2" },
          attr: {
            is: "el-computed-input-v2",
            formatter: (prop) => {
              return prop == null ? 0 : (prop * 1).toFixed(CONFIG.precision);
            },
          },
        },

        {
          item: { width: 100, key: "createByName", title: "创建人名称" },
          attr: {},
        },
        {
          item: { width: 100, key: "updateByName", title: "更新人名称" },
          attr: {},
        },
      ],
    },
  ];

  return { TableColumns, TabColumns };
}
