<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search">
      <div class="flex"  v-if="!show" style="height: 95%">
        <criteria-paged :model="model" v-ref:paged >
          <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 like '%{}%'" placeholder="客户名称">
                </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 HH:mm:ss'"
                              :show-reset-button="true">
<!--                              condition="f_operate_date >=  to_date('{}','yyyy-mm-dd hh24:mi:ss')">-->
                  </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 HH:mm:ss'"
                              :show-reset-button="true">
<!--                              condition="f_operate_date <= to_date('{}','yyyy-mm-dd hh24:mi:ss')">-->
                  </datepicker>
                </div>
                <div class="span" style="float:right;">
                  <read-idcard></read-idcard>
                  <button class="button_search button_spacing" @click="search()">查询</button>
                  <button class="button_clear  button_spacing" @click="$parent.$parent.clear()">清空</button>

                  <export-excel :data="$parent.$parent.getCondition"
                                :field="$parent.$parent.getfield"
                                sqlurl="rs/logic/exportfile" sql-name="chargeQuery" template-name='收费查询导出'
                                v-if ="$parent.$parent.jurisdiction.includes('excel导出')"
                                :choose-col="true"></export-excel>

                  <print-data :model="$parent.model" :field="$parent.$parent.getfield"
                              :defaultfield="$parent.$parent.defaultfield" print-name="收费查询"
                              :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">
                <res-select-group style="col-sm-2 form-group" :initres="$parent.$parent.initres"  @re-res="$parent.$parent.getRes" v-ref:sel></res-select-group>
                <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 class="font_normal_body" style="text-align: center">用户<br/>所属公司</label>
                  <res-select restype='organization'
                              :search="false"
                              :is-mul="true"
                              @res-select="$parent.$parent.getRess">
                  </res-select>
                </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>
                <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_total_gas"
                         condition="f_total_gas like '%{}%'" placeholder='累购气量'>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="f_area_id" class="font_normal_body">小区编码</label>
                  <input id="f_area_id" type="text" style="width:60%" class="input_search" v-model="model.f_area_id"
                         condition="f_area_id = '{}'" placeholder='小区编码'>
                </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" title="参数:付款方式查询">付款方式</label>
                  <v-select :value.sync="model.f_payment" multiple
                            v-model="model.f_payment"
                            :options='$parent.$parent.payment' placeholder='请选择'
                            condition="f_payment in {}"
                            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_type"
                            v-model="model.f_type"
                            :options='$parent.$parent.chargetype' placeholder='请选择'
                            condition="f_type = '{}'"
                            close-on-select></v-select>-->
                  <v-select :value.sync="model.f_type" multiple
                            :options='$parent.$parent.chargetype' placeholder='请选择'
                            close-on-select clear-button
                            condition="f_type in {}"
                            v-model="model.f_type"></v-select>
                </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_user_mold"
                            @change="$parent.$parent.userMoldChange"
                            :options='$parent.$parent.usermold' placeholder='请选择' v-model="model.f_user_mold"
                            condition="f_user_mold = '{}'"
                            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.pricetype" v-model="model.pricetype"
                            placeholder='气价类型' :options="$parent.$parent.pricetypes"
                            close-on-select v-ref:type>
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">气价名称</label>
                  <v-select :value.sync="model.f_price_name"
                            v-model="model.f_price_name"
                            :options="$parent.$parent.getPricenames"
                            condition="f_price_name = '{}'"
                            close-on-select></v-select>
                </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_user_id"
                         condition="f_user_id = '{}'" placeholder='表编号'>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">气表类型</label>
                  <v-select :value.sync="model.f_meter_type" multiple
                            :options='$parent.$parent.metertypes' placeholder='请选择' v-model="model.f_meter_type"
                            condition="f_meter_type in {}"
                            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_brand" multiple
                            v-model="model.f_meter_brand"
                            :options='$parent.$parent.meterbrands' placeholder='请选择'
                            condition="f_meter_brand in {}"
                            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_state" multiple
                            v-model="model.f_state"
                            :options='$parent.$parent.charge_state' placeholder='请选择'
                            condition="f_state in {}"
                            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_bank_name"
                            v-model="model.f_bank_name"
                            :options='$parent.$parent.bank' placeholder='请选择'
                            condition="f_bank_name = '{}'"
                            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_privilege_money"
                            v-model="model.f_privilege_money"
                            :options='$parent.$parent.privilege_money' placeholder='请选择'
                            condition="f_privilege_money {}"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">下账状态</label>
                  <v-select :value.sync="$parent.$parent.accounts"
                            :options='$parent.$parent.accountsState'
                            :value-single = 'true'
                            placeholder='请选择' v-model="$parent.$parent.accounts"
                            close-on-select>
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">建档<br/>开始日期</label>
                  <datepicker id="startDate" placeholder="开始日期" style="width:60%"
                              v-model="model.create_startDate"
                              :value.sync="model.create_startDate"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="f_createfile_date >= to_date('{} 00:00:00','yyyy-mm-dd hh24:mi:ss')">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">建档<br/>结束日期</label>
                  <datepicker id="endDate" placeholder="结束日期" style="width:60%"
                              v-model="model.create_endDate"
                              :value.sync="model.create_endDate"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="f_createfile_date <= to_date('{} 23:59:59','yyyy-mm-dd hh24:mi:ss')">
                  </datepicker>
                </div>

                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">通气<br/>开始日期</label>
                  <datepicker placeholder="通气开始时间" style="width:60%"
                              v-model="model.f_gas_date"
                              :value.sync="model.f_gas_date"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="F_GAS_DATE >= to_date('{} 00:00:00','yyyy-mm-dd hh24:mi:ss')">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">通气<br/>结束日期</label>
                  <datepicker placeholder="通气结束时间" style="width:60%"
                              v-model="model.f_gas_dateend"
                              :value.sync="model.f_gas_dateend"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="F_GAS_DATE <= to_date('{} 23:59:59','yyyy-mm-dd hh24:mi:ss')">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group" v-if="$parent.$parent.jurisdiction.includes('0气量物联网')">
                  <label class="font_normal_body">&nbsp;&nbsp;&nbsp;0气量<br/>&nbsp;&nbsp;&nbsp;物联网</label>
                  <v-select :value.sync="$parent.$parent.debaohan"
                            v-model="$parent.$parent.debaohan"
                            :options='$parent.$parent.baohan' placeholder='请选择'
                            condition=" {} "
                            :search="false"
                            close-on-select></v-select>
                </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_serial_id"
                         condition=" f_serial_id like  '%{}%'" placeholder='表编号'>
                </div>

                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">是否<br/>手持设备</label>
                  <v-select :value.sync="$parent.$parent.f_outlets"
                            :options="$parent.$parent.isPos"
                            :search="false"
                            placeholder='请选择'
                            condition="{}"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">房产地址</label>
                  <input class="input_search" condition="f_house_address = '{}'"
                         placeholder='房产地址'
                         style="width:60%" type="text" v-model="model.f_house_address">
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">用途</label>
                  <input class="input_search" condition="f_property_usage = '{}'"
                         placeholder='用途'
                         style="width:60%" type="text" v-model="model.f_property_usage">
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">房型</label>
                  <input class="input_search" condition="f_house_type = '{}'"
                         placeholder='房型'
                         style="width:60%" type="text" v-model="model.f_house_type">
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">是否一户多表</label>
                  <input class="input_search" condition="f_is_multi_meter = '{}'"
                         placeholder='是否一户多表'
                         style="width:60%" type="text" v-model="model.f_is_multi_meter">
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">关联ID</label>
                  <input class="input_search" condition="f_house_id = '{}'"
                         placeholder='关联ID'
                         style="width:60%" type="text" v-model="model.f_house_id">
                </div>
              </div>
            </div>
          </criteria>

          <data-grid :model="model" partial='list' class="list_area table_sy" 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>
                  <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>{{row.f_operate_date}}</nobr>
              </td>
              <td style="text-align: center;"><nobr>
                <span @click="$parent.$parent.$parent.showmsg(row)"><a>{{row.f_userinfo_code}}</a></span>
              </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_user_type}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_user_mold}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_gasproperties}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_meternumber}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_times}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_total_gas}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_pregas}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_preamount}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_delaypay}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_charge_money}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_yucun}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_balance}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_collection}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_privilege_money}}</nobr>
              </td>


              <td style="text-align: center;">
                <nobr>{{row.f_curbalance}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_payment}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_serial_id}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.wxstate}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_bank_name}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_type}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_state}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.id}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_comments}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_describe}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.filltimes}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_operator}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_depname}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_outlets}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_orgname}}</nobr>
              </td>
                <td style="text-align: center;">
                    <nobr>{{$parent.$parent.$parent.checkPriceName(row)}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stairamount1}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair1price}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair1fee}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair2amount}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair2price}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair2fee}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair3amount}}</nobr>
                </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_stair3price}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_stair3fee}}</nobr>
                </td>
            </template>
            <template partial='foot'></template>
          </data-grid>
        </criteria-paged>
      </div>
      <table class="table-hover" style="height: auto">
        <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">
            气量合计:&emsp;{{sumsmodel.f_pregas}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            应交金额合计:&emsp;{{sumsmodel.f_preamount}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            机表清缴合计:&emsp;{{sumsmodel.f_charge_money}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            超用气量合计:&emsp;{{sumsmodel.overgas}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            超用气量金额合计:&emsp;{{sumsmodel.overgasprice}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            非民用气量合计:&emsp;{{sumsmodel.overount}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            非民用气量金额合计:&emsp;{{sumsmodel.overountprice}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            滞纳金合计:&emsp;{{sumsmodel.f_delaypay}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            预存金额合计:&emsp;{{sumsmodel.f_yucun}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            收款合计:&emsp;{{sumsmodel.f_collection}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            优惠合计:&emsp;{{sumsmodel.f_privilege_money}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            一阶气量合计:&emsp;{{sumsmodel.f_stairamount1}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            一阶气费合计:&emsp;{{sumsmodel.f_stair1fee}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            二阶气量合计:&emsp;{{sumsmodel.f_stair2amount}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            二阶气费合计:&emsp;{{sumsmodel.f_stair2fee}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            三阶气量合计:&emsp;{{sumsmodel.f_stair3amount}}
          </td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
            三阶气费合计:&emsp;{{sumsmodel.f_stair3fee}}
          </td>
        </tr>
      </table>
      <div v-if="show">
        <user-info-detail-manage :f_userinfo_id="rowdata.f_userinfo_id" @cancel-main="cancel"></user-info-detail-manage>
      </div>
      <div v-if="showAttachment">
        <attachment-viewer :business-id="currentRow && currentRow.id"  table-name="t_sellinggas" @close="closeAttachment"></attachment-viewer>
      </div>
    </div>
  </div>
</template>

<script>
  import {HttpResetClass, PagedList} from 'vue-client'
  import exportConfig from '../config/exportConfig'
  import * as Util from '../../../Util'
  import AttachmentViewer from './AttachmentViewer.vue'

  let readySomething = async function (self) {
    self.$refs.paged.$refs.cri.model.startDate = self.$login.toStandardDateString() + ' 00:00:00'
    self.$refs.paged.$refs.cri.model.endDate = self.$login.toStandardDateString() + ' 23:59:59'
    // self.$refs.paged.$refs.cri.search()
    self.defaultfield = [...self.defaultfield, ...self.config.defaultPrint]
    await self.$MagLoadParams.loadParam()
    self.initParams()
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
  }
  export default {
     components: {
      AttachmentViewer
     },
     data() {
      return {

        config: {
          defaultPrint: ['f_userinfo_code', 'f_address', 'f_pregas', 'f_preamount']
        },
        //f_price_name:[],
        gasproperties:[],
        usermold:[],
        showinfo: false,
        jurisdiction:this.$login.r,
        data: {},
        show:false,
        showAttachment: false,
        currentRow: null,
        rowdata:{},
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[]
        },
        initress: {
          org:[this.$login.f.orgid],
        },
        showComponent:['company'],
        filialeid:'',
        accounts:'非自动下账',
        accountsState:[{label:'全部',value:''},{label:'非自动下账',value:'非自动下账'},{label: '自动下账',value:'自动下账'}],
        model: new PagedList('rs/sql/chargeQuery', 20, {
          startDate: 'this.model.startDate',
          endDate:  'this.model.endDate'
        }, {
          f_pregas: 0,
          f_preamount: 0,
          overgas:0,
          overgasprice:0,
          overount:0,
          overountprice:0,
          f_charge_money:0,
          f_delaypay: 0,
          f_yucun :0,
          f_privilege_money: 0,
          f_collection: 0,
          f_stairamount1:0,
          f_stair1price:0,
          f_stair1fee:0,
          f_stair2amount:0,
          f_stair2price:0,
          f_stair2fee:0,
          f_stair3amount:0,
          f_stair3price:0,
          f_stair3fee:0,
        }),
        criteriaShow: false,
        orgCondtionStr: '',
        // 下拉框
        meterbrands: [],
        pricenames: [],
        prices: [],
        area: [],
        //合计数据
        defaultfield: [],
        condition:'',
        //小区
        residentialArea: [],
        sumsmodel: {},
        f_filialeid: this.$login.f.f_orgid,
        wxstate:[
          {label: '全部', value: ''},
          {label: '已退款', value: `= '3'`},
          {label: '未退款', value: `!= '3'`}
        ],
        privilege_money:[
          {label: '全部', value: ''},
          {label: '已优惠', value: '> 0'},
          {label: '未优惠', value: '= 0'}
        ],baohan:[
          {label: '全部', value: ''},
          {label: '是', value: '是'},
          {label: '否', value: '否'},
        ],
        f_outlets: '',
        isPos: [
          {label: '全部', value: ''},
          {label: '是', value: '是'},
          {label: '否', value: '否'},
        ]
      }
    },
    ready() {
      console.log("this.$login.r===>",this.$login.r)
      this.getaddress()


      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {

      async  getaddress(){
        console.log('开始获取小区')
        let HttpReset = new HttpResetClass()
        var data = await HttpReset.load('POST', 'rs/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
      },
      checkPriceName(row){
      return  row.f_price_name.indexOf('.')<0 && row.f_price_type==='固定气价'?row.f_price_name+(row.f_stairprice?row.f_stairprice:''):row.f_price_name
      },
      //把数据库查询数据转换为下拉数据
      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() {
        this.show = false
      },
      showmsg(obj){
        this.rowdata=obj
        this.show=true
      },
      userTypeChange () {
        this.usermold=[]
        this.f_gasproperties=[]
        if(this.$refs.paged.$refs.cri.model !== null) {
          this.$refs.paged.$refs.cri.model.f_gasproperties=''
          this.$refs.paged.$refs.cri.model.f_user_mold=''
          this.usermold = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_type[0])
        }
        else{
          this.usermold =[{label: '全部', value: ''}]
        }
      },
      userMoldChange () {
        this.gasproperties=[]
        if(this.$refs.paged.$refs.cri.model !==null) {
          this.$refs.paged.$refs.cri.model.f_gasproperties=''
          if (this.$refs.paged.$refs.cri.model.f_user_mold[0] ==='居民'){
            this.gasproperties = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_type[0] + this.$refs.paged.$refs.cri.model.f_user_mold[0])
            return
          }
          this.gasproperties = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_mold[0])
        }
        else{
          this.gasproperties =[{label: '全部', value: ''}]
        }
      },
      initParams() {
        // 初始化气表品牌
        let brandArr = []
        this.$MagGetSaleParam.getGasbrand().forEach((item) => {
          let temp = {}
          temp.label = item.label
          temp.value = item.value.f_meter_brand
          brandArr.push(temp)
        })
        this.meterbrands = [{label: '全部', value: ''}, ...brandArr]
        //初始化气表价格
        this.prices = this.$MagGetSaleParam.getPrices();
      },
      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.filialeid.length!==0){
          args.condition += ` and f_filialeid in ${this.filialeid}`
        }

        let f_orgstr = this.orgCondtionStr
        args.condition = `${args.condition} ` + f_orgstr
        if(this.accounts === '自动下账'){
          args.condition+= " and f_type = '自动下账'"
        }else if (this.accounts === '非自动下账'){
          args.condition+= " and f_type != '自动下账'"
        }
        if(this.jurisdiction.includes('0气量物联网')){
          if (this.debaohan[0] === '否'){
            args.condition+=' and (F_PREGAS is not null and  F_PREGAS != 0)'
          }else if (this.debaohan[0] === '是'){
            args.condition+=' and (F_PREGAS is  null or  F_PREGAS = 0)'
          }
        }
        if(this.f_outlets[0] === '是'){
          args.condition+= ` and f_outlets = '手持设备'`
        } else if (this.f_outlets[0] === '否'){
          args.condition+= ` and f_outlets is null`
        }
        this.condition = args.condition
        this.model.search(args.condition, args.model)
        this.sumsmodel = this.$refs.paged.$refs.grid.model.sums
      },
      clear() {
        //清空部门和人员
        this.$refs.paged.$refs.cri.$refs.sel.$children[1].selectres = []
        //部门和人员变为全选
        this.$refs.paged.$refs.cri.$refs.sel.$children[1].$children[0].isSelectAll = false
        this.$refs.paged.$refs.cri.$refs.sel.$children[2].$children[0].isSelectAll = false
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          this.$refs.paged.$refs.cri.model[key] = []
        })

      },
      dealmsg(val) {
        val.model = this.model.model
        this.$dispatch('deal-msg', val)
      },
      show() {
        this.criteriaShow = true
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      getRes(condition,obj) {
        this.orgCondtionStr = condition
        this.orgname = obj.orgnames[0]
        this.depname = obj.depnames[0]
      },
      getRess(obj,text) {
        this.filialeid = Util.convertToIn(obj);
      },

        async updateParams() {
        await this.$MagLoadParams.loadParam(this.f_filialeid)
        this.initParams()
      },
      view(row) {
        this.currentRow = row;
        this.showAttachment = true;
      },
      closeAttachment() {
        this.showAttachment = false;
      },
    },
    events:{
      'getidcard'(IdCard){
        console.log("IdCard-===")
        console.log(IdCard)
        // console.log(param)
        this.$refs.paged.$refs.cri.model.f_info_idnumber=IdCard.strID
      }
    },
    watch: {
      'model'(val) {
      },
      'orgCondtionStr'(val) {
        let res = val.match(/'(.*?)'/)
        console.log('正则提取:',res && res[1])
        if (res) {
          this.f_filialeid = res[1]
          this.updateParams()
        }
      }
    },
    computed: {
      getPricenames() {
        let f_user_type = this.$refs.paged.$refs.cri.model.f_user_type;
        let f_gasproperties = this.$refs.paged.$refs.cri.model.f_gasproperties;
        let pricetype = this.$refs.paged.$refs.cri.model.pricetype;
        console.log("打印一下:",f_user_type,f_gasproperties,pricetype,this.f_filialeid,this.prices)
        console.log("打印二下:",this.$refs.paged.$refs.cri.model)
        if(this.$refs.paged.$refs.cri.model !==null) {
          let rs = []
          let priceArr = []
          if ( pricetype.length >0) {
            let params = {
              f_price_type: pricetype[0],
              filter: this.f_filialeid,
              prices: this.prices
            }
            this.$MagGetSaleParam.getPrice(params).forEach((item) => {
              let temp = {}
              temp.label = item.label
              temp.value = item.value.f_price_name
              priceArr.push(temp)
            })
            rs = [{label: '全部', value: ''}, ...priceArr]
          }
          if (rs.length === 0) {
            console.log('rs读出来是空')
            this.$refs.paged.$refs.cri.model.f_price_name = ''
          }
          return rs
        }
      },
      getCondition() {
        return {condition: `${this.condition}`,  startDate:`${this.$refs.paged.$refs.cri.model.startDate}`,
          endDate:  `${this.$refs.paged.$refs.cri.model.endDate}`}
      },
      getfield() {
        return exportConfig.chargeConfig
      },
      pricetypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')]
      },

      usertypes() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('用户类型')]
      },
      metertypes() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('气表类型')]
      },

      tablestate() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('气表状态')]
      },
      chargetype() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('收费类型')]
      },
      payment() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('付款方式查询')]
      },
      charge_state() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('收费状态')]
      },
      bank(){
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('银行名称')]
      }
    }
  }
</script>

<style scoped>
</style>
