<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="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-tabs>
  </div>
</template>
<script>
export default {
  name: "saleOrder",
  data() {
    return {
      activeName: "first",
      input: "",
      option: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getSaleOrderInfo?apiId=98",
      },
      option2: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getSaleOrderReported?apiId=98",
      },
      option3: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getAmsSaleOrderApproved?apiId=105",
      },
      option4: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getSaleOrderListBySaleCompany?apiId=105",
      },
      
    };
  },
  methods: {

    handleClick(tab, event) {
      console.log(tab, event);
    },
    onclick() {
      console.log(this.input);
    },
    seeclick(saleOrderId) {
      this.$router.push("/saleOrderDetail/" + saleOrderId);
    },
    lookclick(saleOrderId) {
      this.$router.push("/saleOrderDetailApproved/" + saleOrderId);
    },
    passclick(saleOrderId) {
      this.$router.push("/saleOrderUpdateLog/" + saleOrderId);
    },
    btnclick() {
      this.$router.push("/addSaleOrder");
    },
    click(saleOrderId) {
      this.$router.push("/editSaleOrder/" + 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 1.875rem;
  }
}
</style>