refactor: datetime function
This commit is contained in:
parent
23e05efd24
commit
9bedf5f2fe
1 changed files with 24 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { QTableProps, QTableSlots } from 'quasar';
|
||||
|
||||
import QuotationCard from 'src/components/05_quotation/QuotationCard.vue';
|
||||
|
|
@ -6,11 +7,12 @@ import BadgeComponent from 'src/components/BadgeComponent.vue';
|
|||
import KebabAction from 'src/components/shared/KebabAction.vue';
|
||||
|
||||
import useOptionStore from 'src/stores/options';
|
||||
import { dateFormatJS, dateFormat } from 'src/utils/datetime';
|
||||
import { TaskOrder, TaskOrderStatus } from 'src/stores/task-order/types';
|
||||
import { column } from './constants';
|
||||
import { ref } from 'vue';
|
||||
import { dateFormatJS } from 'src/utils/datetime';
|
||||
import { TaskOrder, TaskOrderStatus } from 'src/stores/task-order/types';
|
||||
import { Lang } from 'src/utils/ui';
|
||||
|
||||
const optionStore = useOptionStore();
|
||||
const selectedTask = defineModel<TaskOrder[]>('selectedTask', { default: [] });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
|
|
@ -78,14 +80,13 @@ function getCreatedByName(
|
|||
locale?: string;
|
||||
},
|
||||
) {
|
||||
const createdBy = record.createdBy;
|
||||
|
||||
return (
|
||||
{
|
||||
['eng']: `${useOptionStore().mapOption(createdBy?.namePrefix) || ''} ${createdBy?.firstNameEN} ${createdBy?.lastNameEN}`,
|
||||
['tha']: `${useOptionStore().mapOption(createdBy?.namePrefix) || ''} ${createdBy?.firstName} ${createdBy?.lastName}`,
|
||||
}[opts?.locale || 'eng'] || '-'
|
||||
);
|
||||
const _user = record.createdBy;
|
||||
switch (opts?.locale) {
|
||||
case Lang.English:
|
||||
return `${optionStore.mapOption(_user?.namePrefix) || ''} ${_user?.firstNameEN} ${_user?.lastNameEN}`;
|
||||
default:
|
||||
return `${optionStore.mapOption(_user?.namePrefix) || ''} ${_user?.firstName} ${_user?.lastName}`;
|
||||
}
|
||||
}
|
||||
|
||||
function openList(index: number, data: TaskOrder) {
|
||||
|
|
@ -171,10 +172,15 @@ const emit = defineEmits<{
|
|||
dateFormatJS({
|
||||
date: props.row.createdAt,
|
||||
dayStyle: '2-digit',
|
||||
monthStyle: '2-digit',
|
||||
monthStyle: 'short',
|
||||
}) || '-'
|
||||
}}
|
||||
{{ dateFormat(props.row.createdAt, false, true) }}
|
||||
{{
|
||||
dateFormatJS({
|
||||
date: props.row.createdAt,
|
||||
timeOnly: true,
|
||||
})
|
||||
}}
|
||||
</q-td>
|
||||
<q-td v-if="visibleColumns.includes('createdBy')" class="text-left">
|
||||
{{ getCreatedByName(props.row, $i18n) }}
|
||||
|
|
@ -272,8 +278,11 @@ const emit = defineEmits<{
|
|||
value: `${dateFormatJS({
|
||||
date: props.row.createdAt,
|
||||
dayStyle: '2-digit',
|
||||
monthStyle: '2-digit',
|
||||
})} ${dateFormat(props.row.createdAt, false, true)}`,
|
||||
monthStyle: 'short',
|
||||
})} ${dateFormatJS({
|
||||
date: props.row.createdAt,
|
||||
timeOnly: true,
|
||||
})}`,
|
||||
},
|
||||
{
|
||||
label: $t('taskOrder.madeBy'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue