Алерты

This commit is contained in:
iriska-gri committed 2023-11-27 15:53:14 +03:00
1 parent 1ba8607f40
commit da0d0b4dcb
8 files changed
+121 -173

No files matched your search

+28 -13
View File
@@ -1,25 +1,40 @@
<template>
<v-alert
v-model="alert"
border="start"
variant="tonal"
closable
close-label="Close Alert"
color="deep-purple-accent-4"
title="Closable Alert"
>
Aenean imperdiet. Quisque id odio. Cras dapibus. Pellentesque ut neque. Cras dapibus.
Vivamus consectetuer hendrerit lacus. Sed mollis, eros et ultrices tempus, mauris ipsum aliquam libero, non adipiscing dolor urna a orci. Sed mollis, eros et ultrices tempus, mauris ipsum aliquam libero, non adipiscing dolor urna a orci. Curabitur blandit mollis lacus. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo.
</v-alert>
width = "500"
position="fixed"
class="bottom-alert"
type="success"
title="Успех!"
text="Файл загружен"
:value="alert"
closable
></v-alert>
</template>
<script>
import { ref } from 'vue'
export default {
// props: {
// alert: {
// type: Boolean,
// default: false
// }
// },
setup(){
defineProps(['alert'])
// defineEmits(['update:alert'])
// const alert = ref(true)
return {defineProps}
}
}
</script>
<style>
.bottom-alert {
bottom: 10px;
left: 40%;
}
</style>
+35 -51
View File
@@ -3,14 +3,15 @@
<v-col class="flex-column d-flex">
<v-row class="flex-grow-0 mhight">
<v-col class=" flex-column d-flex">
<v-card class="ml-2 mt-2" width="400" >
<v-card class="ml-2 mt-2" width="500" >
<v-card-title class="text-wrap pb-3">
Ежедневная статистика по сотрудникам
<!-- <v-icon icon="mdi-comment-question-outline" size="xsmall"></v-icon> -->
</v-card-title>
<v-row class="flex-grow-0 align-self-end">
<v-col class="d-flex">
<v-card-subtitle class="mt-2 align-self-end">Файл ежедневной статистики</v-card-subtitle>
<v-card-subtitle class="mt-2 align-self-end">
1. Скачать файл ежедневной статистики
</v-card-subtitle>
<v-icon
class="pt-2 pl-2"
icon="mdi-file-excel"
@@ -22,21 +23,24 @@
</v-row>
<v-row>
<v-col>
<v-card-subtitle class="align-self-center ml-3">
2. Загрузить данные на сервер
</v-card-subtitle>
<v-col class="pr-0">
<v-file-input
accept=".xlsx"
v-model="dailyfiles"
variant="underlined"
density="compact"
label="Выберите файл"
label="Прикрепить файл"
hide-details
class="mr-2 pb-2"
/>
</v-col>
<v-col class="flex-grow-0 align-self-center mb-2">
<v-col class="flex-grow-0 align-self-center pl-0 pr-6">
<v-icon
icon="mdi-download"
icon="mdi-chevron-double-right"
color="blue-grey-darken-2"
@click="onPickFile('roundfilse')"
/>
@@ -49,47 +53,25 @@
</v-col>
<v-col class=" flex-column d-flex">
<!-- <v-row class="flex-grow-0 align-self-end">
<v-col>
<v-icon
class="pt-2"
icon="mdi-file-excel"
color="green-darken-3"
@click="excelOp('vacationsExcel')"
/>
</v-col>
</v-row> -->
<!-- <v-row>
<v-col>
<v-file-input
accept=".xlsx"
v-model="dailyfiles"
variant="underlined"
density="compact"
label="Выберите файл"
hide-details
class="mr-2"
/>
</v-col>
<v-col class="flex-grow-0 align-self-center mb-2">
<v-icon
icon="mdi-download"
color="blue-grey-darken-2"
@click="onPickFile('vacationsExcel')"
/>
</v-col>
</v-row> -->
</v-col>
<v-col></v-col>
<v-col></v-col>
<v-col></v-col>
<v-col></v-col>
<v-alert
width = "500"
position="fixed"
class="bottom-alert"
:type='info.mess=="Файл загружен"?"success":"error"'
:title='info.mess=="Файл загружен"?"Успеssх!":"Упс!"'
:text="info.mess"
v-model="alert"
:color='info.mess=="Файл загружен"?"teal-accent-4":"error"'
closable
></v-alert>
</v-row>
<!-- <v-row>
<v-col v-for="(x) in 6" :key=x class=" flex-column d-flex">
@@ -110,11 +92,12 @@ import { axiosApiInstance } from '@/utils/axios-api'
export default {
setup(){
const dailyfiles = ref('')
const dailyfiles = ref([])
const visiting = ref({})
const info = ref({})
const t_dailyRound = ref('')
const alert = ref(false)
@@ -127,11 +110,7 @@ export default {
})
}
// const excelVacation = () => {
// }
const onPickFile = (ex) => {
@@ -141,10 +120,10 @@ export default {
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
info.value = result.data
console.log(result.data, '----------------')
console.log(info.value, '----------------result.data')
})
showInfo.value = true
dailyfiles.value = ''
dailyfiles.value = []
alert.value = true
@@ -184,4 +163,9 @@ export default {
.mhight {
height: 150px;
}
.bottom-alert {
bottom: 10px;
left: 40%;
}
</style>
+3 -1
View File
@@ -23,7 +23,9 @@
</v-col>
<v-col class="flex-column d-flex ma-3">
<v-row >
<v-col cols="3" class="flex-grow-0 pa-0 pb-3"> <digital-letna/></v-col>
<v-col cols="4" class="flex-grow-0 pa-0 pb-3">
<digital-letna/>
</v-col>
<v-col class="flex-column d-flex pr-0 pt-0 pb-0">
<v-card class=" flex-column pik overflow-auto">
+11 -1
View File
@@ -1,19 +1,29 @@
<template>
<v-row >
<load-round/>
</v-row>
<!-- -->
</template>
<script>
import LoadRound from '@/components/load-round.vue'
import {pagecounter} from '@/utils/universal_functions'
export default {
components: {
LoadRound
},
setup(){
pagecounter()
}
}
+2 -2
View File
@@ -15,8 +15,8 @@ class PlanCalendarAdmin(admin.ModelAdmin):
fields = ('name', 'start_work_period', 'end_work_period')
class BasePositionAmin(admin.ModelAdmin):
list_display = ('name', 'order')
list_editable = ('order',)
list_display = ('id', 'name', 'order')
list_editable = ('order', 'name')
# admin.site.register(GeneralVacation, GeneralVacationAdmin),
admin.site.register(PlanCalendar, PlanCalendarAdmin)
+38 -100
View File
@@ -23,10 +23,9 @@ class roundExcel():
self.df['tabel'] = self.df['login'].str.split('-', expand = True)[1]+self.df['login'].str.split('-', expand = True)[2]
file_path = 'media/DailyRoundUp.xlsx'
thins = Side(border_style="thin")
print(len(self.df), "-------------------------------")
ws = self.wb.active
filters = ws.auto_filter
filters.ref = "A6:L15"
filters.ref = "A6:N15"
ws.title = "Список"
ws['B2'] = 'Список сотрудников'
ws['B3'] = 'МИ ФНС России по ЦОД № 2'
@@ -45,11 +44,12 @@ class roundExcel():
ws['G6'] = 'Отпуск'
ws['I6'] = 'Болен'
ws['K6'] = 'Удаленка'
ws['M6'] = 'Командировка'
heads =['G6', 'I6', 'K6']
heads =['G6', 'I6', 'K6', 'M6']
for x in heads:
ws[x].fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
@@ -62,7 +62,7 @@ class roundExcel():
numb = 1
column_widths = [29, 53, 96, 96, 112, 28, 222, 29, 148, 28, 145, 33]
column_widths = [29, 53, 96, 96, 112, 28, 222, 29, 148, 28, 145, 33, 148, 28]
for i, width in enumerate(column_widths):
column_letter = oxl.utils.get_column_letter(i+1)
ws.column_dimensions[column_letter].width = self.convert_width(width)
@@ -96,7 +96,7 @@ class roundExcel():
zap = [7, 9, 11]
zap = [7, 9, 11, 13]
for x in range(len(l)):
k=k+1
@@ -107,9 +107,7 @@ class roundExcel():
ws.cell(row = k, column = 3).value = l.iloc[x]['familyname']
ws.cell(row = k, column = 4).value = l.iloc[x]['name']
ws.cell(row = k, column = 5).value = l.iloc[x]['parentname']
ws.cell(row = k, column = 6).value = '=If(OR(H'+str(k)+'=1, J'+str(k)+'=1, L'+str(k)+'=1,),"",1)'
# '=If(H'+str(k)+'=1,IF(J'+str(k)+',IF(L'+str(k)+',"",1)))'
ws.cell(row = k, column = 6).value = '=If(OR(H'+str(k)+'=1, J'+str(k)+'=1, L'+str(k)+'=1, N'+str(k)+'=1),"",1)'
for h in zap:
ws.cell(row = k, column = h).border = Border(top=thins, bottom=thins, left=thins, right=thins)
@@ -126,46 +124,25 @@ class roundExcel():
k=k+1
ws.cell(row = k+1, column=6).value = len(self.df)
# "=SUM(F6:F"+str(k-1)+")"
ws.cell(row = k+1, column=6).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
ws.cell(row = k+1, column=6).font = Font(name='Times New Roman', size=13, bold=True)
ws.cell(row = k+1, column=7).value = "ВСЕГО отпуск="
ws.cell(row = k+1, column=7).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
ws.cell(row = k+1, column=7).font = Font(name='Times New Roman', size=10, bold=True)
ws.cell(row = k+1, column=8).value = "=SUM(H6:H"+str(k-1)+")"
ws.cell(row = k+1, column=8).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
ws.cell(row = k+1, column=8).font = Font(name='Times New Roman', size=10, bold=True)
ws.cell(row = k+1, column=9).value = "Всего больных="
ws.cell(row = k+1, column=9).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
ws.cell(row = k+1, column=9).font = Font(name='Times New Roman', size=10, bold=True)
ws.cell(row = k+1, column=10).value = "=SUM(J6:J"+str(k-1)+")"
ws.cell(row = k+1, column=10).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
ws.cell(row = k+1, column=10).font = Font(name='Times New Roman', size=10, bold=True)
ws.cell(row = k+1, column=11).value = "Всего удаленка="
ws.cell(row = k+1, column=11).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
ws.cell(row = k+1, column=11).font = Font(name='Times New Roman', size=10, bold=True)
ws.cell(row = k+1, column=12).value = "=SUM(L6:L"+str(k-1)+")"
ws.cell(row = k+1, column=12).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
ws.cell(row = k+1, column=12).font = Font(name='Times New Roman', size=10, bold=True)
# ws.cell(row = k+3, column=5).value = "ИТОГО"
# ws.cell(row = k+3, column=5).font = Font(name='Times New Roman', size=14, bold=True)
# ws.cell(row = k+3, column=7).value = "факт работающих"
# ws.cell(row = k+3, column=7).font = Font(name='Times New Roman', size=14, bold=True)
col=6
ws.cell(row = k+1, column=col).value = len(self.df)
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=13, bold=True)
# ws.cell(row = k+3, column=8).value = f"=F{k+1}-H{k+1}-J{k+1}-L{k+1}"
# ws.cell(row = k+3, column=8).font = Font(name='Times New Roman', size=14, bold=True)
col+=1
ws.cell(row = k+1, column=col).value = "ВСЕГО отпуск="
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=10, bold=True)
col+=1
ws.cell(row = k+1, column=col).value = "=SUM(H6:H"+str(k-1)+")"
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="00FFFF00", fill_type = "solid")
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=10, bold=True)
val = ["Всего больных=", "=SUM(J6:J"+str(k-1)+")", "Всего удаленка=", "=SUM(L6:L"+str(k-1)+")", "Всего в командировке=", "=SUM(N6:N"+str(k-1)+")"]
for x in val:
col+=1
self.resultpos(ws, x, k, col)
self.wb.save(file_path)
return file_path
@@ -177,57 +154,16 @@ class roundExcel():
PIXELS_PER_CHAR = 7
return (width) / PIXELS_PER_CHAR
def resultpos(self, ws, value, k, col):
# Строка 88 подведение итогов
ws.cell(row = k+1, column=col).value = value
ws.cell(row = k+1, column=col).fill = PatternFill(fgColor="8EA9DB", fill_type = "solid")
ws.cell(row = k+1, column=col).font = Font(name='Times New Roman', size=10, bold=True)
def excelvacation(self):
print('helooooooooooooooooooooooooooooooooooooo')
# def excroundread(self):
# file = request.data['dailyfiles']
# ed = pd.read_excel(file)
# df = pd.DataFrame(ed)
# datas = df.columns[8].split(" ")[1]
# df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
# df=df.iloc[6:]
# df= df[df.b.notna()]
# df= df[df.a.notna()]
# df['b']=df['b'].str[-3:]
# df=df[['b', 'f', 'h', 'j','l']]
# df['b'] = df['b'].astype(int)
# types = ['f', 'h', 'j','l']
# for n in types:
# df[n] = df[n].fillna(0)
# df[n] = df[n].astype(int)
# df3 = pd.merge(df, dfuser, left_on= 'b', right_on="id")
# df3=df3[['login', 'f', 'h', 'j','l']]
# for ind in df3.index:
# keys = ''
# if df3['h'][ind] == 1:
# keys = 4 # В отпуске
# elif df3['j'][ind] == 1:
# keys = 5 # Болен
# elif df3['l'][ind] == 1:
# keys = 2 # Удаленка
# elif df3['f'][ind] == 1:
# keys = 1 # На работе
# else:
# keys = 6
# base=BasePosition.objects.get(pk=keys)
# DailyRoundUp.objects.update_or_create(todaysDate=datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'),
# user=df3['login'][ind], defaults={'position':base})
# pos = DailyRoundUp.objects.values('position__name', 'position').filter(position=6,todaysDate=date.today()).annotate(Count('user'))
# mess = "Файл загружен"
class loadExcel():
def __init__(self, us, files):
@@ -241,22 +177,22 @@ class loadExcel():
df = pd.DataFrame(ed)
datas = df.columns[8].split(" ")[1]
df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"]
df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"]
df=df.iloc[6:]
df= df[df.b.notna()]
df= df[df.a.notna()]
df['b']=df['b'].str[-3:]
df=df[['b', 'f', 'h', 'j','l']]
df=df[['b', 'f', 'h', 'j','l', 'n']]
df['b'] = df['b'].astype(int)
types = ['f', 'h', 'j','l']
types = ['f', 'h', 'j','l', 'n']
for n in types:
df[n] = df[n].fillna(0)
df[n] = df[n].astype(int)
df3 = pd.merge(df, self.dfuser, left_on= 'b', right_on="id")
df3=df3[['login', 'f', 'h', 'j','l']]
df3=df3[['login', 'f', 'h', 'j','l','n']]
for ind in df3.index:
@@ -265,10 +201,12 @@ class loadExcel():
keys = 4 # В отпуске
elif df3['j'][ind] == 1:
keys = 5 # Болен
elif df3['l'][ind] == 1:
keys = 2 # Удаленка
elif df3['f'][ind] == 1:
keys = 1 # На работе
elif df3['l'][ind] == 1:
keys = 2 # Удаленка
elif df3['n'][ind] == 1:
keys = 3 # Командировка
else:
keys = 6
base=BasePosition.objects.get(pk=keys)
+4 -5
View File
@@ -63,17 +63,16 @@ class DailyRoundUpAPIView(APIView):
def post(self, request):
print('----------ssssssssssssssssssssssssssssss-------------------------')
user = DictEmployee.objects.filter(deleted=0).values('login', 'id', 'fio')
print(user, '----------ddsfsdfds-------------------------')
re = loadExcel(user, request.data['dailyfiles'])
pos=''
mess = 'Файл не найден'
try:
getattr(re, request.GET.get("excel"))()
mess = 'Файл загружен'
except Exception as e:
print(e, '-----------------------------')
mess = 'Файл не найден'
pass
Binary file not shown.