<template>
  <!--承运商接收销售订单-->
  <div class="homeworkPath">
    <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>
    </div>
    <dilTable v-bind.sync="option" ref="table">
      <el-table-column fixed="right" label="操作" width="80">
        <template slot-scope="scope">
          <el-button
            @click="detailclick(scope.row)"
            type="text"
            size="small"
          >
            查看详情
          </el-button>
        </template>
      </el-table-column>
      <el-table-column type="expand" width="1">
          <template slot-scope="props">
            <el-form label-position="center" inline class="demo-table-expand">
              <div v-if="false">{{ props }}</div>
              <div>
              <dilTable v-bind.sync="tablelist"></dilTable>
              </div>
            </el-form>
          </template>
        </el-table-column>
    </dilTable>
  </div>
</template>
<script>
export default {
  name: "wagonPlease",
  data() {
    return {
      input: "",
      option: {       
        // 表格请求数据的地址
        requestUrl: "/api/v1/oms/selectCokeRailPlan/1?apiId=236&orderType=2",
      },
      //记录旧的row对象
      oldRow: "",
      //记录上一个展开的点击次数，单数为展开状态，复数为闭合状态
      oldRowCount: 1,
      tablelist:{
        requestUrl:''
      }
    };
  },
  methods: {
    onclick() {
        this.option.requestUrl = "/api/v1/oms/selectCokeRailPlan/1?apiId=236&orderType=3&con=" + this.input;
    },
    // 查看物资详情
    detailclick(row) {
      // 记录重复点击次数
      if (this.oldRow === row) {
        this.oldRowCount += 1;
      }
      // 切换当前详情表
      this.$refs.table.toggleRowExpansion(row);
      // 打开前关闭上一个详情表
      if (this.oldRow != "") {
        if (this.oldRow != row) {
          if (this.oldRowCount % 2 === 1) {
            this.$refs.table.toggleRowExpansion(this.oldRow);
          } else {
            this.oldRowCount = 1;
          }
        } else {
          this.oldRow = null;
          return;
        }
      }
      // 重置上一个点击对象
      this.oldRow = row;
      this.tablelist.requestUrl="/api/v1/oms/selectInfoByDayPlanId/"+ row.dayPlanId +"?apiId=238&orderType=3" ;
      console.log(this.tablelist.requestUrl);
    },
  },
};
</script>
<style lang='scss' scoped>
.homeworkPath {
  .top {
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
}
</style>