<!-- 库存明细 -->
<template>
  <div class="detail-box">
    <el-table
      :data="stockList"
      :header-cell-style="{ background: '#EEEEEE', border: 'none' }"
      ><el-table-column width="80px" label="序号" type="index">
      </el-table-column>
      <!-- <el-table-column
        :label="`${getDictValue('类型用途', baseInfo.assetType)}编码`"
        prop="onlyCode"
        width="200px"
      ></el-table-column> -->
      <el-table-column label="批次号" prop="batchNum"></el-table-column>
      <el-table-column label="编码" prop="code"></el-table-column>
      <el-table-column label="名称" prop="name"></el-table-column>
      <el-table-column label="牌号" prop="brandNum"></el-table-column>
      <el-table-column label="型号" prop="modelType"></el-table-column>
      <el-table-column label="规格" prop="specification"></el-table-column>
      <el-table-column label="最小包装单元" prop="packingUnit">
      </el-table-column>
      <el-table-column label="数量" prop="countNo"></el-table-column>
      <el-table-column label="单价" prop="price">
        <!-- <template slot-scope="{ row }">
          <template v-if="row.univalence || row.univalence === 0">
            {{ row.univalence }} {{ priceList[row.univalenceUnit] }}
          </template>
        </template> -->
      </el-table-column>
      <el-table-column label="质保期" prop="expirationDate"></el-table-column>
      <el-table-column label="入库人" prop="createUserName">
        <template slot-scope="{ row }">
          {{ handleUserName(row.createUserId) }}
        </template>
      </el-table-column>
      <el-table-column label="入库时间" prop="createTime"></el-table-column>
    </el-table>
    <Pagination
      :total="total"
      :page.sync="page"
      :size.sync="size"
      @pagination="handlePageChange"
    />
  </div>
</template>

<script>
  import Pagination from '@/components/Pagination';
  // import { inventoryDetails } from '@/api/stockManagement/stockLedger'
  // import dictMixins from '@/mixins/dictMixins'

  import ouint from '@/api/warehouseManagement/outin';
  export default {
    components: { Pagination },
    // mixins: [dictMixins],
    props: {
      baseInfo: {
        type: Object,
        default: () => ({})
      },
      baseParams: {
        type: Object,
        default: () => ({})
      }
      // stockList: {
      //   type: Array,
      //   default: () => []
      // }
    },
    data() {
      return {
        searchForm: {
          univalenceStart: '',
          univalenceEnd: '',
          onlyCode: '',
          batchNum: '',
          bizNum: ''
        },
        priceList: { yuan: '元', wanyuan: '万元' },
        tableData: [],
        size: 10,
        page: 1,
        total: 0,
        vuexUser: [],
        stockList: []
      };
    },
    computed: {
      dimension() {
        return this.$route.query.dimension;
      }
    },
    created() {
      this.getList();
    },
    methods: {
      handleUserName(row) {
        for (const key in this.vuexUser) {
          if (this.vuexUser[key].id == row) {
            return this.vuexUser[key].name;
          }
        }
      },
      search() {
        this.page = 1;
        this.getList();
      },
      handlePageChange(v) {
        this.page = v.current;
        this.size = v.size;
        this.getList();
      },
      reset() {
        this.searchForm = {};
        this.search();
      },
      async getList() {
        const rep = await ouint.getInventoryDetails({
          pageNum: this.page,
          size: this.size,
          categoryId: this.$parent.$route.query.id
        });
        console.log('===123', rep);
        this.stockList = rep.list;
        this.total = rep.count;
        // this.stockList = rep.list;
        // const res = await ouint.getInventoryDetails({
        //   size: this.size,
        //   page: this.page,
        //   ...this.searchForm,
        //   ...this.baseParams,
        //   batchNum: this.baseParams.batchNum || this.searchForm.batchNum
        // });
        // if (res) {
        //   const list = this.$store.state.userPage.userList;
        //   this.vuexUser = list;
        //   this.tableData = res.list;
        //   this.total = res.count;
        // }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .detail-box {
    margin: 20px auto;
  }
</style>
