const auditAdvancedGroupMixins = {
  data() {
    return {
      // expand: false,
      // searchIconType: 'down',
    }
  },
  methods: {
    changebtnClick(item) {
      this[item] = !this[item]
    },
    changedClick(item) {
      this.changebtnClick(item)
    },
    getTotal(arr) {
      const fieldArr = []
      for (var i = 0; i < arr.length; i++) {
        var m, field
        try {
          field = arr[i].amount.toString().split('.')[1].length
        } catch (e) {
          field = 0
        }
        fieldArr.push(field)
      }
      m = Math.pow(10, Math.max(...fieldArr))
      let add = 0
      arr.forEach(function(item) {
        if (item.amount) {
          var regu = /^(([1-9][0-9]*)|(([0]\.\d{1,}|[1-9][0-9]*\.\d{1,})))$/
          if (regu.test(item.amount)) {
            add = add + item.amount * m
          }
        }
      })

      const sum = Math.round(add) / m
      return sum
    },
    getTotal1(arr) {
      const fieldArr = []
      for (var i = 0; i < arr.length; i++) {
        var m, field
        try {
          field = arr[i].personTimes.toString().split('.')[1].length
        } catch (e) {
          field = 0
        }
        fieldArr.push(field)
      }
      m = Math.pow(10, Math.max(...fieldArr))
      let add = 0
      arr.forEach(function(item) {
        if (item.personTimes) {
          var regu = /^(([1-9][0-9]*)|(([0]\.\d{1,}|[1-9][0-9]*\.\d{1,})))$/
          if (regu.test(item.personTimes)) {
            add = add + item.personTimes * m
          }
        }
      })

      const sum = Math.round(add) / m
      return sum
    },
    getTotal2(arr) {
      const fieldArr = []
      for (var i = 0; i < arr.length; i++) {
        var m, field
        try {
          field = arr[i].personNumber.toString().split('.')[1].length
        } catch (e) {
          field = 0
        }
        fieldArr.push(field)
      }
      m = Math.pow(10, Math.max(...fieldArr))
      let add = 0
      arr.forEach(function(item) {
        if (item.personNumber) {
          var regu = /^(([1-9][0-9]*)|(([0]\.\d{1,}|[1-9][0-9]*\.\d{1,})))$/
          if (regu.test(item.personNumber)) {
            add = add + item.personNumber * m
          }
        }
      })

      const sum = Math.round(add) / m
      return sum
    },
  },
}

export default auditAdvancedGroupMixins
