<template>
  <div id="unit" class="flex-row">
    <div :class="{'basic-main':!useraddressShow,'binary-left':useraddressShow}" @keyup.enter="search">
      <div class="flex" v-if="!show">

        <criteria-paged :model="model" v-ref:paged @sort="sort">
          <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
            <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
              <div class="row">
                <div class="col-sm-2 form-group">
                  <label for="startDate" class="font_normal_body">开始日期</label>
                  <datepicker id="startDate" placeholder="开始日期" style="width:60%"
                              v-model="model.startDate"
                              :value.sync="model.startDate"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              :show-reset-button="true"
                              condition="f_operate_date >= '{}'">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="endDate" class="font_normal_body">结束日期</label>
                  <datepicker id="endDate" placeholder="结束日期" style="width:60%"
                              v-model="model.endDate"
                              :value.sync="model.endDate"
                              :format="'yyyy-MM-dd HH:mm:ss'"
                              :show-reset-button="true"
                              condition="f_operate_date <= '{}'">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户编号</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_userinfo_code"
                         condition="f_userinfo_code = '{}' " placeholder="客户编号">
                </div>
                <div class="col-sm-2 form-group" v-show="false">
                  <label class="font_normal_body" title="旧客户编号">档案编号</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_olduserinfo_code"
                         condition="f_olduserinfo_code = '{}' " placeholder="档案编号">
                </div>

                <div class="span" style="float:right;">
                  <button class="button_search button_spacing" @click="search()">查询</button>
                  <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
                  <!--<button class="btn btn-default" @click="$parent.$parent.stamp()">打印</button>-->

                  <export-excel :data="$parent.$parent.getCondition"
                                :field="$parent.$parent.getfield"
                                :header="$parent.$parent.other"
                                sqlurl="api/af-revenue/logic/openapi/exportfile" sql-name="CancellationQuery" template-name='销户查询导出'
                                :choose-col="true"></export-excel>
                  <print-data :sum-field="$parent.$parent.getfield" :model="$parent.model" :field="$parent.$parent.getfield"
                               :defaultfield="$parent.$parent.defaultfield"
                              titletable="销户记录"
                              :sumsmodel="$parent.$parent.sumsmodel"></print-data>
                  <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                </div>
              </div>

              <div class="row" v-show="$parent.$parent.criteriaShow">
                <res-select-group :initres="$parent.$parent.initres" :show-component="$parent.$parent.showCom" @re-res="$parent.$parent.getRes" v-ref:sel></res-select-group>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户名称</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_user_name"
                         condition=" f_user_name = '{}'" placeholder='客户名称'>
                </div>
                <div class="col-sm-2 form-group" v-show="false">
                  <label class="font_normal_body">客户地址</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_address"
                         condition="f_address like '%{}%'" placeholder='客户地址'>
                </div>

                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">气价名称</label>
                  <v-select :value.sync="model.f_price_name"
                            v-model="model.f_price_name"
                            :options="$parent.$parent.getPricenames"
                            condition="f_price_name = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">气表品牌</label>
                  <v-select :value.sync="model.f_meter_brand" multiple
                            v-model="model.f_meter_brand"
                            :options='$parent.$parent.meterbrands' placeholder='请选择'
                            condition="f_meter_brand in {}"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">小区名称</label>
                  <v-select :value.sync="model.f_residential_area"
                            class="select_list select"
                            v-model="model.f_residential_area"
                            style="width: 60%"
                            condition="f_residential_area like '%{}%'"
                            :options='$parent.$parent.residentialArea' placeholder='选择小区'
                            close-on-select>
                  </v-select>
                </div>
<!--                <div class="col-sm-2 form-group">-->
<!--                  <label class="font_normal_body">小区名称</label>-->
<!--                  <input type="text" style="width:60%" class="input_search" v-model="model.f_residential_area"-->
<!--                         condition="f_residential_area like '%{}%'" placeholder="小区名称">-->
<!--                </div>-->
<!--                <div class="col-sm-2 form-group">-->
<!--                  <label class="font_normal_body">操作类型</label>-->
<!--                  <v-select :value.sync="model.f_operat_type"-->
<!--                            v-model="model.f_operat_type"-->
<!--                            :options='$parent.$parent.operattype' placeholder='请选择'-->
<!--                            condition="f_operat_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_type"
                            v-model="model.f_user_type"
                            :options='$parent.$parent.userTypes' placeholder='请选择'
                            condition="f_user_type = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="f_user_usetype" class="font_normal_body ">用气类型</label>
                  <v-select :value.sync="model.f_user_usetype" :search="false"
                            @change="$parent.$parent.userUseTypeChange()"
                            v-model="model.f_user_usetype"
                            :options='$parent.$parent.userusetypes'
                            condition="f_user_usetype = '{}'"
                            placeholder='用气类型'
                            value-single="true"
                            close-on-select>
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="f_use_institution" class="font_normal_body">用气机构</label>
                  <v-select :value.sync="model.f_use_institution" :search="false"
                            @change="$parent.$parent.userUseInstitutionChange()"
                            v-model="model.f_use_institution"
                            :options='$parent.$parent.useinstitutions'
                            condition="f_use_institution = '{}'"
                            placeholder='用气机构'
                            value-single="true"
                            close-on-select>
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="f_user_usenature" class="font_normal_body ">使用性质</label>
                  <v-select :value.sync="model.f_user_usenature" :search="false"
                            v-model="model.f_user_usenature"
                            :options='$parent.$parent.userusenatures'
                            condition="f_user_usenature = '{}'"
                            placeholder='使用性质'
                            value-single="true"
                            close-on-select>
                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label for="f_cancellation_type" class="font_normal_body ">销户类型</label>
                  <v-select :value.sync="model.f_cancellation_type" :search="false"
                            v-model="model.f_cancellation_type"
                            :options='$parent.$parent.cancellationTypes'
                            condition="f_cancellation_type = '{}'"
                            placeholder='销户类型'
                            value-single="true"
                            close-on-select>
                  </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>
                  <data-order field="f_userinfo_code" name="客户编号"
                              :order.sync="$parent.$parent.$parent.orderFields.f_userinfo_code"></data-order>
                </th>
                <th>
                  <nobr>客户名称</nobr>
                </th>
                <th>
                  <nobr>档案编号</nobr>
                </th>
                <th>
                  <nobr>客户类型</nobr>
                </th>
                <th>
                  <nobr>联系电话</nobr>
                </th>
                <th>
                  <data-order field="f_address" name="客户地址"
                              :order.sync="$parent.$parent.$parent.orderFields.f_address"></data-order>
                </th>
                <th>
                  <nobr>表号</nobr>
                </th>
                <th>
                  <nobr>销户类型</nobr>
                </th>
                <th>
                  <nobr>销户原因</nobr>
                </th>
                <th>
                  <nobr>状态</nobr>
                </th>
                <th>
                  <data-order field="f_operate_date" name="销户日期"
                              :order.sync="$parent.$parent.$parent.orderFields.f_operate_date"></data-order>
                </th>
                <th>
                  <nobr>操作类型</nobr>
                </th>
                <th>
                  <nobr>人员</nobr>
                </th>
                <th>
                  <nobr>部门</nobr>
                </th>
                <th>
                  <nobr>公司</nobr>
                </th>
                <th>
                  <nobr>气价名称</nobr>
                </th>
                <th>
                  <nobr>气表品牌</nobr>
                </th>
                <th>
                  <nobr>小区名称</nobr>
                </th>
                <th>
                  <nobr>操作</nobr>
                </th>
                <th>
                  <nobr>附件</nobr>
                </th>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align: center;">
                <nobr>
                  <span @click="$parent.$parent.$parent.dealmsg(row)"><a>{{row.f_userinfo_code}}</a></span></nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_user_name}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_olduserinfo_code}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_user_type}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_user_phone}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_address}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_meternumber}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_cancellation_type}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_comments}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_state}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_operate_date}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_operat_type}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_operator}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_depname}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_orgname}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_price_name}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_meter_brand}}</nobr>
              </td>
              <td style="text-align: center;">
                <nobr>{{row.f_residential_area}}</nobr>
              </td>
              <td style="text-align: center;" v-else>
                <nobr><a href="#" @click="$parent.$parent.$parent.enable(row)">启用</a> | <a href="#" @click="$parent.$parent.$parent.modifyAddress(row)">修改地址</a></nobr>
              </td>
              <td style="text-align: center;">
                <nobr>
                 <button class="button_search button_spacing width-60" @click.stop="$parent.$parent.$parent.view(row)">查看</button>
                </nobr>
              </td>
            </template>
            <template partial='foot'></template>
          </data-grid>
        </criteria-paged>
        <table class="table-hover">
          <tr style="position: relative" class="table-bordered">
            <td
              style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;color: #5CB95C;font-weight: bold">
              汇总信息
            </td>
            <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">总户数:&emsp;{{$refs.paged.$refs.grid.model.count}}</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 class="binary-right" v-show="useraddressShow">
      <div class="flex">
        <user-address v-ref:useraddressmsg
                      :f_filialeids.sync="f_filialeids"></user-address>

        <user-address-change v-if="addressId" :address_id="addressId"></user-address-change>
      </div>
    <modal :show.sync="showupload" v-if="showupload" width="80%" style="width:auto;"  v-ref:modal middle backdrop="false">
      <article slot="modal-body">
        <upload :blodid="selected.f_userinfo_id" v-ref:upload isupload="false" takeimg="false"  fusetype="销户" :isremark="false" style="width:auto" ></upload>
      </article>
      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
  </div>
    <modal :show.sync="enbaleShow" v-if="enbaleShow"  width="50%" style="width:auto;" v-ref:modal backdrop="false">
      <article slot="modal-body" class="modal-body">
        <div class="auto">
          <validator name='v'>
            <form class="form-horizontal">
              <p class="bg-info text-center" style="padding: 8px;">启用信息</p>
              <div class="form-group" style="margin-top:10px;">
                <label for="f_reason" class=" font_normal_body">销户原因:</label>
                <input class="input_search" style="width:80%" v-model="enableData.f_comments" disabled="">
              </div>
              <div class="form-group" style="margin-top:10px;">
                <div  :class="[$v.f_reason.required ? 'has-error' : 'has-success']">
                  <label for="f_reason" class=" font_normal_body">启用原因:</label>
                  <input class="input_search" style="width:80%" v-model="enableData.f_reason" v-validate:f_reason='{required: true }' rows="3" placeholder="请填写原因">
                </div>
              </div>
            </form>
            <div style="text-align:right;height:auto;margin-top:30px;margin-right:50px;">
              <button class="button_search" @click="confirmEnable()"  :disabled='!$v.valid'>确认</button>
              <button class="button_clear" @click="clean()">取消</button>
            </div>
          </validator>
        </div>
      </article>
      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
  </div>
</template>

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

  let readySomething = async function (self) {
    self.$refs.paged.$refs.cri.model.startDate = self.data ? self.data.startDate : self.$login.toStandardDateString() + ' 00:00:00'
    self.$refs.paged.$refs.cri.model.endDate = self.data ? self.data.endDate : self.$login.toStandardDateString() + ' 23:59:59'
    self.defaultfield = [...self.defaultfield, ...self.config.defaultPrint]
    // await self.$refs.paged.$refs.cri.search()
    //self.$refs.paged.$refs.cri.model.f_sendsuccess = ['有效']
    await self.$MagLoadParams.loadParam()
    self.initParams()
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
  }
  export default {
    props:['data'],
    title: '销户查询',
    data() {
      return {
        data: {},
        other: [],
        footer: [],
        model: new PagedList('api/af-revenue/sql/CancellationQuery', 20, {orderitem: this.orderitem?`${this.orderitem}`: " 'f_operate_date desc '"}),
        criteriaShow: false,
        headData: ["客户编号", "客户名称", "操作人", "操作日期", "销户状态", "销户原因", "同步状态"],
        bodyData: ["f_userinfo_id", "f_user_name", "f_operator", "f_operate_date", "f_state", "f_comments", "f_sendsuccess"],
        orgCondtionStr: '',
        show:false,
        f_filialeids: this.$login.f.orgid,
        useraddressShow: false,
        addressId: '',
        // 下拉框
        meterbrands: [],
        f_price_name: [],
        pricenames: [],
        prices: [],
        //小区
        residentialArea: [],
        rowdata:{},
        enableData: {
          f_reason: ''
        },
        enbaleShow: false,
        modelval: [],
        printshow: false,
        all: false,
        fields: {},
        thead: '',
        showupload:false,
        config: {
          defaultPrint: ['f_userinfo_code', 'f_user_name', 'f_type', 'f_changemeter_fee', 'f_meternumber_old', 'f_meternumber', 'f_change_operator', 'f_state', 'f_operate_date']
        },
        //排序
        orderitem:'f_operate_date desc',
        orderFields: {
          f_operate_date: 'no'
        },
        defaultfield: [],
        selected:{},
        tfoot: '',
        initres: {
          org:[this.$login.f.orgid],
          dep:[],
          user:[],
        },
        useinstitutions: [],
        userusenatures: [],
        //合计数据
        sumsmodel: {},
        operattype:[{label: '全部', value: ''},{label: '销户', value: '销户'},{label: '销户启用', value: '销户启用'}],
        showCom:['company','department','operator']
      }
    },
    ready() {
      this.getaddress()
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      userUseInstitutionChange () {
        this.userusenatures = []
        this.$refs.paged.$refs.cri.model.f_user_usenature = ''
        if (this.$refs.paged.$refs.cri.model.f_use_institution) {
          let str = this.$refs.paged.$refs.cri.model.f_use_institution + '使用性质'
          this.userusenatures = this.$appdata.getParam(str)
        }
      },
      userUseTypeChange () {
        this.useinstitutions = []
        this.$refs.paged.$refs.cri.model.f_use_institution = ''
        if (this.$refs.paged.$refs.cri.model.f_user_usetype) {
          let str = this.$refs.paged.$refs.cri.model.f_user_usetype + '机构'
          this.useinstitutions = this.$appdata.getParam(str)
        }
      },
      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();
      },
      pricetypechanged(){
        this.$refs.paged.$refs.cri.model.f_price_name = []
      },
      async  getaddress(){
        let HttpReset = new HttpResetClass()
        var data = await HttpReset.load('POST', 'api/af-revenue/sql/manage_getarealist', {
          data: {
            condition: `1=1 and s.f_filialeid = '${this.$login.f.orgid}'`
          }
        }, {resolveMsg: null, rejectMsg: '获取小区失败!'})
        console.log('小区',data)
        let house = [{label: '全部', value: ''}]
        for (let row of data.data){
          house.push({label: row.f_residential_area, value: row.f_residential_area})
        }
        this.residentialArea = house
      },
      //把数据库查询数据转换为下拉数据
      calculate(rows){
        let data = []
        rows.forEach((row, n) => {
          data[n] = {label: row.f_residential_area, value: row.id}
        })
        return data
      },
      modifyAddress(obj) {
        this.addressId=obj.addrid
        this.useraddressShow=true
        this.$refs.useraddressmsg.cleardara()
        this.$refs.useraddressmsg.initdata()
        this.$refs.useraddressmsg.usertype=obj.f_user_type
        this.$refs.useraddressmsg.operation='modify'
        this.$refs.useraddressmsg.onedata='one'
        this.$refs.useraddressmsg.model=Object.assign({},this.$refs.useraddressmsg.model,obj)
        if(obj.f_special=='1'){
          this.$refs.useraddressmsg.usertype = true
        }else{
          this.$refs.useraddressmsg.usertype = false
        }
        if (obj.f_slice_area) {
          this.$refs.useraddressmsg.model.slice_area = [{
            name: this.$refs.useraddressmsg.model.f_slice_area,
            code: this.$refs.useraddressmsg.model.f_area_code
          }]
        }
      },
      enable(row) {
        // let obj = {data: {name: ''}}
        // if (this.$refs.paged.$refs.grid.selectStore.selected==null){
        //   this.$refs.paged.$refs.grid.selectStore.selected = obj
        // }else if(this.$refs.paged.$refs.grid.selectStore.selected.data==null){
        //   Object.assign(this.$refs.paged.$refs.grid.selectStore.selected, obj)
        // }
        Object.assign(this.enableData, row)
        this.enbaleShow = true
      },
      confirmEnable() {
        let data = {
          f_operat_type: '销户启用',
          f_describe: `${this.$login.f.name}对客户${this.enableData.f_user_name}进行启用`,
          f_user_id: this.enableData.f_user_id,
          f_user_name: this.enableData.f_user_name,
          f_state: '正常',
          f_comments: this.enableData.f_reason,
          f_operator: this.$login.f.name,
          f_operatorid: this.$login.f.id,
          f_orgid: this.$login.f.orgid,
          f_orgname: this.$login.f.orgs,
          f_depid: this.$login.f.depids,
          f_depname: this.$login.f.deps,
          f_userinfo_id : this.enableData.f_userinfo_id
        }
        this.$resetpost('rs/logic/saveSingleCancellation', data, {resolveMsg: '启用成功', rejectMsg: '启用失败'})
          .then(() => {
            this.enbaleShow = false
            this.$refs.paged.$refs.grid.refresh()
          })
      },
      clean() {
        this.enbaleShow = false
      },
      view(row){
        this.showupload = true
        this.selected= row
      },
      getotherfooter() {
        // this.$refs.paged.$refs.cri.$refs.exports.otherData=[];
        // this.$refs.paged.$refs.cri.$refs.exports.footerData=[];
        this.other = [];
        this.footer = [];
        let exportdata = this.getCondition;
        let otherInData = [];
        otherInData.push(`导出时间: ${this.$login.toStandardTimeString()}`);
        let footerData = [], exportfield = this.getfield;
        footerData.push("合计");
        let self = this;
        for (var field in self.sumsmodel) {
          footerData.push(`${exportfield[field]}合计:${self.sumsmodel[field]}`);
        }
        this.footer.push(footerData);
        this.other.push(otherInData);
      },
      search(){
        this.$refs.paged.$refs.cri.search()
      },
      selfSearch(args) {
        if (this.data) {
          this.$parent.$parent.$parent.data.startDate=this.$refs.paged.$refs.cri.model.startDate
          this.$parent.$parent.$parent.data.endDate=this.$refs.paged.$refs.cri.model.endDate
        }
        args.condition = `${args.condition}` + this.orgCondtionStr
        this.model.search(args.condition, args.model)
        this.sumsmodel = this.$refs.paged.$refs.grid.model.sums
      },
      clear() {
        //清空部门和人员
        this.$refs.paged.$refs.cri.$refs.sel.$children[1].selectres = []
        //部门和人员变为全选
        this.$refs.paged.$refs.cri.$refs.sel.$children[1].$children[0].isSelectAll = false
        this.$refs.paged.$refs.cri.$refs.sel.$children[2].$children[0].isSelectAll = false
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          this.$refs.paged.$refs.cri.model[key] = []
        })
      },
      show() {
        this.criteriaShow = true
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      getRes(obj) {
        this.orgCondtionStr = obj
      },
      stamp() {
        this.all = false
        //默认选择要打印的列
        this.modelval = defaultPrint.config
        this.fields = this.getfield
        console.log('所有打印字段', this.fields)
        this.printshow = true
        this.put()
      },
      sort (field, rule) {
        // 将所有排序方式设为不排序，实现相互排斥
        for (let key in this.orderFields) {
          if (key === field) {
            this.orderFields[key] = rule
          } else {
            this.orderFields[key] = 'no'
          }
        }
        // 如果新规则不排序，还原为默认排序
        if (rule === 'no') {
          this.model.paramSource.orderitem = `'${this.orderitem}'`
        } else {
          this.model.paramSource.orderitem = `'${field} ${rule}'`
        }

        this.search()
      },

      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>'
      },
      cancel() {
        this.show = false
      },
      dealmsg(val) {
        console.log('---------------dealmsg')
        this.rowdata=val
        this.show=true
        val.model = this.model.model
        this.$dispatch('deal-msg', val)
      },
      print() {
        this.$refs.print.PrintAsFile()
        this.printshow = false
      },
      close() {
        this.printshow = false
        this.all = false
      },
      // 对选择的列进行排序
      sortModelval() {
        let sortModel = []
        Object.keys(this.fields).forEach((key) => {
          if (this.modelval.includes(key)) {
            sortModel.push(key)
          }
        })
        this.modelval = sortModel
        console.log('选择的打印的字段', this.modelval)
      }
    },
    watch: {
      'all'(val) {
        if (val) {
          this.modelval = this.bodyData
        } else {
          this.modelval = defaultPrint.config
          this.put()
        }
      },
      sumsmodel: {
        handler: function (val) {
          this.getotherfooter();
        },
        deep: true
      },
      'modelval.length'() {
        this.put()
      },
    },
    computed: {
      userusetypes () {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('用气类型')]
      },
      cancellationTypes () {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('销户类型')]
      },
      userTypes() {
        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.length >0) {
            let params = {
              f_price_type: pricetype[0],
              filter: this.f_filialeid,
              prices: this.prices
            }
            this.$MagGetSaleParam.getPrice(params).forEach((item) => {
              let temp = {}
              temp.label = item.label
              temp.value = item.value.f_price_name
              priceArr.push(temp)
            })
            rs = [{label: '全部', value: ''}, ...priceArr]
          }
          if (rs.length === 0) {
            console.log('rs读出来是空')
            this.$refs.paged.$refs.cri.model.f_price_name = ''
          }
          return rs
        }
      },
      getCondition() {
        return {condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr,
          orderitem: this.orderitem?`${this.orderitem}`: " f_operate_date desc"}
      },
      getfield() {
        return exportConfig.CancellationConfig
      }
    },
    events: {
      'cancel' () {
        this.addressId=null
        this.useraddressShow = false
      },
      'confirm' () {
        this.addressId=null
        this.useraddressShow = false
        this.search()
      },
    }
  }
</script>
