<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 >
          <div class="row">
            <div class="col-sm-2 form-group">
              <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 form-group ">
              <label 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 HH:mm:ss'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2 form-group ">
              <label 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 HH:mm:ss'"
                          :show-reset-button="reset">
              </datepicker>
            </div>

            <div class="col-sm-2 form-group ">
              <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="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 :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 form-group">
              <label class="font_normal_body">客户状态&emsp;  </label>
              <v-select :value.sync="model.f_user_state"
                        v-model="model.f_user_state"
                        :options='$parent.$parent.userstates' placeholder='请选择'
                        condition="f_user_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_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">表&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 form-group ">
              <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 form-group">
              <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 form-group">
              <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 = '{}' " placeholder="客户编号">
            </div>
            <div class="col-sm-2 form-group">
              <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 form-group">
              <label class="font_normal_body">表箱号&emsp;&emsp;</label>
              <input type="text" style="width:60%" class="input_search" v-model="model.f_metertitles"
                     condition="f_metertitles = '{}'" placeholder="表箱号">
            </div>
            <div class="col-sm-2 form-group">
              <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 form-group">
              <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 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 form-group">
              <label class="font_normal_body">表册片区&emsp;</label>
              <v-select :value.sync="model.f_book_slice_area" v-model="model.f_book_slice_area"
                        :options='$parent.$parent.bookSlice' placeholder='片区/表册'
                        style="width:60%"
                        close-on-select
                        condition="f_book_slice_area = '{}'"></v-select>
            </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="model.meter_classify"
                        placeholder='表类型'
                        style="width:70%"
                        :value.sync="model.meter_classify"
                        :options='$parent.$parent.f_meter_classify'
                        condition="f_meter_classify like '%{}'"
                        :value-single="true"
                        close-on-select >
              </v-select>
            </div>
            <div class="col-sm-2 form-group 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.model.qianfei_month_nummin"
                       placeholder="">
                <label   class="font_normal_body">  ≤ x ≤ </label>
                <input type="text" style="width:30%" class="input_search" v-model="model.model.qianfei_month_nummax"
                       placeholder="">
              </div>
            </div>

            <div class="col-sm-2 form-group 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.model.qianfei_nummin"
                       placeholder="">
                <label   class="font_normal_body">  ≤ x ≤ </label>
                <input type="text" style="width:30%" class="input_search" v-model="model.model.qianfei_nummax"
                       placeholder="">
              </div>
            </div>
            <div class="col-sm-2 form-group 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.model.f_totalowe_gasmin"
                       placeholder="">
                <label   class="font_normal_body"> ≤ x ≤ </label>
                <input type="text" style="width:30%" class="input_search" v-model="model.model.f_totalowe_gasmax"
                       placeholder="">
              </div>
            </div>
            <div class="col-sm-2 form-group 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.model.f_totalowe_feemin"
                       placeholder="">
                <label   class="font_normal_body">  ≤ x ≤ </label>
                <input type="text" style="width:30%" class="input_search" v-model="model.model.f_totalowe_feemax"
                       placeholder="">
              </div>
            </div>
            <div class="col-sm-2 form-group 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.model.qianfei_avg_gasmin"
                       placeholder="">
                <label   class="font_normal_body">  ≤ x ≤ </label>
                <input type="text" style="width:30%" class="input_search" v-model="model.model.qianfei_avg_gasmax"
                       placeholder="">
              </div>
            </div>
            <div class="col-sm-2 form-group flex-row" style="white-space: nowrap">
              <label  class="font_normal_body">用气量&emsp;&emsp;</label>
              <div class="row">
                <input type="text" style="width:30%" class="input_search" v-model="model.model.f_oughtamount_min"
                       placeholder="">
                <label   class="font_normal_body">  ≤ x ≤ </label>
                <input type="text" style="width:30%" class="input_search" v-model="model.model.f_oughtamount_max"
                       placeholder="">
              </div>
            </div>
          </div>

        </div>
      </criteria>
      <data-grid :model="model" partial='list' class="list_area table_sy"  v-ref:grid>
        <template partial='head'>
          <tr>
            <th><nobr>序号</nobr></th>
            <th><nobr>客户编号</nobr></th>
            <th><nobr>客户电话</nobr></th>
            <th><nobr>档案编号</nobr></th>
            <th><nobr>表号</nobr></th>
            <th><nobr>客户名称</nobr></th>
            <th><nobr>地址</nobr></th>
            <th><nobr>表箱号</nobr></th>
            <th><nobr>用户类型</nobr></th>
            <th><nobr>用气性质</nobr></th>
            <th><nobr>表具状态</nobr></th>
            <th><nobr>气表品牌</nobr></th>
            <th><nobr>表册片区</nobr></th>
            <th><nobr>当前表底数</nobr></th>
            <th><nobr>最后抄表日期</nobr></th>
            <th><nobr>温度</nobr></th>
            <th><nobr>压力</nobr></th>
            <th><nobr>采集时间</nobr></th>
            <th><nobr>标况流量</nobr></th>
            <th><nobr>工况流量</nobr></th>
            <th><nobr>标况总量</nobr></th>
            <th><nobr>工况总量</nobr></th>
            <th><nobr>上报余额</nobr></th>
            <th><nobr>用气量</nobr></th>
            <th><nobr>用气金额</nobr></th>
            <th><nobr>欠费月数</nobr></th>
            <th><nobr>欠费条数</nobr></th>
            <th><nobr>欠费月平均气量</nobr></th>
            <th><nobr>欠费气量</nobr></th>
            <th><nobr>欠费金额</nobr></th>
          </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_address}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.f_metertitles}}</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.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_book_slice_area}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.f_meter_base}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.end_time}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.flowmetertemperature}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.flowmeterpressure}}</nobr></th>

          <th style="text-align:center"><nobr>{{row.f_hand_date}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.standardconditionflow}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.operatingmodeflow}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.standardconditiontotal}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.operatingmodetotal}}</nobr></th>
          <th style="text-align:center"><nobr>{{row.f_jval}}</nobr></th>

          <th style="text-align: center;"><nobr>{{row.f_oughtamount}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.f_oughtfee}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.qianfei_month_num}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.qianfei_num}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.qianfei_avg_gas}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.f_totalowe_gas}}</nobr></th>
          <th style="text-align: center;"><nobr>{{row.f_totalowe_fee}}</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 style="display: inline-block;width: auto;border-right: 1px solid #f2f6fa;padding: 0px 10px 0px 10px;font-weight: bold">总用气量:&emsp;&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;&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;&emsp;{{sumsmodel.qianfei_num}}</td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">总欠费气量:&emsp;{{sumsmodel.f_totalowe_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_totalowe_fee}}</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'
  import exportConfig from "./config/exportConfig";

  let readySomething = async function (self) {
    await self.$MagLoadParams.loadParam()
    self.initParams()
    self.initSlice(self.$login.f.orgid)
    let year = new Date().getFullYear()
    self.$refs.paged.$refs.cri.model.startDate =  year+'-01-01 00:00:00'
    self.$refs.paged.$refs.cri.model.endDate =  self.$login.toStandardDateString() + ' 23:59:59'
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
  }
  export default {
    title: '用气稽查',
    data () {
      return {
        other:[],
        footer:[],
        org:[this.$login.f.orgid],
        criteriaShow: false,
        filialeNameStr: null,
        filialeCodeStr: `and f_orgid = '${this.$login.f.orgid}'`,
        userid: this.$login.f.id,
        source: `tool.getFullTree(this.getRights().where(row.getType() == $organization$))`,
        model: new PagedList('api/af-revenue/sql/getGasInspection', 50,{mycondition:'this.model.model.mycondition'},{
          f_oughtamount:0,
          f_oughtfee:0,
          qianfei_num:0,
          f_totalowe_gas:0,
          f_totalowe_fee:0
        }),
        rows: null,
        //orgid:'',
        sumsmodel: {},
        sqlName:'getGasInspection',
        config: {
          defaultPrint: ['f_userinfo_code','f_user_id']
        },
        show:false,
        rowdata:{},
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[],
        },
        // qianfei_month_nummin:null,
        // qianfei_month_nummax:null,
        // qianfei_nummin:null,
        // qianfei_nummax:null,
        // qianfei_avg_gasmin:null,
        // qianfei_avg_gasmax:null,
        // f_totalowe_feemin:null,
        // f_totalowe_feemax:null,
        // f_totalowe_gasmin:null,
        // f_totalowe_gasmax:null,
        mycondition:null,
        defaultfield: [],
        meterbrands: [],
        // 表册片区
        bookSlice:[]
      }
    },
    watch:{
      sumsmodel:{
        handler: function(val) {
          this.getotherfooter();
        },
        deep: true
      }
    },
    ready () {
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      // 初始化抄表册片区
      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 = [{label: '全部',value: ''}]
          arr.forEach((res) => {
            this.bookSlice.push({label: res.name, value: res.name})
          })
        }
      },
      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]
      },
      getotherfooter(){
        // this.$refs.paged.$refs.cri.$refs.exports.otherData=[];
        // this.$refs.paged.$refs.cri.$refs.exports.footerData=[];
        this.other=[];
        this.footer=[];
        // let exportdata = this.$refs.paged.$refs.cri.model.model.mycondition;
        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
      },
      async getorg (obj) {
        console.log('组织变化',obj)
        if(obj && obj.resids && obj.resids[0]){
          this.initSlice(obj.resids[0])
        }

        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=[]
        if(this.$refs.paged.model.model !==null) {
          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: ''}]
        }
      },
      search () {
        this.$refs.paged.$refs.cri.search()
      },
      selfSearch (args) {
        let a = " and 1=1 "
        let m=this.$refs.paged.$refs.cri.model.model;
        if(m.qianfei_month_nummin!=null && m.qianfei_month_nummin!=''){
          a += " and qianfei_month_num >= "+this.$refs.paged.$refs.cri.model.model.qianfei_month_nummin
        }
        if(m.qianfei_month_nummax!=null&&m.qianfei_month_nummax!=''){
          a+=' and qianfei_month_num <= '+this.$refs.paged.$refs.cri.model.model.qianfei_month_nummax
        }
        if(m.qianfei_nummin!=null&&m.qianfei_nummin!=''){
          a += " and qianfei_num >= "+this.$refs.paged.$refs.cri.model.model.qianfei_nummin
        }
        if(m.qianfei_nummax!=null&&m.qianfei_nummax!=''){
          a +=" and qianfei_num <= "+this.$refs.paged.$refs.cri.model.model.qianfei_nummax
        }
        if(m.qianfei_avg_gasmin!=null&&m.qianfei_avg_gasmin!=''){
          a +=" and qianfei_avg_gas >= "+this.$refs.paged.$refs.cri.model.model.qianfei_avg_gasmin
        }
        if(m.qianfei_avg_gasmax!=null&&m.qianfei_avg_gasmax!=''){
          a += " and qianfei_avg_gas <= "+this.$refs.paged.$refs.cri.model.model.qianfei_avg_gasmax
        }
        if(m.f_totalowe_feemin!=null&&m.f_totalowe_feemin!=''){
          a += " and f_totalowe_fee >= "+this.$refs.paged.$refs.cri.model.model.f_totalowe_feemin
        }
        if(m.f_totalowe_feemax!=null&&m.f_totalowe_feemax!=''){
          a += " and f_totalowe_fee <= "+this.$refs.paged.$refs.cri.model.model.f_totalowe_feemax
        }
        if(m.f_totalowe_gasmin!=null&&m.f_totalowe_gasmin!=''){
          a +=  " and f_totalowe_gas >= "+this.$refs.paged.$refs.cri.model.model.f_totalowe_gasmin
        }
        if(m.f_totalowe_gasmax!=null&&m.f_totalowe_gasmax!=''){
          a += " and f_totalowe_gas <= "+this.$refs.paged.$refs.cri.model.model.f_totalowe_gasmax
        }
        if (m.f_oughtamount_min) {
          a += " and f_oughtamount >= "+this.$refs.paged.$refs.cri.model.model.f_oughtamount_min
        }
        if (m.f_oughtamount_max) {
          a += " and f_oughtamount <= "+this.$refs.paged.$refs.cri.model.model.f_oughtamount_max
        }
        if (m.f_book_slice_area) {
          a += ` and f_book_slice_area = '${this.$refs.paged.$refs.cri.model.model.f_book_slice_area}'`
        }
        if(this.$refs.paged.$refs.cri.model.startDate){
          this.model.params.startDate = `'${this.$refs.paged.$refs.cri.model.startDate}' `
        }else{
          this.model.params.startDate = this.$login.toStandardDateString() + ' 00:00:00'
        }

        if(this.$refs.paged.$refs.cri.model.endDate){
          this.model.params.endDate = `'${this.$refs.paged.$refs.cri.model.endDate}' `
        }else{
          this.model.params.endDate = this.$login.toStandardDateString() + ' 23:59:59'
        }
        this.mycondition = a
        args.condition = args.condition+ ` ${this.filialeCodeStr}`
        args.condition = args.condition+ ` ${a}`
        console.log("拼接的condition", args.condition, this.model)
        this.model.search(args.condition, args.model)
      },
      hidden(){
        this.criteriaShow = !this.criteriaShow
      },
      clear(){
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          if (key != 'startDate' && key != 'endDate')
            if (key == 'model')
              this.$refs.paged.$refs.cri.model[key] = {}
            else
              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: {
      userstates (){
       return this.$appdata.getParam('用户状态') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('用户状态')] : []
      },
      tablestate() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('气表状态')]
      },
      getfield() {
        return exportConfig.gasInspectionConfig
      },
      usertypes() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('用户类型')]
      },
      gasproperties() {
        return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('用气性质')]
      },
      f_meter_classify(){
        return [{label: '全部', value: ''}, {label: '卡表', value: '卡表'},{label: '机表', value: '机表'},{label: '网表', value: '物联网表'} ]
        // return [{label: '卡表', value: '卡表'}]
      },
      getCondition () {
        let result = {
          condition: '',
          startDate: '',
          endDate: '',
          mycondition:''
        }
        result.condition = this.$refs.paged.$refs.cri.condition + this.filialeCodeStr
        result.condition = result.condition + this.mycondition
        let temp2 = this.$refs.paged.$refs.cri
        if (temp2.model.startDate && temp2.model.endDate) {
          result.startDate = ` '${temp2.model.startDate}'`
          result.endDate = ` '${temp2.model.endDate}'`
        } if (!temp2.model.startDate && !temp2.model.endDate) {
          result.startDate =  this.$login.toStandardDateString() + ' 00:00:00'
          result.endDate =  this.$login.toStandardDateString() + ' 23:59:59'
        }
          if (temp2.model.startDate&&!temp2.model.endDate) {
            result.startDate = ` '${temp2.model.startDate}'`
            result.endDate = this.$login.toStandardDateString() + ' 23:59:59'
          } if (temp2.model.endDate&&!temp2.model.startDate) {
            result.startDate = this.$login.toStandardDateString() + ' 00:00:00'
            result.endDate = ` '${temp2.model.endDate}'`
          }
        if (temp2.model.contain_newfile==='否'){
          result.condition = result.condition+" and f_open_date not between " + result.startDate + " and " + result.endDate
        }
        return result
      }
    }
  }
</script>
<style media="screen">
  .divtext {
    min-width: 50px;
    max-width: 200px;
    border: 1px solid green;
    display: inline-block;
  }
</style>

