<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:criteria>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">所属区域</label>
            <input type="text" class="form-control" v-model="model.f_distinct"
                   style="height:34px;margin-top: 8px"    placeholder="所属区域" condition="f_distinct='{}'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">小区名称</label>
            <input type="text" class="form-control" v-model="model.f_residential_area"
                   style="height:34px;margin-top: 8px"    placeholder="小区名称" condition="f_residential_area = '{}'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">发现时间</label>
            <input type="text" class="form-control" v-model="model.f_offsite_time"
                   style="height:34px;margin-top: 8px"    placeholder="发现时间" condition="f_offsite_time = '%{}%'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">小&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区</label>
            <input type="text" class="form-control" v-model="model.f_residential_area"
                   style="height:34px;margin-top: 8px"    placeholder="小区" condition="f_residential_area like '%{}%'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</label>
            <input type="text" class="form-control" v-model="model.f_building"
                   style="height:34px;margin-top: 8px"    placeholder="楼号" condition="f_building = '{}'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;元</label>
            <input type="text" class="form-control" v-model="model.f_unit"
                   style="height:34px;margin-top: 8px"    placeholder="单元" condition="f_unit = '{}'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;层</label>
            <input type="text" class="form-control" v-model="model.f_floor"
                   style="height:34px;margin-top: 8px"    placeholder="楼层" condition="f_floor = '{}'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">门&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;牌</label>
            <input type="text" class="form-control" v-model="model.f_room"
                   style="height:34px;margin-top: 8px"    placeholder="门牌" condition="f_room = '{}'">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">安检计划</label>
            <input type="text" class="form-control" v-model="$parent.$parent.model.f_check_plan.f_plan_name" @click="$parent.$parent.showChooser"
                   style="height:34px;margin-top: 8px"   placeholder="安检计划" readonly="readonly">
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">开始时间</label>
            <datepicker
              :value.sync="model.f_check_start"
              placeholder='开始时间' style="margin-top: 8px"
              :disabled-days-of-week="[]"
              :format="'yyyy-MM-dd'"
              :show-rest-button="reset"
              v-model = "model.f_check_start"
              condition="f_offsite_time > ='{} 00:00:00'">
            </datepicker>
          </div>
          <div class="col-sm-4 form-group form-input-group" style="width: 20%">
            <label class="control-label">结束时间</label>
            <datepicker
              :value.sync="model.f_check_end"
              placeholder='结束时间' style="margin-top: 8px"
              :disabled-days-of-week="[]"
              :format="'yyyy-MM-dd'"
              :show-rest-button="reset"
              v-model = "model.f_check_end"
              condition="f_offsite_time <=  '{} 23:59:59'">
            </datepicker>
          </div>
          <div class="row">
            <div class="span" style="margin-top:8px;float:right">
              <button class="button_spacing button_search" @click="search()">查询</button>
            </div>
          </div>
          </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>所属区域</th>
            <th>小区名称</th>
            <th>发现时间</th>
            <th>楼房号</th>
            <th>联系电话</th>
            <th>卡号</th>
            <th>用气设备</th>
            <th>是否租住</th>
            <th>左右表</th>
            <th>故障类型</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_distinct}}</td>
          <td>{{row.f_residential_area}}</td>
          <td>{{row.f_offsite_time}}</td>
          <td>{{row.buildingNum}}</td>
          <td>{{row.f_user_phone}}</td>
          <td>{{row.f_card_id}}</td>
          <td>{{row.f_user_equipmen}}</td>
          <td>{{row.f_rent}}</td>
          <td>{{row.f_item_value}}</td>
          <td>{{row.defect}}</td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
import co from 'co'
import AppData from '../../stores/AppData'
import * as Util from '../Util'

export default {
  title: '问题表台账',
  data () {
    let model = new PagedList('rs/sql/ProblemTableBook', 20, {})
    return {
      model:model,
      fun:this.$login.f,
      residentialProperties: [
        {label: '物业小区', value: '物业小区'},
        {label: '企事业单位', value: '企事业单位'},
        {label: '安置小区', value: '安置小区'},
        {label: '自建房', value: '自建房'},
        {label: '公租房', value: '公租房'},
        {label: '廉租房', value: '廉租房'}
      ],
      distincts: [
        {label: '航天', value: '航天'},
        {label: '长安', value: '长安'},
        {label: '曲江', value: '曲江'},
        {label: '高新', value: '高新'},
        {label: '沣东', value: '沣东'},
        {label: '中心站', value: '中心站'},
        {label: '沣西', value: '沣西'},
        {label: '浐灞生态区', value: '浐灞生态区'}
      ],
      heating_style: [
        {label: '壁挂炉供暖', value: '壁挂炉供暖'},
        {label: '集中供暖', value: '集中供暖'},
        {label: '其他', value: '其他'},
        {label: '燃气取暖器供暖', value: '燃气取暖器供暖'}
      ],
      checkersid:[],
      checkersname:[],
      showModal: false,
      // f_approval_states: this.$appdata.getParam('安检单审核状态'),
      f_entry_status: [
        {label: '全部', value: ''},
        {label: '正常', value: '入户'},
        {label: '无人', value: '到访不遇'},
        {label: '拒检', value: '拒检'}
      ],
      f_checkplans: [
        {label: '全部', value: ''},
        {label: '集中安检单', value: '集中安检单'},
        {label: '无计划安检', value: '无计划安检'},
        {label: '点火通气单', value: '点火通气单'},
        {label: '跟进单', value: '跟进单'},
        {label: '预约安检单', value: '预约安检单'},
        {label: '预约开户单', value: '预约开户单'}
      ],
      keyuser: [
        {label: '全部', value: ''},
        {label: '是', value: `f_iskeyuser  = '是'`},
        {label: '否', value: `f_iskeyuser  is null`},
      ],
      showcheckmsg:false,
      checkInfo:{}
    }
  },
  methods: {
    change (row) {
      Vue.$login = {jwt: row.f_checker_id}
      asyncReady(this).then(()=> {
        row.f_upload_state = '已传'
        if (row.f_user_type == '民用') {
          // this.$goto('paper-set', {f_plan_id: row.f_check_plan_id, item: row, role: 'view'}, 'self')
          this.$goto('paper-message', {f_plan_id: row.f_check_plan_id, item: row, role: 'view'}, 'self')
        } else {
          // this.$goto('paper-set-noncivil', {f_plan_id: row.f_check_plan_id, item: row, role: 'view'}, 'self')
          this.$goto('paper-message-nocivil', {f_plan_id: row.f_check_plan_id, item: row, role: 'view'}, 'self')
        }
      }).catch(
        (respanse) => {
          alert('获取配置文件失败')
        })
    },
    readConfig () {
      let gen =  asyncReady(this)
      return co(gen)
    },
    showChooser () {
      this.showModal = true
    },
    refresh() {
      this.$refs.paged.$refs.criteria.search()
      console.log('modle',this.model)
      // this.$refs.paged.model.loadPage(5)
    },
    ok () {
      this.showModal = false
      if(this.$refs.paged.$refs.criteria.$refs.modal.$children[0].selectedRow.id) {
        this.model.f_check_plan = this.$refs.paged.$refs.criteria.$refs.modal.$children[0].selectedRow
      }
    },
    cancel () {
      this.showModal = false
      this.model.f_check_plan = {f_plan_name: '', id: ''}
    },
    print(row){
      this.showcheckmsg = true
      this.checkInfo = row
    }
  },
  ready(){
  },
  watch:{
  }

}
</script>
