<template>
  <!-- 上报运单 -->
  <div class="homeworkPath">
    <div class="top">
      <span class="top_title">采购订单号 </span>
      <el-autocomplete
        popper-class="my-autocomplete"
        v-model="state"
        :fetch-suggestions="querySearch"
        placeholder="请输入内容"
        @select="handleSelect"
      >
        <i class="el-icon-edit el-input__icon" slot="suffix"> </i>
        <template slot-scope="{ item }">
          <div class="name">{{ item.value }}</div>
          <span class="addr">{{ item.address }}</span>
        </template> 
      </el-autocomplete>

      <el-button type="primary" class="btn" @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <el-button type="primary" @click="btnclick">
        <i class="el-icon-plus"></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>
export default {
  name: "wagonPlease",
  data() {
    return {
      status: "",
      state: "",
      option: {       
        // 表格请求数据的地址
        requestUrl: "/api/v1/tms/getAllTruckOrder?apiId=86&status=3",
      },
    };
  },
  mounted() {
     // debugger
    this.restaurants = this.loadAll();
  },
  methods: {
    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      cb(results);
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (
          restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        );
      };
    },
    loadAll() {
      return [
        { value: "三全鲜食（北新泾店）", address: "长宁区新渔路144号" },
        {
          value: "Hot honey 首尔炸鸡（仙霞路）",
          address: "上海市长宁区淞虹路661号",
        },
        {
          value: "新旺角茶餐厅",
          address: "上海市普陀区真北路988号创邑金沙谷6号楼113",
        },
      ];
    },
    handleSelect(item) {
      console.log(item);
    },
    onclick() {
      console.log(1);
    },
    btnclick() {
      this.$router.push("/addApproveWagonPlease/");
    },
    updateClick(resultId) {
      this.$router.push("/editApproveWagonPlease/" + resultId);
    },
    
  },
};
</script>
<style lang='scss' scoped>
.homeworkPath {
  .top {
    padding: 1.25rem 1.875rem;
  }
}
</style>