// 分解计划
<template>
  <div class="steel_inbound">
    <div class="sache">
      <el-input placeholder="请输入内容" v-model="inputText" clearable>
      </el-input>
      <el-button type="primary" class="btn">
        <i class="el-icon-search"></i>查询
      </el-button>
    </div>
    <template>
      <div>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="未接收" name="first">
            <dilTable v-bind.sync="first">
              <el-table-column fixed="right" label="操作" width="50">
                <template slot-scope="scope">
                  <el-button type="text" size="mini" @click="receiver(scope)">
                    接收
                  </el-button>
                </template>
              </el-table-column>
            </dilTable>
          </el-tab-pane>
          <el-tab-pane label="已接收" name="second">
            <dilTable v-bind.sync="second">
              <el-table-column fixed="right" label="操作" width="50">
                <template slot-scope="scope">
                  <el-button
                    type="text"
                    size="mini"
                    @click="desponsePlan(scope)"
                  >
                    分解
                  </el-button>
                </template>
              </el-table-column>
            </dilTable>
          </el-tab-pane>
          <el-tab-pane label="已分解" name="third">
            <dilTable v-bind.sync="third">
              <el-button
                type="text"
                size="mini"
                @click="getdesponsePlan(scope)"
              >
                查看
              </el-button>
            </dilTable>
          </el-tab-pane>
        </el-tabs>
      </div>
    </template>
  </div>
</template>
<script>
import { getCookie } from "@/utils/util.js";
export default {
  data() {
    return {
      inputText: "",
      carrierId:40,
      first: {
        // first请求数据的地址
        requestUrl:
          "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=1&carrierId=" + ''
      },
      second: {
        // second请求数据的地址
        requestUrl:
          "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=2&carrierId=" + ''
      },
      third: {
        // second请求数据的地址
        requestUrl:
          "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=3&carrierId=" + '' 
      },
      activeName: "first",
    };
  },
  created(){
      this.carrierId = getCookie('userId')
      this.first.requestUrl = "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=1"
      this.second.requestUrl = "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=2"
      this.third.requestUrl = "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=3"
      console.log(this.carrierId)
  },
  methods: {
    getRequestUrl(){
      this.first.requestUrl = "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=1&i=" + new Date()
      this.second.requestUrl = "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=2&i="  + new Date()
      this.third.requestUrl = "/api/v1/ams/getTruckPlanList?apiId=258&planStatus=3&i=" + new Date()
    },
    receiver(scope) {
      this.$confirm("是否接收", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.axios
            .post("/api/v1/ams/receiveInwardPlan/" + scope.row.planId)
            .then((res) => {
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "接收成功!",
                });
                this.getRequestUrl()
              } else {
                this.$message({
                  message: "接收失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "接收操作已取消!",
          });
        });
    },
    selectionChange(selection) {
      this.second.mapList = selection;
    },
    desponsePlan(scope) {
      this.$router.push("/decomposePlan/" + scope.row.planId);
    },
    deletePlan(scope) {
      this.$confirm("是否删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.axios
            .post(
              "/api/v1/bms/deleteTrainSettlement/" + scope.row.requirementId
            )
            .then((res) => {
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "删除成功!",
                });
                this.getRequestUrl()
              } else {
                this.$message({
                  message: "删除失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "删除操作已取消!",
          });
        });
    },
    Issue() {
      console.log(this.first.mapList);
      this.$confirm("是否下发", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.axios
            .post(
              "/api/v1/ams/addFixedAmsDispatchSaleOrder",
              this.first.mapList
            )
            .then((res) => {
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "下发成功!",
                });
                this.getRequestUrl()
              } else {
                this.$message({
                  message: "下发失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消下发!",
          });
        });
    },
  },
};
</script>
<style lang="scss">
.steel_inbound{
  .sache{
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
  }
</style>
