added table

This commit is contained in:
2026-08-16 20:01:54 +03:30
parent 27f3a6212a
commit 609f6b2fa3
17 changed files with 1227 additions and 39 deletions
@@ -0,0 +1,28 @@
<template>
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
<BasicShowContext title="تراکنش همکار">
<div class="min-w-0 w-full max-w-full overflow-x-auto">
<BaseTable v-bind="tblProps" @register="submit" />
</div>
</BasicShowContext>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { getColleagueOrderTable } from '@/api/order'
import { getColleagueOrderColumns } from '@/pages/menuPages/colleagueOrders/hooks/colleagueOrderColumns'
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
import type { TableInput } from '@core/type/baseTable'
const [submit, reload] = useBaseTable()
const tblProps = ref({
columns: getColleagueOrderColumns(),
api: (params: TableInput) => getColleagueOrderTable(params)
})
defineExpose({
fetch: reload
})
</script>
@@ -0,0 +1,134 @@
import type { BaseTableColumn } from '@core/type/baseTable'
import { toJalali } from '@core/utils/useDataTime'
import CustomTag from '@/components/CustomTag.vue'
import { usePrice } from '@core/utils/usePrice'
export function getColleagueOrderColumns(): BaseTableColumn[] {
return [
{
title: 'ردیف',
dataIndex: 'id',
key: 'row',
filterable: false,
sortable: false,
customRender: (record: any) => record.index + 1
},
{
title: 'کد سفارش',
dataIndex: 'id',
key: 'id',
type: 'Number'
},
{
title: 'کد همکار',
dataIndex: 'provider_id',
key: 'provider_id',
type: 'Number',
customRender: ({ record }) => record.provider_id ?? '-'
},
{
title: 'نوع',
dataIndex: 'direction',
key: 'direction',
filterable: false,
customRender: ({ record }) => {
if (record.direction === 2) {
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
فروش
</CustomTag>
</div>
)
}
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
خرید
</CustomTag>
</div>
)
}
},
{
title: 'مشتری',
dataIndex: 'customer.name',
key: 'customer.name',
type: 'Text'
},
{
title: 'مقدار مشتری (گرم)',
dataIndex: 'customer_amount',
key: 'customer_amount',
type: 'Number',
filterable: false,
customRender: ({ record }) => record.customer_amount ?? record.amount ?? '-'
},
{
title: 'مقدار نزد همکار (گرم)',
dataIndex: 'colleague_amount',
key: 'colleague_amount',
type: 'Number',
filterable: false,
customRender: ({ record }) => record.colleague_amount ?? record.amount ?? '-'
},
{
title: 'کارمزد',
dataIndex: 'service_charge',
key: 'service_charge',
type: 'Number',
customRender: ({ record }) => {
if (record.fee_asset === 'rial') {
return usePrice(record.service_charge_price ?? 0, true, '')
}
const gold = record.service_charge ?? 0
return `${gold} گرم`
}
},
{
title: 'قیمت مشتری (ریال)',
dataIndex: 'price',
key: 'price',
type: 'Text',
customRender: ({ record }) => usePrice(record.price ?? 0, true, '')
},
{
title: 'مبلغ مشتری (ریال)',
dataIndex: 'total_price',
key: 'total_price',
type: 'Text',
customRender: ({ record }) => usePrice(record.total_price ?? 0, true, '')
},
{
title: 'نرخ همکار (ریال/گرم)',
dataIndex: 'colleague_unit_price',
key: 'colleague_unit_price',
type: 'Text',
filterable: false,
customRender: ({ record }) =>
usePrice(record.colleague_unit_price ?? record.total_price_montzar ?? 0, true, '')
},
{
title: 'مبلغ نزد همکار (ریال)',
dataIndex: 'colleague_total_price',
key: 'colleague_total_price',
type: 'Text',
filterable: false,
customRender: ({ record }) => usePrice(record.colleague_total_price ?? 0, true, '')
},
{
title: 'سود کل (ریال)',
dataIndex: 'total_fee',
key: 'total_fee',
type: 'Text',
customRender: ({ record }) => usePrice(record.total_fee ?? 0, true, '')
},
{
title: 'تاریخ',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => toJalali(record.record.created_at)
}
]
}
@@ -0,0 +1,16 @@
<template>
<div>
<BasicMainCard>
<div class="flex h-full w-full min-w-0 max-w-full flex-col overflow-hidden">
<tbl ref="table" class="min-h-0 flex-1" />
</div>
</BasicMainCard>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import tbl from './components/table.vue'
const table = ref<InstanceType<typeof tbl> | null>(null)
</script>