<template>
  <!-- 修改船只信息 -->
    <div class="shipTransport">
    <page-title>返回</page-title>
    <div class="form">
      <div class="form_box">
          <dil-form :formId="130" v-model="form1" ref="from1"></dil-form>
      </div> 
    </div>
    <!-- 确定和取消 -->
    <div class="button_box">
      <el-button type="primary" @click="onClickConfirm">确认</el-button>
      <el-button @click="onClickCancel">返回</el-button>
    </div>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";
import { sjTime } from "@/utils/sharedJsFile";
export default {
  components: { PageTitle },
 data(){
     return {
      form1: {},
  }
 },
  mounted() {
    this.information();
  },
  methods: {
    information() {
      //编辑船只信息
      this.axios
        .post("/api/v1/tms/getInstructionsCapacity/" + this.$route.params.orderId)
        .then((res) => {
          res.data.data.forEach((e) => {
            this.form1 = e;
            // console.log(e);
            // console.log(this.form1);
            // console.log(this.$route.params.loadingId);
          });
        });
    },
    handleCheckedCitiesChange(value) {
      console.log(value);
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    currentRadioChange(row) {
      this.aaaa = row;
    },
    // 确认
    onClickConfirm() {
      let omsshipInstructionsCapacity = {
        instructionsCapacityId:this.$route.params.orderId,
        instructionsId: this.$route.params.instructionsId,
        capacityId: this.form1.capacityId,
        instructionPlannedLoading: this.form1.instructionPlannedLoading,
        instructionsShipPosition: this.form1.instructionsShipPosition,
        instructionContactInf: this.form1.instructionContactInf,
        instructionsCapacityStatus: this.form1.instructionsCapacityStatus,
        instructionEsarrivalTime: sjTime(
          this.form1.instructionEsarrivalTime
        ),
      };
      console.log(omsshipInstructionsCapacity);
      this.axios
        .post(
          "/api/v1/tms/updateInstructionsCapacity",
          omsshipInstructionsCapacity
        )
        .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();
        });
    },
  },
};
</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;
              }
            }
          }
        }
      }
    }
  }
  .button_box{
    margin-left: 45%;
  }
}
</style>
