Files
boursecu_admin/src/pages/menuPages/pricing/index.vue
T
2026-06-17 13:54:57 +03:30

59 lines
1.4 KiB
Vue

<template>
<div>
<BasicMainCard>
<div class="flex h-full w-full">
<tbl
ref="table"
class="h-full w-full"
:syncing="syncing"
@detail="openDetail"
@sync="handleSync"
/>
</div>
</BasicMainCard>
<PriceSyncDetailModal v-model:visible="detailVisible" :log-id="selectedLogId" />
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import tbl from './components/table.vue'
import { message } from 'ant-design-vue/es'
import { runPriceSync } from '@/api/price'
import PriceSyncDetailModal from './components/PriceSyncDetailModal.vue'
import type { PriceSyncLog } from '@/model/priceSyncLog'
const syncing = ref(false)
const table = ref<null | { fetch: () => void }>(null)
const refreshTable = () => table.value?.fetch()
const detailVisible = ref(false)
const selectedLogId = ref<number | null>(null)
function openDetail(record: PriceSyncLog) {
selectedLogId.value = record.id
detailVisible.value = true
}
async function handleSync() {
syncing.value = true
try {
const res = await runPriceSync()
if (res.data) {
message.success(res.message || 'انجام شد')
refreshTable()
} else {
message.info(res.message || 'قیمت تغییری نکرد')
}
} catch (e) {
console.error(e)
message.error('خطا در به‌روزرسانی قیمت')
} finally {
syncing.value = false
}
}
</script>
<style scoped></style>