diff --git a/src/components/TreeComponent.vue b/src/components/TreeComponent.vue index 10315eae..a1536fd2 100644 --- a/src/components/TreeComponent.vue +++ b/src/components/TreeComponent.vue @@ -51,7 +51,10 @@ defineEmits<{ class="full-width q-py-xs" :class="{ 'clickable-node': typeTree === 'product' || node.isHeadOffice, - 'cursor-pointer': node.type === 'group' || node.type === 'type', + 'cursor-pointer': + node.type === 'group' || + node.type === 'type' || + node.type === 'productService', 'active-node': expandedTree[expandedTree.length - 1] === node.id, }" v-touch-hold.mouse="() => $emit('handleHold', node)" @@ -65,7 +68,7 @@ defineEmits<{
([ { @@ -119,13 +119,6 @@ const stat = ref< mode: 'group', color: 'pink', }, - { - icon: 'mdi-folder-table-outline', - count: 0, - label: 'productService.type.title', - mode: 'type', - color: 'purple', - }, { icon: 'mdi-server-outline', count: 0, @@ -172,33 +165,29 @@ const imageDialog = ref(false); const currentNode = ref(); const expandedTree = ref([]); const editByTree = ref<'group' | 'type' | undefined>(); + const treeProductTypeAndGroup = computed( () => productGroup.value?.map((item) => ({ ...item, _count: { - type: item._count.type, service: item._count.service, product: item._count.product, }, type: 'group', actionDisabled: item.status === 'INACTIVE', - children: - item.id === currentIdGrop.value - ? (recordTreeProductType.value[currentIdGrop.value]?.map((x) => ({ - ...x, - type: 'type', - actionDisabled: item.status === 'INACTIVE', - })) ?? []) - : (recordTreeProductType.value[item.id]?.map((x) => ({ - ...x, - actionDisabled: item.status === 'INACTIVE', - type: 'type', - })) ?? item._count.type > 0) - ? [{ id: '', name: '', actionDisabled: item.status === 'INACTIVE' }] - : [], + children: [ + { id: 'type', name: 'ประเภท', type: 'type', actionDisabled: true }, + { + id: 'productService', + name: 'สินค้าและบริการ', + type: 'productService', + actionDisabled: true, + }, + ], })) ?? [], ); + const profileFileImg = ref(null); const refImageUpload = ref>(); @@ -230,11 +219,10 @@ const pathGroupName = ref(''); const pathTypeName = ref(''); const dialogTotalProduct = ref(false); -const productMode = ref<'group' | 'type' | 'service' | 'product'>('group'); +const productMode = ref<'group' | 'service' | 'product'>('group'); const productTab = ref(1); const productGroup = ref(); -const productType = ref(); const product = ref<(ProductList & { type: 'product' })[]>(); const productIsAdd = ref<(ProductList & { type: 'product' })[]>(); const service = ref<(Service & { type: 'service' })[]>(); @@ -254,8 +242,10 @@ const formDataGroup = ref({ }); const formDataProduct = ref({ + expenseType: '', + vatIncluded: true, registeredBranchId: '', - productTypeId: '', + productGroupId: '', remark: '', serviceCharge: 0, agentPrice: 0, @@ -275,7 +265,7 @@ const formDataProductService = ref({ detail: '', name: '', code: '', - productTypeId: '', + productGroupId: '', registeredBranchId: '', }); @@ -334,12 +324,24 @@ const tbColumn = { label: 'general.detail', field: 'detail', }, + { + name: 'productExpenseType', + align: 'left', + label: 'productService.product.expenseType', + field: 'expenseType', + }, { name: 'productProcessingTime', align: 'left', label: 'productService.product.processingTimeDay', field: 'process', }, + { + name: 'productVat', + align: 'left', + label: 'productService.product.vat', + field: 'expenseType', + }, { name: 'priceInformation', align: 'center', @@ -406,11 +408,19 @@ const tbControl = reactive({ fieldDisplay: [ { value: 'branchLabelNo', label: 'general.order' }, { value: 'productName', label: 'general.name' }, + { + value: 'productExpenseType', + label: 'productService.product.expenseType', + }, { value: 'productDetail', label: 'general.detail' }, { value: 'productProcessingTime', label: 'productService.product.processingTimeDay', }, + { + value: 'productVat', + label: 'productService.product.vat', + }, { value: 'priceInformation', label: 'productService.product.priceInformation', @@ -419,8 +429,10 @@ const tbControl = reactive({ fieldSelected: [ 'branchLabelNo', 'productName', + 'productExpenseType', 'productDetail', 'productProcessingTime', + 'productVat', 'priceInformation', ], }, @@ -455,7 +467,7 @@ const totalProduct = ref(0); const totalService = ref(0); const totalProductAndService = ref(0); -const filterStat = ref<('group' | 'type' | 'service' | 'product')[]>([]); +const filterStat = ref<('group' | 'service' | 'product')[]>([]); // แบ่งหน้า const currentPageGroup = ref(1); @@ -544,27 +556,27 @@ async function fetchListOfOptionBranch() { currentMyBranch.value?.id || ''; } -async function fetchListType() { - const res = await fetchListProductServiceType({ - page: currentPageType.value, - pageSize: pageSizeType.value, - query: !!inputSearch.value ? inputSearch.value : undefined, - productGroupId: currentIdGrop.value, - status: - currentStatus.value === 'All' - ? undefined - : currentStatus.value === 'ACTIVE' - ? 'ACTIVE' - : 'INACTIVE', - }); +// async function fetchListType() { +// const res = await fetchListProductServiceType({ +// page: currentPageType.value, +// pageSize: pageSizeType.value, +// query: !!inputSearch.value ? inputSearch.value : undefined, +// productGroupId: currentIdGrop.value, +// status: +// currentStatus.value === 'All' +// ? undefined +// : currentStatus.value === 'ACTIVE' +// ? 'ACTIVE' +// : 'INACTIVE', +// }); - if (res) { - currentPageType.value = res.page; - totalType.value = res.total; - maxPageType.value = Math.ceil(res.total / pageSizeType.value); - productType.value = res.result; - } -} +// if (res) { +// currentPageType.value = res.page; +// totalType.value = res.total; +// maxPageType.value = Math.ceil(res.total / pageSizeType.value); +// productType.value = res.result; +// } +// } async function fetchListGroups() { const res = await fetchListProductService({ @@ -587,7 +599,7 @@ async function fetchListGroups() { } } -async function fetchListOfProductIsAdd(productTypeId: string) { +async function fetchListOfProductIsAdd(productGroupId: string) { const res = await fetchListProduct({ status: currentStatus.value === 'INACTIVE' @@ -595,7 +607,7 @@ async function fetchListOfProductIsAdd(productTypeId: string) { : currentStatus.value === 'ACTIVE' ? 'ACTIVE' : undefined, - productTypeId, + productGroupId, }); if (res) { @@ -621,7 +633,7 @@ async function fetchListOfProduct() { : currentStatus.value === 'ACTIVE' ? 'ACTIVE' : undefined, - productTypeId: currentIdType.value, + productGroupId: currentIdGrop.value, }); if (res) { @@ -654,7 +666,7 @@ async function fetchListOfService() { : currentStatus.value === 'ACTIVE' ? 'ACTIVE' : undefined, - productTypeId: currentIdType.value, + productGroupId: currentIdGrop.value, }); if (res) { @@ -673,27 +685,27 @@ async function fetchListOfService() { } } -async function submitType() { - if (drawerInfo.value) { - await editProductServiceType(currentIdType.value, { - ...formDataGroup.value, - productGroupId: currentIdGrop.value, - }); - drawerInfo.value = false; - } else { - dialogInputForm.value = false; - const res = await createProductServiceType( - currentIdGrop.value, - formDataGroup.value, - ); +// async function submitType() { +// if (drawerInfo.value) { +// await editProductServiceType(currentIdType.value, { +// ...formDataGroup.value, +// productGroupId: currentIdGrop.value, +// }); +// drawerInfo.value = false; +// } else { +// dialogInputForm.value = false; +// const res = await createProductServiceType( +// currentIdGrop.value, +// formDataGroup.value, +// ); - if (res) { - stat.value[1].count = stat.value[1].count + 1; - } - } +// if (res) { +// stat.value[1].count = stat.value[1].count + 1; +// } +// } - await fetchListType(); -} +// await fetchListType(); +// } async function toggleStatusProduct(id: string, status: Status) { const res = await editProduct(id, { @@ -714,15 +726,15 @@ async function toggleStatusService(id: string, status: Status) { await alternativeFetch(); flowStore.rotate(); } -async function toggleStatusType(id: string, status: Status) { - const res = await editProductServiceType(id, { - status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', - }); - if (res) currentStatusGroupType.value = res.status; +// async function toggleStatusType(id: string, status: Status) { +// const res = await editProductServiceType(id, { +// status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE', +// }); +// if (res) currentStatusGroupType.value = res.status; - await fetchListType(); - flowStore.rotate(); -} +// await fetchListType(); +// flowStore.rotate(); +// } async function toggleStatusGroup(id: string, status: Status) { const res = await editProductService(id, { @@ -737,7 +749,7 @@ async function toggleStatusGroup(id: string, status: Status) { async function triggerChangeStatus( id: string, status: string, - type?: 'type' | 'group' | 'service' | 'product', + type?: 'group' | 'service' | 'product', ) { return await new Promise((resolve, reject) => { dialog({ @@ -756,10 +768,6 @@ async function triggerChangeStatus( const res = await toggleStatusGroup(id, status as Status) .then(resolve) .catch(reject); - } else if (type === 'type' || productMode.value === 'type') { - await toggleStatusType(id, status as Status) - .then(resolve) - .catch(reject); } else if (type === 'service') { await toggleStatusService(id, status as Status) .then(resolve) @@ -847,11 +855,11 @@ async function deleteProductById(productId?: string) { message: t('dialog.message.confirmDelete'), action: async () => { if (editByTree.value !== undefined) { - if (editByTree.value === 'type') { - // Product Type - await deleteProductServiceType(productId ?? currentIdType.value); - await fetchListType(); - } + // if (editByTree.value === 'type') { + // // Product Type + // await deleteProductServiceType(productId ?? currentIdType.value); + // await fetchListType(); + // } if (editByTree.value === 'group') { // Product Group const res = await deleteProductService( @@ -867,11 +875,11 @@ async function deleteProductById(productId?: string) { editByTree.value = undefined; drawerInfo.value = false; } else { - if (productMode.value === 'type') { - // Product Type - await deleteProductServiceType(productId ?? currentIdType.value); - await fetchListType(); - } + // if (productMode.value === 'type') { + // // Product Type + // await deleteProductServiceType(productId ?? currentIdType.value); + // await fetchListType(); + // } if (productMode.value === 'group') { // Product Group const res = await deleteProductService( @@ -923,7 +931,7 @@ const prevService = ref({ detail: '', name: '', code: '', - productTypeId: '', + productGroupId: '', registeredBranchId: '', }); @@ -947,7 +955,7 @@ async function assignFormDataProductService(id: string) { attributes: res.attributes, work: [], status: res.status, - productTypeId: res.productTypeId, + productGroupId: res.productGroupId, registeredBranchId: res.registeredBranchId, }; @@ -983,7 +991,9 @@ async function assignFormDataProductService(id: string) { const currentNoAction = ref(false); const prevProduct = ref({ - productTypeId: '', + expenseType: '', + vatIncluded: true, + productGroupId: '', remark: '', serviceCharge: 0, agentPrice: 0, @@ -1004,7 +1014,7 @@ function assignFormDataProduct(data: ProductList) { profileSubmit.value = true; prevProduct.value = { - productTypeId: data.productTypeId, + productGroupId: data.productGroupId, remark: data.remark, serviceCharge: data.serviceCharge, agentPrice: data.agentPrice, @@ -1016,6 +1026,8 @@ function assignFormDataProduct(data: ProductList) { image: undefined, registeredBranchId: data.registeredBranchId, status: data.status, + expenseType: data.expenseType, + vatIncluded: data.vatIncluded, }; formDataProduct.value = { ...prevProduct.value }; @@ -1034,7 +1046,7 @@ function clearFormGroup() { function clearFormProduct() { formDataProduct.value = { - productTypeId: '', + productGroupId: '', remark: '', serviceCharge: 0, agentPrice: 0, @@ -1045,6 +1057,8 @@ function clearFormProduct() { code: '', image: undefined, registeredBranchId: '', + expenseType: '', + vatIncluded: true, }; imageProduct.value = undefined; dialogProduct.value = false; @@ -1063,7 +1077,7 @@ function clearFormService() { }, work: [], status: undefined, - productTypeId: '', + productGroupId: '', registeredBranchId: '', }; @@ -1090,12 +1104,12 @@ function assignFormDataProductServiceCreate() { async function submitService() { assignFormDataProductServiceCreate(); - formDataProductService.value.productTypeId = currentIdType.value; + formDataProductService.value.productGroupId = currentIdGrop.value; if (profileFileImg.value) formDataProductService.value.image = profileFileImg.value; if (dialogService.value) { - formDataProductService.value.productTypeId = currentIdType.value; + formDataProductService.value.productGroupId = currentIdGrop.value; if (formDataProductService.value.registeredBranchId === '') { formDataProductService.value.registeredBranchId = null; @@ -1111,7 +1125,7 @@ async function submitService() { const res = await createService(formDataProductService.value); if (res) { - stat.value[2].count = stat.value[2].count + 1; + stat.value[1].count = stat.value[1].count + 1; } totalService.value = totalService.value + 1; productAndServiceTab.value = 'service'; @@ -1135,7 +1149,7 @@ async function submitService() { } async function submitProduct() { - formDataProduct.value.productTypeId = currentIdType.value; + formDataProduct.value.productGroupId = currentIdGrop.value; if (profileFileImg.value) { formDataProduct.value.image = profileFileImg.value; // formDataProduct.value.image = imageProduct.value; @@ -1152,7 +1166,7 @@ async function submitProduct() { const res = await createProduct(formDataProduct.value); if (res) { - stat.value[3].count = stat.value[3].count + 1; + stat.value[2].count = stat.value[2].count + 1; } productAndServiceTab.value = 'product'; @@ -1170,7 +1184,6 @@ async function submitProduct() { if (productAndServiceTab.value === 'product') { await fetchListOfProduct(); } - flowStore.rotate(); } @@ -1241,14 +1254,12 @@ function openPropertiesDialog(type: 'service' | 'work') { async function calculateStats() { const resStatsGroup = await fetchStatsProductGroup(); - const resStatsType = await fetchStatsProductType(); const resStatsService = await fetchStatsService(); const resStatsProduct = await fetchStatsProduct(); stat.value[0].count = resStatsGroup ?? 0; - stat.value[1].count = resStatsType ?? 0; - stat.value[2].count = resStatsService ?? 0; - stat.value[3].count = resStatsProduct ?? 0; + stat.value[1].count = resStatsService ?? 0; + stat.value[2].count = resStatsProduct ?? 0; } async function fetchStatus() { @@ -1298,39 +1309,101 @@ function cloneData() { } const currentStatusList = ref([]); -async function enterGroup(id: string, name: string, status: Status) { +async function enterGroup( + id: string, + name: string, + status: Status, + toService?: boolean, +) { expandedTree.value = []; expandedTree.value.push(id); pathGroupName.value = name; currentIdGrop.value = id; currentStatusList.value.push(status); - await fetchListType(); - productMode.value = 'type'; + pathTypeName.value = name; + await fetchListOfService(); + await fetchListOfProduct(); + if (toService) await enterNext('service'); + else productMode.value = 'group'; + + // await fetchListType(); + // productMode.value = 'type'; + // flowStore.rotate(); + // if ( + // expandedTree.value.length > 1 && + // expandedTree.value[expandedTree.value.length - 1] !== id + // ) { + // console.log(1); + // expandedTree.value.pop(); + // expandedTree.value.push(id); + // } else { + // console.log(2); + // expandedTree.value.push(id); + // } + // currentIdType.value = id; + // productMode.value = 'service'; + // productAndServiceTab.value = 'service'; + // currentStatusList.value.push(status); + flowStore.rotate(); } -async function enterType(id: string, name: string, status: Status) { +async function enterNext(type: 'service' | 'product') { + currentPageServiceAndProduct.value = 1; + inputSearchProductAndService.value = ''; + currentStatus.value = 'All'; + filterStat.value = []; + if ( expandedTree.value.length > 1 && - expandedTree.value[expandedTree.value.length - 1] !== id + expandedTree.value[expandedTree.value.length - 1] !== type ) { expandedTree.value.pop(); - expandedTree.value.push(id); - } else { - expandedTree.value.push(id); } - pathTypeName.value = name; - currentIdType.value = id; - productMode.value = 'service'; - productAndServiceTab.value = 'service'; - currentStatusList.value.push(status); - await fetchListOfProduct(); - await fetchListOfService(); + if (type === 'service') { + productMode.value = 'service'; + productAndServiceTab.value = 'service'; + currentIdType.value = 'type'; + pathTypeName.value = 'type'; + expandedTree.value.push('type'); + filterStat.value.push('group'); + filterStat.value.push('product'); + } else { + productMode.value = 'product'; + productAndServiceTab.value = 'product'; + currentIdType.value = 'productService'; + pathTypeName.value = 'productService'; + expandedTree.value.push('productService'); + filterStat.value.push('group'); + filterStat.value.push('service'); + } flowStore.rotate(); } +// async function enterType(id: string, name: string, status: Status) { +// if ( +// expandedTree.value.length > 1 && +// expandedTree.value[expandedTree.value.length - 1] !== id +// ) { +// expandedTree.value.pop(); +// expandedTree.value.push(id); +// } else { +// expandedTree.value.push(id); +// } +// pathTypeName.value = name; +// currentIdType.value = id; +// productMode.value = 'service'; +// productAndServiceTab.value = 'service'; +// currentStatusList.value.push(status); + +// await fetchListOfProduct(); +// await fetchListOfService(); + +// flowStore.rotate(); +// } + function handleStatus() { let tempValue = false; @@ -1345,7 +1418,6 @@ function handleStatus() { function handleHold(node: ProductGroup & { type: string }) { if ($q.screen.gt.xs) return; - console.log('asd'); holdDialog.value = true; currentNode.value = node; // return function (props: unknown) { @@ -1394,11 +1466,7 @@ watch( }, ]; - if ( - productMode.value === 'group' || - productMode.value === 'type' || - productMode.value === 'service' - ) { + if (productMode.value === 'group' || productMode.value === 'service') { tmp.push({ text: 'productService.group.withName', i18n: true, @@ -1406,7 +1474,7 @@ watch( handler: () => { if (productMode.value === 'service') { currentIdType.value = ''; - productMode.value = 'type'; + // productMode.value = 'type'; filterStat.value = filterStat.value.filter((item) => { return item !== 'type'; @@ -1441,9 +1509,10 @@ watch( watch(currentStatus, async () => { if (productMode.value === 'group') { await fetchListGroups(); - } else { - await fetchListType(); } + // else { + // await fetchListType(); + // } flowStore.rotate(); }); @@ -1453,10 +1522,10 @@ watch(inputSearch, async () => { flowStore.rotate(); } - if (productMode.value === 'type') { - await fetchListType(); - flowStore.rotate(); - } + // if (productMode.value === 'type') { + // await fetchListType(); + // flowStore.rotate(); + // } }); watch(inputSearchProductAndService, async () => { @@ -1496,7 +1565,7 @@ watch([currentStatusList, productMode], () => { } " /> - { dialogInputForm = true; } " - > + > --> {
{ async (v: (typeof treeProductTypeAndGroup)[number]) => { if (v.type === 'group') { if (currentIdGrop !== v.id) { - filterStat.push('group'); - currentStatusList = []; + // filterStat.push('group'); + // currentStatusList = []; await enterGroup(v.id, v.name, v.status); return; @@ -1636,27 +1705,25 @@ watch([currentStatusList, productMode], () => { } } if (v.type === 'type') { - currentStatusList = []; - if (v.actionDisabled) { - currentStatusList.push('INACTIVE'); - } - if (!v.actionDisabled) { - currentStatusList.push('ACTIVE'); - } - if (currentIdType !== v.id) { - filterStat.push('group', 'type'); - await enterType(v.id, v.name, v.status); + await enterNext('service'); return; } if (currentIdType === v.id) { - filterStat = filterStat.filter((item) => { - return item !== 'type'; - }); - currentStatusList.splice(1); - currentIdType = ''; - productMode = 'type'; expandedTree.pop(); + productMode = 'group'; + return; + } + } + + if (v.type === 'productService') { + if (currentIdType !== v.id) { + await enterNext('product'); + return; + } + if (currentIdType === v.id) { + expandedTree.pop(); + productMode = 'group'; return; } } @@ -1664,15 +1731,6 @@ watch([currentStatusList, productMode], () => { " @view=" (v: (typeof treeProductTypeAndGroup)[number]) => { - if (v.type === 'type') { - editByTree = 'type'; - currentStatusProduct = v.status === 'INACTIVE'; - clearFormGroup(); - currentIdType = v.id; - assignFormDataGroup(v); - isEdit = false; - drawerInfo = true; - } if (v.type === 'group') { editByTree = 'group'; currentStatusProduct = v.status === 'INACTIVE'; @@ -1687,13 +1745,6 @@ watch([currentStatusList, productMode], () => { @edit=" (v: (typeof treeProductTypeAndGroup)[number]) => { editByTree = v.type as typeof editByTree; - if (v.type === 'type') { - clearFormGroup(); - currentIdType = v.id; - assignFormDataGroup(v); - isEdit = true; - drawerInfo = true; - } if (v.type === 'group') { clearFormGroup(); assignFormDataGroup(v); @@ -1706,10 +1757,6 @@ watch([currentStatusList, productMode], () => { @delete=" (v: (typeof treeProductTypeAndGroup)[number]) => { editByTree = v.type as typeof editByTree; - - if (v.type === 'type') { - deleteProductById(v.id); - } if (v.type === 'group') { deleteProductById(v.id); } @@ -1717,12 +1764,6 @@ watch([currentStatusList, productMode], () => { " @change-status=" async (v: (typeof treeProductTypeAndGroup)[number]) => { - if (v.type === 'type') { - await triggerChangeStatus(v.id, v.status, v.type); - - currentStatusList[0] = - v.status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE'; - } if (v.type === 'group') { await triggerChangeStatus(v.id, v.status, v.type); @@ -1742,7 +1783,7 @@ watch([currentStatusList, productMode], () => {
@@ -1868,8 +1909,8 @@ watch([currentStatusList, productMode], () => {
{ flat bordered :grid="modeView" - :rows=" - (productMode === 'type' ? productType : productGroup) || - [] - " + :rows="productGroup || []" :columns="tbColumn.groupAndType" class="full-width" card-container-class="q-col-gutter-md" @@ -1931,18 +1969,19 @@ watch([currentStatusList, productMode], () => { @click=" async () => { filterStat.push(productMode); - if (productMode === 'type') { - await enterType( - props.row.id, - props.row.name, - props.row.status, - ); - } + // if (productMode === 'type') { + // await enterType( + // props.row.id, + // props.row.name, + // props.row.status, + // ); + // } if (productMode === 'group') { await enterGroup( props.row.id, props.row.name, props.row.status, + true, ); } } @@ -1957,13 +1996,9 @@ watch([currentStatusList, productMode], () => { " > {{ - productMode === 'type' - ? (currentPageType - 1) * pageSizeType + - props.rowIndex + - 1 - : (currentPageGroup - 1) * pageSizeGroup + - props.rowIndex + - 1 + (currentPageGroup - 1) * pageSizeGroup + + props.rowIndex + + 1 }} { flat @click.stop=" () => { - if (productMode === 'type') { - editByTree = 'type'; - currentStatusProduct = - props.row.status === 'INACTIVE'; - clearFormGroup(); - currentIdType = props.row.id; - assignFormDataGroup(props.row); - isEdit = false; - drawerInfo = true; - } + // if (productMode === 'type') { + // editByTree = 'type'; + // currentStatusProduct = + // props.row.status === 'INACTIVE'; + // clearFormGroup(); + // currentIdType = props.row.id; + // assignFormDataGroup(props.row); + // isEdit = false; + // drawerInfo = true; + // } if (productMode === 'group') { editByTree = 'group'; currentStatusProduct = @@ -2079,16 +2114,16 @@ watch([currentStatusList, productMode], () => { :idName="props.row.name" @view=" () => { - if (productMode === 'type') { - editByTree = 'type'; - currentStatusProduct = - props.row.status === 'INACTIVE'; - clearFormGroup(); - currentIdType = props.row.id; - assignFormDataGroup(props.row); - isEdit = false; - drawerInfo = true; - } + // if (productMode === 'type') { + // editByTree = 'type'; + // currentStatusProduct = + // props.row.status === 'INACTIVE'; + // clearFormGroup(); + // currentIdType = props.row.id; + // assignFormDataGroup(props.row); + // isEdit = false; + // drawerInfo = true; + // } if (productMode === 'group') { editByTree = 'group'; currentStatusProduct = @@ -2103,14 +2138,14 @@ watch([currentStatusList, productMode], () => { " @edit=" () => { - if (productMode === 'type') { - editByTree = 'type'; - clearFormGroup(); - currentIdType = props.row.id; - assignFormDataGroup(props.row); - isEdit = true; - drawerInfo = true; - } + // if (productMode === 'type') { + // editByTree = 'type'; + // clearFormGroup(); + // currentIdType = props.row.id; + // assignFormDataGroup(props.row); + // isEdit = true; + // drawerInfo = true; + // } if (productMode === 'group') { editByTree = 'group'; clearFormGroup(); @@ -2124,9 +2159,9 @@ watch([currentStatusList, productMode], () => { " @delete=" () => { - if (productMode === 'type') { - deleteProductById(props.row.id); - } + // if (productMode === 'type') { + // deleteProductById(props.row.id); + // } if (productMode === 'group') { deleteProductById(props.row.id); } @@ -2147,8 +2182,8 @@ watch([currentStatusList, productMode], () => {
@@ -2519,7 +2555,7 @@ watch([currentStatusList, productMode], () => {
-
+
+ {{ + optionStore.mapOption( + { + product: props.row.expenseType, + service: props.row.work?.length, + }[productAndServiceTab], + ) + }} + + {{ { @@ -2777,6 +2835,28 @@ watch([currentStatusList, productMode], () => { }[productAndServiceTab] }} + + {{ + { + product: props.row.vatIncluded, + service: props.row.work?.length, + }[productAndServiceTab] + ? $t('productService.product.vatIncluded') + : $t('productService.product.vatExcluded') + }} +
@@ -3105,7 +3185,7 @@ watch([currentStatusList, productMode], () => { hideFade hideActive useToggle - :img="`/images/product-service-${productMode}-avatar-add${productMode === 'type' ? ($q.dark.isActive ? '-d' : '-l') : ''}.png`" + :img="`/images/product-service-${productMode}-avatar-add.png`" :toggleTitle="$t('status.title')" :icon=" productMode === 'group' @@ -3177,10 +3257,10 @@ watch([currentStatusList, productMode], () => { :class="$q.screen.xs ? 'q-pl-md' : 'q-pl-sm'" style="height: 100%; max-height: 100%; overflow-y: auto" > + { if (editByTree === 'group') { submitGroup(); } - if (editByTree === 'type') { - submitType(); - } + // if (editByTree === 'type') { + // submitType(); + // } editByTree = undefined; } else { if (productMode === 'group') { submitGroup(); } - if (productMode === 'type') { - submitType(); - } + // if (productMode === 'type') { + // submitType(); + // } } } " @@ -3350,10 +3430,10 @@ watch([currentStatusList, productMode], () => { :class="$q.screen.xs ? 'q-pl-md' : 'q-pl-sm'" style="overflow-y: auto" > + { v-model:name="formDataProduct.name" v-model:code="formDataProduct.code" v-model:process="formDataProduct.process" + v-model:expense-type="formDataProduct.expenseType" dense separator /> @@ -3670,6 +3751,7 @@ watch([currentStatusList, productMode], () => { v-model:price="formDataProduct.price" v-model:agent-price="formDataProduct.agentPrice" v-model:service-charge="formDataProduct.serviceCharge" + v-model:vat-included="formDataProduct.vatIncluded" dense />
@@ -3839,6 +3921,7 @@ watch([currentStatusList, productMode], () => { v-model:name="formDataProduct.name" v-model:code="formDataProduct.code" v-model:process="formDataProduct.process" + v-model:expense-type="formDataProduct.expenseType" disableCode dense separator @@ -3849,6 +3932,7 @@ watch([currentStatusList, productMode], () => { v-model:price="formDataProduct.price" v-model:agent-price="formDataProduct.agentPrice" v-model:service-charge="formDataProduct.serviceCharge" + v-model:vat-included="formDataProduct.vatIncluded" dense :priceDisplay="priceDisplay" /> @@ -3982,7 +4066,7 @@ watch([currentStatusList, productMode], () => { dense @addProduct=" async (index) => { - await fetchListOfProductIsAdd(currentIdType); + await fetchListOfProductIsAdd(currentIdGrop); currentWorkIndex = index; selectProduct = JSON.parse( JSON.stringify(workItems[currentWorkIndex].product), @@ -4278,7 +4362,7 @@ watch([currentStatusList, productMode], () => { :priceDisplay="priceDisplay" @addProduct=" async (index) => { - await fetchListOfProductIsAdd(currentIdType); + await fetchListOfProductIsAdd(currentIdGrop); currentWorkIndex = index; selectProduct = JSON.parse( JSON.stringify(workItems[currentWorkIndex].product), @@ -4342,15 +4426,15 @@ watch([currentStatusList, productMode], () => { if (!currentNode) return; await fetchListOfOptionBranch(); - if (currentNode.type === 'type') { - editByTree = 'type'; - currentStatusProduct = currentNode.status === 'INACTIVE'; - clearFormGroup(); - currentIdType = currentNode.id; - assignFormDataGroup(currentNode); - isEdit = false; - drawerInfo = true; - } + // if (currentNode.type === 'type') { + // editByTree = 'type'; + // currentStatusProduct = currentNode.status === 'INACTIVE'; + // clearFormGroup(); + // currentIdType = currentNode.id; + // assignFormDataGroup(currentNode); + // isEdit = false; + // drawerInfo = true; + // } if (currentNode.type === 'group') { editByTree = 'group'; currentStatusProduct = currentNode.status === 'INACTIVE'; @@ -4380,13 +4464,13 @@ watch([currentStatusList, productMode], () => { () => { if (!currentNode) return; editByTree = currentNode.type as 'type' | 'group'; - if (currentNode.type === 'type') { - clearFormGroup(); - currentIdType = currentNode.id; - assignFormDataGroup(currentNode); - isEdit = true; - drawerInfo = true; - } + // if (currentNode.type === 'type') { + // clearFormGroup(); + // currentIdType = currentNode.id; + // assignFormDataGroup(currentNode); + // isEdit = true; + // drawerInfo = true; + // } if (currentNode.type === 'group') { clearFormGroup(); assignFormDataGroup(currentNode); @@ -4440,16 +4524,16 @@ watch([currentStatusList, productMode], () => { @click=" async () => { if (!currentNode) return; - if (currentNode.type === 'type') { - triggerChangeStatus( - currentNode.id, - currentNode.status, - currentNode.type, - ); - currentNode.status === 'ACTIVE' - ? (currentNode.status = 'INACTIVE') - : (currentNode.status = 'ACTIVE'); - } + // if (currentNode.type === 'type') { + // triggerChangeStatus( + // currentNode.id, + // currentNode.status, + // currentNode.type, + // ); + // currentNode.status === 'ACTIVE' + // ? (currentNode.status = 'INACTIVE') + // : (currentNode.status = 'ACTIVE'); + // } if (currentNode.type === 'group') { triggerChangeStatus( currentNode.id, diff --git a/src/stores/product-service/index.ts b/src/stores/product-service/index.ts index eda00bce..e7c940c8 100644 --- a/src/stores/product-service/index.ts +++ b/src/stores/product-service/index.ts @@ -271,7 +271,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { // Product - async function fetchStatsProduct(opts?: { productTypeId?: string }) { + async function fetchStatsProduct(opts?: { productGroupId?: string }) { const params = new URLSearchParams(); for (const [k, v] of Object.entries(opts || {})) { @@ -296,7 +296,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { query?: string; page?: number; pageSize?: number; - productTypeId?: string; + productGroupId?: string; status?: string; }, flow?: { @@ -428,7 +428,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { query?: string; page?: number; pageSize?: number; - productTypeId?: string; + productGroupId?: string; status?: string; }, flow?: { @@ -545,7 +545,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { serviceId: string, data: Partial, ) { - const { image, code, productTypeId, ...payload } = data; + const { image, code, productGroupId, ...payload } = data; if (payload.status === 'CREATED') { delete payload.status; @@ -736,7 +736,7 @@ const useProductServiceStore = defineStore('api-product-service', () => { query?: string; page?: number; pageSize?: number; - productTypeId?: string; + productGroupId?: string; status?: string; }, flow?: { diff --git a/src/stores/product-service/types.ts b/src/stores/product-service/types.ts index 18fc82a5..1d2bb8f5 100644 --- a/src/stores/product-service/types.ts +++ b/src/stores/product-service/types.ts @@ -14,7 +14,7 @@ export interface TreeProduct { } export interface Service { - productTypeId: string; + productGroupId: string; updatedAt: string; updatedBy: UpdatedBy; createdAt: string; @@ -62,7 +62,7 @@ export interface ServiceCreate { code: string; image?: File; status?: Status; - productTypeId: string; + productGroupId: string; registeredBranchId: string | null; } @@ -112,7 +112,7 @@ export interface ServiceById { code: string; id: string; imageUrl: 'string'; - productTypeId: string; + productGroupId: string; registeredBranchId: string; } @@ -136,12 +136,14 @@ export interface WorkItems { } export interface ProductList { + expenseType: string; + vatIncluded: boolean; remark: string; updatedAt: string; updatedBy: UpdatedBy; createdAt: string; createdBy: CreatedBy; - productTypeId: string; + productGroupId: string; status: Status; serviceCharge: number; agentPrice: number; @@ -156,8 +158,10 @@ export interface ProductList { } export interface ProductCreate { + expenseType: string; + vatIncluded: boolean; registeredBranchId: string; - productTypeId: string; + productGroupId: string; remark: string; serviceCharge: number; agentPrice: number; @@ -171,7 +175,7 @@ export interface ProductCreate { } export interface ProductUpdate { - productTypeId: string; + productGroupId: string; remark: string; serviceCharge: number; agentPrice: number;