<template>
  <vxe-modal v-model="value" id="wmsItemstModel" width="60%" v-loading="load" @show="show" height="60%" show-zoom resize transfer>
    <template #title>
      <span>入库商品信息</span>
    </template>
    <by-table :propConfig="tableConfig" ref="table" id="item-table"></by-table>
  </vxe-modal>
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import { queryPrice } from '@/api/priceManage'
@Component({components:{}})
export default class QuestModel extends Vue {
  value=false;
  load=false;
  tableConfig:any={
    attr:{
      size:'mini',
      seq:true,
      align:'center',
      showFooter:true,
      footerMethod: data => {
        let d:Array<any> = [];
        let n = 0;
        for(let i = 0; i < data.columns.length; i++){
          d.push('')
        }
        for(const item of data.data){
          if(Number(item.quantity)){
            n = n + Number(item.quantity)
          }
        }
        d[d.length - 1] = '总数（' + n + '）'
        return [d];
      }
    },
    columns:[{
      title:'商品名称',
      field:'productName'
    },{
      title:'商品编码',
      field:'productCode'
    },{
      title:'商品条码',
      field:'barCode'
    },
    {
      title:'数量',
      field:'quantity'
    }
  ]}
  data:Array<any>=[]
  mounted(){
    
  }
  btn(){
    let data:Array<any> = (this.$refs.table as any).getSelectData();
    if(!data || data.length == 0){
      this.$message('请选择数据！');
      return
    }
    this.$emit('priceHandle', data[0].price)
    this.value = false
  }
  show(){
    let height = (document.getElementById('item-table') as any).parentNode.offsetHeight;
    this.tableConfig.attr.height=height - 36;
    (this.$refs.table as any).setConfig(this.tableConfig);
  }
  setData(data:Array<any>){
    if(data){
      this.$nextTick(()=>{
        (this.$refs.table as any).setValue(data)
      })
    }
    
  }

  setShow(v:boolean){
    this.value = v;
  }
}
</script>

<style lang="scss" scoped>

</style>