<template>
  <!-- 添加货权转移实绩 -->
  <div class="shipTransport">
    <page-title>返回</page-title>
    <!-- 物资 -->
    <div class="mofrom">
      <span class="motext">物资</span>
      <el-input class="moinput" v-model="materialName" disabled> </el-input>
      <el-button class="mobutton" type="primary" @click="ondrawer(1)">浏览</el-button>
    </div>
    <!-- 货权转移送达单位 -->
    <div class="mofrom">
      <span class="motext">货权转移送达单位</span>
      <el-input class="moinput" v-model="cargo" disabled> </el-input>
      <el-button class="mobutton" type="primary" @click="ondrawer(2)">浏览</el-button>
    </div>
    <!-- 货权转移送达单位 -->
    <div class="mofrom">
      <span class="motext">收货人</span>
      <el-input class="moinput" v-model="receiver" disabled> </el-input>
      <el-button class="mobutton" type="primary" @click="ondrawer(3)">浏览</el-button>
    </div>
    <div class="form">
      <div class="form_box">
          <dil-form :formId="109" v-model="form1" ref="from1"></dil-form>
      </div>        
    </div>
    <!-- 确定和取消 -->
    <div class="button_box">
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="makeSure">确定</el-button>
    </div>
    <!-- 模态框 -->
    <el-drawer
      :visible.sync="drawer"
      :direction="direction"
      size="50%"
    >
      <el-input
        placeholder="请输入内容"
        v-model="input"
        style="margin-top: 10px; margin-left: 20px; width:250px"
        clearable
      >
      </el-input>
      <el-button
        type="primary"
        class="btn"
        @click="onclick(a)"
        style="margin-bottom: 15px"
      >
        <i class="el-icon-search"></i>查询
      </el-button>
      <div v-show="a == 1">
        <dilTable
          v-bind.sync="second"
          @radio-change="currentRadioChange1"
        ></dilTable>
      </div>
      <div v-show="a == 2">
        <dilTable
          v-bind.sync="second1"
          @radio-change="currentRadioChange2"
        ></dilTable>
      </div>
      <div v-show="a == 3">
        <dilTable
          v-bind.sync="second2"
          @radio-change="currentRadioChange3"
        ></dilTable>
      </div>
    </el-drawer>
  </div>
</template>
<script>
import PageTitle from "@/components/Page/Title";
export default {
  components: { PageTitle },
  data() {
    return {
      materialName: "",
      cargo: "",
      receiver: "",
      a: 1,
      form1: {},
      value: undefined,
      drawer: false,
      direction: "rtl",
      input: "",
      second: {
        requestUrl: "/api/v1/uc/queryMaterialByLike?apiId=244",
        selectionType: "radio",
        mapList1: [],
      },
      second1: {
        requestUrl: "/api/v1/tms/selectShippeByName?apiId=215",
        selectionType: "radio",
        mapList2: [],
      },
      second2: {
        requestUrl: "/api/v1/tms/getGroupList?apiId=217",
        selectionType: "radio",
        mapList3: [],
      },
    };
  },
  mounted() {},
  methods: {
    currentRadioChange() {
      console.log(1);
    },
    ondrawer(num) {
      this.drawer = true;
      this.a = num;
    },
    currentRadioChange1(selection) {
      (this.mapList1 = selection),
        (this.materialName = this.mapList1.materialName);
    },
    currentRadioChange2(selection) {
      (this.mapList2 = selection), (this.cargo = this.mapList2.portName);
    },
    currentRadioChange3(selection) {
      (this.mapList3 = selection), (this.receiver = this.mapList3.pierName);
    },

    // 确定git
    makeSure() {
      let AmsshipCargoTransferResult = {
        resultContactPerson: this.form1.resultContactPerson,
        resultTelephoneFax: this.form1.resultTelephoneFax,
        resultFreightForwardingInfo: this.form1.resultFreightForwardingInfo,
        resultMemo: this.form1.resultMemo,
        resultNumberOfLoans: this.form1.resultNumberOfLoans,
        resultNumber: this.form1.resultNumber,
        carrierId: this.mapList2.portId,
        groupId: this.mapList3.pierId,
        foreignShipName: this.form1.foreignShipName,
        materialId: this.mapList1.materialId,
      };
      if (
        AmsshipCargoTransferResult.resultContactPerson == null ||
        AmsshipCargoTransferResult.resultTelephoneFax == null
      )
        this.$message.error("存在空值！");
      else
        this.axios
          .post(
            "/api/v1/tms/insertamsshipCargoTransferResult",
            AmsshipCargoTransferResult
          )
          .then((res) => {
            if (res.data.code == 200) {
              this.$router.push("/ship/cargoResult");
              this.$message({
                type: "success",
                message: "新增成功",
              });
            }
          });
    },
    onclick(a) {
      console.log(a);
      if (a == 1) {
        this.second.requestUrl =
          "/api/v1/uc/queryMaterialByLike?apiId=244&index=" + this.input;
      } else if (a == 2) {
        this.second1.requestUrl =
          "/api/v1/tms/selectShippeByName?apiId=215&con=" + this.input;
      } else {
        this.second2.requestUrl =
          "/api/v1/tms/getGroupList?apiId=21&con=" + this.input;
      }
    },
    // 取消
    cancel() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang='scss'>
.shipTransport{
  .form{
    display: flex;
    .form_box{
      width: 320px;
      margin-left: 35%;
      margin-right: 20px;
      .el-form{
        .preview-group{
          .el-form-item{
            .el-form-item__label{
              display: inline-block;
              width: 70px !important;
            }
            .el-form-item__content{
              .el-select{
                width: 250px;
              }
              .el-input{
                width: 250px;
              }
            }
          }
        }
      }
    }
  }
  .mofrom {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 5px;
    margin-bottom: 20px;
    .motext{
      width: 70px;
    }
    .moinput{
      width: 250px;
    }
    .mobutton{
      margin-left: 5px;
    }
  }
  .button_box{
    margin-left: 45%;
  }
}
</style>
