refactor: permission product service

This commit is contained in:
Methapon Metanipat 2024-09-10 14:36:36 +07:00
parent 67d360c92b
commit ed692c823d
5 changed files with 48 additions and 372 deletions

View file

@ -70,12 +70,6 @@ const productServiceStore = useProductServiceStore();
const optionStore = useOptionStore();
const {
fetchStatsProductType,
createProductServiceType,
editProductServiceType,
deleteProductServiceType,
fetchListProductServiceType,
fetchStatsProductGroup,
fetchListProductService,
createProductService,
@ -100,8 +94,7 @@ const {
deleteWork,
} = productServiceStore;
const { workNameItems, recordTreeProductType } =
storeToRefs(productServiceStore);
const { workNameItems } = storeToRefs(productServiceStore);
const allStat = ref<{ mode: string; count: number }[]>([]);
const stat = ref<
@ -252,7 +245,6 @@ const formDataGroup = ref<ProductGroupCreate>({
const formDataProduct = ref<ProductCreate>({
expenseType: '',
vatIncluded: true,
registeredBranchId: '',
productGroupId: '',
remark: '',
serviceCharge: 0,
@ -274,7 +266,6 @@ const formDataProductService = ref<ServiceCreate>({
name: '',
code: '',
productGroupId: '',
registeredBranchId: '',
});
const hideStat = ref(false);
@ -473,21 +464,15 @@ const propertiesDialog = ref<boolean>(false);
const totalProduct = ref<number>(0);
const totalService = ref<number>(0);
const totalProductAndService = ref<number>(0);
const filterStat = ref<('group' | 'service' | 'product')[]>([]);
//
const currentPageGroup = ref<number>(1);
const maxPageGroup = ref<number>(1);
const pageSizeGroup = ref<number>(30);
const currentPageType = ref<number>(1);
const maxPageType = ref<number>(1);
const pageSizeType = ref<number>(30);
const maxPageServiceAndProduct = ref<number>(1);
const pageSizeServiceAndProduct = ref<number>(10);
const currentPageServiceAndProduct = ref<number>(1);
const totalType = ref<number>(0);
const totalGroup = ref<number>(0);
const total = ref<number>(0);
@ -559,9 +544,7 @@ async function fetchListOfOptionBranch() {
if (result && result.total > 0) branchOption.value = result.result;
}
formDataProduct.value.registeredBranchId = currentMyBranch.value?.id || '';
formDataProductService.value.registeredBranchId =
currentMyBranch.value?.id || '';
formDataGroup.value.registeredBranchId = currentMyBranch.value?.id || '';
}
async function fetchListGroups() {
@ -878,7 +861,6 @@ const prevService = ref<ServiceCreate>({
name: '',
code: '',
productGroupId: '',
registeredBranchId: '',
});
const currentService = ref<ServiceById>();
@ -902,7 +884,6 @@ async function assignFormDataProductService(id: string) {
work: [],
status: res.status,
productGroupId: res.productGroupId,
registeredBranchId: res.registeredBranchId,
};
formDataProductService.value = { ...prevService.value };
@ -949,7 +930,6 @@ const prevProduct = ref<ProductCreate>({
name: '',
code: '',
image: undefined,
registeredBranchId: '',
});
function assignFormDataProduct(data: ProductList) {
@ -970,7 +950,6 @@ function assignFormDataProduct(data: ProductList) {
name: data.name,
code: data.code,
image: undefined,
registeredBranchId: data.registeredBranchId,
status: data.status,
expenseType: data.expenseType,
vatIncluded: data.vatIncluded,
@ -1003,7 +982,6 @@ function clearFormProduct() {
name: '',
code: '',
image: undefined,
registeredBranchId: '',
expenseType: '',
vatIncluded: true,
};
@ -1026,7 +1004,6 @@ function clearFormService() {
work: [],
status: undefined,
productGroupId: '',
registeredBranchId: '',
};
workItems.value = [];
@ -1060,10 +1037,6 @@ async function submitService() {
if (dialogService.value) {
formDataProductService.value.productGroupId = currentIdGrop.value;
if (formDataProductService.value.registeredBranchId === '') {
formDataProductService.value.registeredBranchId = null;
}
if (
formDataProductService.value.code === '' ||
formDataProductService.value.name === ''
@ -3449,8 +3422,6 @@ watch(productMode, async () => {
>
<BasicInfoProduct
v-if="productTab === 1"
v-model:options-branch="branchOption"
v-model:registered-branch-id="formDataProduct.registeredBranchId"
v-model:detail="formDataProduct.detail"
v-model:remark="formDataProduct.remark"
v-model:name="formDataProduct.name"
@ -3628,8 +3599,6 @@ watch(productMode, async () => {
<BasicInfoProduct
v-if="productTab === 1"
:readonly="!infoProductEdit"
v-model:options-branch="branchOption"
v-model:registered-branch-id="formDataProduct.registeredBranchId"
v-model:detail="formDataProduct.detail"
v-model:remark="formDataProduct.remark"
v-model:name="formDataProduct.name"