<template>
  <!-- 添加汽车衡信息 -->
  <div class="addWagonLoad">
    <PageTitle>返回</PageTitle>
    <div class="form-box" style="margin-right: 10rem">
      <dil-form :formId="317" v-model="form1" ref="from1"> </dil-form>
    </div>
    <div class="form-box f1">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
      </el-form>
    </div>
    <div class="inputBox">
      <el-input
        :inline="true"
        placeholder="请输入内容"
        v-model="inputText"
        clearable
      >
      </el-input>
      <el-button type="primary" class="btn" @click="onclick" :inline="true">
        <i class="el-icon-search"></i>物资列表查询
      </el-button>
    </div>

    <div>
      <dilTable
        v-bind.sync="options"
        @selection-change="selectionChange"
      ></dilTable>
    </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 {
      materialName: "",
      form1: {},
      checkList: [],
      inputText: "",
      options: {
        // first请求数据的地址
        requestUrl: "/api/v1/rms/getMaterialList?apiId=351",
        selectionType: "select",
        mapList: [],
      },
    };
  },
  mounted() {},
  methods: {
    selectionChange(selection) {
      (this.mapList = selection), console.log(this.mapList);
      this.materialName = this.mapList.materialName;
    },
    onclick() {
      this.options.requestUrl =
        "/api/v1/rms/getMaterialList?apiId=351&con=" + this.inputText;
    },

    makeSure() {
      console.log(this.form1);

      let rmsTruckCalculate = {
        truckCalculateNumber: this.form1.truckCalculateNumber,
        truckCalculateId: this.form1.truckCalculateId,
        truckCalculateLongitude: this.form1.truckCalculateLongitude,
        truckCalculateLatitude: this.form1.truckCalculateLatitude,
        calculateType: this.form1.calculateType,
      };
      let map = {
        mapList: this.mapList,
        rmsTruckCalculate: rmsTruckCalculate,
      };
      if (
        rmsTruckCalculate.truckCalculateNumber == null ||
        rmsTruckCalculate.truckCalculateLongitude == null ||
        rmsTruckCalculate.truckCalculateLatitude == null ||
        rmsTruckCalculate.calculateType == null
      )
        this.$message.error("存在空值！");
      else
        this.axios.post("/api/v1/rms/insertTruckCalculate", map).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();
        });
    },

    // 取消
    cancel() {
      this.$router.go(-1);
    },
  },
};
</script>
<style lang='scss' >
.button-box {
  display: flex;
  justify-content: center;
  .el-button {
    width: 80px;
    margin-right: 10px;
  }
}
.inputBox {
  display: flex;
  text-align: center;
  align-items: center;
  margin-top: 2rem;
  width: 800px;
  .el-input__inner {
    display: flex;
    text-align: center;
    align-items: center;
  }
}
.btn-left {
  margin-left: 470px;
}
.input {
  margin-left: 90px;
}
.label {
  margin-left: 445px;
  margin-bottom: -30px;
  font: bold;
  font-size: 1rem;
  padding-left: -30px;
  font-family: Arial, Helvetica, sans-serif;
  margin-bottom: 20px;
}
.label2 {
  margin-left: 425px;
  margin-bottom: -30px;
  font: bold;
  font-size: 1rem;
  font-family: Arial, Helvetica, sans-serif;
}
.label1 {
  margin-left: 345px;
  margin-bottom: -30px;
  font: bold;
}
.common {
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  font-size: 1rem;
  cursor: default;
  color: #2c3e50;
}
.f1 {
  margin-top: -2.5rem;
  margin-left: 25rem;
}
.f11 {
  margin-top: -3rem;
  // margin-left: 29rem;
}
.f2 {
  margin-top: -2.5rem;
  margin-left: 20.7rem;
}
.f3 {
  margin-top: -2.5rem;
  margin-left: 25rem;
}
.form-box {
  display: flex;
  justify-content: center;
  .el-form-item {
    display: flex;
    justify-content: center;
    .el-form-item__label {
      display: flex;
      align-items: center;
    }
    .el-form-item__content {
      .el-input {
        .el-input__inner {
          width: 250px;
        }
      }
    }
  }
}
</style>
