<template>
    <div>
      <CommonInfo :tradeData="tradeData"/>
      <div style="margin: 11px 30px;color: #1890ff;">买方审核</div>
      <el-row style="margin-left:95px">
        <el-col :span="8">
          <el-radio v-model="radio" label="1">
            <span style="margin: 0px 5px;">议价</span>
            <el-input v-model="price" placeholder="请输入价格" style="width: 130px" @blur="priceInput" :disabled="priceDisabled"/>
          </el-radio>
        </el-col>
        <el-col :span="8">
          <el-radio v-model="radio" label="2">
            <span style="margin: 0px 5px;">评价</span>
            <el-input v-model="socre"
                      placeholder="请输入评分"
                      style="width: 130px" @blur="socreInput"
                      oninput="if(!/^[0-9]+$/.test(value)) value=value.replace(/\D/g,'');if(value>100)value=100;if(value<0)value=null"
                      :disabled="socreDisabled"/>
          </el-radio>
        </el-col>
        <el-col :span="8">
          <span style="margin: 0px 5px">成交价</span>
          <el-input v-model="dealPrice" disabled style="width: 130px"/>
        </el-col>
      </el-row>
      <el-row style="margin-left:90px;padding-top: 10px">
        <el-col :span="24">
          <span style="margin: 0px 5px">说明</span>
          <el-input v-model="dealRemark" type="textarea" style="width: 590px"/>
        </el-col>
      </el-row>
      <el-divider></el-divider>
    </div>
</template>

<script>
  import CommonInfo from "./CommonInfo";
    export default {
      name: "evaluate",
      props:{
        tradeData: {
          type: Object
        }
      },
      components:{
        CommonInfo
      },
      data(){
        return{
          radio:"2",
          priceDisabled: true,
          socreDisabled: false,
          socre: "",
          price: "",
          dealPrice: "",
          dealRemark:""
        }
      },
      watch:{
        radio(newVal,oldVal){
          this.price = "";
          this.socre = "";
          this.dealPrice = "";
          if(newVal == '1'){
            this.priceDisabled = false;
            this.socreDisabled = true;
          }
          if(newVal == '2'){
            this.priceDisabled = true;
            this.socreDisabled = false;
          }
        }
      },
      methods:{
        //议价
        priceInput(){
          this.dealPrice = this.price;
        },
        socreInput(){
          this.dealPrice = this.tradeData.tradeTotal * this.socre / 100;
        },
        resetSuggestion(){
          this.price = "";
          this.socre = "";
          this.dealPrice = "";
          this.dealRemark="";
        },
        checkParam(){
          if(!this.dealPrice){
            this.$message.error("请检查评价信息！")
            return true;
          }
          return false;
        },
        submitSuggestion(){
          let param = {tradeId:this.tradeData.tradeId,tradeStatus:"1",dealPrice:this.dealPrice,dealRemark:this.dealRemark};
          if(this.socre){
            param.tradeScore = this.socre;
          }else{
            param.tradeScore = -1;
          }
          return param;
        }
      }
    }
</script>

<style scoped>

</style>
