<template>
  <!-- 新增请作业页面 -->
  <div class="contractDetails">
    <page-title>返回</page-title>

    <div class="form">
      <div class="form_box">
        <dil-form :formId="118" v-model="form1"></dil-form>
      </div>
    </div>
    <!-- 确定和取消 -->
    <div class="button_box">
      <el-button @click="onClickCancel">返回</el-button>
      <el-button type="primary" @click="onClickConfirm">确认</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/getTmstrainWagonUnLoadResultByUnLoadingId/" +
            this.$route.params.unloadingId
        )
        .then((res) => {
          res.data.data.forEach((e) => {
            this.form1 = e;
            console.log(e);
            console.log(this.form1);
            console.log(this.$route.params.unloadingId);
          });
        });
    },
    handleCheckedCitiesChange(value) {
      console.log(value);
    },
    // 返回
    onClickCancel() {
      this.$router.go(-1);
    },
    currentRadioChange(row) {
      this.aaaa = row;
    },
    //确定
    onClickConfirm() {
      let tmstrainWagonUnloadResult = {
        unloadingId: this.$route.params.unloadingId,
        resultWagonNo: this.form1.resultWagonNo,
        resultArrivalDate: sjTime(this.form1.resultArrivalDate),
        resultUnloadTime: sjTime(this.form1.resultUnloadTime),
        unloadingPointId: this.form1.unloadingPointId,
        resultRemark: this.form1.resultRemark,
      };
      console.log(tmstrainWagonUnloadResult);
      if (
        tmstrainWagonUnloadResult.resultWagonNo == null ||
        tmstrainWagonUnloadResult.resultArrivalDate == null ||
        tmstrainWagonUnloadResult.resultUnloadTime == null
      )
        this.$message.error("存在空值！");
      else
        this.axios
          .post(
            "/api/v1/tms/upadteTmstrainWagonUnLoadResultByUnLoadingId",
            tmstrainWagonUnloadResult
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$message({
                type: "success",
                message: "修改成功!",
              });
            } else {
              this.$message({
                type: "failed",
                message: "修改失败，请联系管理员!",
              });
            }
            this.$router.go(-1);
          });
    },
  },
};
</script>
<style lang="scss">
.contractDetails {
  .form {
    display: flex;
    .form_box {
      width: 340px;
      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;
              }
            }
            .el-textarea {
              .el-textarea__inner {
                width: 230px;
                margin-left: 65px;
                margin-top: 0.03rem;
              }
            }
          }
        }
      }
    }
  }
  .button_box {
    margin-left: 42%;
    margin-top: 55px;
  }
}
.fromOther {
  margin-left: 34.5%;
  width: 50%;
  .inline-input {
    width: 300px;
  }
}
</style>