<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="refresh">
        <i class="el-icon-refresh"></i>刷新
      </el-button>
    </div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <!-- 已审批 -->
       <!-- <el-tab-pane name="four"> -->
        <dilTable v-bind.sync="option4" ref="table">
          <el-table-column fixed="right" label="操作" width="120">
            <template slot-scope="scope">
              <el-button
                @click="sendClick(scope.row.saleOrderId)"
                type="text"
                size="small"
                >派车</el-button
              >
              <el-button
                @click="closeOrder(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: "four",
      input: "",
      option4: {
        // 表格请求数据的地址
        requestUrl:
          "/api/v1/ams/getCokeSaleOrderList?apiId=409",
      },
      
      //记录旧的row对象 (销售公司已审批/财务已审批)
      oldRow: "",
      //记录上一个展开的点击次数，单数为展开状态，复数为闭合状态 (销售公司已审批/财务已审批)
      oldRowCount: 1,
      tableHead: [
        {
          prop: "materialName",
          label: "物资名称",
          width: 150,
        },
        {
          prop: "specificationModel",
          label: "规格型号",
          width: 150,
        },
        {
          prop: "materialNumber",
          label: "物资件数",
          width: 100,
        },
        {
          prop: "materialWeight",
          label: "物资重量",
          width: 100,
        },
      ],
      //(销售公司已审批\财务已审批)
      tableData: [],
    };
  },
//   created(){
//       验证订单是否关闭
      
//       this.axios.post("/api/v1/ams/getCokeSaleOrderList?apiId=409")
//       .then((res)=>{
//           res.data.data.list.
//           console.log("res",res)
//           console.log("res111",res.data.data.list[0])
//       })
//   },
  methods: {
    refresh(){
      this.$router.go(0);
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    onclick() {
        this.option4.requestUrl = "/api/v1/ams/getCokeSaleOrderList?apiId=409&con="+this.input;      
    },
    sendClick(saleOrderId){
      this.$router.push("/addSaleCokeSend/" + saleOrderId);
    },
    closeOrder(saleOrderId) {
      this.$confirm("是否关闭", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "关闭成功!",
          });
          this.axios
            .post(
              "/api/v1/ams/closeSaleOrder?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>