<template>
  <!-- 修改位置作业 -->
    <div class="shipTransport">
    <page-title>返回</page-title>
    <div class="form">
      <div class="form_box">
          <dil-form :formId="136" 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";
import { getCookie } from "@/utils/util.js";
export default {
  components: { PageTitle },
 data(){
     return {
      form1: {},
      waterQualiyResultId:null,
      outWharyResultId:null,
  }
 },
  mounted() {
    this.information();
  },
  methods: {
    information() {
      //编辑位置作业
      this.axios
        .post("/api/v1/tms/getLoadShip/" + this.$route.params.resultId)
        .then((res) => {
          res.data.data.forEach((e) => {
            this.form1 = e;
            this.waterQualiyResultId=e.waterQualiyResultId;
            this.outWharyResultId=e.outWharyResultId;
          });
        });
    },
    handleCheckedCitiesChange(value) {
      console.log(value);
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    currentRadioChange(row) {
      this.aaaa = row;
    },
    // 确认
    onClickConfirm() {
      let mapVal = {
        resultId: this.$route.params.resultId,
        waterQualiyResultId:this.waterQualiyResultId,
        resultActualInstallations: this.form1.resultActualInstallations,
        outWharyResultId:this.outWharyResultId,
        // rwarehouseMaterialId: this.form1.rwarehouseMaterialId,
        resultArrivalPortTime: sjTime(
          this.form1.resultArrivalPortTime
        ),
        resultOutPortTime: sjTime(
          this.form1.resultOutPortTime
        ),
        resultLoadShipDate: sjTime(
          this.form1.resultLoadShipDate
        ),
        resultIsClear: this.form1.resultIsClear,
        resultOutPortName:this.form1.resultOutPortName,
        //planDate:sjTime(this.form1.planDate),
        //planDeliveryDate:sjTime(this.form1.planDeliveryDate),
        //resultHeavyWeight:this.form1.resultHeavyWeight,
        userId:getCookie("userId"),
      };
              //判断放货数量是否为数字
       function isNumber() {
        var value = mapVal.resultActualInstallations;
        //验证是否为数字
        var patrn = /^(-)?\d+(\.\d+)?$/;
        if (patrn.exec(value) == null || value == "") {
          return false;
        } else {
          return true;
        }
      }
      var val=this.value;
    
    
      this.axios
        .post(
          "/api/v1/tms/updateLoadShip",
          mapVal
        )
        .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>
