Прошлый день
This commit is contained in:
1 parent
c6ce03187e
commit
b00c186bfb
2 files changed
+94
-73
No files matched your search
@@ -48,7 +48,13 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
setup(props) {
|
||||||
|
console.log(props.countvising, 'Передача пропса');
|
||||||
|
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row no-gutters class="ma-1">
|
<v-row no-gutters class="ma-1">
|
||||||
<v-col class="d-flex flex-column gap">
|
<v-col class="d-flex flex-column gap">
|
||||||
|
<my-helper :pretext="countvising"/>
|
||||||
<v-row no-gutters class="flex-grow-0">
|
<v-row no-gutters class="flex-grow-0">
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-toolbar
|
<v-toolbar
|
||||||
@@ -81,19 +81,19 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr class="text-uppercase">
|
<tr class="text-uppercase">
|
||||||
<th>Имя страницы</th>
|
<th>Имя страницы</th>
|
||||||
<th class="text-center"> на {{today}} </th>
|
<th class="text-center"> на {{selected_days.today}} </th>
|
||||||
<th class="text-center">за период</th>
|
<th class="text-center">за период</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<!-- <tbody>
|
||||||
<tr v-for="(val, key) in countgrupp()" :key = key>
|
<tr v-for="(val, key) in countgrupp()" :key = key>
|
||||||
<td class="text-left">{{key}}</td>
|
<td class="text-left">{{key}}</td>
|
||||||
<td class="text-center">{{ modelrating?val.now[0].size:val.now[1] }} </td>
|
<td class="text-center">{{ modelrating?val.now[0].size:val.now[1] }} </td>
|
||||||
<td class="text-center">{{ modelrating?val.year[0].size:val.year[1] }}</td>
|
<td class="text-center">{{ modelrating?val.year[0].size:val.year[1] }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody> -->
|
||||||
</v-table>
|
</v-table>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -155,18 +155,67 @@ setup(){
|
|||||||
const visiting = ref([])
|
const visiting = ref([])
|
||||||
const feedback = ref([])
|
const feedback = ref([])
|
||||||
const staff = ref(0)
|
const staff = ref(0)
|
||||||
const countvising = ref({now: [new Set(), 0], year: [new Set(), 0]})
|
const selected_days = ref({today: '', year: ''})
|
||||||
|
const countvising = ref({now: [new Set(), 0], period: [new Set(), 0], year: [new Set(), 0]})
|
||||||
const crit = ref([])
|
const crit = ref([])
|
||||||
const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
|
const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
|
||||||
const endate =ref(format2(new Date()))
|
const endate =ref(format2(new Date()))
|
||||||
|
const last_days = ref('')
|
||||||
const icons = ['mdi-numeric-1-box-outline', 'mdi-numeric-2-box-outline', 'mdi-numeric-3-box-outline']
|
const icons = ['mdi-numeric-1-box-outline', 'mdi-numeric-2-box-outline', 'mdi-numeric-3-box-outline']
|
||||||
|
|
||||||
const selected_days = ref({today: '', year: ''})
|
|
||||||
const today = ref('')
|
|
||||||
const year = ref('')
|
|
||||||
|
|
||||||
const modelrating = ref(false)
|
const modelrating = ref(false)
|
||||||
|
|
||||||
|
pagecounter()
|
||||||
|
|
||||||
|
const weekstart = () => {
|
||||||
|
|
||||||
|
let days_between = Math.floor((new Date(endate.value) - new Date(startdate.value)) / (1000*60*60*24))
|
||||||
|
let start = format1(new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between)))
|
||||||
|
let end = ''
|
||||||
|
|
||||||
|
console.log(start, end, days_between, format1(last_days.value), 'относительно сегодня');
|
||||||
|
// let Start = moment(date).subtract(1, 'weeks').startOf('isoWeek')._d // начало предыдущей недели
|
||||||
|
// let End =new Date(new Date(WeekStart).setDate(new Date(WeekStart).getDate() + 4)) // конец предыдущей недели
|
||||||
|
return {start, end}
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastperiod = () => {
|
||||||
|
let last_day = []
|
||||||
|
visiting.value.map((e)=>{
|
||||||
|
if (e.visitdate < format2(endate.value))
|
||||||
|
last_day.push(e.visitdate)
|
||||||
|
})
|
||||||
|
last_days.value = last_day[last_day.length-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
const returnstart = (dates) => {
|
||||||
|
startdate.value = dates
|
||||||
|
visition()
|
||||||
|
}
|
||||||
|
|
||||||
|
const returnend = (dates) => {
|
||||||
|
endate.value = dates
|
||||||
|
visition()
|
||||||
|
}
|
||||||
|
|
||||||
|
const periodname = () => {
|
||||||
|
selected_days.value.today = 'сегодня'
|
||||||
|
if (format2(new Date()) != format2(endate.value)) {
|
||||||
|
selected_days.value.today = format1(endate.value)
|
||||||
|
}
|
||||||
|
selected_days.value.year = [format1(startdate.value), format1(endate.value)]
|
||||||
|
}
|
||||||
|
|
||||||
|
const visition = () => {
|
||||||
|
let end = format2(new Date(endate.value).setDate(new Date(endate.value).getDate() + 1))
|
||||||
|
axiosApiInstance.get(`api/watcher/counter/?start=${startdate.value}&end=${end}`).then(result => {
|
||||||
|
staff.value = result.data.staff
|
||||||
|
visiting.value = result.data.result
|
||||||
|
feedback.value = result.data.feedback
|
||||||
|
lastperiod()
|
||||||
|
countgrupp()
|
||||||
|
periodname()
|
||||||
|
weekstart()
|
||||||
|
})}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -174,49 +223,12 @@ setup(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const weekstart = (date) => {
|
|
||||||
let WeekStart = moment(date).subtract(1, 'weeks').startOf('isoWeek')._d // начало предыдущей недели
|
|
||||||
let WeekEnd =new Date(new Date(WeekStart).setDate(new Date(WeekStart).getDate() + 4)) // конец предыдущей недели
|
|
||||||
return {WeekStart, WeekEnd}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const returnstart = (dates) => {
|
|
||||||
startdate.value = dates
|
|
||||||
periodname()
|
|
||||||
visition()
|
|
||||||
}
|
|
||||||
|
|
||||||
const returnend = (dates) => {
|
|
||||||
endate.value = dates
|
|
||||||
periodname()
|
|
||||||
visition()
|
|
||||||
}
|
|
||||||
|
|
||||||
const visition = () => {
|
|
||||||
|
|
||||||
let end = format2(new Date(endate.value).setDate(new Date(endate.value).getDate() + 1))
|
|
||||||
axiosApiInstance.get(`api/watcher/counter/?start=${startdate.value}&end=${end}`).then(result => {
|
|
||||||
staff.value = result.data.staff
|
|
||||||
visiting.value = result.data.result
|
|
||||||
feedback.value = result.data.feedback
|
|
||||||
})}
|
|
||||||
|
|
||||||
pagecounter()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const countgrupp = () => {
|
const countgrupp = () => {
|
||||||
|
|
||||||
let us = {}
|
let us = {}
|
||||||
// let countall = {now: [new Set(), 0], year: [new Set(), 0]}
|
let countall = {now: [new Set(), 0, 0], year: [new Set(), 0]}
|
||||||
|
let lastday = new Set()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const groupedData =
|
const groupedData =
|
||||||
@@ -229,18 +241,33 @@ setup(){
|
|||||||
|
|
||||||
acc[item.pages]['year'][0].add(item.author.id)
|
acc[item.pages]['year'][0].add(item.author.id)
|
||||||
acc[item.pages]['year'][1] += item.count
|
acc[item.pages]['year'][1] += item.count
|
||||||
countvising.value['year'][0].add(item.author.id)
|
countall['year'][0].add(item.author.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (item.visitdate == format2(endate.value)) {
|
if (item.visitdate == format2(endate.value)) {
|
||||||
acc[item.pages]['now'][0].add(item.author.id)
|
acc[item.pages]['now'][0].add(item.author.id)
|
||||||
acc[item.pages]['now'][1] += item.count
|
acc[item.pages]['now'][1] += item.count
|
||||||
countvising.value['now'][0].add(item.author.id)
|
countall['now'][0].add(item.author.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(format1(last_days.value), 'last_days.value');
|
||||||
|
|
||||||
|
// Посещаемость портала для перода 1 день
|
||||||
|
if (item.visitdate ==format2(last_days.value)){
|
||||||
|
lastday.add(item.author.id)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
countall['now'][2] = lastday.size
|
||||||
|
// console.log(lastday, 'format2(last_day[last_day.length-1])')
|
||||||
|
// console.log(item.visitdate, , 'item.visitdate');
|
||||||
|
|
||||||
|
// let week = weekstart(endate.value)
|
||||||
|
// if (item.visitdate >=format2(week.start) && item.visitdate <= format2(week.end)) {
|
||||||
|
// console.log(item.visitdate,' item.visitdate');
|
||||||
|
// acc[item.pages]['week'][0].add(item.author.id)
|
||||||
|
// acc[item.pages]['week'][1] += item.count
|
||||||
|
// countall['week'][0].add(item.author.id)
|
||||||
|
// countall['week'][1] += item.count
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -268,33 +295,24 @@ setup(){
|
|||||||
return acc
|
return acc
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
countvising.value['now'][1] = percentageStaff(countvising.value['now'][0])
|
countall['now'][1] = percentageStaff(countall['now'][0])
|
||||||
countvising.value['year'][1] = percentageStaff(countvising.value['year'][0])
|
countall['year'][1] = percentageStaff(countall['year'][0])
|
||||||
|
|
||||||
|
|
||||||
|
countvising.value = countall
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const percentageStaff = (customers) => {
|
const percentageStaff = (customers) => {
|
||||||
return Math.round((customers.size*100)/staff.value)+'%'
|
return Math.round((customers.size*100)/staff.value)+'%'
|
||||||
}
|
}
|
||||||
|
|
||||||
const periodname = () => {
|
|
||||||
let datas = weekstart(endate.value)
|
|
||||||
|
|
||||||
selected_days.value.today = 'сегодня'
|
|
||||||
|
|
||||||
if (format2(new Date()) != format2(endate.value)) {
|
|
||||||
selected_days.value.today = format1(endate.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
selected_days.value.year = [format1(startdate.value), format1(endate.value)]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
periodname()
|
|
||||||
|
|
||||||
|
|
||||||
const activuser = () => {
|
const activuser = () => {
|
||||||
@@ -350,10 +368,7 @@ setup(){
|
|||||||
icons,
|
icons,
|
||||||
periodname,
|
periodname,
|
||||||
weekstart,
|
weekstart,
|
||||||
today,
|
|
||||||
selected_days,
|
selected_days,
|
||||||
|
|
||||||
year,
|
|
||||||
modelrating
|
modelrating
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user