<template>
  <div class="other">
      <el-form label-width="120px"  ref="form" :model="form">
         <div class="divider">
           <div class="title">
             <div class="ele-bg-primary"></div>
             <span>计划</span>
           </div>
           <div class="ele-bg-primary ele-width"></div>
         </div>
         <el-row :gutter="24">
           <el-col :span="8">
             <el-form-item label="固定提前期" prop="fixLeadTime">
                <el-input  v-model="form.fixLeadTime" @input="inputFix"/>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="变动提前期" prop="changeLeadTime">
                <el-input  v-model="form.changeLeadTime" @input="inputChange"/>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="检验提前期" prop="checkLeadTime">
                <el-input  v-model="form.checkLeadTime" @input="inputCheck"/>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="累计提前期" prop="cumLeadTime">
                <el-input  v-model="form.cumLeadTime" readonly/>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="提前期单位" prop="unit">
                <DictSelection dictName="提前期单位" clearable v-model="form.unit">
                </DictSelection>
             </el-form-item>
           </el-col>
           <el-col :span="8">
             <el-form-item label="订货间隔期" prop="scheduleType">
                <div class="form-line">
                  <el-input  v-model="form.orderIntervalTime"/>
                  <DictSelection class="line-select" dictName="提前期单位" clearable v-model="form.orderIntervalUnit">
                  </DictSelection>
                </div>
             </el-form-item>
           </el-col>
         </el-row>
      </el-form>
  </div>
</template>

<script>
  export default {
    props: {
      form: {
        type: Object,
        default: {}
      }
    },
    components: { },
    data() {
      return {


      };
    },

    methods: {
      inputFix(val){
         const  changeLeadTime = this.form.changeLeadTime?Number(this.form.changeLeadTime):0
         const  checkLeadTime = this.form.checkLeadTime?Number(this.form.checkLeadTime):0
         val = val?Number(val):0
         this.form.cumLeadTime = val + changeLeadTime  + checkLeadTime
      },
      inputChange(val){
        const  fixLeadTime = this.form.fixLeadTime?Number(this.form.fixLeadTime):0
        const  checkLeadTime = this.form.checkLeadTime?Number(this.form.checkLeadTime):0
        val = val?Number(val):0
         this.form.cumLeadTime = val + fixLeadTime  + checkLeadTime
      },
      inputCheck(val){
          const  fixLeadTime = this.form.fixLeadTime?Number(this.form.fixLeadTime):0
          const  changeLeadTime = this.form.changeLeadTime?Number(this.form.changeLeadTime):0
          val = val?Number(val):0
         this.form.cumLeadTime = val + fixLeadTime  + changeLeadTime
      }
    }
  };
</script>

<style lang="scss" scoped>
  .other{
    background: #fff;
    padding: 1px 17px;
  }
  .divider {
    margin: 0px 0 20px;
    .title {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      div {
        width: 8px;
        height: 20px;
        margin-right: 10px;
      }
      span {
        font-size: 20px;
      }
    }
    .ele-width{
      width: 100%;
      height: 2px;
    }
  }
  .form-line{
    display: flex;
    align-items: center;
    justify-content: space-between;
    .line-select{
      margin-left:15px;
    }
  }
</style>
