<template>
  <view style="padding-top: 50rpx">
    <view class="mx3 my2 p3 bg-color-white" style="border-radius: 16rpx">
      <equipment-line title="型号" :content="infoData.model" />
      <equipment-line title="名称型号" :content="infoData.nameModel" />
      <equipment-line title="设备名称" :content="infoData.name" />
      <equipment-line title="设备类型" :content="infoData.typeName" />
      <equipment-line
        title="自定义类型"
        :content="$BaseTool.Object.getField(useTypeMap, infoData.useType)"
      />
      <equipment-line
        title="设备等级"
        :content="$BaseTool.Object.getField(levelMap, infoData.level)"
      />
      <equipment-line title="生产商" :content="infoData.producerName" />
      <equipment-line
        title="计量单位"
        :content="$BaseTool.Object.getField(unitMap, infoData.unit)"
      />
      <equipment-line
        title="设备原值"
        :content="$BaseTool.Amount.formatter(infoData.initialValue)"
      />
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      detailId: "",
      infoData: {},
      useTypeMap: {},
      levelMap: {},
      unitMap: {},
    };
  },
  onLoad(options) {
    this.detailId = options.detailId;
    this.initData();
    this.useTypeMap = this.$DictCache.getLabelByValueMapByType(
      this.$DictCache.TYPE.SB_USE_TYPE
    );
    this.levelMap = this.$DictCache.getLabelByValueMapByType(
      this.$DictCache.TYPE.SBINFO_LEVEL
    );
    this.unitMap = this.$DictCache.getLabelByValueMapByType(
      this.$DictCache.TYPE.SBINFO_UNIT
    );
    this.statusMap = this.$DictCache.getLabelByValueMapByType(
      this.$DictCache.TYPE.SB_INFO_STATUS
    );
  },
  methods: {
    initData() {
      this.$Http
        .fetchSbInfo({
          id: this.detailId,
        })
        .then((res) => {
          this.infoData = res.data;
        });
    },
  },
};
</script>

<style lang="less">
page {
  background-color: #f4f4f4;
}
</style>
