.
This commit is contained in:
@@ -7,6 +7,7 @@ import SearchField from '@/components/ui/SearchField.vue'
|
||||
import EmptyState from '@/components/ui/EmptyState.vue'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import IconCatalog from '@/components/icons/IconCatalog.vue'
|
||||
import { navigateToCatalogProduct } from '@/utils/catalogNavigation'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -32,7 +33,7 @@ onMounted(load)
|
||||
watch(companyId, load)
|
||||
|
||||
function openCatalog(catalogId: string) {
|
||||
router.push({ name: 'catalog-detail', params: { catalogId } })
|
||||
void navigateToCatalogProduct(router, catalogId)
|
||||
}
|
||||
|
||||
function getProductCount(catalogId: string) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import { navigateToCatalogProduct } from '@/utils/catalogNavigation'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
onMounted(() => {
|
||||
void navigateToCatalogProduct(router, String(route.params.catalogId ?? ''))
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<PageSkeleton variant="detail" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,314 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import PageHeader from '@/components/layout/PageHeader.vue'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import { useCrmStore } from '@/stores/crm'
|
||||
import { useCatalogRequestsStore } from '@/stores/catalogRequests'
|
||||
import type { CatalogProductCard } from '@/types/crm'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const crm = useCrmStore()
|
||||
const requestsStore = useCatalogRequestsStore()
|
||||
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
const note = ref('')
|
||||
const products = ref<CatalogProductCard[]>([])
|
||||
const quantities = ref<Record<string, number>>({})
|
||||
|
||||
const preselectId = computed(() => String(route.query.productId ?? ''))
|
||||
const catalogId = computed(() => String(route.query.catalogId ?? ''))
|
||||
|
||||
const selectedItems = computed(() =>
|
||||
products.value
|
||||
.filter((p) => (quantities.value[p.id] ?? 0) > 0)
|
||||
.map((p) => ({
|
||||
productId: p.id,
|
||||
productName: p.name,
|
||||
productCode: p.code,
|
||||
quantity: quantities.value[p.id] ?? 0,
|
||||
})),
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const list = await crm.loadBrowseProducts(
|
||||
catalogId.value ? { catalogId: catalogId.value } : undefined,
|
||||
)
|
||||
const selected = preselectId.value
|
||||
products.value = selected
|
||||
? [...list].sort((a, b) => Number(b.id === selected) - Number(a.id === selected))
|
||||
: list
|
||||
if (selected) {
|
||||
quantities.value = { ...quantities.value, [selected]: 1 }
|
||||
}
|
||||
} catch (e) {
|
||||
error.value = e instanceof Error ? e.message : 'بارگذاری محصولات ناموفق بود.'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
function setQty(id: string, value: number) {
|
||||
quantities.value = {
|
||||
...quantities.value,
|
||||
[id]: Math.max(0, Math.floor(value) || 0),
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
saving.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const result = await requestsStore.create({
|
||||
items: selectedItems.value,
|
||||
note: note.value,
|
||||
})
|
||||
if (!result.success) {
|
||||
error.value = result.message
|
||||
return
|
||||
}
|
||||
router.push('/catalog-requests')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page catalog-request-page">
|
||||
<PageHeader class="mobile-only" title="درخواست کالیته" show-back centered @back="router.back()" />
|
||||
|
||||
<header class="desktop-page__head desktop-only">
|
||||
<h1 class="desktop-page__title">درخواست کالیته</h1>
|
||||
<p class="desktop-page__subtitle">محصولات و تعداد اقلام موردنظر را مشخص کنید</p>
|
||||
</header>
|
||||
|
||||
<div class="page__scroll page__scroll--with-nav body">
|
||||
<p class="hint">
|
||||
{{ preselectId ? 'این محصول برای درخواست کالیته انتخاب شده است. در صورت نیاز اقلام دیگر را هم اضافه کنید.' : 'محصولات و تعداد اقلام موردنظر را مشخص کنید.' }}
|
||||
</p>
|
||||
<PageSkeleton v-if="loading" variant="form" />
|
||||
<p v-else-if="error" class="error">{{ error }}</p>
|
||||
<template v-else>
|
||||
<div class="request-layout">
|
||||
<div class="request-products">
|
||||
<article
|
||||
v-for="item in products"
|
||||
:key="item.id"
|
||||
class="row"
|
||||
:class="{ 'row--selected': preselectId === item.id }"
|
||||
>
|
||||
<div>
|
||||
<strong>{{ item.name }}</strong>
|
||||
<span>کد {{ item.code }}</span>
|
||||
</div>
|
||||
<input
|
||||
class="qty"
|
||||
type="number"
|
||||
min="0"
|
||||
:value="quantities[item.id] ?? 0"
|
||||
@input="setQty(item.id, Number(($event.target as HTMLInputElement).value))"
|
||||
/>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<aside class="request-sidebar desktop-summary-panel">
|
||||
<h2 class="desktop-summary-panel__title">خلاصه درخواست</h2>
|
||||
<div class="desktop-summary-panel__row">
|
||||
<span>اقلام انتخابشده</span>
|
||||
<strong>{{ formatNumber(selectedItems.length) }}</strong>
|
||||
</div>
|
||||
<label class="note">
|
||||
توضیحات
|
||||
<textarea v-model="note" rows="3" placeholder="آدرس یا توضیحات اختیاری" />
|
||||
</label>
|
||||
<button type="button" class="submit" :disabled="saving" @click="submit">
|
||||
{{ saving ? 'در حال ثبت...' : 'ثبت درخواست کالیته' }}
|
||||
</button>
|
||||
<button type="button" class="linkish" @click="router.push('/catalog-requests')">
|
||||
وضعیت درخواستهای قبلی
|
||||
</button>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<div class="request-mobile-footer mobile-only">
|
||||
<label class="note">
|
||||
توضیحات
|
||||
<textarea v-model="note" rows="3" placeholder="آدرس یا توضیحات اختیاری" />
|
||||
</label>
|
||||
<p class="summary">اقلام انتخابشده: {{ formatNumber(selectedItems.length) }}</p>
|
||||
<button type="button" class="submit" :disabled="saving" @click="submit">
|
||||
{{ saving ? 'در حال ثبت...' : 'ثبت درخواست کالیته' }}
|
||||
</button>
|
||||
<button type="button" class="linkish" @click="router.push('/catalog-requests')">
|
||||
وضعیت درخواستهای قبلی
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.body {
|
||||
padding: 12px var(--page-padding) 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin: 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #b42318;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 12px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.row--selected {
|
||||
outline: 2px solid var(--color-primary);
|
||||
}
|
||||
|
||||
.row strong {
|
||||
display: block;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.row span {
|
||||
color: var(--color-text-muted);
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.qty {
|
||||
width: 64px;
|
||||
height: 40px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
font: inherit;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.note {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.note textarea {
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
padding: 10px 12px;
|
||||
font: inherit;
|
||||
resize: vertical;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.summary {
|
||||
margin: 4px 0 0;
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.submit {
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
min-height: 48px;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.submit:disabled {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.linkish {
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--color-primary);
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.request-layout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.request-sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.request-mobile-footer {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.catalog-request-page {
|
||||
max-width: var(--content-max-width);
|
||||
margin-inline: auto;
|
||||
padding: 20px var(--page-padding) 28px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.body {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.request-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
|
||||
gap: 20px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.request-sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
position: sticky;
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
.request-sidebar .submit {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.request-mobile-footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.row {
|
||||
box-shadow: var(--shadow-card);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -20,19 +20,15 @@ onMounted(() => store.hydrate())
|
||||
<h1 class="desktop-page__title">وضعیت کالیتهها</h1>
|
||||
<p class="desktop-page__subtitle">پیگیری درخواستهای کالیته ثبتشده</p>
|
||||
</div>
|
||||
<button type="button" class="desk-new-btn" @click="router.push('/catalog-request')">
|
||||
<button type="button" class="desk-new-btn" @click="router.push('/categories')">
|
||||
درخواست کالیته جدید
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="page__scroll page__scroll--with-nav body">
|
||||
<button type="button" class="new-btn mobile-only" @click="router.push('/catalog-request')">
|
||||
<button type="button" class="new-btn mobile-only" @click="router.push('/categories')">
|
||||
درخواست کالیته جدید
|
||||
</button>
|
||||
<button type="button" class="new-btn" @click="router.push('/catalog-request')">
|
||||
درخواست کالیته جدید
|
||||
</button>
|
||||
|
||||
<p v-if="!store.sorted.length" class="empty">هنوز درخواستی ثبت نکردهاید.</p>
|
||||
|
||||
<article v-for="item in store.sorted" :key="item.id" class="card">
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from '@/utils/catalogGallery'
|
||||
import { MOCK_CALITE_CARDS } from '@/data/caliteCollections'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import { navigateToCatalogProduct } from '@/utils/catalogNavigation'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -56,7 +57,7 @@ onMounted(async () => {
|
||||
products.value = browse
|
||||
const focusId = String(route.query.id ?? '')
|
||||
if (focusId && catalogs.value.some((item) => item.id === focusId)) {
|
||||
router.replace({ name: 'catalog-detail', params: { catalogId: focusId } })
|
||||
await navigateToCatalogProduct(router, focusId, products.value)
|
||||
}
|
||||
} catch {
|
||||
catalogs.value = []
|
||||
@@ -66,7 +67,7 @@ onMounted(async () => {
|
||||
})
|
||||
|
||||
function openCatalog(id: string) {
|
||||
router.push({ name: 'catalog-detail', params: { catalogId: id } })
|
||||
void navigateToCatalogProduct(router, id, products.value)
|
||||
}
|
||||
|
||||
function focusSearch() {
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import PageHeader from '@/components/layout/PageHeader.vue'
|
||||
import PageSkeleton from '@/components/ui/PageSkeleton.vue'
|
||||
import SimpleStatusTimeline from '@/components/ui/SimpleStatusTimeline.vue'
|
||||
import { useCatalogRequestsStore } from '@/stores/catalogRequests'
|
||||
import {
|
||||
getSimpleCatalogStatusIndex,
|
||||
getSimpleCatalogStatusTimestamps,
|
||||
SIMPLE_CATALOG_STATUS_STEPS,
|
||||
} from '@/utils/simpleCatalogStatus'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
|
||||
const router = useRouter()
|
||||
const store = useCatalogRequestsStore()
|
||||
const loading = ref(true)
|
||||
|
||||
const latestRequest = computed(() => (store.sorted.length ? store.sorted[0] : null))
|
||||
|
||||
const currentIndex = computed(() =>
|
||||
latestRequest.value ? getSimpleCatalogStatusIndex(latestRequest.value) : 0,
|
||||
)
|
||||
|
||||
const timestamps = computed(() =>
|
||||
latestRequest.value ? getSimpleCatalogStatusTimestamps(latestRequest.value) : {},
|
||||
)
|
||||
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
await store.hydrate()
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
function goToCategories() {
|
||||
router.push('/categories')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page latest-status-page">
|
||||
<PageHeader
|
||||
class="mobile-only"
|
||||
title="آخرین درخواست کالیته"
|
||||
show-back
|
||||
centered
|
||||
@back="router.push('/')"
|
||||
/>
|
||||
|
||||
<header class="desktop-page__head desktop-only">
|
||||
<div>
|
||||
<h1 class="desktop-page__title">آخرین درخواست کالیته</h1>
|
||||
<p class="desktop-page__subtitle">پیگیری مراحل آخرین درخواست کالیته</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="page__scroll page__scroll--with-nav body">
|
||||
<PageSkeleton v-if="loading" />
|
||||
|
||||
<template v-else-if="latestRequest">
|
||||
<article class="summary-card">
|
||||
<p class="summary-card__label">درخواست</p>
|
||||
<strong class="summary-card__value">{{ latestRequest.id.slice(-8) }}</strong>
|
||||
<p class="summary-card__meta">
|
||||
{{ formatNumber(latestRequest.items.length) }} قلم کالیته
|
||||
</p>
|
||||
</article>
|
||||
|
||||
<SimpleStatusTimeline
|
||||
:steps="SIMPLE_CATALOG_STATUS_STEPS"
|
||||
:current-index="currentIndex"
|
||||
:timestamps="timestamps"
|
||||
/>
|
||||
|
||||
<button type="button" class="detail-link" @click="router.push('/catalog-requests')">
|
||||
مشاهده همه درخواستها
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<button v-else type="button" class="empty-cta" @click="goToCategories">
|
||||
شما هیچ کالیته ای درخواست نکرده اید، جهت درخواست کالیته و مشاهده فیزیکی پارچه ها کلیک کنید
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.body {
|
||||
padding: 12px var(--page-padding) 24px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 14px 16px;
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.summary-card__label {
|
||||
margin: 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.summary-card__value {
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
|
||||
.summary-card__meta {
|
||||
margin: 6px 0 0;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
.detail-link {
|
||||
align-self: center;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--color-primary);
|
||||
font-weight: 700;
|
||||
font-size: 0.875rem;
|
||||
cursor: pointer;
|
||||
padding: 8px 4px;
|
||||
}
|
||||
|
||||
.empty-cta {
|
||||
margin: 48px auto 0;
|
||||
max-width: 340px;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--color-text-muted);
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.6;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.empty-cta:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.body {
|
||||
max-width: 560px;
|
||||
margin-inline: auto;
|
||||
width: 100%;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user