fix tv
This commit is contained in:
@@ -71,12 +71,16 @@ const statusBanner = computed(() => {
|
||||
|
||||
function isShowOnTv(product: Product): boolean {
|
||||
const value = product.show_on_tv as unknown
|
||||
return value === true || value === 1 || value === '1'
|
||||
return value === true || value === 1 || value === '1' || value === 'true'
|
||||
}
|
||||
|
||||
const rows = computed(() => {
|
||||
void lastPrice.value
|
||||
return products.value.filter(isShowOnTv).map((product) => {
|
||||
// API فقط محصولات تابلو را میدهد؛ اگر فیلد show_on_tv نبود، همه را نشان بده
|
||||
const list = products.value
|
||||
const marked = list.filter(isShowOnTv)
|
||||
const source = marked.length ? marked : list
|
||||
return source.map((product) => {
|
||||
if (isProductPriceInactive(product)) {
|
||||
return {
|
||||
id: product.id,
|
||||
|
||||
@@ -28,7 +28,7 @@ function productText(product: Product) {
|
||||
|
||||
function isShowOnTv(product: Product) {
|
||||
const value = product.show_on_tv as unknown
|
||||
return value === true || value === 1 || value === '1'
|
||||
return value === true || value === 1 || value === '1' || value === 'true'
|
||||
}
|
||||
|
||||
function isParsianCoin(product: Product) {
|
||||
@@ -79,7 +79,13 @@ export function useTvMonitorPage() {
|
||||
)
|
||||
const brandLogo = computed(() => String(getConfigApp('avatar') || logoFallback))
|
||||
|
||||
const catalogProducts = computed(() => products.value.filter(isShowOnTv))
|
||||
// API فقط show_on_tv میدهد؛ فیلتر کلاینت برای دادهٔ ناقص است
|
||||
const catalogProducts = computed(() => {
|
||||
const list = products.value
|
||||
if (!list.length) return list
|
||||
const marked = list.filter(isShowOnTv)
|
||||
return marked.length ? marked : list
|
||||
})
|
||||
|
||||
const parsianCoins = computed(() =>
|
||||
catalogProducts.value
|
||||
@@ -108,6 +114,20 @@ export function useTvMonitorPage() {
|
||||
.sort((a, b) => Number(a.amount ?? 0) - Number(b.amount ?? 0)),
|
||||
)
|
||||
|
||||
/** آبشده، شمش، … — هر چیزی غیر از سکه/سیمرغ */
|
||||
const otherProducts = computed(() =>
|
||||
catalogProducts.value.filter(
|
||||
(p) => !isParsianCoin(p) && !isBankCoin(p) && !isSimorghBar(p),
|
||||
),
|
||||
)
|
||||
|
||||
const hasBoardContent = computed(
|
||||
() =>
|
||||
hasCoinBoard.value
|
||||
|| otherProducts.value.length > 0
|
||||
|| simorghBars.value.length > 0,
|
||||
)
|
||||
|
||||
const statusBanner = computed(() => {
|
||||
void lastPrice.value
|
||||
const state = getPriceDisplayState()
|
||||
@@ -263,7 +283,9 @@ export function useTvMonitorPage() {
|
||||
parsianCoins,
|
||||
bankCoins,
|
||||
hasCoinBoard,
|
||||
hasBoardContent,
|
||||
coinRowCount,
|
||||
otherProducts,
|
||||
simorghBars,
|
||||
statusBanner,
|
||||
liveBuy,
|
||||
|
||||
+66
-2
@@ -135,7 +135,48 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!loading" class="tv-monitor__empty">
|
||||
<section
|
||||
v-if="otherProducts.length"
|
||||
class="tv-col tv-col--others"
|
||||
:class="{ 'tv-col--others-alone': !hasCoinBoard }"
|
||||
>
|
||||
<header class="tv-col__head">
|
||||
<h2>محصولات تابلو</h2>
|
||||
<span>خرید و فروش</span>
|
||||
</header>
|
||||
<div class="tv-col__labels">
|
||||
<span class="tv-col__labels-gap" />
|
||||
<div class="tv-col__price-heads">
|
||||
<span class="tv-col__label tv-col__label--sell">فروش</span>
|
||||
<span class="tv-col__label tv-col__label--buy">خرید</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tv-col__list tv-col__list--others">
|
||||
<article
|
||||
v-for="item in otherProducts"
|
||||
:key="item.id"
|
||||
class="tv-row"
|
||||
>
|
||||
<div class="tv-row__media">
|
||||
<ProductImage :product="item" img-class="tv-row__img" />
|
||||
</div>
|
||||
<div class="tv-row__meta">
|
||||
<h3>{{ item.title }}</h3>
|
||||
<p>{{ productWeightLabel(item) }}</p>
|
||||
</div>
|
||||
<div class="tv-row__prices">
|
||||
<div class="tv-row__price tv-row__price--sell">
|
||||
<strong>{{ productBuyLabel(item) }}</strong>
|
||||
</div>
|
||||
<div class="tv-row__price tv-row__price--buy">
|
||||
<strong>{{ productSellLabel(item) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div v-if="!loading && !hasBoardContent" class="tv-monitor__empty">
|
||||
محصولی برای نمایش روی تابلو انتخاب نشده است
|
||||
</div>
|
||||
</a-spin>
|
||||
@@ -200,7 +241,9 @@ const {
|
||||
parsianCoins,
|
||||
bankCoins,
|
||||
hasCoinBoard,
|
||||
hasBoardContent,
|
||||
coinRowCount,
|
||||
otherProducts,
|
||||
simorghBars,
|
||||
statusBanner,
|
||||
liveBuy,
|
||||
@@ -420,24 +463,45 @@ const {
|
||||
}
|
||||
|
||||
.tv-monitor__board {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
|
||||
:deep(.tv-monitor__spin),
|
||||
:deep(.ant-spin-nested-loading),
|
||||
:deep(.ant-spin-container) {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.tv-monitor__columns {
|
||||
display: grid;
|
||||
flex: 1;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: clamp(12px, 1.6vw, 22px);
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tv-col--others {
|
||||
margin-top: clamp(12px, 1.6vw, 22px);
|
||||
max-height: 42%;
|
||||
}
|
||||
|
||||
.tv-col--others-alone {
|
||||
margin-top: 0;
|
||||
height: 100%;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.tv-col__list--others {
|
||||
grid-auto-rows: minmax(56px, auto);
|
||||
}
|
||||
|
||||
.tv-col {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
|
||||
Reference in New Issue
Block a user