<template>
  <div>
    <work-busy :is-busy="button_state"></work-busy>
    <div v-for="(i, item) in material " class="y-form">
      <div class="y-form-head">
        <span style="text-align: center">材料{{ $index + 1 }}信息</span>
        <button
          style="float: right"
          class="button_delete button_spacing"
          v-if="i>0"
          @click.prevent="deleteUserFile(i)"
        >删除
        </button>
      </div>

      <div class="y-form-item">
        <label>材料分类</label>
        <input-select
          class="select select_list y-form-item-input"
          :value.sync="item.f_typename"
          v-model="item.f_typename"
          :options="category.options"
          @change="item.f_material_name = undefined, item.f_typenumber = undefined"
          :valueSingle="true">
        </input-select>
      </div>

      <div class="y-form-item">
        <label>材料名称</label>
        <input-select
          class="select select_list y-form-item-input"
          :value.sync="item.f_material_name"
          v-model="item.f_material_name"
          :options="category.children[item.f_typename].options"
          @change="item.f_typenumber = undefined"
          :valueSingle="true">
        </input-select>
      </div>
      <div class="y-form-item">
        <label>型号</label>
        <input-select
          class="select select_list y-form-item-input"
          :value.sync="item.f_typenumber"
          v-model="item.f_typenumber"
          :options="category.children[item.f_typename].children[item.f_material_name].options"
          :valueSingle="true">
        </input-select>
      </div>
      <div class="y-form-item">
        <label>单价(元/{{
            category.children[item.f_typename].children[item.f_material_name].children[item.f_typenumber].unit
          }})</label>
        <input
          type="number"
          class="form-control y-form-item-input"
          v-model="item.f_material_price"
          :value="category.children[item.f_typename].children[item.f_material_name].children[item.f_typenumber].price"
        >
      </div>
      <div class="y-form-item">
        <label>数量</label>
        <input type="number" class="form-control y-form-item-input" v-model="item.f_material_number">
      </div>
      <div class="y-form-item">
        <label>金额</label>
        <input type="number" class="form-control y-form-item-input" v-model="item.f_fee"
               :value="smallnum(item.f_material_price,item.f_material_number)">
      </div>
      <div class="y-form-item">
        <label>备注</label>
        <textarea type="text" rows="2" class="form-control y-form-item-input" v-model="item.f_remarks"></textarea>
      </div>
    </div>
    <div style="padding: 10px;display: flex;justify-content: space-around;">
      <button type="button" class="btn btn-primary" @click="addUserFile">添加</button>
      <button type="button" class="btn btn-primary" @click="showQrcodeButton">保存</button>
    </div>
    <div v-show="showQrCode">
      <div class="row">
        <label class="text-justify lb-left" style="width: 100px">收款</label>
        <div class="row row_sty">
          <label class="lab_sty col-xs-4">合计金额</label>
          <div class="col-xs-8">
            <input type="number" class="form-control" v-model="payNumber" :value.sync="payNumber">
          </div>
        </div>
        <div class="row row_sty">
          <label class="lab_sty col-xs-4">收款方式</label>
          <div class="col-xs-8">
            <v-select
              :width="'100%'"
              :value.sync="payType"
              v-model="payType"
              :options='payTypes'
              placeholder='请选择'
              close-on-select
              :value-single="true"
            ></v-select>
          </div>
        </div>
        <div v-if="zfCode" style="margin-top: 20px; text-align: center;">
          <div id="qrcode" style="margin-top: 25px;width: 266px;height: 266px"></div>
        </div>
      </div>
      <div style="padding: 10px;display: flex;justify-content: space-around;">
        <button type="button" name="button" class="btn btn-primary btn-sm" style="float: right;margin-right:10px;"
                @click="beforeSaveCharge()">收费
        </button>
        <button type="button" class="btn btn-primary" @click="cancel">取消</button>
      </div>
    </div>
  </div>
</template>
<script>
import Vue from 'vue'
import {HttpResetClass} from 'vue-client'
import QRCode from 'qrcodejs2'
import {getNowDate, isEmpty} from '../../../components/Util'

export default {
  title: '材料添加',
  props: {
    selectdata: {
      type: Object
    }
  },
  data() {
    return {
      othercharge_id: '',
      payState: false,
      zfCode: false,
      f_out_trade_no: '',
      payTypes: [{label: '全部', value: ''},...this.$appdata.getParam('呼叫-收款方式'),],
      payType: '',
      payNumber: 0,
      button_state: false,
      category: {},
      showFile: false,
      material: [],
      positions: this.$appdata.getParam('品名及规格'), // 获取材料名称
      charge: {
        payment_terms: [{f_payment_term: '', f_charge_money: '', f_amount_words: '', f_payment_method: ''}]
      }, // 收费内容
      showCharge: false, // 收费显示
      timeLeft: 300, // 收费时间
      title1: '', // 二维码标题
      showQrCode: false, // 二维码显示
      order: {}, // 订单信息
      f_cost_sum: 0, // 总收费
    }
  },
  ready() {
    this.loadOptions()
  },
  methods: {
    cancel() {
      this.payNumber = 0
      this.othercharge_id = ''
      this.payState = false
      this.zfCode = false
      this.showQrCode = false
      clearTimeout(this.orderInterval)
    },
    getChangePayNumber() {
      this.payNumber = 0
      for (let i = 0; i < this.material.length; i++) {
        this.material[i].f_fee = this.material[i].f_material_price * this.material[i].f_material_number
        this.payNumber += Number(this.material[i].f_fee)
      }
    },
    showQrcodeButton() {
      this.getChangePayNumber()
      this.showQrCode = true
    },
    loadOptions() {
      const data = {
        tablename: 't_material_info',
        condition: `org_id = '${Vue.user.orgid}'`
      }
      this.$resetpost(this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data}, {
        resolveMsg: null,
        rejectMsg: '获取数据失败'
      }).then((res) => {
        const categories = []
        const materials = []
        const types = []
        for (let material of res.data) {
          if ( material.type === '报建') {
            categories.push(material)
          } else if ( material.type === '材料') {
            materials.push(material)
          } else if (material.type === '型号') {
            types.push(material)
          }
        }
        this.category.options = []
        for (let category of categories) {
          this.category.options.push({
            label: category.name,
            value: category.name
          })
        }

        this.category.children = {}
        for (let category of categories) {
          this.category.children[category.name] = {}

          this.category.children[category.name].options = []
          this.category.children[category.name].children = {}
          for (let material of materials) {
            if (material.parent_id == category.id) {
              this.category.children[category.name].options.push({
                label: material.name,
                value: material.name
              })

              this.category.children[category.name].children[material.name] = {}

              this.category.children[category.name].children[material.name].options = []
              this.category.children[category.name].children[material.name].children = {}
              for (let type of types) {
                if (type.parent_id == material.id) {
                  this.category.children[category.name].children[material.name].options.push({
                    label: type.name,
                    value: type.name
                  })
                  this.category.children[category.name].children[material.name].children[type.name] = type
                }
              }
            }
          }
        }
        console.log('this.category=', JSON.stringify(this.category))
        // this.search()
      })
    },
    // 删除未保存的材料信息
    async deleteUserFile(index) {
      this.material.splice(index, 1)
      this.cancel()
    },
    // 追加材料信息
    addUserFile() {
      this.material.push({})
      this, this.cancel()
    },
    search() {
      let http = new HttpResetClass()
      let data = {
        tablename: 't_material_service',
        condition: `f_process_id = '${this.selectdata.f_process_id}'`
      }
      http.load('post', this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data: data}, {
        resolveMsg: null,
        rejectMsg: '获取数据失败'
      }).then(res => {
        this.material = res.data
        if (this.material.length <= 0) {
          this.material = [{}]
        }
      })
    },
    // 获取品名规格
    // setTypename(i, val) {
    //   let ac = this.$appdata.getParam(val)
    //   this.$set('material[' + i + '].typeNameList', ac)
    //   this.$set('material[' + i + '].typeNumberList', [])
    //   this.$set('material[' + i + '].f_typenumber', null)
    //   this.$set('material[' + i + '].f_material_price', 0)
    // },
    // 获取类型
    // setTypenumber(i, val) {
    //   let ac = this.$appdata.getParam(val)
    //   this.$set('material[' + i + '].typeNumberList', ac)
    //   this.$set('material[' + i + '].f_material_price', 0)
    // },
    // 获取单价
    // setmaterialprice(i, val) {
    //   var num
    //   if (val == null) {
    //     num = 0
    //   }
    //   num = this.$appdata.getSingleValue(val)
    //   this.$set('material[' + i + '].f_material_price', num)
    // },
    // 金额计算
    smallnum(val, val1) {
      let num = Number(val) * Number(val1)
      return num
    },
    qrcode(url) {
      new QRCode('qrcode', {
        text: url, // 设置二维码内容或跳转地址
        width: 266, // 设置宽度，单位像素
        height: 266, // 设置高度，单位像素
        correctLevel: QRCode.CorrectLevel.L //容错率，L/M/Hs
      })
    },
    clearQrCode() {
      if (document.getElementById('qrcode')) {
        document.getElementById('qrcode').innerHTML = ''
      }
    },
    async getOrderInformation() {
      // 查询订单信息
      console.log('查询订单信息！！！')
      let http = new HttpResetClass()
      let res = await http.load('POST', `${this.$androidUtil.getProxyUrl()}/wx/rs/weixin/orderStatus`, {
        "f_filiale": "wensuxilong",
        "out_trade_no": `${this.f_out_trade_no}`
      }, {
        resolveMsg: null,
        rejectMsg: '订单查询失败！！！'
      })
      // 支付成功
      if (res.data.trade_state_desc.includes('成功')) {
        this.$showMessage('支付成功！！！')
        await this.saveUserFile('save')
        this.clearQrCode()
        this.cancel()
      }
    },
    async openQrcode() {
      this.clearQrCode()
      let data = {
        tablename: 't_userfiles',
        condition: `f_userinfo_id = '${this.selectdata.model.f_userinfo_id}'`
      }
      let res = await new HttpResetClass().load('post', this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data: data}, {
        resolveMsg: null,
        rejectMsg: '获取数据失败'
      })
      let reqdata = {
        "filiale": "wensuxilong",
        "money": 1,
        "str": "材料收费",
        "attach": {
          "f_userfiles_id": res.data[0].f_userfiles_id,
          "f_userinfo_id": this.selectdata.model.f_userinfo_id
        }
      }
      new HttpResetClass().load('POST', `${this.$androidUtil.getProxyUrl()}/wx/rs/weixin/gasgetcode`, reqdata).then(res => {
        if (res.data.code === 200) {
          this.f_out_trade_no = res.data.out_trade_no
          this.zfCode = true
          this.$nextTick(() => {
            this.qrcode(res.data.url)
          })
          this.orderInterval = setInterval(() => {
            this.getOrderInformation()
          }, 3000)
        } else {
          this.$showMessage('网络异常。。。')
        }
      })
    },
    async beforeSaveCharge() {


      if (this.material.length == 0) {
        return this.$showMessage(`请先添加消耗的材料！`)
      }
      for (let index = 0; index < this.material.length; index++) {
        const item = this.material[index]
        if (!item.f_material_name) {
          this.$showMessage(`请选择材料${index + 1}的材料名称`)
          return;
        }
        if (!item.f_typenumber) {
          this.$showMessage(`请选择材料${index + 1}的型号`)
          return;
        }
        if (!item.f_material_price) {
          this.$showMessage(`请填写材料${index + 1}的单价`)
          return;
        }
        if (!item.f_material_number || item.f_material_number == 0) {
          this.$showMessage(`请填写材料${index + 1}的数量`)
          return;
        }
      }
      if (!this.payType) {
        this.$showMessage(`请选择缴费方式`)
        return;
      }
      if (this.payType.includes('二维码') && this.payNumber>0) {
        await this.openQrcode()
      } else {
        await this.saveUserFile('save')
      }
    },
    async saveUserFile(type) {
      for (let i = 0; i < this.material.length; i++) {
        this.material[i].f_process_id = this.selectdata.f_process_id
        this.material[i].f_source = '安检'
        this.material[i].f_department = Vue.user.f_department_name
        this.material[i].f_fee = this.material[i].f_material_price * this.material[i].f_material_number
        if (isEmpty(this.material[i].f_state)) {
          this.material[i].f_state = null
        }
      }
      await this.saveOrder(type)
    },
    async saveOrder(type) {
      this.button_state = true
      console.log('this.material', this.material)
      let otherdetail = []
      if (this.payNumber == 0) {
        otherdetail.push({
          f_brand_spec: ['维修'],
          f_typename: ['材料费'],
          f_typenumber: [],
          f_unitprice: 0,
          f_number: this.material.length
        })
      } else {
        this.material.forEach((row) => {
          if (row.f_material_price != 0) {
            otherdetail.push({
              f_brand_spec: ['维修'],
              f_typename:  [`${row.f_material_name ? row.f_material_name : '材料费'}`],
              f_typenumber: [`${row.f_typenumber ? row.f_typenumber : ''}`],
              f_unitprice: row.f_material_price,
              f_number: row.f_material_number
            })
          }
        })
      }
      // if (this.payState) {
      //   let other = {
      //     "record_userinfo": this.selectdata.model.f_userinfo_id,
      //     //"f_userfiles_id": '',
      //     //"f_user_id": '',
      //     "f_user_name": this.selectdata.model.f_user_name,
      //     "f_address": this.selectdata.model.f_address,
      //     "f_user_type": this.selectdata.model.f_user_type,
      //     "f_gasproperties": "",
      //     "f_collection": this.payNumber,
      //     "f_comments": `${Vue.user.name}进行维修材料收费，收费方式-${this.payType} ${this.order.body && this.order.body.tradeNo ? '。支付订单号:' + this.order.body.tradeNo : ''}`,
      //     "f_payment": this.payType,
      //     "f_voucher_number": this.selectdata.f_process_id,
      //     "f_bill_style": "普通收据",
      //     "f_userinfo_id": this.selectdata.model.f_userinfo_id,
      //     "f_service_person": Vue.user.name,
      //     "f_operat_type": "维修收费",
      //     "f_describe": "",
      //     "f_serial_id": this.order.body ? this.order.body.tradeNo : null,
      //     "f_state": '有效',
      //     "f_operator": Vue.user.name,
      //     "f_operatorid": Vue.user.id,
      //     "f_orgid": Vue.user.orgid,
      //     "f_orgname": Vue.user.orgs,
      //     "f_depid": Vue.user.depids,
      //     "f_depname": Vue.user.f_department_name,
      //     "t_userfees": "",
      //     "f_fee_type": "维修费用",
      //     "f_fee_time": "12",
      //     "otherdetail": otherdetail
      //   }
      //   console.log("缴费记录保存", other)
      //   let res1 = await new HttpResetClass().load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/sale_othercharge_logic`, other, {
      //     resolveMsg: null,
      //     rejectMsg: null
      //   })
      //   this.othercharge_id = res1.data.othercharge_id
      // }
      let data = {
        tablename: 't_userfiles',
        condition: `f_userinfo_id = '${this.selectdata.model.f_userinfo_id}'`
      }
      let userfile = await new HttpResetClass().load('post', this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data: data}, {
        resolveMsg: null,
        rejectMsg: '获取数据失败'
      })
      let param = {
        model: this.material,
        operator_type: type,
        other:{
          f_userinfo_id:this.selectdata.model.f_userinfo_id,
          f_userfiles_id:userfile.data[0].f_userfiles_id,
          f_user_id:userfile.data[0].f_user_id,
          record_userinfo: this.selectdata.model.f_userinfo_id,
          f_user_name: this.selectdata.model.f_user_name,
          f_address: this.selectdata.model.f_address,
          f_user_type: this.selectdata.model.f_user_type,
          f_gasproperties: "",
          f_collection: this.payNumber,
          f_comments: `${Vue.user.name}进行维修材料收费，收费方式-${this.payType} ${this.order.body && this.order.body.tradeNo}`,
          f_payment: this.payType,
          f_voucher_number: this.selectdata.f_process_id,
          f_bill_style: "普通收据",
          f_service_person: Vue.user.name,
          f_operat_type: "维修收费",
          f_describe: "",
          f_serial_id: this.order.body ? this.order.body.tradeNo : null,
          f_state: '有效',
          f_operator: Vue.user.name,
          f_operatorid: Vue.user.id,
          f_orgid: Vue.user.orgid,
          f_orgname: Vue.user.orgs,
          f_depid: Vue.user.depids,
          f_depname: Vue.user.f_department_name,
          t_userfees: "",
          f_fee_type: "维修费用",
          f_fee_time: "12",
          otherdetail: otherdetail
        },
        othercharge_id: this.othercharge_id,
        f_process_id: this.selectdata.f_process_id,
        f_userinfo_id: this.selectdata.model.f_userinfo_id
      }
      console.log("材料收费保存", param)
      let res = await new HttpResetClass().load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/saveMaterialService`, param, {
        resolveMsg: null,
        rejectMsg: null
      })
      if (res.data.code == 200) {
        if (type === 'create') {
          this.button_state = false
          this.$emit('aftersave')
        } else {
          this.$showMessage('材料保存成功!!!')
          this.$emit('aftersave')
          this.button_state = false
        }
      } else {
        this.button_state = false
        this.$showMessage(res.data.msg)
      }
      this.$parent.$parent.showmaterial = false
    },
    // 关闭对话框
    // closeModal() {
    //   this.showCharge = false
    //   this.charge = {
    //     payment_terms: [{
    //       f_payment_term: '',
    //       f_charge_money: '',
    //       f_amount_words: '',
    //       f_payment_method: this.charge.f_payment_method
    //     }]
    //   }
    // },
    // 金额转大写
    // handleInput(index) {
    //   // 通过正则过滤小数点后两位
    //   console.log('-----------------------')
    //   this.charge.payment_terms[index].f_charge_money = (this.charge.payment_terms[index].f_charge_money.match(/^\d*(\.?\d{0,2})/g)[0]) || null
    //   this.charge.payment_terms[index].f_amount_words = this.smalltoBIG(this.charge.payment_terms[index].f_charge_money)
    // },
    // 金额转大写
    // 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(/^整$/, '零元整')
    // },
    // moneyChange(index) {
    //   console.log(`当前下标----${index}`)
    //   if (isEmpty(this.charge.payment_terms[index].f_charge_money) || Number(this.charge.payment_terms[index].f_charge_money) === 0) {
    //     this.$showMessage('单笔收费不能为0元！！！', 'warning', 3000)
    //     this.charge.payment_terms[index].f_charge_money = null
    //     return
    //   }
    //
    // },
    // 打开二维码
    // async openQrCode() {
    //   let http = new HttpResetClass()
    //   for (let row = 0; row < this.charge.payment_terms.length; row++) {
    //     console.log(this.charge.payment_terms[row])
    //     if (isEmpty(this.charge.payment_terms[row].f_payment_term)) {
    //       this.$showMessage('请选择收费项目！！！', 'warning', 3000)
    //       return
    //     } else if (isEmpty(this.charge.payment_terms[row].f_charge_money)) {
    //       this.$showMessage('请输入收费金额！！！', 'warning', 3000)
    //       return
    //     }
    //   }
    //   if (this.charge.f_payment_method !== '微信支付' && this.charge.f_payment_method !== '支付宝支付') {
    //     this.saveother()
    //     this.$showMessage('缴费成功！')
    //     this.update()
    //     this.showCharge = false
    //     return
    //   }
    //   if (this.charge.f_payment_method == '微信支付') {
    //     this.title1 = '微信'
    //   }
    //   if (this.charge.f_payment_method == '支付宝支付') {
    //     this.title1 = '支付宝'
    //   }
    //   this.showCharge = false
    //   // 接口金额 单位为：分
    //   let data = {
    //     money: this.accMul(this.getTotalAmount(), 1) + '',
    //     attach: {
    //       "f_user": Vue.user.id,
    //       "f_user_name": Vue.user.name
    //     },
    //     orderType: '工单收费',
    //     userfilesid: '',
    //     flag: 'JsApiWeiNan',
    //     openid: '',
    //     filiale: 'weinanchengtou'
    //   }
    //   // 下订单
    //   await http.load('POST', `${this.$androidUtil.getProxyUrl()}/wx/rs/pay/jsApiPay`, data, {
    //     resolveMsg: null,
    //     rejectMsg: '订单生成失败！！！'
    //   }).then(
    //     res => {
    //       this.order = res.data
    //       this.showQrCode = true
    //       this.$nextTick(() => {
    //         this.qrcode()
    //       })
    //       // 剩余支付时间
    //       this.paymentInterval = setInterval(() => {
    //         this.timeLeft = this.timeLeft - 1
    //       }, 1000)
    //
    //       // 3秒查询一次订单支付信息
    //       this.orderInterval = setInterval(() => {
    //         this.getOrderInformation()
    //       }, 3000)
    //     }
    //   )
    // },
    // getTotalAmount() {
    //   let money = 0
    //   this.charge.payment_terms.forEach((row) => {
    //     money = Math.floor((Number(money) + Number(row.f_charge_money)) * 100) / 100
    //   })
    //   return money
    // },
    // getPaymentTerm() {
    //   let term = ''
    //   this.charge.payment_terms.forEach((row) => {
    //     term += `${row.f_payment_term} `
    //   })
    //   return term
    // },
    // closeQRCode() {
    //   clearTimeout(this.paymentInterval)
    //   clearTimeout(this.orderInterval)
    //   this.timeLeft = 300
    //   this.closeOrder()
    //   // 清除二维码
    //   this.clearQrCode()
    //   this.showQrCode = false
    // },
    // clearQrCode() {
    //   document.getElementById('qrcode').innerHTML = ''
    // },
    // async closeOrder() {
    //   let data = {
    //     "flag": "JsApiWeiNan",
    //     "f_filiale": "weinanchengtou",
    //     "f_out_trade_no": this.order.f_out_trade_no,// 商户单号
    //     "isClose": "是",
    //     "f_sys_trace": this.order.f_sys_trace // 交易流水号
    //   }
    //   let http = new HttpResetClass()
    //   let res = await http.load('POST', `${this.$androidUtil.getProxyUrl()}/wx/rs/pay/microPayOrderStatus`, data, {
    //     resolveMsg: null,
    //     rejectMsg: '关闭失败！！！'
    //   })
    // },
    // qrcode() {
    //   let qrcode = new QRCode('qrcode', {
    //     text: this.order.appId, // 设置二维码内容或跳转地址
    //     width: 200, // 设置宽度，单位像素
    //     height: 200, // 设置高度，单位像素
    //     correctLevel: QRCode.CorrectLevel.L //容错率，L/M/Hs
    //   })
    // },
    // // 获取订单信息
    // async getOrderInformation() {
    //   // 查询订单信息
    //   console.log('查询订单信息！！！')
    //   let http = new HttpResetClass()
    //   let res = await http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/sql/tel_singleTable`, {
    //     data: {
    //       tablename: "t_weixinreturnxml",
    //       condition: ` f_out_trade_no = '${this.order.f_out_trade_no}' and f_order_state = '已支付' `,
    //     }
    //   }, {
    //     resolveMsg: null,
    //     rejectMsg: '订单查询失败！！！'
    //   })
    //   // 支付成功
    //   if (res.data.length > 0) {
    //     clearTimeout(this.paymentInterval)
    //     clearTimeout(this.orderInterval)
    //     this.timeLeft = 300
    //     // 修改支付状态
    //     this.saveother()
    //     this.$showMessage('支付成功！！！')
    //     this.update()
    //     // 清除二维码
    //     this.clearQrCode()
    //     this.showQrCode = false
    //   }
    // },
    // async update() {
    //   let http = new HttpResetClass()
    //   for (let i = 0; i < this.material.length; i++) {
    //     if (this.material[i].f_state == '未收费') {
    //       this.material[i].f_state = '已收费'
    //     }
    //   }
    //   let data = {
    //     model: this.material
    //   }
    //   let res = await http.load('post', this.$androidUtil.getProxyUrl() + '/rs/logic/saveweinanmaterial', {data: data}, {
    //     resolveMsg: null,
    //     rejectMsg: '保存失败'
    //   })
    //   this.search()
    // },
    // async saveother() {
    //   let http = new HttpResetClass()
    //   let data1 = {
    //     tablename: 't_material_service',
    //     condition: `f_process_id = '${this.selectdata.f_process_id}' and f_state = '未收费'`
    //   }
    //   let res1 = await http.load('post', this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data: data1}, {
    //     resolveMsg: null,
    //     rejectMsg: '获取数据失败'
    //   })
    //   let data = {
    //     tablename: 't_userfiles',
    //     condition: `f_userinfo_id = '${this.selectdata.model.f_userinfo_id}'`
    //   }
    //   let res = await http.load('post', this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data: data}, {
    //     resolveMsg: null,
    //     rejectMsg: '获取数据失败'
    //   })
    //   let otherdetails = []
    //   for (let i = 0; i < res1.data.length; i++) {
    //     otherdetails.push(
    //       {
    //         "f_brand_spec": [res1.data[i].f_material_name],
    //         "f_unitprice": res1.data[i].f_material_price,
    //         "f_typename": [res1.data[i].f_typename],
    //         "f_typenumber": [res1.data[i].f_typenumber],
    //         "f_number": res1.data[i].f_material_number
    //       }
    //     )
    //   }
    //
    //   console.log("查询的用户信息", otherdetails)
    //   let data2 = {
    //     "record_userinfo": this.selectdata.model.f_userinfo_id,
    //     "f_userfiles_id": res.data[0].f_userfiles_id,
    //     "f_user_id": res.data[0].f_user_id,
    //     "f_user_name": this.selectdata.model.f_user_name,
    //     "f_address": this.selectdata.model.f_address,
    //     "f_user_type": this.selectdata.model.f_user_type,
    //     "f_gasproperties": "",
    //     "f_collection": this.f_cost_sum,
    //     "f_comments": "",
    //     "f_payment": this.charge.f_payment_method,
    //     "f_voucher_number": "",
    //     "f_bill_style": "普通收据",
    //     "f_userinfo_id": this.selectdata.model.f_userinfo_id,
    //     "f_service_person": Vue.user.name,
    //     "f_operat_type": "其他收费",
    //     "f_describe": "",
    //     "f_state": "有效",
    //     "f_operator": Vue.user.name,
    //     "f_operatorid": Vue.user.id,
    //     "f_orgid": Vue.user.orgid,
    //     "f_orgname": Vue.user.orgs,
    //     "f_depid": Vue.user.depids,
    //     "f_depname": Vue.user.f_department_name,
    //     "t_userfees": "",
    //     "f_fee_type": "其他费用",
    //     "f_fee_time": "12",
    //     "otherdetail": otherdetails
    //   }
    //   let res2 = await http.load('POST', `${this.$androidUtil.getProxyUrl()}/rs/logic/sale_othercharge_logic`, {data: data2}, {
    //     resolveMsg: null,
    //     rejectMsg: '保存数据失败'
    //   })
    // },
    // async shoufei() {
    //   let http = new HttpResetClass()
    //   let data = {
    //     tablename: 't_material_service',
    //     condition: `f_process_id = '${this.selectdata.f_process_id}' and f_state = '未收费'`
    //   }
    //   let res = await http.load('post', this.$androidUtil.getProxyUrl() + '/rs/sql/tel_singleTable', {data: data}, {
    //     resolveMsg: null,
    //     rejectMsg: '获取数据失败'
    //   })
    //   if (res.data.length <= 0) {
    //     this.$showMessage('请先添加未收费的材料！！！')
    //     return
    //   }
    //   this.f_cost_sum = 0
    //   for (let i = 0; i < res.data.length; i++) {
    //     this.f_cost_sum += Number(res.data[i].f_fee)
    //   }
    //   this.showCharge = true
    //   this.charge.payment_terms[0].f_charge_money = this.f_cost_sum
    // },
    // accMul(arg1, arg2) {
    //   let m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    //   try {
    //     m += s1.split(".")[1].length
    //   } catch (e) {
    //   }
    //   try {
    //     m += s2.split(".")[1].length
    //   } catch (e) {
    //   }
    //   return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
    // },
  },
  events: {},
  computed: {
    paymentMethod() {
      return this.$appdata.getParam("付款方式")
    },
    paymentTerm() {
      return this.$appdata.getParam("收费项目")
    }
  },
  watch: {}
}
</script>
<style lang="less" scoped>
.head-but {
  margin-left: 5px;
  height: 34px;
  /*background-color: #6aa6e2;*/
  border-radius: 4px;
  font-family: PingFang;
  color: #ffffff;
}

/*清除model中的浮动*/
.clearfix:after, .clearfix:before {
  display: table;
}

.clearfix:after {
  clear: both;
}

.y-form {
  display: flex;
  flex-flow: column;
  gap: 10px;
  padding: 10px 5px;

  .y-form-head {
    background-color: #e8f4ff;
    display: flex;
    padding: 10px 20px;
    align-items: center;
    justify-content: space-between;
  }

  .y-form-item {
    display: flex;
    gap: 10px;

    label {
      width: 30%;
      text-align: right;
    }

    .y-form-item-input {
      width: 70%;
    }
  }
}
</style>
