<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-3 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 like '%{}%'">
            </div>
            <div class="col-sm-4 form-group form-input-group" style="width: 20%">
              <label class="control-label">起始时间</label>
              <datepicker
                :value.sync="model.f_start_time"
                placeholder='起始安检时间' style="width:60%"
                :disabled-days-of-week="[]"
                :format="'yyyy-MM-dd'"
                :show-rest-button="reset"
                v-model = "model.f_start_time"
                condition="f_onsite_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_end_time"
                placeholder='结束安检时间' style="width:60%"
                :disabled-days-of-week="[]"
                :format="'yyyy-MM-dd'"
                :show-rest-button="reset"
                v-model = "model.f_end_time"
                condition="f_onsite_time < ='{} 23:59:59'">
              </datepicker>
            </div>
            <div class="col-sm-3 form-group form-input-group" style="width: 20%">
              <label class="control-label">联系电话</label>
              <input type="text" class="form-control" v-model="model.f_defect_type"
                     style="height:34px;margin-top: 8px"      placeholder="联系电话"
                     condition="f_user_phone = '{}'">
            </div>
            <div class="col-sm-3 form-group form-input-group" style="width: 20%">
              <label class="control-label">卡号</label>
              <input type="text" class="form-control" v-model="model.f_card_id"
                     style="height:34px;margin-top: 8px"      placeholder="卡号"
                     condition="f_card_id = '{}'">
            </div>
          </div>
          <div class="row">
            <div class="col-sm-3 form-group form-input-group" style="width: 20%">
              <label class="control-label">用户类型</label>
              <input type="text" class="form-control" v-model="model.f_focususer_type"
                     style="height:34px;margin-top: 8px"    placeholder="用户类型"
                     condition="f_focususer_type like '%{}%'">
            </div>
            <div class="col-sm-3 form-group form-input-group" style="width: 20%">
              <label class="control-label">是否租住</label>
              <v-select placeholder='是否租住'
                        :value.sync="model.f_is_rent"
                        :value-single="true" style="width:60% "
                        class="select select_list"
                        :options='$parent.$parent.isRents'
                        v-model="model.f_is_rent"
                        condition="f_is_rent='{}'"
                        close-on-select clear-button> </v-select>
            </div>
            <div class="col-sm-3 form-group form-input-group" style="width: 20%">
              <label class="control-label">用气设备</label>
              <v-select placeholder='用气设备'
                        :value.sync="model.f_user_equipmen"
                        :value-single="true" style="width:60% "
                        class="select select_list"
                        :options='$parent.$parent.userEquipments'
                        v-model="model.f_user_equipmen"
                        condition="f_user_equipmen='{}'"
                        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="ImpleUserFollow" 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>
            <th>备注</th>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align: center">{{row.f_residential_area}}</td>
          <td style="text-align: center">{{row.f_address}}</td>
          <td style="text-align: center">{{row.f_focususer_type}}</td>
          <td style="text-align: center">{{row.f_user_phone}}</td>
          <td style="text-align: center">{{row.f_card_id}}</td>
          <td style="text-align: center">{{row.f_is_rent}}</td>
          <td style="text-align: center">{{row.f_user_equipmen}}</td>
          <td style="text-align: center">{{row.f_pregas}}</td>
          <td style="text-align: center">{{row.f_writeback}}</td>
          <td style="text-align: center">{{row.f_is_entry}}</td>
          <td style="text-align: center">{{row.f_onsite_time}}</td>
          <td style="text-align: center">{{row.f_indoor_circumstance}}</td>
          <td style="text-align: center">{{row.f_remark}}</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/ImpleUserFollow', 20)
      return {
        show:true,
        fun:this.$login.f,
        f_check_result:'',
        checkersid:[],
        model: model,
        showModal: false,
        selfcondition:'',
        userTypes:[{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('安检项')],
        isRents:[{label: '全部', value: ''}, {label: '是', value: '是'},{label: '否', value: '否'}],
        userEquipments: [{label: '全部', value: ''},{label:'未使用',value:'未使用'},{label:'单灶',value:'单灶'},{label:'单热水器',value:'单热水器'},
                          {label:'单壁挂锅炉',value:'单壁挂锅炉'},{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_residential_area": '小区名称',
          "f_address": "楼房号",
          "f_focususer_type": "用户类型",
          "f_user_phone": "联系电话",
          "f_card_id": "卡号",
          "f_is_rent": "是否租住",
          "f_user_equipmen": "用气设备",
          "f_pregas": "总购气量",
          "f_writeback": "末次购气时间",
          "f_is_entry": "是否入户",
          "f_onsite_time": "入户时间",
          "f_indoor_circumstance": "户内情况",
          "f_remark": "备注"
        }
        return Config
      }
    }
  }
</script>
