<template>
  <div class="bgcolor">
    <div class="navBarTOP" >
      <van-nav-bar class="navBar" title="产品列表"   left-arrow @click-left="onClickLeft">
        <template #right>
        </template>
      </van-nav-bar>
    </div>
    <div class="lineGrey"></div>
    <div class="lineGrey"></div>
    <div class="lineGrey"></div>
    <div class="lineGrey"></div>
    <div class="lineGrey"></div>
    <div class="container" style="width: 100%; margin: 0 auto;">
      <div v-for="item  in  list">
        <p style="font-weight: bold;font-size: 14px">&nbsp;&nbsp;&nbsp;{{item.m01Name}}</p>
        <el-table :data="item.productDetailList" border  style="width: 100%"   >
          <el-table-column label="物料名称" prop="productName" />
          <el-table-column label="规格" prop="productSku" />
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import {getItemList} from "@/api";
export default {
  data() {
    return {
      list: []
    }
  },
  created() {
    this.getMyInventoryList()
  },
  watch: {
    $route(to, from) {
      if (to.path == "/pItem") {
        this.getMyInventoryList()
      }
    }
  },
  methods: {
    onSelect(action) {
      this.$router.push({path: "/material", query: {
          tabVal:action
        }
      })
    },
    getMyInventoryList() {
      let loading1 = this.$toast.loading({
        duration: 0,
        message: '加载中...',
        forbidClick: true,
      });
      getItemList({storeCode:this.$route.query.id}).then(res => {
        loading1.clear()
        if (res.code == 200) {
          this.loading = false;
          this.list = res.data
        } else {
          this.$toast.fail(res.msg)
        }
      })
    },
    onClickLeft() {
      this.$router.go(-1)
    },
  }
}
</script>
