<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"> </dilTable>
  </div>
</template>

<script>
import { sjTime } from "@/utils/sharedJsFile";
export default {
  name: "homeworkPath",
  data() {
    return {
      startTime:null,
      endTime:null,
      restaurants: [],
      input: "",
      option: {
        // 表格请求数据的地址
        requestUrl: "/api/v1/tms/getAllJiPiResult?apiId=146&orderType=5",
      },
    };
  },

  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/getAllJiPiResult?apiId=146&orderType=5&con=" +
            this.input +
            "&startTime=" +
            startTime +
            "&endTime=" +
            endTime +
            "&i=" +
            new Date();
        }
      } else {
        this.option.requestUrl =
          "/api/v1/tms/getAllJiPiResult?apiId=146&orderType=5&con=" +
          this.input +
          "&i=" +
          new Date();
      }
    },
  },
};
</script>
<style lang='scss'>
.homeworkPath {
  .top {
    padding: 40px;
    .input {
      width: 250px;
      margin-right: 10px;
    }
  }
}
</style>