refactor: edit assign treeFile
This commit is contained in:
parent
86a0c1f775
commit
d66c2b3469
1 changed files with 20 additions and 15 deletions
|
|
@ -171,25 +171,29 @@ export const useCustomerForm = defineStore('form-customer', () => {
|
||||||
contactName: v.contactName || '',
|
contactName: v.contactName || '',
|
||||||
file: await customerStore.listAttachment(v.id).then(async (r) => {
|
file: await customerStore.listAttachment(v.id).then(async (r) => {
|
||||||
if (r) {
|
if (r) {
|
||||||
r.forEach((item) => {
|
const fileGroups: Record<
|
||||||
const temp = item.split('-').at(0);
|
string,
|
||||||
|
{ label: string; files: { label: string }[] }
|
||||||
|
> = {};
|
||||||
|
|
||||||
if (
|
r.forEach((file) => {
|
||||||
!state.value.treeFile.some(
|
const temp = file.split('-')[0];
|
||||||
(x) => x.label === t(`customer.typeFile.${temp || ''}`),
|
|
||||||
)
|
if (!fileGroups[temp]) {
|
||||||
) {
|
fileGroups[temp] = {
|
||||||
state.value.treeFile.push({
|
label: t(`customer.typeFile.${temp}`),
|
||||||
label: t(`customer.typeFile.${temp || ''}`),
|
files: [],
|
||||||
file: r
|
};
|
||||||
.filter((x) => x.includes(temp || ''))
|
|
||||||
.map((x) => ({
|
|
||||||
label: x,
|
|
||||||
})),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileGroups[temp].files.push({ label: file });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
state.value.treeFile = Object.values(fileGroups).map((group) => ({
|
||||||
|
label: group.label,
|
||||||
|
file: group.files,
|
||||||
|
}));
|
||||||
|
|
||||||
return await Promise.all(
|
return await Promise.all(
|
||||||
r.map(async (item) => ({
|
r.map(async (item) => ({
|
||||||
url: await customerStore.getAttachment(v.id, item),
|
url: await customerStore.getAttachment(v.id, item),
|
||||||
|
|
@ -848,6 +852,7 @@ export const useEmployeeForm = defineStore('form-employee', () => {
|
||||||
|
|
||||||
resetEmployeeData = {
|
resetEmployeeData = {
|
||||||
...playlond,
|
...playlond,
|
||||||
|
|
||||||
provinceId: province?.id,
|
provinceId: province?.id,
|
||||||
districtId: district?.id,
|
districtId: district?.id,
|
||||||
subDistrictId: subDistrict?.id,
|
subDistrictId: subDistrict?.id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue