<template>
    <!-- 订单获取入仓记录 -->
    <el-dialog :title="title" visible :before-close="closeDialog" :close-on-click-modal="false" width="800px">
       <el-table v-if="packData" :data="packData">
         <el-table-column type="index" :label="$t('序号')" />
         <el-table-column :label="$t('打包人')" prop="name">
           <template slot-scope="{row}">
             {{row.creatorName}}
           </template>
          </el-table-column>isNoNeedToPack
         <el-table-column :label="$t('打包时间')" prop="time" >
           <template slot-scope="{row}">{{row.createTime|parseTime}}</template>
         </el-table-column>
         <el-table-column :label="$t('备注')" prop="time" >
           <template slot-scope="{row}">{{row.isNoNeedToPack?this.$t('无需打包'):''}}</template>
         </el-table-column>
         <el-table-column :label="$t('操作')">
           <template slot-scope="{row}">
             <el-button type="primary" @click="showPackDetail(row)">{{$t('详情')}}</el-button>
           </template>
         </el-table-column>
       </el-table>
       <!-- 分页组件 -->
       <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.rows"
         @pagination="getList" />
    </el-dialog>
</template>
<script>
import { orderItemPackLogPage } from '@/api/ecw/order'
import { parseTime } from '@/utils/ruoyi'

export default {
    filters: {parseTime},
    props:{
      order: Object,
      orderItemId: Number,
    },
    data(){
        return {
          total:0,
          queryParams:{
            page:1,
            rows:10
          },
          packData:[]
        }
    },
    computed:{
      title(){
        if(!this.order||!this.orderItemId) return this.$t('打包历史')
        var orderItem = this.order.orderItemVOList.find(item => item.orderItemId == this.orderItemId)
        if(!orderItem) return this.$t('打包历史')
        return  orderItem.prodTitleZh+'('+ orderItem.prodTitleEn+')' + this.$t('打包历史')
      }
    },

    created(){
        this.show = true
        console.log(this.orderItemId)
        if(this.order && this.orderItemId){
          this.queryParams.orderId = this.order.orderId;
          this.queryParams.orderItemId = this.orderItemId;
          this.getList()
        }

    },
    methods:{
      getList(){
          orderItemPackLogPage(this.queryParams).then(res => {
            this.packData = []
            this.$nextTick(() => {
              this.packData = res.data.list
            })
            this.total = res.data.total;
          })
      },
      closeDialog(){
          this.show = false
          this.$emit('close');
      },
      showPackDetail(orderWarehouseInContent){
        this.$emit('showPackDetail',orderWarehouseInContent);
      }
    }
}
</script>