<template>
  <!-- 销售化产焦炭派车页面 -->
  <div class="salePlan">
    <div class="top">
      <span class="text">订单时间：</span>
      <el-date-picker
        v-model="startTime"
        type="datetime"
        placeholder="选择日期"
        style="width:200px"
      >
      </el-date-picker>
      <span class="text">至</span>
      <el-date-picker
        v-model="endTime"
        type="datetime"
        placeholder="选择日期"
        style="width:200px"
      >
      </el-date-picker>
      <el-input
        placeholder="请输入内容"
        v-model="input"
        style="width:250px"
        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>
    <div class="table">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <!-- 已审批 -->
        <el-tab-pane label="已审批" name="four">
          <dilTable v-bind.sync="option4" ref="table" :pageSize="200">
            <el-table-column fixed="right" label="操作" width="180">
              <template slot-scope="scope">
                <el-button
                  @click="sendClick(scope.row.saleOrderId)"
                  type="text"
                  size="small"
                  >派车</el-button
                >
                <el-button
                  @click="addClick(scope.row.saleOrderId)"
                  type="text"
                  size="small"
                  >排车</el-button
                >
                <el-button
                  @click="checkSaleOrderDetails(scope.row.saleOrderId)"
                  type="text"
                  size="small"
                  >运单详情</el-button
                >
              </template>
            </el-table-column>
          </dilTable>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>
<script>
import { sjTime } from "@/utils/sharedJsFile";
export default {
  name: "saleOrder",
  data() {
    return {
      endTime: null,
      startTime: null,
      startDate: new Date().getTime() - 3600 * 1000 * 24 * 85,
      endDate: new Date(),
      activeName: "four",
      input: "",
      option4: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/ams/getSaleCokeOrder?apiId=475&shipperId=2"
        // &startDate="+sjTime(new Date().getTime() - 3600 * 1000 * 24 * 85)+"&endDate="+sjTime(new Date()),
      }
    };
  },
  methods: {
    checkSaleOrderDetails(saleOrderId) {
      console.log(saleOrderId);
      this.$router.push("saleOrderOODetails/" + saleOrderId);
    },
    refresh() {
      this.$router.go(0);
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    onclick() {
      let startTime = null;
      let endTime = null;
      if (this.startTime && this.endTime) {
        startTime = sjTime(this.startTime);
        endTime = sjTime(this.endTime);
      }
      this.option4.requestUrl =
        "/api/v1/ams/getSaleCokeOrder?apiId=475&shipperId=2&con=" +
        this.input +
        "&startTime=" +
        startTime +
        "&endTime=" +
        endTime +
        "&i=" +
        new Date();
    },
    click(saleOrderId) {
      this.$router.push("/editSaleOrder/" + saleOrderId);
    },
    addClick(saleOrderId) {
      this.$router.push("/addSaleOrderArrange/" + saleOrderId);
    },
    sendClick(saleOrderId) {
      this.$router.push("/addSaleOrderSend/" + saleOrderId);
    },
    //删除
    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 {
    margin-left: 20px;
    margin-top: 20px;
  }
  .table {
    margin-left: 20px;
    margin-top: 20px;
  }
}
</style>
