export default function useColumns() {

  const SearchColumns = [
    {
      item: {
        key: "docSubject",
        title: "单据标题"
      },
      attr: {
        is: "el-input",
        clearable: true,
      }
    },
    {
      item: {
        key: "modelIds",
        title: "单据类型"
      },
      attr: {
        is: "el-select",
        dictName: "oa_templete_id",
        clearable: true,
        multiple: true,
        collapseTags: true,
      }
    },
  ];

  const TableColumns = [
    {
      item: { key: "docSubject", title: "标题", width: "auto" },
      attr: {

      },
    },
    {
      item: { key: "docCreate", title: "创建人", width: 180 },
      attr: {},
    },
  ];

  // 采购需求单
  const PU_DEMAND_RULE = [
    {
      item: { title: "物料编码", key: "materialCode" },
      attr: {}
    },
    {
      item: { title: "物料名称", key: "materialName" },
      attr: {}
    },
    {
      item: { title: "规格", key: "specification" },
      attr: {}
    },
    {
      item: { title: "单位", key: "unitName", width: 50 },
      attr: {}
    },
    {
      item: { title: "生产厂家/代理人", key: "manufacturerName" },
      attr: {}
    },
    {
      item: { title: "实际(业务)需求量", key: "qty", width: 130 },
      attr: {}
    },
    {
      item: { title: "月均销量", key: "averageQtyMonth", width: 80 },
      attr: {}
    },
    {
      item: { title: "需求可用周期", key: "demandPeriod", width: 80 },
      attr: {}
    },
    {
      item: { title: "业务备注", key: "remark" },
      attr: {}
    },
    {
      item: { title: "紧急标识", key: "isUrgency", width: 80, },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: {
        title: "补单标识", key: "isReplenishment", width: 80,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      }
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 150
    },
  }));;


  const ALLOT_RULE = [
    {
      item: { title: "物料编码", key: "materialCode", width: 120 },
      attr: {}
    },
    {
      item: { title: "物料名称", key: "materialName" },
      attr: {}
    },
    {
      item: { title: "规格", key: "specification" },
      attr: {}
    },
    {
      item: { title: "单位", key: "unitName" },
      attr: {}
    },
    {
      item: { title: "生产厂家/代理人", key: "manufacturerName" },
      attr: {}
    },
    {
      item: { title: "调出仓库", key: "deliveryWarehouseName" },
      attr: {}
    },
    {
      item: { title: "调出货位", key: "deliveryAllocationName" },
      attr: {}
    },
    {
      item: { title: "数量", key: "qty", width: 50 },
      attr: {}
    },
    {
      item: { title: "调入仓库", key: "storageWarehouseName" },
      attr: {}
    },
    {
      item: { title: "调入货位", key: "storageAllocationName" },
      attr: {}
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 150
    },
  }));;


  // 物料申请单
  const MATERIAL_APPLY_RULE = [
    {
      item: { key: 'name', title: '物料名称', },
      attr: {}
    },
    {
      item: { key: 'code', title: '物料编码', },
      attr: {}
    },
    {
      item: { key: 'specification', title: '规格' },
      attr: {}
    },
    {
      item: { key: 'model', title: '型号', },
      attr: {}
    },
    {
      item: { key: 'unitName', title: '计量单位', },
      attr: {}
    },
    {
      item: { key: 'manufacturerName', title: '生产厂家/代理人', },
      attr: {}
    },
    {
      item: { key: 'registrant', title: '注册人/备案人/上市许可持有人', },
      attr: {}
    },
    {
      item: { key: 'productionPermit', title: '生产许可证', },
      attr: {}
    },
    {
      item: {
        key: 'storageCondition',
        title: '存储条件',
        width: 100
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_storage_condition",
      },
    },
    {
      item: {
        key: 'transportationCondition',
        title: '运输条件',
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_conditions_carriage",
      },
    },
    {
      item: { key: 'originPlaceName', title: '产地', },
      attr: {}
    },
    {
      item: { key: 'serviceLife', title: '使用期限/次数', },
      attr: {}
    },
    {
      item: { key: 'brand', title: '品牌', },
      attr: {}
    },
    {
      item: { key: 'classifyName', title: '四级分类', },
      attr: {}
    },
    {
      item: { key: 'packExplain', title: '包装说明', },
      attr: {}
    },
    {
      item: { key: 'deliveryPeriod', title: '交货周期', },
      attr: {}
    },
    {
      item: { key: 'minOrderQty', title: '最小起订量', },
      attr: {}
    },
    {
      item: { key: 'minPackQty', title: '最小包装量', },
      attr: {}
    },
    {
      item: { key: 'minBatchQty', title: '最小批量', },
      attr: {}
    },
    {
      item: { key: 'diCode', title: 'DI码', },
      attr: {}
    },
    {
      item: { key: 'healthCode', title: '医保代码', },
      attr: {}
    },
    {
      item: { key: 'manufacturersMaterialCode', title: '厂家物料编码', },
      attr: {}
    },
    {
      item: { key: 'purchasingOrganizationName', title: '默认采购组织', },
      attr: {}
    },
    {
      item: { key: 'puPersonnelName', title: '负责采购员', },
      attr: {}
    },
    {
      item: { key: 'version', title: '版本号', },
      attr: {}
    },
    {
      item: {
        key: 'isMedicine',
        title: '医药物料',
        width: 100,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: {
        key: 'serialNoManager',
        title: '序列号管理',
        width: 100,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: {
        key: 'isInventoryStatus',
        title: '批号及库存状态管理',
        width: 100,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: {
        key: 'expiryDateManagerment',
        title: '效期管理',
        width: 100,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: {
        key: 'expiryUnitId',
        title: '效期单位',
      },
      attr: {
        is: "el-dict-tag",
        dictName: "period_unit",
      },
    },
    {
      item: { key: 'usefulLife', title: '有效期', },
      attr: {}
    },
    {
      item: {
        key: 'usefulLifeUnitId',
        title: '有效期至单位',
      },
      attr: {
        is: "el-dict-tag",
        dictName: "expiry_date",
      },
    },
    {
      item: {
        key: 'nearOnsetManagerment',
        title: '近效期管理',
        width: 100,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: { key: 'recentWarningPeriod', title: '近效期预警天数', },
      attr: {}
    },
    {
      item: { key: 'materialRateName', title: '物料税类', },
      attr: {}
    },
    {
      item: { key: 'failCause', title: '同步失败原因', },
      attr: {}
    },
    {
      item: {
        key: 'isDrug',
        title: '是否药品',
        width: 100,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: { key: 'ratifyBatchNo', title: '批准文号', },
      attr: {}
    },
    {
      item: { key: 'registrationNo', title: '注册证号/备案凭证编号', },
      attr: {}
    },
    {
      item: { key: 'dosageFrom', title: '剂型', },
      attr: {}
    },
    {
      item: {
        key: 'medicalInstruments',
        title: '管理类别',
      },
      attr: {
        is: "el-dict-tag",
        dictName: "medical_instruments",
      },
    },
    {
      item: { key: 'oriRegistrationNo', title: '旧注册证号', },
      attr: {}
    },
    {
      item: {
        key: 'curingType',
        title: '养护类型',
      },
      attr: {
        is: "el-dict-tag",
        dictName: "curing_type",
      },
    },
    {
      item: { key: 'drugCode', title: '药品类别编码', },
      attr: {}
    },
    {
      item: { key: 'drugName', title: '药品类别名称', },
      attr: {}
    },
    // { key: 'orgName', title: '所属组织', },
    // { key: 'barCode', title: '条形码', },
    // { key: 'height', title: '高度', },
    // { key: 'width', title: '宽度', },
    // { key: 'length', title: '长度', },
    // { key: 'oneClass', title: '一级分类', },
    // { key: 'twoClass', title: '二级分类', },
    // { key: 'threeClass', title: '三级分类', },
    // {
    //   key: 'isEnable',
    //   title: '启用状态',
    //   attr: {
    //     is: "el-dict-tag",
    //     dictName: "material_enable",
    //   },
    // },
    // { key: 'remark', title: '备注', },
    // { key: 'proposerName', title: '物料申请人', },
    // { key: 'serviceClass', title: '服务类', },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 150
    },
  }));;

  // 价格申报单
  const PU_PRICE_APPLY_RULE = [
    {
      item: { title: "物料编码", key: "materialCode", width: 120 },
      attr: {}
    },
    {
      item: { title: "物料名称", key: "materialName" },
      attr: {}
    },
    {
      item: { title: "规格", key: "specification" },
      attr: {}
    },
    {
      item: { title: "型号", key: "model" },
      attr: {}
    },
    {
      item: { title: "生产厂家/代理人", key: "manufacturerName" },
      attr: {}
    },
    {
      item: { title: "客户", key: "customerName" },
      attr: {}
    },
    {
      item: { title: "主单位", key: "unitName" },
      attr: {}
    },
    {
      item: { title: "含税单价", key: "taxPrice", width: 80 },
      attr: {}
    },
    {
      item: { title: "税率", key: "tax" },
      attr: {}
    },
    {
      item: { title: "价格有效期（起）", key: "periodBegin" },
      attr: {}
    },
    {
      item: { title: "价格有效期（止）", key: "periodEnd" },
      attr: {}
    },
    {
      item: {
        title: "首次报批",
        key: "isApprovalFirst",
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: { title: "调整类型", key: "isPriceAdjustment" },
      attr: {}
    },
    {
      item: { title: "最近价格", key: "recentlyPrice", width: 80 },
      attr: {}
    },
    {
      item: { title: "单价差", key: "priceDiffer", width: 80 },
      attr: {}
    },
    {
      item: { title: "涨幅", key: " increase" },
      attr: {}
    },
    {
      item: { title: "预计年采购量", key: "yPurchaseQuantity" },
      attr: {}
    },
    {
      item: { title: "预计年影响金额", key: "yAffectedAmount" },
      attr: {}
    },
    {
      item: {
        title: "价格类型",
        key: "priceType",
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_price_type",
      },
    },
    {
      item: { title: "申请理由", key: "explainStr" },
      attr: {}
    },
    // { title: "供应商名称1", key: "supplierName1" },
    // { title: "单价1", key: "unitPrice1", width: 70 },
    // { title: "供应商名称2", key: "supplierName2" },
    // { title: "单价2", key: "unitPrice2", width: 70 },
    // { title: "供应商名称3", key: "supplierName3" },
    // { title: "单价3", key: "unitPrice3", width: 70 },
    // {
    //   title: "配送价",
    //   key: "isDistributionPrice",
    //   attr: {
    //     is: "el-dict-tag",
    //     dictName: "sys_number_yes_no",
    //   },
    //   // formatter: function (row, column, cellValue, index) {
    //   //   return row.isDistributionPrice == "Y" ? "是" : "否";
    //   // },
    // },
    // { title: "币种名称", key: "currencyName" },
    // { title: "无税单价", key: "price" },
    // { title: "采购换算率", key: "conversionRate" },
    // { title: "采购单位名称", key: "puUnitName" },
    // { title: "单位名称", key: "unitName" },
    // { title: "预计年影响量", key: "yAffectedAmount" },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 150
    },
  }));;


  // 采购订单
  const PU_ORDER_RULE = [
    {
      item: { title: "物料编码", key: "materialCode", width: 120 },
      attr: {}
    },
    {
      item: { title: "物料名称", key: "materialName" },
      attr: {}
    },
    {
      item: { title: "规格", key: "specification" },
      attr: {}
    },
    {
      item: { title: "生产厂家", key: "manufacturerName" },
      attr: {}
    },
    //  title: '医药物料',  key: 'isMedcine'},
    {
      item: { title: "单位", key: "unitName" },
      attr: {}
    },
    {
      item: { title: "数量", key: "qty", width: 60 },
      attr: {}
    },
    {
      item: { title: "含税单价", key: "taxPrice", width: 80 },
      attr: {}
    },
    {
      item: {
        title: "价税合计",
        key: "money",
        width: 80,
      },
      attr: {
        formatter: function (row, column, cellValue, index) {
          return row.money ? parseFloat(row.money).toFixed(2) : "0.00";
        },
      }
    },
    {
      item: { title: "收货客户", key: "customerName" },
      attr: {}
    },
    {
      item: { title: "税率", key: "tax" },
      attr: {}
    },
    {
      item: {
        title: "赠品",
        key: "isGift",
        width: 50,
      },
      attr: {
        is: "el-dict-tag",
        dictName: "sys_number_yes_no",
      },
    },
    {
      item: { title: "价格类型", key: "priceType", width: 80 },
      attr: {}
    },
    {
      item: { title: "折扣%", key: "nitemdiscountrate", width: 70 },
      attr: {}
    },
    {
      item: { title: "注册证号", key: "registration" },
      attr: {}
    },
    {
      item: { title: "需求单号", key: "demandCode" },
      attr: {}
    },
  ].map(({ item, attr }) => ({
    attr,
    item: {
      ...item,
      width: item.width || 150
    },
  }));;

  return {
    SearchColumns,
    TableColumns,
    PU_DEMAND_RULE,
    ALLOT_RULE,
    MATERIAL_APPLY_RULE,
    PU_PRICE_APPLY_RULE,
    PU_ORDER_RULE,
  }
};