<template>
  <!-- 辅料质检作业 -->
  <div class="homeworkPath">
    <div class="top">
      <el-input
        placeholder="请输入内容"
        class="input"
        v-model="input"
        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>
    <dilTable v-bind.sync="option">
      <el-table-column fixed="right" label="操作" width="50">
        <template slot-scope="scope">
          <el-button
            @click="updateClick(scope.row.resultId)"
            type="text"
            size="small"
          >
            修改
          </el-button>
        </template>
      </el-table-column>
    </dilTable>
  </div>
</template>



<script>
import { sjTime } from "@/utils/sharedJsFile";
export default {
  name: "wagonPlease",
  data() {
    return {
      startTime: null,
      endTime: null,
      status: "",
      input: "",
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/tms/getQualityResult?apiId=150&orderType=5&i="+new Date(),
      },
    };
  },

  methods: {
    onclick() {
      let startTime = null;
      let endTime = null;
      if (this.startTime) {
        startTime = sjTime(this.startTime);
        // console.log("startTime", startTime);
      }
      if (this.endTime) {
        endTime = sjTime(this.endTime);
        // console.log("endTime", endTime);
      }
      if (startTime && endTime) {
        if (startTime < endTime) {
          this.option.requestUrl =
            "/api/v1/tms/getQualityResult?apiId=150&orderType=5&con=" +
            this.input +
            "&startTime=" +
            startTime +
            "&endTime=" +
            endTime +
            "&i=" +
            new Date();
        }
      } else {
        this.option.requestUrl =
          "/api/v1/tms/getQualityResult?apiId=150&orderType=5&con=" +
          this.input +
          "&startTime=" +
          startTime +
          "&endTime=" +
          endTime +
          "&i=" +
          new Date();
      }
    },
    updateClick(resultId) {
      this.$router.push("/truckQualityRanLaoResultEdit/" + resultId);
    },
  },
};
</script>
<style lang='scss'>
.homeworkPath {
  .top {
    padding: 40px;
    .input {
      width: 250px;
      margin-right: 10px;
    }
  }
}
</style>