export const getDictName = (dict, id) => {
  if (!dict || !Array.isArray(dict)) {
    console.error('请传入正确的字典')
    return ''
  }
  const obj = dict.find(item => (item && item.id) === id)
  return obj && obj.name
}
export const getDict = dict => {
  if (!dict || !Array.isArray(dict)) {
    console.error('请传入正确的字典')
    return ''
  }
  return id => {
    const obj = dict.find(item => (item && item.id) === id)
    return obj || {}
  }
}

// *入库明细
export const warehousingMaterialListTable = {
  物料: {
    assetId: 'id',
    assetCode: 'materialCode', //编码
    assetName: 'materialName', //名称
    batchNo: 'batchNo', //批次号
    brandNum: 'tradeMark', //牌号
    modelType: 'model', //型号
    materialType: '', //类型
    amount: 'price', //单价
    realInventoryNum: 'inventoryLibrary', //实时库存
    realInventoryAmount: '', //实时库存金额
    outInAmount: '', //入库总额
    unit: 'unit', //单位
    minimumPackingUnit: '', //最小包装单位
    minimumUnit: '', //最小单元
    warehouseName: '' //仓库
  },
  周转车: {
    assetId: 'id',
    assetCode: 'code', //编码
    assetName: 'name', //名称
    batchNo: '', //批次号
    brandNum: 'model', //牌号
    materialType: '', //类型
    amount: 'price', //单价
    realInventoryNum: 'inventoryLibrary', //实时库存
    realInventoryAmount: '', //实时库存金额
    outInAmount: '', //入库总额
    unit: 'unit', //单位
    warehouseName: '' //仓库
  },
  舟皿: {
    assetId: 'id',
    assetCode: 'code', //编码
    assetName: 'name', //名称
    batchNo: '', //批次号
    brandNum: 'model', //牌号
    materialType: '', //类型
    amount: 'price', //单价
    realInventoryNum: 'inventoryLibrary', //实时库存
    realInventoryAmount: '', //实时库存金额
    outInAmount: '', //入库总额
    unit: 'unit', //单位
    warehouseName: '' //仓库
  },
  生产设备: {
    assetId: 'id',
    assetCode: 'code', //编码
    assetName: 'name', //名称
    batchNo: '', //批次号
    brandNum: 'specifications', //牌号
    materialType: '', //类型
    amount: 'price', //单价
    realInventoryNum: 'inventoryLibrary', //实时库存
    realInventoryAmount: '', //实时库存金额
    outInAmount: '', //入库总额
    unit: 'pkgUnit', //单位
    warehouseName: '' //仓库
  },
  模具: {
    assetId: 'id',
    assetCode: 'code', //编码
    assetName: 'name', //名称
    batchNo: '', //批次号
    brandNum: 'model', //牌号
    materialType: '', //类型
    amount: 'price', //单价
    realInventoryNum: 'inventoryLibrary', //实时库存
    realInventoryAmount: '', //实时库存金额
    outInAmount: '', //入库总额
    unit: 'unit', //单位
    warehouseName: '' //仓库
  },
  备品备件: {
    assetId: 'id',
    assetCode: 'code', //编码
    assetName: 'name', //名称
    batchNo: '', //批次号
    brandNum: 'model', //牌号
    materialType: '', //类型
    amount: 'price', //单价
    realInventoryNum: 'inventoryLibrary', //实时库存
    realInventoryAmount: '', //实时库存金额
    outInAmount: '', //入库总额
    unit: 'unit', //单位
    warehouseName: '' //仓库
  }
}

export const warehousingType = [
  {
    id: 3,
    name: '物料',
    key: 'WULIAO',
    url: '/classificationMaterialAccount/getlist'
  },
  // { id: 4, name: "产品", type: "c", key:'CHANPIN', warehousingType:2 },
  {
    id: 5,
    name: '周转车',
    key: 'ZHOUZHUANCHE',
    url: '/classificationTurnover/getlist'
  },
  {
    id: 2,
    name: '舟皿',
    key: 'ZHOUMIN',
    url: '/classificationBoat/getlist'
  },
  {
    id: 1,
    name: '生产设备',
    key: 'SHENGCHANSHEBEI',
    url: '/Equipment/Accoint/getlist'
  },
  {
    id: 6,
    name: '模具',
    key: 'MOJU',
    url: '/classificationMould/getlist'
  },
  {
    id: 7,
    name: '备品备件',
    key: 'BEIPINBEIJIAN',
    url: '/classificationSpareParts/classificationSpare/list'
  }
]

export const tableContentData = [
  {
    name: '物料',
    keys: {
      name: 'materialName',
      code: 'materialCode',
      tradeMark: 'tradeMark',
      model: 'model'
    },
    tableData: [
      { label: '物料编码', key: 'materialCode' },
      { label: '物料名称', key: 'materialName' },
      { label: '牌号', key: 'tradeMark' },
      { label: '型号', key: 'model' },
      { label: '单位', key: 'standardUnit' }
    ]
  },
  // {
  //     name: "产品",
  //     tableData: [
  //         { label: "产品编码", key: "materialCode" },
  //         { label: "产品名称", key: "materialName" },
  //         { label: "牌号", key: "tradeMark" },
  //         { label: "型号", key: "model" },
  //         { label: "单位", key: "standardUnit" }
  //     ]
  // },
  {
    name: '周转车',
    keys: {
      name: 'name',
      code: 'code',
      tradeMark: 'tradeMark',
      model: 'model'
    },
    tableData: [
      { label: '周转车编码', key: 'code' },
      { label: '周转车名称', key: 'name' },
      { label: '规格型号', key: 'model' },
      { label: '权属部门', key: 'ownDept' },
      { label: '单位', key: 'unit' }
    ]
  },
  {
    name: '舟皿',
    keys: {
      name: 'name',
      code: 'code',
      tradeMark: 'tradeMark',
      model: 'model'
    },
    tableData: [
      { label: '舟皿编码', key: 'code' },
      { label: '舟皿名称', key: 'name' },
      { label: '规格型号', key: 'model' },
      { label: '权属部门', key: 'ownDept' },
      { label: '单位', key: 'unit' }
    ]
  },
  {
    name: '生产设备',
    keys: {
      name: 'name',
      code: 'code',
      tradeMark: 'tradeMark',
      model: 'specifications'
    },
    tableData: [
      { label: '设备编码', key: 'code' },
      { label: '设备名称', key: 'name' },
      { label: '规格型号', key: 'specifications' },
      { label: '权属部门', key: 'ownDept' },
      { label: '单位', key: 'pkgUnit' }
    ]
  },
  {
    name: '模具',
    keys: {
      name: 'name',
      code: 'code',
      tradeMark: 'tradeMark',
      model: 'model'
    },
    tableData: [
      { label: '模具编码', key: 'code' },
      { label: '模具名称', key: 'name' },
      { label: '规格型号', key: 'model' },
      { label: '权属部门', key: 'ownDept' },
      { label: '单位', key: 'unit' }
    ]
  },
  {
    name: '备品备件',
    keys: {
      name: 'name',
      code: 'code',
      tradeMark: 'tradeMark',
      model: 'model'
    },
    tableData: [
      { label: '备品备件编码', key: 'code' },
      { label: '备品备件名称', key: 'name' },
      { label: '规格型号', key: 'model' },
      { label: '单位', key: 'unit' }
    ]
  }
]

export const sceneState = [
  { id: 1, name: '生产入库' },
  { id: 2, name: '采购入库' },
  { id: 3, name: '赠送入库' },
  { id: 4, name: '借用入库' },
  // { id: 5, name: '退还入库' },
  { id: 6, name: '其他入库' }
]
// 紧急状态
export const emergencyState = [
  { id: 1, name: '普通', color: 'red' },
  { id: 2, name: '重要', color: 'blue' },
  { id: 3, name: '加急', color: 'red' }
]

export const materialType = [
  { id: 1, name: '混炼料' },
  { id: 2, name: '混合料' }
]

export const inputStatus = [
  { id: 1, name: '入库' },
  { id: 2, name: '出库' }
]

// 审核状态
export const auditStatus = [
  { id: 0, name: '已驳回', class: 'text-danger' },
  { id: 1, name: '待审核', class: 'text-primary' },
  { id: 2, name: '已完成', class: 'text-primary' }
]

// 盘点资产状态
export const wh_equStatus = [
  { id: 0, name: '待盘点', color: '' },
  { id: 1, name: '盘亏', color: '#D9001B' },
  { id: 2, name: '盘损', color: '#F59A23' },
  { id: 3, name: '盘盈', color: '#70B603' },
  { id: 4, name: '正常', color: '' }
]

export const outputSceneState = [
  { id: 1, name: '退供出库' },
  { id: 2, name: '调拨出库' },
  { id: 3, name: '销售出库' },
  { id: 4, name: '领用出库' },
  { id: 5, name: '报废出库' }
]
