<template>
  <!-- 添加车皮卸车实绩 -->
  <div class="addWagonLoad">
    <page-title>返回</page-title>

    <div>
      <dilTable
        v-bind.sync="option"
        ref="table"
        @selection-change="selectionChange"
      >
      </dilTable>
    </div>

  <div class="form">
      <div class="form_box">
         <dil-form :formId="255" v-model="form1" ></dil-form>
      </div>
    </div>
    <div class="button_box">
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="makeSure">确定</el-button>
    </div>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";

export default {
  components: { PageTitle },
  data() {
    return {
      form1: {},
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/tms/getWagonNo/2?apiId=213",
        // 控制显示当选列
        selectionType: "select",
      },
      value: undefined,
      list: [],
    };
  },
  mounted() {},
  methods: {
    selectionChange(selection) {
      this.list = [];
      selection.forEach((e) => {
        this.list.push({
          resultWagonNo: e.resultWagonNo,
          resultId: e.resultId,
        });
      });
    },
    // 确定
    makeSure() {
      let tmstrainWagonUnloadResult = {
        wagonNoList: this.list,
        resultArrivalDate: sjTime(this.form1.resultArrivalDate),
        resultUnloadTime: sjTime(this.form1.resultUnloadTime),
        unloadingPointId: this.form1.unloadingPointId,
        resultBigTicketWeight: this.form1.resultBigTicketWeight,
        resultRailHorizontalWeight: this.form1.resultRailHorizontalWeight,
        resultRemark: this.form1.resultRemark,
        resultType: 2,
      };
      console.log(tmstrainWagonUnloadResult);
      if (
        tmstrainWagonUnloadResult.wagonNoList == null ||
        tmstrainWagonUnloadResult.resultArrivalDate == null ||
        tmstrainWagonUnloadResult.resultUnloadTime == null ||
        tmstrainWagonUnloadResult.unloadingPointId == null ||
        tmstrainWagonUnloadResult.resultBigTicketWeight == null ||
        tmstrainWagonUnloadResult.resultRailHorizontalWeight == null
      )
        this.$message.error("存在空值！");
      else
        this.axios
          .post(
            "/api/v1/tms/insertTmstrainWagonUnLoadResult",
            tmstrainWagonUnloadResult
          )
          .then((res) => {
            if (res.data.code == "200") {
              this.$message({
                type: "success",
                message: "新增成功!",
              });
            }
            this.$router.go(-1);
          });
    },
    // 取消
    cancel(){
      this.$router.go(-1);
    },
  },
};
</script>
<style lang='scss'>
.addWagonLoad {
  .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>