diff --git a/db.sqlite3 b/db.sqlite3 index 386f1caab..e0b7ba959 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/front/src/views/HomePage.vue b/front/src/views/HomePage.vue index 9b228f731..7b845b999 100644 --- a/front/src/views/HomePage.vue +++ b/front/src/views/HomePage.vue @@ -52,7 +52,10 @@ + {{t_daily}} kk + + - + {{x.status}} @@ -153,7 +156,7 @@ import { axiosApiInstance } from '@/utils/axios-api' import CalendarFull from '@/components/UI/Calendar-full.vue' import NewsListHome from '@/components/news-list-home.vue' - + import {getfromserver} from '@/utils/universal_functions' export default { components: { @@ -166,12 +169,14 @@ setup(){ const t_baseCriteria = ref([]) + const t_daily = ref('') onMounted(() => { - proba() + proba(), + dailyfun() }) const appStore = useAppStore() @@ -204,7 +209,19 @@ .then(data => { t_baseCriteria.value = data.data.results }) + + } + + function dailyfun(){ + // getfromserver(`api/general_vacation/dailyload/`, t_daily.value) + axiosApiInstance.get('api/general_vacation/dailyload/') + .then(data => { + console.log(data.data); + t_daily.value = data.data + }) + } + return { accountStore, stat, @@ -212,6 +229,7 @@ onlines, appStore, proba, + t_daily } } } diff --git a/general_vacation/models.py b/general_vacation/models.py index 92e7a9502..09012964b 100644 --- a/general_vacation/models.py +++ b/general_vacation/models.py @@ -22,7 +22,7 @@ class DailyRoundUp(models.Model): verbose_name_plural = "Ежедневный обход" def __str__(self): - return str(self.name) + return str(self.position) class GeneralVacation(models.Model): CHOICES = ( diff --git a/general_vacation/serializers.py b/general_vacation/serializers.py index 9207d8fa9..374f14287 100644 --- a/general_vacation/serializers.py +++ b/general_vacation/serializers.py @@ -11,4 +11,11 @@ class PlanCalendarSerializer(serializers.ModelSerializer): class Meta: model = PlanCalendar - fields ='__all__' \ No newline at end of file + fields ='__all__' + +class DailyRoundUpSerializer(serializers.ModelSerializer): + + class Meta: + model = DailyRoundUp + fields ='__all__' + \ No newline at end of file diff --git a/general_vacation/urls.py b/general_vacation/urls.py index 25473cf6b..64537d7d6 100644 --- a/general_vacation/urls.py +++ b/general_vacation/urls.py @@ -5,4 +5,5 @@ from .views import * urlpatterns = [ path('generalvacation/', GeneralVacationAPIView.as_view(), name='generalvacation'), path('dailyroundup/', DailyRoundUpAPIView.as_view(), name='dailyroundup'), + path('dailyload/', DailyloadAPIView.as_view(), name='dailyload'), ] \ No newline at end of file diff --git a/general_vacation/views.py b/general_vacation/views.py index 4a2a13aef..1b8e4179a 100644 --- a/general_vacation/views.py +++ b/general_vacation/views.py @@ -1,4 +1,4 @@ -import datetime +from datetime import datetime import os from openpyxl import load_workbook import openpyxl @@ -196,30 +196,15 @@ class DailyRoundUpAPIView(APIView): 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) - # print(ws.write(k+3, col, 'hhh'), '-------------------1') wb.save(file_path) - # urllib.request.urlretrieve(file_path, 'Пупка.xlsx') - # file_path = 'media/DailyRoundUp.xlsx' return Response(file_path) - # with ExcelWriter(file_path, mode="a" if os.path.exists(file_path) else "w" , if_sheet_exists='replace') as writer: - # # - # for i in df['department'].unique(): - # for i in df['department'].unique(): - # k = pd.DataFrame(df[(df.department==i)][['tabel', 'familyname', 'name', 'parentname']]) - # # k.to_excel(writer,header=None,index=None) - # print(i) - # print(k) - # return Response('') - # - # - # df.to_excel(table) def post(self, request): @@ -236,7 +221,7 @@ class DailyRoundUpAPIView(APIView): # DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'), defaults={'user':self.request.user, 'position':base}) df.columns = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"] - df=df.iloc[6:, ] + df=df.iloc[6:] df= df[df.b.notna()] df= df[df.a.notna()] df['b']=df['b'].str[-3:] @@ -253,7 +238,6 @@ class DailyRoundUpAPIView(APIView): df3=df3[['login', 'f', 'h', 'j','l']] - # base=BasePosition.objects.get(pk=keys) for ind in df3.index: keys = '' @@ -266,11 +250,30 @@ class DailyRoundUpAPIView(APIView): else: keys = 6 base=BasePosition.objects.get(pk=keys) - DailyRoundUp.objects.update_or_create(todaysDate=datetime.datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'), + DailyRoundUp.objects.update_or_create(todaysDate=datetime.strptime(datas, '%d.%m.%Y').strftime('%Y-%m-%d'), user=df3['login'][ind], defaults={'position':base}) - - print(base) + + + + # serializer_for_daily = DailyRoundUpSerializer( + # instance=daily, # Передаём набор записей + # many=True # Указываем, что на вход подаётся именно набор записей + # ) - return Response('') + return Response("") + + +class DailyloadAPIView(APIView): + def get(self, request): + daily = DailyRoundUp.objects.filter(todaysDate=datetime.now()) + print(daily, '-----------------------------') + + # + # serializer_for_daily = DailyRoundUpSerializer( + # instance=daily, # Передаём набор записей + # many=True # Указываем, что на вход подаётся именно набор записей + # ) + return Response('kkkk') + # return Response({"Обход":serializer_for_daily}) \ No newline at end of file diff --git a/media/DailyRoundUp.xlsx b/media/DailyRoundUp.xlsx index 849c816cc..4a78b5750 100644 Binary files a/media/DailyRoundUp.xlsx and b/media/DailyRoundUp.xlsx differ