<template>
    <div style="margin-bottom: 20px">
      <el-table v-loading="loading" :data="recordList">
        <el-table-column label="操作人" align="center" prop="createBy" />
        <el-table-column label="数量" align="center" prop="number" />
        <el-table-column label="操作时间" align="center" prop="createTime" />
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
</template>

<script>
  import { listLog } from "@/api/track/storeLog.js";
  import { listDetail } from "@/api/track/executeDetail";
  export default {
    name: "record-info",
    props:{
      tab: {
        type: String,
        default: "import"
      },
      id: {
        type: Number
      }
    },
    data(){
        return{
          loading: false,
          recordList: [],
          total: 0,
          queryParams:{
            pageNum: 1,
            pageSize: 10,
            storeId: null
          }
        }
    },
    created(){
      this.getList();
    },
    methods:{
      getList(){
        if(this.tab == 'import'){
          this.getImportRecord();
        }else{
          this.getExportRecord();
        }

      },
      //入库信息
      getImportRecord(){
        this.loading = true;
        this.queryParams.storeId = this.id;
        listLog(this.queryParams).then(res =>{
          this.loading = false;
          if(res.code == 200){
              this.total = res.total;
              this.recordList = res.rows;
          }
        })
      },
      //出库记录
      getExportRecord(){
        this.loading = true;
        this.queryParams.typeId = this.id;
        this.queryParams.type = 2;
        listDetail(this.queryParams).then(res =>{
          this.loading = false;
          if(res.code == 200){
            this.total = res.total;
            this.recordList = res.rows;
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
