<template>
  <div class="flex-row" id="machineHandManager">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:paged @sort="sort">
        <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch">
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>

            <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_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">小&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">抄&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="row">
              <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">客户编号</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 v-if="$parent.$parent.jurisdiction.includes('单户抄表')"-->
<!--                        class="button_search button_spacing" style="width:90px" @click="$parent.$parent.danhuShow()">-->
<!--                  单户抄表-->
<!--                </button>-->

                <button class="button_search button_spacing" @click="$parent.$parent.search()">查询</button>
                <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</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>

            <export-excel :data="$parent.$parent.getCondition"
                          :field="$parent.$parent.getfield"
                          sqlurl="rs/logic/saleExport" sql-name="getIotHand" template-name='泰鹏抄表导出'
                          :choose-col="true"></export-excel>
            <div class="row" v-show="$parent.$parent.criteriaShow">



              <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">抄表单状态</label>
                <v-select :value.sync="model.f_meter_state" v-model='model.f_meter_state'
                          style="width:60%" :value-single="true"
                          :options='$parent.$parent.meterstates' placeholder='抄表单状态'
                          close-on-select
                       ></v-select>
              </div>
              <div class="col-sm-2 form-group" >
                <label class="font_normal_body">抄表时间</label>
                <datepicker placeholder="开始日期"
                            style="width:60%"
                            class="datepicker"
                            v-model="model.startDate1"
                            :value.sync="model.startDate1"
                            :format="'yyyy-MM-dd'"
                ></datepicker>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">抄表时间</label>
                <datepicker placeholder="结束日期"
                            style="width:60%"
                            v-model="model.endDate1"
                            :value.sync="model.endDate1"

                            :format="'yyyy-MM-dd'"
                ></datepicker>
              </div>

            </div>
          </div>
        </criteria>
        <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid id="hand_manager_grid">
          <template partial='head'>
            <tr>
              <!--<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>
                  <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>
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center;">{{ $index + 1 }}</td>
            <td>{{ row.f_userinfo_code }}</td>
            <td>{{ row.f_user_name }}&nbsp;&nbsp;{{ row.f_address }}</td>
            <td>{{ row.f_user_phone }}</td>
            <td>{{ row.f_idnumber }}</td>
            <td>{{ row.f_card_id }}</td>
            <td>{{ row.f_meternumber }}</td>
            <td>{{ row.f_table_state }}</td>
            <td>{{ row.f_meter_base }}</td>
            <td id="hand-creat" >
              <div class="form-group" style="margin-bottom:0px;display: contents;" :class="{
                       'has-success has-feedback': !row.error,
                       'has-error has-feedback': row.error}"
              >
                <input title="只能录入整数" type="text" class="input_search" v-model="row.f_tablebase"
                       @blur="$parent.$parent.$parent.beforenter($index, row)"
                       v-next-el="{id: $index+2}" :id="$index+1" style="width: 100px;padding: 6px;"
                       @focus="$parent.$parent.$parent.clearError(row)"
                       :disabled="row.state === '开始'">
              </div>
            <td>{{ row.f_last_input_date }}</td>
            <td>{{ row.f_inputtor }}</td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>
<script>
import MixPriceInfo from '../../components/revenue/base/leftview/MixPriceInfo'
import {PagedList, HttpResetClass} from 'vue-client'
import  * as Util from '../../Util'
import Vue from 'vue'
import co from 'co'
export default {
  title: '鹏泰表抄表',
  components: {MixPriceInfo},
  data() {
    return {
      priceModel: false,
      initres: {
        org: [this.$login.f.orgid],
        dep: [],
        user: []
      },
      sumsmodel: [],
      orgCondtionStr: '',
      priceSplit: false,
      deletestate: false,
      criteriaShow: false,
      model: new PagedList('rs/sql/getIotHand', 50, {orderitem: this.orderDefault ? '"' + this.orderDefault + ' "' : `'f_hand_date desc'`}),
      meter_state: false, // 是否显示计划下发按钮
      downModel: {
        downDate: Vue.$login.toStandardTimeString(),
        downWay: 'downWithUserfiles',
        downInputtor: []
      },
      meterstates: this.$appdata.getParam('抄表状态') ? [{label: '全部', value: ''}, ...this.$appdata.getParam('抄表状态')] : [],
      inputtorModel: {
        inputtor: [],
        reason: ''
      },
      auditState: [{label: '全部', value: ''}, {label: '未抄表', value: '未抄表'}, {
        label: '待审核',
        value: '待审核'
      }, {label: '已抄表', value: '已抄表'}],
      // 小区
      residentialArea: [],
      //  downDate: this.$login.toStandardYearMonth().replace("-", ""),
      msg: '',
      condition: '',
      headers: {'username': Vue.$login.f.name, 'blodid': Vue.$login.guid()},
      orderDefault: 'f_hand_date',
      orderFields: {
        f_userinfo_id: 'no'
      },
      getfield: {
        'f_userinfo_code': '客户编号',
        'f_user_name': '客户姓名',
        'f_address': '客户地址',
        'f_user_phone': '用户电话',
        'f_idnumber': '身份证号',
        'f_card_id': '卡号',
        'f_meternumber': '表号',
        'f_table_state': '表具状态',
        'f_meter_base': '上期底数',
        'f_tablebase': '本期底数',
        'f_last_input_date': '最近一次抄表时间',
        'f_inputtor': '抄表员'
      },
      outlet: '',
      filiale: '',
      condition2: '',
      area: [],
      inputtouPerson: [],
      usertypes: this.$appdata.getParam('客户类型') ? [{
        label: '全部',
        value: ''
      }, ...this.$appdata.getParam('客户类型')] : [],
      f_filialeid: this.$login.f.orgid,
      upshow: false,
      inputid: 0,
      examineshow: false,
      examinerow: null,
      showfiles: false,
      uploadText: '抄表',
      examinetype: false,
      err: '',
      // 请求对象(批量导入,查询进度使用)
      HttpReset: new HttpResetClass(),
      // 气价使用详情展示
      detailsShow: false,
      row: null,
      // 应抄底数
      should_base: 0
    }
  },
  ready() {
    this.getaddress()
  },
  methods: {
    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
    },
    getRes(obj) {
      this.orgCondtionStr = obj
    },

    hidden() {
      console.log(this.criteriaShow )
      this.criteriaShow = !this.criteriaShow
      console.log(this.criteriaShow )
    },
    clear() {
      Object.keys(this.$refs.paged.$refs.criteria.model).forEach((key) => {
        this.$refs.paged.$refs.criteria.model[key] = []
      })
    },

    search() {
      // 查询前清空选择项
      this.$refs.paged.$refs.criteria.search()
    },

    selfSearch(args) {
      if (!this.orgCondtionStr) {
        args.condition = `${args.condition}` + ' and f_orgid = ' + this.$login.f.orgid
      } else {
        args.condition = `${args.condition}` + this.orgCondtionStr
      }
      // 抄表员查询条件
      // this.inputtouPerson = this.$refs.paged.$refs.criteria.model.f_inputtor
      // if (this.inputtouPerson.length !== 0) {
      //   let str = JSON.stringify(this.inputtouPerson)
      //   str = str.replace(/"/g, `'`)
      //   str = str.replace(/\[/g, ``)
      //   str = str.replace(/\]/g, ``)
      //   console.log('=====抄表员model22222222222绑定====', str)
      //   // 查询多个抄表员时条件
      //   args.condition += ` and f_inputtor in  ( ${str} )`
      // }
      // 小区查询条件
      this.area = this.$refs.paged.$refs.criteria.model.f_residential_area
      console.log('=====小区model绑定====', this.area)
      if (this.area.length !== 0) {
        let str = JSON.stringify(this.area)
        str = str.replace(/"/g, `'`)
        str = str.replace(/\[/g, ``)
        str = str.replace(/\]/g, ``)
        console.log('=====小区model22222222222绑定====', str)
        // 查询多个小区时条件
        args.condition += ` and f_residential_area in  ( ${str} )`
      }
      this.condition2 = args.condition
      if (this.$refs.paged.$refs.criteria.model.f_meter_state === '未抄表') {
        if (this.$refs.paged.$refs.criteria.model.startDate1 && this.$refs.paged.$refs.criteria.model.endDate1) {
          this.condition2 = this.condition2 + ` and (f_last_input_date<'${this.$refs.paged.$refs.criteria.model.startDate1}' or f_last_input_date>'${this.$refs.paged.$refs.criteria.model.endDate1}')`
        } else {
          if (this.$refs.paged.$refs.criteria.model.startDate1) {
            this.condition2 = this.condition2 + ` and f_last_input_date<'${this.$refs.paged.$refs.criteria.model.startDate1}'`
          }
          if (this.$refs.paged.$refs.criteria.model.endDate1) {
            this.condition2 = this.condition2 + ` and f_last_input_date>'${this.$refs.paged.$refs.criteria.model.endDate1}'`
          }
        }
      } else {
        if (this.$refs.paged.$refs.criteria.model.startDate1) {
          this.condition2 = this.condition2 + ` and f_last_input_date>='${this.$refs.paged.$refs.criteria.model.startDate1}'`
        }
        if (this.$refs.paged.$refs.criteria.model.endDate1) {
          this.condition2 = this.condition2 + ` and f_last_input_date<='${this.$refs.paged.$refs.criteria.model.endDate1}'`
        }
      }
      this.model.search(this.condition2, this.model)
    },
    reflash() {
      this.$refs.paged.$refs.criteria.model.f_orgid = `${Vue.$login.f.orgid}`
      this.$refs.paged.$refs.criteria.model.startDate = this.$login.toStartAndEndDateString()[0]
      this.$refs.paged.$refs.criteria.model.endDate = this.$login.toStartAndEndDateString()[1]
      this.search()
    },
    beforenter(index, row) {
      this.inputid = index + 1
      // 限制本次抄表不能低于上次
      if (row.f_tablebase) {
        if (row.f_tablebase < 0) {
          row.state = '失败'
          Vue.set(row, 'error', '底数不能小于0')
          this.speckText('底数不能小于0，请注意!')
        } else {

        let param = {
          f_userfiles_id:row.f_userfiles_id,
          f_meter_base:row.f_tablebase,
          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: Vue.$login.f.depids,
          f_depname: Vue.$login.f.deps,
          downDate:Util.toStandardTimeString()
        }
          this.$resetpost('rs/logic/iotHand',{data:param},).then((res)=>{
            this.$refs.paged.$refs.criteria.search()
            // if(res.data.code==='0000'){
            //   console.log(res.data)
            //
            //   self.$showAlert('提交成功！！', 'info', 5000)
            // }else {
            //   self.$showAlert(res.data.msg, 'info', 5000)
            // }

          })
        }
      }
    },

    clearError(row) {
      if (row.f_tablebase === 0) {
        row.f_tablebase = ''
      }
      Vue.set(row, 'error', null)
    },
    async speckText(str) {
      var url = 'http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&spd=6&text=' + encodeURI(str)
      await new Audio(url).play()
      this.err = str
      this.showerr = true
      this.paycodefocus()
    },
    closeerr() {
      this.showerr = false
    },
    fileUpload() {
      this.uploadshow = true
    },
    // 删除这条计划
    delectHand(row) {
      this.$showMessage('删除后不可恢复，确认删除吗？', ['confirm', 'cancel']).then((res) => {
        if (res === 'confirm') {
          this.$resetpost('rs/logic/deletePlan', {data: row}).then(() => {
            this.$dispatch('refresh', '删除计划', row)
            this.search()
          })
        }
      })
    },
    cancelHand4(row) {
      this.examinerow = row
      this.examineshow = true
      this.examinetype = true
    },
    cancelHand2(row) {
      if (this.config.examine) {
        let handdate = new Date(row.f_hand_date)
        console.log('获取月份', handdate.getMonth())
        let ima = new Date()
        console.log('获取月份', ima.getMonth())
        if (handdate.getMonth() == ima.getMonth()) {
          this.cancelHand3(row)
        } else {
          if (!this.$login.r.find(value => value == '抄表隔月冲正')) {
            this.$showMessage('当前登录用户没有隔月冲正权限, 请联系管理员!')
          } else {
            this.cancelHand3(row)
          }
        }
      } else {
        this.cancelHand3(row)
      }
    },
    async cancelHand5() {
      let sqldata = `update t_handplan set f_audit_state ='已审核',f_audit_person='${this.$login.f.name}',
        f_audit_date='${this.$login.toStandardTimeString()}' where  id ='${this.examinerow.id}'`
      await this.$resetpost('rs/logic/runSQL', {data: {sql: sqldata}}, {
        resolveMsg: null,
        rejectMsg: '更新收费记录订单号失败'
      })

      this.cancelHand3(this.examinerow)
    },
    cancelHand3(row) {
      // 抄表加入权限
      if (!this.$login.r.find(value => value == '机表抄表冲正')) {
        this.$showMessage('当前登录用户没有冲正权限, 请联系管理员!')
        return
      }
      // console.log('抄表冲正。、。。、', row)
      let param = {
        f_hand_id: row.id,
        operInfo: {
          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
        }
      }
      let url = 'rs/logic/sale_commonEnterCancel'
      this.$resetpost(url, {data: param}, {warnMsg: '确定对这条记录进行撤销吗？'}).then(() => {
        this.search()
        this.close()
      })
    },
    down(type, condition, data) {
      co(downGen(type, condition, data, this))
    },
    // 单条下发计划
    downHand(row) {
      console.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + row.f_userfiles_id)
      this.down('single', `f_userfiles_id = '${row.f_userfiles_id}'`, row)
    },
    // 批量下发计划
    batchDownHand() {
      this.down('batch', this.model.condition, this.model.count)
    },
    // batchDownHand () {
    //   this.condition = ''
    //   let count = 0
    //   for (let plan of this.plans){
    //     if(plan.state){
    //       this.condition = this.condition + plan.id + ','
    //       count = count + 1
    //     }
    //   }
    //   this.down('batch', `f_user_id in (${this.condition.substring(0,this.condition.length-1)})`,count)
    // },
    // allDownHand () {
    //   this.down('all', this.model.condition, this.model.count)
    // },

    validateDate() {
      let currentDown = new Date(this.downModel.downDate)
      console.log(new Date(this.$refs.paged.$refs.criteria.model.startDate))
      console.log(new Date(this.$refs.paged.$refs.criteria.model.endDate))
      return currentDown >= new Date(this.$refs.paged.$refs.criteria.model.startDate + ' 00:00:00') && currentDown <= new Date(this.$refs.paged.$refs.criteria.model.endDate + ' 23:59:59')
    },

    async examineconfirm() {
      let sqldata = `update t_handplan set f_audit_state ='审核中',f_examinereason='${this.examinerow.f_examinereason}' where  id ='${this.examinerow.id}'`
      await this.$resetpost('rs/logic/runSQL', {data: {sql: sqldata}}, {resolveMsg: null, rejectMsg: null})
      this.close()
      this.search()
    },
    // 关闭下发计划得弹出框
    close() {
      this.show = false
      this.inputtor_show = false
      this.downConfirm = false
      this.examineshow = false
      this.examinetype = false
      this.detailsShow = false
      this.priceModel = false
      // 初始化模态框数据
      this.initModal()
      if (this.uploadshow) {
        this.uploadshow = false
        // 讲选的文件清空
        this.$refs.file.$el.querySelector('input').value = ''
      }
    },
    initModal() {
      this.downModel = {
        downDate: Vue.$login.toStandardDateString(),
        downWay: 'downWithUserfiles',
        downInputtor: []
      }
      this.inputtorModel = {
        inputtor: [],
        reason: ''
      }
    },
    // 判断当前登陆人是不是子公司的人员
    isHead() {
      return this.$login.f.parent.parent.name.includes('统一资源管理')
    },
    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.orderDefault}'`
      } else {
        this.model.paramSource.orderitem = `'${field} ${rule}'`
      }
      this.search()
    },
    guid() {
      return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        let r = Math.random() * 16 | 0,
          v = c == 'x' ? r : (r & 0x3 | 0x8)
        return v.toString(16)
      })
    },
    computeAmount(event) {
      let money = event.target.value
      if (this.row.f_price_type === '固定气价') {
        let price = this.$refs.mix_price.model.f_price
        // 可以购买的总气量
        let purchaseSum = (money / price).toFixed(2)
        // 计算应抄底数
        this.should_base = (this.row.f_last_tablebase - 0) + (purchaseSum - 0)
        // 计算公式
        this.designFormulas = `${purchaseSum}X${price}`
      } else {
        let mydata = this.$refs.statir.mydata
        // 剩余1阶气量
        let surplus1 = (mydata.f_stair1ceiling - (mydata.f_hasuse1 > 0 ? mydata.f_hasuse1 : 0))
        // 把1阶买完的钱
        let price1 = surplus1 * mydata.f_stair1price
        // 剩余2阶气量
        let surplus2 = (mydata.f_stair2ceiling - mydata.f_stair1ceiling - (mydata.f_hasuse2 > 0 ? mydata.f_hasuse2 : 0)).toFixed(2)
        // 把2阶买完的钱
        let price2 = surplus2 * mydata.f_stair2price
        // 兼容一下
        if (this.$refs.statir.jt != 3) {
          this.$showMessage('暂不支持该气价类型的运算,请联系开发人员!')
        }
        // 开始计算
        // 可以购买各阶梯量
        let purchase1 = 0
        let purchase2 = 0
        let purchase3 = 0
        if (money <= price1) {
          purchase1 = (money / mydata.f_stair1price).toFixed(2)
        } else if (money <= (price1 + price2)) {
          purchase1 = surplus1
          purchase2 = ((money - price1) / mydata.f_stair2price).toFixed(2)
        } else {
          purchase1 = surplus1
          purchase2 = surplus2
          purchase3 = ((money - price1 - price2) / mydata.f_stair3price).toFixed(2)
        }
        // 可以购买的总气量
        let purchaseSum = (purchase1 - 0) + (purchase2 - 0) + (purchase3 - 0)
        // 计算应抄底数
        this.should_base = (this.row.f_last_tablebase - 0) + purchaseSum
        // 计算公式
        this.designFormulas = `${purchase1}X${mydata.f_stair1price} + ${purchase2}X${mydata.f_stair2price} + ${purchase3}X${mydata.f_stair3price}`
      }
      this.should_base = this.should_base.toFixed(2) - 0
    }
  },
  watch: {
    'downModel.downWay'(val) {
      if (val === 'downWithSelf') {
        console.log('抄表员。。', this.inputtores2)
        if (this.inputtores2.length > 0) {
          this.downModel.downInputtor = [this.inputtores2[0].value]
        }
      }
    },
    'detailsShow'(val) {
      if (!val) {
        this.should_base = 0
        this.designFormulas = null
        this.$els.inputmoney.value = 0
      }
    }
    // 'model.rows'(val){
    //   console.log('页面切换',val)
    //   if(this.isChooseAll(val)){
    //     this.all = true
    //   }else{
    //     this.all = false
    //   }
    // },
  },
  computed: {
    danhutitle() {
      return '单户抄表    当前计划年月：' + this.downModel.downDate
    },
    getCondition() {
      // return {condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr}
      return {
        startDate: this.$refs.paged.$refs.criteria.model.startDate,
        endDate: this.$refs.paged.$refs.criteria.model.endDate,
        orderitem: this.orderDefault ? this.orderDefault : 'id',
        condition: this.condition2
      }
    },

    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]
    },
    whetherpaies() {
      return [
        {label: '全部', value: ''},
        {label: '已缴费', value: '是'},
        {label: '未缴费', value: '否'}
      ]
    },
    // 界面细节权限
    jurisdiction() {
      console.log('抄表界面细节', this.$login.r)
      return this.$login.r ? this.$login.r : []
    }
  }
}
</script>
<style lang="less">
#handManager {
  display: flex;
  justify-content: space-around;
  align-items: center;

  .btn {
    margin: 0px;
  }

  .hand-loading {
    border: 3px solid #ccc;
    border-right-color: #337ab7;
    border-radius: 50%;
    animation: spin 0.6s linear;
    position: absolute;
    animation-iteration-count: infinite;
    top: 0;
    right: 50%;
    z-index: 2;
    display: block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    pointer-events: none;
  }

  @keyframes spin {
    100% {
      transform: rotate(360deg);
    }
  }

  .detail-panel {
    text-align: center;
    color: #31708f;
    background-color: #e8f1f9;
    border-color: #F2F6FA;
  }
}

#hand_manager_grid {
  thead {
    position: relative;
    z-index: 2;
  }
}

#machineHandManager {
  .color-red {
    color: red;
  }
}
</style>
