All files / src/components/UI/aboutportal portal-traffic.vue

0% Statements 0/39
0% Branches 0/20
0% Functions 0/11
0% Lines 0/39

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182                                                                                                                                                                                                                                                                                                                                                                           
<template>
  <pattern-card
    :title="'Посещаемость портала'"
    :ico="'mdi-walk'"
  >
    <template v-slot:filling>
      <v-table class="text-subtitle-2 table_traffic pt-1">
        <thead>
          <tr>
            <th class="pr-0"></th>
            <th class="text-center px-1">сегодня</th>
            <th class="text-center">за период</th>
          </tr>
        </thead>
        <tbody class="text-button">
          <tr> 
            <td>
              <tooltip-ico :info=traffic.user />
            </td> 
            <td :class="csstext()">
            <!-- -->
              <tooltip-user :info=traffic.user.today />
            </td>
            <td :class="csstext()">
              <tooltip-user :info=traffic.user.period />
            </td>
          </tr> 
          <tr> 
            <td>
              <tooltip-ico :info=traffic.proc />
            </td> 
            <td :class="cssproc()">
            {{traffic.proc.today}}%
            </td>
            <td :class="cssproc()">
              {{traffic.proc.period}}%
            </td>
          </tr>       
          <tr> 
            <td>
              <tooltip-ico :info=traffic.before />
            </td> 
            <td >
 
            </td>
            <td :class="cssproc()">
              <v-icon
                v-if="parseFloat((traffic.user.period.length * 100 /traffic.before.period).toFixed(2))-100 != 'Infinity' && parseFloat((traffic.user.period.length * 100 /traffic.before.period).toFixed(2))-100 != 0"
                size="x-small"
                :class="traffic.before.period<traffic.user.period.length?'pb-1':'pt-0'"
                :color="traffic.before.period<traffic.user.period.length?'green-darken-2':'deep-orange-darken-4'"
                :icon="traffic.before.period<traffic.user.period.length?'mdi-arrow-up-bold':'mdi-arrow-down-bold'"
              />
     
              <span v-if="traffic.before.period!=0">

                {{parseFloat(((traffic.user.period.length * 100 /traffic.before.period)-100).toFixed(2))}} %
              </span>
              <span v-else>
                0%
              </span>
            
            </td>
          </tr>    
          
          
        </tbody>
      </v-table>
    </template>
  </pattern-card>
</template>
 
<script>
import PatternCard from '@/components/UI/aboutportal/pattern-card.vue'
import { ref, computed } from 'vue'
import {formatDash, splitname, checking_for_entry} from '@/utils/universal_functions'
import { usePortalFilterStore } from '@/store/AboutPortalFilter'
import moment from 'moment'
import TooltipIco from '@/components/UI/aboutportal/tooltip-ico.vue'
import TooltipUser from '@/components/UI/aboutportal/tooltip-user.vue'
export default {

  components: {
    PatternCard,
    TooltipIco,
    TooltipUser
  },
 
    props: {
 
      alldata: {
        type: Object,
            default: () => {return {period: [], staff: 0}}
      },
 
       
},
    setup(props) {
      const filterStore = usePortalFilterStore()
      const traffic = computed({
        get() {
 
 
let res = {
  "user": {
    "tooltip": "Уникальные пользователи",
    "today": [],
    "period": [],
    "ico": "mdi-account-box",
    "color" : "indigo"
  },
  "proc": {
    "tooltip": "% от штата",
    "today": 0,
    "period": 0,
    "ico": "mdi-chart-pie",
    "color" : "green"
  },
 
  "before": {
    "tooltip":"По сравнению предыдущим периодом",
    "today": "",
    "period": 0,
    "ico": "mdi-elevation-rise",
    "color" : "pink-darken-4"
  }
  
}
 
 
          
          props.alldata.period.forEach(e => { 
        
            if (e.visitdate == formatDash(new Date())) {
                checking_for_entry(res.user.today, splitname(e.user)) 
            }
            if (new Date(e.visitdate) <= filterStore.date_period.enddate) {
              checking_for_entry(res.user.period, splitname(e.user)) 
            }
            
          })
        //   res.before.user=res.period.user
          res.proc.today = parseFloat(((res.user.today.length * 100) / props.alldata.staff).toFixed(2))
          res.proc.period = parseFloat(((res.user.period.length * 100) / props.alldata.staff).toFixed(2))
          // res.proc.tooltip =`% от штата (${props.alldata.staff} сотрудников не конец выбранного периода)` 
          let data1 = moment(filterStore.date_period.enddate)
          let data2 = moment(filterStore.date_period.startdate)
          let between = data1.diff(data2, 'days') + 1
  
          
          props.alldata.beforperiod.filter( e=> data2.diff(moment(e.visitdate), 'days') <  between).reduce((acc, item) => {
            res.before.period += item.user.length
            return acc
          }, res.before.period)
 
         return res
        }
      })
      const csstext = () => {
        return 'text-center px-0 font-weight-bold text-subtitle-1 cursor-help text-grey-darken-3'
      }
 
      const cssproc = () => {
        return 'text-center font-weight-bold text-subtitle-1 text-grey-darken-3 cursor-default'
      }
 
        return {
          traffic,
          csstext,
          cssproc
        }
    }
 
}
</script>
 
<style>
.v-table > .v-table__wrapper > table > tbody > tr > td 
{
  padding: 0 0 0px;
}
</style>