<template>
  <!-- 分派计划 -->
  <div class="homeworkPath">
    <div class="top">
      <el-input
        class="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>
  
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <!--接收 -->
      <el-tab-pane label="待接收" name="zero">
        <dilTable v-bind.sync="zero" ref="table">
          <el-table-column fixed="right" label="操作" width="80">
            <template slot-scope="scope">
              <el-button
                @click="receiveClick(scope.row.planId)"
                type="text"
                size="small"
              >
                接收
              </el-button>
            </template>
          </el-table-column>
        </dilTable>
      </el-tab-pane>
      <!-- 待分派 -->
      <el-tab-pane label="待分解" name="first">
        <dilTable v-bind.sync="option1" ref="table">
          <el-table-column fixed="right" label="操作" width="80">
            <template slot-scope="scope">
              <el-button
                @click="seeClick(scope.row.planId)"
                type="text"
                size="small"
              >
                查看详情
              </el-button>
            </template>
          </el-table-column>
        </dilTable>
      </el-tab-pane>
      <!-- 已分派 -->
      <el-tab-pane label="已分解" name="second">
        <dilTable v-bind.sync="option2"> </dilTable>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
export default {
  name: "wagonPlease",
  data() {
    return {
      status: "",
      input: "",
      activeName: "zero",
      zero: {
        requestUrl: "/api/v1/ams/getAllPurPlan?apiId=79&status=1",
      },
      option1: {
        //待分解
        requestUrl:
          "/api/v1/ams/getDecomposedPlan?apiId=82&status=2&planStatus=0",
      },
      option2: {
        //已分解
        requestUrl:
          "/api/v1/ams/getDecomposedPlan?apiId=82&status=2&planStatus=1",
      },
    };
  },
  methods: {
    // 接收
    receiveClick(planId) {
      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/ams/receptionPurPlan/" + planId).then(() => {
            this.zero.requestUrl =
              "/api/v1/ams/getAllPurPlan?apiId=79&status=1&q=1";
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消接收!",
          });
        });
    },
    onclick() {
      if (this.activeName == "zero") {
        this.zero.requestUrl =
          "/api/v1/ams/getAllPurPlan?apiId=79&status=1&con=" + this.input;
      } else if (this.activeName == "first") {
        this.option1.requestUrl =
          "/api/v1/ams/getDecomposedPlan?apiId=82&status=2&con=" + this.input;
      } else {
        this.option2.requestUrl =
          "/api/v1/ams/getDecomposedPlan?apiId=82&status=2&planStatus=1&con=" +
          this.input;
      }
    },
    seeClick(planId) {
      console.log(planId);
      this.$router.push("/breakdownPlanAdd/" + planId);
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
  },
};
</script>
<style lang='scss'>
.homeworkPath {
  .top {
    padding: 1.25rem 0.375rem;
    .el-input el-input--suffix {
      .el-input__inner {
        width: 20%;
        margin-right: 1.25rem;
      }
    }
  }
}
</style>