admin big changes

This commit is contained in:
2026-06-13 17:38:35 +03:30
parent 213ef1a1b7
commit 0c404ee3e1
14 changed files with 188 additions and 276 deletions
@@ -11,29 +11,30 @@
@refresh="reload"
@load-more="loadMore"
>
<PriceMobileListItem v-for="item in items" :key="item.id" :item="item" @open="openSheet" />
<PriceMobileListItem v-for="item in items" :key="item.id" :item="item" @open="openDetail" />
</MobileCardList>
<PriceMobileDetailSheet v-model:visible="sheetVisible" :item="selectedItem" />
</template>
<script setup lang="ts">
import { getPriceTable } from '@/api/price'
import type { Price } from '@/model/price'
import { getPriceSyncLogTable } from '@/api/price'
import type { PriceSyncLog } from '@/model/priceSyncLog'
import MobileCardList from '@/components/mobile/MobileCardList.vue'
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
import PriceMobileDetailSheet from './PriceMobileDetailSheet.vue'
import PriceMobileListItem from './PriceMobileListItem.vue'
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<Price>()
const emit = defineEmits<{
(e: 'detail', item: PriceSyncLog): void
}>()
const { loading, search, items, hasMore, reload, loadMore, fetch } = useMobileTableList<Price>({
fetchApi: getPriceTable,
onFetched: (rows) => syncSelectedItem(rows)
const { loading, search, items, hasMore, reload, loadMore, fetch } = useMobileTableList<PriceSyncLog>({
fetchApi: getPriceSyncLogTable
})
function openDetail(item: PriceSyncLog) {
emit('detail', item)
}
onMounted(() => reload())
defineExpose({ fetch, openSheet })
defineExpose({ fetch, openDetail })
</script>
@@ -2,12 +2,12 @@
<MobileCard clickable @click="$emit('open', item)">
<div class="space-y-1">
<div class="flex items-center justify-between gap-2">
<span class="truncate text-sm font-700 text-gray-900">{{ userName }}</span>
<span class="truncate text-sm font-700 text-gray-900">{{ sourceLabel }}</span>
<span class="shrink-0 text-xs text-gray-400">{{ dateLabel }}</span>
</div>
<div class="flex items-center justify-between gap-2 text-xs">
<span class="truncate text-gray-600">#{{ item.id ?? '-' }}</span>
<span class="truncate text-gray-600">{{ item.products_updated }} محصول</span>
<span class="shrink-0 font-700 text-green-700">{{ priceLabel }}</span>
</div>
</div>
@@ -15,20 +15,27 @@
</template>
<script setup lang="ts">
import type { Price } from '@/model/price'
import type { PriceSyncLog } from '@/model/priceSyncLog'
import MobileCard from '@/components/mobile/MobileCard.vue'
import { toJalaliNoTime } from '@core/utils/useDataTime'
import { usePrice } from '@core/utils/usePrice'
const SOURCE_LABELS: Record<string, string> = {
zaarbox: 'تابلو Zaarbox',
legacy: 'فید قدیمی'
}
const props = defineProps<{
item: Price
item: PriceSyncLog
}>()
defineEmits<{
(e: 'open', item: Price): void
(e: 'open', item: PriceSyncLog): void
}>()
const userName = computed(() => props.item.user?.name || '-')
const sourceLabel = computed(() => SOURCE_LABELS[props.item.source] ?? props.item.source)
const dateLabel = computed(() => (props.item.created_at ? toJalaliNoTime(props.item.created_at) : '-'))
const priceLabel = computed(() => usePrice(props.item.price ?? 0, true, ''))
const priceLabel = computed(() =>
props.item.liquid_gold_price > 0 ? usePrice(props.item.liquid_gold_price, true, '') : '—'
)
</script>
@@ -1,9 +1,8 @@
<template>
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
<BasicShowContext :title="isStore ? 'تاریخچه همگام‌سازی قیمت' : 'تاریخچه قیمت'">
<BasicShowContext title="تاریخچه قیمت">
<template #extra>
<BaseButton
v-if="isStore"
type="primary"
size="small"
class="flex shrink-0 md:hidden"
@@ -13,23 +12,12 @@
<div>به‌روزرسانی قیمت</div>
<BaseIcon icon="vuesax-linear:refresh" Size="16px" />
</BaseButton>
<BaseButton
v-else
type="primary"
size="small"
class="flex shrink-0 md:hidden"
@click="emits('add')"
>
<div>قیمت گذاری</div>
<BaseIcon icon="vuesax-linear:dollar-circle" Size="16px" />
</BaseButton>
</template>
<div class="flex h-full min-h-0 flex-col">
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
<template #extraHeader>
<BaseButton
v-if="isStore"
type="primary"
size="small"
class="flex"
@@ -39,10 +27,6 @@
<div>به‌روزرسانی قیمت</div>
<BaseIcon icon="vuesax-linear:refresh" Size="16px" />
</BaseButton>
<BaseButton v-else type="primary" size="small" class="flex" @click="emits('add')">
<div>قیمت گذاری</div>
<BaseIcon icon="vuesax-linear:dollar-circle" Size="16px" />
</BaseButton>
</template>
<template #action="{ record }">
<div class="flex justify-center gap-2">
@@ -56,8 +40,12 @@
</template>
</BaseTable>
<PriceMobileCardList v-else-if="!isStore" ref="mobileListRef" class="min-h-0 flex-1" />
<div v-else class="p-4 text-center text-gray-500">در موبایل از نسخه دسکتاپ استفاده کنید</div>
<PriceMobileCardList
v-else
ref="mobileListRef"
class="min-h-0 flex-1"
@detail="emits('detail', $event)"
/>
</div>
</BasicShowContext>
</div>
@@ -67,30 +55,26 @@
import type { TableInput } from '@core/type/baseTable'
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
import Icon from '@core/components/BaseIcon/src/Icon.vue'
import { cols } from '../hooks/priceColumns'
import { storePriceColumns } from '../hooks/storePriceColumns'
import { usePrefix } from '@core/composable/usePrefix'
import { getPriceSyncLogTable, getPriceTable } from '@/api/price'
import { isStoreApp } from '@/utils/config'
import { getPriceSyncLogTable } from '@/api/price'
import PriceMobileCardList from './PriceMobileCardList.vue'
import { isMobile } from '@core/utils/is'
import { computed } from 'vue'
import type { PriceSyncLog } from '@/model/priceSyncLog'
const props = defineProps<{ syncing?: boolean }>()
defineProps<{ syncing?: boolean }>()
const [submit, reload] = useBaseTable()
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'detail', 'sync'])
const emits = defineEmits(['detail', 'sync'])
const isStore = computed(() => isStoreApp())
const { prefixCls } = usePrefix('pophoverstatus')
const tblProps = computed(() => ({
columns: isStore.value ? storePriceColumns : cols,
api: (params: TableInput) =>
isStore.value ? getPriceSyncLogTable(params) : getPriceTable(params)
}))
const tblProps = {
columns: storePriceColumns,
api: (params: TableInput) => getPriceSyncLogTable(params)
}
async function fetch() {
await Promise.allSettled([reload(), mobileListRef.value?.fetch?.() as Promise<void>])
+2 -73
View File
@@ -6,74 +6,28 @@
ref="table"
class="h-full w-full"
:syncing="syncing"
@add="add"
@detail="openDetail"
@sync="handleSync"
/>
</div>
</BasicMainCard>
<template v-if="!isStore">
<BasicModal
v-model:visible="priceConfirmVisible"
width="25rem"
@ok="ok"
:confirm-loading="loading"
@close="priceConfirmVisible = false"
>
<div class="flex items-center gap-2 font-bold">
<BaseIcon icon="vuesax-linear:info-circle" color="orange" />
<div>آیا مطمئن به تغییر قیمت می باشید؟</div>
</div>
</BasicModal>
<BasicModal
v-model:visible="addPriceVisible"
width="25rem"
title="قیمت گذاری"
@ok="confirmPrice"
:loading="loading"
@close="addPriceVisible = false"
>
<a-form :model="form" ref="formRef" autocomplete="off">
<div class="gap-4">
<a-form-item label="قیمت جدید" name="price" :rules="inputRules()">
<BasicInput v-model:value="form.price" type="price" addon-before="ریال" />
</a-form-item>
<div v-show="form.price > 10">معادل {{ usePrice(form.price / 10, true, 'تومان') }}</div>
</div>
</a-form>
</BasicModal>
</template>
<PriceSyncDetailModal v-model:visible="detailVisible" :log-id="selectedLogId" />
</div>
</template>
<script setup lang="ts">
import { inputRules } from '@/utils/inputRules'
import { computed, ref } from 'vue'
import { ref } from 'vue'
import tbl from './components/table.vue'
import type { FormInstance } from 'ant-design-vue'
import { message } from 'ant-design-vue/es'
import type { Price } from '@/model/price'
import { createPrice, runPriceSync } from '@/api/price'
import { usePrice } from '@core/utils/usePrice'
import { isStoreApp } from '@/utils/config'
import { runPriceSync } from '@/api/price'
import PriceSyncDetailModal from './components/PriceSyncDetailModal.vue'
import type { PriceSyncLog } from '@/model/priceSyncLog'
const loading = ref(false)
const syncing = ref(false)
const table = ref<null | { fetch: () => void }>(null)
const refreshTable = () => table.value?.fetch()
const isStore = computed(() => isStoreApp())
const form = ref<Price>({})
const formRef = ref<FormInstance>()
const addPriceVisible = ref(false)
const priceConfirmVisible = ref(false)
const detailVisible = ref(false)
const selectedLogId = ref<number | null>(null)
@@ -95,31 +49,6 @@ async function handleSync() {
syncing.value = false
}
}
async function add() {
addPriceVisible.value = true
form.value = {}
}
function confirmPrice() {
formRef.value?.validateFields().then(async () => {
priceConfirmVisible.value = true
})
}
async function ok() {
loading.value = true
try {
await createPrice(form.value)
refreshTable()
priceConfirmVisible.value = false
addPriceVisible.value = false
} catch (e) {
console.error(e)
} finally {
loading.value = false
}
}
</script>
<style scoped></style>