<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search">
      <div class="flex" v-if="!show">
        <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 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 >= '{}'">
                  </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 <= '{}'">
                  </datepicker>
                </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_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="span" style="float:right;">
                  <button class="button_search button_spacing" v-show="false" @click="$parent.$parent.ReadIDCard()">读取身份证</button>
                  <read-card :is-single.sync="$parent.$parent.isSingleUser" @read-info="$parent.$parent.cardBtn"  v-ref:readcard></read-card>
                  <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" :footer="$parent.$parent.footer"
                                :field="$parent.$parent.getfield" :header="$parent.$parent.other"
                                :defaultselect="$parent.$parent.defaultexport"
                                sqlurl="api/af-revenue/logic/openapi/exportfile" sql-name="chargeQuery" template-name='收费查询导出'
                                :choose-col="true">
                  </export-excel>

                  <print-data :sum-field="$parent.$parent.getfield" :model="$parent.model" :field="$parent.$parent.getfield"
                    :defaultfield="$parent.$parent.defaultfield"
                    titletable="缴费记录报表" :starthead="$parent.$parent.getstart"
                              :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">
                <res-select-group :show-component="$parent.$parent.resshow" :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.id"
                         condition="id = '{}'" 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 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">&nbsp;&nbsp;&nbsp;小区&nbsp;&nbsp;&nbsp;</label>
                  <v-select :value.sync="model.f_residential_area"
                            class="select_list select"
                            v-model="model.f_residential_area"
                            style="width: 60%"
                            multiple
                            condition="f_residential_area in {}"
                            :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" title="参数:支付渠道查询">支付渠道</label>
                  <v-select :value.sync="model.f_bank_type" multiple
                            v-model="model.f_bank_type"
                            :options='$parent.$parent.banktype' placeholder='请选择'
                            condition="f_bank_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_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_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">收&ensp;据&ensp;号</label>
                  <input type="text" style="width:30%" class="input_search" title="大于等于"
                         v-model="model.f_bill_number_big" condition="f_bill_number >= {}" placeholder='大于等于'>
                  <input type="text" style="width:30%" class="input_search" title="小于等于"
                         v-model="model.f_bill_number_small" condition="f_bill_number <= {}" 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_serial_id"
                         condition="f_serial_id = '{}'" 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_invoice_num"
                         condition="f_invoice_num = '{}'" placeholder='发票号码'>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body" title="发票类型查询">发票类型</label>
                  <v-select :value.sync="model.f_invoice_type"
                            v-model="model.f_invoice_type"
                            :options='$parent.$parent.invoiceType' placeholder='请选择'
                            condition="f_invoice_type = '{}'"
                            close-on-select :value-single="true" :search="false">
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">开&ensp;票&ensp;人</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_invoiceuse_operator"
                         condition="f_invoiceuse_operator like '%{}%'" placeholder='开票人'>
                </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.invoice_startDate"
                              :value.sync="model.invoice_startDate"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="f_invoice_date >= '{}'">
                  </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.invoice_endDate"
                              :value.sync="model.invoice_endDate"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="true"
                              condition="f_invoice_date <= '{}'">
                  </datepicker>
                </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"
                            :options='$parent.$parent.inputtores' placeholder='请选择'
                            condition="f_inputtor = '{}'"
                            close-on-select :search="false">
                  </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"
                            @change="$parent.$parent.inputtorchange"
                            :options='$parent.$parent.bookSlice' placeholder='片区/表册'
                            multiple
                            style="width:60%"
                            close-on-select
                            condition="f_book_slice_area in {}"></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">抄&ensp;表&ensp;册</label>
                  <v-select :value.sync="model.f_meter_book" v-model="model.f_meter_book"
                            :options='$parent.$parent.meterbooks' placeholder='抄表册'
                            multiple
                            style="width:60%"
                            close-on-select
                            condition="f_meter_book_num in {}"></v-select>
                </div>
                  <div class="col-sm-2 form-group">
                      <label class="font_normal_body">写卡状态</label>
                      <v-select :value.sync="model.f_write_card" v-model="model.f_write_card"
                                :options='$parent.$parent.writecard' placeholder='写卡状态'
                                style="width:60%"
                                close-on-select
                                condition="f_write_card = '{}'"></v-select>
                  </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">街&ensp;&ensp;&ensp;&ensp;道</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_street"
                         condition="f_street like '%{}%'" placeholder='街道'>
                </div>


              </div>
            </div>
          </criteria>

          <data-grid :model="model" partial='list' class="list_area table_sy" style="height: 95%" v-ref:grid>
            <template partial='head'>
              <tr>
                <th>
                  <nobr>收费编号</nobr>
                </th>
                <th>
<!--                  <nobr>客户编号</nobr>-->
                  <data-order field="f_userinfo_code" name="客户编号"
                              :order.sync="$parent.$parent.$parent.orderFields.f_userinfo_code"></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>-->
                  <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>-->
<!--&lt;!&ndash;                  <nobr>所属年月</nobr>&ndash;&gt;-->
                  <!--<data-order field="f_rest_date" name="所属年月"-->
                              <!--:order.sync="$parent.$parent.$parent.orderFields.f_rest_date"></data-order>-->

                <!--</th>-->
                <th>
<!--                  <nobr>收费日期</nobr>-->
                  <data-order field="f_operate_date" name="收费日期"
                              :order.sync="$parent.$parent.$parent.orderFields.f_operate_date"></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>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align: center;">
                <nobr>{{row.id}}</nobr>
              </td>
              <td style="text-align: center;"><nobr>
                <nobr>{{row.f_userinfo_code}}</nobr>
              </nobr> </td>
              <td style="text-align: center;">
                <nobr>{{row.f_street}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_book_slice_area}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_user_name}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_user_phone}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_zones}}</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_gasproperties}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_meternumber}}</nobr>
              </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_meter_brand}}</nobr>
                </td>
              <td style="text-align: center;">
                <nobr>{{row.f_card_id}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_times}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_pregas}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.fee}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_delaypay}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_preamount}}</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 v-if="row.f_meter_type === '物联网表'">{{row.f_balance_amount}}</nobr>
                <nobr v-else>{{row.f_balance}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_collection}}</nobr>
              </td>
              <!--<td style="text-align: center;">-->
                <!--<nobr>{{row.f_rest_date}}</nobr>-->
              <!--</td>-->
              <td style="text-align: center;">
                <nobr>{{row.f_operate_date}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_privilege_money}}</nobr>
              </td>


              <td style="text-align: center;">
                <nobr v-if="row.f_meter_type === '物联网表'">{{row.f_curbalance_amount}}</nobr>
                <nobr v-else>{{row.f_curbalance}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_payment}}</nobr>
              </td>
                <td style="text-align: center;">
                    <nobr>{{row.f_write_card}}</nobr>
                </td>
              <td style="text-align: center;">
                <nobr>{{row.f_bank_type}}</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_terminal_num}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_bluetooth_package}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_state}}</nobr>
              </td>

              <td style="text-align: center;">
                <nobr>{{row.f_comments}}</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_orgname}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_serial_id}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_bill_number}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_serial_number}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_invoice_num}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_invoice_type}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_invoiceuse_operator}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_invoice_date}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_write_money}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_corr_operator}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_corr_operate_date}}</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 - 0).toFixed(2)}}</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 - 0).toFixed(2)}}</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 - 0).toFixed(2)}}</nobr>
                </td>
              <td style="text-align: center;"><nobr>
                <button class="btn btn-link" @click.stop="$parent.$parent.$parent.view(row)">查看</button>
              </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_pregas}}
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              应交金额合计:&emsp;{{sumsmodel.fee}}
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              违约金合计:&emsp;{{sumsmodel.f_delaypay}}
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              燃气费合计:&emsp;{{sumsmodel.f_preamount}}
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              预存金额合计:&emsp;{{sumsmodel.f_yucun}}
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              收款合计:&emsp;{{sumsmodel.f_collection}}
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              优惠合计:&emsp;{{sumsmodel.f_privilege_money}}
            </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                  一阶气量合计:&emsp;{{sumsmodel.f_stairamount1}}
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                  一阶气费合计:&emsp;{{sumsmodel.f_stair1fee}}
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                  二阶气量合计:&emsp;{{sumsmodel.f_stair2amount}}
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                  二阶气费合计:&emsp;{{sumsmodel.f_stair2fee}}
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                  三阶气量合计:&emsp;{{sumsmodel.f_stair3amount}}
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
                  三阶气费合计:&emsp;{{sumsmodel.f_stair3fee}}
              </td>
          </tr>
        </table>
      </div>
      <!--<div v-if="show">-->
        <!--<user-info-detail-manage :f_userinfo_id="rowdata.f_userinfo_id" @cancel-main="cancel"></user-info-detail-manage>-->
      <!--</div>-->
    </div>
    <modal :show.sync="showupload" v-if="showupload" width="80%" style="width:auto;"  v-ref:modal middle backdrop="false">
      <article slot="modal-body">
        <upload :blodid="selected.f_userinfo_id" :businessid="selected.id" v-ref:upload isupload="false" takeimg="false"  fusetype="%收费" :isremark="false" style="width:auto" ></upload>
      </article>
      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
  </div>
  <high-meter-idcard :show.sync="false"  v-ref:highcard  ></high-meter-idcard>
</template>

<script>
  import {HttpResetClass, PagedList} from 'vue-client'
  import exportConfig from './exportConfig'
  let cardBtnGen = async function (self, val) {
    self.cardInfo = val.data

    // 判断读卡是否需要卡密码
    console.log('读卡上的信息', self.cardInfo)

    if (self.cardInfo.NewParam) {
      if (self.cardInfo.NewParam.error) {
        if (self.cardInfo.NewParam.error === '0001') {
          // 需要重新读卡并传卡密码
          if (self.model.rows.length == 1 && self.model.rows[0].f_alias === self.cardInfo.Factory) {
            self.readCardParam = self.model.rows[0].f_card_password
            self.cardInfo = await self.$refs.paged.$refs.cri.$refs.readcard.readCard2(self.model.rows[0].f_card_password)
          } else {
            self.$showAlert('此卡需要先获取客户信息。请通过条件查询该客户信息之后进行读卡！！', 'warning', 2000)
            return
          }
        }
      }
    }
    self.card=self.cardInfo.CardID
    self.search()
  }
  let readySomething = async function (self) {
    //加载抄表册
    self.initmeterbook();
    // 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.model.startDate = self.data ? self.data.startDate : self.$login.toStandardDateString() + ' 00:00:00'
    self.$refs.paged.$refs.cri.model.endDate = self.data ? self.data.endDate : self.$login.toStandardDateString() + ' 23:59:59'
    // self.$refs.paged.$refs.cri.model.f_state=['有效'];
    // self.$refs.paged.$refs.cri.search()
    self.initSlice(self.$login.f.orgid)
    self.defaultfield = [...self.defaultfield, ...self.config.defaultPrint]
    await self.$MagLoadParams.loadParam()
    self.initParams()
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums;
  }
  export default {
    props:['data'],
    title: '收费查询',
     data() {
      return {
        IdCardInfo:'',
        card:'',
        isSingleUser: null,
        startDate1:'',
        endDate1:'',
        resshow:['company','department','operator','slicearea'],
        other:[],

        footer:[],
        config: {
          defaultPrint: ['f_userinfo_code', 'f_user_name', 'f_pregas', 'f_collection', 'f_stairamount1', 'f_stair2amount', 'f_stair3amount']
        },
        //排序
        orderitem:'f_operate_date desc',
        orderFields: {
          f_operate_date: 'no'
        },
        //f_price_name:[],
        gasproperties:[],
        showinfo: false,
        data: {},
        getstart:'',
        show:false,
        rowdata:{},
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[]
        },
        model: new PagedList('api/af-revenue/sql/chargeQuery', 20, {orderitem: this.orderitem?'"' + this.orderitem + ' "':`'f_operate_date desc'`},{
          f_pregas: 0,
          f_preamount: 0,
          f_delaypay: 0,
          fee:0,
          f_yucun:0,
          f_privilege_money: 0,
          f_collection: 0,
          f_stairamount1:0,
          f_stair1fee:0,
          f_stair2amount:0,
          f_stair2fee:0,
          f_stair3amount:0,
          f_stair3fee:0,
        }),
        criteriaShow: false,
        orgCondtionStr: '',
        // 下拉框
        meterbrands: [],
        pricenames: [],
        prices: [],
        area: [],
        //默认打印列
        defaultfield: [],
        //小区
        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'}
        ],
        showupload:false,
        selected:{},
        meterbooks:[{label: '全部',value: ''}],  //抄表册
        inputtores:[{label: '全部',value: ''}],
        writecard:[{label: '全部',value: ''},{label: '已写卡',value: '已写卡'},{label: '未写卡',value: '未写卡'}],
        //表册片区
        bookSlice:[{label: '全部',value: ''}],
        allorgid:[],
        tempfalg :false,
        lastorgstr:'',
      }
    },
    ready() {
      this.$refs.paged.$refs.cri.model.f_state=['有效']
      this.getaddress()
      //加载抄表册
      this.$MagGetSaleParam.initinputtor();
      this.getinputtores();
      // this.initres.dep.push(this.$login.f.depids)
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      ReadIDCard(){
        this.$refs.highcard.sendMsg(this.$refs.highcard.CLT_MSG.READ_IDCARD, (msg) => {
          console.log('======',msg)
          if(msg.err !== 0){ return}
          this.IdCardInfo=msg.strID
        })
        if(this.IdCardInfo) {
          this.search()
        }else{
          alert("读取失败，找不到用户信息")
        }
      },
      cardBtn (val) {
        // this.clear()
        cardBtnGen(this, val)
      },
      async initmeterbook(orgstr){
        if(orgstr == null ){
          orgstr = this.f_filialeid;
        }
        //获取新的抄表册,先去清理所有的抄表册
        this.$GetSaleParam.meterbooks = [];
        //开始加载新的抄表册
        await this.$LoadParams.loadMeterBook(orgstr)
        this.meterbooks = [{label: '全部', value: ''}, ...this.$GetSaleParam.getMeterBooks()]
      },
      //初始化片区
      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 = []
          arr.forEach((res) => {
            this.bookSlice.push({label: res.name, value: res.name})
          })
        }
      },
      //表册片区和抄表册关联
      async inputtorchange(){
        this.$set('$refs.paged.$refs.cri.model.f_meter_book',[]);
        /*let val1=this.$refs.paged.$refs.cri.model.f_meter_book*/
        let val2=this.$refs.paged.$refs.cri.model.f_book_slice_area
        if((val2.length>0)){
          let condition = ` 1=1 and f_orgid ='${this.f_filialeid}' and f_book_state='有效' `
          let aaa = '('
          val2.forEach((item) => {
            aaa = aaa + `'${item}',`
          })
          aaa = aaa + `'')`
          condition = condition + ` and f_book_slice_area in ${aaa} `
          let param={
            items:'*',
            tablename:'t_meter_book',
            condition:condition,
            orderitem:'id'
          }
          let getMeterBooks = await this.$resetpost('api/af-revenue/sql/singleTable_OrderBy', {data: param}, {resolveMsg: null, rejectMsg: '获取营收参数出错！！！'})
          if (getMeterBooks.data) {
            if(getMeterBooks.data.length >0){
              let rs = [];
              getMeterBooks.data.forEach((item)=>{
                let temp = {
                  label:item.f_book_name,
                  value:item.id
                };
                rs.push(temp);

              })
              this.meterbooks = [{label: '全部',value: ''}, ...rs];
            }else{
              this.meterbooks = [{label: '全部',value: ''}];
            }
          }
        }else{
          this.meterbooks = [{label: '全部',value: ''}];
          this.initmeterbook();
        }
      },
      async initmeterbook(orgstr){
        if(orgstr == null ){
          orgstr = this.f_filialeid;
        }
        //获取新的抄表册,先去清理所有的抄表册
        this.$GetSaleParam.meterbooks = [];
        //开始加载新的抄表册
        await this.$LoadParams.loadMeterBook(orgstr)
        this.meterbooks = [{label: '全部', value: ''}, ...this.$GetSaleParam.getMeterBooks()]
      },
      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]
      },
       //显示附件
      view(row){
        this.showupload = true
        this.selected= row
      },
      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.getfield;
        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(){
        let HttpReset = new HttpResetClass()
        var data = await HttpReset.load('POST', 'api/af-revenue/sql/manage_getarealist', {
          data: {
            condition: `1=1 and s.f_orgid = '${this.$login.f.orgid}'`
          }
        }, {resolveMsg: null, rejectMsg: '获取小区失败!'})
        console.log('小区',data)
        let house = [{label: '全部', value: ''}]
        for (let row of data.data){
          house.push({label: row.f_residential_area, value: row.f_residential_area})
        }
        this.residentialArea = house
      },
      //把数据库查询数据转换为下拉数据
      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.gasproperties=[]
        if(this.$refs.paged.$refs.cri.model !==null) {
          this.$refs.paged.$refs.cri.model.f_gasproperties=''
          this.gasproperties = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_type[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) {
        debugger
        if (this.data) {
          this.$parent.$parent.$parent.data.startDate=this.$refs.paged.$refs.cri.model.startDate
          this.$parent.$parent.$parent.data.endDate=this.$refs.paged.$refs.cri.model.endDate
        }

        let f_orgstr = this.orgCondtionStr
        args.condition = `${args.condition} ` + f_orgstr
        if(this.card!=''){
            args.condition+=` and f_card_id='${this.card}'`
        }
        if(this.IdCardInfo!=''){
          args.condition +=` and f_idnumber='${this.IdCardInfo}'`
        }
        this.model.search(args.condition, args.model)
        this.sumsmodel = this.$refs.paged.$refs.grid.model.sums;
        this.card=''
        this.IdCardInfo=''
      },
      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,startDate,endDate) {
        val.model = this.model.model
        startDate=this.startDate1
        endDate=this.endDate1
        this.$dispatch('deal-msg', val,startDate,endDate)
      },
      show() {
        this.criteriaShow = true
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      async getRes(condition,obj) {
        this.orgCondtionStr = condition
        this.orgname = obj.orgnames[0]
        this.depname = obj.depnames[0]


      },
      async updateParams() {
        await this.$MagLoadParams.loadParam(this.f_filialeid)
        this.inputtores = [];
        this.initSlice(this.f_filialeid)
        this.inputtores.push({label: "全部", value: ""})
        if(this.allorgid!=null){
          this.allorgid.forEach((res)=>{
            this.inputtores = this.inputtores.concat(this.$MagGetSaleParam.getresinputtor(res));
          })
        }
        this.initParams()
      },
      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()
      }

    },
    events:{
      'getidcard'(IdCard){
        // console.log(param)
        this.$refs.paged.$refs.cri.model.f_info_idnumber=IdCard.strID
      }
    },
    watch: {
      'model.rows'(val) {
        if(val.length === 0){
          this.sumsmodel = {}
        }
      },
      'model.rows.length' () {
        this.isSingleUser = this.model.rows
      },
      async 'orgCondtionStr'(val) {
        //更新抄表册
        this.$refs.paged.$refs.cri.model.f_inputtor=[]
        this.$refs.paged.$refs.cri.model.f_book_slice_area=[]
        this.$refs.paged.$refs.cri.model.f_meter_book = []
        this.meterbooks = [{label: '全部',value: ''}];
        if(this.lastorgstr != val){
          this.tempfalg = true;
          this.lastorgstr = val;
        }
        if(this.tempfalg && val != null && val!=''  && val.indexOf("(")>-1){
          this.tempfalg = false;
          let a = val.substring(val.indexOf("(")+2)
          await this.initmeterbook(a.substring(0,a.indexOf(")")-1));
        }
        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()
        }
      },
      sumsmodel:{
        handler: function(val) {
          this.getotherfooter();
        },
        deep: true
      }
    },
    computed: {
      getstart(){
        return `开始时间：${this.$refs.paged.$refs.cri.model.startDate} 结束时间：${this.$refs.paged.$refs.cri.model.endDate}`
      },
         chooserow(){
             let aaa= true
             if(this.$login.r && this.$login.r.includes('打印项选择')){
                 aaa =  false
             }
             return aaa
         },
      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)
        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 {
          startDate: this.$refs.paged.$refs.cri.model.startDate,
          endDate: this.$refs.paged.$refs.cri.model.endDate,
          condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr,
          orderitem: this.orderitem?`${this.orderitem}`: " f_operate_date desc"
        }
      },
      getfield() {
        return exportConfig.chargeConfig
      },
      defaultexport() {
          return exportConfig.chargeexportConfig
      },
      pricetypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')]
      },

      invoiceType() {
        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 [...this.$appdata.getParam('付款方式查询')]
      },
      banktype() {
        return [...this.$appdata.getParam('支付渠道查询')]
      },
      charge_state() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('收费状态')]
      },
      bank(){
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('银行名称')]
      }

    }
  }
</script>
