<template>
  <div class="app-container">
    <el-row type="flex" justify="center">
     <el-col :xs="24" :sm="24" :md="24" :lg="20" :xl="16">
       <el-card class="box-card">
         <div slot="header" class="clearfix">
           <span>优惠申请</span>
         </div>
         offerId: {{ form.offerId }}<br>
         offerProdId: {{ form.offerProdId }}<br>
         clearanceFreight: {{ form.clearanceFreight }}<br>
         seaFreight: {{ form.seaFreight }}
         <div>
           <el-button type="primary" @click="handleSubmit">提交</el-button>
         </div>
       </el-card>
     </el-col>
    </el-row>
  </div>
</template>

<script>
import {createOfferSpecial, getOffer} from "@/api/ecw/offer"

export default {
  name: "specialDiscount",
  props: {
  },
  created() {
    if(this.$route.query.offerId){
      this.form.offerId = this.$route.query.offerId - 0
    }
    if(this.$route.query.offerProdId){
      this.form.offerProdId = this.$route.query.offerProdId - 0
    }
    getOffer(this.form.offerId).then(r => {
      const line = r.data.offerProdRespVOList.find(e => e.offerProdId = this.form.offerProdId)
      console.log(line)
      const {
        clearanceFreight,
        seaFreight
      } = line
      this.form = {
        ...this.form,
        clearanceFreight,
        seaFreight
      }
    })
  },
  data() {
    return {
      form: {
        // "applyResult": "",
        // "applyStatus": 0,
        "clearanceFreight": 0,
        "offerId": 0,
        "offerProdId": 0,
        "seaFreight": 0
      }
    }
  },
  methods: {
    handleSubmit(){
      createOfferSpecial(this.form).then(r => {
        this.$message.success(r.msg || '提交成功')
      })
    }
  }
}
</script>

<style scoped>

</style>
