<template>
  <section>
    <nav-bar title="备件出库"></nav-bar>
    <section class="content mgt186">
      <div class="filter-wraper">
        <search-box
        label="备品备件"
        v-model="val1"
        @handleChange="handleChange1"
        ></search-box>
      </div>
      <div class="grid-wraper">
        <div class="left_fixed">
          <table class="layout-t left_layout_t">
            <tr>
            <th>出库单号</th>
            </tr>
            <tr v-for="e in dataList" :key="e.worktask_id" @click="toCheck(e)" :class="{'checked': e.worktask_id === pkId}">
              <td>{{e.device_code}}</td>
            </tr>
          </table>
        </div>
        <div class="slide">
          <table class="layout-t">
            <tr>
              <th>物料编码</th>
              <th>物料名称</th>
              <th>数量</th>
            </tr>
            <tr v-for="e in dataList" :key="e.worktask_id" @click="toCheck(e)" :class="{'checked': e.worktask_id === pkId}">
              <td>{{e.workorder_code}}</td>
              <td>{{e.material_code}}</td>
              <td>{{e.pcsn}}</td>
            </tr>
          </table>
        </div>
      </div>
    </section>
    <section class="content mgt186">
      <div class="grid-wraper">
        <div class="left_fixed">
          <table class="layout-t left_layout_t">
            <tr>
            <th>备件唯一码</th>
            </tr>
            <tr v-for="e in dataList" :key="e.worktask_id" @click="toCheck(e)" :class="{'checked': e.worktask_id === pkId}">
              <td>{{e.device_code}}</td>
            </tr>
          </table>
        </div>
        <div class="slide">
          <table class="layout-t">
            <tr>
              <th>物料编码</th>
              <th>物料名称</th>
              <th>数量</th>
            </tr>
            <tr v-for="e in dataList" :key="e.worktask_id" @click="toCheck(e)" :class="{'checked': e.worktask_id === pkId}">
              <td>{{e.workorder_code}}</td>
              <td>{{e.material_code}}</td>
              <td>{{e.pcsn}}</td>
            </tr>
          </table>
        </div>
      </div>
    </section>
    <section class="submit-bar">
      <button class="btn submit-button">查询</button>
      <button class="btn submit-button">删除</button>
      <button class="btn submit-button">确认</button>
    </section>
  </section>
</template>

<script>
import NavBar from '@components/NavBar.vue'
import SearchBox from '@components/SearchBox.vue'
export default {
  name: 'SparePartOutstore',
  components: {
    NavBar,
    SearchBox
  },
  data () {
    return {
      val1: '',
      dataList: [],
      pkId: '',
      pkObj: {}
    }
  },
  methods: {
    handleChange1 (e, type) {
      if (type) {
        console.log(e)
      }
    },
    toCheck (e) {
      this.pkId = this.pkId === e.worktask_id ? '' : e.worktask_id
      this.pkObj = this.pkId === e.worktask_id ? e : {}
    }
  }
}
</script>
