<template>
  <work-busy :is-busy="showWork" v-show="showWork"></work-busy>
  <div class="col-sm-12" style="margin: 20px 0px;">
    <data-grid :model="model" v-ref:grid class="list_area table_sy" style="padding: 0px">
      <template partial='head'>
        <tr>
          <th class="textNoLineBreak">序号</th>
          <th class="textNoLineBreak">收费金额</th>
          <th class="textNoLineBreak">金额大写</th>
          <th class="textNoLineBreak">付款方式</th>
          <th class="textNoLineBreak">收费人员</th>
          <th class="textNoLineBreak">收费日期</th>
          <th class="textNoLineBreak">备注</th>
          <th class="textNoLineBreak">缴费状态</th>
          <th class="textNoLineBreak">作废人员</th>
          <th class="textNoLineBreak">作废时间</th>
          <th class="textNoLineBreak">作废原因</th>
          <th class="textNoLineBreak">票据类型</th>
          <th class="textNoLineBreak">票据状态</th>
          <th class="textNoLineBreak">
            <button
              type="button"
              class="btn btn-info head-but"
              @click="$parent.$parent.showChargeModal()"
              :disabled="$parent.$parent.mark === 1 || ($parent.$parent.selectdata.f_cumulative_payment_money >= $parent.$parent.selectdata.f_due_money || $parent.$parent.selectdata.f_surplus_money === 0)"
            >新增收费</button>
          </th>
        </tr>
      </template>
      <template partial='body'>
        <tr>
          <td style="text-align: center;">
            <nobr>{{$index+1}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_charge_money}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_amount_words}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_payment_method}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_charge_collectors}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_charge_date}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_charge_remarks}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_charge_status}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_void_staff}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_void_date}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_void_remarks}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_bill_style}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr>{{row.f_bill_state}}</nobr>
          </td>
          <td style="text-align: center;">
            <nobr v-if="row.f_charge_status !== '退款'">
              <button
                type="button"
                name="button"
                class="btn btn-link"
                v-if = false
                :disabled="$parent.$parent.mark === 1 || row.f_charge_status === '作废'"
                @click="$parent.$parent.showInvalidModal(row)"
              >作废</button>

              <button
                type="button" name="button" class="btn btn-link"
                v-if="row.f_bill_state !== '开票成功' && row.f_bill_state != '冲红' && row.f_charge_status !== '作废'&& row.f_bill_state !== '冲正'"
                @click="$parent.$parent.openBill(row)"
              >开票</button>

              <button
                type="button" name="button" class="btn btn-link"
                 @click="$parent.$parent.showPrintModal(row)"
              >查看发票</button>
            </nobr>
          </td>
        </tr>
      </template>
    </data-grid>

    <validator name="v">
      <modal v-if="showCharge" :show.sync="showCharge" v-ref:modal :large="true" :backdrop="false" title="收费明细">
        <header slot="modal-header" class="modal-header">
          <button type="button" class="close" @click="closeModal"><span>&times;</span></button>
          <h4 class="modal-title">收费明细</h4>
        </header>
        <article slot="modal-body" class="modal-body clearfix">
          <div class="form-group col-sm-6" :class="[$v.f_charge_money.required ? 'has-error' : '']">
            <label class="col-sm-4 control-label">收费金额：</label>
            <div class="col-sm-8">
              <input type="text"
                     class="form-control input_view"
                     style="width: 100%"
                     placeholder="0.00"
                     @keyup="handleInput"
                     @change="moneyChange"
                     :readonly="selectdata.f_apply_type == '民用报建'"
                     v-validate:f_charge_money = "['required']"
                     v-model="charge.f_charge_money" />
            </div>
          </div>
          <div class="form-group col-sm-6" :class="[$v.f_feecount.required ? 'has-error' : '']">
            <label class="col-sm-4 control-label">缴费户数：</label>
            <div class="col-sm-8">
              <input type="text"
                     class="form-control input_view"
                     style="width: 100%"
                     v-validate:f_feecount = "['required']"
                     v-model="charge.f_feecount"
                     @blur="feecountchange"
                     :value="selectdata.f_install_count"
              />
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">金额大写：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%" readonly
                     v-model.sync="charge.f_amount_words"/>
            </div>
          </div>
          <div class="form-group col-sm-6" :class="[$v.f_payment_method.required ? 'has-error' : '']">
            <label class="col-sm-4 control-label">付款方式：</label>
            <div class="col-sm-8">
              <input type="text" v-show="false" v-model="charge.f_payment_method" v-validate:f_payment_method = "['required']" >
              <input-select
                placeholder='请选择' width="100%"
                v-model="charge.f_payment_method"
                :value.sync="charge.f_payment_method"
                :options='paymentMethod'
                class="select select_list"
                :value-single="true"
                close-on-select ></input-select>
            </div>
          </div>
          <div class="form-group col-sm-6" :class="[$v.f_bill_style.required ? 'has-error' : '']">
            <label class="col-sm-4 control-label">票据类型：</label>
            <div class="col-sm-8">
              <input type="text" v-show="false" v-model="charge.f_bill_style" :value.sync="selectdata.f_paper_type" v-validate:f_bill_style = "['required']" >
              <input-select
                placeholder='请选择' width="100%"
                v-model="charge.f_bill_style"
                :value.sync="selectdata.f_paper_type"
                :options='billStyleList'
                class="select select_list"
                :value-single="true"
                close-on-select ></input-select>
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">应交总金额：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%" readonly
                     v-model="selectdata.f_due_money" />
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">未结总金额：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%" readonly
                     v-model="selectdata.f_surplus_money" />
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">累计缴费总金额：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%" readonly
                     v-model="selectdata.f_cumulative_payment_money" />
            </div>
          </div>
          <div class="form-group col-sm-12">
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-10">
              <input type="text" class="form-control input_view" style="width: 100%"
                     v-model="charge.f_charge_remarks" />
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">购货单位识别号：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%"
                     v-model="charge.f_taxpayer_id" :value="selectdata.f_taxpayer_id" />
            </div>
          </div>
          <div class="form-group col-sm-6" :class="[$v.f_paper_name.required ? 'has-error' : '']">
            <label class="col-sm-4 control-label">购货单位名称：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%"
                     v-validate:f_paper_name = "['required']"
                     v-model="charge.f_paper_name" :value="selectdata.f_paper_name" />
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">购货单位银行账号：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%"
                     v-model="charge.f_paper_account" :value="selectdata.f_paper_account" />
            </div>
          </div>
          <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">购货单位地址电话：</label>
            <div class="col-sm-8">
              <input type="text" class="form-control input_view" style="width: 100%"
                     v-model="charge.f_address_phone" :value="selectdata.f_address_phone" />
            </div>
          </div>
          <div class="form-group col-sm-12">
            <label class="col-sm-2 control-label">发票备注：</label>
            <div class="col-sm-10">
              <input type="text" class="form-control input_view" style="width: 100%"
                     v-model="charge.f_bill_remarks" :value="selectdata.f_paper_remarks"/>
            </div>
          </div>
        </article>
        <footer slot="modal-footer" class="modal-footer">
          <button type="button" class="btn btn-primary" :disabled='!$v.valid' @click="saveCharge()">新增收费</button>
        </footer>
      </modal>
    </validator>

    <modal v-if="showInvalid" :show.sync="showInvalid" v-ref:modal :backdrop="false" title="作废收费">
      <header slot="modal-header" class="modal-header">
        <button type="button" class="close" @click="closeModal"><span>&times;</span></button>
        <h4 class="modal-title">作废收费</h4>
      </header>
      <article slot="modal-body" class="modal-body clearfix">
        <div class="form-group col-sm-12" v-if="false">
          <label class="col-sm-2 control-label">缴费地址：</label>
          <div class="col-sm-10">
            <input type="text"
                   class="form-control input_view"
                   style="width: 100%"
                   readonly
                   v-model="charge.f_useraddres" />
          </div>
        </div>
        <div class="form-group col-sm-12">
          <label class="col-sm-2 control-label">收费金额：</label>
          <div class="col-sm-10">
            <input type="text"
                   class="form-control input_view"
                   style="width: 100%"
                   readonly
                   v-model="charge.f_charge_money" />
          </div>
        </div>
        <div class="form-group col-sm-12">
          <label class="col-sm-2 control-label">付款方式：</label>
          <div class="col-sm-10">
            <input type="text"
                   class="form-control input_view"
                   style="width: 100%"
                   readonly
                   v-model="charge.f_payment_method" />
          </div>
        </div>
        <div class="form-group col-sm-12">
          <label class="col-sm-2 control-label">金额大写：</label>
          <div class="col-sm-10">
            <input type="text"
                   class="form-control input_view"
                   style="width: 100%"
                   readonly
                   v-model="charge.f_amount_words" />
          </div>
        </div>
        <div class="form-group col-sm-12">
          <label class="col-sm-2 control-label">收费人员：</label>
          <div class="col-sm-10">
            <input type="text"
                   class="form-control input_view"
                   style="width: 100%"
                   readonly
                   v-model="charge.f_charge_collectors" />
          </div>
        </div>
        <div class="form-group col-sm-12" :class="charge.f_void_remarks ? '':'has-error'">
          <label class="col-sm-2 control-label">作废原因：</label>
          <div class="col-sm-10">
            <input type="text"
                   class="form-control input_view"
                   style="width: 100%"
                   v-model="charge.f_void_remarks" />
          </div>
        </div>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-primary" :disabled="!charge.f_void_remarks" @click="invalidApplyCharge()">确认作废</button>
      </footer>
    </modal>

    <modal v-if="showPrint" :show.sync="showPrint" v-ref:modal :large="true" :backdrop="false">
      <header slot="modal-header" class="modal-header">
        <button type="button" class="close" @click="closePrint()"><span>&times;</span></button>
        <h4 class="modal-title">票据信息</h4>
      </header>
      <article slot="modal-body" class="modal-body clearfix">
        <span v-if="charge.f_bill_link == '' || charge.f_bill_link == null">正在查询票据信息...</span>
        <iframe width="100%" height="500px" :src="charge.f_bill_link" v-if="charge.f_bill_link != ''&& charge.f_bill_link != null"></iframe>
      </article>
      <footer slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-primary" @click="query()">重新查询</button>
      </footer>
    </modal>
  </div>
</template>
<script>
import {PagedList} from 'vue-client'
import {HttpResetClass} from 'vue-client'
import Vue from 'vue'
import {isEmpty} from '../../../Util'

export default {
  title: '收费管理',
  props: {
    selectdata: {
      type: Object
    },
    mark: {
      type: Number,
      default: 0
    }
  },
  data () {
    return {
      showWork: false,
      showCharge: false,  // 收费明细
      showInvalid: false, // 作废
      showPrint: false,   // 打印
      model: {
        data: null
      },       // 记录
      charge: {
        f_amount_words:'',
        f_charge_money:''
      }
    }
  },
  ready () {
    this.search()
  },
  methods: {

    async invalidApplyCharge() {

      let http = new HttpResetClass()
      let data = {
        apply: this.selectdata,
        user: this.$login.f,
        charge: this.charge
      }
      let res = await http.load('POST', 'rs/logic/invalidApplyCharge', {data:data}, {
        resolveMsg: null,
        rejectMsg: '作废失败！！！'
      })
      this.selectdata = res.data
      this.showInvalid=false
      this.charge = {}
      this.$dispatch('breakControl', this.selectdata)
    },
    // 打开作废收费
    showInvalidModal(row) {
      this.charge = row
      this.showInvalid = true
    },
    // 查看发票
    showPrintModal(row, type) {
      this.charge = row
      this.charge.f_bill_link = this.charge.f_bill_url
      if(this.charge.f_bill_link == '' || this.charge.f_bill_link == null ){
        this.timer1 = window.setInterval(this.query, 3000)
      }
      /*if (!this.charge.f_bill_link && this.charge.f_filepath){
        let date = new Date(this.charge.f_charge_date)
        let year = date.getFullYear()
        let month = date.getMonth() + 1
        let month2 = month <= 9 ? '0' + month : month
        let day = date.getDate()
        let day2 = day <= 9 ? '0' + day : day
        let chargedate = year + '-' + month2 + '-' + day2
        this.charge.f_bill_link = `http://193.168.1.6:8082/eticket/` + chargedate + '/' + this.charge.f_filepath + '.pdf'
      }else if(!this.charge.f_bill_link){
        this.charge.f_bill_link = this.charge.f_bill_url
        if(this.charge.f_bill_link == '' || this.charge.f_bill_link == null ){
          this.timer1 = window.setInterval(this.query, 3000)
        }
      }*/
      this.showPrint = true
    },
    // 开票组织数据
    async openBill (charge) {
      this.$showMessage("请稍后查询，发票开具中.....")
      /*this.charge = charge
      let data = null
      let res = null

      let http = new HttpResetClass()

      if (isEmpty(this.charge.f_bill_id)) {
        try {
          data = {
            id: this.charge.id,
            charge_type: '报装收费',
            f_user_name: this.selectdata.f_user_name
          }
          if (this.selectdata.f_apply_type === '改线业务'){
            data.charge_type = '整改收费'
          }
          res = await http.load('POST', 'rs/logic/bjEticketCharge', {data:data}, {
            resolveMsg: null,
            rejectMsg: '开票组织数据失败！！！'
          }).then((res) => {
            this.charge.f_bill_id = res.data
            this.outBill()
          })
        }catch (e){
          console.error("错误信息",e)
          this.charge.f_bill_state = '开票失败'

          data = {
            f_bill_id: '',
            id: this.charge.id,
            apply: this.selectdata,
            user: this.$login.f
          }
          res = await http.load('POST', 'rs/logic/updateChargeBill', {data: data}, {
            resolveMsg: null,
            rejectMsg: '收费信息更新失败！！！'
          })
          this.$showMessage(`开票信息组织失败！！`, ['confirm']).then(async (res) => {
            if (res === 'confirm') {
              this.$dispatch('loadPage')
            }else {
              this.$dispatch('loadPage')
            }
          })
        }
      }else {
        await this.outBill()
      }*/
    },
    //开票
    async outBill () {

      let data = null
      let res = null
      let http = new HttpResetClass()
      if (this.charge.f_bill_style === '电子票') {
        data = {
          id: this.charge.f_bill_id,
          f_sell_id: this.charge.id
        }
        try {
          res = await http.load('POST', 'rs/logic/bjOpenEticket', {data: data}, {
            resolveMsg: null,
            rejectMsg: '开票失败！！！'
          })

          // res.data.f_bill_url = 'https://dlj.51fapiao.cn/dlj/v7/de4c9b985021111ef1c722c2914e34d9273291'

          if (res.data.f_bill_state !== '开票成功') {
            throw '开票失败！！！'
          } else {
            this.charge.f_bill_state = res.data.f_bill_state
            this.charge.f_bill_url = res.data.f_bill_url
            let date = new Date(this.charge.f_charge_date)
            let year = date.getFullYear()
            let month = date.getMonth() + 1
            let month2 = month <= 9 ? '0' + month : month
            let day = date.getDate()
            let day2 = day <= 9 ? '0' + day : day
            let chargedate = year + '-' + month2 + '-' + day2
            this.charge.f_bill_link = `http://193.168.1.6:8082/eticket/` + chargedate + '/' + res.data.f_filepath + '.pdf'
            this.showPrint = true
            let pram = {
              f_bill_link: this.charge.f_bill_link,
              f_sell_id: this.charge.id,
              apply: this.selectdata,
              user: this.$login.f
            }
            await http.load('POST', 'rs/logic/updataChargeRecord', {data: pram}, {
              resolveMsg: null,
              rejectMsg: null
            })
          }
        } catch (e) {
          console.error(e)
          this.charge.f_bill_state = '开票失败'

          data = {
            f_bill_id: this.charge.f_bill_id,
            id: this.charge.id,
            apply: this.selectdata,
            user: this.$login.f
          }
          res = await http.load('POST', 'rs/logic/updateChargeBill', {data: data}, {
            resolveMsg: null,
            rejectMsg: '收费信息更新失败！！！'
          })
          this.$showMessage(`开票失败！！`, ['confirm']).then(async (res) => {
            if (res === 'confirm') {
              this.$dispatch('loadPage')
            }else {
              this.$dispatch('loadPage')
            }
          })
        }
      } else if (this.charge.f_bill_style === '专票') {
        data = {
          id: this.charge.f_bill_id
        }
        res = await http.load('POST', 'rs/sql/getEticketData', {data: data}, {
          resolveMsg: null,
          rejectMsg: '开票数据查询失败！！！'
        })
        let openBillData = JSON.parse(res.data[0].f_bill_data)
        openBillData.kpzdbs = this.$login.f.taxnum
        const nowDate = new Date()
        let year = nowDate.getFullYear()
        let mouth = nowDate.getMonth() + 1
        let day = nowDate.getDate()
        openBillData.f_operate_date = year + '-' + mouth + '-' + day
        openBillData.f_operator = this.$login.f.name
        openBillData.outlets = this.$login.f.f_department_name
        openBillData.hjse = ''
        openBillData.jshh = ''
        openBillData.tzdbh = ''
        openBillData.yfpdm = ''
        openBillData.yfphm = ''
        console.log('返回开票信息。。 ', openBillData)
        let billInfo = await this.$resetpost('http://127.0.0.1:8003/Goldtax', openBillData, {
          resolveMsg: null,
          rejectMsg: '专用发票开具失败！'
        })
        console.log('返回票据信息。。 ', JSON.parse(billInfo.data))//保存发票明细
        if (!JSON.parse(billInfo.data).fphm) {
          this.charge.f_bill_state = '开票失败'
          data = {
            f_bill_id: this.charge.f_bill_id,
            id: this.charge.id,
            apply: this.selectdata,
            user: this.$login.f
          }
          res = await http.load('POST', 'rs/logic/updateChargeBill', {data: data}, {
            resolveMsg: null,
            rejectMsg: '收费信息更新失败！！！'
          })
          this.$showMessage(`开票失败！！`, ['confirm']).then(async (res) => {
            if (res === 'confirm') {
              this.$dispatch('loadPage')
            }else {
              this.$dispatch('loadPage')
            }
          })
        } else {
          data = {
            id: this.charge.f_bill_id,
            f_bill_number: JSON.parse(billInfo.data).fphm,
            f_bill_code: JSON.parse(billInfo.data).fpdm,
            f_filepath: JSON.parse(billInfo.data).dzpkex ? JSON.parse(billInfo.data).dzpkex : '',
            charge_id: this.charge.id,
            apply: this.selectdata,
            user: this.$login.f
          }
          res = await http.load('POST', 'rs/logic/updateEticketBill', {data: data}, {
            resolveMsg: null,
            rejectMsg: '开票信息更新失败！！！'
          })

          this.charge.f_bill_state = '开票成功'
          this.charge.f_bill_url = ''
          this.charge.f_bill_link = ''
        }
      }
    },
    // 新增收费
    async saveCharge() {
      let http = new HttpResetClass()
      let data = {
        apply: this.selectdata,
        user: this.$login.f,
        charge: this.charge
      }

      let res = await http.load('POST', 'rs/logic/addApplyChargeRecord', {data:data}, {
        resolveMsg: null,
        rejectMsg: '缴费失败！！！'
      }).then((res) => {
        this.charge = res.data.charge
        this.selectdata = res.data.apply

        this.showCharge = false
        // this.$dispatch('loadPage')
        this.showPrintModal(this.charge)
        /*try {
          if (this.charge.id) {
            this.openBill(this.charge)
          }
        } catch (e) {
          this.$dispatch('breakControl', this.selectdata)
        }*/
      })
    },
    moneyChange () {
      if (isEmpty(this.charge.f_charge_money) || Number(this.charge.f_charge_money) === 0) {
        this.$showMessage('单笔收费不能为0元！！！')
        this.charge.f_charge_money = null
        return
      }
      if (Number(this.charge.f_charge_money) > Number(this.selectdata.f_surplus_money)) {
        this.$showMessage('单笔收费不能超过未交总金额！！！')
        this.charge.f_charge_money = null
        return
      }
    },
    // 金额转大写
    handleInput(e) {
      // 通过正则过滤小数点后两位
      e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
      this.charge.f_amount_words = this.smalltoBIG(e.target.value)
    },
    // 金额转大写
    smalltoBIG(n) {
      let fraction = ['角', '分'];
      let digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
      let unit = [['元', '万', '亿'], ['', '拾', '佰', '仟']];
      let head = n < 0 ? '欠' : '';
      n = Math.abs(n);

      let s = '';

      for (var i = 0; i < fraction.length; i++) {
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '');
      }
      s = s || '整';
      n = Math.floor(n);

      for (var i = 0; i < unit[0].length && n > 0; i++) {
        let p = '';
        for (var j = 0; j < unit[1].length && n > 0; j++) {
          p = digit[n % 10] + unit[1][j] + p;
          n = Math.floor(n / 10);
        }
        s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s;
      }
      return head + s.replace(/(零.)*零元/, '元').replace(/(零.)+/g, '零').replace(/^整$/, '零元整')
    },
    async showChargeModal() {
      this.feecountchange()
      this.showCharge = true
    },
    async search () {
      let http = new HttpResetClass()
      let data = {
        f_process_id: this.selectdata.f_process_id
      }
      let res = await http.load('POST', 'rs/sql/getApplyChargeRecord', {data:data}, {
        resolveMsg: null,
        rejectMsg: '收费记录查询失败！！！'
      })
      this.model.data = res.data
    },
    // 关闭对话框
    closeModal() {
      this.showCharge = false
      this.showInvalid = false
      this.showPrint = false
      this.charge = {}
      this.search()
    },
    // 关闭对话框
    async closePrint() {
      this.showWork=true
      this.showPrint = false
      window.clearInterval(this.timer1)
      const http = new HttpResetClass()
      let pram = {
        f_bill_link: this.charge.f_bill_link,
        f_sell_id: this.charge.id,
        apply: this.selectdata,
        user: this.$login.f
      }
     await http.load('POST', 'rs/logic/updataChargeRecord', {data: pram}, {
        resolveMsg: null,
        rejectMsg: null
      }).then(res=>{
       this.showWork=false
        this.charge = {}
        this.$dispatch('loadPage')
      })
    },
    // 重新查询
    async query(){
      let http = new HttpResetClass()
      let data = {
        f_process_id: this.selectdata.f_process_id
      }
      let res = await http.load('POST', 'rs/sql/getApplyChargeRecord', {data:data}, {
        resolveMsg: null,
        rejectMsg: '收费记录查询失败！！！'
      })
      res.data.forEach(item=>{
        if (item.id == this.charge.id){
          this.charge = item
          if (item.f_bill_url != '' && item.f_bill_url != null){
            window.clearInterval(this.timer1)
          }
          this.charge.f_bill_link = this.charge.f_bill_url
        }
      })
    },
    feecountchange(){
      if(this.selectdata.f_apply_type == '民用报建'){
        this.charge.f_charge_money = Number(this.selectdata.f_price) * Number(this.charge.f_feecount || this.selectdata.f_install_count)
        this.charge.f_amount_words = this.smalltoBIG(this.charge.f_charge_money)
      }
    }
  },
  events: {
  },
  computed: {
    billStyleList () {
      return this.$appdata.getParam("打印格式")
    },
    paymentMethod() {
      return this.$appdata.getParam("付款方式")
    },
    paymentTerm() {
      return this.$appdata.getParam("收费项目")
    }
  },
  watch: {
  }
}
</script>
<style scoped>
.textNoLineBreak {
  white-space: nowrap;
}
.head-but{
  margin-left: 5px;
  height: 34px;
  /*background-color: #6aa6e2;*/
  border-radius: 4px;
  font-family: PingFang;
  color: #ffffff;
}
.form-control{
  padding: 8px 12px;
}
</style>
