// 倒垛
<template>
  <div class="steel_inbound">
    <div class="sache">
      <el-input
        placeholder="请输入内容"
        v-model="inputText"
        clearable>
      </el-input>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
       <el-button type="primary" class="btn" @click="Addclick">
         <i class="el-icon-circle-plus-outline"></i>新增
      </el-button>
    </div>
    <div class="table">
<!--       <dilTable v-bind.sync="options"> 
      </dilTable> -->
    </div>
      <template>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="待下发" name="first">
            <dilTable v-bind.sync="first">
              <el-table-column label="操作" fixed="right" width="120">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="Issued(scope.row.resultId)">
                    下发
                  </el-button>
                    <el-button type="text" size="mini" @click="deleteclick(scope.row.resultId)">
                     删除
                   </el-button>
                   <el-button type="text" size="mini"   @click="editclick(scope.row.resultId)">
                     修改
                   </el-button>
                </template>
              </el-table-column>
            </dilTable>
          </el-tab-pane>
          <el-tab-pane label="已下发" name="second">
            <dilTable v-bind.sync="second">    
            </dilTable>
          </el-tab-pane>     
        </el-tabs>
      </template>
    </div>
</template>
<script>
// import { first, values } from "xe-utils";
export default {
  data() {
    return {
      state: "",
      inputText:"",
      first: {
        // 未分配地址
        // 请求未下发的数据
        requestUrl:
          "/api/v1/wms/selectRestackList?apiId=438&DistrubtionStatus=0",
      },
      second: {
        // second请求数据的地址
        // 请求已下发的数据
        requestUrl:
          "/api/v1/wms/selectRestackList2?apiId=440&DistrubtionStatus=1",
      },
      //默认显示待下发的标签页
      activeName: "first",
    };
  },
  methods: {
    onclick() {
       if(this.activeName == "first"){
        this.option1.requestUrl = "/api/v1/wms/selectRestackList?apiId=119&DistrubtionStatus=0&con=" + this.inputText;
      }else{
        this.option2.requestUrl = "/api/v1/wms/selectRestackList?apiId=119&DistrubtionStatus=0&con=" + this.inputText;
      }
     
    },
    Addclick() {
      this.$router.push("/bar1_steel_restackAdd");
    },
    //删除方法
    deleteclick(scope) {
      let resultId = scope;
      this.$confirm("是否删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.axios
            .post(
              "/api/v1/wms/deleteByResultId/" + resultId
            )
            .then(() => {
              this.$router.go(0);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消删除!",
          });
        });
    },
    //  handleClick(tab, event) {
    //     console.log(tab, event);

    //   },
    //根据id进行修改
    editclick(resultId) {
      this.$router.push("/bar1_editSteel_restack/" + resultId);
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    Issued(resultId) {
      this.$confirm("是否下发", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "下发成功!",
          });
          // console.log(this.arr[0].text_prop);
          this.axios
            .post(
              "/api/v1/wms/dispatchDistrubtionStatus/" +
                resultId
            )
            .then(() => {
              this.$router.go(0);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消下发!",
          });
        });
    },
  },
};
</script>
<style lang="scss"scode>

</style>