<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">
            <label class="font_normal_body">设备类型</label>
            <v-select id="f_device_type"
                      class="select_list select"
                      style="width: 60%;"
                      v-model='model.f_device_type'
                      :value.sync="model.f_device_type"
                      :options='$parent.$parent.f_devices'
                      condition="t_paper_devices.f_device_type = '{}'"
                      :value-single="true"
                      close-on-select
                      clear-button> </v-select>
          </div>
          <div class="form-group">
            <button class="button_spacing button_search" @click="search()">查询</button>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid >
        <template partial='head'>
          <tr>
            <th>设备类型</th>
            <th>检查项信息名</th>
            <th>检查项信息值</th>
            <th>是否已处理</th>
            <th>维修人</th>
          </tr>
        </template>
        <template partial='body'>
          <td v-if="row.type !== 'picture'">{{row.f_device_type}}</td>
          <td v-if="row.type !== 'picture'">{{row.f_item_name}}</td>
          <td v-if="row.f_is_defect === 'true' && row.type !== 'picture'" style="color: red;font-weight: bold">{{row.f_item_value}}</td>
          <td v-if="row.f_is_defect !== 'true' && row.type !== 'picture'">{{row.f_item_value}}</td>
          <td >{{row.f_is_repaired}}</td>
          <td >{{row.repairman}}</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',
      })
      model.f_paper_id = this.row.id
      return {
        model: model,
        f_devices: this.devices(),
        rowdata: this.row
      }
    },
    methods: {
      devices(){
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('安检项')]
      },
    },
    ready () {
      //tag
      this.rowdata = this.row
      this.$refs.paged.$refs.criteria.model.f_device_type = this.$parent.$parent.$refs.checksearch.model.model.f_device_type[0]
      this.$children[0].$children[0].search()
    },
    watch: {
      '$parent.$parent.rowData' (val) {
        this.rowdata = val
        this.model.f_paper_id = val.id
        this.$refs.paged.$refs.criteria.model.f_device_type = this.$parent.$parent.$refs.checksearch.model.model.f_device_type[0]
          this.$refs.paged.$refs.criteria.search()
        //tag
      }
    },

  }
</script>
