<template>
  <div class="flex-row">
    <div @keyup.enter="search" class="basic-main">
      <criteria-paged :model="model" v-ref:paged>
        <criteria partial='criteria' @condition-changed='$parent.search' v-ref:cri>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">客户编号</label>
                <input type="text" style="width:60%" class="input_search" v-model="model.f_userinfo_code"
                       condition="f_userinfo_code = '{}'" placeholder='客户编号'>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">客户姓名</label>
                <input type="text" style="width:60%" class="input_search" v-model="model.f_user_name"
                       condition="f_user_name = '{}'" placeholder='客户姓名'>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">减免状态&nbsp;&nbsp;&nbsp;</label>
                <v-select id="f_pos_state"
                          v-model="model.f_remission_late_fee"
                          placeholder='减免状态'
                          condition="{}"
                          @change="$parent.$parent.showSearchbtn"
                          :value.sync="model.f_remission_late_fee"
                          :options='$parent.$parent.whetherPay'
                          close-on-select clear-button>
                </v-select>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">起始日期</label>
                <datepicker id="statDate" placeholder="起始日期"
                            v-model="model.f_stat_data"
                            :value.sync="model.f_stat_data"
                            condition="f_hand_date >'{}'"
                            :format="'yyyy-MM-dd'"
                            class="datepicker"
                            style="width:60%">
                </datepicker>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">结束日期</label>
                <datepicker id="endDate" placeholder="结束日期"
                            v-model="model.f_end_data"
                            :value.sync="model.f_end_data"
                            condition="f_hand_date <'{}'"
                            :format="'yyyy-MM-dd'"
                            class="datepicker"
                            style="width:60%">
                </datepicker>
              </div>
              <div class="span" style="float:right;">
                  <button class="button_search button_spacing" @click="search()" v-el:cx>查询</button>
                  <button v-if="$parent.$parent.bathshow" class="button_clear button_spacing" @click="$parent.$parent.batchtax()">批量减免</button>

                  <div
                    :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"
                    @click="$parent.$parent.hidden()"
                    class="button_spacing"
                    style="float: right">
                  </div>
              </div>
            </div>

            <div class="row" v-show="$parent.$parent.criteriaShow">

              <div class="col-sm-2 form-group">
                <label class="font_normal_body">违约金大于</label>
                <input type="text" style="width:60%" class="input_search" v-model="model.overdue_be"
                       @blur="$parent.$parent.showSearchbtn"
                       condition="overdue >= '{}'" placeholder='违约金大于'>
              </div>
              <res-select-group :initres="$parent.$parent.initres"  @re-res="$parent.$parent.getRes" v-ref:sel></res-select-group>
              <!--表册片区-->
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">表册片区</label>
                <v-select :value.sync="model.f_book_slice_area" v-model="model.f_book_slice_area"
                          :options='$parent.$parent.bookSliceArea' placeholder='表册片区'
                          multiple
                          style="width:60%"
                          @change="$parent.$parent.sliceChange"
                          close-on-select
                          condition="f_book_slice_area in {}"></v-select>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">抄&ensp;表&ensp;册</label>
                <v-select :value.sync="model.f_meter_book" v-model="model.f_meter_book"
                          :options='$parent.$parent.meterbooks' placeholder='抄表册'
                          multiple
                          style="width:60%"
                          close-on-select
                          condition="f_meter_book_num in {}"></v-select>
              </div>
            </div>
          </div>
        </criteria>
        <data-grid :model="model" partial='list' class="table_sy" v-ref:grid>
          <template partial='head'>
            <tr>
              <th>序号</th>
              <th>客户编号</th>
              <th>客户姓名</th>
              <th>地址</th>
              <th>上期指数</th>
              <th>本期指数</th>
              <th>抄表日期</th>
              <th>滞纳天数</th>
              <th>欠费金额</th>
              <th>违约金金额</th>
              <th>减免金额</th>
              <th>减免后金额</th>
              <th>操作</th>
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center;">{{$index+1}}</td>
            <td style="text-align: center;">{{row.f_userinfo_code}}</td>
            <td style="text-align: center;">{{row.f_user_name}}</td>
            <td style="text-align: center;">{{row.f_address}}</td>
            <td style="text-align: center;">{{row.f_last_tablebase}}</td>
            <td style="text-align: center;">{{row.f_tablebase}}</td>
            <td style="text-align: center;">{{row.f_hand_date}}</td>
            <td style="text-align: center;">{{row.overduedays}}</td>
            <td style="text-align: center;">{{row.f_oughtfee}}</td>
            <td style="text-align: center;">{{ row.overdue}}</td>
            <!--根据违约金金额是否显示减免金额输入框-->
            <div class="form-group" style="margin-bottom:0px;display: contents;" :class="{'has-error has-feedback': row.error}"
                 v-if="row.overdue>0">
              <!--根据减免金额显示输入框 @blur="$parent.$parent.$parent.beforenter(row)"-->

              <input title="违约金减免" type="text" class="input_search" v-model="row.f_remission_late_fee_vue"
                     @blur="$parent.$parent.$parent.comentsenter(row)"
                     v-next-el="{id: $index+1}" :id="$index"
                     style="width: 100px;padding: 6px;"
                     v-if="!row.f_relation_sign">
              <label style="text-align: center" v-else>{{row.f_remission_late_fee_vue}}</label>
            </div>
            <td style="text-align: center;" v-else></td>
            <td style="text-align: center;" v-html="row.f_overdue"></td>
            <td style="text-align: center;">
              <button type="button" name="button" class="btn btn-link"
                      v-if="row.f_relation_sign"
                      @click="$parent.$parent.$parent.cancelHand(row)">冲正
              </button>
              <button type="button" name="button" class="btn btn-link"
                      v-if="!row.f_relation_sign"
                      @click="$parent.$parent.$parent.sectionJM(row)">区间减免
              </button>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
      <!--批量减免弹框-->
      <modal :show.sync="arrshow" v-ref:modal backdrop="false">
        <header slot="modal-header" class="modal-header">
          <h4 class="modal-title">违约金批量减免</h4>
        </header>
        <article slot="modal-body" class="modal-body">
          <div class="form-group">
            <input type="text" class="input_search" v-model="batchtaxs" :value.sync="batchtaxs"
                   placeholder='减免金额'>
          </div>
        </article>
        <footer slot="modal-footer" class="modal-footer">
          <button v-show="arrshow" type="button" class="btn btn-default" @click='close'>取消</button>
          <button v-show="arrshow" type="button" class="btn btn-success" @click='create()'>确认</button>
        </footer>
      </modal>

      <!--备注输入框-->
      <modal :show.sync="comentsshow" v-ref:modal backdrop="false">
        <header slot="modal-header" class="modal-header">
          <h4 class="modal-title">备注</h4>
        </header>
        <article slot="modal-body" class="modal-body">
          <div class="form-group">
            <label class="font_normal_body">备注 &nbsp;&nbsp;</label>
            <input type="text" class="input_search" v-model="chooserow.f_comments" :value.sync="chooserow.f_comments"
                   placeholder='备注'>
          </div>
        </article>
        <footer slot="modal-footer" class="modal-footer">
          <button v-show="comentsshow" type="button" class="btn btn-default" @click='close'>取消</button>
          <button v-show="comentsshow" type="button" class="btn btn-success" @click='beforenter(chooserow)'>确认</button>
        </footer>
      </modal>
      <!--区间减免弹框-->
      <modal :show.sync="sectionShow" v-ref:modal backdrop="false">
        <header slot="modal-header" class="modal-header">
          <h4 class="modal-title">违约金区间减免</h4>
        </header>
        <article slot="modal-body" class="modal-body">
          <div class="form-group">
            <div class="row ">
              <label class="font_normal_body">起始日期 &nbsp;&nbsp;</label>
              <datepicker id="statDate" placeholder="起始日期"
                          v-model="section_f_start_data"
                          :value.sync="section_f_start_data"
                          :format="'yyyy-MM-dd 00:00:00'"
                          class="datepicker"
                          style="width:60%">
              </datepicker>
            </div>
            <div class="row ">
              <label class="font_normal_body">结束日期 &nbsp;&nbsp;</label>
              <datepicker id="endDate" placeholder="结束日期"
                          v-model="section_f_end_data"
                          :value.sync="section_f_end_data"
                          :format="'yyyy-MM-dd 59:99:99'"
                          class="datepicker"
                          style="width:60%">
              </datepicker>
            </div>
            <div class="row ">
              <label class="font_normal_body">减免金额 &nbsp;&nbsp;</label>
            <input type="text" class="input_search" v-model="batchtaxs" :value.sync="batchtaxs" readonly
                   placeholder='减免金额'>
            </div>
          </div>
        </article>
        <footer slot="modal-footer" class="modal-footer">
          <button v-show="sectionShow" type="button" class="btn btn-default" @click='close'>取消</button>
          <button v-show="sectionShow" type="button" class="btn btn-success" @click='sectionClickOk()'>确认</button>
        </footer>
      </modal>
    </div>
  </div>
</template>

<script>
  /**
   *违约金减免页面
   */
  import Vue from 'vue'
  import {PagedList, HttpResetClass} from 'vue-client'
  let readyGen = async function (self) {
    await self.$getConfig(self, 'HandManager')

    await self.$MagGetSaleParam.initinputtor()
    await self.getinputtores()
    console.log('-----------------', self.$login.f.orgid)
    await self.initSlice(self.$login.f.orgid)
    self.getfield = self.config.excelHeaders
    await self.initmeterbook()

    self.reflash()
  }
  export default {
    title: '违约金减免',
    data () {
      return {
        initres: {
          org: [this.$login.f.orgid],
          dep: [],
          user: []
        },
        query: false,
        orgCondtionStr: '',
        criteriaShow: false,
        model: new PagedList('rs/sql/getSearchOverdue', 20),
        // 减免状态根据减免金额判断
        whetherPay: [
          // 减免金额为0,或者为null时,为未减免
          {label: '未减免', value: '(f_remission_late_fee is null or f_remission_late_fee = 0)'},
          // 减免金额大于0时,为已减免
          {label: '已减免', value: 'f_remission_late_fee > 0'}
        ],
        // 批量减免的减免金额
        batchtaxs: '',
        // 控制显示批量减免按钮
        bathshow: false,
        // 控制批量减免确定取消按钮
        arrshow: false,
        section_f_start_data: '',
        section_f_end_data: '',
        nowRowdate: '',
        nowUserfilesId: '',
        newUserId: '',
        newHandplanId: '',
        toDayDate: '',
        sectionShow: false,
        chooserow: null,
        comentsshow: false,
        bookSliceArea: [],
        meterbooks: []
      }
    },
    ready () {
      // this.$refs.paged.$refs.cri.search()
      // 获取当前时间
      // this.$refs.paged.$refs.cri.model.f_stat_data = this.$login.toStartAndEndDateString()[0]
      // this.$refs.paged.$refs.cri.model.f_end_date = this.$login.toStartAndEndDateString()[1]
      this.toDayDate = this.$login.toStandardTimeString()
      readyGen(this)
    },
    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.bookSliceArea = []
          arr.forEach((res) => {
            this.bookSliceArea.push({label: res.name, value: res.name})
          })
        }
      },
      async sliceChange () {
        this.$set('$refs.paged.$refs.cri.model.f_meter_book', [])
        let val2 = this.$refs.paged.$refs.cri.model.f_book_slice_area
        if (val2.length > 0) {
          let condition = ` 1=1 and f_orgid ='${this.f_filialeid}' and f_book_state='有效' `
          let aaa = '('
          val2.forEach((item) => {
            aaa = aaa + `'${item}',`
          })
          aaa = aaa + `'')`
          condition = condition + ` and f_book_slice_area in ${aaa} `
          let param = {
            items: '*',
            tablename: 't_meter_book',
            condition: condition,
            orderitem: 'id'
          }
          let getMeterBooks = await this.$resetpost('rs/sql/singleTable_OrderBy', {data: param}, {resolveMsg: null, rejectMsg: '获取营收参数出错！！！'})
          if (getMeterBooks.data) {
            if (getMeterBooks.data.length > 0) {
              let rs = []
              getMeterBooks.data.forEach((item) => {
                let temp = {
                  label: item.f_book_name,
                  value: item.id
                }
                rs.push(temp)
              })
              this.meterbooks = [{label: '全部', value: ''}, ...rs]
            } else {
              this.meterbooks = [{label: '全部', value: ''}]
            }
          }
        } else {
          this.meterbooks = [{label: '全部', value: ''}]
        }
      },
      async getMeterBook () {
        let temp = {
          tablename: 't_meter_book',
          condition: `f_book_state='有效' and f_filiale_id='${this.$login.f.orgid}'`
        }
        let meterbooks = await this.$resetpost('rs/sql/saleSingleTable', {data: temp},
                {resolveMsg: null, rejectMsg: '获取抄表册信息失败！！'})
        if (meterbooks.data.length > 0) {
          let options = []
          for (let i = 0; i < meterbooks.data.length; i++) {
            let tmp = {label: meterbooks.data[i].f_book_name, value: `${meterbooks.data[i].id}`}
            options.push(tmp)
          }
          this.meterbooks = options
        }
      },
      getRes (obj) {
        this.orgCondtionStr = obj
      },
      sectionJM (row) {
        if (row) {
          this.nowRowdate = row.f_hand_date
          this.nowUserfilesId = row.f_userfiles_id
          this.newHandplanId = row.handplan_id
          this.newUserId = row.f_user_id
        }
        this.sectionShow = true
      },
      hidden () {
        this.criteriaShow = !this.criteriaShow
      },
      cancelHand (row) {
        console.log('减免金额冲正', row)
        let param = {
          id: row.handplan_id,
          version: row.version,
          f_relation_sign: row.f_relation_sign
          // f_remission_late_fee: 0,
          // f_operator: Vue.$login.f.name,
          // f_old_overdue: row.overdue + row.f_remission_late_fee,
          // f_new_overdue: row.overdue,
          // f_rush_state: '已冲正',
          // f_operatorid: Vue.$login.f.id,
          // f_orgid: Vue.$login.f.orgid,
          // f_orgname: Vue.$login.f.orgs,
        }
        this.$resetpost('rs/logic/overDueTaxuncannel', {data: param}, {warnMsg: '确定对这条记录进行撤销吗？'}).then(() => {
          this.$refs.paged.$refs.cri.search()
        })
        row.f_remission_late_fee_vue = 0
        this.close()
      },
      // 选择减免状态和减免金额大于后才显示批量减免按钮
      showSearchbtn () {
        console.log('===>' + this.$refs.paged.$refs.cri.model.f_remission_late_fee)
        this.$refs.paged.$refs.cri.search()
        if (this.$refs.paged.$refs.cri.model.f_remission_late_fee == '(f_remission_late_fee is null or f_remission_late_fee = 0)' && this.$refs.paged.$refs.cri.model.overdue_be != '') {
          this.bathshow = true
        } else {
          this.bathshow = false
        }
      },
      search (args) {
        if (this.query) {
          console.log('===>', args)
          console.log('=this.model==>', this.model)
          if (!this.orgCondtionStr) {
            args.condition = `${args.condition}` + ' and f_orgid = ' + this.$login.f.orgid
          } else {
            args.condition = `${args.condition}` + this.orgCondtionStr
          }
          this.model.search(args.condition)
        } else {
          this.query = true
        }
      },
      // 批量减免按钮
      async batchtax () {
        let msgRet = await this.$showMessage('此操作将减免当前页面所有欠费记录的全部违约金，是否确定？', ['confirm', 'cancel'])
        if (msgRet === 'confirm') {
          this.create()
        }
      },
      // 点击关闭
      close () {
        this.arrshow = false
        if (this.sectionShow) {
          this.section_f_start_data = ''
          this.section_f_end_data = ''
          this.nowRowdate = ''
          this.nowUserfilesId = ''
          this.newHandplanId = ''
        }
        this.sectionShow = false
        this.comentsshow = false
      },
      // 点击区间减免
      async sectionClickOk () {
        let http = new HttpResetClass()
        // 去除左右两边空格
        if (this.batchtaxs === '') {
          return
        }
        if (this.batchtaxs <= 0) {
          this.$showMessage('减免金额不能为负数')
          this.batchtaxs = ''
          return
        }
        let handplan = {
          f_remission_late_fee: this.batchtaxs,
          f_operator: Vue.$login.f.name,
          f_operatorid: Vue.$login.f.id,
          f_orgid: Vue.$login.f.orgid,
          f_orgname: Vue.$login.f.orgs,
          f_depid: Vue.$login.f.depids,
          f_depname: Vue.$login.f.deps,
          f_user_id: this.newUserId,
          f_hand_id: this.newHandplanId
        }
        let res = await http.load('POST', 'rs/logic/overDueTaxun', handplan, {
          resolveMsg: null,
          rejectMsg: '减免违约金出错'
        })
        this.close()
        this.$refs.paged.$refs.cri.search()
      },
      // 点击批量减免确定触发
      create (row) {
        // 批量减免金额不能大于选择的违约金大于金额
        this.arrshow = false
        // 组织数据
        let batch = {
          f_operator: Vue.$login.f.name,
          f_operatorid: Vue.$login.f.id,
          f_orgid: Vue.$login.f.orgid,
          f_orgname: Vue.$login.f.orgs,
          f_depid: Vue.$login.f.depids,
          f_depname: Vue.$login.f.deps,
          // 根据条件查询出符合批量减免的所有数据
          condition: this.model.condition
        }
        console.log('info数据', batch.condition)
        this.$resetpost('rs/logic/batchtaxs', batch, {
          resolveMsg: null,
          rejectMsg: '减免违约金出错!!!'
        }).then((res) => {
          this.$refs.paged.$refs.cri.search()
        })
      },
      updateParams () {
        // await this.$MagLoadParams.loadParam(this.f_filialeid)
        this.inputtoreser = []
        this.inputtoreser.push({label: '全部', value: ''})
        this.initSlice(this.f_filialeid)
        if (this.allorgid != null) {
          this.allorgid.forEach((res) => {
            this.inputtoreser = this.inputtoreser.concat(this.$MagGetSaleParam.getresinputtor(res))
          })
        }
      },
      async inputtorchange () {
        let val = this.$refs.paged.$refs.cri.model.f_inputtor
        if (val != null && val != '') {
          let param = {
            items: '*',
            tablename: 't_meter_book',
            condition: ` 1=1 and f_inputtor = '${val}' and f_orgid ='${this.f_filialeid}' and f_book_state='有效' `,
            orderitem: 'id'

          }
          let getMeterBooks = await this.$resetpost('rs/sql/manage_singleTable', {data: param}, {resolveMsg: null, rejectMsg: '获取营收参数出错！！！'})
          if (getMeterBooks.data) {
            if (getMeterBooks.data.length > 0) {
              let rs = []
              getMeterBooks.data.forEach((item) => {
                let temp = {
                  label: item.f_book_name,
                  value: item.id
                }
                rs.push(temp)
              })
              this.meterbooks = [{label: '全部', value: ''}, ...rs]
              // this.$set('$refs.paged.$refs.cri.model.f_meter_book',[getMeterBooks.data[0].id]);
            } else {
              this.$set('$refs.paged.$refs.cri.model.f_meter_book', [])
              this.meterbooks = [{label: '全部', value: ''}]
            }
          } else {
            this.$set('$refs.paged.$refs.cri.model.f_meter_book', [])
          }
        } else {
          this.$set('$refs.paged.$refs.cri.model.f_meter_book', [])
          this.meterbooks = [{label: '全部', value: ''}]
          this.initmeterbook()
        }
      },
      async initmeterbook (orgstr) {
        if (orgstr == null) {
          orgstr = this.f_filialeid
        }
        // 获取新的抄表册,先去清理所有的抄表册
        this.$GetSaleParam.meterbooks = []
        // 开始加载新的抄表册
        await this.$LoadParams.loadMeterBook(orgstr)
        this.meterbooks = [{label: '全部', value: ''}, ...this.$GetSaleParam.getMeterBooks()]
      },
      create2 (row) {
        if (this.batchtaxs === '' || this.batchtaxs === null) {
          this.$showAlert('减免金额不能为空', 'warning', 2000)
          return
        }
        // 批量减免金额不能大于选择的违约金大于金额
        if (parseInt(this.batchtaxs) > parseInt(this.$refs.paged.$refs.cri.model.overdue_be)) {
          this.$showAlert('违约金不能大于总金额！！', 'warning', 2000)

          return
        }
        this.arrshow = false
        // 组织数据
        let batch = {
          // 批量减免金额
          f_remission_late_fee: this.batchtaxs,
          f_operator: Vue.$login.f.name,
          f_operatorid: Vue.$login.f.id,
          f_orgid: Vue.$login.f.orgid,
          f_orgname: Vue.$login.f.orgs,
          f_depid: Vue.$login.f.depids,
          f_depname: Vue.$login.f.deps,
          // 根据条件查询出符合批量减免的所有数据
          condition: this.model.condition
        }
        console.log('info数据', batch.condition)
        this.$resetpost('rs/logic/batchtaxs', batch, {
          resolveMsg: null,
          rejectMsg: '减免违约金出错!!!'
        }).then((res) => {
          this.$refs.paged.$refs.cri.search()
        })
      },
      // 单个减免操作
      comentsenter (row) {
        // 去除左右两边空格
        row.f_remission_late_fee_vue = row.f_remission_late_fee_vue.replace(/\s+/g, '')
        if (row.f_remission_late_fee_vue === '') {
          return
        }
        if (row.f_remission_late_fee_vue > row.overdue) {
          this.$showMessage('减免金额不能大于违约金')
          row.f_remission_late_fee_vue = ''
          return
        }
        if (row.f_remission_late_fee_vue <= 0) {
          this.$showMessage('减免金额必须大于0')
          row.f_remission_late_fee_vue = ''
          return
        }
        this.chooserow = row
        this.comentsshow = true
      },
      async beforenter (row) {
        console.log('3333333333333333333333')
        let http = new HttpResetClass()
        let handplan = {
          id: row.handplan_id,
          f_remission_late_fee: row.f_remission_late_fee_vue,
          f_operator: Vue.$login.f.name,
          f_old_overdue: row.overdue_base,
          f_new_overdue: row.overdue,
          f_operatorid: Vue.$login.f.id,
          f_orgid: Vue.$login.f.orgid,
          f_orgname: Vue.$login.f.orgs,
          f_depid: Vue.$login.f.depids,
          f_depname: Vue.$login.f.deps,
          f_user_id: row.f_user_id,
          f_userfiles_id: row.f_userfiles_id,
          f_hand_id: row.handplan_id,
          // f_end_date: row.f_end_date,
          f_userinfo_code: row.f_userinfo_code,
          f_comments: row.f_comments
        }
        let res = await http.load('POST', 'rs/logic/overDueTaxun', handplan, {
          resolveMsg: null,
          rejectMsg: '减免违约金出错'
        })
        this.close()
        this.$refs.paged.$refs.cri.search()
      }

    },
    watch: {
      async 'orgCondtionStr' (val) {
        // 更新抄表册
        this.$refs.paged.$refs.cri.model.f_meter_book = []
        this.$refs.paged.$refs.cri.model.f_book_slice_area = []
        this.$refs.paged.$refs.cri.model.f_inputtor = []
        this.meterbooks = [{label: '全部', value: ''}]
        if (this.lastorgstr != val) {
          this.tempfalg = true
          this.lastorgstr = val
        }
        if (this.tempfalg && val != null && val != '' && val.indexOf('(') > -1) {
          this.tempfalg = false
          let a = val.substring(val.indexOf('(') + 2)
          await this.initmeterbook(a.substring(0, a.indexOf(')') - 1))
        }
        let res = val.match(/'(.*?)'/)
        console.log('正则提取:', res && res[1])
        if (res) {
          this.f_filialeid = res[1]
          if (res.input != null) {
            let resorgid = res.input.substring(res.input.indexOf("'"))
            if (resorgid != null && resorgid != '') {
              resorgid = resorgid.substring(0, resorgid.lastIndexOf("'") + 1)
              // resorgid = resorgid.replaceAll("'","");
              resorgid = resorgid.replace(/'/g, '')
              this.allorgid = resorgid.split(',')
            }
          }
          this.updateParams()
        }
      },
      // async 'orgCondtionStr' (val) {
      //   this.meterbooks = [{label: '全部', value: ''}]
      //   this.$set('$refs.paged.$refs.cri.model.f_meter_book', [])
      //   let res = val.match(/'(.*?)'/)
      //   console.log('正则提取:', res)
      //   if (res) {
      //     if (res.input != null) {
      //       let resorgid = res.input.substring(res.input.indexOf("'"))
      //       let condition = ` 1=1 and f_orgid in (${resorgid} and f_book_state='有效' `
      //       let param = {
      //         items: '*',
      //         tablename: 't_meter_book',
      //         condition: condition,
      //         orderitem: 'id'
      //       }
      //       let getMeterBooks = await this.$resetpost('rs/sql/singleTable_OrderBy', {data: param}, {resolveMsg: null, rejectMsg: '获取营收参数出错！！！'})
      //       if (getMeterBooks.data) {
      //         if (getMeterBooks.data.length > 0) {
      //           let rs = []
      //           getMeterBooks.data.forEach((item) => {
      //             let temp = {
      //               label: item.f_book_name,
      //               value: item.id
      //             }
      //             rs.push(temp)
      //           })
      //           this.meterbooks = [{label: '全部', value: ''}, ...rs]
      //         }
      //       }
      //     }
      //   }
      // },
      section_f_start_data (val) {
        if (this.section_f_end_data != '' && val > this.section_f_end_data) {
          this.$showAlert('开始日期不能大于结束日期', 'warning', 1000)
          this.section_f_start_data = ''
        }
        if (val < this.nowRowdate) {
          this.$showAlert('开始日期不能小于抄表日期', 'warning', 1000)
          this.section_f_start_data = ''
        }
        if (val > this.toDayDate) {
          this.$showAlert('开始日期不能大于当前日期', 'warning', 1000)
          this.section_f_start_data = ''
        }
      },
      section_f_end_data (val) {
        if (val < this.section_f_start_data) {
          this.$showAlert('结束日期不能小于开始日期', 'warning', 1000)
          this.section_f_end_data = ''
          return
        }
        if (val < this.nowRowdate) {
          this.$showAlert('结束日期不能小于抄表日期', 'warning', 1000)
          this.section_f_end_data = ''
          return
        }
        if (val > this.toDayDate) {
          this.$showAlert('结束日期不能大于当前日期', 'warning', 1000)
          this.section_f_end_data = ''
          return
        }
        let temp = {
          f_userfiles_id: this.nowUserfilesId,
          days: parseInt(this.section_f_end_data.replace(/\-/, '').replace(/\-/, '')) - parseInt(this.section_f_start_data.replace(/\-/, '').replace(/\-/, '')),
          handplan_id: this.newHandplanId
        }
        // 获取减免违约金
        this.$resetpost('rs/sql/getLatefee_money', {data: temp}, {
          resolveMsg: null,
          rejectMsg: '获取违约金违约金减免金额失败'
        }).then((res) => {
          if (res.data.length == 1) {
            this.batchtaxs = res.data[0].f_overdue
          } else {
            this.batchtaxs = 0
          }
        })
      }
    }
  }
</script>
<style lang="less" scoped>

</style>

