<template>
  <!-- 附加页面 -->
  <div>
    <!-- 页面左半部分 -->
    <el-form
      :model="model"
      ref="modelForm"
      label-position="left"
      label-width="150px"
      size="small"
      :rules="rules"
    >
      <el-col :span="12">
        <el-col :span="22">
          <el-form-item label="成本" prop="cost">
            <c-input-number v-model="model.cost"   :precision="4" placeholder="请输入"></c-input-number>%
          </el-form-item>
        </el-col>
      </el-col>
      <el-col :span="12">
        <el-col :span="22">
          <el-form-item label="报价" prop="offer">
            <c-input-number v-model="model.offer" :precision="4" placeholder="请输入"></c-input-number>%
          </el-form-item>
        </el-col>
      </el-col>
      <el-col :span="12">
        <el-col :span="22">
          <el-form-item label="税率" prop="tax">
            <div>
            <c-input-number v-model="model.tax" :precision="4" placeholder="请输入"></c-input-number>%</div>
          </el-form-item>
        </el-col>
      </el-col>
      <el-col :span="12">
        <el-col :span="22">
          <el-form-item label="税后报价" prop="taxBehindOffer">
            <c-input-number v-model="model.taxBehindOffer" :precision="4" disabled></c-input-number>%
          </el-form-item>
        </el-col>
      </el-col>
      <el-col :span="12">
        <el-col :span="22">
          <el-form-item label="税后收益" prop="taxBehindProfit">
            <c-input-number v-model="model.taxBehindProfit" :precision="4" disabled></c-input-number>%
          </el-form-item>
        </el-col>
      </el-col>
    </el-form>
  </div>
</template>

<script>
import moment from "moment";
import Api from "~/service/Api";
import Calculator from "./Calculator";

export default {
  data() {
    return {
      zczyDate: {
        // 最迟装运/服务提供日  大于等于有效日期 且 小于等于 信用证的到期日
        disabledDate: time => {
          return (
            time.getTime() < moment(this.model.bgnIntDay) ||
            time.getTime() > moment(this.model.dueDate)
          );
        }
      },
      model: new Calculator().data,
      rules: {}
    };
  },
  props: ["model", "codes"],
  methods: {},
  computed: {
    //税后报价=成本*(1+税率）
    taxBehindOffer() {
      return this.model.cost *(1 + (this.model.tax/100));
    },
    //税后收益=报价-税后报价
    taxBehindProfit() {
      // let profit1=this.model.offer / (1 + this.model.tax/100) - this.model.cost;
      let profit1 =this.model.offer - this.taxBehindOffer;
      console.log(profit1)
      return profit1
    }
  },
  watch: {
    taxBehindOffer() {
      this.model.taxBehindOffer = this.taxBehindOffer;
    },
    taxBehindProfit() {
      this.model.taxBehindProfit = this.taxBehindProfit;
    }
  }
};
</script>