refactor(04): service group (unfinish)
This commit is contained in:
parent
91c9dfaa95
commit
4199b0e549
1 changed files with 131 additions and 72 deletions
|
|
@ -145,6 +145,8 @@ const stat = ref<
|
|||
const { t } = useI18n();
|
||||
const baseUrl = ref<string>(import.meta.env.VITE_API_BASE_URL);
|
||||
|
||||
const isWorkProductGroup = ref(false);
|
||||
const workProductGroupName = ref('');
|
||||
const holdDialog = ref(false);
|
||||
const imageDialog = ref(false);
|
||||
const currentNode = ref<ProductGroup>();
|
||||
|
|
@ -3646,12 +3648,23 @@ watch(
|
|||
:submit="
|
||||
() => {
|
||||
selectProduct.forEach((i) => {
|
||||
workItems[currentWorkIndex].product.push({
|
||||
...i,
|
||||
nameEn: '',
|
||||
});
|
||||
const productExists = workItems[currentWorkIndex].product.some(
|
||||
(product) => product.id === i.id,
|
||||
);
|
||||
if (!productExists) {
|
||||
workItems[currentWorkIndex].product.push({
|
||||
...i,
|
||||
nameEn: '',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
workItems[currentWorkIndex].product = workItems[
|
||||
currentWorkIndex
|
||||
].product.filter((product) =>
|
||||
selectProduct.some((i) => i.id === product.id),
|
||||
);
|
||||
|
||||
dialogTotalProduct = false;
|
||||
selectProduct = [];
|
||||
}
|
||||
|
|
@ -3663,9 +3676,57 @@ watch(
|
|||
}
|
||||
"
|
||||
>
|
||||
<div class="full-width full-height q-pa-lg">
|
||||
<div class="row items-center">
|
||||
<q-space />
|
||||
<div class="q-pa-lg full-height scroll column">
|
||||
<div class="row items-center justify-between">
|
||||
<div class="row">
|
||||
<q-checkbox
|
||||
:label="$t('selectAll')"
|
||||
:model-value="selectProduct.length === productIsAdd?.length"
|
||||
@click="
|
||||
() => {
|
||||
if (selectProduct.length === productIsAdd?.length) {
|
||||
selectProduct = [];
|
||||
} else {
|
||||
productIsAdd?.forEach((i) => {
|
||||
const productExists = selectProduct.some(
|
||||
(product) => product.id === i.id,
|
||||
);
|
||||
if (!productExists) {
|
||||
selectProduct.push({ ...i });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
"
|
||||
/>
|
||||
<q-btn
|
||||
flat
|
||||
:icon="isWorkProductGroup ? 'mdi-ungroup' : 'mdi-group'"
|
||||
class="rounded q-ml-lg q-mr-sm"
|
||||
padding="4px 8px"
|
||||
style="color: hsl(var(--text-mute-2))"
|
||||
@click="
|
||||
() => {
|
||||
isWorkProductGroup = !isWorkProductGroup;
|
||||
if (!isWorkProductGroup) workProductGroupName = '';
|
||||
}
|
||||
"
|
||||
>
|
||||
<q-tooltip>สร้างกลุ่ม</q-tooltip>
|
||||
</q-btn>
|
||||
<q-input
|
||||
v-if="isWorkProductGroup"
|
||||
dense
|
||||
outlined
|
||||
clearable
|
||||
v-model="workProductGroupName"
|
||||
style="width: 400px"
|
||||
>
|
||||
<template #prepend>
|
||||
<div class="text-caption text-black">ชื่อกลุ่ม:</div>
|
||||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<q-input
|
||||
lazy-rules="ondemand"
|
||||
id="input-search-add-product"
|
||||
|
|
@ -3683,76 +3744,72 @@ watch(
|
|||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<div>
|
||||
<AppBox
|
||||
no-padding
|
||||
class="row q-mt-md q-col-gutter-sm"
|
||||
style="background: none"
|
||||
|
||||
<div class="row q-mt-md q-col-gutter-md col">
|
||||
<div
|
||||
class="flex col justify-center items-center"
|
||||
v-if="resultSearchProduct?.length === 0"
|
||||
>
|
||||
<div
|
||||
class="col-12 text-center"
|
||||
v-if="resultSearchProduct?.length === 0"
|
||||
>
|
||||
<NoData />
|
||||
</div>
|
||||
<NoData />
|
||||
</div>
|
||||
|
||||
<div
|
||||
:class="`${$q.screen.gt.sm ? 'col-3 ' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`"
|
||||
v-for="i in (!!inputSearchProductAndService
|
||||
? resultSearchProduct
|
||||
: productIsAdd
|
||||
)?.filter((i) => {
|
||||
if (i.status === 'INACTIVE') {
|
||||
return false;
|
||||
<div
|
||||
class="col-md-3 col-sm-6 col-12"
|
||||
v-for="i in (!!inputSearchProductAndService
|
||||
? resultSearchProduct
|
||||
: productIsAdd
|
||||
)?.filter((i) => {
|
||||
if (i.status === 'INACTIVE') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})"
|
||||
:key="i.id"
|
||||
>
|
||||
<TotalProductCardComponent
|
||||
no-time-img
|
||||
:index="selectProduct.findIndex((v) => v.id === i.id)"
|
||||
:isAddProduct="!!selectProduct.find((v) => v.id === i.id)"
|
||||
:isSelected="true"
|
||||
:data="{ ...i, type: 'product' }"
|
||||
:title="i.name"
|
||||
:status="i.status === 'INACTIVE' ? true : false"
|
||||
@menuViewDetail="
|
||||
() => {
|
||||
currentIdProduct = i.id;
|
||||
assignFormDataProduct(i);
|
||||
dialogProductEdit = true;
|
||||
}
|
||||
return true;
|
||||
})"
|
||||
:key="i.id"
|
||||
>
|
||||
<TotalProductCardComponent
|
||||
:index="selectProduct.findIndex((v) => v.id === i.id)"
|
||||
:isAddProduct="!!selectProduct.find((v) => v.id === i.id)"
|
||||
:isSelected="true"
|
||||
:data="{ ...i, type: 'product' }"
|
||||
:title="i.name"
|
||||
:status="i.status === 'INACTIVE' ? true : false"
|
||||
@menuViewDetail="
|
||||
() => {
|
||||
currentIdProduct = i.id;
|
||||
assignFormDataProduct(i);
|
||||
dialogProductEdit = true;
|
||||
}
|
||||
"
|
||||
@menuEdit="
|
||||
() => {
|
||||
currentIdProduct = i.id;
|
||||
infoProductEdit = true;
|
||||
assignFormDataProduct(i);
|
||||
dialogProductEdit = true;
|
||||
}
|
||||
"
|
||||
@viewDetail="
|
||||
() => {
|
||||
currentIdProduct = i.id;
|
||||
infoProductEdit = false;
|
||||
assignFormDataProduct(i);
|
||||
dialogProductEdit = true;
|
||||
}
|
||||
"
|
||||
@select="
|
||||
(data) => {
|
||||
const tempValue = selectProduct.find((v) => v.id === i.id);
|
||||
"
|
||||
@menuEdit="
|
||||
() => {
|
||||
currentIdProduct = i.id;
|
||||
infoProductEdit = true;
|
||||
assignFormDataProduct(i);
|
||||
dialogProductEdit = true;
|
||||
}
|
||||
"
|
||||
@viewDetail="
|
||||
() => {
|
||||
currentIdProduct = i.id;
|
||||
infoProductEdit = false;
|
||||
assignFormDataProduct(i);
|
||||
dialogProductEdit = true;
|
||||
}
|
||||
"
|
||||
@select="
|
||||
(data) => {
|
||||
const tempValue = selectProduct.find((v) => v.id === i.id);
|
||||
|
||||
if (tempValue) {
|
||||
selectProduct = selectProduct.filter((v) => v.id !== i.id);
|
||||
} else {
|
||||
selectProduct.push(data);
|
||||
}
|
||||
if (tempValue) {
|
||||
selectProduct = selectProduct.filter((v) => v.id !== i.id);
|
||||
} else {
|
||||
selectProduct.push(data);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</AppBox>
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogForm>
|
||||
|
|
@ -4155,6 +4212,7 @@ watch(
|
|||
async (index) => {
|
||||
await fetchListOfProductIsAdd(currentIdType);
|
||||
currentWorkIndex = index;
|
||||
selectProduct = workItems[currentWorkIndex].product;
|
||||
dialogTotalProduct = true;
|
||||
}
|
||||
"
|
||||
|
|
@ -4374,6 +4432,7 @@ watch(
|
|||
async (index) => {
|
||||
await fetchListOfProductIsAdd(currentIdType);
|
||||
currentWorkIndex = index;
|
||||
selectProduct = workItems[currentWorkIndex].product;
|
||||
dialogTotalProduct = true;
|
||||
}
|
||||
"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue