<template>
     <div v-if="isShow">
         <template >
             <a-modal
                 v-model="isShow"
                 width="900px"
                :closable="false"
                 :maskClosable="false"
                 ok-text="确认"
                 
                 class="add-edit-model"
             >
             <template #footer>
                 <a-button key="submit" type="primary"  @click="exportSummary">导出</a-button>
                 <a-button key="submit" type="primary"  @click="handleOk">确认</a-button>
             </template>
                 <a-table
                    :columns="streetSummaryColumns"
                    :data-source="streetSummarys"
                    :pagination="false"
                    @change="getStreetSummarys"
                >
        </a-table>
             </a-modal>
         </template>
         
         

     </div>
</template>
<script>

export default {
    props:[ 'visible', 'modelData'],
    watch: {
        //监听并接收父组件的visible并赋值给isShow（子组件接收父组件props传过来的值时不能起一样的类名，会报重复定义的错）
        visible: function(newVal){
            this.isShow = newVal;  //newVal即是visible
            // newVal && this.showConfirm(); //newVal存在的话执行showConfirm函数
        },
        
        modelData: function(newVal){
            console.log(newVal)
            this.mdata=newVal
            this.$nextTick(()=>{
                this.getStreetSummarys();
            })
            
        },
    },
    data() {
        return {
            isShow:false,
            
            closable:true,//取消model模态框右上角的X号
            mdata:[],
            streetSummarys:[],
            streetSummaryColumns:[
                {
                    title: "巷道",
                    dataIndex: "streetName",
                },
                {
                    title: "盘点任务号",
                    dataIndex: "taskId",
                },
                {
                    title: "空托盘数量",
                    dataIndex: "emptyCount",
                },
                {
                    title: "空货位数",
                    dataIndex: "emptyGoodsCount",
                },
                {
                    title: "卷烟货位数",
                    dataIndex: "goodsCount",
                },
                {
                    title: "开始时间 ",
                    dataIndex: "startTime",
                },
                {
                    title: "结束时间",
                    dataIndex: "endTime",
                }
            ],
        };
    },
    mounted() {
        //todo 查询列表
        this.getStreetSummarys();
    },
    destroy(){
        
        
    },
    methods: {
        
        //获取盘点任务下所有巷道的统计
        
        getStreetSummarys() {
            console.log(this.modelData);
            this.$api.httpApi.getStreetSummary({
                params: {
                    taskId: this.modelData.taskId,
                }
            }).then(res => {
                if (res.code == 200) {
                    this.streetSummarys = res.data
                    console.log("getStreetSummarys");
                    console.log(this.streetSummarys);
                }
            }).catch(err => {
                console.log(err);
            });
        },
        handleOk() {
            this.$emit('close', false, {});
        },
        exportSummary() {
            this.$utils.downloadFileUrl('盘点统计'+this.mdata.taskId+'.xls', '/api/checkSummary/export?taskId='+this.mdata.taskId);
        }
        
        
      
       
        
    },
};
</script>
<style lang="scss" scoped>
    
</style>
