<template>
  <el-descriptions :column="2" border v-loading="loading">
    <el-descriptions-item label="仓库代码">{{ data.stockCode }}</el-descriptions-item>
    <el-descriptions-item label="仓库名称">{{ data.stockName }}</el-descriptions-item>
    <el-descriptions-item label="有效期起">{{ data.validityStart }}</el-descriptions-item>
    <el-descriptions-item label="有效期止">{{ data.validityEnd }}</el-descriptions-item>
    <el-descriptions-item label="备注">{{ data.remark }}</el-descriptions-item>
  </el-descriptions>
</template>

<script>

import { getWarehouse } from "@/api/jxc/warehouse";
export default {
  name: 'StockDesc',
  props: {
    stockId: {
      type: String | Number,
      default: ''
    }
  },
  watch: {
    stockId: {
      handler(val) {
        this.getDetail(val);
      },
      immediate: true
    }
  },
  data() {
    return {
      data: {},
      loading: false,
    }
  },
  methods: {
    getDetail(id) {
      if (!id) {
        return;
      }
      this.loading = true;
      getWarehouse(id).then(res => {
        this.data = res.data || {};
        this.loading = false;
      }).catch(e => {
        this.loading = false;
      });
    }
  }
}
</script>

<style>

</style>