<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 = '{}' " 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 = '{}'" 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="col-sm-2 form-group">
                    <label for="startGasDate" class="font_normal_body">通气时间</label>
                    <datepicker id="startGasDate" placeholder="开始日期" style="width:60%"
                                v-model="model.startGasDate"
                                :value.sync="model.startGasDate"
                                :format="'yyyy-MM-dd 00:00:00'"
                                :show-reset-button="true"
                                condition="f_gas_date >= '{}'">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="endGasDate" class="font_normal_body">至</label>
                    <datepicker id="endGasDate" placeholder="结束日期" style="width:60%"
                                v-model="model.endGasDate"
                                :value.sync="model.endGasDate"
                                :format="'yyyy-MM-dd 23:59:59'"
                                :show-reset-button="true"
                                condition="f_gas_date <= '{}'">
                    </datepicker>
                  </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="button_clear button_spacing"  style="margin-top: 10px;background-color: #6aa6e2;"  @click="$parent.$parent.downloadFiles()">导出</button>

                    <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>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_address"
                           condition="f_address like '%{}%'" placeholder='项目地址'>
                  </div>
                  <res-select-group :initres="$parent.$parent.initres" @re-res="$parent.$parent.getRes"></res-select-group>
                  <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  00:00:00'"
                                :show-reset-button="true"
                                condition="f_createfile_date >= '{}'">
                    </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 23:59:59'"
                                :show-reset-button="true"
                                condition="f_createfile_date <= '{}'">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">通气年限</label>
                    <input type="number" style="width:60%" class="input_search" v-model="model.diffAllyear1"
                           condition="diffAllyear >= {}" placeholder="最小值">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;</label>
                    <input type="number" style="width:60%" class="input_search" v-model="model.diffAllyear2"
                           condition="diffAllyear <= {}" placeholder="最大值">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户类型</label>
                    <v-select
                      :value.sync="model.f_user_type"
                      @change="$parent.$parent.userTypeChange()"
                      :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">&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">用户状态</label>
                    <v-select
                      placeholder='用户状态'
                      value-single
                      style="width:60%"
                      :value.sync="model.f_user_state"
                      v-model="model.f_user_state"
                      :options='$parent.$parent.userstate'
                      close-on-select condition="f_user_state ='{}'">
                    </v-select>
                  </div>
                </div>
              </div>
            </criteria>
            <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid>
              <template partial='head'>
                <tr>
                  <th rowspan="2"><nobr>序号</nobr></th>
                  <th colspan="11"><nobr>用户信息</nobr></th>
                  <th colspan="5"><nobr>建档信息</nobr></th>
                  <th colspan="8"><nobr>用气设备</nobr></th>
                  <th colspan="8"><nobr>燃气计量装置</nobr></th>
                  <th colspan="6"><nobr>控制器设备</nobr></th>
                  <th colspan="6"><nobr>燃气连接管</nobr></th>
                  <th colspan="7"><nobr>调压设备</nobr></th>
                  <th colspan="11"><nobr>燃气报警器装置</nobr></th>
                  <th colspan="6"><nobr>安检信息</nobr></th>
                  <th colspan="2"><nobr>初次充值信息</nobr></th>
                  <th colspan="2"><nobr>最新充值信息</nobr></th>
                  <th rowspan="2"><nobr>备注</nobr></th>
                </tr>

                <tr>
                  <th><nobr>统一社会信用代码</nobr></th>
                  <th><nobr>单位名称</nobr></th>
                  <th><nobr>经营名称</nobr></th>
                  <th><data-order field="f_address" name="经营场所"></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><data-order field="f_createfile_date" name="建档日期"></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>
                  <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>
                  <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 style="text-align: center;" ><nobr>
                  {{$index + 1}}
                </nobr></td>
                <!--用户信息-->
                <td style="text-align: center;">
                  <nobr>
                    {{row.f_taxpayer_id}}
                  </nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_paper_name}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_user_name}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_address}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_legal_name}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_user_phone}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_idnumber}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_agent_name}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_agent_credentials}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_agent_phone}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,'','用户信息')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>


                <!--建档信息-->
                <td style="text-align: center;">
                  <nobr>{{row.f_createfile_date}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_contract_id}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gas_date}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gas_person}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,'','建档信息')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>


                <!--用气设备-->
                <td style="text-align: center;">
                  <nobr>{{row.f_zx}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_bzl}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_syz}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_dyz}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_rsq}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_dgz}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gl}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,'','用气设备')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>

                <!--燃气计量装置-->
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_devices_no}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_equipment_type}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_devices_model}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gmd_lsnumber}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_make_date}}</nobr>
                </td>
                <td style="text-align: center;" :class="$parent.$parent.$parent.formatTime(row.ranqi_exp_date).indexOf('已过期')!==-1? 'back-red' : 'back-blue'">
                  <nobr>{{$parent.$parent.$parent.formatTime(row.ranqi_exp_date)}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,row.ranqi_id,'燃气计量装置')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>

                <!--控制器设备-->
                <td style="text-align: center;">
                  <nobr>{{row.control_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.control_devices_no}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.control_devices_model}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.control_make_date}}</nobr>
                </td>
                <td style="text-align: center;" :class="$parent.$parent.$parent.formatTime(row.control_exp_date).indexOf('已过期')!==-1? 'back-red' : 'back-blue'">
                  <nobr>{{$parent.$parent.$parent.formatTime(row.control_exp_date)}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,row.control_id,'控制器设备')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>


                <!--燃气连接管-->
                <td style="text-align: center;">
                  <nobr>{{row.f_conn_style}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_pipe_material}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_pipe_length}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.ranqi_pipe_prdate}}</nobr>
                </td>
                <td style="text-align: center;" :class="$parent.$parent.$parent.formatTime(row.ranqi_pipe_expdate).indexOf('已过期')!==-1? 'back-red' : 'back-blue'">
                  <nobr>{{$parent.$parent.$parent.formatTime(row.ranqi_pipe_expdate)}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,row.ranqi_id,'燃气连接管')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>


                <!--调压设备-->
                <td style="text-align: center;">
                  <nobr>{{row.tiaoya_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.tiaoya_equipment_type}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.tiaoya_devices_model}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.tiaoya_install_position}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.tiaoya_make_date}}</nobr>
                </td>
                <td style="text-align: center;" :class="$parent.$parent.$parent.formatTime(row.tiaoya_exp_date).indexOf('已过期')!==-1? 'back-red' : 'back-blue'">
                  <nobr>{{$parent.$parent.$parent.formatTime(row.tiaoya_exp_date)}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,row.tiaoya_id,'调压设备')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>

                <!--燃气报警装置-->
                <td style="text-align: center;">
                  <nobr>{{row.f_icgd_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_icgd_num}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_icgd_prdate}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_host_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_host_num}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_host_prdate}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gssv_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gssv_num}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gssv_prdate}}</nobr>
                </td>
                <td style="text-align: center;" :class="$parent.$parent.$parent.formatTime(row.alarm_exp_date).indexOf('已过期')!==-1? 'back-red' : 'back-blue'">
                  <nobr>{{$parent.$parent.$parent.formatTime(row.alarm_exp_date)}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>
                    <span @click="$parent.$parent.$parent.dealmsg(row,row.alarm_id,'燃气报警装置')"><a><b>变更记录</b></a></span>
                  </nobr>
                </td>


                <!--安检信息-->
                <td style="text-align: center;">
                  <nobr>{{row.f_upload_date}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_checker_name}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_total_gas}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.c}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_defect_content}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_repair_date}}</nobr>
                </td>

                <td style="text-align: center;">
                  <nobr>{{row.f_collection}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_operate_date}}</nobr>
                </td>

                <td style="text-align: center;">
                  <nobr>{{row.f_collection1}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_operate_date1}}</nobr>
                </td>

                <!--备注-->
                <td style="text-align: center;">
                  <nobr>{{row.f_comments}}</nobr>
                </td>

              </template>
              <template partial='foot'>
              </template>
            </data-grid>
          </criteria-paged>

        </div>
      </div>
    </div>
    <modal :show.sync="filechangeHistoryShow" v-ref:filechangeHistoryShow backdrop="false" class="filechangeHistoryShow">
      <header slot="modal-header" class="modal-header" style="text-align: center">
        <h4 class="modal-title">{{titles}}</h4>
      </header>
      <article slot="modal-body" class="modal-body">
        <data-grid class="list_area table_sy" :model="filechangeHistorys" partial='list'>
          <template partial='head'>
            <th><nobr>序号</nobr></th>
            <th><nobr>更改内容</nobr></th>
            <th><nobr>更改前</nobr></th>
            <th><nobr>更改后</nobr></th>
            <th><nobr>变更时间</nobr></th>
          </template>
          <template partial='body'>
            <td >{{$index+1}}</td>
            <td><nobr>{{row.f_field_name}}</nobr></td>
            <td><nobr>{{row.f_used_content}}</nobr></td>
            <td><nobr>{{row.f_new_content}}</nobr></td>
            <td><nobr>{{row.f_submit_date}}</nobr></td>
          </template>
        </data-grid>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-default"  @click='filechangeHistoryShow = false'>关闭</button>
      </footer>
    </modal>
  </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.defaultfield = [...self.defaultfield, ...self.config.defaultPrint]
    self.$refs.paged.$refs.cri.model.f_user_state='正常'
  }

  export default {
    title: '非民用用气设备查询',
    data() {
      return {
        titles:'',
        other:[],
        footer:[],
        gasproperties: [],
        model: new PagedList('api/af-revenue/sql/fmyGasDeviceQuery', 20, {orderitem: this.orderitem?'"' + this.orderitem + ' "':`'f_userinfo_code desc'`}),
        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: ''
        },
        filechangeHistorys: {rows:[]},
        filechangeHistoryShow: false,
        show:false,
        rowdata:{},
        meterInfo:{},
        deviceInfo:{},
        condition2:'',


        //小区
        residentialArea: [],
        allorgid:[],
        f_filialeid: this.$login.f.f_orgid,
      }
    },
    ready() {
      this.getaddress()
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      async dealmsg(row,id,type){
        this.titles = type+'变更记录'
        if (type==='燃气连接管'){
          type = '燃气计量装置连接管'
        }
        this.filechangeHistorys.rows = []
        let data = {
          tablename: `t_infochange`,
          items: '*',
          condition: `1=1`,
          orderitem: 'f_change_id desc'
        }
        let urlParam = 'rs/sql/singleTable_OrderBy'
        if (id){
          data.condition = `1=1 and f_table_id = ${id} and f_field_name like '%${type}%'`
          let res = await this.$resetpost(urlParam, {data: data}, {rejectMsg: '获取变更记录出错', resolveMsg: null})
          if (res){
            this.filechangeHistorys.rows = res.data
          }
        }else{
          if (type === '建档信息'||type === '用户信息'){
            urlParam = 'api/af-revenue/sql/sxchangeuserquery'
            data = {
              condition: ` 1=1  and f_orgid in ('${this.$login.f.orgid}') and f_userinfo_code = '${row.f_userinfo_code}' `,
              orderitem: "f_operate_date desc"
            }
            let res = await this.$resetpost(urlParam, {data: data}, {rejectMsg: '获取变更记录出错', resolveMsg: null})
            if (res){
              this.filechangeHistorys.rows = res.data
            }
          }
        }
        this.filechangeHistoryShow =true
      },
      ventilationYear(diffAllyear){
        console.log("diffAllyear?",diffAllyear)
        if ( 1<= diffAllyear && diffAllyear <= 2 ){
          return  {
            color: 'green !important'
          }
        }else if (3<= diffAllyear && diffAllyear <=4){
          return  {
            color: 'orange !important'
          }
        }else if (5<= diffAllyear && diffAllyear <=8){
          return  {
            color: 'red !important'
          }
        }else if (diffAllyear>8){
          return  {
            color: 'crimson !important'
          }
        }else {
          return {

          }
        }
      },
      formatTime(expireTime){
        if (expireTime){
          let formats = {
            'year': '%n%年',
            'month': '%n%月',
            'day': '%n%天',
          };
          let now = new Date().getTime()
          let expireTimes = new Date(expireTime).getTime()
          if (now < expireTimes){
            return expireTime
          }else {
            let seconds = Math.floor((now - expireTimes) / 1000)
            let minutes = Math.floor(seconds / 60)
            let hours = Math.floor(minutes / 60)
            let days = Math.floor(hours / 24)
            let months = Math.floor(days / 30)
            let years = Math.floor(months / 12)

            let diffType = ''
            let diffValue = 0
            if (years > 0) {
              diffType = 'year'
              diffValue = years
            } else {
              if (months > 0) {
                diffType = 'month'
                diffValue = months
              } else {
                if (days > 0) {
                  diffType = 'day'
                  diffValue = days
                }
              }
            }
            return '已过期'+formats[diffType].replace('%n%', diffValue);
          }
        }else {
          return ''
        }
      },
      async  getaddress(){
        console.log('开始获取小区')
        let HttpReset = new HttpResetClass()
        var data = await HttpReset.load('POST', 'api/af-revenue/sql/manage_getarealist', {
          data: {
            condition: `1=1 and s.f_filialeid = '${this.$login.f.orgid}'`
          }
        }, {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
      },
      async downloadFiles() {
        if (this.condition2) {
          let data = {
            sqlName: 'fmyGasDeviceQuery',
            condition: this.condition2,
            orderitem: this.orderitem,
            fileName: '非民用用气设备查询'
          }
          let HttpReset = new HttpResetClass()
          let res = await HttpReset.load('POST', 'rs/deviceExport/gasDevices', {
            data: data
          }, {resolveMsg: null, rejectMsg: null})
          if (res){
            let downurl = 'rs/deviceExport/download?filename=非民用用气设备查询.xlsx';
            this.$resetget(downurl, {}).then(res => {
              var link = document.createElement('a');
              link.target = "_blank"
              link.href = downurl;
              link.setAttribute("download", "非民用用气设备查询.xlsx"); //指定下载后的文件名，防跳转
              document.body.appendChild(link);
              link.click();
            })
          }
        } else {
          this.$showAlert('查询条件为空，请查询后再导出', 'warning', 3000)
          return
        }
      },
      userTypeChange() {
        this.gasproperties = [];
        if (this.$refs.paged.$refs.cri.model !== null) {
          this.$refs.paged.$refs.cri.model.f_gasproperties = "";

          // console.log("查看客户类型",this.$refs.paged.$refs.cri.model.f_user_type[0])
          this.gasproperties = this.$appdata.getParam(
            this.$refs.paged.$refs.cri.model.f_user_type[0]
          );
          // this.gasproperties.push({label: '全部', value: ''})
        } else {
          this.gasproperties = [{ label: "全部", value: "" }];
        }
      },
      //把数据库查询数据转换为下拉数据
      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
      },
      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()
      },
      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()
      },
      '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(",")
            }
          }
        }
      },
    },
    computed: {
      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
      },
      usertypes() {
        return [
          { label: " 全部 ", value: "" },
          ...this.$appdata.getParam("用户类型"),
        ];
      },
      addressstate() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('地址状态')]
      },
      userstate() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用户状态')]
      }
    }
  }
</script>
<style lang="less">
  .filechangeHistoryShow {
  td {
    text-align: center !important;
  }
  }
  .back-red{		/* 红色背景 */
    color: #df1335 !important;
  }
  .back-blue{		/* 蓝色背景 */

  }
</style>

