<template>
  <!-- 添加车皮卸车实绩 -->
  <div class="addWagonLoad">
    <page-title>返回</page-title>
    <div class="main">
      <el-divider content-position="left"></el-divider>
    </div>
    <div>
      <dilTable
        v-bind.sync="option"
        ref="table"
        @selection-change="selectionChange"
      >
      </dilTable>
    </div>
    <!-- <el-divider content-position="left">车皮卸车实绩</el-divider> -->
    <div class="form">
      <div class="form_box" style="margin-right: 10rem">
        <dil-form :formId="255" v-model="form1" ref="from1"></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/3?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,
          purchaseOrderId: e.purchaseOrderId,
          unloadingPointId: e.unloadingPointId,
        });
      });
    },
    // 确定
    makeSure() {
      console.log(this.list);
      let tmstrainWagonUnloadResult = {
        wagonNoList: this.list,
        resultArrivalDate: sjTime(this.form1.resultArrivalDate),
        resultUnloadTime: sjTime(this.form1.resultUnloadTime),
        resultBigTicketWeight: this.form1.resultBigTicketWeight,
        resultRailHorizontalWeight: this.form1.resultRailHorizontalWeight,
        resultRemark: this.form1.resultRemark,
        resultType: 3,
      };
      console.log(tmstrainWagonUnloadResult);
      if (
        tmstrainWagonUnloadResult.wagonNoList == null ||
        tmstrainWagonUnloadResult.resultArrivalDate == null ||
        tmstrainWagonUnloadResult.resultUnloadTime == null ||
        tmstrainWagonUnloadResult.resultBigTicketWeight == null ||
        tmstrainWagonUnloadResult.resultRailHorizontalWeight == null
      )
        this.$message.error("存在空值！");
      else
        this.axios
          .post(
            "/api/v1/tms/insertTmstrainWagonUnLoadResult",
            tmstrainWagonUnloadResult
          )
          .then(() => {
            this.$message({
              type: "success",
              message: "新增成功!",
            });
            this.$router.go(-1);
          });
    },
    // 取消
    cancel() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang='scss' scoped>
.addWagonLoad {
  .form {
    display: flex;
    .form_box {
      width: 320px;
      margin-left: 35%;
      margin-top: 30px;
      margin-right: 22px;
      .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: 220px;
              }
            .el-textarea{
                .el-textarea__inner {
                  display: block;
                  resize: vertical;
                  padding: 5px 13px;
                  line-height: 1.5;
                  width: 70%;
                  border-radius: 4px;
                  margin-left: 56px;
                  margin-top: -25px;
    
                }
             }  
            }
          }
        }
      }
    }
  }
  .button-box{
    margin-top: 50px;
    margin-left: 600px;
  }
}
</style>