<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search" v-if="!show">
      <div class="flex">

        <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 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_input_date >= '{}'">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="endDate" class="font_normal_body">&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;&ensp;</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_input_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 = '{}'" placeholder="客户名称">
                </div>
                <div class="span" style="float:right;">
                  <button class="button_search button_spacing" @click="search()">查询</button>
                  <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>

                  <button class="btn btn-default" @click="$parent.$parent.Fileinput()">反盘导入</button>
                  <export-excel :data="$parent.$parent.getCondition"
                                :field="$parent.$parent.getBankfield" :header="$parent.$parent.other"
                                sqlurl="rs/logic/exportfile" sql-name="newhandplanQuery" template-name='送盘导出' btn-name="送盘导出"
                                :choose-col="true"></export-excel>
                  <export-excel :data="$parent.$parent.getCondition" :footer="$parent.$parent.footer"
                                :field="$parent.$parent.getfield" :header="$parent.$parent.other"
                                sqlurl="rs/logic/saleExport" sql-name="salehandplanQuery" 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" print-name="抄表查询打印"
                              titletable="抄表查询"
                              :sumsmodel="$parent.$parent.sumsmodel"></print-data>

                  <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                </div>
              </div>
              <div class="row" v-show="$parent.$parent.criteriaShow">
                <res-select-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>
                  <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">楼&emsp;栋&emsp;</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_building"
                         condition="f_building like '%{}%'" placeholder="楼栋">
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户地址</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>
                  <v-select :value.sync="model.f_meter_state"
                            v-model="model.f_meter_state"
                            :options='$parent.$parent.meterstate' placeholder='请选择'
                            condition="f_meter_state = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">表单状态</label>
                  <v-select :value.sync="model.f_hand_state"
                            v-model="model.f_hand_state"
                            :options='$parent.$parent.handstate' placeholder='请选择'
                            condition="f_hand_state = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">录入人员</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_input_person"
                         condition="f_input_person like '%{}%'" placeholder='录入人员'>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">是否缴费</label>
                  <v-select :value.sync="model.f_whether_pay"
                            v-model="model.f_whether_pay"
                            :options='$parent.$parent.whetherPay' placeholder='请选择'
                            condition="f_whether_pay = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">&ensp;壁挂炉&ensp;</label>
                  <v-select :value.sync="model.f_bgl"
                            v-model="model.f_bgl"
                            :options='$parent.$parent.bgl' placeholder='请选择'
                            condition="f_bgl = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户类型</label>
                  <v-select :value.sync="model.f_user_type"
                            @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">下账状态</label>
                  <v-select :value.sync="model.f_accounts_state"
                            :options='$parent.$parent.accountsState' placeholder='请选择' v-model="model.f_accounts_state"
                            condition="f_accounts_state = '{}'"
                            close-on-select></v-select>
                </div>

                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">气表品牌</label>
                  <v-select :value.sync="model.f_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">用&ensp;气&ensp;量</label>
                  <input type="text" style="width:30%" class="input_search" title="大于等于"
                         v-model="model.f_oughtamount_big" condition="f_oughtamount >= {}" placeholder='大于等于'>
                  <input type="text" style="width:30%" class="input_search" title="小于等于"
                         v-model="model.f_oughtamount_small" condition="f_oughtamount <= {}" placeholder='小于等于'>
                </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.prices"-->
                <!--                            condition="f_price_name = '{}'" close-on-select></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_meternumber"
                         condition="f_meternumber = '{}' " placeholder="表号">
                </div>
                <div class="col-sm-2 form-group">
                  <label for="startDate" class="font_normal_body">下发日期</label>
                  <datepicker id="handStartDate" placeholder="开始日期" style="width:60%"
                              v-model="model.handStartDate"
                              :value.sync="model.handStartDate"
                              :format="'yyyy-MM-dd 00:00:00'"
                              :show-reset-button="true"
                              condition="f_hand_date >= '{}'">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="endDate" class="font_normal_body">&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;</label>
                  <datepicker id="handEndDate" placeholder="结束日期" style="width:60%"
                              v-model="model.handEndDate"
                              :value.sync="model.handEndDate"
                              :format="'yyyy-MM-dd 23:59:59'"
                              :show-reset-button="true"
                              condition="f_hand_date <= '{}'">
                  </datepicker>
                </div>

                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">抄&ensp;表&ensp;员</label>
                  <v-select :value.sync="model.f_inputtor" v-model='model.f_inputtor'
                            style="width:60%"
                            multiple="true"
                            :options='$parent.$parent.inputtores' placeholder='抄表员'
                            condition="f_inputtor = '{}'"
                            close-on-select
                            v-el:cc></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"
                            multiple
                            :options='$parent.$parent.bookSlice' placeholder='片区/表册'
                            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='抄表册'
                            style="width:60%"
                            multiple
                            close-on-select
                            condition="f_meter_book_num in {}"></v-select>
                </div>
                <div class="col-sm-2 form-group" >
                  <label for="belongmonth" class="font_normal_body" >所属年月</label>
                  <datepicker placeholder="所属年月" style="width:60%"
                              v-model="model.belongmonth"
                              :value.sync="model.belongmonth"
                              :format="'yyyy-MM'"
                              :show-reset-button="true"
                              condition="belongmonth = '{}'"
                              :select-month="true">
                  </datepicker>
                </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.banklist' placeholder='银行名称'
                            style="width:60%"
                            close-on-select
                            condition="f_bank_name = '{}'"></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="startDate" class="font_normal_body">收费日期</label>
                  <datepicker id="handStartDate" placeholder="开始日期" style="width:60%"
                              v-model="model.sellStartDate"
                              :value.sync="model.sellStartDate"
                              :format="'yyyy-MM-dd 00:00:00'"
                              :show-reset-button="true"
                              condition="f_sellinggas_operate_date >= '{}'">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="endDate" class="font_normal_body">&nbsp;&nbsp;&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;</label>
                  <datepicker id="handEndDate" placeholder="结束日期" style="width:60%"
                              v-model="model.sellEndDate"
                              :value.sync="model.sellEndDate"
                              :format="'yyyy-MM-dd 23:59:59'"
                              :show-reset-button="true"
                              condition="f_sellinggas_operate_date <= '{}'">
                  </datepicker>
                </div>
              </div>
            </div>
          </criteria>

          <data-grid :model="model" partial='list' class="list_area table_sy"  v-ref:grid :classname="$parent.classname">
            <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>
                <th>
                  <nobr>公司</nobr>
                </th>
                <th><nobr>附件</nobr></th>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align: center;">
                <nobr>
                  <span @click="$parent.$parent.$parent.dealmsg(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_zones}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_book_slice_area}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_address}}</nobr>
              </td>

              <td style="text-align: center;">
                <nobr>{{row.phone}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_meternumber}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.ym_data}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_last_tablebase}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_tablebase}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_oughtamount}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_oughtfee}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_debt_money}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_actual_arrears}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_privilege_money}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_balance}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_curbalance}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_accounts_state}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_sellinggas_operate_date}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_sell_operator}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_corrhand_date}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_corrhand_operator}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_hand_date}}</nobr>
              </td>
              <td>
                <nobr>{{row.belongmonth}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_input_date}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_price_name}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_stair1amount}}</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>
              <td style="text-align: center;">
                <nobr>{{row.dd}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_inputtor}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_input_person}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_whether_pay}}</nobr>
              </td>

              <td style="text-align: center;">
                <nobr>{{row.f_meter_state}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_hand_state}}</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>
                <button class="button_search button_spacing width-60" @click.stop="$parent.$parent.$parent.view(row)">查看</button>
                <button v-if="row.f_notified_path" class="button_search button_spacing width-60" @click.stop="$parent.$parent.$parent.imgShow(row.f_notified_path)">图像识别</button>
              </nobr></td>
            </template>
            <template partial='foot'></template>
          </data-grid>
        </criteria-paged>

        <table class="table-hover">
          <tr style="position: relative;margin-top: -16px;" 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_oughtamount}}-->
            <!--            </td>-->
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              气费合计:&emsp;{{sumsmodel.f_oughtfee}}-->
            <!--            </td>-->
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              已交金额合计:&emsp;{{sumsmodel.f_debt_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_actual_arrears}}
            </td>
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              一阶气量合计:&emsp;{{sumsmodel.f_stair1amount}}-->
            <!--            </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>-->
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              剩余气量合计:&emsp;{{sumsmodel.f_surplus_gas}}-->
            <!--            </td>-->
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              扣减气量合计:&emsp;{{sumsmodel.f_haircut_gas}}-->
            <!--            </td>-->
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              应交气量合计:&emsp;{{sumsmodel.f_oughtamount}}-->
            <!--            </td>-->
            <!--            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">-->
            <!--              已交气费金额合计:&emsp;{{sumsmodel.alloughtfee}}-->
            <!--            </td>-->
          </tr>
        </table>
      </div>
      <modal :show.sync="batchmoneyShow" width="500px" title="反盘导入" v-ref:modal large backdrop="false">
        <article slot="modal-body" class="modal-body">
          <file-upload class="my-file-uploader" name="useraddressUploadFile" action="rs/file/uploadFile" tagname="确定" multiple v-ref:file></file-upload>
        </article>
        <footer slot="modal-footer" class="modal-footer">
        </footer>
      </modal>
    </div>
    <div class="flex" v-if="show">
      <user-info-detail-manage-new :f_userinfo_code="rowdata.f_userinfo_code" @cancel-main="cancel"></user-info-detail-manage-new>
    </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>
    <modal :show.sync="imgshow" v-ref:modal backdrop="true">
      <header slot="modal-header" class="modal-header">
        抄表图像识别照片
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="from-group">
          <img-self :src="imgfilename"   width="500" height="500"></img-self>
        </div>
      </article>
    </modal>

    <modal :show.sync="progressShow" v-ref:modal backdrop="true"  width="50%" style="width:auto;" >
      <header slot="modal-header" class="modal-header">
        反盘导入
      </header>
      <article slot="modal-body" class="modal-body">
        <div class="progress" style="margin: 20px" >
          <div class="progress-bar progress-bar-success progress-bar-striped active" :style="{width: percent+'%'}">
            {{percent}}%
          </div>
        </div>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-default" @click='progressclose'>关闭</button>
      </footer>
    </modal>
    <work-busy :is-busy="iswork" v-show="iswork"></work-busy>
  </div>
</template>

<script>
  import {PagedList, HttpResetClass} from 'vue-client'


  import axios from 'axios'

  let readySomething = async function (self) {
    //加载抄表册

    await self.$LoadParams.loadMeterBook(self.f_filialeid)
    self.loadMeterBooks()
    // await self.$LoadParams.loadMeterBook(self.f_filialeid)
    // self.loadMeterBooks()
    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.startDate = self.$login.toStandardDateString() + ' 00:00:00'
    // self.$refs.paged.$refs.cri.model.endDate = self.$login.toStandardDateString() + ' 23:59:59'
    // await self.$refs.paged.$refs.cri.search()
    await self.$getConfig(self, 'HandplanQuery')
    self.defaultfield = [...self.defaultfield, ...self.config.defaultPrint]
    await self.$LoadParams.loadParam()
    self.initParams()
    console.log('开始查询')
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
  }
  export default {
    props:['data'],
    title: '机表抄表查询',
    data() {
      return {
        iswork:false,
        other:[],
        footer:[],
        data: {},
        model: new PagedList('rs/sql/salehandplanQuery', 20, {}, {
          // f_oughtamount: 0,
          // f_oughtfee: 0,
          // f_debt_money: 0,
          f_actual_arrears: 0,
          // f_stair1amount: 0,
          // f_stair1fee: 0,
          // f_stair2amount: 0,
          // f_stair2fee: 0,
          // f_stair3amount: 0,
          // f_stair3fee: 0,
          // f_surplus_gas: 0,
          // f_haircut_gas: 0
          // , alloughtfee:0
        }),
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[],
        },
        show:false,
        rowdata:{},
        criteriaShow: false,
        residentialArea: [],
        orgCondtionStr: '',
        modelval: [],
        gasproperties:[],
        inputtouPerson: [],
        meterbrands: [],
        printshow: false,
        f_filialeid: this.$login.f.f_orgid,
        all: false,
        fields: {},
        thead: '',
        tfoot: '',
        showupload:false,
        selected:{},

        // 下拉框

        //合计数据
        sumsmodel: {},
        defaultfield: [],
        config: {
          defaultPrint1:[
            "f_userinfo_code","f_user_name","f_user_phone","f_pregas","f_preamount","f_collection","f_balance","f_curbalance","f_idnumber"
          ],
          defaultPrint: ['f_userinfo_code', 'f_address', 'f_user_name', 'f_meternumber'],
          excelHeaders:{'f_userinfo_code': '客户编号', 'f_user_name': '客户名称', 'f_address': '客户地址', 'f_zones': '片区','phone': '客户手机', 'f_meternumber': '表号','ym_data': '数据年月',
            'f_last_tablebase': '上期底数', 'f_tablebase': '本期底数', 'f_oughtamount': '用气量', 'f_oughtfee': '用气金额', 'f_debt_money': '已交金额',
            'f_actual_arrears': '欠费金额','f_balance': '上期余额','f_curbalance': '本期余额',
            'f_accounts_state': '下账状态', 'f_sellinggas_operate_date': '收费时间', 'f_inputtor': '抄表员', 'f_book_slice_area': '表册片区',
            'f_hand_date': '下发日期', 'f_input_date': '录入日期', 'f_meter_state': '抄表状态', 'f_hand_state': '记录状态',
            'f_operator': '操作员', 'f_depname': '部门', 'f_orgname': '公司', 'f_surplus_gas': '剩余气量', 'f_haircut_gas': '扣减气量',
            'f_stair1amount': '一阶气量', 'f_stair1price': '一阶单价', 'f_stair1fee': '一阶气费',
            'f_stair2amount': '二阶气量', 'f_stair2price': '二阶单价', 'f_stair2fee': '二阶气费',
            'f_stair3amount': '三阶气量', 'f_stair3price': '三阶单价', 'f_stair3fee': '三阶气费', 'f_rest_date': '所属年月'}
        },
        batchBankConfig2:{'f_userinfo_code': '客户编号', 'f_userinfo_id': '用户编号', 'phone': '客户电话', 'f_user_name': '客户姓名', 'f_address': '客户地址',
          'f_bank_accopen': '银行户名', 'f_bank_pay_number': '缴费编号', 'f_bank_account': '银行开户账号', 'f_paper_account': '开户行及账号',
          'f_bank_name': '银行名称', 'f_oughtfee': '欠费金额','f_balance': '上期余额'},
        batchmoneyShow:false,
        prices: [],
        bgl:[{label: '全部', value: ''},{label: '有', value: '1'},{label: '无', value: '0'}],
        meterbooks:[{label: '全部',value: ''}],  //抄表册
        tempfalg :false,
        lastorgstr:'',
        allorgid:[],
        inputtores:[{label: '全部',value: ''}],  //抄表员
        //表册片区
        bookSlice:[{label: '全部',value: ''}],
        imgshow:false,
        imgfilename:'',
        percent:0,
        progressShow:false,
        uuida:'',
        timer:'',
      }
    },
    ready() {
      this.getaddress()
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      loadMeterBooks () {
        this.meterbooks = [...this.meterbooks, ...this.$GetSaleParam.getMeterBooks()]
      },
      getuuid(){
        let uuidA = '';
        var s = [];
        var hexDigits = '0123456789abcdef';
        for (var i = 0; i < 36; i++) {
          s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        }
        s[14] = '4';
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
        s[8] = s[13] = s[18] = s[23] = '-';
        uuidA = s.join('');
        this.uuida = uuidA;
      },
      progressclose(){
        this.progressShow = false;
        if(this.timer != null){
          clearInterval(this.timer);
        }
      },
      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('rs/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 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]
        this.inputtores.push({label: "微信公众号", value: "微信公众号"})
      },
      async updateParams() {
        await this.$LoadParams.loadParam(this.f_filialeid)
        this.inputtores = [];
        this.inputtores.push({label: "全部", value: ""})
        this.initSlice(this.f_filialeid)
        if(this.allorgid!=null){
          this.allorgid.forEach((res)=>{
            this.inputtores = this.inputtores.concat(this.$GetSaleParam.getresinputtor(res));
          })
        }
        this.initParams(this.f_filialeid)
      },
      view(row){
        this.showupload = true
        this.selected= row
      },
      imgclose(){
        this.imgshow = false
      },
      imgShow(val){
        this.imgfilename = `rs/image/file/`+val
        this.imgshow = true
      },
      initParams() {
        // 初始化气表品牌
        let brandArr = []
        this.$GetSaleParam.getGasbrand().forEach((item) => {
          let temp = {}
          temp.label = item.label
          temp.value = item.value.id
          brandArr.push(temp)
          // // 取出对应气表型号
          // let styleArr = []
          // for (let row of item.value.gasmodel) {
          //   styleArr.push({label: row.label, value: row.value.id})
          // }
          // this.meterstyle[temp.value] = styleArr
        })
        this.meterbrands = [{label: '全部', value: ''}, ...brandArr]
        // 初始化气表价格
        this.prices = this.$GetSaleParam.getPrice(this.$login.f.orgid)
      },
      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', 'rs/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
      },
      Fileinput(){
        this.batchmoneyShow=true;
      },
      search(){
        this.$refs.paged.$refs.cri.search()
      },
      cancel() {
        this.show = false
      },
      selfSearch(args) {
        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
        }
        this.area =  this.$refs.paged.$refs.cri.model.f_residential_area
        if(this.area.length !== 0){
          let str = JSON.stringify(this.area)
          str = str.replace(/"/g,`'`)
          str = str.replace(/\[/g,``)
          str = str.replace(/\]/g,``)
          //查询多个小区时条件
          args.condition += ` and f_residential_area in  ( ${str} )`
        }
        //抄表员查询条件
        this.inputtouPerson = this.$refs.paged.$refs.cri.model.f_inputtor
        if(this.inputtouPerson.length !== 0){
          let str = JSON.stringify(this.inputtouPerson)
          str = str.replace(/"/g,`'`)
          str = str.replace(/\[/g,``)
          str = str.replace(/\]/g,``)
          //查询多个抄表员时条件
          args.condition += ` and f_inputtor in  ( ${str} )`
        }

        args.condition = `${args.condition} and f_meter_classify = '机表' ` + this.orgCondtionStr
        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] = []
        })
        this.$refs.paged.$refs.cri.model.f_meter_classify = []
      },
      show() {
        this.criteriaShow = true
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      async getRes(condition,obj) {
        console.log("condition:----------",condition)
        console.log("obj:----------",obj)
        this.orgCondtionStr = condition

      },
      stamp() {
        this.all = false
        //默认选择要打印的列
        this.modelval = this.defaultPrint1
        this.fields = this.getfield
        this.printshow = true
        this.put()
      },
      put() {
        // 对Modelval进行排序
        this.sortModelval()
        this.thead = `<tr><th colspan=${this.modelval.length}>抄表查询统计报表</th></tr><tr>`
        for (let key of this.modelval) {
          this.thead += '<th>' + this.fields[key] + '</th>'
        }
        this.thead += '</tr>'
      },
      print() {
        this.$refs.print.PrintAsFile()
        this.printshow = false
      },
      dealmsg(val) {
        this.rowdata=val
        this.show=true
        val.model = this.model.model
        this.$dispatch('deal-msg', val)
      },
      close() {
        this.printshow = false
        this.all = false
      },

      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: ''}]
        }
      },
      // 对选择的列进行排序
      sortModelval() {
        let sortModel = []
        Object.keys(this.fields).forEach((key) => {
          if (this.modelval.includes(key)) {
            sortModel.push(key)
          }
        })
        this.modelval = sortModel
      }
    },
    watch: {
      'model.rows'(val) {
        if(val.length === 0){
          this.sumsmodel = {}
        }
      },
      // async 'orgCondtionStr'(val) {
      //   console.log("-----------准备加载抄表员了",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()
        // }
      // },
      'all'(val) {
        if (val) {
          this.modelval = this.bodyData
        } else {
          this.modelval = this.defaultPrint1
          this.put()
        }
      },
      'modelval.length'() {
        this.put()
      },
      sumsmodel:{
        handler: function(val) {
          this.getotherfooter();
        },
        deep: true
      }
    },
    computed: {
      banklist() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('银行名称')]
      },
      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 + "and f_meter_classify = '机表'"
        }
      },
      getfield() {
        return this.config.excelHeaders
      },
      getBankfield(){
        return this.config.batchBankConfig2
      },
      usertypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用户类型')]
      },
      accountsState() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('下账状态')]
      },
      meterstate() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('抄表状态')]
      },
      handstate() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('表单状态')]
      },
      // inputtor() {
      //   return [{label: '全部', value: ''}, ...this.$appdata.getParam('抄表员')]
      // },
      pricetypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')]
      },
      getPricenames () {
        let f_filialeid = this.f_filialeid
        let result = []
        this.$GetSaleParam.prices.forEach((item) => {
          if (item.f_state === '有效' && f_filialeid == item.f_filialeid) {
            let value = {
              label: item.f_price_name,
              value: item
            }
            result.push(value)
          }
        })
        return Array.from(new Set(result))
      },
      inputtores () {
        // 获取抄表员
        console.log('获取抄表员', this.$login.f)
        let rs = []
        if (this.$login.f.f_gasman.length > 0) {
          for (let i = 0; i < this.$login.f.f_gasman.length; i++) {
            let temp = {
              label: this.$login.f.f_gasman[i].name,
              value: this.$login.f.f_gasman[i].name
            }
            rs.push(temp)
          }
        }
        return [...rs]
      },
      whetherPay() {
        return [{label: '全部', value: ''},{label: '是', value: '是'},{label: '否', value: '否'}]
      },

    },
    events:{
      'onFileUpload': async function (file, res) {
        if (this.batchmoneyShow) {
          this.percent = 0;
          this.getuuid();
          let param = {
            filepath: res.f_downloadpath,
            f_operator: this.$login.f.name,
            f_operatorid: this.$login.f.id,
            f_orgid: this.$login.f.orgid,
            f_orgname: this.$login.f.orgs,
            f_depid: this.$login.f.depids,
            f_depname: this.$login.f.deps,
            uuid: this.uuida
          }
          this.batchmoneyShow=false;
          try{
            await this.$resetpost('rs/logic/SumSettleFileImport',{data: param},{resolveMsg: null, rejectMsg: null},1000).then((res)=>{
              if(res.data){
              }
            })
          }catch(error){}
          let getparam = {
            uuid: this.uuida
          }
          let self = this;
          this.progressShow=true;
          this.timer = setInterval(function(){
            self.$resetpost('/rs/logic/getBatchOperaPro',{data:getparam},{resolveMsg: null, rejectMsg: null}, 0).then((res)=>{
              if(res.data ){
                if(res.data.speed){
                  if(res.data.speed>= 100){
                    clearInterval(self.timer);
                    if(res.data.speed){
                      self.percent = 99;
                    }
                    setTimeout(()=>{
                      self.percent = 100;
                      self.progressclose();
                      self.$showMessage(`导入成功! 累计导入:${res.data.totalsum}, 成功:${res.data.successsum},失败:${res.data.errorsum}(包含之前导入${res.data.aftersum}),失败数据请在稽查查询中错误查询进行查看!!`);
                    },600);
                  }else{
                    self.percent = res.data.speed
                  }
                }else{
                  self.percent=0;
                }
              }
            });
          },3000);
        }
      }
    }
  }
</script>
