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