<template>
  <div id="unit" class="flex-row">
    <div class="basic-main">
      <div class="flex">
        <criteria-paged :model="model" v-ref:paged>
          <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch">
            <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
              <div class="row">
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">组织机构</label>
                  <res-select
                    :initresid='$parent.$parent.curorgid'
                    @res-select="$parent.$parent.getorg"
                    is-mul="false"
                    restype='organization'
                  >
                  </res-select>
                </div>
                <div class="form-group col-sm-2" >
                  <label class="font_normal_body">客户编号</label>
                  <input type="text" class="input_search" style="width:60%"
                         v-model="model.f_userinfo_code" placeholder='客户编号'
                         condition="f_userinfo_code = '{}'" >
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">客户名称</label>
                  <input type="text" class="input_search" style="width:60%"
                         v-model="model.f_user_name" placeholder='客户名称'
                         condition="f_user_name = '{}'">
                </div>
                <div class="form-group col-sm-2" >
                  <label class="font_normal_body">开始日期</label>
                  <datepicker placeholder="开始日期"
                              style="width:60%"
                              v-model="model.startDate"
                              :value.sync="model.startDate"
                              :format="'yyyy-MM-dd'"
                  ></datepicker>
                </div>
                <div class="form-group col-sm-2" >
                  <label class="font_normal_body">结束日期</label>
                  <datepicker placeholder="结束日期"
                              style="width:60%"
                              v-model="model.endDate"
                              :value.sync="model.endDate"
                              :format="'yyyy-MM-dd'"
                  ></datepicker>
                </div>
                <div class="span" style="float:right;">&nbsp;&nbsp;
                  <button class="button_new" style="width: max-content" v-show="$parent.$parent.pricechange" @click="$parent.$parent.priceshow()">批量调价</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <button class="button_search" @click="search()" v-el:cx>查询</button>
                  <export-excel :data="$parent.$parent.getCondition" :footer="$parent.$parent.footer"
                                :field="$parent.$parent.getfield"
                                sqlurl="rs/logic/saleExport" sql-name="get_AdjustSellCharge" template-name='卡表调价补差导出'
                                :choose-col="true"></export-excel>
                  <button class="button_clear" @click="$parent.$parent.clear()">清空</button>
                  <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="form-group col-sm-2">
                  <label class="font_normal_body">客户地址</label>
                  <input type="text" class="input_search" style="width:60%" style="width:60%" v-model="model.f_address" placeholder='客户地址'
                         condition="u3.f_address like '%{}%'">
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">电&emsp;&emsp;话</label>
                  <input type="text" class="input_search" style="width:60%"  v-model="model.f_user_phone" placeholder='电话'
                         condition="f_user_phone like '%{}%'">
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">表&emsp;&emsp;号</label>
                  <input type="text" class="input_search" style="width:60%" style="width:60%" v-model="model.f_meternumber" placeholder='表号'
                         condition="f_meternumber like '%{}%'">
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">状&emsp;&emsp;态</label>
                  <v-select id="price_states"
                            v-model="model.price_states"
                            placeholder='调价状态'
                            style="width: 60%"
                            :value.sync="model.price_states"
                            :options='$parent.$parent.price_states'
                            condition="f_change_price1 {}"
                            close-on-select></v-select>
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">用户类型</label>
                  <v-select id="f_user_tye"
                            v-model="model.f_user_type"
                            placeholder='用户类型'
                            style="width: 60%"
                            @change="$parent.$parent.userTypeChange"
                            :value.sync="model.f_user_type"
                            :options='$parent.$parent.userTypes'
                            condition="u2.f_user_type = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">气价类型</label>
                  <v-select id="f_price_type"
                            v-model="model.price_type"
                            placeholder='气价类型'
                            :value-single="true"
                            style="width: 60%"
                            :value.sync="model.price_type"
                            @change="$parent.$parent.priceTypeChange"
                            :options='$parent.$parent.priceTypes'
                            condition="sp.f_price_type = '{}'"
                            close-on-select></v-select>
                </div>
                <div class="form-group col-sm-2">
                  <label class="font_normal_body">气&emsp;&emsp;价</label>
                  <v-select id="f_price_name"
                            v-model="model.price_name"
                            placeholder='气价名称'
                            style="width: 60%"
                            :value.sync="model.price_name"
                            :options='$parent.$parent.price_name'
                            condition="sp.id = '{}'"
                            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><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;">{{$index+1}}</td>
              <th style="text-align: center;">{{row.f_userinfo_code}}</th>
              <th style="text-align: center;">{{row.f_meternumber}}</th>
              <th style="text-align: center;">{{row.f_user_name}}</th>
              <th style="text-align: center;">{{row.f_user_type}}</th>
              <th style="text-align: center;">{{row.f_meter_type}}</th>
              <th style="text-align: center;"><nobr>{{row.sell_date}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_pregas}}</nobr></th>
              <th style="text-align: center;"><nobr>{{row.f_preamount}}</nobr></th>
              <th style="text-align: center;">{{row.f_price_name}}</th>
              <th style="text-align: center;">{{row.f_stair_gas1}}</th>
              <th style="text-align: center;">{{row.f_stair_gas2}}</th>
              <th style="text-align: center;">{{row.f_stair_gas3}}</th>
              <th style="text-align: center;">{{row.f_stair_price1}}</th>
              <th style="text-align: center;">{{row.f_stair_price2}}</th>
              <th style="text-align: center;">{{row.f_stair_price3}}</th>
              <th style="text-align: center;">
                <div v-if="!row.f_surplus_fee">
                  <button type="button" name="button" class="btn btn-link"
                          @click.stop="$parent.$parent.$parent.calculation(row)  && row.states === 1">调价补差
                  </button>

                </div>
                <div v-else>
                  {{row.f_change_price1}}
                </div>

              </th>
              <th style="text-align: center;">{{row.f_change_price2}}</th>
              <th style="text-align: center;">{{row.f_change_price3}}</th>
              <th style="text-align: center;">{{row.f_surplus_fee1}}</th>
              <th style="text-align: center;">{{row.f_surplus_fee2}}</th>
              <th style="text-align: center;">{{row.f_surplus_fee3}}</th>
              <!--              <th style="text-align: center;">{{row.f_address}}</th>-->
<!--              <th style="text-align: center;">-->
<!--                <div class="form-group" style="margin-bottom:0px;"-->
<!--                     v-if="!row.f_new_price>0">-->
<!--                  <input type="text" class="form-control" v-model="row.oldprice"-->
<!--                         v-next-el="{id: $index+1}"  :id="$index" style="width: 100px;padding: 6px;" :disabled="row.state === '开始'">-->
<!--                </div>-->
<!--                <div v-else>{{row.f_old_price}}</div>-->
<!--              </th>-->
<!--              <th style="text-align: center;">-->
<!--                <div class="form-group" style="margin-bottom:0px;"-->
<!--                     v-if="!row.f_new_price>0">-->
<!--                  <input type="text" class="form-control" v-model="row.newprice"  @blur="$parent.$parent.$parent.enter(row)"-->
<!--                         v-next-el="{id: $index+1}"  :id="$index" style="width: 100px;padding: 6px;" :disabled="row.state === '开始'">-->
<!--                </div>-->
<!--                <div v-else>{{row.f_new_price}}</div>-->
<!--              </th>-->
<!--              <th style="text-align: center;">-->
<!--                <div class="form-group" style="margin-bottom:0px;" v-if="!row.f_surplus_id">-->
<!--                  <input type="number" class="form-control" v-model="row.f_change_price"  @blur="$parent.$parent.$parent.enter(row)"-->
<!--                         v-next-el="{id: $index+1}"  :id="$index" style="width: 100px;padding: 6px;" :disabled="row.state === '开始'">-->
<!--                </div>-->
<!--                <div v-else>{{row.f_change_price}}</div>-->
<!--              </th>-->
<!--              <th style="text-align: center;">{{row.f_change_price}}</th>-->
              <th style="text-align: center;">{{row.f_pregas}}</th>
              <th style="text-align: center;">{{row.f_surplus_fee}}</th>
              <th style="text-align: center;">{{row.f_source}}</th>
              <th style="text-align: center;">
                <button type="button" name="button" class="btn btn-link" v-if="row.f_surplus_fee"
                        @click.stop="$parent.$parent.$parent.delectHand(row)  && row.states === 1">冲正
                </button>
              </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;{{sumsmodel.f_pregas}}
            </td>
            <td
              style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;font-weight: bold">
              补差金额:&emsp;{{sumsmodel.f_surplus_fee}}
            </td>
          </tr>
        </table>
        <modal :show.sync="show">
          <header slot="modal-header" class="modal-header">
            <h4 class="modal-title">调 价 补 差</h4>
          </header>
          <article slot="modal-body" class="modal-body">
            <div class="flex">
              <div class="row" v-if="model.model.price_type==='阶梯气价'">
                <div class="row">
                  <div class="form-group col-sm-6">
                    <label class="font_normal_body col-sm-9"><span v-if="operatorrow">({{operatorrow.f_stair_price1}})</span>一阶补差单价</label>
                    <input type="text" class="form-control" v-model="f_change_price1">
                  </div>
                </div>
                <div class="row" >
                  <div class="form-group col-sm-6">
                    <label class="font_normal_body col-sm-9"><span v-if="operatorrow">({{operatorrow.f_stair_price2}})</span>二阶补差单价</label>
                    <input type="text" class="form-control" v-model="f_change_price2">
                  </div>
                </div>
                <div class="row">
                  <div class="form-group col-sm-6 ">
                    <label class="font_normal_body col-sm-9"><span v-if="operatorrow">({{operatorrow.f_stair_price3}})</span>三阶补差单价</label>
                    <input type="text" class="form-control" v-model="f_change_price3">
                  </div>
                </div>
              </div>
              <div v-else>
                <div class="form-group col-sm-4">
                  <label class="font_normal_body">补差单价</label>
                  <input type="text" class="form-control" v-model="f_change_price1">
                </div>
              </div>
            </div>
          </article>
          <footer slot="modal-footer" class="modal-footer">
            <button class="button_search" @click="priceadjustment">生成调价补差表</button>
            <button type="button" class="btn btn-default" @click='close'>取消</button>
          </footer>
        </modal>
        <work-busy :is-busy="locking" v-show="locking"></work-busy>
      </div>
    </div>
  </div>
</template>

<script>
  import { HttpResetClass } from 'vue-client'
  import { PagedList } from 'vue-client'
  import Vue from 'vue'
  let readySomething = async function (self) {
    self.$refs.paged.$refs.criteria.model.startDate = self.$login.toStandardDateString()
    self.$refs.paged.$refs.criteria.model.endDate = self.$login.toStandardDateString()
    self.$refs.paged.$refs.criteria.model.f_change_date = ''
    self.sumsmodel = self.$refs.paged.$refs.grid.model.sums
    getPrice(self)
    self.$showAlert('请输入[气价类型]后进行查询！', 'warning', 2000)
    self.pricechange = false

  }
  let getPrice = async function(self) {
    self.$resetpost('rs/sql/getpriceid', {data: {f_filialeids: self.f_filialeid}}, {
      resolveMsg: null,
      rejectMsg: null
    }).then((res) => {
      console.log('气价信息-------->',res.data)
      let rs = []
      for (let i = 0; i < res.data.length; i++) {
        let temp = {
          label: res.data[i].f_price_name+`(${res.data[i].id})`,
          type:res.data[i].f_price_type,
          flage: res.data[i].f_user_type,
          value: res.data[i].id
        }
        rs.push(temp)
      }
      console.log(rs)
      self.pricers = [ ...rs]
      self.priceTypeChange()
    })
  }

  export default {
    title: '调价补差',
    data () {
      return {
        f_orgid: '',
        sumsmodel:[],
        footer: [],
        other:[],
        f_filialeid: this.$login.f.orgid,
        operatorrow:'',
        operatortype :'one',
        config: {
          defaultPrint: [],
          excelHeaders: {
            'f_userinfo_code': '用户编号',
            'f_meternumber': '表号',
            'f_user_name': '用户姓名',
            'sell_date': '购气时间',
            'f_preamount': '购气金额',
            'f_user_type': '用户类型',
            'f_meter_type': '气表类型',
            'f_price_name': '气价名称',
            'f_stair_gas1': '一阶气量',
            'f_stair_gas2': '二阶气量',
            'f_stair_gas3': '三阶气量',
            'f_stair_price1': '一阶单价',
            'f_stair_price2': '二阶单价',
            'f_stair_price3': '三阶单价',
            'f_change_price1': '一阶补差单价',
            'f_change_price2': '二阶补差单价',
            'f_change_price3': '三阶补差单价',
            'f_surplus_fee1': '一阶补差金额',
            'f_surplus_fee2': '二阶补差金额',
            'f_surplus_fee3': '三阶补差金额',
            'f_pregas': '补差气量',
            'f_surplus_fee': '补差金额',
            'f_source': '差价来源'
          }
        },
        pricechange: true,
        criteriaShow: false,
        f_change_price1:0,
        f_change_price2:0,
        f_change_price3:0,
        pricers: [{label: '全部', value: '', flage: ''}],
        price_name: [{label: '全部', value: ''}],
        price_states: [{label: '全部', value: ''}, {label: '已调价', value: ' is not null'}, {label: '未调价', value: 'is null'}],
        userTypes: this.$appdata.getParam('用户类型') ? [...this.$appdata.getParam('用户类型')] : [],
        priceTypes: this.$appdata.getParam('气价类型') ? [ ...this.$appdata.getParam('气价类型')] : [],
        condition: '',
        locking: false,
        model: new PagedList('rs/sql/get_AdjustSellCharge', 20, {startDate: 'this.model.startDate', endDate: 'this.model.endDate', price_states: 'this.model.price_states[0]', addSelectParam: 'this.model.addSelectParam'},{  f_pregas: 0,
          f_surplus_fee: 0
        }),
        f_new_price: 0.0,
        f_old_price:0.0,
        f_change_price:0.0,
        show: false,
        curorgid: [this.$login.f.orgid],
        addSelectParam: ''
        // joinTable:'',
      }
    },
    ready () {
      readySomething(this).then(() => {
        this.$emit('ready')
      }).catch((error) => {
        this.$emit('error', error)
      })
    },
    methods: {
      getotherfooter () {
        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)
      },
      calculation (row) {
        this.f_change_price1 = 0,
          this.f_change_price2 = 0,
          this.f_change_price3 = 0,
          this.pricetime_states = ''
        this.show = true
        this.operatorrow = row
        this.operatortype = 'one'
      },
      getorg (val) {
        this.f_filialeid = val[0]
      },
      hidden () {
        this.criteriaShow = !this.criteriaShow
      },
      priceTypeChange () {
        console.log(1)
        this.price_name = []
        if (this.$refs.paged.$refs.criteria.model.f_user_type) {
          if (this.$refs.paged.$refs.criteria.model.price_type) {
            console.log(2)
            for (let i = 0; i < this.pricers.length; i++) {
              if (this.pricers[i].type === this.$refs.paged.$refs.criteria.model.price_type && this.pricers[i].flage === this.$refs.paged.$refs.criteria.model.f_user_type[0]) {
                let rs = {
                  type:this.pricers[i].type,
                  label: this.pricers[i].label,
                  value: this.pricers[i].value
                }
                this.price_name.push(rs)
              }
            }
          }
        }
      },
      // 用户类型发生改变
      userTypeChange () {
        this.price_name = []
        if (this.$refs.paged.$refs.criteria.model.price_type) {
          if (this.$refs.paged.$refs.criteria.model.price_type) {
            for (let i = 0; i < this.pricers.length; i++) {
              if (this.pricers[i].type === this.$refs.paged.$refs.criteria.model.price_type && this.pricers[i].flage === this.$refs.paged.$refs.criteria.model.f_user_type[0]) {
                let rs = {
                  type:this.pricers[i].type,
                  label: this.pricers[i].label,
                  value: this.pricers[i].value
                }
                this.price_name.push(rs)
              }
            }
          }
        }
      },
      // 冲正
      delectHand (row) {
        this.$showMessage('冲正后不可恢复，确定冲正吗？', ['confirm', 'cancel']).then((res) => {
          if (res === 'confirm') {
            row.f_operator = this.$login.f.name
            row.f_operatorid = this.$login.f.id
            row.f_orgid = this.$login.f.orgid
            row.f_orgname = this.$login.f.orgs
            row.f_depid = this.$login.f.depids
            row.f_depname = this.$login.f.deps
            this.$resetpost('rs/logic/newpriceAdjustmentOffset', {data: row}).then(() => {
              // this.$dispatch('refresh', '正在处理', row)
              this.selfSearch(this.model)
            })
          }
        })
      },
      priceshow () {
        this.operatorrow = this.model.rows[0]
        this.show = true
        this.f_change_price1 = 0
        this.f_change_price2 = 0
        this.f_change_price3 = 0
        this.pricetime_states = ''
        this.operatortype = 'batch'
      },
      close () {
        this.show = false
        this.f_change_price1 = 0
        this.f_change_price2 = 0
        this.f_change_price3 = 0
      },
      async priceadjustment () {
        if (this.operatortype == 'one') {
          this.enter()
        } else if (this.operatortype == 'batch') {
          this.$showMessage('确认生成补差记录吗?', ['cancel', 'confirm']).then(
            (response) => {
              if (response === 'confirm') {
                this.show = false
                this.locking = true
                this.getAdjustData()
              }
            })
        }
      },
      async enter (row) {

        let param = {
          f_state: '有效',
          f_change_price1:this.f_change_price1,
          f_change_price2:this.f_change_price2,
          f_change_price3:this.f_change_price3,
          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_start_date: this.model.model.startDate + ' 00:00:00',
          f_end_date: this.model.model.endDate + ' 23:59:59',
          f_change_date: this.model.model.f_change_date,
          row: this.operatorrow
        }
        await this.$resetpost('rs/logic/newpriceAdjustmentSell', {data: param}, {resolveMsg: '调价补差成功!', rejectMsg: '调价补差失败!'})
        this.operatorrow = {}
        this.show = false
        this.selfSearch(this.model)



      },
      async getAdjustData () {
        try {
          let param = {
            f_state: '有效',
            f_resource:'卡表收费',
            pricetime_states: this.pricetime_states,
            f_change_price1:this.f_change_price1,
            f_change_price2:this.f_change_price2,
            f_change_price3:this.f_change_price3,
            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_start_date: this.model.model.startDate + ' 00:00:00',
            f_end_date: this.model.model.endDate + ' 23:59:59',
            f_change_date: this.model.model.f_change_date,  //调价时间
            condition: ''
          }
          let searchCondition = {
            data: {
              condition: this.condition,
              f_change_date: this.model.model.f_change_date === '' ? '1911-01-01' : this.model.model.f_change_date,
              startDate: this.model.model.startDate,
              endDate: this.model.model.endDate, addSelectParam: '', price_states: 'not'
            }
          }
          param.condition = searchCondition
          let res = await this.$resetpost('rs/logic/newpriceAdjustmentAll', {data: param}, {
            resolveMsg: null,
            rejectMsg: null
          })
          if (res.data) {
            this.$showMessage(`本次调价用户数：${res.data.allsize},调价成功数量:${res.data.successsize},无需调价数量:${res.data.nodealsize},调价错误数量:${res.data.errorsize}`, ['confirm'])
          }
          this.close()
          this.$refs.paged.$refs.criteria.search()
          this.locking = false
          this.pricetime_states = ''
          this.f_new_price = ''
        } catch (error) {
          this.$showAlert('生成调价补差表失败!!!', 'error', 3)
          this.locking = false
        }
      },
      search () {
        this.selfSearch()
      },
      async selfSearch (args) {
        this.f_prices = [{label: '全部', value: ''}]
        if (this.$refs.paged.$refs.criteria.model.price_type == '') {
          this.$showAlert('请输入[气价类型]后进行查询！', 'warning', 2000)
          this.model.rows = []
          this.pricechange = false
          return
        }
        args.model.addSelectParam = ''
        if( args.model.price_name[0] && args.model.price_type && args.model.price_states[0] && args.model.price_states[0]==='is null'){
          this.pricechange = true
        }else {
          this.pricechange = false
        }
        this.condition = `${args.condition} and u2.f_orgid = '${this.f_filialeid}'`
        await this.model.search(this.condition, args.model)
        // let arr2 = this.model.rows.filter((value, index, array) => {
        //   return array.findIndex(item => item.key === value.key && item.f_price === value.f_price) === index
        // })
        // let rs = [{label: '全部', value: ''}]
        // arr2.forEach(function (item) {
        //   console.log('item', item.f_price)
        //   let temp = {
        //     label: item.f_price,
        //     value: item.f_price
        //   }
        //   rs.push(temp)
        // })
        // this.f_prices = rs
        // console.log('this.f_price', this.f_prices)
      },
      clear () {
        Object.keys(this.$refs.paged.$refs.criteria.model).forEach((key) => {
          this.$refs.paged.$refs.criteria.model[key] = ''
        })
      }
    },
    computed: {
      getCondition () {
        return {
          startDate:this.$refs.paged.$refs.criteria.model.startDate,
          endDate: this.$refs.paged.$refs.criteria.model.endDate,
          condition: this.condition
        }
      },
      getfield () {
        return this.config.excelHeaders
      }
    },
    watch: {
      async 'f_filialeid' (val) {
        // 更新抄表册
        this.$refs.paged.$refs.criteria.model.f_meter_book = []
        this.$refs.paged.$refs.criteria.model.f_book_slice_area = []
        this.$refs.paged.$refs.criteria.model.f_inputtor = []
        this.meterbooks = [{label: '全部', value: ''}]
        if (this.f_filialeid) {
          getPrice(this)
        }
      },
      sumsmodel: {
        handler: function (val) {
          this.getotherfooter()
        },
        deep: true
      }
    }
  }
</script>

<style >
</style>
