refactor(04): table order

This commit is contained in:
puriphatt 2024-08-16 16:05:34 +07:00
parent 266ee54e3b
commit 5c03a12aa9

View file

@ -270,6 +270,12 @@ const hideStat = ref(false);
const tbColumn = { const tbColumn = {
groupAndType: [ groupAndType: [
{
name: 'branchLabelNo',
align: 'center',
label: 'orderNumber',
field: 'branchNo',
},
{ {
name: 'name', name: 'name',
align: 'left', align: 'left',
@ -297,6 +303,12 @@ const tbColumn = {
], ],
product: [ product: [
{
name: 'branchLabelNo',
align: 'center',
label: 'orderNumber',
field: 'branchNo',
},
{ name: 'productName', align: 'left', label: 'productName', field: 'name' }, { name: 'productName', align: 'left', label: 'productName', field: 'name' },
{ {
name: 'productDetail', name: 'productDetail',
@ -318,6 +330,12 @@ const tbColumn = {
}, },
], ],
service: [ service: [
{
name: 'branchLabelNo',
align: 'center',
label: 'orderNumber',
field: 'branchNo',
},
{ name: 'serviceName', align: 'left', label: 'serviceName', field: 'name' }, { name: 'serviceName', align: 'left', label: 'serviceName', field: 'name' },
{ {
name: 'serviceDetail', name: 'serviceDetail',
@ -346,17 +364,31 @@ const tbColumn = {
const tbControl = reactive({ const tbControl = reactive({
groupAndType: { groupAndType: {
fieldDisplay: ['name', 'detail', 'formDialogInputRemark', 'createdAt'], fieldDisplay: [
fieldSelected: ['name', 'detail', 'formDialogInputRemark', 'createdAt'], { value: 'branchLabelNo', label: 'orderNumber' },
{ value: 'name', label: 'name' },
{ value: 'detail', label: 'detail' },
{ value: 'formDialogInputRemark', label: 'formDialogInputRemark' },
{ value: 'createdAt', label: 'createdAt' },
],
fieldSelected: [
'branchLabelNo',
'name',
'detail',
'formDialogInputRemark',
'createdAt',
],
}, },
product: { product: {
fieldDisplay: [ fieldDisplay: [
'productName', { value: 'branchLabelNo', label: 'orderNumber' },
'productDetail', { value: 'productName', label: 'productName' },
'productProcessingTime', { value: 'productDetail', label: 'productDetail' },
'priceInformation', { value: 'productProcessingTime', label: 'productProcessingTime' },
{ value: 'priceInformation', label: 'priceInformation' },
], ],
fieldSelected: [ fieldSelected: [
'branchLabelNo',
'productName', 'productName',
'productDetail', 'productDetail',
'productProcessingTime', 'productProcessingTime',
@ -365,12 +397,14 @@ const tbControl = reactive({
}, },
service: { service: {
fieldDisplay: [ fieldDisplay: [
'serviceName', { value: 'branchLabelNo', label: 'orderNumber' },
'serviceDetail', { value: 'serviceName', label: 'serviceName' },
'serviceWorkTotal', { value: 'serviceDetail', label: 'serviceDetail' },
'createdAt', { value: 'serviceWorkTotal', label: 'serviceWorkTotal' },
{ value: 'createdAt', label: 'createdAt' },
], ],
fieldSelected: [ fieldSelected: [
'branchLabelNo',
'serviceName', 'serviceName',
'serviceDetail', 'serviceDetail',
'serviceWorkTotal', 'serviceWorkTotal',
@ -1995,8 +2029,8 @@ watch(
for="select-field" for="select-field"
:options=" :options="
tbControl.groupAndType.fieldDisplay.map((x) => ({ tbControl.groupAndType.fieldDisplay.map((x) => ({
label: $t(x), label: $t(x.label),
value: x, value: x.value,
})) }))
" "
:hide-dropdown-icon="$q.screen.lt.sm" :hide-dropdown-icon="$q.screen.lt.sm"
@ -2134,6 +2168,24 @@ watch(
} }
" "
> >
<q-td
class="text-center"
v-if="
tbControl.groupAndType.fieldSelected.includes(
'branchLabelNo',
)
"
>
{{
productMode === 'type'
? (currentPageType - 1) * pageSizeType +
props.rowIndex +
1
: (currentPageGroup - 1) * pageSizeGroup +
props.rowIndex +
1
}}
</q-td>
<q-td <q-td
v-if=" v-if="
tbControl.groupAndType.fieldSelected.includes( tbControl.groupAndType.fieldSelected.includes(
@ -2698,8 +2750,8 @@ watch(
product: tbControl.product.fieldDisplay, product: tbControl.product.fieldDisplay,
service: tbControl.service.fieldDisplay, service: tbControl.service.fieldDisplay,
}[productAndServiceTab].map((x) => ({ }[productAndServiceTab].map((x) => ({
label: $t(x), label: $t(x.label),
value: x, value: x.value,
})) }))
" "
:display-value="$t('displayField')" :display-value="$t('displayField')"
@ -2883,11 +2935,40 @@ watch(
<template v-slot:body="props"> <template v-slot:body="props">
<q-tr <q-tr
:style="
props.rowIndex % 2 !== 0
? $q.dark.isActive
? 'background: hsl(var(--gray-11-hsl)/0.2)'
: `background: #f9fafc`
: ''
"
:class="{ :class="{
'app-text-muted': props.row.status === 'INACTIVE', 'app-text-muted': props.row.status === 'INACTIVE',
}" }"
:props="props" :props="props"
> >
<q-td
class="text-center"
v-if="
{
product: tbControl.product.fieldSelected,
service: tbControl.service.fieldSelected,
}[productAndServiceTab].includes(
{
product: 'branchLabelNo',
service: 'branchLabelNo',
}[productAndServiceTab],
)
"
>
{{
(currentPageServiceAndProduct - 1) *
pageSizeServiceAndProduct +
props.rowIndex +
1
}}
</q-td>
<q-td <q-td
v-if=" v-if="
{ {
@ -4572,8 +4653,8 @@ watch(
ref="refImageUpload" ref="refImageUpload"
v-model:dialogState="imageDialog" v-model:dialogState="imageDialog"
v-model:file="profileFileImg" v-model:file="profileFileImg"
v-model:image-url="profileUrl" :hidden-footer="!infoProductEdit && !infoServiceEdit"
:hidden-footer="!infoProductEdit" v-model:image-url="profileUrl as string"
clearButton clearButton
@save="handleImageUpload" @save="handleImageUpload"
> >