//采购化工材料运输派单
<template>
  <div >
    <div style="margin:10px">
           <el-select v-model="condition1" placeholder="请选择筛选条件"  style="width:150px" clearable>
          <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
          </el-option>
      </el-select>
      <el-input
          placeholder="请输入内容"
          v-model="input1"
          style="width:200px"
          clearable
      >
      </el-input>
      <el-select v-model="condition2" placeholder="请选择筛选条件" style="width:150px" clearable>
          <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
          </el-option>
      </el-select>
      <el-input
          placeholder="请输入内容"
          v-model="input2"
          style="width:200px"
          clearable
      >
      </el-input>
      <span class="text">下发时间：</span>
      <el-date-picker
        v-model="startTime"
        type="datetime"
        placeholder="选择日期"
      >
      </el-date-picker>
      <span class="text">至</span>
      <el-date-picker v-model="endTime" type="datetime" placeholder="选择日期">
      </el-date-picker>
      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
    </div>
    <el-tabs v-model="activeName">
      <!-- 未下发 -->
      <el-tab-pane label="已接收" name="first">
        <dilTable v-bind.sync="option1" ref="table"> </dilTable>
      </el-tab-pane>
      <!-- 已下发 -->
      <el-tab-pane label="已拒绝" name="second">
        <dilTable v-bind.sync="option2"> </dilTable>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { getCookie } from "@/utils/util.js";
import { sjTime } from "@/utils/sharedJsFile";
export default {
  name: "inplantTMS",
  data() {
    return {
      condition1:null,
      condition2:null,
      input1:null,
      input2:null,
      options:[
          {
          label:"车牌号",
          value:"capacityNumber"
          },
          {
          label:"物资名称",
          value:"materialName"
          },
          {
          label:"发货单位",
          value:"supplierName"
          },
          {
          label:"采购订单",
          value:"purchaseOrderNo"
          }
          
      ],
      input: "",
      Time: "",
      startTime: null,
      endTime: null,
      activeName: "first",
      option1: {
        // 表格请求数据的地址
        requestUrl: "",
      },
      option2: {
        // 表格请求数据的地址
        requestUrl: "",
      },
    };
  },
  created() {
    //判断是否是承运商
    if (getCookie("orgCode") == "chengyunshang") {
      this.option1.requestUrl =
        "/api/v1/oms/getTransportDispatch?apiId=148&fuelOrder=2&orderStatus=111&carrierSSOId=" +
        getCookie("userId");
      this.option2.requestUrl =
        "/api/v1/oms/getTransportDispatch?apiId=241&fuelOrder=2&orderStatus=6&carrierSSOId=" +
        getCookie("userId");
    } else {
      this.option1.requestUrl =
        "/api/v1/oms/getTransportDispatch?apiId=148&fuelOrder=2&orderStatus=111&carrierSSOId=" +
        null;
      this.option2.requestUrl =
        "/api/v1/oms/getTransportDispatch?apiId=241&fuelOrder=2&orderStatus=6&carrierSSOId=" +
        null;
    }
  },
  methods: {
    onclick() {
       let requestQuery={}
      if(this.condition1 == this.condition2){
            requestQuery[this.condition1]=[this.input1,this.input2]
        }else{
            requestQuery[this.condition1]=[this.input1+'']
            requestQuery[this.condition2]=[this.input2+'']
        }
      let startTime = null;
      let endTime = null;
      if (this.startTime) {
        startTime = sjTime(this.startTime);
      }
      if (this.endTime) {
        endTime = sjTime(this.endTime);
      }
      if (startTime && endTime) {
        if (startTime < endTime) {
          if (this.activeName == "first") {
            this.option1.requestUrl =
              "/api/v1/oms/getTransportDispatch?apiId=241&fuelOrder=2&orderStatus=111&startTime=" +
              startTime +
              "&endTime=" +
              endTime +
              "&i=" +
              new Date();
            this.option1.requestQuery=requestQuery;
          } else {
            this.option2.requestUrl =
              "/api/v1/oms/getTransportDispatch?apiId=241&fuelOrder=2&orderStatus=6&startTime=" +
              startTime +
              "&endTime=" +
              endTime +
              "&i=" +
              new Date();
            this.option2.requestQuery=requestQuery;
          }
        }
      } else {
        if (this.activeName == "first") {
          this.option1.requestUrl =
            "/api/v1/oms/getTransportDispatch?apiId=241&fuelOrder=2&orderStatus=111&i=" +
            new Date();
            this.option1.requestQuery=requestQuery;
        } else {
          this.option2.requestUrl =
            "/api/v1/oms/getTransportDispatch?apiId=241&fuelOrder=2&orderStatus=6&i=" +
            new Date();
            this.option2.requestQuery=requestQuery;
        }
      }
      this.$forceUpdate();
    },
  },
};
</script>
<style lang='scss'>
.homeworkPath {
  .top {
    padding: 40px;
    .input {
      width: 250px;
      margin-right: 10px;
    }
  }
}
</style>