fix some bugs

This commit is contained in:
2026-06-23 22:31:07 +03:30
parent 4e7d6bca00
commit 71764f7e9a
68 changed files with 1941 additions and 1288 deletions
+168 -229
View File
@@ -1,239 +1,178 @@
import type { BaseTableColumn } from '@core/type/baseTable'
import { toJalali, toJalaliNoTime, toTime } from '@core/utils/useDataTime'
import { toJalali } from '@core/utils/useDataTime'
import CustomTag from '@/components/CustomTag.vue'
import { usePrice } from '@core/utils/usePrice'
/*import BudgetSelect from '@/components/BudgetSelect.vue'
import { useStaticApiListsStore } from '@/store/staticApisStore'
import type { FilterSelect } from '@/model/filterSelect'
import type { DocItem } from '@/model/docType'*/
import { formatAmountWithUnit } from '@/utils/weightUnit'
//define store
//const store = useStaticApiListsStore()
//document types
/*let docTypes: DocItem[]*/
/*onMounted(async () => {
docTypes = await store.readyDocTypeList()
})
const filteredDocTypes: FilterSelect = docTypes?.map((x: DocItem) => {
return {
label: x.title,
value: x.id
}
})*/
export type OrderMetalColumn = { metal_id: number; label: string; display_unit?: string }
export const cols: BaseTableColumn[] = [
{
title: 'ردیف',
dataIndex: 'id',
key: 'id',
filterable: false,
sortable: false,
customRender: (record: any) => {
return record.index + 1
}
},
{
title: 'کد سفارش',
dataIndex: 'id',
key: 'id',
type: 'Number'
// className: 'column-money'
},
{
title: 'نوع سفارش',
dataIndex: 'direction',
key: 'direction',
filterable: false,
customRender: ({ record }) => {
switch (record.direction) {
case 2:
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
فروش
</CustomTag>
</div>
)
case 1:
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
خرید
</CustomTag>
</div>
)
export function buildOrderColumns(_metals: OrderMetalColumn[] = []): BaseTableColumn[] {
return [
{
title: 'ردیف',
dataIndex: 'id',
key: 'id',
filterable: false,
sortable: false,
customRender: (record: any) => {
return record.index + 1
}
}
},
{
title: 'نام و نام خانوادگی',
dataIndex: 'customer.name',
key: 'customer.name',
type: 'Text'
},
{
title: 'شماره موبایل',
dataIndex: 'customer.mobile',
key: 'customer.mobile',
type: 'Number'
},
{
title: 'مقدار (گرم)',
dataIndex: 'amount',
key: 'amount',
type: 'Text'
},
/*{
title: 'کارمزد ریالی',
dataIndex: 'service_charge_price',
key: 'service_charge_price',
type: 'Number',
customRender(data) {
return usePrice(data.record?.service_charge_price ?? 0, true, '')
}
// className: 'column-money'
},*/
{
title: 'کارمزد طلایی',
dataIndex: 'service_charge',
key: 'service_charge',
type: 'Number',
customRender(data) {
return data.record?.service_charge
}
// className: 'column-money'
},
{
title: 'قیمت هر گرم طلا برای مشتری (ریال)',
dataIndex: 'price',
key: 'price',
type: 'Text',
customRender(data) {
return usePrice(data.record?.price ?? 0, true, '')
}
},
/* {
title: 'قیمت هر گرم طلا در لیمان',
dataIndex: 'limanPrice',
key: 'limanPrice',
type: 'Text',
customRender(data) {
return usePrice(data.record?.total_price_liman ?? 0, true, '')
}
},*/
{
title: 'قیمت کل برای مشتری (ریال)',
dataIndex: 'total_price',
key: 'total_price',
type: 'Text',
customRender(data) {
return usePrice(data.record?.total_price ?? 0, true, '')
}
},
{
title: 'وضعیت',
dataIndex: 'sts',
key: 'sts',
filterable: false,
customRender: ({ record }) => {
switch (record.sts) {
case 1:
return (
<div class="flex justify-center">
<CustomTag textColor="#ca8a04" bgColor="#fef3c7">
{record.sts_str}
</CustomTag>
</div>
)
case 2:
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
{record.sts_str}
</CustomTag>
</div>
)
default:
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
{record.sts_str}
</CustomTag>
</div>
)
},
{
title: 'کد سفارش',
dataIndex: 'id',
key: 'id',
type: 'Number'
},
{
title: 'نوع سفارش',
dataIndex: 'direction',
key: 'direction',
filterable: false,
customRender: ({ record }) => {
switch (record.direction) {
case 2:
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
فروش
</CustomTag>
</div>
)
case 1:
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
خرید
</CustomTag>
</div>
)
}
}
}
},
{
title: 'تاریخ ثبت',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalali(record.record.created_at)
}
},
/*{
title: 'نقش',
dataIndex: 'user_type_record',
key: 'user_type_record',
type: 'Select',
filterable: false,
sortable: false,
filterComponentProps: {
multiple: true
},
filterField: 'user_type_obj.id',
filterComponent: ReadyUserTypeSelect,
/!* customRender: (record: any) => {
return record.record.user_type_record?.value
}*!/
customRender: ({ record }) => {
const items = record.is_admin ? (
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
ادمین
},
{
title: 'نام و نام خانوادگی',
dataIndex: 'customer.name',
key: 'customer.name',
type: 'Text'
},
{
title: 'شماره موبایل',
dataIndex: 'customer.mobile',
key: 'customer.mobile',
type: 'Number'
},
{
title: 'نوع فلز',
dataIndex: 'order_metal_label',
key: 'order_metal_label',
type: 'Text',
filterable: false,
customRender({ record }) {
return (
<div class="flex justify-center">
<CustomTag textColor="#ca8a04" bgColor="#fef3c7" class={'font-bold px-6'}>
{record.order_metal_label ?? '-'}
</CustomTag>
) : (
record.user_type_obj.map((item: { title: any }, index: any) => {
if (item) {
return (
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
{item?.title}
</CustomTag>
)
}
})
)
return <div class="flex justify-center items-center gap-2">{items}</div>
</div>
)
}
},
{
title: 'مقدار',
dataIndex: 'amount',
key: 'amount',
type: 'Text',
customRender({ record }) {
const amount = record.amount_display ?? record.amount
return formatAmountWithUnit(amount, record.amount_unit)
}
},
{
title: 'کارمزد',
dataIndex: 'service_charge',
key: 'service_charge',
type: 'Number',
customRender({ record }) {
const value = record.service_charge
if (value == null || value === '') {
return '-'
}
},
{
title: 'حوزه',
dataIndex: 'section',
key: 'section'
},
{
title: 'شماره موبایل',
dataIndex: 'mobile',
type: 'Number',
key: 'mobile'
},
{
title: 'تاریخ ثبت',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalaliNoTime(record.record.created_at)
return formatAmountWithUnit(Number(value), record.amount_unit)
}
},
{
title: 'قیمت زمان معامله (ریال)',
dataIndex: 'price',
key: 'price',
type: 'Text',
customRender({ record }) {
return usePrice(record.price ?? 0, true, '')
}
},
{
title: 'قیمت کل برای مشتری (ریال)',
dataIndex: 'total_price',
key: 'total_price',
type: 'Text',
customRender(data) {
return usePrice(data.record?.total_price ?? 0, true, '')
}
},
{
title: 'وضعیت',
dataIndex: 'sts',
key: 'sts',
filterable: false,
customRender: ({ record }) => {
switch (record.sts) {
case 1:
return (
<div class="flex justify-center">
<CustomTag textColor="#ca8a04" bgColor="#fef3c7">
{record.sts_str}
</CustomTag>
</div>
)
case 2:
return (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
{record.sts_str}
</CustomTag>
</div>
)
default:
return (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
{record.sts_str}
</CustomTag>
</div>
)
}
},*/
{
title: 'عملیات',
dataIndex: 'action',
key: 'action',
slot: 'action',
fixed: 'right',
filterable: false
}
]
}
},
{
title: 'تاریخ ثبت',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalali(record.record.created_at)
}
},
{
title: 'عملیات',
dataIndex: 'action',
key: 'action',
slot: 'action',
fixed: 'right',
filterable: false
}
]
}
export function getOrderColumns(): BaseTableColumn[] {
return buildOrderColumns()
}