refactor: permission product service
This commit is contained in:
parent
67d360c92b
commit
ed692c823d
5 changed files with 48 additions and 372 deletions
|
|
@ -94,7 +94,7 @@ watch(
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
input-debounce="0"
|
input-debounce="0"
|
||||||
:disable="!readonly && disableCode"
|
:disable="!readonly && disableCode"
|
||||||
class="col-md-3 col-6"
|
class="col-md-4 col-12"
|
||||||
v-model="code"
|
v-model="code"
|
||||||
id="select-br-id"
|
id="select-br-id"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
|
|
@ -123,7 +123,7 @@ watch(
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:borderless="readonly"
|
:borderless="readonly"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-6"
|
class="col-md-8 col-12"
|
||||||
:label="$t('productService.product.name')"
|
:label="$t('productService.product.name')"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||||
|
|
|
||||||
|
|
@ -167,58 +167,12 @@ watch(
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-md-3 col-4"
|
class="col-md-4 col-12"
|
||||||
:label="$t('productService.service.code')"
|
:label="$t('productService.service.code')"
|
||||||
v-model="serviceCode"
|
v-model="serviceCode"
|
||||||
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-select
|
|
||||||
outlined
|
|
||||||
clearable
|
|
||||||
use-input
|
|
||||||
fill-input
|
|
||||||
emit-value
|
|
||||||
map-options
|
|
||||||
hide-selected
|
|
||||||
hide-bottom-space
|
|
||||||
class="col-md-3 col-8"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
v-model="registeredBranchId"
|
|
||||||
id="input-source-nationality"
|
|
||||||
for="input-source-nationality"
|
|
||||||
:dense="dense"
|
|
||||||
:readonly="readonly"
|
|
||||||
:options="branchOptions"
|
|
||||||
:hide-dropdown-icon="readonly"
|
|
||||||
:label="$t('productService.service.registeredBranch')"
|
|
||||||
:rules="[
|
|
||||||
(val) => {
|
|
||||||
const roles = getRole() || [];
|
|
||||||
const isSpecialRole = ['admin', 'system', 'head_of_admin'].some(
|
|
||||||
(role) => roles.includes(role),
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
isSpecialRole ||
|
|
||||||
!!val ||
|
|
||||||
$t('form.error.selectField', {
|
|
||||||
field: $t('productService.service.registeredBranch'),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
|
||||||
]"
|
|
||||||
@filter="branchFilter"
|
|
||||||
>
|
|
||||||
<template v-slot:no-option>
|
|
||||||
<q-item>
|
|
||||||
<q-item-section class="text-grey">
|
|
||||||
{{ $t('general.noData') }}
|
|
||||||
</q-item-section>
|
|
||||||
</q-item>
|
|
||||||
</template>
|
|
||||||
</q-select>
|
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
id="input-service-name"
|
id="input-service-name"
|
||||||
for="input-service-name"
|
for="input-service-name"
|
||||||
|
|
@ -226,11 +180,12 @@ watch(
|
||||||
outlined
|
outlined
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
hide-bottom-space
|
hide-bottom-space
|
||||||
class="col-md-6 col"
|
class="col-md-8 col-12"
|
||||||
:label="$t('productService.service.name')"
|
:label="$t('productService.service.name')"
|
||||||
v-model="serviceName"
|
v-model="serviceName"
|
||||||
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
:rules="[(val: string) => !!val || $t('form.error.required')]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
id="input-service-description"
|
id="input-service-description"
|
||||||
for="input-service-description"
|
for="input-service-description"
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,6 @@ const productServiceStore = useProductServiceStore();
|
||||||
const optionStore = useOptionStore();
|
const optionStore = useOptionStore();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
fetchStatsProductType,
|
|
||||||
createProductServiceType,
|
|
||||||
editProductServiceType,
|
|
||||||
deleteProductServiceType,
|
|
||||||
fetchListProductServiceType,
|
|
||||||
|
|
||||||
fetchStatsProductGroup,
|
fetchStatsProductGroup,
|
||||||
fetchListProductService,
|
fetchListProductService,
|
||||||
createProductService,
|
createProductService,
|
||||||
|
|
@ -100,8 +94,7 @@ const {
|
||||||
deleteWork,
|
deleteWork,
|
||||||
} = productServiceStore;
|
} = productServiceStore;
|
||||||
|
|
||||||
const { workNameItems, recordTreeProductType } =
|
const { workNameItems } = storeToRefs(productServiceStore);
|
||||||
storeToRefs(productServiceStore);
|
|
||||||
|
|
||||||
const allStat = ref<{ mode: string; count: number }[]>([]);
|
const allStat = ref<{ mode: string; count: number }[]>([]);
|
||||||
const stat = ref<
|
const stat = ref<
|
||||||
|
|
@ -252,7 +245,6 @@ const formDataGroup = ref<ProductGroupCreate>({
|
||||||
const formDataProduct = ref<ProductCreate>({
|
const formDataProduct = ref<ProductCreate>({
|
||||||
expenseType: '',
|
expenseType: '',
|
||||||
vatIncluded: true,
|
vatIncluded: true,
|
||||||
registeredBranchId: '',
|
|
||||||
productGroupId: '',
|
productGroupId: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
serviceCharge: 0,
|
serviceCharge: 0,
|
||||||
|
|
@ -274,7 +266,6 @@ const formDataProductService = ref<ServiceCreate>({
|
||||||
name: '',
|
name: '',
|
||||||
code: '',
|
code: '',
|
||||||
productGroupId: '',
|
productGroupId: '',
|
||||||
registeredBranchId: '',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const hideStat = ref(false);
|
const hideStat = ref(false);
|
||||||
|
|
@ -473,21 +464,15 @@ const propertiesDialog = ref<boolean>(false);
|
||||||
|
|
||||||
const totalProduct = ref<number>(0);
|
const totalProduct = ref<number>(0);
|
||||||
const totalService = ref<number>(0);
|
const totalService = ref<number>(0);
|
||||||
const totalProductAndService = ref<number>(0);
|
|
||||||
|
|
||||||
const filterStat = ref<('group' | 'service' | 'product')[]>([]);
|
const filterStat = ref<('group' | 'service' | 'product')[]>([]);
|
||||||
|
|
||||||
// แบ่งหน้า
|
// แบ่งหน้า
|
||||||
const currentPageGroup = ref<number>(1);
|
const currentPageGroup = ref<number>(1);
|
||||||
const maxPageGroup = ref<number>(1);
|
const maxPageGroup = ref<number>(1);
|
||||||
const pageSizeGroup = ref<number>(30);
|
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 maxPageServiceAndProduct = ref<number>(1);
|
||||||
const pageSizeServiceAndProduct = ref<number>(10);
|
const pageSizeServiceAndProduct = ref<number>(10);
|
||||||
const currentPageServiceAndProduct = ref<number>(1);
|
const currentPageServiceAndProduct = ref<number>(1);
|
||||||
const totalType = ref<number>(0);
|
|
||||||
const totalGroup = ref<number>(0);
|
const totalGroup = ref<number>(0);
|
||||||
const total = ref<number>(0);
|
const total = ref<number>(0);
|
||||||
|
|
||||||
|
|
@ -559,9 +544,7 @@ async function fetchListOfOptionBranch() {
|
||||||
if (result && result.total > 0) branchOption.value = result.result;
|
if (result && result.total > 0) branchOption.value = result.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
formDataProduct.value.registeredBranchId = currentMyBranch.value?.id || '';
|
formDataGroup.value.registeredBranchId = currentMyBranch.value?.id || '';
|
||||||
formDataProductService.value.registeredBranchId =
|
|
||||||
currentMyBranch.value?.id || '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListGroups() {
|
async function fetchListGroups() {
|
||||||
|
|
@ -878,7 +861,6 @@ const prevService = ref<ServiceCreate>({
|
||||||
name: '',
|
name: '',
|
||||||
code: '',
|
code: '',
|
||||||
productGroupId: '',
|
productGroupId: '',
|
||||||
registeredBranchId: '',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentService = ref<ServiceById>();
|
const currentService = ref<ServiceById>();
|
||||||
|
|
@ -902,7 +884,6 @@ async function assignFormDataProductService(id: string) {
|
||||||
work: [],
|
work: [],
|
||||||
status: res.status,
|
status: res.status,
|
||||||
productGroupId: res.productGroupId,
|
productGroupId: res.productGroupId,
|
||||||
registeredBranchId: res.registeredBranchId,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
formDataProductService.value = { ...prevService.value };
|
formDataProductService.value = { ...prevService.value };
|
||||||
|
|
@ -949,7 +930,6 @@ const prevProduct = ref<ProductCreate>({
|
||||||
name: '',
|
name: '',
|
||||||
code: '',
|
code: '',
|
||||||
image: undefined,
|
image: undefined,
|
||||||
registeredBranchId: '',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function assignFormDataProduct(data: ProductList) {
|
function assignFormDataProduct(data: ProductList) {
|
||||||
|
|
@ -970,7 +950,6 @@ function assignFormDataProduct(data: ProductList) {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
code: data.code,
|
code: data.code,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
registeredBranchId: data.registeredBranchId,
|
|
||||||
status: data.status,
|
status: data.status,
|
||||||
expenseType: data.expenseType,
|
expenseType: data.expenseType,
|
||||||
vatIncluded: data.vatIncluded,
|
vatIncluded: data.vatIncluded,
|
||||||
|
|
@ -1003,7 +982,6 @@ function clearFormProduct() {
|
||||||
name: '',
|
name: '',
|
||||||
code: '',
|
code: '',
|
||||||
image: undefined,
|
image: undefined,
|
||||||
registeredBranchId: '',
|
|
||||||
expenseType: '',
|
expenseType: '',
|
||||||
vatIncluded: true,
|
vatIncluded: true,
|
||||||
};
|
};
|
||||||
|
|
@ -1026,7 +1004,6 @@ function clearFormService() {
|
||||||
work: [],
|
work: [],
|
||||||
status: undefined,
|
status: undefined,
|
||||||
productGroupId: '',
|
productGroupId: '',
|
||||||
registeredBranchId: '',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
workItems.value = [];
|
workItems.value = [];
|
||||||
|
|
@ -1060,10 +1037,6 @@ async function submitService() {
|
||||||
if (dialogService.value) {
|
if (dialogService.value) {
|
||||||
formDataProductService.value.productGroupId = currentIdGrop.value;
|
formDataProductService.value.productGroupId = currentIdGrop.value;
|
||||||
|
|
||||||
if (formDataProductService.value.registeredBranchId === '') {
|
|
||||||
formDataProductService.value.registeredBranchId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
formDataProductService.value.code === '' ||
|
formDataProductService.value.code === '' ||
|
||||||
formDataProductService.value.name === ''
|
formDataProductService.value.name === ''
|
||||||
|
|
@ -3449,8 +3422,6 @@ watch(productMode, async () => {
|
||||||
>
|
>
|
||||||
<BasicInfoProduct
|
<BasicInfoProduct
|
||||||
v-if="productTab === 1"
|
v-if="productTab === 1"
|
||||||
v-model:options-branch="branchOption"
|
|
||||||
v-model:registered-branch-id="formDataProduct.registeredBranchId"
|
|
||||||
v-model:detail="formDataProduct.detail"
|
v-model:detail="formDataProduct.detail"
|
||||||
v-model:remark="formDataProduct.remark"
|
v-model:remark="formDataProduct.remark"
|
||||||
v-model:name="formDataProduct.name"
|
v-model:name="formDataProduct.name"
|
||||||
|
|
@ -3628,8 +3599,6 @@ watch(productMode, async () => {
|
||||||
<BasicInfoProduct
|
<BasicInfoProduct
|
||||||
v-if="productTab === 1"
|
v-if="productTab === 1"
|
||||||
:readonly="!infoProductEdit"
|
:readonly="!infoProductEdit"
|
||||||
v-model:options-branch="branchOption"
|
|
||||||
v-model:registered-branch-id="formDataProduct.registeredBranchId"
|
|
||||||
v-model:detail="formDataProduct.detail"
|
v-model:detail="formDataProduct.detail"
|
||||||
v-model:remark="formDataProduct.remark"
|
v-model:remark="formDataProduct.remark"
|
||||||
v-model:name="formDataProduct.name"
|
v-model:name="formDataProduct.name"
|
||||||
|
|
|
||||||
|
|
@ -18,147 +18,20 @@ import {
|
||||||
Work,
|
Work,
|
||||||
ProductOnWork,
|
ProductOnWork,
|
||||||
WorkCreate,
|
WorkCreate,
|
||||||
ServiceAndProduct,
|
|
||||||
TreeProduct,
|
|
||||||
} from './types';
|
} from './types';
|
||||||
import { computed, ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import useFlowStore from '../flow';
|
import useFlowStore from '../flow';
|
||||||
|
|
||||||
import useMyBranchStore from 'stores/my-branch';
|
|
||||||
|
|
||||||
const useProductServiceStore = defineStore('api-product-service', () => {
|
const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
const useMyBranch = useMyBranchStore();
|
|
||||||
|
|
||||||
const recordTreeProductType = ref<Record<string, TreeProduct[]>>({});
|
|
||||||
|
|
||||||
// Product Type
|
|
||||||
const flowStore = useFlowStore();
|
const flowStore = useFlowStore();
|
||||||
|
|
||||||
const workNameItems = ref<{ id: string; name: string; isEdit: boolean }[]>(
|
const workNameItems = ref<
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
async function fetchStatsProductType() {
|
|
||||||
const res = await api.get('/product-type/stats');
|
|
||||||
|
|
||||||
if (!res) return false;
|
|
||||||
|
|
||||||
if (res.status === 200) {
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchListProductServiceByIdType(groupId: string) {
|
|
||||||
const res = await api.get<ProductGroup & { productGroupId: string }>(
|
|
||||||
`/product-type/${groupId}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!res) return false;
|
|
||||||
|
|
||||||
if (res.status === 200) {
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchListProductServiceType(
|
|
||||||
opts?: {
|
|
||||||
page?: number;
|
|
||||||
pageSize?: number;
|
|
||||||
query?: string;
|
|
||||||
productGroupId?: string;
|
|
||||||
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
|
||||||
},
|
|
||||||
flow?: {
|
|
||||||
sessionId?: string;
|
|
||||||
refTransactionId?: string;
|
|
||||||
transactionId?: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get<
|
|
||||||
Pagination<(ProductGroup & { productGroupId: string })[]>
|
|
||||||
>(`/product-type${(params && '?'.concat(query)) || ''}`, {
|
|
||||||
headers: {
|
|
||||||
'X-Session-Id': flow?.sessionId,
|
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!res) return false;
|
|
||||||
if (res.status === 200) {
|
|
||||||
if (!!opts?.productGroupId) {
|
|
||||||
recordTreeProductType.value[opts?.productGroupId] = res.data.result;
|
|
||||||
}
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createProductServiceType(
|
|
||||||
id: string,
|
|
||||||
data: ProductGroupCreate,
|
|
||||||
) {
|
|
||||||
const { code, ...payload } = data;
|
|
||||||
|
|
||||||
const res = await api.post<ProductGroupCreate & { productGroupId: string }>(
|
|
||||||
'/product-type',
|
|
||||||
{
|
{
|
||||||
productGroupId: id,
|
id: string;
|
||||||
...payload,
|
name: string;
|
||||||
},
|
isEdit: boolean;
|
||||||
);
|
}[]
|
||||||
|
>([]);
|
||||||
if (!res) return false;
|
|
||||||
|
|
||||||
if (res.status === 201) {
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function editProductServiceType(
|
|
||||||
groupId: string,
|
|
||||||
data: Partial<ProductGroupUpdate & { productGroupId: string }>,
|
|
||||||
) {
|
|
||||||
const { code, ...payload } = data;
|
|
||||||
|
|
||||||
const res = await api.put<ProductGroupUpdate & { productGroupId: string }>(
|
|
||||||
`/product-type/${groupId}`,
|
|
||||||
{
|
|
||||||
...payload,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!res) return false;
|
|
||||||
|
|
||||||
if (res.status === 200) {
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function deleteProductServiceType(groupId: string) {
|
|
||||||
const res = await api.delete(`/product-type/${groupId}`);
|
|
||||||
|
|
||||||
if (!res) return false;
|
|
||||||
|
|
||||||
if (res.status === 200) {
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Product Group
|
// Product Group
|
||||||
|
|
||||||
|
|
@ -182,19 +55,12 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListProductService(
|
async function fetchListProductService(opts?: {
|
||||||
opts?: {
|
|
||||||
page?: number;
|
page?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
query?: string;
|
query?: string;
|
||||||
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
||||||
},
|
}) {
|
||||||
flow?: {
|
|
||||||
sessionId?: string;
|
|
||||||
refTransactionId?: string;
|
|
||||||
transactionId?: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
for (const [k, v] of Object.entries(opts || {})) {
|
||||||
|
|
@ -207,9 +73,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
`/product-group${(params && '?'.concat(query)) || ''}`,
|
`/product-group${(params && '?'.concat(query)) || ''}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Rtid': flowStore.rtid,
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -291,40 +155,25 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListProduct(
|
async function fetchListProduct(opts?: {
|
||||||
opts?: {
|
|
||||||
query?: string;
|
query?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
productGroupId?: string;
|
productGroupId?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
},
|
}) {
|
||||||
flow?: {
|
|
||||||
sessionId?: string;
|
|
||||||
refTransactionId?: string;
|
|
||||||
transactionId?: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
for (const [k, v] of Object.entries(opts || {})) {
|
||||||
v !== undefined && params.append(k, v.toString());
|
v !== undefined && params.append(k, v.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useMyBranch.myBranch?.length !== 0 && useMyBranch.myBranch) {
|
|
||||||
params.append('registeredBranchId', useMyBranch.myBranch[0].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
const query = params.toString();
|
||||||
|
|
||||||
const res = await api.get<Pagination<ProductList[]>>(
|
const res = await api.get<Pagination<ProductList[]>>(
|
||||||
`/product${(params && '?'.concat(query)) || ''}`,
|
`/product${(params && '?'.concat(query)) || ''}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: { 'X-Rtid': flowStore.rtid },
|
||||||
'X-Session-Id': flow?.sessionId,
|
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -433,39 +282,26 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListService(
|
async function fetchListService(opts?: {
|
||||||
opts?: {
|
|
||||||
query?: string;
|
query?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
productGroupId?: string;
|
productGroupId?: string;
|
||||||
status?: string;
|
status?: string;
|
||||||
},
|
}) {
|
||||||
flow?: {
|
|
||||||
sessionId?: string;
|
|
||||||
refTransactionId?: string;
|
|
||||||
transactionId?: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
for (const [k, v] of Object.entries(opts || {})) {
|
||||||
v !== undefined && params.append(k, v.toString());
|
v !== undefined && params.append(k, v.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useMyBranch.myBranch?.length !== 0 && useMyBranch.myBranch) {
|
|
||||||
params.append('registeredBranchId', useMyBranch.myBranch[0].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
const query = params.toString();
|
||||||
|
|
||||||
const res = await api.get<Pagination<Service[]>>(
|
const res = await api.get<Pagination<Service[]>>(
|
||||||
`/service${(params && '?'.concat(query)) || ''}`,
|
`/service${(params && '?'.concat(query)) || ''}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Rtid': flowStore.rtid,
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -508,11 +344,6 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
async function fetchListServiceByIdWork(
|
async function fetchListServiceByIdWork(
|
||||||
serviceId: string,
|
serviceId: string,
|
||||||
opts?: { query?: string; page?: number; pageSize?: number },
|
opts?: { query?: string; page?: number; pageSize?: number },
|
||||||
flow?: {
|
|
||||||
sessionId?: string;
|
|
||||||
refTransactionId?: string;
|
|
||||||
transactionId?: string;
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
|
@ -526,9 +357,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
`/service/${serviceId}/work${(params && '?'.concat(query)) || ''}`,
|
`/service/${serviceId}/work${(params && '?'.concat(query)) || ''}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Rtid': flowStore.rtid,
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -598,19 +427,12 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// work
|
// work
|
||||||
async function fetchListWork(
|
async function fetchListWork(opts?: {
|
||||||
opts?: {
|
|
||||||
query?: string;
|
query?: string;
|
||||||
page?: number;
|
page?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
baseOnly?: boolean;
|
baseOnly?: boolean;
|
||||||
},
|
}) {
|
||||||
flow?: {
|
|
||||||
sessionId: string;
|
|
||||||
refTransactionId: string;
|
|
||||||
transactionId: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
for (const [k, v] of Object.entries(opts || {})) {
|
||||||
|
|
@ -623,9 +445,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
Pagination<(Work & { productOnWork: ProductOnWork[] })[]>
|
Pagination<(Work & { productOnWork: ProductOnWork[] })[]>
|
||||||
>(`/work${(params && '?'.concat(query)) || ''}`, {
|
>(`/work${(params && '?'.concat(query)) || ''}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Rtid': flowStore.rtid,
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -698,11 +518,6 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
async function fetchListProductByIdWork(
|
async function fetchListProductByIdWork(
|
||||||
workId: string,
|
workId: string,
|
||||||
opts?: { query?: string; page?: number; pageSize?: number },
|
opts?: { query?: string; page?: number; pageSize?: number },
|
||||||
flow?: {
|
|
||||||
sessionId: string;
|
|
||||||
refTransactionId: string;
|
|
||||||
transactionId: string;
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
|
|
@ -716,9 +531,7 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
`/work/${workId}/product${(params && '?'.concat(query)) || ''}`,
|
`/work/${workId}/product${(params && '?'.concat(query)) || ''}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-Session-Id': flow?.sessionId,
|
'X-Rtid': flowStore.rtid,
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -741,60 +554,8 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListProductAndService(
|
|
||||||
opts?: {
|
|
||||||
query?: string;
|
|
||||||
page?: number;
|
|
||||||
pageSize?: number;
|
|
||||||
productGroupId?: string;
|
|
||||||
status?: string;
|
|
||||||
},
|
|
||||||
flow?: {
|
|
||||||
sessionId: string;
|
|
||||||
refTransactionId: string;
|
|
||||||
transactionId: string;
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(opts || {})) {
|
|
||||||
v !== undefined && params.append(k, v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useMyBranch.myBranch?.length !== 0 && useMyBranch.myBranch) {
|
|
||||||
params.append('registeredBranchId', useMyBranch.myBranch[0].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
const query = params.toString();
|
|
||||||
|
|
||||||
const res = await api.get<Pagination<ServiceAndProduct[]>>(
|
|
||||||
`/product-service${(params && '?'.concat(query)) || ''}`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
'X-Session-Id': flow?.sessionId,
|
|
||||||
'X-Rtid': flow?.refTransactionId || flowStore.rtid,
|
|
||||||
'X-Tid': flow?.transactionId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!res) return false;
|
|
||||||
if (res.status === 200) {
|
|
||||||
return res.data;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
workNameItems,
|
workNameItems,
|
||||||
recordTreeProductType,
|
|
||||||
|
|
||||||
fetchStatsProductType,
|
|
||||||
fetchListProductServiceByIdType,
|
|
||||||
fetchListProductServiceType,
|
|
||||||
createProductServiceType,
|
|
||||||
editProductServiceType,
|
|
||||||
deleteProductServiceType,
|
|
||||||
|
|
||||||
fetchStatsProductGroup,
|
fetchStatsProductGroup,
|
||||||
fetchListProductServiceById,
|
fetchListProductServiceById,
|
||||||
|
|
@ -826,8 +587,6 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
fetchListProductByIdWork,
|
fetchListProductByIdWork,
|
||||||
|
|
||||||
fetchListOfWork,
|
fetchListOfWork,
|
||||||
|
|
||||||
fetchListProductAndService,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
import { Status } from '../types';
|
import { Status } from '../types';
|
||||||
import { Pagination, UpdatedBy, CreatedBy } from 'stores/types';
|
import { UpdatedBy, CreatedBy } from 'stores/types';
|
||||||
|
|
||||||
export type ServiceAndProduct =
|
|
||||||
| (Service & { type: 'service' })
|
|
||||||
| (ProductList & { type: 'product' });
|
|
||||||
|
|
||||||
export interface TreeProduct {
|
export interface TreeProduct {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
@ -63,7 +59,6 @@ export interface ServiceCreate {
|
||||||
image?: File;
|
image?: File;
|
||||||
status?: Status;
|
status?: Status;
|
||||||
productGroupId: string;
|
productGroupId: string;
|
||||||
registeredBranchId: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Attributes {
|
export interface Attributes {
|
||||||
|
|
@ -154,13 +149,11 @@ export interface ProductList {
|
||||||
code: string;
|
code: string;
|
||||||
id: string;
|
id: string;
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
registeredBranchId: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProductCreate {
|
export interface ProductCreate {
|
||||||
expenseType: string;
|
expenseType: string;
|
||||||
vatIncluded: boolean;
|
vatIncluded: boolean;
|
||||||
registeredBranchId: string;
|
|
||||||
productGroupId: string;
|
productGroupId: string;
|
||||||
remark: string;
|
remark: string;
|
||||||
serviceCharge: number;
|
serviceCharge: number;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue