<template>
  <div>
    <div v-show="businessType === 'warehouse_flow_in'|| this.businessType === 'warehouse_flow_out'">
      <stock-order-detail ref="stockOrderDetail" @approveFinished="approveFinished"/>
    </div>
    <div v-show="businessType === 'contract_review'">
      <contract-detail ref="contractDetail" @approveFinished="approveFinished"/>
    </div>
    <div v-show="businessType === 'sale_order_flow'">
      <order-detail ref="orderDetail" @approveFinished="approveFinished"/>
    </div>
    <div v-show="businessType === 'sale_purchase_flow'">
      <purchase-detail ref="purchaseDetail" @approveFinished="approveFinished"/>
    </div>
    <div v-show="businessType === 'wh_template_record_flow'">
      <template-out-detail ref="templateOutDetail" @approveFinished="approveFinished"/>
    </div>
    <div v-show="businessType === 'pro_product_flow'">
      <product-detail ref="productDetail" @approveFinished="approveFinished"/>
    </div>
    <div v-show="businessType === 'pro_technology_flow'">
      <craft-detail ref="craftDetail" @approveFinished="approveFinished"/>
    </div>
  </div>
</template>

<script>
  import stockOrderDetail from '../warehouse/stock-order-detail'
  import contractDetail from '../cus/contract-detail'
  import orderDetail from '../order/order-detail'
  import purchaseDetail from '../sale/purchase-detail'
  import templateOutDetail from '../warehouse/template-delivery-detail'
  import productDetail from '../tech/product-detail'
  import craftDetail from '../tech/crafts-detail'
  export default {
    name: 'approve-add-or-update',
    components: {
      stockOrderDetail, contractDetail, orderDetail, purchaseDetail, templateOutDetail, productDetail, craftDetail
    },
    data () {
      return {
        businessType: 0,
        businessId: 0,
        display: false
      }
    },
    methods: {
      async init (businessType, businessId, display) {
        this.businessType = businessType || ''
        this.businessId = businessId || 0
        this.display = display
        if (this.businessType === 'warehouse_flow_in' || this.businessType === 'warehouse_flow_out') {
          this.display ? this.$refs.stockOrderDetail.init(this.businessId) : this.$refs.stockOrderDetail.init(this.businessId, businessType)
        } else if (this.businessType === 'contract_review') {
          this.display ? this.$refs.contractDetail.init(this.businessId) : this.$refs.contractDetail.init(this.businessId, businessType)
        } else if (this.businessType === 'sale_order_flow') {
          this.display ? this.$refs.orderDetail.init(this.businessId) : this.$refs.orderDetail.init(this.businessId, businessType)
        } else if (this.businessType === 'sale_purchase_flow') {
          this.display ? this.$refs.purchaseDetail.init(this.businessId) : this.$refs.purchaseDetail.init(this.businessId, businessType)
        } else if (this.businessType === 'wh_template_record_flow') {
          this.display ? this.$refs.templateOutDetail.init(this.businessId) : this.$refs.templateOutDetail.init(this.businessId, businessType)
        } else if (this.businessType === 'pro_product_flow') {
          this.display ? this.$refs.productDetail.init(this.businessId) : this.$refs.productDetail.init(this.businessId, businessType)
        } else if (this.businessType === 'pro_technology_flow') {
          this.display ? this.$refs.craftDetail.init(this.businessId) : this.$refs.craftDetail.init(this.businessId, businessType)
        } else {
          this.$message.error('流程类别不支持，请联系管理员！')
        }
      },
      approveFinished () {
        this.$emit('refreshDataList')
      }
    }
  }
</script>

<style scoped>
.my-line{
  border-bottom: 1px solid #c0c4cc;
  margin-bottom: 10px;
}
.title{
  padding: 10px 0 ;
}
</style>
