<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>
         <el-form ref="form" :model="form" label-width="80px">
           <el-form-item label="offerId">
             <el-input v-model="form.offerId" placeholder="placeholder"></el-input>
           </el-form-item>
           <el-form-item label="offerProdId">
             <el-input v-model="form.offerProdId" placeholder="placeholder"></el-input>
           </el-form-item>
           <el-form-item label="clearanceFreight">
             <el-input v-model="form.clearanceFreight" placeholder="placeholder"></el-input>
           </el-form-item>
           <el-form-item label="seaFreight">
             <el-input v-model="form.seaFreight" placeholder="placeholder"></el-input>
           </el-form-item>
         </el-form>
         <h3>
           {{ JSON.stringify(follow) }}
         </h3>
         <div>
           <el-button type="primary" @click="handleSubmit">提交</el-button>
         </div>
       </el-card>
     </el-col>
    </el-row>
  </div>
</template>

<script>
import {createOfferSpecial, getOffer, getOfferSpecial} 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
      }
    })
    this.getOfferSpecial()
  },
  data() {
    return {
      form: {
        // "applyResult": "",
        // "applyStatus": 0,
        "clearanceFreight": 0,
        "offerId": 0,
        "offerProdId": 0,
        "seaFreight": 0
      },
      follow: {}
    }
  },
  methods: {
    handleSubmit(){
      createOfferSpecial(this.form).then(r => {
        this.$message.success(r.msg || '提交成功')
      })
    },
    getOfferSpecial(){
      getOfferSpecial(this.form.offerProdId).then(r => {
        this.follow = r.data
      })
    }
  }
}
</script>

<style scoped>

</style>
