// 新增汽车装货
<template>
  <div id="endMaintenance">
    <page-title>新增汽车装货</page-title>
    <div class="main">
      <span class="text">选择运输订单</span>
      <span class="a"></span>
    </div>

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

    <div>
      <div class="form-box" style="margin-left: 5rem">
        <dil-form :formId="343" v-model="form"></dil-form>
      </div>
    </div>

    <div class="" style="margin-left: 40rem">
      <el-button type="primary" @click="makeSure">确认新增</el-button>
      <el-button type="primary" @click="cancel">返回</el-button>
    </div>
  </div>
</template>

<script>
import PageTitle from "@/components/Page/Title";
import { sjTime } from "@/utils/sharedJsFile";
export default {
  components: { PageTitle },
  data() {
    return {
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/oms/getReceiveRefuseOrder/1?apiId=117&orderType=9",
        // 控制显示多选列
        selectionType: "select",
      },
      form: {},
      totalResultIdList: [],
    };
  },
  created() {
    this.form = {
      loadTime:new Date(),
    }
  }, 
  methods: {
    selectionChange(val) {
      this.totalResultIdList = []
      val.forEach(e => {
        this.totalResultIdList.push(e.resultTotalId)
      });
    },

    // 新增
    makeSure() {
      let obj = {
        totalResultIdList: this.totalResultIdList,
        loadTime: sjTime(this.form.loadTime),
        isdeduct: this.form.isdeduct,
        loadingId: 10003,
      };
      console.log(obj);
      this.$axios
        .post("/api/v1/tms/addDaZhouToDaGangLoadResult", obj)
        .then((res) => {
          console.log(res);
          if (res.data.code == "200") {
            this.$message({
              type: "success",
              message: "新增成功!",
            });
            this.$router.go(-1);
          } else {
            this.$message.error("新增失败！");
          }
        });
    },
    // 返回
    cancel() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="scss">
</style>
