fix(admin): Jalali dates in grids and legacy order-status tags
The API sends ISO timestamps where legacy sent formatted Jalali strings, so every grid printed "2026-07-25T12:32:29.000Z". Date columns now render 1405/5/3-16:02. The order-status column is a green/red «فعال/عدم سفارش» tag again (Customer::$STS), not bare «مجاز». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
29084904e9
commit
38ce3d2488
@@ -130,6 +130,7 @@
|
|||||||
<template v-if="slotNameFor(column)">
|
<template v-if="slotNameFor(column)">
|
||||||
<slot :name="slotNameFor(column)" :text="text" :record="record" />
|
<slot :name="slotNameFor(column)" :text="text" :record="record" />
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="column.__date">{{ gridDate(text) }}</template>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,6 +141,7 @@ import { computed, onMounted, reactive, ref } from 'vue';
|
|||||||
import { FilterOutlined, PrinterOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons-vue';
|
import { FilterOutlined, PrinterOutlined, ReloadOutlined, SettingOutlined } from '@ant-design/icons-vue';
|
||||||
import api from '../../api/client';
|
import api from '../../api/client';
|
||||||
import type { XTbl } from './model';
|
import type { XTbl } from './model';
|
||||||
|
import { gridDate } from '../../utils/filters';
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -224,6 +226,7 @@ const antColumns = computed(() =>
|
|||||||
sorter: c.__sorter,
|
sorter: c.__sorter,
|
||||||
width: c.width,
|
width: c.width,
|
||||||
__slot: c.scopedSlots?.customRender,
|
__slot: c.scopedSlots?.customRender,
|
||||||
|
__date: c.filterType === 'date',
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,19 @@ export function jdate(val: unknown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Jalali date+time. Legacy used 12-hour 'hh' here — preserved. */
|
/** Jalali date+time. Legacy used 12-hour 'hh' here — preserved. */
|
||||||
|
/**
|
||||||
|
* A date column in an XTable grid. The legacy API sent `caj`/`uaj`/… already
|
||||||
|
* formatted (Selector::convertDate, Jalalian) and the grid printed the string;
|
||||||
|
* the new API sends an ISO timestamp, which the grid printed raw
|
||||||
|
* ("2026-07-25T12:32:29.000Z"). Same shape the legacy screen shows:
|
||||||
|
* 1405/5/3-16:02, in the viewer's local (Tehran) time. Anything that is not
|
||||||
|
* an ISO timestamp is returned untouched.
|
||||||
|
*/
|
||||||
|
export function gridDate(val: unknown) {
|
||||||
|
if (typeof val !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(val)) return val;
|
||||||
|
return moment(val).format('jYYYY/jM/jD-HH:mm');
|
||||||
|
}
|
||||||
|
|
||||||
export function jdateTime(val: unknown) {
|
export function jdateTime(val: unknown) {
|
||||||
if (val) {
|
if (val) {
|
||||||
return moment(val as string).format('jYYYY/jMM/jDD - hh:mm:ss');
|
return moment(val as string).format('jYYYY/jMM/jDD - hh:mm:ss');
|
||||||
|
|||||||
@@ -31,8 +31,9 @@
|
|||||||
<div v-else>-</div>
|
<div v-else>-</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- legacy OmdeList.vue:182-185: a green/red tag, not bare text -->
|
||||||
<template #sts="{ record }">
|
<template #sts="{ record }">
|
||||||
{{ record.sts_str }}
|
<a-tag :color="record.sts === 1 ? 'green' : 'red'">{{ record.sts_str }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #active="{ record }">
|
<template #active="{ record }">
|
||||||
|
|||||||
@@ -32,8 +32,9 @@
|
|||||||
<div v-else>-</div>
|
<div v-else>-</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- legacy ReagentList.vue:75-78: a green/red tag, not bare text -->
|
||||||
<template #sts="{ record }">
|
<template #sts="{ record }">
|
||||||
{{ record.sts_str }}
|
<a-tag :color="record.sts === 1 ? 'green' : 'red'">{{ record.sts_str }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #active="{ record }">
|
<template #active="{ record }">
|
||||||
|
|||||||
Reference in New Issue
Block a user