Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shift modal fix #4196

Merged
merged 6 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cash_registers/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytz

from cash_registers.models import CashRegister, Shift
import cash_registers.req as cash_req
from laboratory.settings import TIME_ZONE


def get_cash_registers():
Expand Down Expand Up @@ -41,14 +44,15 @@ def close_shift(cash_register_id: int, doctor_profile_id: int):

def get_shift_data(doctor_profile_id: int):
"""Проверка статуса смены: открывается, открыта, закрывается, закрыта"""
data = {"shiftId": None, "cashRegisterId": None, "status": "Закрыта"}
data = {"shiftId": None, "cashRegisterId": None, "cashRegisterTitle": "", "open_at": None, "status": "Закрыта"}
result = {"ok": True, "message": "", "data": data}
shift: Shift = Shift.objects.filter(operator_id=doctor_profile_id, close_status=False).select_related('cash_register').last()
if shift:
shift_status = shift.get_shift_status()
current_status = shift_status["status"]
uuid_data = shift_status["uuid"]
result["data"] = {"shiftId": shift.pk, "cashRegisterId": shift.cash_register_id, "status": current_status}
open_at = shift.open_at.astimezone(pytz.timezone(TIME_ZONE)).strftime('%d.%m.%Y %H:%M')
result["data"] = {"shiftId": shift.pk, "cashRegisterId": shift.cash_register_id, "cashRegisterTitle": shift.cash_register.title, "open_at": open_at, "status": current_status}

if uuid_data:
cash_register_data = CashRegister.get_meta_data(shift.cash_register_id)
Expand All @@ -59,6 +63,8 @@ def get_shift_data(doctor_profile_id: int):
job_status = job_result["data"]["results"][0]
if job_status["status"] == "ready":
result["data"]["status"] = Shift.change_status(current_status, job_status, shift)
open_at = shift.open_at.astimezone(pytz.timezone(TIME_ZONE)).strftime('%d.%m.%Y %H:%M')
result["data"]["open_at"] = open_at
elif job_status["status"] == "error":
result = {"ok": False, "message": "Задача заблокирована на кассе"}
else:
Expand Down
116 changes: 106 additions & 10 deletions l2-frontend/src/ui-cards/ShiftModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<div slot="body">
<div class="body">
<div
v-if="!shiftIsOpen"
class="flex"
>
<div class="input-group">
Expand All @@ -46,22 +47,76 @@
/>
</div>
<button
v-if="shiftIsOpen"
class="btn btn-blue-nb nbr width-action"
:disabled="!selectedCashRegister || loading || statusShift === 'Смена закрывается'"
@click="closeShift"
>
Закрыть
</button>
<button
v-else
class="btn btn-blue-nb nbr width-action"
:disabled="!selectedCashRegister || loading || statusShift === 'Смена открывается'"
@click="openShift"
>
Открыть
</button>
</div>
<div>
<table class="table">
<colgroup>
<col style="width: 50px">
<col style="width: 50px">
<col>
<col style="width: 100px">
<col style="width: 100px">
<col style="width: 100px">
</colgroup>
<thead>
<tr>
<th class="text-center">
<strong>Смена №</strong>
</th>
<th class="text-center">
<strong>Касса №</strong>
</th>
<th class="text-center">
<strong>Название кассы</strong>
</th>
<th class="text-center">
<strong>Открыта</strong>
</th>
<th class="text-center">
<strong>Статус</strong>
</th>
<th />
</tr>
</thead>
<tr>
<td class="text-center">
{{ currentShiftData.shiftId }}
</td>
<td class="text-center">
{{ currentShiftData.cashRegisterId }}
</td>
<VueTippyTd
:text="currentShiftData.cashRegisterTitle"
class="cash-register-title"
/>
<td class="text-center">
{{ currentShiftData.open_at }}
</td>
<td class="text-center">
{{ currentShiftData.status }}
</td>
<td>
<div class="button">
<button
v-tippy
class="btn btn-blue-nb nbr close-button"
title="Закрыть смену"
:disabled="!shiftIsOpen || statusShift === 'Смена закрывается'"
@click="closeShift"
>
<i class="fa fa-times" />
</button>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div slot="footer">
Expand All @@ -70,7 +125,6 @@
<button
class="btn btn-primary-nb btn-blue-nb"
type="button"
:disabled="loading"
@click="closeModal"
>
Закрыть
Expand All @@ -95,6 +149,15 @@ import Modal from '@/ui-cards/Modal.vue';
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
import { useStore } from '@/store';
import api from '@/api';
import VueTippyTd from '@/construct/VueTippyTd.vue';

interface shiftData {
shiftId: number,
cashRegisterId: number,
cashRegisterTitle: string,
open_at: string,
status: string
}

const store = useStore();
const root = getCurrentInstance().proxy.$root;
Expand All @@ -112,6 +175,13 @@ const cashRegister = computed(() => store.getters.cashRegisterShift);
const shiftIsOpen = computed(() => !!cashRegister.value?.cashRegisterId);
const selectedCashRegister = ref(null);
const cashRegisters = ref([]);
const currentShiftData = ref<shiftData>({
shiftId: null,
cashRegisterId: null,
cashRegisterTitle: '',
open_at: '',
status: '',
});
const statusShift = ref('');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand All @@ -127,6 +197,7 @@ const getCashRegisters = async () => {
const getShiftData = async () => {
const { ok, message, data } = await api('cash-register/get-shift-data');
if (ok) {
currentShiftData.value = data;
statusShift.value = data.status;
if (!shiftIsOpen.value && data.status === 'Открывается') {
titleLocal.value = `Смена ${data.status.toLowerCase()}`;
Expand Down Expand Up @@ -218,4 +289,29 @@ const closeShift = async () => {
border: 1px solid #AAB2BD !important;
border-radius: 0;
}

.table {
margin-bottom: 0;
table-layout: fixed;
}
.button {
width: 100%;
display: flex;
flex-wrap: nowrap;
flex-direction: row;
justify-content: stretch;
}
.btn {
align-self: stretch;
flex: 1;
padding: 7px 0;
}
.cash-register-title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.close-button {
padding: 9px 0;
}
</style>
Loading