<template>
  <div>
    <LossTemplate v-if="!loading" :actionTypes="actionTypes" :actionQueryParams="actionQueryParams"
      :baseQueryParams="baseQueryParams" :warehouseOptions="warehouseOptions" :productionLine="productionLine" />
    <el-empty v-else description="正在加载报表配置..." />
  </div>
</template>

<script>
import LossTemplate from '@/views/wms/report/template/loss.vue'
import { listReportConfig } from '@/api/wms/reportConfig.js'

export default {
  name: 'LossReport',
  components: {
    LossTemplate,
  },
  data() {
    return {
      loading: true,
      actionTypes: [],
      actionQueryParams: {},
      baseQueryParams: {},
      warehouseOptions: [],
      productionLine: '',
    }
  },
  mounted() {
    this.getReportConfig()
  },
  methods: {
    getReportConfig() {
      this.loading = true
      listReportConfig({
        reportCode: 'acid'
      }).then(res => {
        console.log(res)
        if (res.rows.length == 1) {
          const config = JSON.parse(res.rows[0].configJson)
          this.actionTypes = config.actionTypes
          this.actionQueryParams = config.actionQueryParams
          this.baseQueryParams = config.baseQueryParams
          this.warehouseOptions = config.warehouseOptions
          this.productionLine = config.productionLine
          this.loading = false
        }
      })
    }
  }
}
</script>