<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.search' v-ref:criteria>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <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_area1"
                     style="height:34px;margin-top: 8px"    placeholder="小区名称"
                     condition="f_residential_area1 like '%{}%'">
            </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_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">街&nbsp;&nbsp;&nbsp;&nbsp;道</label>
              <input type="text" class="form-control" v-model="model.f_street"
                     style="height:34px;margin-top: 8px"    placeholder="街道"
                     condition="f_street = '{}'">
            </div>
            <div class="col-sm-4 form-group form-input-group" style="width: 20%">
              <label class="control-label">起始时间</label>
              <datepicker
                :value.sync="model.f_onsite_time"
                placeholder='最后安检时间起始' style="width:60%"
                :disabled-days-of-week="[]"
                :format="'yyyy-MM-dd'"
                :show-rest-button="reset"
                v-model = "model.f_onsite_time"
                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_offsite_time"
                placeholder='最后安检时间截止' style="width:60%"
                :disabled-days-of-week="[]"
                :format="'yyyy-MM-dd'"
                :show-rest-button="reset"
                v-model = "model.f_offsite_time"
                condition="f_offsite_time < ='{} 23:59:59'">
              </datepicker>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-4 form-group form-input-group" style="width: 20%">
              <label class="control-label">小区性质</label>
              <v-select placeholder='小区性质'
                        :value.sync="model.f_residential_properties"
                        :value-single="true" style="width:60% "
                        class="select select_list"
                        :options='$parent.$parent.residentialProperties'
                        v-model="model.f_residential_properties"
                        condition="f_residential_properties='{}'"
                        close-on-select clear-button> </v-select>
            </div>
            <div class="col-sm-4 form-group form-input-group" style="width: 20%">
              <label class="control-label">供暖方式</label>
              <v-select placeholder='供暖方式'
                        :value.sync="model.f_heating_style"
                        :value-single="true" style="width:60% "
                        class="select select_list"
                        :options='$parent.$parent.heating_style'
                        v-model="model.f_heating_style"
                        condition="f_heating_style='{}'"
                        close-on-select clear-button> </v-select>
            </div>
          </div>
          <div class="row">
            <div class="span" style="margin-top:8px;float:right">
              <button class="button_search button_spacing" @click="search()">查询</button>
              <export-excel :data="$parent.$parent.getCondition"
                            :field="$parent.$parent.getfield"
                            sqlurl="rs/logic/SafeExportExcel" sql-name="AreaStandingBook" template-name='小区台账导出'  :choose-col="true"></export-excel>
            </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>
            <th>壁挂炉比例</th>
            <th>最后一次安检时间</th>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align: center">{{row.f_distinct}}</td>
          <td style="text-align: center">{{row.f_street}}</td>
          <td style="text-align: center">{{row.f_residential_area1}}</td>
          <!--<td>{{row.f_residential_area2}}</td>-->
          <td style="text-align: center">{{row.sum}}</td>
          <td style="text-align: center">{{row.countbuilding}}</td>
          <td style="text-align: center">{{row.countunit}}</td>
          <td style="text-align: center">{{row.countplumb}}</td> <!--TODO 立管数-->
          <td style="text-align: center">{{row.f_residential_properties}}</td>
          <td style="text-align: center">{{row.f_heating_style}}</td>
          <td style="text-align: center">{{row.bglbl}}</td>
          <td style="text-align: center">{{row.f_offsite_time}}</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:'小区台账',
    data() {
      let model = new PagedList('rs/sql/AreaStandingBook', 20)
      return {
        show:true,
        fun:this.$login.f,
        f_check_result:'',
        checkersid:[],
        model: model,
        showModal: false,
        selfcondition:'',
        eliminates:[{label: '全部', value: ''}, {label: '已处理', value: '已处理'},{label: '未处理', value: '未处理'}],
        residentialProperties: [
          {label: '全部', value: ''},
          {label: '物业小区', value: '物业小区'},
          {label: '企事业单位', value: '企事业单位'},
          {label: '安置小区', value: '安置小区'},
          {label: '自建房', value: '自建房'},
          {label: '公租房', value: '公租房'},
          {label: '廉租房', value: '廉租房'}
        ],
        heating_style: [
          {label: '全部', value: ''},
          {label: '壁挂炉供暖', value: '壁挂炉供暖'},
          {label: '集中供暖', value: '集中供暖'},
          {label: '其他', value: '其他'},
          {label: '燃气取暖器供暖', value: '燃气取暖器供暖'}
        ],
        // f_approval_states:  [{label: '全部', value: ''}, ...this.$appdata.getParam('安检单审核状态')],
        // f_entry_status:  [{label: '全部', value: ''}, ...this.$appdata.getParam('安检状态')],
        // f_devices:  [{label: '全部', value: ''}, ...this.$appdata.getParam('安检项')],
        // f_check_results:  [{label: '全部', value: ''}, {label: '正常', value: '正常'},{label: '有隐患', value: '有隐患'}],
        // f_repaired: [{label: '全部', value: ''},{label:'维修状态',value:''},{label:'已修',value:'已修'},{label:'未修',value:'未修'}]
      }
    },
    ready(){
      // this.$refs.paged.$refs.criteria.model.f_filialeids = this.$login.f.f_orgids
      // this.$refs.paged.$refs.criteria.model.f_device_type = ['']
      //
      // let gen = select(this)
      // return co(gen)
    },
    methods: {
      cancel () {
        this.showModal = false
        this.$set('selfcondition','')
    },
      search(args) {
        var str = args.condition
        str += this.selfcondition
        this.model.search(str, args.model)
      },
    },
    computed: {
      getCondition() {
        return {
          condition: `${this.$refs.paged.$refs.criteria.condition} `,
        }
      },
      getfield() {
        let Config = {
          "f_distinct": '所属区域',
          "f_street": "地址",
          "f_residential_area1": "小区名称(档案)",
          // "": "小区名称(安检)",
          "sum": "户数",
          "countbuilding": "楼栋数",
          "countunit": "单元数",
          // "": "立管数",
          "f_residential_properties": "小区性质",
          "f_heating_style": "供暖方式",
          "bglbl": "壁挂炉比例",
          "f_offsite_time": "最后一次安检时间"
        }
        return Config
      }
    }
  }
</script>
