<template>
  <!-- 计费详单页面 -->
  <div class="purchaseOrder">
    <div class="top">
      <el-input
        placeholder="请输入内容"
        v-model="input"
        clearable>
      </el-input>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <el-button type="primary" @click="btnclick">
        生成账单
      </el-button>
    </div>
    <dilTable v-bind.sync="option" @selection-change="selectionChange">
    </dilTable>
     <div class="button-box" style="margin-left:40rem">
      <el-button type="primary" @click="cancel">返回</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "purchaseOrder",
  data() {
    return {
      input:"",
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/bms/getUnFinishedTruckDetailsOrderList?apiId=176&orderType=1",
        // 控制显示多选列
        selectionType: "select",
        mapList:[],
      },
    };
  },
  methods: {
    selectionChange(selection) { 
      this.mapList=selection
    },
    onclick() {
      console.log("查询待定值");
    },
    btnclick() {
      this.$confirm("是否生成账单", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.axios
            .post("/api/v1/bms/addTruckStatement",this.mapList
			)
            .then((res) => {
              if (res.data.code == 0) {
                this.$message({
                  type: "success",
                  message: "生成账单成功!",
                });     
                this.$router.go(-1);
              } else {
                this.$message({
                  message: "生成账单失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消生成账单!",
          });
        });
      // this.$router.push("/path/addHomeworkPath/");
    },
    cancel(){
        this.$router.go(-1);
    }
  },
};
</script>
<style lang='scss' scoped>
.form-box{
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 5px;
  margin-bottom: 20px;
}
.button-box{
  display: flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  margin-top: 0.3125rem;
  margin-bottom: 1.25rem;
}
.purchaseOrder {
  .top {
    padding: 1.25rem 0.375rem;
			.el-input {
			width: 20%;
			margin-right: 1.25rem;
			}
  }
}
</style>