init
This commit is contained in:
132
frontend/src/components/AiAdvisor.vue
Normal file
132
frontend/src/components/AiAdvisor.vue
Normal file
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="fade">
|
||||
<div v-if="open" class="fixed inset-0 z-50 flex items-start justify-end bg-black/30" @click.self="$emit('close')">
|
||||
<div class="mt-0 h-full w-full max-w-md bg-white shadow-xl sm:mt-0 flex flex-col">
|
||||
<div class="flex items-center justify-between border-b border-gray-200 px-5 py-4">
|
||||
<h3 class="text-base font-semibold text-gray-900">AI-ассистент по материалам</h3>
|
||||
<button @click="$emit('close')" class="rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600">
|
||||
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto p-5">
|
||||
<p class="mb-4 text-sm text-gray-600">
|
||||
Опишите вашу задачу, и AI порекомендует оптимальный материал.
|
||||
</p>
|
||||
|
||||
<textarea
|
||||
v-model="taskDescription"
|
||||
rows="4"
|
||||
class="input-field mb-4"
|
||||
placeholder="Например: Корпус для уличного датчика температуры, диапазон -30..+50, водонепроницаемый"
|
||||
></textarea>
|
||||
|
||||
<button @click="getRecommendation" :disabled="!taskDescription.trim() || loading" class="btn-primary w-full mb-5">
|
||||
<svg v-if="loading" class="mr-2 h-4 w-4 animate-spin" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
|
||||
</svg>
|
||||
{{ loading ? 'Анализирую...' : 'Получить рекомендацию' }}
|
||||
</button>
|
||||
|
||||
<div v-if="error" class="mb-4 rounded-lg bg-red-50 p-3 text-sm text-red-700">{{ error }}</div>
|
||||
|
||||
<div v-if="recommendation">
|
||||
<!-- Main recommendation -->
|
||||
<div class="mb-4 rounded-lg border-2 border-primary-200 bg-primary-50 p-4">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<span class="text-xs font-semibold uppercase tracking-wider text-primary-600">Рекомендация</span>
|
||||
<button @click="selectMaterial(recommendation.recommended_material_id)" class="btn-primary !py-1 !px-3 !text-xs">
|
||||
Выбрать
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-base font-bold text-gray-900 mb-1.5">{{ recommendation.recommended_material_name }}</p>
|
||||
<p class="text-sm text-gray-700 leading-relaxed">{{ recommendation.reasoning }}</p>
|
||||
</div>
|
||||
|
||||
<!-- Alternatives -->
|
||||
<div v-if="recommendation.alternatives?.length" class="space-y-2.5">
|
||||
<p class="text-xs font-semibold uppercase tracking-wider text-gray-500">Альтернативы</p>
|
||||
<div v-for="alt in recommendation.alternatives" :key="alt.material_id" class="flex items-start justify-between rounded-lg border border-gray-200 p-3">
|
||||
<div class="flex-1">
|
||||
<p class="text-sm font-semibold text-gray-900">{{ alt.name }}</p>
|
||||
<p class="text-xs text-gray-500 mt-0.5">{{ alt.why }}</p>
|
||||
</div>
|
||||
<button @click="selectMaterial(alt.material_id)" class="btn-secondary !py-1 !px-2.5 !text-xs ml-3 shrink-0">
|
||||
Выбрать
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Questions -->
|
||||
<div v-if="recommendation.questions?.length" class="mt-4 rounded-lg bg-amber-50 p-3">
|
||||
<p class="text-xs font-semibold text-amber-700 mb-1.5">Уточняющие вопросы:</p>
|
||||
<ul class="list-disc pl-4 text-sm text-amber-700 space-y-1">
|
||||
<li v-for="q in recommendation.questions" :key="q">{{ q }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import api from '../api/client'
|
||||
import { useCalculatorStore } from '../stores/calculator'
|
||||
|
||||
defineProps({ open: Boolean })
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const store = useCalculatorStore()
|
||||
const taskDescription = ref('')
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const recommendation = ref(null)
|
||||
|
||||
async function getRecommendation() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const payload = {
|
||||
task_description: taskDescription.value,
|
||||
budget_preference: 'optimal',
|
||||
}
|
||||
if (store.result?.file_info) {
|
||||
payload.file_info = {
|
||||
volume_cm3: store.result.file_info.volume_cm3,
|
||||
bounding_box_mm: store.result.file_info.bounding_box_mm,
|
||||
}
|
||||
}
|
||||
const { data } = await api.post('/advisor', payload)
|
||||
recommendation.value = data
|
||||
} catch (e) {
|
||||
error.value = e.response?.data?.detail || 'Ошибка получения рекомендации'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function selectMaterial(id) {
|
||||
store.materialId = id
|
||||
store.result = null
|
||||
emit('close')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
125
frontend/src/components/FileUploader.vue
Normal file
125
frontend/src/components/FileUploader.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<h2 class="mb-4 text-lg font-semibold text-gray-900">1. Загрузите 3D-модель</h2>
|
||||
|
||||
<div
|
||||
@dragover.prevent="isDragging = true"
|
||||
@dragleave.prevent="isDragging = false"
|
||||
@drop.prevent="onDrop"
|
||||
:class="[
|
||||
'relative flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-all',
|
||||
isDragging ? 'border-primary-400 bg-primary-50' : 'border-gray-300 hover:border-gray-400',
|
||||
selectedFile ? 'bg-green-50 border-green-300' : '',
|
||||
]"
|
||||
>
|
||||
<template v-if="!selectedFile">
|
||||
<svg class="mb-3 h-10 w-10 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5" />
|
||||
</svg>
|
||||
<p class="mb-1 text-sm font-medium text-gray-700">
|
||||
Перетащите файл сюда или
|
||||
<label class="cursor-pointer text-primary-600 hover:text-primary-700">
|
||||
выберите
|
||||
<input type="file" class="hidden" :accept="acceptTypes" @change="onFileSelect" />
|
||||
</label>
|
||||
</p>
|
||||
<p class="text-xs text-gray-500">STL, 3MF, OBJ — до 50 МБ</p>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex h-10 w-10 items-center justify-center rounded-lg bg-green-100">
|
||||
<svg class="h-5 w-5 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-900">{{ selectedFile.name }}</p>
|
||||
<p class="text-xs text-gray-500">{{ formatSize(selectedFile.size) }} · {{ getExtension(selectedFile.name) }}</p>
|
||||
</div>
|
||||
<button @click.stop="removeFile" class="ml-4 rounded-md p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600">
|
||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Upload progress -->
|
||||
<div v-if="store.loading && store.uploadProgress > 0" class="mt-3">
|
||||
<div class="flex items-center justify-between text-xs text-gray-600 mb-1">
|
||||
<span>Загрузка...</span>
|
||||
<span>{{ store.uploadProgress }}%</span>
|
||||
</div>
|
||||
<div class="h-1.5 w-full rounded-full bg-gray-200">
|
||||
<div class="h-1.5 rounded-full bg-primary-600 transition-all" :style="{ width: store.uploadProgress + '%' }"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p v-if="validationError" class="mt-2 text-sm text-red-600">{{ validationError }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { useCalculatorStore } from '../stores/calculator'
|
||||
|
||||
const store = useCalculatorStore()
|
||||
const isDragging = ref(false)
|
||||
const validationError = ref('')
|
||||
|
||||
const acceptTypes = '.stl,.3mf,.obj'
|
||||
const allowedExtensions = ['stl', '3mf', 'obj']
|
||||
const maxSize = 50 * 1024 * 1024
|
||||
|
||||
const selectedFile = computed(() => store.file)
|
||||
|
||||
function getExtension(name) {
|
||||
return name.split('.').pop().toUpperCase()
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (bytes < 1024) return bytes + ' Б'
|
||||
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' КБ'
|
||||
return (bytes / (1024 * 1024)).toFixed(1) + ' МБ'
|
||||
}
|
||||
|
||||
function validateFile(file) {
|
||||
validationError.value = ''
|
||||
const ext = file.name.split('.').pop().toLowerCase()
|
||||
if (!allowedExtensions.includes(ext)) {
|
||||
validationError.value = `Формат .${ext} не поддерживается. Используйте STL, 3MF или OBJ.`
|
||||
return false
|
||||
}
|
||||
if (file.size > maxSize) {
|
||||
validationError.value = 'Файл слишком большой (максимум 50 МБ)'
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function setFile(file) {
|
||||
if (validateFile(file)) {
|
||||
store.file = file
|
||||
store.result = null
|
||||
}
|
||||
}
|
||||
|
||||
function onFileSelect(e) {
|
||||
const file = e.target.files[0]
|
||||
if (file) setFile(file)
|
||||
}
|
||||
|
||||
function onDrop(e) {
|
||||
isDragging.value = false
|
||||
const file = e.dataTransfer.files[0]
|
||||
if (file) setFile(file)
|
||||
}
|
||||
|
||||
function removeFile() {
|
||||
store.file = null
|
||||
store.result = null
|
||||
validationError.value = ''
|
||||
}
|
||||
</script>
|
||||
82
frontend/src/components/MaterialPicker.vue
Normal file
82
frontend/src/components/MaterialPicker.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold text-gray-900">2. Выберите материал</h2>
|
||||
<button @click="$emit('openAdvisor')" class="btn-secondary !py-1.5 !px-3 !text-xs">
|
||||
<svg class="mr-1.5 h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09z" />
|
||||
</svg>
|
||||
Помочь выбрать
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-for="(label, cat) in categories" :key="cat" class="mb-5 last:mb-0">
|
||||
<h3 class="mb-2.5 text-xs font-semibold uppercase tracking-wider text-gray-500">{{ label }}</h3>
|
||||
<div class="grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<button
|
||||
v-for="mat in materialsByCategory(cat)"
|
||||
:key="mat.id"
|
||||
@click="selectMaterial(mat.id)"
|
||||
:class="[
|
||||
'flex flex-col rounded-lg border-2 p-3.5 text-left transition-all',
|
||||
store.materialId === mat.id
|
||||
? 'border-primary-500 bg-primary-50 ring-1 ring-primary-500'
|
||||
: 'border-gray-200 hover:border-gray-300 hover:bg-gray-50',
|
||||
]"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm font-semibold text-gray-900">{{ mat.name }}</span>
|
||||
<span class="text-xs font-medium text-gray-500">{{ mat.price_per_gram }} ₽/г</span>
|
||||
</div>
|
||||
<p class="mt-1 text-xs leading-relaxed text-gray-500">{{ mat.description }}</p>
|
||||
<div class="mt-2 flex flex-wrap gap-1.5">
|
||||
<span v-if="mat.properties.food_safe" class="inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700">
|
||||
Food safe
|
||||
</span>
|
||||
<span class="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600">
|
||||
{{ mat.properties.max_temp_c }}°C
|
||||
</span>
|
||||
<span class="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600">
|
||||
{{ strengthLabel(mat.properties.strength) }}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted } from 'vue'
|
||||
import { useCalculatorStore } from '../stores/calculator'
|
||||
import { useMaterialsStore } from '../stores/materials'
|
||||
|
||||
defineEmits(['openAdvisor'])
|
||||
|
||||
const store = useCalculatorStore()
|
||||
const materialsStore = useMaterialsStore()
|
||||
const { categories } = materialsStore
|
||||
|
||||
onMounted(() => materialsStore.fetchMaterials())
|
||||
|
||||
function materialsByCategory(cat) {
|
||||
return materialsStore.materials.filter((m) => m.category === cat)
|
||||
}
|
||||
|
||||
function selectMaterial(id) {
|
||||
store.materialId = id
|
||||
store.result = null
|
||||
}
|
||||
|
||||
const strengthLabels = {
|
||||
low: 'Низкая',
|
||||
medium: 'Средняя',
|
||||
high: 'Высокая',
|
||||
very_high: 'Очень высокая',
|
||||
extreme: 'Экстремальная',
|
||||
}
|
||||
|
||||
function strengthLabel(val) {
|
||||
return strengthLabels[val] || val
|
||||
}
|
||||
</script>
|
||||
77
frontend/src/components/OrderForm.vue
Normal file
77
frontend/src/components/OrderForm.vue
Normal file
@@ -0,0 +1,77 @@
|
||||
<template>
|
||||
<form @submit.prevent="submitOrder" class="space-y-4">
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700">Имя *</label>
|
||||
<input v-model="form.client_name" required class="input-field" placeholder="Иван Петров" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700">Телефон *</label>
|
||||
<input v-model="form.client_phone" required class="input-field" placeholder="+79001234567" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700">Email</label>
|
||||
<input v-model="form.client_email" type="email" class="input-field" placeholder="ivan@example.com" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700">Компания</label>
|
||||
<input v-model="form.client_company" class="input-field" placeholder="ООО Технопарк" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700">Способ получения</label>
|
||||
<select v-model="form.delivery_method" class="input-field">
|
||||
<option value="pickup">Самовывоз</option>
|
||||
<option value="delivery">Доставка</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-sm font-medium text-gray-700">Комментарий</label>
|
||||
<textarea v-model="form.comment" rows="3" class="input-field" placeholder="Дополнительные пожелания"></textarea>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="text-sm text-red-600">{{ error }}</p>
|
||||
|
||||
<button type="submit" :disabled="loading" class="btn-primary w-full">
|
||||
<svg v-if="loading" class="mr-2 h-4 w-4 animate-spin" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
|
||||
</svg>
|
||||
{{ loading ? 'Оформляем...' : 'Оформить заказ' }}
|
||||
</button>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import api from '../api/client'
|
||||
|
||||
const props = defineProps({ calculationId: String })
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const form = reactive({
|
||||
client_name: '',
|
||||
client_phone: '',
|
||||
client_email: '',
|
||||
client_company: '',
|
||||
delivery_method: 'pickup',
|
||||
comment: '',
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
async function submitOrder() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const { data } = await api.post('/orders', {
|
||||
calculation_id: props.calculationId,
|
||||
...form,
|
||||
})
|
||||
emit('success', data)
|
||||
} catch (e) {
|
||||
error.value = e.response?.data?.detail || 'Ошибка оформления заказа'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
80
frontend/src/components/PriceResult.vue
Normal file
80
frontend/src/components/PriceResult.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<div class="card" v-if="result">
|
||||
<h2 class="mb-4 text-lg font-semibold text-gray-900">Результат расчёта</h2>
|
||||
|
||||
<!-- File info -->
|
||||
<div class="mb-4 rounded-lg bg-gray-50 p-3.5">
|
||||
<p class="text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2">Модель</p>
|
||||
<div class="grid grid-cols-2 gap-2 text-sm">
|
||||
<div><span class="text-gray-500">Файл:</span> {{ result.file_info.filename }}</div>
|
||||
<div><span class="text-gray-500">Объём:</span> {{ result.file_info.volume_cm3 }} см³</div>
|
||||
<div><span class="text-gray-500">Габариты:</span> {{ bbox }}</div>
|
||||
<div>
|
||||
<span class="text-gray-500">Водонепр.:</span>
|
||||
<span :class="result.file_info.is_watertight ? 'text-green-600' : 'text-amber-600'">
|
||||
{{ result.file_info.is_watertight ? 'Да' : 'Нет' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Price breakdown -->
|
||||
<div class="space-y-2.5 mb-4">
|
||||
<div class="flex justify-between text-sm">
|
||||
<span class="text-gray-600">Материал ({{ result.calculation.material.name }}, {{ result.calculation.weight_grams }} г)</span>
|
||||
<span class="font-medium">{{ fmt(result.calculation.material_cost_rub) }} ₽</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-sm">
|
||||
<span class="text-gray-600">Время печати (~{{ result.calculation.print_time_hours }} ч)</span>
|
||||
<span class="font-medium">{{ fmt(result.calculation.time_cost_rub) }} ₽</span>
|
||||
</div>
|
||||
<div v-if="result.calculation.post_processing_cost_rub > 0" class="flex justify-between text-sm">
|
||||
<span class="text-gray-600">Постобработка</span>
|
||||
<span class="font-medium">{{ fmt(result.calculation.post_processing_cost_rub) }} ₽</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-sm border-t border-gray-100 pt-2.5">
|
||||
<span class="text-gray-600">Подитог (1 шт)</span>
|
||||
<span class="font-medium">{{ fmt(result.calculation.subtotal_rub) }} ₽</span>
|
||||
</div>
|
||||
<div v-if="result.calculation.quantity > 1" class="flex justify-between text-sm">
|
||||
<span class="text-gray-600">Количество: {{ result.calculation.quantity }} шт</span>
|
||||
<span v-if="result.calculation.quantity_discount_percent" class="text-green-600 font-medium">
|
||||
-{{ result.calculation.quantity_discount_percent }}% скидка
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Total -->
|
||||
<div class="rounded-lg bg-primary-50 p-4 mb-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-medium text-primary-700">Итого</p>
|
||||
<p class="text-xs text-primary-600">Срок: ~{{ result.calculation.estimated_days }} рабочих дней</p>
|
||||
</div>
|
||||
<p class="text-2xl font-bold text-primary-700">{{ fmt(result.calculation.total_rub) }} ₽</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<router-link :to="`/order/${result.calculation_id}`" class="btn-primary w-full text-center block">
|
||||
Оформить заказ
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { useCalculatorStore } from '../stores/calculator'
|
||||
|
||||
const store = useCalculatorStore()
|
||||
const result = computed(() => store.result)
|
||||
|
||||
const bbox = computed(() => {
|
||||
if (!result.value) return ''
|
||||
const b = result.value.file_info.bounding_box_mm
|
||||
return `${b.x} x ${b.y} x ${b.z} мм`
|
||||
})
|
||||
|
||||
function fmt(n) {
|
||||
return new Intl.NumberFormat('ru-RU', { maximumFractionDigits: 0 }).format(n)
|
||||
}
|
||||
</script>
|
||||
100
frontend/src/components/PrintSettings.vue
Normal file
100
frontend/src/components/PrintSettings.vue
Normal file
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<h2 class="mb-4 text-lg font-semibold text-gray-900">3. Параметры печати</h2>
|
||||
|
||||
<div class="space-y-5">
|
||||
<!-- Infill -->
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="text-sm font-medium text-gray-700" title="Больше заполнение — прочнее, но тяжелее и дороже">
|
||||
Заполнение
|
||||
</label>
|
||||
<span class="text-sm font-semibold text-primary-600">{{ store.settings.infill_percent }}%</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
:value="store.settings.infill_percent"
|
||||
@input="store.settings.infill_percent = +$event.target.value"
|
||||
min="10" max="100" step="10"
|
||||
class="w-full accent-primary-600"
|
||||
/>
|
||||
<div class="mt-1 flex justify-between text-[10px] text-gray-400">
|
||||
<span>10%</span><span>50%</span><span>100%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Layer height -->
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="text-sm font-medium text-gray-700" title="Меньше слой — лучше качество, но дольше печать">
|
||||
Высота слоя
|
||||
</label>
|
||||
<span class="text-sm font-semibold text-primary-600">{{ store.settings.layer_height_mm }} мм</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
:value="store.settings.layer_height_mm"
|
||||
@input="store.settings.layer_height_mm = +parseFloat($event.target.value).toFixed(2)"
|
||||
min="0.08" max="0.4" step="0.04"
|
||||
class="w-full accent-primary-600"
|
||||
/>
|
||||
<div class="mt-1 flex justify-between text-[10px] text-gray-400">
|
||||
<span>0.08</span><span>0.2</span><span>0.4</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quantity -->
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-gray-700">Количество</label>
|
||||
<input
|
||||
type="number"
|
||||
:value="store.settings.quantity"
|
||||
@input="store.settings.quantity = Math.max(1, Math.min(500, +$event.target.value || 1))"
|
||||
min="1" max="500"
|
||||
class="input-field w-28"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Post-processing -->
|
||||
<div>
|
||||
<label class="mb-2.5 block text-sm font-medium text-gray-700">Постобработка</label>
|
||||
<div class="space-y-2">
|
||||
<label v-for="pp in postProcessingOptions" :key="pp.value" class="flex items-center gap-2.5 cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
:value="pp.value"
|
||||
:checked="store.settings.post_processing.includes(pp.value)"
|
||||
@change="togglePP(pp.value)"
|
||||
class="h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
<span class="text-sm text-gray-700">{{ pp.label }}</span>
|
||||
<span class="text-xs text-gray-400">{{ pp.price }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useCalculatorStore } from '../stores/calculator'
|
||||
|
||||
const store = useCalculatorStore()
|
||||
|
||||
const postProcessingOptions = [
|
||||
{ value: 'sanding', label: 'Шлифовка', price: '300 ₽/шт' },
|
||||
{ value: 'painting', label: 'Покраска', price: '500 ₽/шт' },
|
||||
{ value: 'threading', label: 'Нарезка резьбы', price: '200 ₽/шт' },
|
||||
{ value: 'acetone_smoothing', label: 'Ацетоновая обработка (ABS)', price: '400 ₽/шт' },
|
||||
]
|
||||
|
||||
function togglePP(value) {
|
||||
const idx = store.settings.post_processing.indexOf(value)
|
||||
if (idx > -1) {
|
||||
store.settings.post_processing.splice(idx, 1)
|
||||
} else {
|
||||
store.settings.post_processing.push(value)
|
||||
}
|
||||
store.result = null
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user