//转移
<template>
  <div class="addqueueFCancel">
    <div class="top">
      <dil-form :formId="247" v-model="form" @change="onChange"></dil-form>
    </div>
    <div class="tab">
      <dilTable
        v-bind.sync="option"
        @radio-change="currentRadioChange"
      ></dilTable>
    </div>
    <div class="reason">
      <dil-form :formId="248" v-model="form1" @change="onChange1"></dil-form>
    </div>
    <div class="input_textarea">
      <span>转移原因：</span>
      <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="resultTransferReason">
      </el-input>
    </div>
    <div class="btn">
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="onclick">确认</el-button>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {},
      form1: {},
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/qms/getAllQueueMes?apiId=184",
        // 控制显示当选列
        selectionType: "radio",
      },
      // 转移后的门岗id
      gatepostId: 0,
      // 排队实绩id
      resultId:0,
        //转移原因 
      resultTransferReason:''  
    };
  },
  methods: {
    cancel(){
        this.$router.push({
          path: "/queueFTransfer",
        });
    },
    onChange(val) {
      this.option.requestUrl =
        "/api/v1/qms/getAllQueueMes?apiId=184&gatepostId=" + val.gatepostId+"&i="+new Date();
    },
    onChange1(val) {
      this.gatepostId = val.gatepostId;
    },
    currentRadioChange(row) {
      this.resultId = row.resultId
    },
    onclick() {
      var mapValue = {
        resultId:this.resultId,
        gatepostId:this.gatepostId,
        resultTransferReason: this.resultTransferReason,
      };
      console.log(mapValue)
      if(mapValue.resultId !== 0 && mapValue.gatepostId !== 0 && mapValue.resultTransferReason !== ""){
        this.axios.post("/api/v1/qms/changeQueue",mapValue).then((res)=>{
          if(res.data.code == "200"){
            this.cancel();
            this.$message({
                message: '转移成功！',
                type: 'success'
            });
          }
        })
      }else{
        if(mapValue.resultId == 0){
          this.$message({
            message: '请选择需要转移的车辆！',
            type: 'warning'
          });
        }else{
          if(mapValue.gatepostId == 0){
            this.$message({
                message: '请选择需要转移到的门岗！',
                type: 'warning'
              });
          }else{
            if(mapValue.resultTransferReason == ""){
              this.$message({
                message: '请填写转移的原因！',
                type: 'warning'
              });
            }
          }
        }
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.addqueueFCancel {
  .top {
    width: 100%;
    height: 80px;
    padding-left: 50px;
    padding-top: 20px;
  }
  .tab {
    width: 100%;
    max-height: 300px;
  }
  .reason {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 30px;
    .el-form{
      width: 400px;
    }
  }
  .input_textarea{
    display: flex;
    align-items: center;
    justify-content: center;
    .el-textarea{
      width: 320px;
    }
  }
  .btn {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
</style>