<template>
  <div>
    <criteria-paged :model="model" v-ref:paged :pager="false">
      <criteria partial='criteria' @condition-changed='search' v-ref:criteria>
        <div novalidate class="form-inline auto" partial style="text-align: center">
          <div class="form-group">
            <v-select id="f_device_type"
                      placeholder='设备类型'
                      v-model='$parent.$parent.model.f_device_type'
                      :value.sync="$parent.$parent.model.f_device_type"
                      :options='$parent.$parent.f_devices'
                      condition=""
                      close-on-select
                      clear-button> </v-select>
          </div>
          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()">查询</button>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th><nobr>设备类型</nobr></th>
            <th><nobr>检查项信息名</nobr></th>
            <th><nobr>检查项信息值</nobr></th>
          </tr>
        </template>
        <template partial='body'>
          <td v-if="row.type !== 'picture'"><nobr>{{row.f_device_type}}</nobr></td>
          <td v-if="row.type !== 'picture'"><nobr>{{row.f_item_name}}</nobr></td>
          <td v-if="row.f_is_defect === 'true' && row.type !== 'picture'" style="color: red;font-weight: bold"><nobr>{{row.f_item_value}}</nobr></td>
          <td v-if="row.f_is_defect !== 'true' && row.type !== 'picture'"><nobr>{{row.f_item_value}}</nobr></td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  import Vue from 'vue'
  import co from 'co'
  export default {
    title: '安检详细信息',
    name: 'CheckPaperItems',
    props: ['row'],
    data () {
      let model = new PagedList('rs/sql/CheckPaperSearchItem', 100, {
        f_paper_id: 'this.f_paper_id',
        f_device_type: 'this.f_device_type[0]'
      })
      model.f_paper_id = this.row.id
      model.f_device_type = this.$parent.$parent.$children[0].f_device_type
      return {
        model: model,
        f_device_type:this.$parent.$parent.$children[0].f_device_type,
        f_devices: [{label: '全部', value: ''}, ... this.$appdata.getParam('安检项')],
        rowdata: this.row
      }
    },
    ready () {
      //tag
      this.rowdata = this.row
      if(!this.f_device_type)
        this.f_device_type = ''
      this.$children[0].$children[0].search()
    },
    watch: {
      'row' (val) {
        this.rowdata = val
        this.model.f_paper_id = val.id
        this.$children[0].$children[0].search()
        //tag
      }
    },

  }
</script>
