refactor(WorkerPda): refs #5926 optimize fetchDocuware and sendToTablet functions for better readability
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
f7d3b340ca
commit
63cf602ab2
|
@ -88,12 +88,11 @@ function reloadData() {
|
||||||
|
|
||||||
async function fetchDocuware() {
|
async function fetchDocuware() {
|
||||||
loadingDocuware.value = true;
|
loadingDocuware.value = true;
|
||||||
const id = worker.value?.lastName + ' ' + worker.value?.firstName;
|
|
||||||
const promises = [];
|
|
||||||
|
|
||||||
for (const row of tableRef.value.CrudModelRef.formData) {
|
const id = `${worker.value?.lastName} ${worker.value?.firstName}`;
|
||||||
promises.push(
|
const rows = tableRef.value.CrudModelRef.formData;
|
||||||
(async () => {
|
|
||||||
|
const promises = rows.map(async (row) => {
|
||||||
const { data } = await axios.post(`Docuwares/${id}/checkFile`, {
|
const { data } = await axios.post(`Docuwares/${id}/checkFile`, {
|
||||||
fileCabinet: 'hr',
|
fileCabinet: 'hr',
|
||||||
signed: false,
|
signed: false,
|
||||||
|
@ -104,32 +103,25 @@ async function fetchDocuware() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DBName: 'FILENAME',
|
DBName: 'FILENAME',
|
||||||
Value: [row.deviceProductionFk + '-pda'],
|
Value: [`${row.deviceProductionFk}-pda`],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
row.docuware = data;
|
row.docuware = data;
|
||||||
})(),
|
});
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.allSettled(promises);
|
||||||
loadingDocuware.value = false;
|
loadingDocuware.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendToTablet(rows) {
|
async function sendToTablet(rows) {
|
||||||
const promises = [];
|
const promises = rows.map(async (row) => {
|
||||||
for (const row of rows) {
|
|
||||||
promises.push(
|
|
||||||
(async () => {
|
|
||||||
await axios.post(`Docuwares/upload-pda-pdf`, {
|
await axios.post(`Docuwares/upload-pda-pdf`, {
|
||||||
ids: [row.deviceProductionFk],
|
ids: [row.deviceProductionFk],
|
||||||
});
|
});
|
||||||
row.docuware = true;
|
row.docuware = true;
|
||||||
})(),
|
});
|
||||||
);
|
await Promise.allSettled(promises);
|
||||||
}
|
|
||||||
await Promise.all(promises);
|
|
||||||
notify(t('PDF sended to signed'), 'positive');
|
notify(t('PDF sended to signed'), 'positive');
|
||||||
tableRef.value.reload();
|
tableRef.value.reload();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue