<template>
  <!-- 下游港口港存库实时库存页面 -->
  <div class="homeworkPath">
    <div class="top">
      <el-autocomplete
        popper-class="my-autocomplete"
        v-model="state"
        :fetch-suggestions="querySearch"
        placeholder="请输入内容"
        @select="handleSelect"
      >
      </el-autocomplete>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
    </div>
    <mergeRowTable v-bind.sync="option">
      <el-table-column fixed="right" label="操作" width="60">
          <template slot-scope="scope">
              <el-button @click="detailclick3(scope.row)" type="text" size="small">
                手动清场
              </el-button>
          </template>
    </el-table-column>
    </mergeRowTable>
  </div>
</template>

<script>
export default {
  name: "homeworkPath",
  data() {
    return {
      restaurants: [],
      state: "",
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/wmsh/getUnloadPortStockList?apiId=497",
        comparison:"portName",
        columnIndexs:[0,1]
      },
    };
  },
  mounted() {
  },
  methods: {
    handleSelect(item) {
      console.log(item);
    },
    onclick() {
      this.option.requestUrl="/api/v1/wmsh/getUnloadPortStockList?apiId=497&i="+new Date();
    },
    btnclick(pathId) {
      this.$router.push("/path/addHomeworkPath/" + pathId);
    },
     detailclick3(row){
      console.log("row",row);
       this.$confirm('确认清场?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
         this.axios.post("/api/v1/wmsh/clearWmshGridMaterial", row).then(res => {
          console.log("res", res);
          if(res.data.succeed){
            this.$message.success("清场成功！");
            this.onclick();
          }else{
            this.$message.error("清场失败！");
          }
        });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消操作'
          });          
        });
    },
  },
};
</script>
<style lang='scss' scoped>
.homeworkPath {
  .top {
    padding: 1.25rem 1.875rem;
  }
}
</style>