forked from verdnatura/salix-front
fix: #5926 fix downdload function
This commit is contained in:
parent
c626a10a98
commit
ea0398df61
|
@ -14,7 +14,7 @@ import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
const FILECABINET_ID = 'hr';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const loadingDocuware = ref(true);
|
const loadingDocuware = ref(true);
|
||||||
|
@ -52,13 +52,13 @@ function reloadData() {
|
||||||
|
|
||||||
const handleSendToTablet = async (row) => {
|
const handleSendToTablet = async (row) => {
|
||||||
try {
|
try {
|
||||||
// if (isProduction(false)) {
|
if (isProduction(false)) {
|
||||||
const { deviceProductionFk } = row;
|
const { deviceProductionFk } = row;
|
||||||
await axios.post(`Docuwares/upload`, {
|
await axios.post(`Docuwares/upload`, {
|
||||||
fileCabinet: 'hr',
|
fileCabinet: FILECABINET_ID,
|
||||||
ids: [deviceProductionFk],
|
ids: [deviceProductionFk],
|
||||||
});
|
});
|
||||||
// }
|
}
|
||||||
notify(t('PDF sended to signed'), 'positive');
|
notify(t('PDF sended to signed'), 'positive');
|
||||||
row.isDocuware = true;
|
row.isDocuware = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -67,7 +67,7 @@ const handleSendToTablet = async (row) => {
|
||||||
};
|
};
|
||||||
function checkFileFocuware({ deviceProductionFk }, signed) {
|
function checkFileFocuware({ deviceProductionFk }, signed) {
|
||||||
return axios.post(`Docuwares/${deviceProductionFk}/checkFile`, {
|
return axios.post(`Docuwares/${deviceProductionFk}/checkFile`, {
|
||||||
fileCabinet: 'hr',
|
fileCabinet: FILECABINET_ID,
|
||||||
signed,
|
signed,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ const handleDownloadDocuware = async (row) => {
|
||||||
try {
|
try {
|
||||||
if (isProduction(false)) {
|
if (isProduction(false)) {
|
||||||
const { deviceProductionFk } = row;
|
const { deviceProductionFk } = row;
|
||||||
await axios.post(`Docuwares/upload`, {
|
await axios.post(`Docuwares/download`, {
|
||||||
fileCabinet: 'hr',
|
fileCabinet: FILECABINET_ID,
|
||||||
ids: [deviceProductionFk],
|
ids: [deviceProductionFk],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -96,30 +96,33 @@ const handleDownloadDocuware = async (row) => {
|
||||||
console.error('Error removing department');
|
console.error('Error removing department');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
function handlePromiseDocuware(promise, deviceProductions) {
|
||||||
async function fetchDocuware(deviceProductions) {
|
|
||||||
let promisesIsDocuware = deviceProductions.map((device) =>
|
|
||||||
checkFileFocuware(device, false)
|
|
||||||
);
|
|
||||||
let promisesIsSigned = [];
|
|
||||||
promisesIsDocuware = await Promise.all(promisesIsDocuware);
|
|
||||||
promisesIsDocuware.forEach((promise) => {
|
|
||||||
const id = +promise.config.url.match(/\d+/)[0];
|
const id = +promise.config.url.match(/\d+/)[0];
|
||||||
const deviceProduction = deviceProductions.find(
|
const deviceProduction = deviceProductions.find(
|
||||||
({ deviceProductionFk }) => deviceProductionFk === id
|
({ deviceProductionFk }) => deviceProductionFk === id
|
||||||
);
|
);
|
||||||
|
return deviceProduction;
|
||||||
|
}
|
||||||
|
async function fetchDocuware(deviceProductions) {
|
||||||
|
const promisesIsDocuware = await Promise.allSettled(
|
||||||
|
deviceProductions.map((device) => checkFileFocuware(device, false))
|
||||||
|
);
|
||||||
|
|
||||||
|
let promisesIsSigned = [];
|
||||||
|
promisesIsDocuware.forEach(({ value: promise }) => {
|
||||||
|
const deviceProduction = handlePromiseDocuware(promise, deviceProductions);
|
||||||
if (!deviceProduction) return;
|
if (!deviceProduction) return;
|
||||||
|
|
||||||
deviceProduction.isDocuware = promise.data;
|
deviceProduction.isDocuware = promise.data;
|
||||||
if (promise.data)
|
if (promise.data)
|
||||||
promisesIsSigned.push(checkFileFocuware(deviceProduction, true));
|
promisesIsSigned.push(checkFileFocuware(deviceProduction, true));
|
||||||
});
|
});
|
||||||
promisesIsSigned = await Promise.all(promisesIsSigned);
|
|
||||||
promisesIsSigned.forEach((promise) => {
|
promisesIsSigned = await Promise.allSettled(promisesIsSigned);
|
||||||
const id = +promise.config.url.match(/\d+/)[0];
|
promisesIsSigned.forEach(({ value: promise }) => {
|
||||||
const deviceProduction = deviceProductions.find(
|
const deviceProduction = handlePromiseDocuware(promise, deviceProductions);
|
||||||
({ deviceProductionFk }) => deviceProductionFk === id
|
|
||||||
);
|
|
||||||
if (!deviceProduction) return;
|
if (!deviceProduction) return;
|
||||||
|
|
||||||
deviceProduction.isSigned = !!promise.data.id;
|
deviceProduction.isSigned = !!promise.data.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue