v1.0.7, fix bugs and UI improvments
This commit is contained in:
@ -14,12 +14,34 @@ export const COLOR_MODES = [
|
||||
export const FORMATS = ['A4', 'A5'];
|
||||
|
||||
/**
|
||||
* Расчет цены за страницу в зависимости от объема
|
||||
* Возвращает количество физических листов.
|
||||
* Для двусторонней печати: страницы / 2, округлённые вверх.
|
||||
*/
|
||||
export function getPricePerPage(pagesCount) {
|
||||
if (pagesCount >= 1000) return 4;
|
||||
if (pagesCount >= 25) return 9;
|
||||
return 10;
|
||||
export function getSheetsCount(pagesCount, isDuplex = false) {
|
||||
const pages = Math.max(0, Number(pagesCount) || 0);
|
||||
|
||||
if (!isDuplex) {
|
||||
return pages;
|
||||
}
|
||||
|
||||
return Math.ceil(pages / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Расчет цены за лист.
|
||||
* Для двусторонней печати фиксированно 15 ₽/лист.
|
||||
* Для односторонней остаются старые тарифы.
|
||||
*/
|
||||
export function getPricePerPage(pagesOrSheetsCount, sides = 'Односторонняя') {
|
||||
if (sides === 'Двусторонняя') {
|
||||
return 15;
|
||||
}
|
||||
|
||||
const n = Math.max(0, Number(pagesOrSheetsCount) || 0);
|
||||
|
||||
if (n >= 25) return 9;
|
||||
|
||||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -205,5 +205,5 @@
|
||||
|
||||
<div class="version">
|
||||
<span>v{backendVersion}</span>
|
||||
<span>v1.0.5</span>
|
||||
<span>v1.0.7</span>
|
||||
</div>
|
||||
|
||||
@ -16,12 +16,23 @@
|
||||
event.target.value = '';
|
||||
}
|
||||
|
||||
const hasTierSmall = $derived(store.files.some((f) => (f.selectedPages?.size || 0) < 25));
|
||||
const hasTierMedium = $derived(store.files.some((f) => {
|
||||
const hasDuplex = $derived(
|
||||
store.files.some((f) => f.sides === 'Двусторонняя')
|
||||
);
|
||||
|
||||
const hasTierSmall = $derived(
|
||||
store.files.some((f) => {
|
||||
const s = f.selectedPages?.size || 0;
|
||||
return s >= 25 && s < 1000;
|
||||
}));
|
||||
const hasTierLarge = $derived(store.files.some((f) => (f.selectedPages?.size || 0) >= 1000));
|
||||
return f.sides !== 'Двусторонняя' && s > 0 && s < 25;
|
||||
})
|
||||
);
|
||||
|
||||
const hasTierMedium = $derived(
|
||||
store.files.some((f) => {
|
||||
const s = f.selectedPages?.size || 0;
|
||||
return f.sides !== 'Двусторонняя' && s >= 25;
|
||||
})
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if store.job}
|
||||
@ -60,17 +71,17 @@
|
||||
{/if}
|
||||
</main>
|
||||
<PrintUI
|
||||
as="footer"
|
||||
totalPrice={store.totalPrice}
|
||||
filesCount={store.files.length}
|
||||
extraCopies={store.extraCopies}
|
||||
isPrinting={store.isPrinting}
|
||||
onSubmit={store.openPayment}
|
||||
hasTierSmall={hasTierSmall}
|
||||
hasTierMedium={hasTierMedium}
|
||||
hasTierLarge={hasTierLarge}
|
||||
plFiles={plFiles}
|
||||
plCopies={plCopies}
|
||||
as="footer"
|
||||
totalPrice={store.totalPrice}
|
||||
filesCount={store.files.length}
|
||||
extraCopies={store.extraCopies}
|
||||
isPrinting={store.isPrinting}
|
||||
onSubmit={store.openPayment}
|
||||
hasDuplex={hasDuplex}
|
||||
hasTierSmall={hasTierSmall}
|
||||
hasTierMedium={hasTierMedium}
|
||||
plFiles={plFiles}
|
||||
plCopies={plCopies}
|
||||
/>
|
||||
<input
|
||||
type="file"
|
||||
|
||||
@ -4,9 +4,11 @@
|
||||
|
||||
const currentStatus = $derived.by(() => {
|
||||
if (!store.job) return 'idle';
|
||||
const f = store.job.files.find(f => f.status === 'printing');
|
||||
|
||||
const f = store.job.files?.find((x) => x.status === 'printing');
|
||||
if (f) return 'printing';
|
||||
const q = store.job.files.find(f => f.status === 'queued');
|
||||
|
||||
const q = store.job.files?.find((x) => x.status === 'queued');
|
||||
return q ? 'queued' : store.job.phase;
|
||||
});
|
||||
|
||||
@ -36,7 +38,121 @@
|
||||
});
|
||||
|
||||
const canCancel = $derived(
|
||||
store.job?.files.some(f => f.status === 'queued' || f.status === 'printing')
|
||||
store.job?.files?.some((f) => f.status === 'queued' || f.status === 'printing') ?? false
|
||||
);
|
||||
|
||||
const jobPhase = $derived(store.job?.phase);
|
||||
const jobFiles = $derived(store.job?.files ?? []);
|
||||
|
||||
/**
|
||||
* Двусторонняя печать определяется по настройкам файлов,
|
||||
* которые всё ещё лежат в store.files после отправки задания.
|
||||
*/
|
||||
const isDuplex = $derived(
|
||||
store.files.some((f) => f.sides === 'Двусторонняя')
|
||||
);
|
||||
|
||||
/**
|
||||
* Текущие запросы сервера на пользовательские действия.
|
||||
*/
|
||||
const hasClearPhase = $derived(jobPhase === 'awaiting_clear_output');
|
||||
const hasFlip = $derived(
|
||||
jobPhase === 'awaiting_flip' ||
|
||||
jobFiles.some((f) => f.status === 'awaiting_flip')
|
||||
);
|
||||
const hasPickup = $derived(
|
||||
jobPhase === 'awaiting_pickup' ||
|
||||
jobFiles.some((f) => f.status === 'awaiting_pickup')
|
||||
);
|
||||
|
||||
/**
|
||||
* Проверяем, есть ли уже напечатанные или отправленные файлы.
|
||||
* Если нет — значит это первая печать и лоток выдачи принтера пуст.
|
||||
*/
|
||||
const hasPrintedFiles = $derived(
|
||||
store.job?.files?.some(f => ['done', 'sent', 'awaiting_flip', 'awaiting_pickup'].includes(f.status)) ?? false
|
||||
);
|
||||
|
||||
/**
|
||||
* Нам важно запомнить, что первый проход уже был,
|
||||
* иначе при печати второй стороны инструкция очистки может появиться снова.
|
||||
*/
|
||||
let hadFlip = $state(false);
|
||||
let hadPickup = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
if (!store.job) return;
|
||||
|
||||
if (
|
||||
jobPhase === 'awaiting_flip' ||
|
||||
jobFiles.some((f) => f.status === 'awaiting_flip')
|
||||
) {
|
||||
hadFlip = true;
|
||||
}
|
||||
|
||||
if (
|
||||
jobPhase === 'awaiting_pickup' ||
|
||||
jobFiles.some((f) => f.status === 'awaiting_pickup')
|
||||
) {
|
||||
hadPickup = true;
|
||||
}
|
||||
});
|
||||
|
||||
const firstSideFinished = $derived(
|
||||
hadFlip ||
|
||||
hadPickup ||
|
||||
jobPhase === 'finished' ||
|
||||
jobPhase === 'cancelled' ||
|
||||
jobFiles.some((f) => f.status === 'done')
|
||||
);
|
||||
|
||||
/**
|
||||
* Инструкция очистки лотка:
|
||||
* - если сервер явно просит awaiting_clear_output И есть уже напечатанные файлы;
|
||||
* - для двусторонней печати — до первого прохода,
|
||||
* пока ещё не было flip/pickup/done И есть напечатанные файлы.
|
||||
*/
|
||||
const showClearOutput = $derived(
|
||||
store.jobActive &&
|
||||
!firstSideFinished &&
|
||||
(
|
||||
(hasClearPhase && hasPrintedFiles) ||
|
||||
(isDuplex && hasPrintedFiles && ['waiting_start', 'printing', 'awaiting_clear_output'].includes(jobPhase ?? ''))
|
||||
)
|
||||
);
|
||||
|
||||
const showFlip = $derived(
|
||||
store.jobActive &&
|
||||
hasFlip &&
|
||||
jobPhase !== 'finished' &&
|
||||
jobPhase !== 'cancelled'
|
||||
);
|
||||
|
||||
const showPickup = $derived(
|
||||
store.jobActive &&
|
||||
hasPickup &&
|
||||
!showFlip &&
|
||||
jobPhase !== 'finished' &&
|
||||
jobPhase !== 'cancelled'
|
||||
);
|
||||
|
||||
const clearActionAvailable = $derived(
|
||||
showClearOutput &&
|
||||
(jobPhase === 'awaiting_clear_output' || jobPhase === 'waiting_start')
|
||||
);
|
||||
|
||||
const flipActionAvailable = $derived(
|
||||
showFlip && jobPhase === 'awaiting_flip'
|
||||
);
|
||||
|
||||
const pickupActionAvailable = $derived(
|
||||
showPickup && jobPhase === 'awaiting_pickup'
|
||||
);
|
||||
|
||||
const clearButtonLabel = $derived(
|
||||
jobPhase === 'waiting_start'
|
||||
? 'Убрал листы — начать печать'
|
||||
: 'Убрал листы — продолжать'
|
||||
);
|
||||
|
||||
const HOLD_MS = 1500;
|
||||
@ -46,14 +162,23 @@
|
||||
|
||||
function startHold(e) {
|
||||
if (!store.jobActive || !canCancel) return;
|
||||
|
||||
e.preventDefault();
|
||||
e.currentTarget.setPointerCapture?.(e.pointerId);
|
||||
|
||||
t0 = performance.now();
|
||||
|
||||
const step = (now) => {
|
||||
hold = Math.min(1, (now - t0) / HOLD_MS);
|
||||
if (hold >= 1) { raf = 0; hold = 0; store.cancelJob(); return; }
|
||||
if (hold >= 1) {
|
||||
raf = 0;
|
||||
hold = 0;
|
||||
store.cancelJob();
|
||||
return;
|
||||
}
|
||||
raf = requestAnimationFrame(step);
|
||||
};
|
||||
|
||||
raf = requestAnimationFrame(step);
|
||||
}
|
||||
|
||||
@ -76,6 +201,50 @@
|
||||
</header>
|
||||
|
||||
<main class="list">
|
||||
{#if showClearOutput}
|
||||
<section class="instruction-card clear">
|
||||
<p class="instruction-title">
|
||||
Уберите распечатанные листы из выходного лотка
|
||||
</p>
|
||||
<ol class="instruction-list">
|
||||
<li>Уберите распечатанные листы из выходного лотка</li>
|
||||
{#if clearActionAvailable}
|
||||
<li>Нажмите кнопку ниже для продолжения</li>
|
||||
{:else}
|
||||
<li>Дождитесь завершения первого прохода</li>
|
||||
{/if}
|
||||
</ol>
|
||||
</section>
|
||||
{:else if showFlip}
|
||||
<section class="instruction-card flip">
|
||||
<p class="instruction-title">
|
||||
Переложите бумагу
|
||||
</p>
|
||||
<ol class="instruction-list">
|
||||
<li>Не переворачивая, положите листы в слот ручной подачи</li>
|
||||
{#if flipActionAvailable}
|
||||
<li>Нажмите кнопку ниже для печати обратной стороны</li>
|
||||
{:else}
|
||||
<li>Дождитесь завершения текущего этапа</li>
|
||||
{/if}
|
||||
</ol>
|
||||
</section>
|
||||
{:else if showPickup}
|
||||
<section class="instruction-card pickup">
|
||||
<p class="instruction-title">
|
||||
Печать завершается...
|
||||
</p>
|
||||
<ol class="instruction-list">
|
||||
<li>Дождитесь завершения печати</li>
|
||||
{#if pickupActionAvailable}
|
||||
<li>Нажмите кнопку ниже для подтверждения</li>
|
||||
{:else}
|
||||
<li>Дождитесь завершения текущего этапа</li>
|
||||
{/if}
|
||||
</ol>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if store.job}
|
||||
{#each store.job.files as f, i (i + '-' + f.name)}
|
||||
{@const b = badge(f.name)}
|
||||
@ -93,23 +262,6 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{#if f.status === 'awaiting_pickup'}
|
||||
<ol class="pickup-hint">
|
||||
<li>Дождитесь завершения печати</li>
|
||||
<li>Нажмите кнопку ниже для подтверждения</li>
|
||||
</ol>
|
||||
{:else if f.status === 'awaiting_clear_output'}
|
||||
<ol class="pickup-hint clear-hint">
|
||||
<li>Уберите распечатанные листы из выходного лотка</li>
|
||||
<li>Нажмите кнопку ниже для продолжения</li>
|
||||
</ol>
|
||||
{:else if f.status === 'awaiting_flip'}
|
||||
<ol class="pickup-hint flip-hint">
|
||||
<li>Не переворачивая, положите листы в слот ручной подачи</li>
|
||||
<li>Нажмите кнопку ниже для печати обратной стороны</li>
|
||||
</ol>
|
||||
{/if}
|
||||
|
||||
{#if f.error}
|
||||
<p class="file-error">{f.error}</p>
|
||||
{/if}
|
||||
@ -119,32 +271,34 @@
|
||||
</main>
|
||||
|
||||
<footer class="actions">
|
||||
<label class="auto-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={store.autoContinue}
|
||||
onchange={(e) => store.setAutoContinue(e.target.checked)}
|
||||
/>
|
||||
<span>Автоматически продолжать печать</span>
|
||||
</label>
|
||||
{#if canCancel}
|
||||
<label class="auto-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={store.autoContinue}
|
||||
onchange={(e) => store.setAutoContinue(e.target.checked)}
|
||||
/>
|
||||
<span>Автоматически продолжать печать</span>
|
||||
</label>
|
||||
|
||||
{#if store.autoContinue}
|
||||
<p class="auto-warning">⚠️ Отправленные файлы нельзя будет отменить</p>
|
||||
{#if store.autoContinue}
|
||||
<p class="auto-warning">⚠️ Отправленные файлы нельзя будет отменить</p>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if store.jobActive}
|
||||
{#if store.job?.phase === 'awaiting_pickup'}
|
||||
{#if pickupActionAvailable}
|
||||
<button class="next-btn" onclick={store.advanceJob}>
|
||||
Печать закончена — далее
|
||||
</button>
|
||||
{:else if store.job?.phase === 'awaiting_clear_output'}
|
||||
<button class="next-btn next-btn-clear" onclick={store.advanceJob}>
|
||||
Убрал листы — продолжать
|
||||
</button>
|
||||
{:else if store.job?.phase === 'awaiting_flip'}
|
||||
{:else if flipActionAvailable}
|
||||
<button class="next-btn next-btn-flip" onclick={store.advanceJob}>
|
||||
Переложил — печатать обратную сторону
|
||||
</button>
|
||||
{:else if clearActionAvailable}
|
||||
<button class="next-btn next-btn-clear" onclick={store.advanceJob}>
|
||||
{clearButtonLabel}
|
||||
</button>
|
||||
{:else}
|
||||
<button class="next-btn next-btn-disabled" disabled>
|
||||
{currentStatus === 'printing' ? 'Отправка...' : 'Ожидание...'}
|
||||
@ -184,9 +338,6 @@
|
||||
.st-error { color: #ef4444; }
|
||||
.st-cancelled { color: #6b7280; }
|
||||
|
||||
.clear-hint { color: #f59e0b; }
|
||||
.flip-hint { color: #f59e0b; }
|
||||
|
||||
.auto-warning {
|
||||
margin: -4px 0 8px;
|
||||
text-align: center;
|
||||
@ -196,69 +347,198 @@
|
||||
}
|
||||
|
||||
.page-container {
|
||||
width: 100%; min-height: 100dvh;
|
||||
display: flex; flex-direction: column;
|
||||
width: 100%;
|
||||
min-height: 100dvh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: radial-gradient(120% 60% at 50% -10%, rgba(99,102,241,0.18) 0%, transparent 60%);
|
||||
font-family: system-ui, -apple-system, sans-serif;
|
||||
color: #f5f7fa;
|
||||
}
|
||||
|
||||
.header { padding: 24px 20px 8px; display: flex; align-items: center; position: relative; }
|
||||
.back-btn {
|
||||
background: none; border: none; color: #6366f1;
|
||||
font-size: 15px; font-weight: 600; cursor: pointer;
|
||||
padding: 8px 4px; margin-right: auto; min-height: 44px;
|
||||
.header {
|
||||
padding: 24px 20px 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
.back-btn:disabled { opacity: 0.3; cursor: not-allowed; }
|
||||
|
||||
.back-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #6366f1;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
padding: 8px 4px;
|
||||
margin-right: auto;
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.back-btn:disabled {
|
||||
opacity: 0.3;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
margin: 0; font-size: 28px; font-weight: 700;
|
||||
position: absolute; left: 50%; transform: translateX(-50%);
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.list { flex: 1; padding: 24px 20px 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
|
||||
.list {
|
||||
flex: 1;
|
||||
padding: 24px 20px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
overflow-y: auto;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.instruction-card {
|
||||
border-radius: 16px;
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
border: 1px solid rgba(245, 158, 11, 0.35);
|
||||
background: rgba(245, 158, 11, 0.08);
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.instruction-card.pickup {
|
||||
border-color: rgba(165, 180, 252, 0.35);
|
||||
background: rgba(99, 102, 241, 0.08);
|
||||
}
|
||||
|
||||
.instruction-title {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #f59e0b;
|
||||
}
|
||||
|
||||
.instruction-card.pickup .instruction-title {
|
||||
color: #a5b4fc;
|
||||
}
|
||||
|
||||
.instruction-list {
|
||||
margin: 0;
|
||||
padding-left: 22px;
|
||||
color: #f59e0b;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
font-weight: 600;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.instruction-card.pickup .instruction-list {
|
||||
color: #a5b4fc;
|
||||
}
|
||||
|
||||
.file-card {
|
||||
border-radius: 16px; background: rgba(255,255,255,0.04);
|
||||
border-radius: 16px;
|
||||
background: rgba(255,255,255,0.04);
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
padding: 14px; display: flex; flex-direction: column; gap: 8px;
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
transition: border-color 0.2s ease, background 0.2s ease;
|
||||
text-align: left;
|
||||
}
|
||||
.file-card.current { border-color: rgba(99,102,241,0.45); background: rgba(99,102,241,0.07); }
|
||||
|
||||
.file-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
||||
.file-name {
|
||||
flex: 1; min-width: 0; font-size: 15px; font-weight: 500;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
.file-card.current {
|
||||
border-color: rgba(99,102,241,0.45);
|
||||
background: rgba(99,102,241,0.07);
|
||||
}
|
||||
|
||||
.file-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
min-width: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.file-status {
|
||||
flex-shrink: 0;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.file-status { flex-shrink: 0; font-size: 14px; font-weight: 700; }
|
||||
|
||||
.type-badge {
|
||||
flex-shrink: 0; padding: 3px 7px; border-radius: 6px;
|
||||
background: rgba(99,102,241,0.2); border: 1px solid rgba(99,102,241,0.35);
|
||||
color: #a5b4fc; font-size: 10px; font-weight: 700;
|
||||
letter-spacing: 0.04em; line-height: 1.2; user-select: none;
|
||||
flex-shrink: 0;
|
||||
padding: 3px 7px;
|
||||
border-radius: 6px;
|
||||
background: rgba(99,102,241,0.2);
|
||||
border: 1px solid rgba(99,102,241,0.35);
|
||||
color: #a5b4fc;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
line-height: 1.2;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.pickup-hint {
|
||||
margin: 0; padding-left: 22px;
|
||||
color: #eab308; font-size: 14px; line-height: 1.6; font-weight: 600;
|
||||
.file-error {
|
||||
margin: 0;
|
||||
color: #fca5a5;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.file-error { margin: 0; color: #fca5a5; font-size: 12px; line-height: 1.4; }
|
||||
|
||||
.actions { padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 12px; }
|
||||
.actions {
|
||||
padding: 16px 20px 32px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.auto-row {
|
||||
display: flex; align-items: center; justify-content: center; gap: 10px;
|
||||
color: #a9b0c0; font-size: 14px; font-weight: 600;
|
||||
user-select: none; cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
color: #a9b0c0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.auto-row input {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
accent-color: #6366f1;
|
||||
cursor: pointer;
|
||||
}
|
||||
.auto-row input { width: 18px; height: 18px; accent-color: #6366f1; cursor: pointer; }
|
||||
|
||||
.next-btn {
|
||||
width: 100%; padding: 16px 24px; border-radius: 16px;
|
||||
font-size: 16px; font-weight: 700; cursor: pointer; border: none; color: #fff;
|
||||
width: 100%;
|
||||
padding: 16px 24px;
|
||||
border-radius: 16px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #5b8cff 0%, #38c6ff 100%);
|
||||
box-shadow: 0 8px 24px -6px rgba(72,150,255,0.4);
|
||||
}
|
||||
@ -274,31 +554,68 @@
|
||||
}
|
||||
|
||||
.next-btn-disabled {
|
||||
opacity: 0.5; cursor: wait; pointer-events: none;
|
||||
opacity: 0.5;
|
||||
cursor: wait;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(135deg, #475569 0%, #64748b 100%);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
position: relative; overflow: hidden; width: 100%; padding: 16px 24px;
|
||||
border-radius: 16px; border: 1px solid rgba(239,68,68,0.35);
|
||||
background: rgba(239,68,68,0.08); color: #fca5a5;
|
||||
font-size: 16px; font-weight: 700; cursor: pointer;
|
||||
touch-action: none; user-select: none;
|
||||
-webkit-user-select: none; -webkit-touch-callout: none;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
padding: 16px 24px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid rgba(239,68,68,0.35);
|
||||
background: rgba(239,68,68,0.08);
|
||||
color: #fca5a5;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
touch-action: none;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.cancel-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
|
||||
.cancel-fill {
|
||||
position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
|
||||
background: rgba(239,68,68,0.35); pointer-events: none;
|
||||
|
||||
.cancel-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cancel-fill {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 0%;
|
||||
background: rgba(239,68,68,0.35);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cancel-label {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.hold-hint {
|
||||
margin: -4px 0 0;
|
||||
text-align: center;
|
||||
color: rgba(139,147,161,0.6);
|
||||
font-size: 11px;
|
||||
}
|
||||
.cancel-label { position: relative; }
|
||||
.hold-hint { margin: -4px 0 0; text-align: center; color: rgba(139,147,161,0.6); font-size: 11px; }
|
||||
|
||||
.home-btn {
|
||||
width: 100%; padding: 16px 24px; border-radius: 16px;
|
||||
font-size: 16px; font-weight: 700; cursor: pointer; border: none; color: #fff;
|
||||
width: 100%;
|
||||
padding: 16px 24px;
|
||||
border-radius: 16px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
|
||||
box-shadow: 0 8px 24px -6px rgba(34,197,94,0.4);
|
||||
}
|
||||
|
||||
@ -36,6 +36,17 @@
|
||||
function isOffice(file) {
|
||||
return file?.fileType === 'office';
|
||||
}
|
||||
|
||||
/** Можно ли разрешить двустороннюю печать для файла */
|
||||
function canDuplex(file) {
|
||||
if (!file) return false;
|
||||
|
||||
// Для office число страниц неизвестно.
|
||||
// Если нужно блокировать и office, убери эту строку.
|
||||
if (file.fileType === 'office') return true;
|
||||
|
||||
return (file.selectedPages?.size ?? 0) > 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if as === 'button'}
|
||||
@ -149,12 +160,14 @@
|
||||
<GearOption value={formatText(file)} open={formatOpen} onclick={() => (formatOpen = !formatOpen)} />
|
||||
</div>
|
||||
<div class="duo-row">
|
||||
<ToggleOption
|
||||
label="Печать"
|
||||
options={SIDES_OPTIONS}
|
||||
value={file.sides ?? 'Односторонняя'}
|
||||
onchange={(v) => props.onUpdate?.(file.id, { sides: v })}
|
||||
/>
|
||||
<ToggleOption
|
||||
label="Печать"
|
||||
options={SIDES_OPTIONS}
|
||||
value={file.sides ?? 'Односторонняя'}
|
||||
disabled={!canDuplex(file)}
|
||||
hint={canDuplex(file) ? '' : 'Двусторонняя доступна при выборе 2 и более страниц'}
|
||||
onchange={(v) => props.onUpdate?.(file.id, { sides: v })}
|
||||
/>
|
||||
<ToggleOption
|
||||
label="Цветность"
|
||||
options={COLOR_LABELS}
|
||||
@ -221,11 +234,23 @@
|
||||
{#if props.extraCopies > 0}, {props.extraCopies} {props.plCopies(props.extraCopies)}{/if}
|
||||
</p>
|
||||
{/if}
|
||||
<div class="pricing-info">
|
||||
<span class="price-tier" class:active={props.hasTierSmall}>10р/л от 1</span>
|
||||
<span class="price-tier" class:active={props.hasTierMedium}>9р/л от 25</span>
|
||||
<span class="price-tier" class:active={props.hasTierLarge}>4р/л от 1000</span>
|
||||
</div>
|
||||
<div class="pricing-info">
|
||||
<div class="pricing-row pricing-row-duplex">
|
||||
<span class="price-tier" class:active={!!props.hasDuplex}>
|
||||
Двусторонняя 15р/л
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="pricing-row">
|
||||
<span class="price-tier" class:active={props.hasTierSmall}>
|
||||
10р/л от 1
|
||||
</span>
|
||||
|
||||
<span class="price-tier" class:active={props.hasTierMedium}>
|
||||
9р/л от 25
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="price-summary">
|
||||
<span class="summary-itogo">Итого</span>
|
||||
<span class="summary-price">{props.totalPrice}₽</span>
|
||||
@ -272,7 +297,26 @@
|
||||
.empty-hint { color: #8b93a1; font-size: 15px; margin: 0; }
|
||||
.actions { padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 12px; }
|
||||
.file-count { color: #8b93a1; font-size: 13px; margin: 0; text-align: center; line-height: 1.4; }
|
||||
.pricing-info { display: flex; justify-content: center; gap: 12px; font-size: 10px; line-height: 1.2; color: rgba(255,255,255,0.25); margin-bottom: 4px; user-select: none; flex-wrap: wrap; }
|
||||
.pricing-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 4px;
|
||||
user-select: none;
|
||||
}
|
||||
.pricing-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
font-size: 10px;
|
||||
line-height: 1.2;
|
||||
color: rgba(255, 255, 255, 0.25);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.pricing-row-duplex {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.price-tier { transition: color 0.2s ease; }
|
||||
.price-tier.active { color: rgba(255,255,255,0.6); }
|
||||
.price-summary { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// lib/pages/print/store.svelte.js
|
||||
import { onDestroy, tick } from 'svelte';
|
||||
import { getPricePerPage } from '$lib/common/utils/pricing.util.js';
|
||||
import { getPricePerPage, getSheetsCount } from '$lib/common/utils/pricing.util.js';
|
||||
import { detectFileType, pagesLabel as _pagesLabel } from '$lib/common/utils/file.util.js';
|
||||
import { loadPdfDocument, renderPageToImage } from '$lib/common/services/pdf.service.js';
|
||||
|
||||
@ -34,20 +34,44 @@ export function createPrintStore() {
|
||||
const jobActive = $derived(!!job && job.phase !== 'finished' && job.phase !== 'cancelled');
|
||||
let uid = 0;
|
||||
|
||||
const totalPrice = $derived(
|
||||
files.reduce((sum, f) => {
|
||||
const pages = f.selectedPages?.size || 0;
|
||||
return sum + pages * f.copies * getPricePerPage(pages);
|
||||
}, 0)
|
||||
);
|
||||
const totalPrice = $derived(
|
||||
files.reduce((sum, f) => {
|
||||
const pages = f.selectedPages?.size || 0;
|
||||
const isDuplex = f.sides === 'Двусторонняя';
|
||||
|
||||
const sheets = getSheetsCount(pages, isDuplex);
|
||||
|
||||
const pricePerSheet = getPricePerPage(
|
||||
isDuplex ? sheets : pages,
|
||||
f.sides ?? 'Односторонняя'
|
||||
);
|
||||
|
||||
return sum + sheets * f.copies * pricePerSheet;
|
||||
}, 0)
|
||||
);
|
||||
const extraCopies = $derived(files.reduce((sum, f) => sum + (f.copies - 1), 0));
|
||||
|
||||
function updateFile(id, changes) {
|
||||
files = files.map((f) => (f.id === id ? { ...f, ...changes } : f));
|
||||
if (activeFile?.id === id) {
|
||||
activeFile = files.find((f) => f.id === id);
|
||||
}
|
||||
}
|
||||
function updateFile(id, changes) {
|
||||
files = files.map((f) => {
|
||||
if (f.id !== id) return f;
|
||||
|
||||
const next = { ...f, ...changes };
|
||||
|
||||
const blockDuplex =
|
||||
next.fileType !== 'office' &&
|
||||
(next.selectedPages?.size ?? 0) <= 1;
|
||||
|
||||
if (blockDuplex && next.sides === 'Двусторонняя') {
|
||||
next.sides = 'Односторонняя';
|
||||
}
|
||||
|
||||
return next;
|
||||
});
|
||||
|
||||
if (activeFile?.id === id) {
|
||||
activeFile = files.find((f) => f.id === id);
|
||||
}
|
||||
}
|
||||
|
||||
async function ensurePdfLoaded(entry) {
|
||||
if (entry.pdfDoc) return entry.pdfDoc;
|
||||
@ -227,9 +251,17 @@ export function createPrintStore() {
|
||||
alert('⚠️ Некорректный ответ сервера печати.');
|
||||
return;
|
||||
}
|
||||
job = data;
|
||||
showPayment = false;
|
||||
await advanceJob();
|
||||
job = data;
|
||||
showPayment = false;
|
||||
|
||||
const hasDuplex = files.some((f) => f.sides === 'Двусторонняя');
|
||||
const needsManualStart =
|
||||
hasDuplex &&
|
||||
(job.phase === 'waiting_start' || job.phase === 'awaiting_clear_output');
|
||||
|
||||
if (!needsManualStart) {
|
||||
await advanceJob();
|
||||
}
|
||||
} catch {
|
||||
alert('⚠️ Не удалось связаться с сервером печати.');
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user