<template>
  <div class="basic-main" style="height: 98%">
    <div class="flex">
      <criteria-paged :model="model" v-ref:paged>
        <criteria partial='criteria' v-ref:cri @condition-changed="$parent.selfSearch">
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <!--<div class="col-sm-6">-->
              <!--style="border: 1px solid #a6d5ea; box-shadow: darkgrey 1px 1px 1px 2px;padding: 0.5%">-->
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">下发日期</label>
                <datepicker placeholder="开始日期"
                            style="width:60%"
                            class="datepicker"
                            v-model="model.startDate"
                            :value.sync="model.startDate"
                            condition="f_hand_date >='{} 00:00:00'"
                            :format="'yyyy-MM-dd'"
                ></datepicker>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">&emsp;&emsp;至&emsp;</label>
                <datepicker placeholder="结束日期"
                            style="width:60%"
                            v-model="model.endDate"
                            :value.sync="model.endDate"
                            condition="f_hand_date <='{} 23:59:59'"
                            :format="'yyyy-MM-dd'"
                ></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="span" style="float:right;">

                <button class="button_search button_spacing" @click="$parent.$parent.search()">查询</button>
                <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
                <export-excel
                  :data="{condition: $parent.$parent.excelCondition}"
                  :field="$parent.$parent.fields"
                  sqlurl="rs/logic/saleExport" progress="saleGetExportProgress" sql-name="getAuditMachineHand"
                  template-name='抄表审核导出'
                  :choose-col="true">
                </export-excel>
                <button class="button_search button_spacing width-60"
                        @click="$parent.$parent.allsuccess()" v-el:cx>全部通过</button>
                <button class="button_search button_spacing width-60"
                        @click="$parent.$parent.allfaild()" v-el:cx>全部不通过</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">表&ensp;编&ensp;号</label>-->
              <!--                <input type="text" style="width:60%" class="input_search" v-model="model.f_user_id"-->
              <!--                       condition="f_user_id='{}'" placeholder='表编号'>-->
              <!--              </div>-->
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">抄表状态</label>
                <v-select :value.sync="model.f_audit_state"
                          class="select_list select"
                          v-model="model.f_audit_state"
                          style="width: 60%"
                          condition="f_meter_state = '{}'"
                          :options='$parent.$parent.auditState' placeholder='请选择'
                          close-on-select v-el:cc>
                </v-select>
              </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_meternumber"
                       condition="f_meternumber like '%{}%'" 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" placeholder='客户姓名'
                       condition="f_user_name = '{}'">
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">小&ensp;&ensp;&ensp;&ensp;区</label>
                <v-select :value.sync="model.f_residential_area"
                          class="select_list select"
                          enter-push
                          v-model="model.f_residential_area"
                          style="width: 60%"
                          multiple="true"
                          :options='$parent.$parent.residentialArea' placeholder='选择小区'
                          close-on-select v-el:cc>
                </v-select>
              </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_building"
                       condition="f_building = '{}'" 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_unit"
                       condition="f_unit = '{}'" 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_floor"
                       condition="f_floor = '{}'" placeholder='楼层'>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">门&ensp;牌&ensp;号</label>
                <input type="text" style="width:60%" class="input_search" v-model="model.f_room"
                       condition="f_room like '%{}%'" 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_address"
                       condition="f_address like '%{}%'" placeholder='客户地址'>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">抄&ensp;表&ensp;员</label>
                <v-select :value.sync="model.f_inputtor" v-model='model.f_inputtor'
                          style="width:60%"
                          multiple="true"
                          condition="f_inputtor in {}"
                          :options='$parent.$parent.inputtores' placeholder='抄表员'
                          close-on-select
                          v-el:cc></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='客户类型'
                          style="width:60%"
                          close-on-select
                          condition="f_user_type = '{}'"></v-select>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">用户等级</label>
                <v-select :value.sync="model.f_user_level" v-model="model.f_user_level"
                          :options='$parent.$parent.userlevels' placeholder='用户等级'
                          style="width:60%"
                          close-on-select
                          condition="f_user_level = '{}'"></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='抄表册'
                          style="width:60%"
                          :multiple="true"
                          condition="f_meter_book_num in {}"></v-select>
              </div>
              <div class="col-sm-2 flex-row" style="white-space: nowrap" >
                <label  class="font_normal_body">应交气量</label>
                <div class="row">
                  <input type="text" style="width:30%" class="input_search" v-model="model.oughtamountmin"
                         condition="f_oughtamount >= {} " placeholder="">
                  <label   class="font_normal_body">  ≤ x ≤ </label>
                  <input type="text" style="width:30%" class="input_search" v-model="model.oughtamountmax"
                         condition="f_oughtamount <= {} " placeholder="">
                </div>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">审核状态</label>
                <v-select :value.sync="model.f_audit_state_1"
                          class="select_list select"
                          v-model="model.f_audit_state_1"
                          style="width: 60%"
                          condition="f_audit_state = '{}'"
                          :options='$parent.$parent.auditState1' placeholder='请选择'
                          close-on-select v-el:cc>
                </v-select>
              </div>
              <res-select-group :initres="$parent.$parent.initres" @re-res="$parent.$parent.getRes"
                                v-ref:sel></res-select-group>
            </div>

          </div>
        </criteria>
        <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid id="hand_manager_grid" :optional="true">
          <template partial='head'>
            <tr>
              <th> <nobr>审核</nobr></th>
              <!--<th><input type='checkbox' v-model="$parent.$parent.$parent.all" @change="$parent.$parent.$parent.chooseAll"></th>-->
              <th>
                <nobr>序号</nobr>
              </th>
              <th>
                <nobr>客户编号
                  <!--                  <data-order field="f_userinfo_code" name="客户编号"-->
                  <!--                              :order.sync="$parent.$parent.$parent.orderFields.f_userinfo_code"></data-order>-->
                </nobr>
              </th>
              <!--              <th>-->
              <!--                <nobr>表编号</nobr>-->
              <!--              </th>-->
              <!--              <th>基本信息</th>-->
              <th>
                <nobr>
                  基本信息
                  <!--                  <data-order field="f_address" name="基本信息"-->
                  <!--                              :order.sync="$parent.$parent.$parent.orderFields.f_address"></data-order>-->
                </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>上次抄表日期</th>-->
              <th>
                <nobr>
                  上次抄表录入日期
                  <!--                  <data-order field="f_last_input_date" name="上次抄表录入日期"-->
                  <!--                              :order.sync="$parent.$parent.$parent.orderFields.f_last_input_date"></data-order>-->
                </nobr>
              </th>
              <!--              <th>下发日期</th>-->
              <th>
                <nobr>下发日期
                  <!--                  <data-order field="f_hand_date" name="下发日期"-->
                  <!--                              :order.sync="$parent.$parent.$parent.orderFields.f_hand_date"></data-order>-->
                </nobr>
              </th>
              <!--              <th>抄表日期</th>-->
              <th>
                <nobr>抄表录入日期
                  <!--                  <data-order field="f_input_date" name="抄表录入日期"-->
                  <!--                              :order.sync="$parent.$parent.$parent.orderFields.f_input_date"></data-order>-->
                </nobr>
              </th>
              <!--              <th>抄表册</th>-->
              <th>
                <nobr>抄表册
                  <!--                  <data-order field="f_book_name" name="抄表册"-->
                  <!--                              :order.sync="$parent.$parent.$parent.orderFields.f_book_name"></data-order>-->
                </nobr>

              </th>
              <th>
                <nobr>调压箱名称</nobr>
              </th>
              <th>
                <nobr>抄表员</nobr>
              </th>
              <th><nobr>附件</nobr></th>
              <!--              <th><nobr>附件</nobr></th>-->
              <!--            f_oughtfee-->
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center;" class="row auto">
              <nobr>
                <button type="button" name="button" class="button_search button_spacing width-60"
                        @click.stop="$parent.$parent.$parent.pass(row)"
                        v-if="row.f_meter_state === '待审核'">通过
                </button>

                <button type="button" name="button" class="button_search button_spacing width-60"
                        @click.stop="$parent.$parent.$parent.nopass(row)"
                        v-if="row.f_meter_state === '待审核' ">不通过
                </button>
              </nobr>
            </td>
            <td style="text-align: center;">{{$index + 1}}</td>
            <td>{{row.f_userinfo_code}}</td>
            <!--            <td>{{row.f_user_id}}</td>-->
            <td> <nobr>{{row.f_user_name}}&nbsp;&nbsp;{{row.f_address}} </nobr></td>
            <td>{{row.f_user_level}}</td>
            <!--<td>{{row.f_building}}</td>-->
            <!--<td>{{row.f_unit}}</td>-->
            <!--<td>{{row.f_room}}</td>-->
            <td>{{row.f_balance}}</td>
<!--            <td style="text-align: center;">{{Math.round(row.avggas)}}</td>-->
            <td>{{row.f_meternumber}}</td>
            <td>{{row.f_meter_base}}</td>
            <td id="hand-creat" style="display: flex;justify-content: space-between;align-items: center">
              <b>{{row.f_tablebase}}</b>
              <button type="button" name="button" class="button_search button_spacing width-60"
                      @click.stop="$parent.$parent.$parent.amend(row)">修正
              </button>
            </td>
            <td style="text-align: center;">{{row.f_oughtamount}}</td>
            <td style="text-align: center;">{{row.f_adjustment_volume}}</td>
            <td style="text-align: center;">{{row.f_oughtfee}}</td>
            <td>{{row.f_result_state}}</td>
            <td><nobr>{{row.f_last_input_date}}</nobr></td>
            <td><nobr>{{row.f_hand_date}}</nobr></td>
            <td><nobr>{{row.f_input_date}}</nobr></td>
            <td> <nobr>{{row.f_book_name}} </nobr></td>
            <td>{{row.f_adjustable_name}}</td>
            <td>{{row.f_inputtor}}</td>
            <td style="text-align: center;"><nobr>
              <img-self :src="row.f_handplan_image" v-if="row.f_handplan_image" :width="50" :height="50"></img-self>

              <!--              <button v-if="row.is_has_file=='是'" class="btn btn-link" @click.stop="$parent.$parent.$parent.view(row)">查看</button>-->
              <button v-if="row.f_notified_path" class="btn btn-link" @click.stop="$parent.$parent.$parent.imgShow(row.f_notified_path)">图像识别</button>
            </nobr></td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
  <modal :show.sync="imgshow" v-ref:modal backdrop="true">
    <header slot="modal-header" class="modal-header">
      抄表图像识别照片
    </header>
    <article slot="modal-body" class="modal-body">
      <div class="from-group">
        <img-self :src="imgfilename"   width="500" height="500"></img-self>
      </div>
    </article>
    <footer slot="modal-footer" class="modal-footer">
      <button type="button" class="btn btn-success" @click='imgclose'>关闭</button>
    </footer>
  </modal>
</template>
<script>
  import {HttpResetClass, PagedList} from 'vue-client'
  import Vue from 'vue'
  import * as Util from '../../../../Util'

  let readyGen = async function (self) {
    self.$refs.paged.$refs.cri.model.startDate = self.$login.toStartAndEndDateString()[0]
    self.$refs.paged.$refs.cri.model.endDate = self.$login.toStandardDateString()
    await self.$LoadParams.loadMeterBook(self.f_filialeid)
    self.loadMeterBooks()
    self.getaddress()
  }

  export default {
    title: '机表抄表审核',
    data () {
      return {
        // 请求对象(批量导入,查询进度使用)
        HttpReset: new HttpResetClass(),
        timer: null,
        model: new PagedList('rs/sql/getAuditMachineHand', 50),
        initres: {
          org: [this.$login.f.orgid],
          dep: [],
          user: []
        },
        show: false,
        config: {
          examine: false
        },
        imgfilename: '',
        // 小区
        residentialArea: [],
        imgshow: false,
        criteriaShow: false,
        orgCondtionStr: '',
        excelCondition: '',
        condition: '',
        fields: {
          'f_userinfo_code': '客户编号',
          'f_user_name': '客户名称',
          'f_address': '客户地址',
          'f_user_level': '用户等级',
          'f_balance': '上期结余',
          'f_meternumber': '表号',
          'f_meter_base': '上期底数',
          'f_tablebase': '本期底数',
          'f_oughtamount': '应交气量',
          'f_adjustment_volume': '增量值',
          'f_oughtfee': '应交金额',
          'f_result_state': '抄表结果状态',
          'f_last_input_date': '上次抄表录入日期',
          'f_hand_date': '下发日期',
          'f_input_date': '抄表录入日期',
          'f_book_name': '抄表册',
          'f_adjustable_name': '调压箱名称',
          'f_inputtor': '抄表员'
        },
        auditState: [{label: '全部', value: ''}, {label: '已审核', value: '已抄表'}, {label: '未审核', value: '待审核'}],
        auditState1: [{label: '全部', value: ''}, {label: '审核失败', value: '审核失败'}],
        meters: [{label: '全部', value: ''}, {label: '机表', value: '机表'}, {label: '物联网表', value: '物联网表'}],
        resultstate: this.$appdata.getParam('抄表结果状态'),
        meterstates: this.$appdata.getParam('抄表状态') ? [{
          label: '全部',
          value: ''
        }, ...this.$appdata.getParam('抄表状态')] : [],
        usertypes: this.$appdata.getParam('客户类型') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('客户类型')] : [],
        userlevels: this.$appdata.getParam('用户等级') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('用户等级')] : [],
        adjustablename: this.$appdata.getParam('调压箱名称') ? [{
          label: '全部',
          value: ''
        }, ...this.$appdata.getParam('调压箱名称')] : [],
        meterbooks: [],
        // 公司下拉
        curorgid: [this.$login.f.orgid]
      }
    },
    props: [],
    beforeDestroy () {
      // 销毁定时器
      if (this.timer) clearInterval(this.timer)
    },
    ready () {
      this.model.pageSizeMax = 9999999
      readyGen(this)
    },
    methods: {
      // 修正本期底数
      amend (row) {
        let tablebase = window.prompt('请输入你要修正的底数值，上期底数：' + row.f_meter_base)
        if (!tablebase) return
        if (tablebase < 0) {
          this.$showAlert(`底数不能小于0，请注意!`, 'warning', 2000)
          return
        } else if (tablebase - parseInt(tablebase) !== 0) {
          this.$showAlert(`底数只能输入整数，请注意!`, 'warning', 2000)
          return
        } else if (tablebase < row.f_last_tablebase && !row.f_capacity) {
          this.$showAlert(`本期表底数不能低于上期表底数`, 'warning', 2000)
          return
        } else {
          if (tablebase < row.f_last_tablebase) {
            this.$showMessage('本次抄表已超越最大量程, 请熟知!')
          }
        }
        let oughtamount = null
        if (tablebase) {
          if (row.f_share_gas) {
            oughtamount = (tablebase - 0 - (row.f_last_tablebase - 0)).toFixed(4) + (row.f_share_gas > 0 ? '+' : '') + row.f_share_gas.toFixed(2)
          } else {
            if (row.f_capacity && row.f_capacity > 0 && tablebase < row.f_last_tablebase) {
              oughtamount = (tablebase - 0 + (row.f_capacity - row.f_last_tablebase)).toFixed(2)
            } else {
              oughtamount = (tablebase - 0 - (row.f_last_tablebase - 0)).toFixed(2)
            }
          }
        } else {
          oughtamount = 0
        }
        let handplan = {
          id: row.id,
          f_tablebase: tablebase,
          f_oughtamount: oughtamount
        }
        this.$resetpost('rs/entity/t_handplan', handplan, {resolveMsg: '修正成功', rejectMsg: '抄表数据修正出错!!!'}).then((res) => {
          row.f_tablebase = tablebase
          row.f_oughtamount = oughtamount
        })
      },
      async allsuccess () {
        console.log('条件:', this.condition)
        let res = await this.$showMessage('确定通过全部抄表吗?操作后将不可取消', ['confirm', 'cancel'])
        let con = []
        if (res === 'confirm') {
          let rowdata = this.$refs.paged.$refs.grid.getRowData()
          let length = rowdata.length
          let condition = rowdata.length == 0 ? this.condition : '1=1'
          if (1) {
            if (rowdata.length > 0) {
              for (let i = 0; i < rowdata.length; i++) {
                let temp = {
                  f_hand_id: rowdata[i].id,
                  // 本次表底数
                  f_tablebase: rowdata[i].f_tablebase,
                  // 表类型
                  f_meter_classify: rowdata[i].f_meter_classify,
                  // 气表品牌
                  f_meter_brand: rowdata[i].f_meter_brand,
                  f_audit_person: this.$login.f.name
                }
                con.push(temp)
              }
            }
            let data = {
              con: con,
              condition: condition,
              f_audit_person: this.$login.f.name
            }
            let jobParam = {
              f_operatorid: this.$login.f.id,
              total: length,
              operator: this.$login.f.orgs + ':' + this.$login.f.deps + ':' + Vue.$login.f.name,
              jobType: '抄表审核'
            }
            let param = {
              batchParam: data,
              jobParam: jobParam
            }
            if (length > 0) {
              let confirm = await this.$showMessage(`您即将开始执行一个类型为【${jobParam.jobType}】的新任务,任务总量为${jobParam.total},是否执行?`, ['confirm', 'cancel'])
              if (confirm === 'confirm') {
                try {
                  this.$showMessage(`【立即执行】批量执行${jobParam.jobType}任务添加成功,可在【我的任务】查看任务进度!`)
                  let res = await this.$resetpost('rs/business/batchRun/handPlanAudit', {data: param}, {resolveMsg: '执行成功', rejectMsg: '执行失败'}, 1000 * 60 * 1)
                  console.log('111111', res)
                  this.$showMessage(`成功批量审核了${res.data.successnum}条数据`)
                } catch (e) {}
              }
            } else {
              let data = {
                condition: condition,
                f_audit_person: this.$login.f.name
              }
              let param = {
                sqlParam: data,
                jobParam: jobParam,
                isNowRun: true // 是否立即执行
              }
              let confirm = await this.$showMessage(`您即将开始执行一个类型为【${jobParam.jobType}】的执行任务,是否执行?`, ['confirm', 'cancel'])
              if (confirm === 'confirm') {
                try {
                  // this.$showMessage(`【闲时执行】批量执行${jobParam.jobType}任务添加成功,任务将在【0:00-5:00】闲时执行,可在【我的任务】查看任务进度!`)
                  this.$showMessage(`【立即执行】批量执行${jobParam.jobType}任务添加成功,可在【我的任务】查看任务进度!`)
                  let res = await this.$resetpost('rs/business/batchRun/handPlanAudit/getAuditMachineHandSimple', {data: param}, {resolveMsg: '执行成功', rejectMsg: '执行失败'}, 1000 * 60 * 1)
                  // this.$showMessage(`成功批量添加了${res.data.success}条数据,!!`)
                } catch (e) {}
              }
            }
          } else {
            this.$showMessage('暂无数据，无法通过当前所有抄表')
          }
        }
      },
      async allfaild () {
        let res = await this.$showMessage('确定作废全部抄表吗?操作后将不可取消', ['confirm', 'cancel'])
        let condition = '('
        if (res === 'confirm') {
          let rowdata = this.$refs.paged.$refs.grid.getRowData()
          if (rowdata.length > 0) {
            for (let i = 0; i < rowdata.length; i++) {
              condition += `'` + rowdata[i].id + `',`
            }
            condition = condition.substring(0, condition.length - 1)
            condition += ')'
            let sql = `UPDATE t_handplan SET f_oughtamount=0,f_tablebase=0,f_input_date=null,f_meter_source=null,f_audit_person = '${this.$login.f.name}',f_audit_date = getDate(),f_meter_state = '未抄表' WHERE id in ${condition}`
            await this.$resetpost('rs/logic/runSQL', {sql: sql}, {resolveMsg: '操作成功', rejectMsg: '操作失败'})
            this.search()
          } else {
            this.$showMessage('暂无数据，无法作废当前所有抄表')
          }
        }
      },
      hidden () {
        this.criteriaShow = !this.criteriaShow
      },
      getRes (obj) {
        this.orgCondtionStr = obj
      },
      view (row) {
        this.$parent.showupload = true
        this.$parent.row = row
      },
      imgclose () {
        this.imgshow = false
      },
      imgShow (val) {
        console.log('-----------val2:', val)
        this.imgfilename = `rs/image/file/` + val
        console.log('-----------imgfilename2:', this.imgfilename)
        this.imgshow = true
      },
      async getaddress () {
        console.log('开始获取小区')
        let HttpReset = new HttpResetClass()
        var data = await HttpReset.load('POST', 'rs/sql/manage_getarealist', {
          data: {
            condition: `1=1 and s.f_filialeid = '${this.$login.f.orgid}'`
          }
        }, {resolveMsg: null, rejectMsg: '获取小区失败!'})
        console.log('小区', data)
        let house = []
        house.push()
        for (let row of data.data) {
          console.log('开始保存小区')
          house.push({label: row.f_residential_area, value: row.f_residential_area})
        }
        this.residentialArea = house
      },
      search () {
        this.$refs.paged.$refs.cri.search()
      },
      clear () {
        Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
          this.$refs.paged.$refs.cri.model[key] = []
        })
      },
      selfSearch (args) {
        if (!this.orgCondtionStr) {
          args.condition = `${args.condition}` + ' and f_orgid = ' + this.$login.f.orgid
        } else {
          args.condition = `${args.condition}` + this.orgCondtionStr
        }
        this.excelCondition = args.condition
        this.condition = args.condition
        this.$refs.paged.$refs.grid.selectInit()
        this.model.search(args.condition, args.model)
      },
      pass (row) {
        let param = {
          f_meter_classify: row.f_meter_classify,
          f_meter_brand: row.f_meter_brand,
          f_hand_id: row.id,
          f_tablebase: row.f_tablebase,
          f_userinfo_id: row.f_userinfo_id,
          f_audit_person: Vue.$login.f.name,
          f_adjustment_volume: row.f_adjustment_volume
        }
        this.$resetpost('rs/logic/sale_commonEnter', {data: param}, {resolveMsg: null, rejectMsg: null}).then((res) => {
          row.f_meter_state = res.data.f_meter_state
          row.f_whether_pay = res.data.f_whether_pay
          row.f_oughtfee = res.data.f_oughtfee
          // this.$resetpost('rs/logic/getMeterSms', {data: param}, {resolveMsg: null, rejectMsg: null}).then((res) => {
          // this.search()
          let f_result_state = '正常'
          if (row.f_result_state && row.f_result_state != '') {
            f_result_state = row.f_result_state
          }
          let f_input_date = ''
          if (row.f_input_date && row.f_input_date != '') {
            f_input_date = ` ,f_input_date = '${row.f_input_date}'`
          }
          let sqldata = `update t_handplan set f_result_state = '${f_result_state}' ${f_input_date} where id = '${row.id}'`
          this.$resetpost('rs/logic/runSQL', {data: {sql: sqldata}}, {resolveMsg: null, rejectMsg: '业务单号保存失败'})
          //   }).catch((error) => {
          //   row.state = '失败'
          //  Vue.set(row, 'error', JSON.stringify(error))
          //   this.speckText('抄表出错，请注意!')
          // })
          this.search()
        }).catch((error) => {
          row.state = '失败'
          Vue.set(row, 'error', JSON.stringify(error))
          Vue.showAlert(`审核失败: ${JSON.stringify(error)}`, 'danger', 0)
          this.speckText('抄表出错，请注意!')
        })
      },
      nopass (row) {
        console.log('不通过。。。', row)
        let handplan = {
          id: row.id,
          f_oughtamount: 0,
          f_tablebase: 0,
          f_input_date: null,
          f_meter_state: '未抄表',
          f_meter_source: null,
          f_audit_person: Vue.$login.f.name
        }
        this.$resetpost('rs/entity/t_handplan', handplan, {
          resolveMsg: null,
          rejectMsg: '未通过，抄表数据返回未抄表保存出错!!!'
        }).then((res) => {
          this.search()
        })
      },
      loadMeterBooks () {
        this.meterbooks = this.$GetSaleParam.getMeterBooks()
      }

    },
    computed: {
      inputtores () {
        // 获取抄表员
        console.log('获取抄表员', this.$login.f)
        let rs = []
        if (this.$login.f.f_gasman.length > 0) {
          for (let i = 0; i < this.$login.f.f_gasman.length; i++) {
            let temp = {
              label: this.$login.f.f_gasman[i].name,
              value: this.$login.f.f_gasman[i].name
            }
            rs.push(temp)
          }
        }
        this.inputtores2 = rs
        return [...rs]
      }
    },
    watch: {

    }
  }
</script>
