админка
This commit is contained in:
1 parent
b8b0487aaf
commit
cc9dc09f61
5 files changed
+62
-56
No files matched your search
Binary file not shown.
@@ -31,7 +31,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
icon="mdi-download"
|
icon="mdi-download"
|
||||||
color="blue-grey-darken-2"
|
color="blue-grey-darken-2"
|
||||||
@click="onPickFile"
|
@click="onPickFile('round')"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
icon="mdi-download"
|
icon="mdi-download"
|
||||||
color="blue-grey-darken-2"
|
color="blue-grey-darken-2"
|
||||||
@click="onPickFile"
|
@click="onPickFile('vacation')"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
@@ -180,7 +180,8 @@ export default {
|
|||||||
|
|
||||||
const sdata = new FormData()
|
const sdata = new FormData()
|
||||||
sdata.append('dailyfiles', dailyfiles.value[0])
|
sdata.append('dailyfiles', dailyfiles.value[0])
|
||||||
axiosApiInstance.post(`api/general_vacation/dailyroundup/`, sdata).then(result => {
|
console.log(sdata, 'sdata');
|
||||||
|
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
||||||
info.value = result.data
|
info.value = result.data
|
||||||
console.log(result.data, '----------------')
|
console.log(result.data, '----------------')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,11 +39,7 @@ class GeneralVacationAPIView(APIView):
|
|||||||
return Response({"Отпуск": serializer_for_basecrit.data, "План-график": serializer_for_plan.data})
|
return Response({"Отпуск": serializer_for_basecrit.data, "План-график": serializer_for_plan.data})
|
||||||
|
|
||||||
class DailyRoundUpAPIView(APIView):
|
class DailyRoundUpAPIView(APIView):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
user = DictEmployee.objects.using('user_directory').filter(deleted=0).values('login', 'department', 'familyname', 'name', 'parentname')
|
user = DictEmployee.objects.using('user_directory').filter(deleted=0).values('login', 'department', 'familyname', 'name', 'parentname')
|
||||||
re = roundExcel(user)
|
re = roundExcel(user)
|
||||||
@@ -65,64 +61,62 @@ class DailyRoundUpAPIView(APIView):
|
|||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
user = DictEmployee.objects.using('user_directory').filter(deleted=0).values('login', 'id')
|
user = DictEmployee.objects.using('user_directory').filter(deleted=0).values('login', 'id')
|
||||||
dfuser = pd.DataFrame.from_records(user)
|
dfuser = pd.DataFrame.from_records(user)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if request.GET.get("excel") == 'round':
|
||||||
file = request.data['dailyfiles']
|
file = request.data['dailyfiles']
|
||||||
ed = pd.read_excel(file)
|
ed = pd.read_excel(file)
|
||||||
df = pd.DataFrame(ed)
|
df = pd.DataFrame(ed)
|
||||||
|
|
||||||
datas = df.columns[8].split(" ")[1]
|
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']]
|
||||||
|
|
||||||
|
|
||||||
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)
|
for ind in df3.index:
|
||||||
|
|
||||||
types = ['f', 'h', 'j','l']
|
keys = ''
|
||||||
for n in types:
|
if df3['h'][ind] == 1:
|
||||||
df[n] = df[n].fillna(0)
|
keys = 4 # В отпуске
|
||||||
df[n] = df[n].astype(int)
|
elif df3['j'][ind] == 1:
|
||||||
|
keys = 5 # Болен
|
||||||
df3 = pd.merge(df, dfuser, left_on= 'b', right_on="id")
|
elif df3['l'][ind] == 1:
|
||||||
df3=df3[['login', 'f', 'h', 'j','l']]
|
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 = "Файл загружен"
|
||||||
|
if request.GET.get("excel") == 'vacation':
|
||||||
|
print(request.data['dailyfiles'], 'request.data[dailyfiles]--------------------')
|
||||||
|
|
||||||
for ind in df3.index:
|
|
||||||
print(df3['h'][ind], 'df3-----------------------------------')
|
|
||||||
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 = "Файл загружен"
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e, '1111111111111111111111')
|
|
||||||
pos=''
|
pos=''
|
||||||
mess = 'Файл не найден'
|
mess = 'Файл не найден'
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ from django.db.models import Q
|
|||||||
class MultiDBModelAdmin(admin.ModelAdmin):
|
class MultiDBModelAdmin(admin.ModelAdmin):
|
||||||
# A handy constant for the name of the alternate database.
|
# A handy constant for the name of the alternate database.
|
||||||
using = "user_directory"
|
using = "user_directory"
|
||||||
|
list_display=('fio', 'login', 'birthdate')
|
||||||
|
search_fields = ('login', 'fio',)
|
||||||
|
list_editable=('birthdate',)
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
def save_model(self, request, obj, form, change):
|
||||||
# Tell Django to save objects to the 'other' database.
|
# Tell Django to save objects to the 'other' database.
|
||||||
@@ -31,4 +34,9 @@ class MultiDBModelAdmin(admin.ModelAdmin):
|
|||||||
return super().formfield_for_manytomany(
|
return super().formfield_for_manytomany(
|
||||||
db_field, request, using=self.using, **kwargs
|
db_field, request, using=self.using, **kwargs
|
||||||
)
|
)
|
||||||
admin.site.register(DictEmployee, MultiDBModelAdmin)
|
|
||||||
|
# class DictEmployeeAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(DictEmployee, MultiDBModelAdmin)
|
||||||
@@ -157,6 +157,9 @@ class DictEmployee(models.Model):
|
|||||||
db_table = 'dict_employee'
|
db_table = 'dict_employee'
|
||||||
db_table_comment = '╤яшёюъ ёюЄЁєфэшъют'
|
db_table_comment = '╤яшёюъ ёюЄЁєфэшъют'
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return str(self.fio)
|
||||||
|
|
||||||
|
|
||||||
class DictPosition(models.Model):
|
class DictPosition(models.Model):
|
||||||
name = models.CharField(max_length=1024, db_comment='═ршьхэютрэшх фюыцэюёЄш')
|
name = models.CharField(max_length=1024, db_comment='═ршьхэютрэшх фюыцэюёЄш')
|
||||||
|
|||||||
Reference in new issue
Block a user