<template>
  <div id="unit" class="flex-row">
    <div class="basic-main" @keyup.enter="search" v-if="!show">
      <div class="flex">

        <criteria-paged :model="model" v-ref:paged>
          <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
            <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
              <div class="row">
                <div class="col-sm-2 form-group" >
                  <label for="belongmonth" class="font_normal_body" >所属年月</label>
                  <datepicker placeholder="所属年月" style="width:60%"
                              v-model="model.last_month_date"
                              :value.sync="model.last_month_date"
                              :format="'yyyy-MM'"
                              :show-reset-button="true"
                              condition="last_month_date = '{}'"
                              :select-month="true">
                  </datepicker>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户编号</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_userinfo_code"
                         condition="f_userinfo_code = '{}' " placeholder="客户编号">
                </div>
                <div class="col-sm-2 form-group">
                  <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 like '%{}%'" placeholder="客户名称">
                </div>
                <div class="span" style="float:right;">
                  <button class="button_search button_spacing" @click="search()">查询</button>
                  <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
                  <export-excel :data="$parent.$parent.getCondition" :footer="$parent.$parent.footer"
                                :field="$parent.$parent.getfield" :header="$parent.$parent.other"
                                sqlurl="api/af-revenue/logic/openapi/exportfile" sql-name="getWebHandRatioQuery" template-name='抄表查询导出'
                                :choose-col="true"></export-excel>

                  <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
                </div>
              </div>
              <div class="row" v-show="$parent.$parent.criteriaShow">
                <res-select-group :show-component="['company','department','slicearea']" :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_residential_area"
                            class="select_list select"
                            enter-push
                            multiple = "true"
                            v-model="model.f_residential_area"
                            style="width: 60%"
                            :options='$parent.$parent.residentialArea' placeholder='选择小区'
                            close-on-select>

                  </v-select>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">客户地址</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_address"
                         condition="f_address like '%{}%'" placeholder='客户地址'>
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body">&ensp;表&ensp;号&ensp;&ensp;</label>
                  <input type="text" style="width:60%" class="input_search" v-model="model.f_meternumber"
                         condition="f_meternumber = '{}' " placeholder="表号">
                </div>
                <div class="col-sm-2 form-group">
                  <label class="font_normal_body" >抄&nbsp;&nbsp;表&nbsp;员</label>
                  <v-select :value.sync="model.f_inputtor"
                            v-model="model.f_inputtor"
                            :options='$parent.$parent.inputtores' placeholder='请选择'
                            condition="f_inputtor = '{}'"
                            close-on-select :search="false">
                  </v-select>
                </div>
                <div class="col-sm-2 form-group  flex-row" style="white-space: nowrap">
                  <label class="font_normal_body">气量环比&nbsp;</label>
                  <div class="row">
                    <input type="text" style="width:27%" class="input_search" v-model="model.amount_ratio1"
                           condition="amount_ratio >= {} " placeholder="">
                    <label class="font_normal_body"> ≤ x ≤ </label>
                    <input type="text" style="width:27%" class="input_search" v-model="model.amount_ratio2"
                           condition="amount_ratio <= {} " placeholder="">
                  </div>
                </div>

              </div>
            </div>
          </criteria>

          <data-grid :model="model" partial='list' class="list_area table_sy"  v-ref:grid :classname="$parent.classname">
            <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>
              </tr>
            </template>
            <template partial='body'>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>
                  <span>{{row.f_userinfo_code}}</span></nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_user_name}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_zones}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_residential_area}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_address}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_user_phone}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_meternumber}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_month_date}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_last_month_tablebase}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_month_tablebase}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_last_month_oughtamount}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_month_oughtamount}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.amount_ratio}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_last_month_oughtfee}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.last_month_oughtfee}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_balance}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_curbalance}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_depname}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.f_orgname}}</nobr>
              </td>
              <td style="text-align: center;"  :class="{'bg-danger' : Math.abs(row.amount_ratio)>$parent.$parent.$parent.ratio }">
                <nobr>{{row.insert_time}}</nobr>
              </td>
            </template>
            <template partial='foot'></template>
          </data-grid>
        </criteria-paged>
      </div>

    </div>
  </div>
</template>

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

let readySomething = async function (self) {
  //加载抄表册
  self.$MagGetSaleParam.initinputtor();
  self.getinputtores();
  await self.$MagLoadParams.loadParam()
}
export default {
  title: '物联网表抄表环比查询',
  data () {
    return {
      iswork: false,
      other: [],
      footer: [],
      data: {},
      ratio: this.$appdata.getSingleValue('环比报警值百分比'),
      model: new PagedList('api/af-revenue/sql/getWebHandRatioQuery', 20, {
        startDate: 'this.model.startDate',
        endDate: 'this.model.endDate',
        index: 'this.model.index'
      }),
      initres: {
        org: [this.$login.f.orgid],
        dep: []
      },
      show: false,
      rowdata: {},
      criteriaShow: false,
      residentialArea: [],
      orgCondtionStr: '',
      modelval: [],
      gasproperties: [],
      inputtouPerson: [],
      meterbrands: [],
      printshow: false,
      f_filialeid: this.$login.f.f_orgid,
      all: false,
      fields: {},
      thead: '',
      tfoot: '',
      index: '',
      showupload: false,
      selected: {},

      // 下拉框

      //合计数据
      sumsmodel: {},
      defaultfield: [],
      config: {
        defaultPrint: ['f_userinfo_code', 'f_address', 'f_user_name', 'f_meternumber']
      },
      dypayment: [{label: "全部", value: ""}, {label: "银行代扣", value: "银行代扣",}, {
        label: "现金缴费",
        value: "现金缴费"
      }],
      batchmoneyShow: false,
      prices: [],
      bgl: [{label: '全部', value: ''}, {label: '有', value: '1'}, {label: '无', value: '0'}],
      meterbooks: [{label: '全部', value: ''}],  //抄表册
      tempfalg: false,
      lastorgstr: '',
      allorgid: [],
      inputtores: [{label: '全部', value: ''}],  //抄表员
      //表册片区
      bookSlice: [{label: '全部', value: ''}],
      imgshow: false,
      imgfilename: '',
      percent: 0,
      progressShow: false,
      uuida: '',
      timer: '',
    }
  },
  ready () {
    this.getaddress()
    readySomething(this).then(() => {
      this.$emit('ready')
    }).catch((error) => {
      this.$emit('error', error)
    })
  },
  methods: {
    getuuid () {
      let uuidA = '';
      var s = [];
      var hexDigits = '0123456789abcdef';
      for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = '4';
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
      s[8] = s[13] = s[18] = s[23] = '-';
      uuidA = s.join('');
      this.uuida = uuidA;
    },
    progressclose () {
      this.progressShow = false;
      if (this.timer != null) {
        clearInterval(this.timer);
      }
    },
    // 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()]
    // },
    //初始化片区
    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.bookSlice = []
        arr.forEach((res) => {
          this.bookSlice.push({label: res.name, value: res.name})
        })
      }
    },
    async getinputtores () {
      // 获取抄表员
      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.inputtores = [{label: '全部', value: ''}, ...rs]
      this.inputtores.push({label: "微信公众号", value: "微信公众号"})
    },
    async updateParams () {
      this.inputtores = [];
      this.inputtores.push({label: "全部", value: ""})
      if (this.allorgid != null) {
        this.allorgid.forEach((res) => {
          this.inputtores = this.inputtores.concat(this.$MagGetSaleParam.getresinputtor(res));
        })
      }
      // this.initParams()
    },
    view (row) {
      this.showupload = true
      this.selected = row
    },
    imgclose () {
      this.imgshow = false
    },
    imgShow (val) {
      this.imgfilename = `rs/image/file/` + val
      this.imgshow = true
    },
    getotherfooter () {
      // this.$refs.paged.$refs.cri.$refs.exports.otherData=[];
      // this.$refs.paged.$refs.cri.$refs.exports.footerData=[];
      this.other = [];
      this.footer = [];
      let exportdata = this.getCondition;
      let otherInData = [];
      otherInData.push(`导出时间: ${this.$login.toStandardTimeString()}`);
      let footerData = [], exportfield = this.getfield;
      this.other.push(otherInData);
    },
    async getaddress () {
      let HttpReset = new HttpResetClass()
      var data = await HttpReset.load('POST', 'api/af-revenue/sql/manage_getarealist', {
        data: {
          condition: `1=1 and s.f_orgid = '${this.$login.f.orgid}'`
        }
      }, {resolveMsg: null, rejectMsg: '获取小区失败!'})
      console.log('小区', data)
      let house = [{label: '全部', value: ''}]
      for (let row of data.data) {
        house.push({label: row.f_residential_area, value: row.f_residential_area})
      }
      this.residentialArea = house
    },
    Fileinput () {
      this.batchmoneyShow = true;
    },
    search () {
      this.$refs.paged.$refs.cri.search()
    },
    cancel () {
      this.show = false
    },
    selfSearch (args) {
      if (this.$refs.paged.$refs.cri.model.last_month_date === '') {
        this.$showMessage('请选择所属年月!')
        return
      }
      this.area = this.$refs.paged.$refs.cri.model.f_residential_area
      if (this.area.length !== 0) {
        let str = JSON.stringify(this.area)
        str = str.replace(/"/g, `'`)
        str = str.replace(/\[/g, ``)
        str = str.replace(/\]/g, ``)
        //查询多个小区时条件
        args.condition += ` and f_residential_area in  ( ${str} )`
      }
      //抄表员查询条件
      this.inputtouPerson = this.$refs.paged.$refs.cri.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, ``)
        //查询多个抄表员时条件
        args.condition += ` and f_inputtor in  ( ${str} )`
      }
      let ratio1 = this.ratio-0
      let ratio2 = 0-this.ratio
      let condition = `${args.condition} ` + this.orgCondtionStr + ` and ( amount_ratio>=${ratio1} or amount_ratio<=${ratio2})`
      this.model.search(condition, args.model)
    },
    clear () {
      //清空部门和人员
      this.$refs.paged.$refs.cri.$refs.sel.$children[1].selectres = []
      //部门和人员变为全选
      this.$refs.paged.$refs.cri.$refs.sel.$children[1].$children[0].isSelectAll = false
      this.$refs.paged.$refs.cri.$refs.sel.$children[2].$children[0].isSelectAll = false
      Object.keys(this.$refs.paged.$refs.cri.model).forEach((key) => {
        this.$refs.paged.$refs.cri.model[key] = []
      })
      this.$refs.paged.$refs.cri.model.f_meter_classify = []
    },
    show () {
      this.criteriaShow = true
    },
    hidden () {
      this.criteriaShow = !this.criteriaShow
    },
    async getRes (condition, obj) {
      this.orgCondtionStr = condition

    },
    close () {
      this.printshow = false
      this.all = false
    }
  },
  watch: {
    'model.rows' (val) {
      if (val.length === 0) {
        this.sumsmodel = {}
      }
    },
    async 'orgCondtionStr' (val) {
      this.$refs.paged.$refs.cri.model.f_inputtor = []
      this.$refs.paged.$refs.cri.model.f_book_slice_area = []
      this.$refs.paged.$refs.cri.model.f_meter_book = []
      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()
      }
    },
    'all' (val) {
      if (val) {
        this.modelval = this.bodyData
      } else {
        this.modelval = defaultPrint.config
        this.put()
      }
    },
    'modelval.length' () {
      this.put()
    },
    sumsmodel: {
      handler: function (val) {
        this.getotherfooter();
      },
      deep: true
    }
  },
  computed: {
    payment () {
      return [...this.$appdata.getParam('付款方式查询')]
    },
    authArr () {
      return this.$login.r ? this.$login.r : []
    },
    metertypes () {
      return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('气表类型')]
    },
    banklist () {
      return [{label: ' 全部 ', value: ''}, ...this.$appdata.getParam('银行名称')]
    },
    getCondition () {
      return {
        condition: `${this.$refs.paged.$refs.cri.condition}` + this.orgCondtionStr
      }
    },
    getfield () {
      return exportConfig.handplanRatioConfig
    },
    getBankfield () {
      return exportConfig.batchBankConfig
    },
    usertypes () {
      return [{label: '全部', value: ''}, ...this.$appdata.getParam('用户类型')]
    },
    accountsState () {
      return [{label: '全部', value: ''}, ...this.$appdata.getParam('下账状态')]
    },
    meterstate () {
      return [{label: '全部', value: ''}, ...this.$appdata.getParam('抄表状态')]
    },
    handstate () {
      return [{label: '全部', value: ''}, ...this.$appdata.getParam('表单状态')]
    },
    // inputtor() {
    //   return [{label: '全部', value: ''}, ...this.$appdata.getParam('抄表员')]
    // },
    pricetypes () {
      return [{label: '全部', value: ''}, ...this.$appdata.getParam('气价类型')]
    },
    getPricenames () {
      let f_user_type = this.$refs.paged.$refs.cri.model.f_user_type;
      let f_gasproperties = this.$refs.paged.$refs.cri.model.f_gasproperties;
      let pricetype = this.$refs.paged.$refs.cri.model.pricetype;
      console.log("打印一下:", f_user_type, f_gasproperties, pricetype, this.f_filialeid, this.prices)
      if (this.$refs.paged.$refs.cri.model !== null) {
        let rs = []
        let priceArr = []
        if (pricetype.length > 0) {
          let params = {
            f_price_type: pricetype[0],
            filter: this.f_filialeid,
            prices: this.prices
          }
          this.$MagGetSaleParam.getPrice(params).forEach((item) => {
            let temp = {}
            temp.label = item.label
            temp.value = item.value.f_price_name
            priceArr.push(temp)
          })
          rs = [{label: '全部', value: ''}, ...priceArr]
        }
        if (rs.length === 0) {
          console.log('rs读出来是空')
          this.$refs.paged.$refs.cri.model.f_price_name = ''
        }
        return rs
      }
    },
    inputtor () {
      // 获取抄表员
      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)
        }
      }

      return [{label: '全部', value: ''}, ...rs]
    },
    whetherPay () {
      return [{label: '全部', value: ''}, {label: '是', value: '是'}, {label: '否', value: '否'}]
    },
  },
  events: {
    'onFileUpload': async function (file, res) {
      let res1 = await this.$resetpost('api/af-revenue/sql/manageSingleTable', {
        data: {
          tablename: 't_singlevalue',
          condition: `f_filialeids = ${this.$login.f.orgid} and name='反盘状态'`
        }
      }, {resolveMsg: null, rejectMsg: null})
      console.log("看看res1,", res1.data[0])
      if (res1.data[0].value === '导入中') {
        this.$showAlert(`数据正在导入中，请稍后再试`, 'warning', 3000);
        this.batchmoneyShow = false
        return
      }

      //更新状态
      let bankreverse = {
        id: res1.data[0].id,
        value: '导入中'
      }
      await this.$resetpost('rs/entity/t_singlevalue', bankreverse, {resolveMsg: null, rejectMsg: null})

      //导入逻辑开始
      if (this.batchmoneyShow) {
        this.percent = 0;
        this.getuuid();
        let param = {
          filepath: res.f_downloadpath,
          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,
          uuid: this.uuida,
          id: res1.data[0].id
        }
        this.batchmoneyShow = false;
        try {
          await this.$resetpost('api/af-revenue/logic/SumSettleFileImport', {data: param}, {
            resolveMsg: null,
            rejectMsg: null
          }, 1000)
        } catch (e) {
        }
        let getparam = {
          uuid: this.uuida
        }
        let self = this;
        this.progressShow = true;
        this.timer = setInterval(function () {
          self.$resetpost('/api/af-revenue/logic/getBatchOperaPro', {data: getparam}, {
            resolveMsg: null,
            rejectMsg: null
          }, 0).then((res) => {
            if (res.data) {
              if (res.data.speed) {
                if (res.data.speed >= 100) {
                  clearInterval(self.timer);
                  if (res.data.speed) {
                    self.percent = 99;
                  }
                  setTimeout(() => {
                    self.percent = 100;
                    self.progressclose();
                    self.$showMessage(`导入成功! 累计导入:${res.data.totalsum}, 成功:${res.data.successsum},失败:${res.data.errorsum}(包含之前导入${res.data.aftersum}),失败数据请在稽查查询中错误查询进行查看!!`);
                  }, 600);
                } else {
                  self.percent = res.data.speed
                }
              } else {
                self.percent = 0;
              }
            }
          });
        }, 3000);
      }
    }

  }
}
</script>
