export default {
  data () {
    return {
      columns_product: [
        {
          type: 'index',
          label: '序号',
          width: 80
        },
        {
          prop: 'code',
          label: '物品编码'
        },
        {
          prop: 'name',
          label: '物品名称'
        },
        {
          prop: 'brandNum',
          label: '牌号'
        },
        {
          prop: 'modelType',
          label: '型号'
        },
        {
          prop: 'classificationCode',
          label: '物品类型',
          formatter: this.classificationCodeFormatter
        },
        {
          prop: 'categoryLevelPath',
          label: '分类'
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 150,
          align: 'center',
          slot: 'action',
          fixed: 'right'
        }
      ],
      columns_mould: [
        {
          type: 'index',
          label: '序号',
          width: 50
        },
        {
          prop: 'code',
          label: '物品编码'
        },
        {
          prop: 'name',
          label: '物品名称'
        },
        {
          prop: 'brandNum',
          label: '牌号'
        },
        {
          prop: 'modelType',
          label: '型号'
        },
        {
          prop: 'shrinkageCoefficient',
          label: '收缩系数',
          formatter: this.shrinkFormatter
        },
        {
          prop: 'dieBodyModel',
          label: '大模体型号',
          formatter: this.modleFormatter
        },
        {
          prop: 'classificationCode',
          label: '物品类型',
          formatter: this.classificationCodeFormatter
        },
        {
          prop: 'categoryLevelPath',
          label: '分类'
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 150,
          align: 'center',
          slot: 'action',
          fixed: 'right'
        }
      ],
      columns_part: [
        {
          type: 'index',
          label: '序号',
          width: 50
        },
        {
          prop: 'code',
          label: '物品编码'
        },
        {
          prop: 'name',
          label: '物品名称'
        },
        {
          prop: 'modelType',
          label: '型号'
        },
        {
          prop: 'classificationCode',
          label: '物品类型',
          formatter: this.classificationCodeFormatter
        },
        {
          prop: 'categoryLevelPath',
          label: '分类'
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 150,
          align: 'center',
          slot: 'action',
          fixed: 'right'
        }
      ],
      columns_bom: [
        {
          type: 'index',
          label: '序号',
          width: 50
        },
        {
          prop: 'code',
          label: '物品编码'
        },
        {
          prop: 'name',
          label: '物品名称'
        },
        {
          prop: 'brandNum',
          label: '牌号'
        },
        {
          prop: 'classificationCode',
          label: '物品类型',
          formatter: this.classificationCodeFormatter
        },
        {
          prop: 'categoryLevelPath',
          label: '分类'
        },
        {
          label: '数量',
          columnKey: 'num',
          width: 120,
          slot: 'num'
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 150,
          align: 'center',
          slot: 'action',
          fixed: 'right'
        }
      ],
      columns_facility: [
        {
          type: 'index',
          label: '序号',
          width: 50
        },
        {
          prop: 'code',
          label: '物品编码'
        },
        {
          prop: 'name',
          label: '物品名称'
        },
        {
          prop: 'classificationCode',
          label: '物品类型',
          formatter: this.classificationCodeFormatter
        },
        {
          prop: 'categoryLevelPath',
          label: '分类'
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 150,
          align: 'center',
          slot: 'action',
          fixed: 'right'
        }
      ]
    };
  },
  methods: {
    // 物品类型格式化
    classificationCodeFormatter (row) {
      let itemName = '';
      this.typeList.map((item) => {
        if (item.code == row.type) {
          itemName = item.name;
        }
      });
      return itemName;
    },

    // 收缩系数格式化
    shrinkFormatter (row) {
      let shrink = '';
      let extendField = JSON.parse(row.extendField);
      if (extendField.hasOwnProperty('shrinkageCoefficient')) {
        shrink = extendField.shrinkageCoefficient;
      }
      return shrink;
    },

    modleFormatter (row) {
      let modle = '';
      let extendField = JSON.parse(row.extendField);
      if (extendField.hasOwnProperty('dieBodyModel')) {
        modle = extendField.dieBodyModel;
      }
      return modle;
    }
  }
};
