<template>
  <section>
    <nav-bar :inner="true" title="保养结果填报"></nav-bar>
    <section class="content mgt186">
      <div class="filter-wraper">
        <search-box
        label="设备"
        v-model="val1"
        @handleChange="handleChange1"
        ></search-box>
        <div class="bottom-filter-tip">
          <div class="filter-label txtjustify">保养单</div>
          <div class="fxcol mgl20">
            <input type="text" class="filter-input filter-scan-input" placeholder="" v-model="val2">
          </div>
        </div>
      </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">
              <td>
                <for-dropdown-menu
                :value="e.is"
                :id="e.worktask_id"
                @getValue="getValue">
                </for-dropdown-menu>
              </td>
            </tr>
          </table>
        </div>
        <div class="slide">
          <table class="layout-t">
            <tr>
              <th>保养项目名称</th>
              <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>
              <td>{{e.status_name}}</td>
            </tr>
          </table>
        </div>
      </div>
    </section>
    <section class="submit-bar">
      <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'
import ForDropdownMenu from '@components/ForDropdownMenu.vue'
export default {
  name: 'MaintainResults',
  components: {
    NavBar,
    SearchBox,
    ForDropdownMenu
  },
  data () {
    return {
      val1: '',
      val2: '',
      dataList: [{worktask_id: '1', is: '2', pcsn: '00000'}],
      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 : {}
    },
    getValue (p) {
      this.dataList.map(el => {
        if (el.worktask_id === p[0]) {
          el.is = p[1]
        }
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
.mgb140
  margin-bottom 1.4rem
</style>
