<template>
  <div id="unit" class="flex-row">
    <div class="basic-main">
      <div class="flex" v-if="!show">
        <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 @keyup.enter="search()">
              <div class="row">
                <div class="col-sm-2">
                  <label class="font_normal_body">&emsp;公&emsp;&emsp;司</label>
                  <right-tree @re-res="$parent.$parent.getorg"
                              :initresid='$parent.$parent.org'></right-tree>
                </div>

                <div class="col-sm-2 ">
                  <label v-if="$parent.$parent.meter_classify == '卡表'" for="startDate" class="font_normal_body">&emsp;购气开始</label>
                  <label v-else for="startDate" class="font_normal_body">&emsp;抄表开始</label>
                  <datepicker id="startDate" placeholder="开始日期"
                              v-model="model.startDate"
                              style="width:60%"
                              :value.sync="model.startDate"
                              :disabled-days-of-Week="[]"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="reset">
                  </datepicker>
                </div>
                <div class="col-sm-2 ">
                  <label v-if="$parent.$parent.meter_classify == '卡表'" for="startDate" class="font_normal_body">&emsp;购气结束</label>
                  <label v-else for="startDate" class="font_normal_body">&emsp;抄表结束</label>
                  <datepicker id="endDate" placeholder="结束日期"
                              v-model="model.endDate"
                              style="width:60%"
                              :value.sync="model.endDate"
                              :disabled-days-of-Week="[]"
                              :format="'yyyy-MM-dd'"
                              :show-reset-button="reset">
                  </datepicker>
                </div>
                <div class="col-sm-2 ">
                  <label for="f_meter_classify"class="font_normal_body">&emsp;&emsp;表类型</label>
                  <v-select id="f_meter_classify"
                            v-model="$parent.$parent.meter_classify"
                            placeholder='表类型'
                            style="width:70%"
                            :value.sync="$parent.$parent.meter_classify"
                            :options='$parent.$parent.f_meter_classify'
                            condition="f_meter_type like '%{}'"
                            :value-single="true"
                            close-on-select >
                  </v-select>
                </div>
                <!--新增通气状态查询条件-->
<!--                <div class="col-sm-2">-->
<!--                  <label for="f_gas_date" class="font_normal_body">通气状态&emsp;</label>-->
<!--                  <v-select id="f_gas_date"-->
<!--                            style="width:60%"-->
<!--                            v-model="model.f_gas_date"-->
<!--                            placeholder='通气状态'-->
<!--                            :value.sync="model.f_gas_date"-->
<!--                            :options='$parent.$parent.f_gas_date'-->
<!--                            condition="ss.ventilation_status = '{}'"-->
<!--                            close-on-select>-->
<!--                  </v-select>-->
<!--                </div>-->
                <div class="span" style="float:right;">
                  <button class="btn button_search" @click="search()">查询</button>
                  <button class="btn button_clear" @click="$parent.$parent.clear()">清空</button>
                  <export-excel :data="$parent.$parent.getCondition"
                                :field="$parent.$parent.getfield"
                                :footer="$parent.$parent.footer"
                                :header="$parent.$parent.other"
                                sqlurl="api/af-revenue/logic/openapi/exportfile"
                                :sql-name="$parent.$parent.sqlName"
                                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="稽查查询打印"
                              :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">
                <div class="col-sm-2 ">
                  <label for="f_gasproperties"class="font_normal_body">&emsp;用气性质</label>
                  <v-select id="f_gasproperties"
                            style="width:60%"
                            v-model="model.f_gasproperties"
                            placeholder='用气性质'
                            :value.sync="model.f_gasproperties"
                            :options='$parent.$parent.gasproperties'
                            condition="f_gasproperties = '{}'"
                            close-on-select >
                  </v-select>
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body" title="旧客户编号">&emsp;档案编号</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_olduserinfo_code"
                         condition="f_olduserinfo_code = '{}' " placeholder="档案编号">
                </div>
                <div class="col-sm-2 ">
                  <label for="contain_newfile" class="font_normal_body">包含新开户</label>
                  <v-select id="contain_newfile"
                            v-model="model.contain_newfile"
                            style="width:60%"
                            :value.sync="model.contain_newfile"
                            :options='$parent.$parent.contain_newfiles'
                            :value-single="true"
                            close-on-select >
                  </v-select>
                </div>
                <div class="col-sm-2" >
                  <label  for="f_user_state" class="font_normal_body">&emsp;客户状态</label>
                  <v-select :value.sync="model.f_user_state"
                            v-model="model.f_user_state"
                            :options='$parent.$parent.userstate' placeholder='请选择'
                            condition="f_user_state = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 ">
                  <label for="f_table_state"class="font_normal_body">&emsp;&emsp;表状态</label>
                  <v-select id="f_table_state"
                            style="width:60%"
                            v-model="model.f_table_state"
                            placeholder='表状态'
                            :value.sync="model.f_table_state"
                            :options='$parent.$parent.tablestate'
                            condition="f_table_state = '{}'"
                            close-on-select >
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">&emsp;气表品牌</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">
                  <label class="font_normal_body">&emsp;&emsp;&emsp;表号</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 ">
                  <label class="font_normal_body">&emsp;用户类型</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">
                  <label class="font_normal_body">&emsp;客户名称</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">
                  <label class="font_normal_body">&emsp;客户编号</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_userinfo_code"
                         condition="f_userinfo_code like '%{}%' " placeholder="客户编号">
                </div>
                <div class="col-sm-2">
                  <label class="font_normal_body">&emsp;客户地址</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">
                  <label class="font_normal_body">&emsp;客户电话</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_user_phone"
                         condition="f_user_phone like '%{}%'" placeholder="客户电话">
                </div>

                <div  v-if="$parent.$parent.meter_classify == '卡表'" class="col-sm-2 flex-row" style="white-space: nowrap">
                  <label  class="font_normal_body">&emsp;期间次数</label>
                  <div class="row">
                    <input type="text" style="width:30%" class="input_search" v-model="model.sellcishumin"
                           condition="sellcishu >= {} " placeholder="">
                    <label   class="font_normal_body">  ≤ x ≤ </label>
                    <input type="text" style="width:30%" class="input_search" v-model="model.sellcishumax"
                           condition="sellcishu <= {} " placeholder="">
                  </div>
                </div>
                <div  v-if="$parent.$parent.meter_classify == '机表'" class="col-sm-2 flex-row" style="white-space: nowrap">
                  <label  class="font_normal_body">&emsp;期间次数</label>
                  <div class="row">
                    <input type="text" style="width:30%" class="input_search" v-model="model.handsellcishumin"
                           condition="sellcishu >= {} " placeholder="">
                    <label   class="font_normal_body">  ≤ x ≤ </label>
                    <input type="text" style="width:30%" class="input_search" v-model="model.handsellcishumax"
                           condition="sellcishu <= {} " placeholder="">
                  </div>
                </div>
                <div v-if="$parent.$parent.meter_classify == '卡表'" class="col-sm-2 flex-row" style="white-space: nowrap">
                  <label  class="font_normal_body">期间购气量</label>
                  <div class="row">
                    <input type="text" style="width:30%" class="input_search" v-model="model.sellpregasmin"
                           condition="sellpregas >= {} " placeholder="">
                    <label   class="font_normal_body">  ≤ x ≤ </label>
                    <input type="text" style="width:30%" class="input_search" v-model="model.sellpregasmax"
                           condition="sellpregas <= {} " placeholder="">
                  </div>
                </div>
                <div v-if="$parent.$parent.meter_classify == '机表'"  class="col-sm-2 flex-row" style="white-space: nowrap">
                  <label class="font_normal_body">期间用气量</label>
                  <div class="row">
                    <input type="text" style="width:30%" class="input_search" v-model="model.handsellpregasmin"
                           condition="sellpregas >= {} " placeholder="">
                    <label   class="font_normal_body">  ≤ x ≤ </label>
                    <input type="text" style="width:30%" class="input_search" v-model="model.handsellpregasmax"
                           condition="sellpregas <= {} " placeholder="">
                  </div>
                </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 = '{}'" @change="$parent.$parent.pricetypechanged"
                            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"
                            multiple
                            :options="$parent.$parent.getPricenames" placeholder='气价名称'
                            condition="f_price_name in {}"
                  ></v-select>
                </div>
              </div>
            </div>
          </criteria>
          <data-grid :model="model" partial='list' class="list_area table_sy"  v-ref:grid>
            <template partial='head'>
              <tr>
                <th><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 v-show="$parent.$parent.$parent.meter_classify == '卡表'"><nobr>总购气次数</nobr></th>-->
    <!--            <th v-show="$parent.$parent.$parent.meter_classify == '机表'"><nobr>总抄表次数</nobr></th>-->
    <!--            <th v-show="$parent.$parent.$parent.meter_classify == '卡表'"><nobr>总购气量</nobr></th>-->
    <!--            <th v-show="$parent.$parent.$parent.meter_classify == '机表'"><nobr>总抄表气量</nobr></th>-->
                <th v-show="$parent.$parent.$parent.meter_classify == '卡表' || $parent.$parent.$parent.meter_classify =='物联网表'"><nobr>期间购气次数</nobr></th>
                <th v-show="$parent.$parent.$parent.meter_classify == '机表'"><nobr>期间抄表次数</nobr></th>
                <th v-show="$parent.$parent.$parent.meter_classify == '卡表' || $parent.$parent.$parent.meter_classify == '物联网表'"><nobr>期间购气量</nobr></th>
                <th v-show="$parent.$parent.$parent.meter_classify == '机表'"><nobr>期间抄表气量</nobr></th>
    <!--            <th v-show="$parent.$parent.$parent.meter_classify == '卡表'"><nobr>累计未购气天数</nobr></th>-->
    <!--            <th v-show="$parent.$parent.$parent.meter_classify == '机表'"><nobr>累计未抄表天数</nobr></th>-->
                <th><nobr>组织机构</nobr></th>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align: center;"><nobr>{{$index+1}}</nobr></td>
              <td style="text-align: center;"><nobr>
                <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_phone}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_olduserinfo_code}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_meternumber}}</nobr></td>
              <th style="text-align: center;"><nobr>{{row.f_user_name}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_user_state}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_address}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_user_type}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_gasproperties}}</nobr></th>
<!--              <th style="text-align: center;"><nobr>{{row.ventilation_status}}</nobr></th>-->
              <th style="text-align: center;"><nobr>{{row.f_table_state}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_meter_brand}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_price_name}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.delivery_date}}</nobr></th>
    <!--          <th style="text-align: center;"><nobr>{{row.cishu}}</nobr></th>-->
    <!--          <th style="text-align: center;"><nobr>{{row.pregas}}</nobr></th>-->
              <th style="text-align: center;"><nobr>{{row.sellcishu}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.sellpregas}}</nobr></th>
    <!--          <th style="text-align: center;"><nobr>{{row.diffday}}</nobr></th>-->
              <th style="text-align: center;"><nobr>{{row.f_orgname}}</nobr></th>
            </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 v-if="meter_classify == '卡表'" style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">总购气量合计:&emsp;&emsp;{{sumsmodel.pregas}}</td>-->
            <td v-if="meter_classify == '卡表' || meter_classify == '物联网表'" style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">期间购气量合计:&emsp;&emsp;{{sumsmodel.sellpregas}}</td>
            <!--      <td v-if="meter_classify == '机表'" style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">总抄表气量合计:&emsp;&emsp;{{sumsmodel.pregas}}</td>-->
            <td v-if="meter_classify == '机表'" style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">期间抄表气量合计:&emsp;{{sumsmodel.sellpregas}}</td>
          </tr>
        </table>
      </div>
      <div class="flex" v-if="show">
        <user-info-detail-manage-new :f_userinfo_id="rowdata.f_userinfo_id" @cancel-main="cancel"></user-info-detail-manage-new>
      </div>
    </div></div>
</template>
<script>
  /**
   *用户档案查询列表以及添加操作组件
   */
  import { PagedList } from 'vue-client'
  import Vue from 'vue'
  import plugin from 'system-clients/src/plugins/GetLoginInfoService'

  let readySomething = async function (self) {
    await self.$MagLoadParams.loadParam()
    self.initParams()
    // 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'
    let year = new Date().getFullYear()
    self.$refs.paged.$refs.cri.model.startDate =  year+'-01-01'
    self.$refs.paged.$refs.cri.model.endDate =  self.$login.toStandardDateString()

    // 初始化气表价格
    self.prices = self.$MagGetSaleParam.getPrices()

    // await self.$refs.paged.$refs.cri.search()
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
  }
  export default {
    title: '购气稽查',
    data () {
      return {
        meterbrands: [],
        other:[],
        footer:[],
        org:[this.$login.f.orgid],
        criteriaShow: false,
        meter_classify:'卡表',
        filialeNameStr: null,
        filialeCodeStr: `and f_orgid = '${this.$login.f.orgid}'`,
        userid: this.$login.f.id,
        source: `tool.getFullTree(this.getRights().where(row.getType() == $organization$))`,
        getfield:{"f_userinfo_code":"客户编号","f_user_phone":"客户电话","f_olduserinfo_code":"档案编号","f_meternumber":"表号",
          "f_user_name":"客户名称","f_user_state":"客户状态","f_address":"地址","f_user_type":"用户类型",
          "f_gasproperties":"用气性质","f_table_state":"表具状态","f_meter_brand":"气表品牌","f_price_name":"气价名称",
          "delivery_date":"最后购气日期",
          "sellcishu":"期间购气次数","sellpregas":"期间购气量","f_orgname":"组织机构"},
        model: new PagedList('api/af-revenue/sql/inspectList_sellinggas', 50,{},{sellpregas: 0}),
        rows: null,
        //orgid:'',
        sumsmodel: {},
        sqlName:'inspectList_sellinggas',
        config: {
          defaultPrint: ['f_userinfo_code','f_user_id']
        },
        show:false,
        rowdata:{},
        prices: [],
        f_filialeid: this.$login.f.orgid,
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[],
        },
        defaultfield: [],
      }
    },
    watch:{
      sumsmodel:{
        handler: function(val) {
          this.getotherfooter();
        },
        deep: true
      },
      meter_classify(val){
        if(val == '卡表') {
          this.url = 'api/af-revenue/sql/inspectList_sellinggas'
          this.sqlName = 'inspectList_sellinggas'
          this.getfield = {"f_userinfo_code":"客户编号","f_olduserinfo_code":"档案编号","f_user_phone":"客户电话","f_meternumber":"表号",
            "f_user_name":"客户名称","f_user_state":"客户状态","f_address":"地址","f_user_type":"用户类型",
            "f_gasproperties":"用气性质","f_table_state":"表具状态","f_meter_brand":"气表品牌","f_price_name":"气价名称",
            "delivery_date":"最后购气日期",
            "sellcishu":"期间购气次数","sellpregas":"期间购气量","f_orgname":"组织机构"}
        }if(val == '物联网表'){
          this.url = 'api/af-revenue/sql/getwulw_listgas'
          this.sqlName = 'getwulw_listgas'
          this.getfield = {"f_userinfo_code":"客户编号","f_olduserinfo_code":"档案编号","f_user_phone":"客户电话","f_meternumber":"表号",
            "f_user_name":"客户名称","f_user_state":"客户状态","f_address":"地址","f_user_type":"用户类型",
            "f_gasproperties":"用气性质","f_table_state":"表具状态","f_meter_brand":"气表品牌","f_price_name":"气价名称",
            "delivery_date":"最后购气日期",
            "sellcishu":"期间购气次数","sellpregas":"期间购气量","f_orgname":"组织机构"}
        }
        if(val == '机表'){
          this.url = 'api/af-revenue/sql/handinspectList_sellinggas'
          this.sqlName = 'handinspectList_sellinggas'
          this.getfield = {"f_userinfo_code":"客户编号","f_olduserinfo_code":"档案编号","f_user_phone":"客户电话","f_meternumber":"表号",
            "f_user_name":"客户名称","f_user_state":"客户状态","f_address":"地址","f_user_type":"用户类型",
            "f_gasproperties":"用气性质","f_table_state":"表具状态","f_meter_brand":"气表品牌","f_price_name":"气价名称",
            "delivery_date":"最后抄表日期",
            "sellcishu":"期间抄表次数","sellpregas":"期间抄表气量","f_orgname":"组织机构"}
        }
        this.clear()
      }
    },
    ready () {

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

      // 添加回车键监听
      document.addEventListener('keyup', this.handleKeyUp)
    },
    methods: {
      pricetypechanged() {
        this.$refs.paged.$refs.cri.model.f_price_name = []
      },
      // 添加处理回车键的方法
      handleKeyUp(e) {
        if (e.key === 'Enter') {
          this.search()
        }
      },
      initParams () {
        // 初始化气表品牌
        let brandArr = []
        this.$MagGetSaleParam.getGasbrand().forEach((item) => {
          console.log('item-->',item)
          let temp = {}
          temp.label = item.label
          temp.value = item.value.f_meter_brand
          brandArr.push(temp)
        })
        this.meterbrands = [{label: '全部', value: ''}, ...brandArr]
        console.log('气表品牌---------->',this.meterbrands)
      },
      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);
      },
      cancel() {
        this.show = false
      },
      showmsg(obj){
        this.rowdata=obj
        this.show=true
      },
      getorg (obj) {
        if(obj.resids.length>0){
          this.filialeCodeStr =" and f_orgid in " + plugin.convertToIn(obj.resids)
        }
        else{
          this.filialeCodeStr= " and f_orgid = " + this.$login.f.orgid
        }
      },
      userTypeChange () {
        this.gasproperties=[]
        console.log("查气价")
        console.log(this.$refs.paged.model.model)

        if(this.$refs.paged.model.model !==null) {
          console.log("进if")
          this.$refs.paged.model.model.f_gasproperties=''
          this.gasproperties = this.$appdata.getParam(this.$refs.paged.model.model.f_user_type[0])
          // this.gasproperties.push({label: '全部', value: ''})
          console.log(this.gasproperties )
        }
        else{
          this.gasproperties =[{label: '全部', value: ''}]
        }
        console.log("最终气价")
        console.log(this.gasproperties )
      },
      search () {
        this.$refs.paged.$refs.cri.search()
      },
      selfSearch (args) {
        console.log('9999999999999999999', this.meter_classify )
        console.log('9999999999999999999', this.meter_classify.length)
        if(this.meter_classify == '卡表'){
          this.model.url='api/af-revenue/sql/inspectList_sellinggas'
        }
        if(this.meter_classify == '机表'){
          this.model.url='api/af-revenue/sql/handinspectList_sellinggas'
        }
        if(this.meter_classify == '物联网表'){
          this.model.url= 'api/af-revenue/sql/getwulw_listgas'
        }
        if (this.meter_classify == '卡表') {
          if (!this.$refs.paged.$refs.cri.model.sellcishumin && !this.$refs.paged.$refs.cri.model.sellcishumax) {
            args.condition = args.condition + "and sellcishu > 0"
          }
        }
        if (this.meter_classify == '机表') {
          if (!this.$refs.paged.$refs.cri.model.handsellcishumin && !this.$refs.paged.$refs.cri.model.handsellcishumax) {
            args.condition = args.condition + "and sellcishu > 0"
          }
        }
        console.log(this.$login.f)
        if(this.$refs.paged.$refs.cri.model.startDate){
          this.model.params.startDate = `'${this.$refs.paged.$refs.cri.model.startDate} 00:00:00' `
        }else{
          this.model.params.startDate ='DATEADD(yy,DATEDIFF(yy,0,getdate()),0)'
        }
        if(this.$refs.paged.$refs.cri.model.endDate){
          this.model.params.endDate = `'${this.$refs.paged.$refs.cri.model.endDate} 23:59:59' `
        }else{
          this.model.params.endDate ='DATEADD(SS,-1,DATEADD(DD,1,CONVERT(DATETIME,CONVERT(VARCHAR(10),GETDATE(),120))))'
        }

        if(this.$refs.paged.$refs.cri.model.contain_newfile){
          if(this.$refs.paged.$refs.cri.model.contain_newfile==='否') {
            if (this.$refs.paged.$refs.cri.model.startDate === ''&&this.$refs.paged.$refs.cri.model.endDate ==='') {
              args.condition = args.condition + "and f_open_date not between DATEADD(yy,DATEDIFF(yy,0,getdate()),0) and DATEADD(SS,-1,DATEADD(DD,1,CONVERT(DATETIME,CONVERT(VARCHAR(10),GETDATE(),120))))"
            }else if (this.$refs.paged.$refs.cri.model.startDate === ''&& this.$refs.paged.$refs.cri.model.endDate !=='') {
              args.condition = args.condition + "and f_open_date not between DATEADD(yy,DATEDIFF(yy,0,getdate()),0) and "+this.model.params.endDate
            }else if (this.$refs.paged.$refs.cri.model.startDate !== ''&& this.$refs.paged.$refs.cri.model.endDate ==='') {
              args.condition = args.condition + "and f_open_date not between " + this.model.params.startDate + "and DATEADD(SS,-1,DATEADD(DD,1,CONVERT(DATETIME,CONVERT(VARCHAR(10),GETDATE(),120))))"
            }
            else {
              args.condition = args.condition + "and f_open_date not between " + this.model.params.startDate + " and " + this.model.params.endDate
            }
          }
        }
        args.condition = args.condition+ ` ${this.filialeCodeStr}`
        console.log("拼接的condition", args.condition, this.model)
        this.model.search(args.condition, args.model)
      },
      // show(){
      //   this.criteriaShow = true
      // },
      hidden(){
        this.criteriaShow = !this.criteriaShow
      },
      clear(){
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          if(key != 'startDate' && key != 'endDate')
            this.$refs.paged.$refs.cri.model[key] = []
        })
        this.$refs.paged.$refs.cri.model.contain_newfile='是'
        let year = new Date().getFullYear()
        this.$refs.paged.$refs.cri.model.startDate =  year+'-01-01'
        this.$refs.paged.$refs.cri.model.endDate =  this.$login.toStandardDateString()
      }

    },
    computed: {
      gasproperties() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('用气性质')]
      },
      usertypes() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('用户类型')]
      },
      userstate() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('客户状态')]
      },
      tablestate () {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气表状态')]
      },
      f_meter_classify(){
        return [{label: '卡表', value: '卡表'},{label: '机表', value: '机表'},{label: '网表', value: '物联网表'} ]
        // return [{label: '卡表', value: '卡表'}]
      },
      contain_newfiles(){
        return [{label: '是', value: '是'},{label: '否', value: '否'} ]
      },
      f_gas_date() {
        return [{label: ' 已通气 ', value: '已通气'}, {label: ' 未通气 ', value: '未通气'} ]
      },
      pricetypes() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')]
      },
      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 && 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
        }
        return [{label: '全部', value: ''}]
      },
      getCondition () {
        let result = {
          condition: '',
          startDate: '',
          endDate: ''
          // diffDay:' 1=1 '
        }
        result.condition = this.$refs.paged.$refs.cri.condition + this.filialeCodeStr
        let temp2 = this.$refs.paged.$refs.cri
        if (temp2.model.startDate && temp2.model.endDate) {
          result.startDate = ` '${temp2.model.startDate} 00:00:00'`
          result.endDate = ` '${temp2.model.endDate} 23:59:59'`
        } if (!temp2.model.startDate && !temp2.model.endDate) {
          result.startDate = 'new Date().getFullYear()'
          result.endDate = 'DATEADD(SS,-1,DATEADD(DD,1,CONVERT(DATETIME,CONVERT(VARCHAR(10),GETDATE(),120))))'
        }
          if (temp2.model.startDate&&!temp2.model.endDate) {
            result.startDate = ` '${temp2.model.startDate} 00:00:00'`
            result.endDate = 'DATEADD(SS,-1,DATEADD(DD,1,CONVERT(DATETIME,CONVERT(VARCHAR(10),GETDATE(),120))))'
          } if (temp2.model.endDate&&!temp2.model.startDate) {
            result.startDate = 'new Date().getFullYear()'
            result.endDate = ` '${temp2.model.endDate} 23:59:59'`
          }

        // if(temp2.model.diffday != ''){
        //   result.diffDay += " and diffDay "+ temp2.model.diffday;
        // }
        if (temp2.model.contain_newfile==='否'){
          result.condition = result.condition+" and f_open_date not between " + result.startDate + " and " + result.endDate
        }

          return result
      }
    },
    beforeDestroy() {
      // 组件销毁前移除事件监听
      document.removeEventListener('keyup', this.handleKeyUp)
    }
  }
</script>
<style media="screen">
  .divtext {
    min-width: 50px;
    max-width: 200px;
    border: 1px solid green;
    display: inline-block;
  }
</style>

