<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search" v-if="!show">
      <div class="flex">
        <div style="flex:1;" class="flex" >
          <criteria-paged :model="model" v-ref:paged @sort="sort">
            <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
              <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
                <div class="row">
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户编号</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_userinfo_code"
                           condition="f_userinfo_code like '%{}%' " placeholder="客户编号">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户名称</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_user_name"
                           condition="f_user_name like '%{}%'" placeholder="客户名称">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户电话</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_user_phone"
                           condition="f_user_phone like '%{}%'" placeholder="客户电话">
                  </div>
                  <div class="span" style="float:right;">
                    <button class="button_search button_spacing" @click="search()">查询</button>
                    <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
                    <!--<button class="btn btn-default" @click="$parent.$parent.stamp()">打印</button>-->

                    <export-excel :data="$parent.$parent.getCondition"
                                  :field="$parent.$parent.getExportField"
                                  :footer="$parent.$parent.footer"
                                  :header="$parent.$parent.other"
                                  v-if="$parent.$parent.authArr.includes('档案查询导出')"
                                  sqlurl="api/af-revenue/logic/openapi/exportfile" sql-name="filesQuery" template-name='用户查询导出'
                                  :choose-col="true"></export-excel>
                    <print-data :sum-field="$parent.$parent.getExportField" :model="$parent.model" :field="$parent.$parent.getExportField"
                                 :defaultfield="$parent.$parent.defaultfield"
                                titletable="客户查询"
                                :sumsmodel="$parent.$parent.sumsmodel"></print-data>

                    <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                  </div>
                </div>
                <div class="row" v-show="$parent.$parent.criteriaShow">
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">身份证号</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_idnumber"
                           condition="f_idnumber like '%{}%'" placeholder="身份证号">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户状态</label>
                    <v-select :value.sync="model.f_user_state"
                              v-model="model.f_user_state"
                              :options='$parent.$parent.userstates' placeholder='请选择'
                              condition="f_user_state = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户类型</label>
                    <v-select :value.sync="model.f_user_type"
                              :options='$parent.$parent.usertypes'
                              placeholder='请选择' v-model="model.f_user_type"
                              condition="f_user_type = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">用气性质</label>
                    <v-select :value.sync="model.f_gasproperties" v-model="model.f_gasproperties"
                              :options='$parent.$parent.gasproperties' placeholder='请选择'
                              condition="f_gasproperties = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">气表分类</label>
                    <v-select :value.sync="model.f_meter_classify"
                              :multiple="true"
                              v-model="model.f_meter_classify"
                              :options='$parent.$parent.metertypes' placeholder='请选择'
                              condition="f_meter_classify in {}"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;人数&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_people_num"
                           condition="f_people_num = '{}'" placeholder="人数">
                  </div>
<!--                  <div  class="col-sm-2 form-group">-->
<!--                    <label  class="font_normal_body">微信绑定</label>-->
<!--                    <v-select-->
<!--                      :value.sync="model.f_wechat"-->
<!--                      v-model="model.f_wechat"-->
<!--                      :options='$parent.$parent.weixinSign'-->
<!--                      placeholder='请选择'-->
<!--                      condition="f_wechat = '{}'"-->
<!--                      close-on-select>-->
<!--                    </v-select>-->
<!--                  </div>-->
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body" >缴费类型</label>
                    <v-select :value.sync="model.f_payment" multiple
                              v-model="model.f_payment"
                              :options='$parent.$parent.dypayment' placeholder='请选择'
                              condition="f_cost_type in {}"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户地址</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_address"
                           condition="f_address like '%{}%'" placeholder='客户地址'>
                  </div>
                  <div v-show=this.flag class="col-sm-2 form-group">
                    <label  for="startDate" class="font_normal_body">建档日期</label>
                    <datepicker placeholder="建档日期" style="width:60%"
                                v-model="model.f_createfile_date"
                                :value.sync="model.f_createfile_date"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_createfile_date >= '{} 00:00:00'">
                    </datepicker>
                  </div>
                  <div v-show=this.flag class="col-sm-2 form-group">
                    <label class="font_normal_body">建档部门</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_depname"
                           condition="f_depname like '%{}%'" placeholder='建档部门'>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">报警器编码</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_alarm_code"
                           condition="f_alarm_code like '%{}%'" placeholder='报警器编码'>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">发票编码</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_taxpayer_id"
                           condition="f_taxpayer_id like '%{}%'" placeholder='发票编码'>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">燃气表号</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_meternumber"
                           condition="f_meternumber like '%{}%'" placeholder='燃气表号'>
                  </div>
<!--                  <div class="col-sm-2">-->
<!--                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;小区名称&nbsp;&nbsp;&nbsp;</label>-->
<!--                    <input type="text" style="width:60%" class="input_search" v-model="model.f_residential_area"-->
<!--                           condition="f_residential_area like '%{}%'" placeholder="小区"/>-->
<!--                   <div class="col-sm-8">&ndash;&gt;-->
<!--                 <input type="text" v-show="false" v-model="model.f_residential_area" class="input_search" style="width: 80%"&ndash;&gt;-->
<!--;                             v-validate:f_residential_area='{required: true }'>&ndash;&gt;-->
<!--                               <v-select :value.sync="model.f_residential_area" :value-single="true"&ndash;&gt;-->
<!--                                class="select_list select"&ndash;&gt;-->
<!--                                :options='fresidentialarea' placeholder='请选择'&ndash;&gt;-->
<!--                               close-on-select search="true">&ndash;&gt;-->
<!--                      </v-select>-->
<!--                    </div>-->

                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;小区&nbsp;&nbsp;&nbsp;</label>
                    <v-select :value.sync="model.f_residential_area"
                              class="select_list select"
                              enter-push
                              multiple = "true"
                              v-model="model.f_residential_area"
                              style="width: 60%"
                              :options='$parent.$parent.residentialArea' placeholder='选择小区'
                              close-on-select>

                    </v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;楼栋&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_building"
                           condition="f_building like '%{}%'" placeholder="楼栋"/>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;单元&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_unit"
                           condition="f_unit like '%{}%'" placeholder="单元"/>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;楼层&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_floor"
                           condition="f_floor like '%{}%'" placeholder="楼层"/>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;门牌号</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_room"
                           condition="f_room like '%{}%'" placeholder="门牌号">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">余额区间</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_balance"
                           condition="f_balance >= '{}'" placeholder="最小值">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.balance2"
                           condition="f_balance <= '{}'" placeholder="最大值">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;抄表员</label>
                    <v-select :value.sync="model.f_inputtor"
                              v-model="model.f_inputtor" condition="f_inputtor = '{}'"
                              :options='$parent.$parent.inputtores' placeholder='请选择'
                              multiple = "true"
                              close-on-select></v-select>
                  </div>
                  <!--            <div class="col-sm-2" >-->
                  <!--              <label for="f_balance"  class="font_normal_body">账户结余</label>-->
                  <!--              <div class="form-group">-->
                  <!--                <v-input  id="f_balance" placeholder="账户结余"-->
                  <!--                          :expression.sync = 'model.f_balance'-->
                  <!--                          v-model="model.f_balance"-->
                  <!--                          condition= "f_balance  {}"-->
                  <!--                          :show-reset-button="reset"-->
                  <!--                          v-ref:f_balance>-->
                  <!--                </v-input>-->
                  <!--              </div>-->
                  <!--            </div>-->
                  <div class="col-sm-2 form-group">
                    <label for="startDate" class="font_normal_body">建档开始日期</label>
                    <datepicker id="startDate" placeholder="开始日期" style="width:60%"
                                v-model="model.startDate"
                                :value.sync="model.startDate"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_createfile_date >= '{} 00:00:00'">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="endDate" class="font_normal_body">建档结束日期</label>
                    <datepicker id="endDate" placeholder="结束日期" style="width:60%"
                                v-model="model.endDate"
                                :value.sync="model.endDate"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_createfile_date <= '{} 23:59:59'">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="startDate" class="font_normal_body">户档案开户开始日期</label>
                    <datepicker id="startDate1" placeholder="开始日期" style="width:60%"
                                v-model="model.startDate1"
                                :value.sync="model.startDate1"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_open_date >= '{} 00:00:00'">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                  <label for="endDate" class="font_normal_body">户档案开户结束日期</label>
                  <datepicker  id="endDate1"  placeholder="结束日期" style="width:60%"
                              v-model="model.endDate1"
                              :value.sync="model.endDate1"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="f_open_date <= '{} 23:59:59'">
                  </datepicker>
                </div>
                  <div class="col-sm-2 form-group">
                    <label for="startDate" class="font_normal_body">表档案开户开始日期</label>
                    <datepicker id="startDate1" placeholder="开始日期" style="width:60%"
                                v-model="model.startDate1_uf"
                                :value.sync="model.startDate1_uf"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_open_date_uf >= '{} 00:00:00'">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="endDate" class="font_normal_body">表档案开户结束日期</label>
                    <datepicker  id="endDate1"  placeholder="结束日期" style="width:60%"
                                 v-model="model.endDate1_uf"
                                 :value.sync="model.endDate1_uf"
                                 :format="'yyyy-MM-dd'"
                                 :show-reset-button="true"
                                 condition="f_open_date_uf <= '{} 23:59:59'">
                    </datepicker>
                  </div>
                  <div
                    :class="{'col-sm-2':!$parent.$parent.createFile,'col-sm-4':$parent.$parent.createFile}"
                    class="form-group">
                    <label class="font_normal_body">区&nbsp;&nbsp;&nbsp;&nbsp;域</label>
                    <v-select
                      :multiple="true"
                      v-model="model.f_pcd"
                      placeholder='选择区域'
                      :value.sync="model.f_pcd"
                      :options='$parent.$parent.pcdslist'
                      condition="f_pcd_id in {}"
                      style="width: 60%"
                      close-on-select >
                    </v-select>
                  </div>
                  <!--表册片区-->
<!--                  <div class="col-sm-2 form-group">-->
<!--                    <label class="font_normal_body">表册片区</label>-->
<!--                    <v-select :value.sync="model.f_book_slice_area" v-model="model.f_book_slice_area"-->
<!--                              :options='$parent.$parent.bookSlice' placeholder='片区/表册'-->
<!--                              style="width:60%"-->
<!--                              close-on-select-->
<!--                              condition="f_book_slice_area = '{}'"></v-select>-->
<!--                  </div>-->
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">安全协议</label>
                    <v-select :value.sync="model.f_safe"
                              v-model="model.f_safe" condition=" {}"
                              :options='$parent.$parent.safe' placeholder='请选择'
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;壁挂炉</label>
                    <v-select :value.sync="model.isbgl" v-model="model.isbgl"
                              :options='$parent.$parent.bgl' placeholder='请选择'
                              condition="isbgl = '{}'"
                              close-on-select></v-select>
                  </div>
                  <res-select-group :initres="$parent.$parent.initres" @re-res="$parent.$parent.getRes"></res-select-group>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">是否煤改气</label>
                    <v-select :value.sync="model.f_is_mgq"
                              :options='$parent.$parent.ismgq'
                              placeholder='请选择'
                              v-model="model.f_is_mgq"
                              condition="f_is_mgq = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">是否空置户</label>
                    <v-select :value.sync="model.f_is_vacant"
                              :options='$parent.$parent.isvacant'
                              placeholder='请选择'
                              v-model="model.f_is_vacant"
                              condition="f_is_vacant = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">是否孤寡老人</label>
                    <v-select :value.sync="model.f_is_alone"
                              :options='$parent.$parent.isalone'
                              placeholder='请选择'
                              v-model="model.f_is_alone"
                              condition="f_is_alone = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">是否空房</label>
                    <v-select :value.sync="model.f_is_empty"
                              :options='$parent.$parent.isempty'
                              placeholder='请选择'
                              v-model="model.f_is_empty"
                              condition="f_is_empty = '{}'"
                              close-on-select></v-select>
                  </div>
                </div>
              </div>
            </criteria>


            <data-grid :model="model" partial='list' class="list_area table_sy" @dblclick="$parent.dblclick" v-ref:grid>
              <template partial='head'>
                <tr>
                  <th>
                    <nobr>客户编号</nobr>
                  </th>
                  <th>
                    <nobr>客户名称</nobr>
                  </th>
                  <th>
                    <nobr>客户电话</nobr>
                  </th>
                  <th>
                    <nobr>身份证号</nobr>
                  </th>
                  <th>
                    <nobr>表册片区</nobr>
                  </th>
                  <th>
                    <nobr>账户余额</nobr>
                  </th>
                  <th>
                    <data-order field="f_address" name="客户地址"
                                :order.sync="$parent.$parent.$parent.orderFields.f_address"></data-order>
                  </th>
                  <th>
                    <nobr>小区</nobr>
                  </th>
                  <th>
                    <nobr>楼栋</nobr>
                  </th>
                  <th>
                    <nobr>单元</nobr>
                  </th>
                  <th>
                    <nobr>楼层</nobr>
                  </th>
                  <th>
                    <nobr>门牌号</nobr>
                  </th>
                  <th>
                    <nobr>客户状态</nobr>
                  </th>
                  <th>
                    <nobr>建档日期</nobr>
                  </th>
                  <th>
                    <nobr>户档案开户日期</nobr>
                  </th>
                  <th>
                    <nobr>表档案开户日期</nobr>
                  </th>
                  <th>
                    <nobr>建档人</nobr>
                  </th>
                  <th>
                    <nobr>缴费类型</nobr>
                  </th>
                  <th>
                    <nobr>是否壁挂炉</nobr>
                  </th>
                  <th>
                    <nobr>银行户名</nobr>
                  </th>
                  <th>
                    <nobr>银行名称</nobr>
                  </th>
                  <th>
                    <nobr>银行账号</nobr>
                  </th>
                  <th>
                    <nobr>银行身份证号</nobr>
                  </th>
                  <th>
                    <nobr>缴费编号</nobr>
                  </th>
                  <th>
                    <nobr>备注</nobr>
                  </th>
                  <th><nobr>是否煤改气</nobr></th>
                  <th><nobr>是否空置户</nobr></th>
                  <th><nobr>是否孤寡老人</nobr></th>
                  <th><nobr>是否空房</nobr></th>
<!--                  <th>-->
<!--                    <nobr>部门</nobr>-->
<!--                  </th>-->
<!--                  <th>-->
<!--                    <nobr>公司</nobr>-->
<!--                  </th>-->
                </tr>
              </template>
              <template partial='body'>
                <td  :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;" ><nobr>
                  <span @click="$parent.$parent.$parent.showmsg(row)"><a>{{row.f_userinfo_code}}</a></span>
                </nobr> </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_user_name}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_user_phone}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_idnumber}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_book_slice_area}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_balance}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_address}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_residential_area}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_building}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_unit}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_floor}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_room}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_user_state}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_createfile_date}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_open_date}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_open_date_uf}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_createfile_person}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_cost_type}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.isbgl}}</nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr><span v-if="row.f_cost_type =='银行代扣'">{{row.f_bank_accopen}}</span></nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr><span v-if="row.f_cost_type =='银行代扣'">{{row.f_bank_name}}</span></nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr><span v-if="row.f_cost_type =='银行代扣'">{{row.f_bank_account}}</span></nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr><span v-if="row.f_cost_type =='银行代扣'">{{row.f_bank_idnumber}}</span></nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr><span v-if="row.f_cost_type =='银行代扣'">{{row.f_bank_pay_number}}</span></nobr>
                </td>
                <td :class="row.f_user_state !== '正常'? 'back-red' : 'back-blue'" style="text-align: center;">
                  <nobr>{{row.f_comments}}</nobr>
                </td>
                <th style="text-align: center;"><nobr>{{row.f_is_mgq}}</nobr></th>
                <th style="text-align: center;"><nobr>{{row.f_is_vacant}}</nobr></th>
                <th style="text-align: center;"><nobr>{{row.f_is_alone}}</nobr></th>
                <th style="text-align: center;"><nobr>{{row.f_is_empty}}</nobr></th>
<!--                <td style="text-align: center;">-->
<!--                  <nobr>{{row.f_depname}}</nobr>-->
<!--                </td>-->
<!--                <td style="text-align: center;">-->
<!--                  <nobr>{{row.f_orgname}}</nobr>-->
<!--                </td>-->
              </template>
              <template partial='foot'>
              </template>
            </data-grid>
          </criteria-paged>

          <table class="table-hover">
            <tr style="position: relative" class="table-bordered">
              <td
                style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;color: #5CB95C;font-weight: bold">
                汇总信息
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                结余合计:&emsp;{{sumsmodel.f_balance}}
              </td>
            </tr>
          </table>

          <!--<modal :show.sync="printshow" v-ref:modal backdrop="false">-->
          <!--<header slot="modal-header" class="modal-header text-center">-->
          <!--<h4 class="modal-title">打印列选择</h4>-->
          <!--<input type="checkbox" class="" id="f_generations" v-model="all">-->
          <!--<label for="f_generations" class="font-size">全选</label>-->
          <!--</header>-->
          <!--<article slot="modal-body">-->
          <!--<div class="auto col-sm-11 col-md-offset-1"  style="margin-top: 10px;">-->
          <!--<div class="col-sm-3" v-for="f in fields">-->
          <!--<input type="checkbox" class="" :id="'water-owe-details-'+$index" v-model="modelval" :value="$key">-->
          <!--<label :for="'water-owe-details-'+$index" class="font-size">{{f}}</label>-->
          <!--</div>-->
          <!--</div>-->
          <!--</article>-->
          <!--<footer slot="modal-footer" class="modal-footer">-->
          <!--<center>-->
          <!--<button v-show="printshow" type="button" class="btn btn-default" @click='close()'>取消</button>-->
          <!--<button v-show="printshow" type="button" class="btn btn-success" @click='print()'>打印</button>-->
          <!--<print-table :model='model' v-show="false" v-ref:print-->
          <!--:top='40' :left='60' :right='40' :bottom='60'-->
          <!--:thead="thead" :tfoot='tfoot' :attach="yangsen"-->
          <!--:fields="modelval" :printpage="true">-->
          <!--</print-table>-->
          <!--</center>-->
          <!--</footer>-->
          <!--</modal>-->
          <!--<user-detail v-if="userdetail.show" :data="userdetail"></user-detail>-->
        </div>

      </div>
    </div>
    <div class="basic-main" style="width:99%;height:98%;margin-bottom:0px" v-if="show">
      <user-info-detail-manage-new :f_userinfo_id="rowdata.f_userinfo_id" @cancel-main="cancel"></user-info-detail-manage-new>
    </div>
  </div>
</template>

<script>
  import {HttpResetClass, PagedList} from 'vue-client'
  import defaultPrint from './config/DefaultPrint'
  import exportConfig from './config/exportConfig'

  let readySomething = async function (self) {
    self.$MagGetSaleParam.initinputtor();
    self.getinputtores();
    // 获取区县
    // self.$refs.paged.$refs.cri.model.startDate = self.$login.toStandardDateString()
    // self.$refs.paged.$refs.cri.model.endDate = self.$login.toStandardDateString()
    // await self.$refs.paged.$refs.cri.search()
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
    self.defaultfield = [...self.defaultfield, ...self.config.defaultPrint]

  }

  export default {
    title: '客户查询',
    data() {
      return {
        other:[],
        footer:[],
        flag:true,
        pcdslist:[],
        model: new PagedList('api/af-revenue/sql/filesQuery', 20, {orderitem: this.orderitem?'"' + this.orderitem + ' "':`'f_userinfo_code desc'`}, {f_balance: 0}),
        criteriaShow: false,
        orgCondtionStr: '',
        modelval: [],
        printshow: false,
        all: false,
        fields: {},
        //排序
        orderitem:'f_userinfo_code desc',
        orderFields: {
          f_operate_date: 'no'
        },
        //默认打印列
        defaultfield: [],
        config: {
          defaultPrint: ['f_userinfo_code', 'f_user_name', 'f_user_phone', 'f_user_state']
        },
        balance2:'',
        thead: '',
        tfoot: '',
        area: [],
        //合计数据
        sumsmodel: {},
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[],
        },
        userdetail: {
          show: false,
          f_userinfo_code: '',
          f_filialeids: ''
        },
        safe:[{label:'已签订',value:"(f_security_date is not null and f_security_date !='')"},{label:'未签订',value:"(f_security_date is null or f_security_date='')"}],
        userstates:this.$appdata.getParam('用户状态') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('用户状态')] : [],
        show:false,
        rowdata:{},
        meterInfo:{},
        deviceInfo:{},
        condition2:'',

        ismgq: [{label: '全部', value: ''},{label: '是', value: '是'},{label: '否', value: '否'}],
        isvacant: [{label: '全部', value: ''},{label: '是', value: '是'},{label: '否', value: '否'}],
        isalone: [{label: '全部', value: ''},{label: '是', value: '是'},{label: '否', value: '否'}],
        isempty: [{label: '全部', value: ''},{label: '是', value: '是'},{label: '否', value: '否'}],
        weixinSign:[{label:"全部",value:""},{label:"已绑定",value:"已绑定"},{label:"未绑定",value:"未绑定"}],
        //小区
        residentialArea: [],
        //表册片区
        bookSlice:[{label: '全部',value: ''}],
        inputtores:[{label: '全部',value: ''}],  //抄表员
        allorgid:[],
        f_filialeid: this.$login.f.f_orgid,
        dypayment:[{label:"全部",value:""},{label:"银行代扣",value:"银行代扣",},{label:"现金缴费",value:"现金缴费",}],
      }
    },
    ready() {
       this.getaddress()

      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
      this.initAreas(this.$login.f.orgid)
    },
    methods: {
      async getinputtores () {
        // 获取抄表员
        let rs = []
        if (this.$login.f.f_gasman.length > 0) {
          for (let i = 0; i < this.$login.f.f_gasman.length; i++) {
            let temp = {
              label: this.$login.f.f_gasman[i].name,
              value: this.$login.f.f_gasman[i].name
            }
            rs.push(temp)
          }
        }
        this.inputtores = [{label: '全部', value: ''}, ...rs]
      },
      async updateParams() {
        await this.$MagLoadParams.loadParam(this.f_filialeid)
        this.inputtores = [];
        this.inputtores.push({label: "全部", value: ""})
        this.initSlice(this.f_filialeid)
        if(this.allorgid!=null){
          this.allorgid.forEach((res)=>{
            this.inputtores = this.inputtores.concat(this.$MagGetSaleParam.getresinputtor(res));
          })
        }
      },
      getotherfooter () {
        // this.$refs.paged.$refs.cri.$refs.exports.otherData = [];
        // this.$refs.paged.$refs.cri.$refs.exports.footerData = [];
        this.other = [];
        this.footer = [];
        let exportdata = this.getCondition;
        let otherInData = [];
        otherInData.push(`导出时间: ${this.$login.toStandardTimeString()}`);
        let footerData = [], exportfield = this.getExportField;
        footerData.push("合计");
        let self = this;
        for (var field in self.sumsmodel) {
          footerData.push(`${exportfield[field]}合计:${self.sumsmodel[field]}`);
        }
        this.footer.push(footerData);
        this.other.push(otherInData);
      },
      async  getaddress(){
        console.log('开始获取小区')
        let HttpReset = new HttpResetClass()
        var data = await HttpReset.load('POST', 'api/af-revenue/sql/manage_getarealist', {
          data: {
            condition: `1=1 `
          }
        }, {resolveMsg: null, rejectMsg: '获取小区失败!'})
        console.log('小区',data)
        let house = []
        for (let row of data.data){
          console.log('开始保存小区')
          house.push({label: row.f_residential_area, value: row.f_residential_area})
        }
        this.residentialArea = house

       console.log('开始获取区域')
        var req = await HttpReset.load('POST','api/af-revenue/sql/address_singleTableOrderBy?pageNo=1&pageSize=9999999', {
          data: {
            items: '*',
            tablename: 't_pcd',
            orderitem: 'id',
            condition: `1=1`
          }
        }, {resolveMsg: null, rejectMsg: '获取地址失败!'})
        let redata = []
        console.log('区域是：',req)
        req.data.forEach((row, n) => {
          redata[n] = {
            label: row.f_pcd,
            value: row.id,
            data: row,
            id: row.id
          }
        })
        console.log('获取到的小区',redata)
        this.pcdslist = redata
      },

      //把数据库查询数据转换为下拉数据
      calculate(rows){
        let data = []
        rows.forEach((row, n) => {
          data[n] = {label: row.f_residential_area, value: row.id}
        })
        return data
      },
      search(){
        this.$refs.paged.$refs.cri.search()
      },
      cancel(obj) {
        this.show = false
      },
      showmsg(obj){

        this.rowdata=obj
        this.show=true
        // let http = new HttpResetClass()
        // http.load('POST','api/af-revenue/sql/getUserMeter',{data: {condition: `f_userinfo_id ='${obj.f_userinfo_id}'`}},
        //   {resolveMsg: null, rejectMsg: null}).then((res) => {
        //   this.meterInfo = res.data})
        // let http2 = new HttpResetClass()
        // http2.load('POST','api/af-revenue/sql/deviceQuery',{data: {condition: `f_userinfo_id ='${obj.f_userinfo_id}'`}},
        //   {resolveMsg: null, rejectMsg: null}).then((res) => {
        //   this.deviceInfo = res.data})

        // this.f_userinfo_id=obj.f_userinfo_id
      },
      //初始化片区
      async initSlice (val) {
        if (val) {
          let getAllArea = await this.$resetpost('/rs/search', {
            source: 'this.getParentByType($organization$).getAllChildrens().where(row.getType() == $zone$)',
            userid: this.$login.f.id
          }, {resolveMsg: null, rejectMsg: '获取片区出错！！！'})
          let arr = getAllArea.data.filter((res) => {
            return res.parentid == val
          })
          this.bookSlice = []
          console.log('过滤之后的片区-------------------', arr)
          arr.forEach((res) => {
            this.bookSlice.push({label: res.name, value: res.name})
          })
        }
      },
      async initAreas (val) {

        if (val) {
          let getAllArea = await this.$resetpost('/rs/search', {
            source: 'this.getParentByType($organization$).getAllChildrens().where(row.getType() == $zone$)',
            userid: this.$login.f.id
          }, {resolveMsg: null, rejectMsg: '获取片区出错！！！'})

          let arr = getAllArea.data.filter((res) => {
            return res.parentid == val
          })
          console.log('过滤之后的片区', arr)
          this.sliceArea = []
          arr.forEach((res) => {
            this.sliceArea.push({label: res.name, value: res.name})
          })
        }
      },
      selfSearch(args) {
        //小区查询条件
        this.area =  this.$refs.paged.$refs.cri.model.f_residential_area
        console.log("=====小区model绑定====",this.area)
        if(this.area.length !== 0){
          let str = JSON.stringify(this.area)
          str = str.replace(/"/g,`'`)
          str = str.replace(/\[/g,``)
          str = str.replace(/\]/g,``)
          console.log("=====小区model22222222222绑定====",str)
          //查询多个小区时条件
          args.condition += ` and f_residential_area in  ( ${str} )`
        }

        if (!this.orgCondtionStr) {
          args.condition = `${args.condition}` + " and f_orgid = " + this.$login.f.orgid
        } else {
          args.condition = `${args.condition}` + this.orgCondtionStr
        }
        this.condition2 = args.condition
        this.model.search(args.condition, args.model)
        this.sumsmodel = this.$refs.paged.$refs.grid.model.sums
        console.log('合计字段', this.sumsmodel)
      },
      clear() {
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          this.$refs.paged.$refs.cri.model[key] = []
        })
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      getRes(obj) {
        this.orgCondtionStr = obj
      },
      stamp() {
        this.all = false
        //默认选择要打印的列
        this.modelval = defaultPrint.config
        this.fields = this.getfield
        console.log('所有打印字段', this.fields)
        this.printshow = true
        this.put()
      },
      put() {
        // 对Modelval进行排序
        this.sortModelval()
        this.thead = `<tr><th colspan=${this.modelval.length}>用户查询统计报表</th></tr><tr>`
        for (let key of this.modelval) {
          this.thead += '<th>' + this.fields[key] + '</th>'
        }
        this.thead += '</tr>'
      },
      print() {
        this.$refs.print.PrintAsFile()
        this.printshow = false
      },
      close() {
        this.printshow = false
      },
      // 对选择的列进行排序
      sortModelval() {
        let sortModel = []
        Object.keys(this.fields).forEach((key) => {
          if (this.modelval.includes(key)) {
            sortModel.push(key)
          }
        })
        this.modelval = sortModel
        console.log('选择的打印的字段', this.modelval)
      },
      dblclick(row, index) {
        console.log('双击之后数据', row, index)
        this.userdetail.show = true
        this.userdetail.f_userinfo_code = row.f_userinfo_code
        this.userdetail.f_filialeids = row.f_filialeids
      },
      sort (field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'no') {
          this.model.paramSource.orderitem = `'${this.orderitem}'`
        } else {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }

        this.search()
      }
    },

    watch: {
      'all'(val) {
        if (val) {
          this.modelval = this.bodyData
        } else {
          this.modelval = defaultPrint.config
          this.put()
        }
      },
      'modelval.length'() {
        this.put()
      },
      sumsmodel:{
        handler: function(val) {
          this.getotherfooter();
        },
        deep: true
      },
      'orgCondtionStr'(val) {
        let res = val.match(/'(.*?)'/)
        console.log('正则提取:',res && res[1])
        if (res) {
          this.f_filialeid = res[1]
          if(res.input !=null){
            let resorgid = res.input.substring(res.input.indexOf("'"));
            if(resorgid!= null && resorgid!=''){
              resorgid = resorgid.substring(0,resorgid.lastIndexOf("'")+1);
              // resorgid = resorgid.replaceAll("'","");
              resorgid = resorgid.replace(/'/g,"");
              this.allorgid = resorgid.split(",")
            }
          }
          this.updateParams()
        }
      },
    },
    computed: {
      // defaultexport() {
      //   return exportConfig.chargeexportConfig
      // },
      authArr () {
        return this.$login.r ? this.$login.r : []
      },

      getCondition() {
        return {condition: this.condition2,orderitem:this.orderitem}
      },
      getfield() {
        let data = {}
        this.bodyData.forEach((value, index) => {
          data[this.bodyData[index]] = this.headData[index]
        })
        //合计字段打印
        this.tfoot = `<tr><th colspan=${this.modelval.length}>全表汇总信息: `
        if (this.sumsmodel) {
          Object.keys(this.sumsmodel).forEach((key) => {
            this.tfoot += this.fields[key] + '合计: ' + `<font color="blue">${this.sumsmodel[key]} </font>`
          })
        } else {
          this.tfoot += '暂无'
        }
        this.tfoot += '</th></tr>'
        return data
      },
      getExportField() {
        return exportConfig.userConfig
      },
      inputtor () {
        // 获取抄表员
        console.log('获取抄表员', this.$login.f)
        let rs = []
        if (this.$login.f.f_gasman.length > 0) {
          for (let i = 0; i < this.$login.f.f_gasman.length; i++) {
            let temp = {
              label: this.$login.f.f_gasman[i].name,
              value: this.$login.f.f_gasman[i].name
            }
            rs.push(temp)
          }
        }

        return [{label: '全部', value: ''}, ...rs]
      },
      bgl(){
        return [{label: '全部', value: ''}, {label: '是', value: '是'}, {label: '否', value: '否'}]
      },
      userstates() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('客户状态')]
      },
      //参数获取 用户类型
      usertypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用户类型')]
      },
      //参数获取 用气性质
      gasproperties() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用气性质')]
      },
      //参数获取 气表类型
      metertypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气表类型')]
      }
    }
  }
</script>
<style>
  .back-red{		/* 红色背景 */
    background-color: #F6C6CE;
  }
  .back-blue{		/* 蓝色背景 */

  }
</style>

