store 4
This commit is contained in:
@@ -4,11 +4,22 @@ import type { last, Price } from "@/model/price";
|
|||||||
import type { TableInput } from '@core/type/baseTable'
|
import type { TableInput } from '@core/type/baseTable'
|
||||||
import type { MethodePrices } from "@/model/product";
|
import type { MethodePrices } from "@/model/product";
|
||||||
|
|
||||||
|
import type { PriceSyncLog } from '@/model/priceSyncLog'
|
||||||
|
|
||||||
export const createPrice = async (obj: Price) => await useAxios.post<AddId>(`/admin/price`, obj)
|
export const createPrice = async (obj: Price) => await useAxios.post<AddId>(`/admin/price`, obj)
|
||||||
|
|
||||||
export const getPriceTable = async (params: TableInput) =>
|
export const getPriceTable = async (params: TableInput) =>
|
||||||
await useAxios.post<Array<Price>>('/admin/price/table', params)
|
await useAxios.post<Array<Price>>('/admin/price/table', params)
|
||||||
|
|
||||||
|
export const getPriceSyncLogTable = async (params: TableInput) =>
|
||||||
|
await useAxios.post<Array<PriceSyncLog>>('/admin/price-sync-logs/table', params)
|
||||||
|
|
||||||
|
export const getPriceSyncLogDetail = async (id: number) =>
|
||||||
|
await useAxios.get<PriceSyncLog>(`/admin/price-sync-logs/${id}`)
|
||||||
|
|
||||||
|
export const runPriceSync = async () =>
|
||||||
|
await useAxios.post<{ message: string; data: PriceSyncLog | null }>('/admin/price-sync/run')
|
||||||
|
|
||||||
export const getLastPrice = async () => await useAxios.get<last>(`/api/price/last`)
|
export const getLastPrice = async () => await useAxios.get<last>(`/api/price/last`)
|
||||||
|
|
||||||
export const methodePrices = async () => await useAxios.get<MethodePrices[]>('/admin/p')
|
export const methodePrices = async () => await useAxios.get<MethodePrices[]>('/admin/p')
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export interface PriceSyncLogItem {
|
||||||
|
id: number
|
||||||
|
log_id: number
|
||||||
|
product_id?: number | null
|
||||||
|
product_title?: string | null
|
||||||
|
reading_method?: string | null
|
||||||
|
source_name?: string | null
|
||||||
|
base_price: number
|
||||||
|
base_profit: number
|
||||||
|
offset_percent: number
|
||||||
|
stored_price: number
|
||||||
|
previous_price: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PriceSyncLog {
|
||||||
|
id: number
|
||||||
|
source: string
|
||||||
|
source_url?: string | null
|
||||||
|
liquid_gold_price: number
|
||||||
|
products_updated: number
|
||||||
|
created_at: string
|
||||||
|
items?: PriceSyncLogItem[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
<template>
|
||||||
|
<BasicActionSheet
|
||||||
|
v-model:visible="visible"
|
||||||
|
title="جزئیات همگامسازی قیمت"
|
||||||
|
modal-width="52rem"
|
||||||
|
:showButton="false"
|
||||||
|
:showCancel="true"
|
||||||
|
:showOk="false"
|
||||||
|
cancelText="بستن"
|
||||||
|
@cancel="visible = false"
|
||||||
|
@close="visible = false"
|
||||||
|
>
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<div v-if="log" class="flex flex-col gap-4">
|
||||||
|
<div class="grid grid-cols-1 gap-2 text-sm md:grid-cols-2">
|
||||||
|
<div><span class="text-gray-500">منبع:</span> {{ sourceLabel(log.source) }}</div>
|
||||||
|
<div><span class="text-gray-500">آدرس:</span> {{ log.source_url || '—' }}</div>
|
||||||
|
<div>
|
||||||
|
<span class="text-gray-500">قیمت مرجع آبشده:</span>
|
||||||
|
{{ log.liquid_gold_price > 0 ? usePrice(log.liquid_gold_price, true, 'ریال') : '—' }}
|
||||||
|
</div>
|
||||||
|
<div><span class="text-gray-500">تعداد محصول:</span> {{ log.products_updated }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a-table
|
||||||
|
:columns="itemColumns"
|
||||||
|
:data-source="log.items ?? []"
|
||||||
|
:pagination="false"
|
||||||
|
row-key="id"
|
||||||
|
size="small"
|
||||||
|
:scroll="{ x: 900 }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-spin>
|
||||||
|
</BasicActionSheet>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { TableColumnType } from 'ant-design-vue'
|
||||||
|
import { ref, watch } from 'vue'
|
||||||
|
import { getPriceSyncLogDetail } from '@/api/price'
|
||||||
|
import type { PriceSyncLog } from '@/model/priceSyncLog'
|
||||||
|
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||||
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
|
|
||||||
|
const visible = defineModel<boolean>('visible', { default: false })
|
||||||
|
const props = defineProps<{ logId?: number | null }>()
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const log = ref<PriceSyncLog | null>(null)
|
||||||
|
|
||||||
|
const SOURCE_LABELS: Record<string, string> = {
|
||||||
|
zaarbox: 'تابلو Zaarbox',
|
||||||
|
legacy: 'فید قدیمی'
|
||||||
|
}
|
||||||
|
|
||||||
|
function sourceLabel(source?: string) {
|
||||||
|
return SOURCE_LABELS[source ?? ''] ?? source ?? '—'
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemColumns: TableColumnType[] = [
|
||||||
|
{ title: 'محصول', dataIndex: 'product_title', key: 'product_title', width: 140 },
|
||||||
|
{ title: 'کلید مرجع', dataIndex: 'reading_method', key: 'reading_method', width: 120 },
|
||||||
|
{ title: 'نام در فید', dataIndex: 'source_name', key: 'source_name', width: 120 },
|
||||||
|
{
|
||||||
|
title: 'قیمت پایه فید',
|
||||||
|
key: 'base_price',
|
||||||
|
customRender: ({ record }) => usePrice(record.base_price ?? 0, true, '')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'سود فید',
|
||||||
|
key: 'base_profit',
|
||||||
|
customRender: ({ record }) => usePrice(record.base_profit ?? 0, true, '')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تعدیل ٪',
|
||||||
|
dataIndex: 'offset_percent',
|
||||||
|
key: 'offset_percent'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'قیمت قبلی',
|
||||||
|
key: 'previous_price',
|
||||||
|
customRender: ({ record }) => usePrice(record.previous_price ?? 0, true, '')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'قیمت ذخیرهشده',
|
||||||
|
key: 'stored_price',
|
||||||
|
customRender: ({ record }) => usePrice(record.stored_price ?? 0, true, '')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
async function loadDetail(id: number) {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
log.value = await getPriceSyncLogDetail(id)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
log.value = null
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [visible.value, props.logId] as const,
|
||||||
|
([open, id]) => {
|
||||||
|
if (open && id) {
|
||||||
|
void loadDetail(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
</script>
|
||||||
@@ -1,8 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
|
<div class="h-full min-h-0 min-w-0 max-w-full overflow-hidden">
|
||||||
<BasicShowContext title="تاریخچه قیمت">
|
<BasicShowContext :title="isStore ? 'تاریخچه همگامسازی قیمت' : 'تاریخچه قیمت'">
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<BaseButton type="primary" size="small" class="flex shrink-0 md:hidden" @click="emits('add')">
|
<BaseButton
|
||||||
|
v-if="isStore"
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
class="flex shrink-0 md:hidden"
|
||||||
|
:loading="syncing"
|
||||||
|
@click="emits('sync')"
|
||||||
|
>
|
||||||
|
<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>
|
<div>قیمت گذاری</div>
|
||||||
<BaseIcon icon="vuesax-linear:dollar-circle" Size="16px" />
|
<BaseIcon icon="vuesax-linear:dollar-circle" Size="16px" />
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
@@ -10,25 +27,37 @@
|
|||||||
|
|
||||||
<div class="flex h-full min-h-0 flex-col">
|
<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">
|
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #extraHeader>
|
<template #extraHeader>
|
||||||
<BaseButton type="primary" size="small" class="flex" @click="emits('add')">
|
<BaseButton
|
||||||
<div>قیمت گذاری</div>
|
v-if="isStore"
|
||||||
<BaseIcon icon="vuesax-linear:dollar-circle" Size="16px" />
|
type="primary"
|
||||||
</BaseButton>
|
size="small"
|
||||||
</template>
|
class="flex"
|
||||||
<template #action="{ column, record }">
|
:loading="syncing"
|
||||||
<div class="gap-2 flex justify-center">
|
@click="emits('sync')"
|
||||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
>
|
||||||
<template #title>
|
<div>بهروزرسانی قیمت</div>
|
||||||
<span>مشخصات</span>
|
<BaseIcon icon="vuesax-linear:refresh" Size="16px" />
|
||||||
</template>
|
</BaseButton>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<BaseButton v-else type="primary" size="small" class="flex" @click="emits('add')">
|
||||||
</a-tooltip>
|
<div>قیمت گذاری</div>
|
||||||
</div>
|
<BaseIcon icon="vuesax-linear:dollar-circle" Size="16px" />
|
||||||
</template>
|
</BaseButton>
|
||||||
</BaseTable>
|
</template>
|
||||||
|
<template #action="{ record }">
|
||||||
|
<div class="flex justify-center gap-2">
|
||||||
|
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('detail', record)">
|
||||||
|
<template #title>
|
||||||
|
<span>جزئیات محصولات</span>
|
||||||
|
</template>
|
||||||
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
|
</a-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</BaseTable>
|
||||||
|
|
||||||
<PriceMobileCardList v-else ref="mobileListRef" class="min-h-0 flex-1" />
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</BasicShowContext>
|
</BasicShowContext>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,24 +68,29 @@ import type { TableInput } from '@core/type/baseTable'
|
|||||||
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
|
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
|
||||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||||
import { cols } from '../hooks/priceColumns'
|
import { cols } from '../hooks/priceColumns'
|
||||||
|
import { storePriceColumns } from '../hooks/storePriceColumns'
|
||||||
import { usePrefix } from '@core/composable/usePrefix'
|
import { usePrefix } from '@core/composable/usePrefix'
|
||||||
import { getPriceTable } from '@/api/price'
|
import { getPriceSyncLogTable, getPriceTable } from '@/api/price'
|
||||||
|
import { isStoreApp } from '@/utils/config'
|
||||||
import PriceMobileCardList from './PriceMobileCardList.vue'
|
import PriceMobileCardList from './PriceMobileCardList.vue'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps<{ syncing?: boolean }>()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||||
|
|
||||||
const emits = defineEmits(['delete', 'edit', 'add', 'info'])
|
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'detail', 'sync'])
|
||||||
|
|
||||||
|
const isStore = computed(() => isStoreApp())
|
||||||
const { prefixCls } = usePrefix('pophoverstatus')
|
const { prefixCls } = usePrefix('pophoverstatus')
|
||||||
|
|
||||||
const tblProps = ref<any>({
|
const tblProps = computed(() => ({
|
||||||
columns: cols,
|
columns: isStore.value ? storePriceColumns : cols,
|
||||||
api: (params: TableInput) => {
|
api: (params: TableInput) =>
|
||||||
return getPriceTable(params)
|
isStore.value ? getPriceSyncLogTable(params) : getPriceTable(params)
|
||||||
}
|
}))
|
||||||
})
|
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
await Promise.allSettled([reload(), mobileListRef.value?.fetch?.() as Promise<void>])
|
await Promise.allSettled([reload(), mobileListRef.value?.fetch?.() as Promise<void>])
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import type { BaseTableColumn } from '@core/type/baseTable'
|
||||||
|
import { toJalaliNoTime, toTime } from '@core/utils/useDataTime'
|
||||||
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
|
|
||||||
|
const SOURCE_LABELS: Record<string, string> = {
|
||||||
|
zaarbox: 'تابلو Zaarbox',
|
||||||
|
legacy: 'فید قدیمی'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const storePriceColumns: BaseTableColumn[] = [
|
||||||
|
{
|
||||||
|
title: 'ردیف',
|
||||||
|
dataIndex: 'id',
|
||||||
|
key: 'row',
|
||||||
|
filterable: false,
|
||||||
|
sortable: false,
|
||||||
|
customRender: (record: any) => record.index + 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'منبع قیمت',
|
||||||
|
dataIndex: 'source',
|
||||||
|
key: 'source',
|
||||||
|
type: 'Text',
|
||||||
|
customRender: ({ record }) => SOURCE_LABELS[record.source] ?? record.source
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'قیمت مرجع آبشده (ریال)',
|
||||||
|
dataIndex: 'liquid_gold_price',
|
||||||
|
key: 'liquid_gold_price',
|
||||||
|
type: 'Text',
|
||||||
|
customRender: ({ record }) =>
|
||||||
|
record.liquid_gold_price > 0 ? usePrice(record.liquid_gold_price, true, '') : '—'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'محصولات بهروز شده',
|
||||||
|
dataIndex: 'products_updated',
|
||||||
|
key: 'products_updated',
|
||||||
|
type: 'Number'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تاریخ',
|
||||||
|
dataIndex: 'created_at',
|
||||||
|
key: 'created_at',
|
||||||
|
type: 'DateTime',
|
||||||
|
customRender: (record: any) => toJalaliNoTime(record.record.created_at)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'زمان',
|
||||||
|
dataIndex: 'created_at',
|
||||||
|
key: 'time_at',
|
||||||
|
type: 'DateTime',
|
||||||
|
customRender: (record: any) => toTime(record.record.created_at)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'عملیات',
|
||||||
|
dataIndex: 'action',
|
||||||
|
key: 'action',
|
||||||
|
slot: 'action',
|
||||||
|
fixed: 'right',
|
||||||
|
filterable: false,
|
||||||
|
sortable: false
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,245 +1,112 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<BasicMainCard>
|
<BasicMainCard>
|
||||||
<div class="flex w-full h-full">
|
<div class="flex h-full w-full">
|
||||||
<tbl
|
<tbl
|
||||||
ref="table"
|
ref="table"
|
||||||
class="w-full h-full"
|
class="h-full w-full"
|
||||||
@info="info"
|
:syncing="syncing"
|
||||||
@edit="edit"
|
|
||||||
@delete="deleteItem"
|
|
||||||
@add="add"
|
@add="add"
|
||||||
|
@detail="openDetail"
|
||||||
|
@sync="handleSync"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
|
|
||||||
<component :is="selectedComponent" class="mr-5" />-->
|
|
||||||
<!-- <BasicShowContext title="پروژه ها"> <Search /> </BasicShowContext>-->
|
|
||||||
</div>
|
</div>
|
||||||
</BasicMainCard>
|
</BasicMainCard>
|
||||||
|
|
||||||
<BasicModal
|
<template v-if="!isStore">
|
||||||
v-model:visible="priceConfirmVisible"
|
<BasicModal
|
||||||
width="25rem"
|
v-model:visible="priceConfirmVisible"
|
||||||
@ok="ok"
|
width="25rem"
|
||||||
:confirm-loading="loading"
|
@ok="ok"
|
||||||
@close="priceConfirmVisible = false"
|
:confirm-loading="loading"
|
||||||
>
|
@close="priceConfirmVisible = false"
|
||||||
<div class="flex items-center gap-2 font-bold">
|
>
|
||||||
<BaseIcon icon="vuesax-linear:info-circle" color="orange" />
|
<div class="flex items-center gap-2 font-bold">
|
||||||
<div>آیا مطمئن به تغییر قیمت می باشید؟</div>
|
<BaseIcon icon="vuesax-linear:info-circle" color="orange" />
|
||||||
</div>
|
<div>آیا مطمئن به تغییر قیمت می باشید؟</div>
|
||||||
</BasicModal>
|
</div>
|
||||||
<!-- <BasicInfoModal
|
</BasicModal>
|
||||||
v-model:visible="userInfoVisible"
|
|
||||||
@close="userInfoVisible = false"
|
<BasicModal
|
||||||
:title="infoParams.title"
|
v-model:visible="addPriceVisible"
|
||||||
:date="infoParams.date"
|
width="25rem"
|
||||||
:time="infoParams.time"
|
title="قیمت گذاری"
|
||||||
:type="infoParams.type"
|
@ok="confirmPrice"
|
||||||
:name="infoParams.name"
|
:loading="loading"
|
||||||
:items="infoParams.items"
|
@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>
|
</div>
|
||||||
<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>
|
|
||||||
<!-- <a-form-item label="نام چاپی" name="print_name" :rules="inputRules()">
|
|
||||||
<BasicInput v-model:value="form.print_name" />
|
|
||||||
</a-form-item>-->
|
|
||||||
</div>
|
|
||||||
</a-form>
|
|
||||||
</BasicModal>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// import BasicInfoModal from '@/components/BasicInfoModal'
|
import { inputRules } from '@/utils/inputRules'
|
||||||
import { inputLenRules, inputRules } from '@/utils/inputRules'
|
import { computed, ref } from 'vue'
|
||||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import tbl from './components/table.vue'
|
import tbl from './components/table.vue'
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
import type { FormInstance } from 'ant-design-vue'
|
||||||
import BasicInfoModal from '@/components/BasicInfoModal/index.vue'
|
|
||||||
import { message } from 'ant-design-vue/es'
|
import { message } from 'ant-design-vue/es'
|
||||||
import type { Info } from '@/components/BasicInfoModal/model/Info'
|
|
||||||
import { toJalaliNoTime, toTime } from '@core/utils/useDataTime'
|
|
||||||
import { confirmActOnApi, confirmDeleteItem } from '@/utils/confirmModal'
|
|
||||||
import { cloneDeep } from 'lodash'
|
|
||||||
import type { Item } from '@/model/Item'
|
|
||||||
import type { Customer } from '@/model/customer'
|
|
||||||
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
|
|
||||||
import type { Order } from '@/model/order'
|
|
||||||
import type { Price } from '@/model/price'
|
import type { Price } from '@/model/price'
|
||||||
import { createPrice } from '@/api/price'
|
import { createPrice, runPriceSync } from '@/api/price'
|
||||||
import { usePrice } from '@core/utils/usePrice'
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
import Icon from '@core/components/BaseIcon'
|
import { isStoreApp } from '@/utils/config'
|
||||||
|
import PriceSyncDetailModal from './components/PriceSyncDetailModal.vue'
|
||||||
|
import type { PriceSyncLog } from '@/model/priceSyncLog'
|
||||||
|
|
||||||
//loading
|
const loading = ref(false)
|
||||||
const loading = ref<boolean>(false)
|
const syncing = ref(false)
|
||||||
|
const table = ref<null | { fetch: () => void }>(null)
|
||||||
|
const refreshTable = () => table.value?.fetch()
|
||||||
|
|
||||||
//define store
|
const isStore = computed(() => isStoreApp())
|
||||||
const store = useStaticApiListsStore()
|
|
||||||
|
|
||||||
//define tbl
|
|
||||||
const table = ref(null)
|
|
||||||
const refreshTable = () => table?.value?.fetch()
|
|
||||||
|
|
||||||
let updateKey = ref<number>(0)
|
|
||||||
|
|
||||||
//role confirm items
|
|
||||||
const confirmItems: Array<Item> = [
|
|
||||||
{
|
|
||||||
value: 'بله',
|
|
||||||
key: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'خیر',
|
|
||||||
key: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
//form
|
|
||||||
const form = ref<Price>({})
|
const form = ref<Price>({})
|
||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
|
const addPriceVisible = ref(false)
|
||||||
|
const priceConfirmVisible = ref(false)
|
||||||
|
const detailVisible = ref(false)
|
||||||
|
const selectedLogId = ref<number | null>(null)
|
||||||
|
|
||||||
//info
|
function openDetail(record: PriceSyncLog) {
|
||||||
let infoParams = reactive<Info>({})
|
selectedLogId.value = record.id
|
||||||
|
detailVisible.value = true
|
||||||
/*
|
|
||||||
function info(val: Order) {
|
|
||||||
infoParams.name = val.customer.name
|
|
||||||
infoParams.type = val.customer.mobile
|
|
||||||
infoParams.date = toJalaliNoTime(val.created_at)
|
|
||||||
infoParams.time = toTime(val.created_at)
|
|
||||||
infoParams.itemsTitle = 'اطلاعات کاربری'
|
|
||||||
infoParams.items = [
|
|
||||||
{
|
|
||||||
key: 'مقدار (گرم)',
|
|
||||||
value: val.amount ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'قیمت هر گرم طلا برای مشتری (ریال)',
|
|
||||||
value: val.price ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'قیمت کل برای مشتری (ریال)',
|
|
||||||
value: val.total_price ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: '/قیمت هر گرم طلا بدون سود (ریال)',
|
|
||||||
value: val.price_original ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'قیمت کل بدون سود (ریال)',
|
|
||||||
value: val.total_price_original ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'سود هر گرم (ریال)',
|
|
||||||
value: val.fee ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'سود کل (ریال)',
|
|
||||||
value: val.total_fee ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'کد کاربری',
|
|
||||||
value: val.customer.id ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'شماره ملی',
|
|
||||||
value: val.customer.n_code ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'تاریخ تولد',
|
|
||||||
value: toJalaliNoTime(val.customer.birth_date) ?? '-'
|
|
||||||
},
|
|
||||||
/!* {
|
|
||||||
key: 'نام فروشگاه',
|
|
||||||
value: val.customer.shop_name ?? '-'
|
|
||||||
},*!/
|
|
||||||
{
|
|
||||||
key: 'شماره تلفن',
|
|
||||||
value: val.customer.phone_number ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'نام استان',
|
|
||||||
value: val.customer.province ?? '-'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'نام شهر',
|
|
||||||
value: val.customer.city ?? '-'
|
|
||||||
}
|
|
||||||
/!* {
|
|
||||||
key: 'نام چاپی',
|
|
||||||
value: val.print_name ?? '-'
|
|
||||||
}*!/
|
|
||||||
]
|
|
||||||
userInfoVisible.value = true
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//edit
|
async function handleSync() {
|
||||||
let editId: number | undefined = undefined
|
syncing.value = true
|
||||||
|
try {
|
||||||
/*
|
const res = await runPriceSync()
|
||||||
async function edit(record: Customer) {
|
message.success(res.message || 'انجام شد')
|
||||||
addPriceVisible.value = true
|
refreshTable()
|
||||||
editId = record.id
|
} catch (e) {
|
||||||
form.value = cloneDeep(record)
|
console.error(e)
|
||||||
|
message.error('خطا در بهروزرسانی قیمت')
|
||||||
|
} finally {
|
||||||
|
syncing.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//add
|
|
||||||
async function add() {
|
async function add() {
|
||||||
loading.value = true
|
|
||||||
editId = undefined
|
|
||||||
// await store.getUsersList()
|
|
||||||
addPriceVisible.value = true
|
addPriceVisible.value = true
|
||||||
updateKey.value++
|
|
||||||
resetData()
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
//reset data
|
|
||||||
const resetData = () => {
|
|
||||||
formRef.value?.resetFields()
|
|
||||||
form.value = {}
|
form.value = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete
|
|
||||||
// const deleteItem = (id: number) => confirmDeleteItem('کاربر', id, deleteCustomer, refreshTable)
|
|
||||||
|
|
||||||
//define selects
|
|
||||||
/*
|
|
||||||
onMounted(async () => {
|
|
||||||
loading.value = true
|
|
||||||
// await getResponsible()
|
|
||||||
// await getQC()
|
|
||||||
// await getManager()
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
|
|
||||||
//add project modal
|
|
||||||
const addPriceVisible = ref<boolean>(false)
|
|
||||||
const priceConfirmVisible = ref<boolean>(false)
|
|
||||||
|
|
||||||
//submit user
|
|
||||||
function confirmPrice() {
|
function confirmPrice() {
|
||||||
formRef.value?.validateFields().then(async () => {
|
formRef.value?.validateFields().then(async () => {
|
||||||
priceConfirmVisible.value = true
|
priceConfirmVisible.value = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ok() {
|
async function ok() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
@@ -247,10 +114,8 @@ async function ok() {
|
|||||||
refreshTable()
|
refreshTable()
|
||||||
priceConfirmVisible.value = false
|
priceConfirmVisible.value = false
|
||||||
addPriceVisible.value = false
|
addPriceVisible.value = false
|
||||||
// await confirmActOnApi('آیا از اعمال قیمت جدید اطمینان دارید؟', form.value, createPrice)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
// message.error('خطا در بارگذاری اطلاعات')
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import { cloneDeep } from 'lodash'
|
|||||||
function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
|
function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
|
||||||
const store = isStoreApp()
|
const store = isStoreApp()
|
||||||
|
|
||||||
|
if (route.name === 'pricing' && route.meta) {
|
||||||
|
route.meta.title = store ? 'تاریخچه قیمت' : 'قیمت گذاری'
|
||||||
|
}
|
||||||
|
|
||||||
if (!route.children?.length) return
|
if (!route.children?.length) return
|
||||||
|
|
||||||
for (const child of route.children) {
|
for (const child of route.children) {
|
||||||
@@ -26,6 +30,9 @@ function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
|
|||||||
if (child.name === 'productsMain_categories' && child.meta) {
|
if (child.name === 'productsMain_categories' && child.meta) {
|
||||||
child.meta.hideMenu = !store
|
child.meta.hideMenu = !store
|
||||||
}
|
}
|
||||||
|
if (child.name === 'pricingMain' && child.meta) {
|
||||||
|
child.meta.title = store ? 'تاریخچه قیمت' : 'قیمت گذاری'
|
||||||
|
}
|
||||||
applyAppModeMeta(child, appName)
|
applyAppModeMeta(child, appName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user