<template>
  <!-- 新增驳船作业 -->
<div class="shipTransport">
    <page-title>返回</page-title>
    <!-- 第一部分 -->
      <div class="top">
        <el-input placeholder="请输入内容" v-model="input" clearable> </el-input> 
        <el-button type="primary" class="btn" @click="onclick()">
          <i class="el-icon-search"></i>查询
        </el-button>   
      </div>
      <dilTable v-bind.sync="option" @radio-change="currentRadioChange">
      </dilTable>
    <div class="form">
      <!-- 第二部分 -->
      <div class="form_box">
          <dil-form :formId="125" v-model="form"></dil-form>
      </div>
    </div>
    <div class="button_box">
        <el-button type="primary" @click="makeSure" :disable="isLock">新增驳船作业</el-button>
    </div>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";
import { sjTime } from "@/utils/sharedJsFile";
export default {
  components: { PageTitle },
  data() {
    return {
      isLock:false,
      input:'',
      restaurants: [],
      state: "",
      form: {},
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/tms/getCapacityList?apiId=138",
        // 控制显示当选列
        selectionType: "radio",
        bagerShipMap:{},
      },
    };
  },
  mounted() {
  },
  methods: {
    currentRadioChange(row) {
      this.bagerShipMap=row
      console.log(row);
    },
    // 新增
    makeSure() {
      let mapVal = {
        orderId: this.$route.params.orderId,
        smallCapacityId: this.form.smallCapacityId,
        bargeSmallshipLoadWeight: this.form.bargeSmallshipLoadWeight,
        bargeRefuteDate: sjTime(
          this.form.bargeRefuteDate
        ),
        bargeRefuteLocation: this.form.bargeRefuteLocation,
        bargeBackDate: sjTime(
          this.form.bargeBackDate
        ),
        bargeBackLocation: this.form.bargeBackLocation,
      };
    
       if (
      mapVal.smallCapacityId==null||
      mapVal.bargeSmallshipLoadWeight==null||
      mapVal.bargeRefuteDate==null||
      mapVal.bargeRefuteLocation==null||
      mapVal.bargeBackDate==null||
      mapVal.bargeBackLocation==null
      ) this.$message.error("存在空值！");
      else
      this.axios
        .post(
          "/api/v1/tms/addBargeOperation",
          {
            mapVal:mapVal,
            bagerShipMap:this.bagerShipMap
          }
        )
        .then((res) => {
          if (res.data.code == 200) {
            this.$message({
              type: "success",
              message: "新增成功!",
            });
            // this.$refs.table.refreshData();
            this.$router.go(-1);
          } else {
            this.$message.error("新增失败！");
          }
          this.$refs['table'].resetField();
        });
    },
    loadAll() {
      return [

      ];
    },
    handleSelect(item) {
      console.log(item);
    },
    onclick() {
      this.option.requestUrl = "/api/v1/tms/getCapacityList?apiId=138&con=" + this.input
    },
  },
};
</script>
<style lang='scss'>
.shipTransport{
  .form{
    display: flex;
    .form_box{
      width: 320px;
      margin-left: 35%;
      margin-top: 30px;
      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;
              }
            }
          }
        }
      }
    }
  }
  .top {
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
  .button_box{
    margin-left: 45%;
    margin-right:1500px;
    width:150px;
  }
}
</style>