<template>
  <!-- 销售订单页面 -->
  <div class="salePlan">
    <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>
      <el-button type="primary" @click="btnclick(0)">
        <i class="el-icon-plus"></i>钢材订单新增
      </el-button>
    </div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="未上报" name="first">
        <dilTable v-bind.sync="option">
          <el-table-column fixed="right" label="操作" align="center" width="150">
            <template slot-scope="scope">
              <el-button
                @click="uploadclick(scope.row.saleOrderId)"
                type="text"
                size="small"
                >上传</el-button
              >
              <el-button
                @click="click(scope.row.saleOrderId)"
                type="text"
                size="small"
                >修改</el-button
              >
              <el-button
                type="text"
                size="small"
                @click="deleteclick(scope.row.saleOrderId)"
                >删除</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-tab-pane label="财务已审批" name="third">
        <dilTable v-bind.sync="option3">
          <el-table-column fixed="right" label="操作" width="200">
            <template slot-scope="scope">
              <el-button
                @click="lookclick(scope.row.saleOrderId)"
                type="text"
                size="small"
                >查看</el-button
              >
              <el-button
                @click="passclick(scope.row.saleOrderId)"
                type="text"
                size="small"
                >修改日志</el-button
              >
            </template>
          </el-table-column>
        </dilTable>
      </el-tab-pane>
      <!-- 销售公司已审批 -->
       <el-tab-pane label="销售公司已审批" name="four">
        <dilTable v-bind.sync="option4">
          <el-table-column fixed="right" label="操作" width="130">
            <template slot-scope="scope">
              <el-button
                @click="addClick(scope.row.saleOrderId)"
                type="text"
                size="small"
                >新增车序号</el-button
              >
              <el-button
                @click="detailedClick(scope.row.saleOrderId)"
                type="text"
                size="small"
                >物资详情</el-button
              >
            </template>
          </el-table-column>
        </dilTable>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
export default {
  name: "saleOrder",
  data() {
    return {
      activeName: "first",
      input: "",
      option: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getSaleOrderInfoes?apiId=408",
      },
      option2: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getSaleOrderReportedes?apiId=408",
      },
      option3: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getAmsSaleOrderApprovedes?apiId=409",
      },
      option4: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getSaleOrderListBySaleCompanyes?apiId=409",
      },
      
    };
  },
  methods: {

    handleClick(tab, event) {
      console.log(tab, event);
    },
    onclick() {
      console.log(this.input);
    },
    seeclick(saleOrderId) {
      this.$router.push("/saleOrderDetail/" + saleOrderId);
    },
    btnclick() {
      this.$router.push("/addSaleOrder");
    },
    click(saleOrderId) {
      this.$router.push("/editSaleOrder/" + saleOrderId);
    },
    addClick(saleOrderId){
      this.$router.push("/addSaleOrderArrange/" + saleOrderId);
    },
    detailedClick(saleOrderId){
      this.$router.push("saleOrderMaterial/" + saleOrderId);
    },
    // 上传
    uploadclick(saleOrderId) {
      this.$confirm("是否上传", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "上传成功!",
          });
          this.axios
            .post(
              "/api/v1/ams/uploadSaleOrder?saleOrderId=" +
                saleOrderId
            )
            .then(() => {
              this.$router.go(0);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消上传!",
          });
        });
    },
    //删除
    deleteclick(scope) {
      let saleOrderId = scope;
      this.$confirm("是否删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.axios
            .post(
              "/api/v1/ams/deleteAmsSaleOrderBySaleOrderId?saleOrderId=" +
                saleOrderId
            )
            .then(() => {
              this.$router.go(0);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消删除!",
          });
        });
    },
  },
};
</script>
<style lang='scss' scoped>
.salePlan {
  .top {
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
}
</style>