<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search">
      <div class="flex">
        <div style="flex:1;" 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 class="font_normal_body">客户编号</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_userinfo_code"
                           condition="f_userinfo_code = '{}' " placeholder="客户编号">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户名称</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_user_name"
                           condition="f_user_name like '%{}%'" placeholder="客户名称">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label 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>
                    <v-select :value.sync="model.f_user_state"
                              v-model="model.f_user_state"
                              :search="false"
                              :options='$parent.$parent.userstates' placeholder='请选择'
                              condition="f_user_state = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="span" style="float:right;">
                    <button class="button_search button_spacing" @click="search()">查询</button>
                    <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
                    <!--<button class="btn btn-default" @click="$parent.$parent.stamp()">打印</button>-->

                    <export-excel :data="$parent.$parent.exportCondition"
                                  :field="$parent.$parent.getExportField"
                                  v-if="$parent.$parent.authArr.includes('档案查询导出') && $parent.$parent.jurisdiction.includes('excel导出')"
                                  sqlurl="rs/logic/exportfile" sql-name="meterQuery" template-name='表具查询导出'
                                  :choose-col="true"></export-excel>



                    <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                  </div>
                </div>
                <div class="row" v-show="$parent.$parent.criteriaShow">
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">客户地址</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_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>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_meternumber"
                           condition="f_meternumber like '%{}%'" placeholder='表号'>
                  </div>

                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;卡号&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_card_id"
                           condition="f_card_id like '%{}%'" placeholder='卡号'>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;区域码&nbsp;&nbsp;</label>
                    <input type="text" style="width:60%" class="input_search" v-model="model.f_area_code"
                           condition="f_area_code like '%{}%'" placeholder='区域码'>
                  </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='抄表员'
                              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_user_type"
                              @change="$parent.$parent.userTypeChange"
                              :options='$parent.$parent.usertypes' placeholder='请选择' v-model="model.f_user_type"
                              condition="f_user_type = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">用户类型</label>
                    <v-select :value.sync="model.f_user_mold"
                              @change="$parent.$parent.userMoldChange"
                              :options='$parent.$parent.usermold' placeholder='请选择' v-model="model.f_user_mold"
                              condition="f_user_mold = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">用气性质</label>
                    <v-select :value.sync="model.f_gasproperties" v-model="model.f_gasproperties"
                              :options='$parent.$parent.gasproperties' placeholder='请选择'
                              condition="f_gasproperties = '{}'"
                              close-on-select></v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">气价类型</label>
                    <v-select :value.sync="model.pricetype" v-model="model.pricetype"
                              placeholder='气价类型' :options="$parent.$parent.pricetypes"
                              condition="f_price_type = '{}'"
                              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"
                              placeholder='请选择'
                              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_meter_classify"
                              v-model="model.f_meter_classify"
                              :options='$parent.$parent.metertypes' placeholder='请选择'
                              condition="f_meter_classify = '{}'"
                              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"
                              v-model="model.f_meter_brand"
                              :options='$parent.$parent.meterbrands' placeholder='请选择'
                              condition="f_meter_brand = '{}'"
                              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_table_state"
                              v-model="model.f_table_state"
                              :options='$parent.$parent.tablestate' placeholder='请选择'
                              condition="f_table_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_whether_hairpin" v-model="model.f_whether_hairpin"
                              placeholder='是否发卡' :options="$parent.$parent.whether_hairpins"
                              :search="false"
                              condition="f_whether_hairpin = '{}'"
                              :value-single="true"
                              close-on-select>
                    </v-select>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label  class="font_normal_body">通气时间</label>
                    <datepicker placeholder="通气开始时间" style="width:60%"
                                v-model="model.f_gas_date"
                                :value.sync="model.f_gas_date"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="F_GAS_DATE >= to_date('{} 00:00:00','yyyy-mm-dd hh24:mi:ss')">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label  class="font_normal_body">通气时间</label>
                    <datepicker placeholder="通气结束时间" style="width:60%"
                                v-model="model.f_endgas_date"
                                :value.sync="model.f_endgas_date"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="F_GAS_DATE <= to_date('{} 23:59:59','yyyy-mm-dd hh24:mi:ss')">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="startDate" class="font_normal_body">建档日期</label>
                    <datepicker placeholder="建档起始日期" style="width:60%"
                                v-model="model.f_createfile_date"
                                :value.sync="model.f_createfile_date"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_createfile_date >= to_date('{} 00:00:00','yyyy-mm-dd hh24:mi:ss')">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="startDate" class="font_normal_body">建档日期</label>
                    <datepicker placeholder="建档结束日期" style="width:60%"
                                v-model="model.f_endcreatefile_date"
                                :value.sync="model.f_endcreatefile_date"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_createfile_date <= to_date('{} 23:59:59','yyyy-mm-dd hh24:mi:ss')">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="startDate" class="font_normal_body">开始日期</label>
                    <datepicker id="startDate" placeholder="开始日期" style="width:60%"
                                v-model="model.startDate"
                                :value.sync="model.startDate"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_input_date >= to_date('{} 00:00:00','yyyy-mm-dd hh24:mi:ss')">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label for="endDate" class="font_normal_body">结束日期</label>
                    <datepicker id="endDate" placeholder="结束日期" style="width:60%"
                                v-model="model.endDate"
                                :value.sync="model.endDate"
                                :format="'yyyy-MM-dd'"
                                :show-reset-button="true"
                                condition="f_input_date <= to_date('{} 23:59:59','yyyy-mm-dd hh24:mi:ss')">
                    </datepicker>
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">&nbsp;&nbsp;&nbsp;壁挂炉</label>
                    <v-select :value.sync="model.isbgl" v-model="model.isbgl"
                              :options='$parent.$parent.bgl' placeholder='请选择'
                              condition="isbgl = '{}'"
                              close-on-select></v-select>
                  </div>
                  <res-select-group :initres="$parent.$parent.initres" @re-res="$parent.$parent.getRes"></res-select-group>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">房产地址</label>
                    <input class="input_search" condition="f_house_address = '{}'"
                           placeholder='房产地址'
                           style="width:60%" type="text" v-model="model.f_house_address">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">用途</label>
                    <input class="input_search" condition="f_property_usage = '{}'"
                           placeholder='用途'
                           style="width:60%" type="text" v-model="model.f_property_usage">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">房型</label>
                    <input class="input_search" condition="f_house_type = '{}'"
                           placeholder='房型'
                           style="width:60%" type="text" v-model="model.f_house_type">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">是否一户多表</label>
                    <input class="input_search" condition="f_is_multi_meter = '{}'"
                           placeholder='是否一户多表'
                           style="width:60%" type="text" v-model="model.f_is_multi_meter">
                  </div>
                  <div class="col-sm-2 form-group">
                    <label class="font_normal_body">关联ID</label>
                    <input class="input_search" condition="f_house_id = '{}'"
                           placeholder='关联ID'
                           style="width:60%" type="text" v-model="model.f_house_id">
                  </div>
                </div>
              </div>
            </criteria>

            <data-grid :model="model" partial='list' v-ref:grid class="list_area table_sy" :classname="$parent.classname">
              <template partial='head'>
                <tr>
                  <th>
                    <data-order field="f_userinfo_code" name="客户编号"></data-order>
                  </th>
                  <th>
                    <nobr>客户名称</nobr>
                  </th>
                  <th>
                    <nobr>客户电话</nobr>
                  </th>
                  <th>
                    <nobr>身份证号</nobr>
                  </th>
                  <th>
                    <nobr>客户地址</nobr>
                  </th>
                  <th>
                    <nobr>表上余额</nobr>
                  </th>
                  <th>
                    <nobr>累购气量</nobr>
                  </th>
                  <th>
                    <nobr>规模量</nobr>
                  </th>
                  <th>
                    <nobr>客户类型</nobr>
                  </th>
                  <th>
                    <nobr>用气性质</nobr>
                  </th>
                  <th>
                    <nobr>表号</nobr>
                  </th>
                  <th>
                    <nobr>卡号</nobr>
                  </th>


                  <th>
                    <nobr>气价名称</nobr>
                  </th>
                  <th>
                    <nobr>气价详情</nobr>
                  </th>
                  <th>
                    <nobr>气表品牌</nobr>
                  </th>
                  <th>
                    <nobr>气表型号</nobr>
                  </th>
                  <th>
                    <nobr>户管员</nobr>
                  </th>
                  <th>
                    <nobr>通气人</nobr>
                  </th>
                  <th>
                    <nobr>通气时间</nobr>
                  </th>
                  <th>
                    <nobr>建表时间</nobr>
                  </th>
                  <th>
                    <nobr>气表状态</nobr>
                  </th>
                  <th>
                    <nobr>是否壁挂炉</nobr>
                  </th>
                </tr>
              </template>
              <template partial='body'>
                <td style="text-align: center;"><nobr>
                  <span @click="$parent.$parent.$parent.showmsg(row)"><a>{{row.f_userinfo_code}}</a></span>
                </nobr> </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_user_name}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_user_phone}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.idnumber}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_address}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_balance_amount}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_total_gas}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.guimo}}</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_card_id}}</nobr>
                </td>


                <td style="text-align: center;">
                  <nobr>{{row.f_price_name}}</nobr>
                </td>
                <th>
                  <nobr>{{row.value}}</nobr>
                </th>
                <td style="text-align: center;">
                  <nobr>{{row.f_meter_brand}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_meter_style}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_inputtor}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gas_person}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_gas_date}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_input_date}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.f_table_state}}</nobr>
                </td>
                <td style="text-align: center;">
                  <nobr>{{row.isbgl}}</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">
                表上余额合计&emsp;{{sumsmodel.f_balance_amount}}
              </td>
              <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
                客户余额合计&emsp;{{sumsmodel.f_balance}}
              </td>
            </tr>
          </table>

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

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

  let readySomething = async function (self) {
    // self.$refs.paged.$refs.cri.model.startDate = self.$login.toStandardDateString()
    // self.$refs.paged.$refs.cri.model.endDate = self.$login.toStandardDateString()
    // await self.$refs.paged.$refs.cri.search()
    await self.$MagLoadParams.loadParam()
    self.initParams()
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
  }

  export default {
    data() {
      return {
        model: new PagedList('rs/sql/meterQuery', 20, {orderitem: "'f_userinfo_code desc'"}, {f_balance_amount: 0, f_balance_gas: 0}),
        orderFields: {
          f_userinfo_code: 'no'
        },
        criteriaShow: false,
        jurisdiction:this.$login.r,
        orgCondtionStr: '',
        exportCondition:{},
        modelval: [],
        printshow: false,
        all: false,
        fields: {},
        thead: '',
        tfoot: '',
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[],
        },
        show:false,
        rowdata:{},
        meterbrands: [],
        pricenames: [],
        inputtouPerson: [],
        prices: [],
        //合计数据
        sumsmodel: {},
        gasproperties:[],
        usermold:[],
        userstates:this.$appdata.getParam('用户状态') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('用户状态')] : [],
        whether_hairpins:[{label:'全部',value:''},{label:'已发',value:'已发'},{label:'未发',value:'未发'},{label:'无卡',value:'无卡'},{label:'换表待发',value:'换表待发'}],
        f_filialeid: this.$login.f.f_orgid,
      }
    },
    ready() {
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      search(){
        this.$refs.paged.$refs.cri.search()
      },
      userTypeChange () {
        this.usermold=[]
        this.f_gasproperties=[]
        if(this.$refs.paged.$refs.cri.model !== null) {
          this.$refs.paged.$refs.cri.model.f_gasproperties=''
          this.$refs.paged.$refs.cri.model.f_user_mold=''
          this.usermold = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_type[0])
        }
        else{
          this.usermold =[{label: '全部', value: ''}]
        }
      },
      userMoldChange () {
        this.gasproperties=[]
        if(this.$refs.paged.$refs.cri.model !==null) {
          this.$refs.paged.$refs.cri.model.f_gasproperties=''
          if (this.$refs.paged.$refs.cri.model.f_user_mold[0] ==='居民'){
            this.gasproperties = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_type[0] + this.$refs.paged.$refs.cri.model.f_user_mold[0])
            return
          }
          this.gasproperties = this.$appdata.getParam(this.$refs.paged.$refs.cri.model.f_user_mold[0])
        }
        else{
          this.gasproperties =[{label: '全部', value: ''}]
        }
      },
      cancel() {
        this.show = false
      },
      showmsg(obj){
        this.rowdata=obj
        this.show=true
      },
      sort (field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'asc') {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }else if (rule === 'desc') {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }
        this.search()
      },
      selfSearch(args) {
        //抄表员查询条件
        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,``)
          console.log("=====抄表员model22222222222绑定====",str)
          //查询多个抄表员时条件
          args.condition += ` and f_inputtor in  ( ${str} )`
        }
        if (!this.orgCondtionStr) {
          args.condition = `${args.condition}` + " and f_orgid = " + this.$login.f.orgid
        } else {
          args.condition = `${args.condition}` + this.orgCondtionStr
        }
        this.model.search(args.condition, args.model)
        this.sumsmodel = this.$refs.paged.$refs.grid.model.sums
        this.exportCondition = {condition: `${args.condition}`,orderitem:`${this.model.paramSource.orderitem }`}
        console.log("导出条件")
      },
      clear() {
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          this.$refs.paged.$refs.cri.model[key] = ''
        })
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      getRes(condition) {
        this.orgCondtionStr = condition
      },
      stamp() {
        this.all = false
        //默认选择要打印的列
        this.modelval = defaultPrint.config
        this.fields = this.getfield
        console.log('所有打印字段', this.fields)
        this.printshow = true
        this.put()
      },
      put() {
        // 对Modelval进行排序
        this.sortModelval()
        this.thead = `<tr><th colspan=${this.modelval.length}>表具查询统计报表</th></tr><tr>`
        for (let key of this.modelval) {
          this.thead += '<th>' + this.fields[key] + '</th>'
        }
        this.thead += '</tr>'
      },
      print() {
        this.$refs.print.PrintAsFile()
        this.printshow = false
      },
      close() {
        this.printshow = false
        this.all = false
      },
      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();
      },
      // 对选择的列进行排序
      sortModelval() {
        let sortModel = []
        Object.keys(this.fields).forEach((key) => {
          if (this.modelval.includes(key)) {
            sortModel.push(key)
          }
        })
        this.modelval = sortModel
        console.log('选择的打印的字段', this.modelval)
      },
      async updateParams() {
        await this.$MagLoadParams.loadParam(this.f_filialeid)
        this.initParams()
      },
    },
    watch: {
      'all'(val) {
        if (val) {
          this.modelval = this.bodyData
        } else {
          this.modelval = defaultPrint.config
          this.put()
        }
      },
      'modelval.length'() {
        this.put()
      },
      'orgCondtionStr'(val) {
        let res = val.match(/'(.*?)'/)
        console.log('正则提取:',res && res[1])
        if (res) {
          this.f_filialeid = res[1]
          this.updateParams()
        }
      }
    },
    computed: {
      authArr () {
        return this.$login.r ? this.$login.r : []
      },

      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 [{label: '全部', value: ''}, ...rs]
      },

      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 (f_user_type.length > 0 && f_gasproperties.length > 0 && pricetype.length >0) {
            let params = {
              f_user_type: f_user_type[0],
              f_gasproperties: f_gasproperties[0],
              f_price_type: pricetype[0],
              filter: this.f_filialeid,
              prices: this.prices
            }
            this.$MagGetSaleParam.getPrice(params).forEach((item) => {
              let temp = {}
              temp.label = item.label
              temp.value = item.value.f_price_name
              priceArr.push(temp)
            })
            rs = [{label: '全部', value: ''}, ...priceArr]
          }
          if (rs.length === 0) {
            console.log('rs读出来是空')
            this.$refs.paged.$refs.cri.model.f_price_name = ''
          }
          return rs
        }
      },
      getCondition() {
        return {condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr}
      },
      getfield() {
        let data = {}
        this.bodyData.forEach((value, index) => {
          data[this.bodyData[index]] = this.headData[index]
        })
        //合计字段打印
        this.tfoot = `<tr><th colspan=${this.modelval.length}>全表汇总信息: `
        if (this.sumsmodel) {
          Object.keys(this.sumsmodel).forEach((key) => {
            this.tfoot += this.fields[key] + '合计: ' + `<font color="blue">${this.sumsmodel[key]} </font>`
          })
        } else {
          this.tfoot += '暂无'
        }
        this.tfoot += '</th></tr>'
        return data
      },
      getExportField() {
        return exportConfig.meterConfig
      },
      areas() {
        let rs = []
        for (let i = 0; i < this.$login.f.f_allArea.length; i++) {
          let temp = {
            label: this.$login.f.f_allArea[i].label,
            value: this.$login.f.f_allArea[i].label
          }
          rs.push(temp)
        }
        return [{label: '全部', value: ''}, ...rs]
      },
      sliceArea() {
        let rs = []
        if (this.$refs.paged.$refs.cri.model.f_area.length > 0) {
          for (let i = 0; i < this.$login.f.f_allArea.length; i++) {
            if (this.$login.f.f_allArea[i].label === this.$refs.paged.$refs.cri.model.f_area[0]) {
              rs = this.$login.f.f_allArea[i].value
            }
          }
        }
        return [{label: '全部', value: ''}, ...rs]
      },
      usertypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用户类型')]
      },
      // gasproperties() {
      //   return [{label: '全部', value: ''}, ...this.$appdata.getParam('用气性质')]
      // },

      metertypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气表类型')]
      },
      // meterbrands() {
      //   let arr = []
      //   this.$MagGetSaleParam.getGasbrand().forEach((item) => {
      //     let temp = {}
      //     temp.label = item.label
      //     temp.value = item.value.f_meter_brand
      //     arr.push(temp)
      //   })
      //   return [{label: '全部', value: ''}, ...arr]
      // },
      pricetypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')]
      },
      tablestate() {
        return [{label: '全部', value: ''}, {label: '正常', value: '正常'}, {label: '停用', value: '停用'}, {label: '换表', value: '换表'}]
      },
      bgl(){
        return [{label: '全部', value: ''}, {label: '是', value: '是'}, {label: '否', value: '否'}]
      }
    }
  }
</script>
