forked from verdnatura/salix-front
Implement Route autonomous dms
This commit is contained in:
parent
b2be4c1380
commit
1073512aae
|
@ -27,6 +27,10 @@ const $props = defineProps({
|
|||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const warehouses = ref();
|
||||
|
@ -65,14 +69,15 @@ function mapperDms(data) {
|
|||
}
|
||||
|
||||
function getUrl() {
|
||||
if ($props.url) return $props.url;
|
||||
if ($props.formInitialData) return 'dms/' + $props.formInitialData.id + '/updateFile';
|
||||
return `${$props.model}/${route.params.id}/uploadFile`;
|
||||
}
|
||||
|
||||
async function save() {
|
||||
const body = mapperDms(dms.value);
|
||||
await axios.post(getUrl(), body[0], body[1]);
|
||||
emit('onDataSaved', body[1].params);
|
||||
const response = await axios.post(getUrl(), body[0], body[1]);
|
||||
emit('onDataSaved', body[1].params, response);
|
||||
}
|
||||
|
||||
function defaultData() {
|
||||
|
|
|
@ -12,8 +12,11 @@ import VnLv from 'components/ui/VnLv.vue';
|
|||
import useNotify from 'composables/useNotify';
|
||||
import RouteAutonomousFilter from 'pages/Route/Card/RouteAutonomousFilter.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import RouteSummary from "pages/Route/Card/RouteSummary.vue";
|
||||
import {useSummaryDialog} from "composables/useSummaryDialog";
|
||||
import RouteSummary from 'pages/Route/Card/RouteSummary.vue';
|
||||
import { useSummaryDialog } from 'composables/useSummaryDialog';
|
||||
import VnDms from 'components/common/VnDms.vue';
|
||||
import { useState } from 'composables/useState';
|
||||
import axios from 'axios';
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const { t } = useI18n();
|
||||
|
@ -24,6 +27,13 @@ const { viewSummary } = useSummaryDialog();
|
|||
onMounted(() => (stateStore.rightDrawer = true));
|
||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||
|
||||
const state = useState();
|
||||
const user = state.getUser();
|
||||
const dmsDialog = ref({
|
||||
show: false,
|
||||
initialForm: {},
|
||||
rowsToCreateInvoiceIn: [],
|
||||
});
|
||||
const selectedRows = ref([]);
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -108,8 +118,8 @@ const refreshKey = ref(0);
|
|||
|
||||
const total = computed(() => selectedRows.value.reduce((item) => item?.price || 0, 0));
|
||||
|
||||
const openCreateInvoiceIn = () => {
|
||||
const rowsToCreateInvoiceIn = selectedRows.value
|
||||
const openDmsUploadDialog = async () => {
|
||||
dmsDialog.value.rowsToCreateInvoiceIn = selectedRows.value
|
||||
.filter(
|
||||
(agencyTerm) => agencyTerm.supplierFk === selectedRows.value?.[0].supplierFk
|
||||
)
|
||||
|
@ -120,20 +130,44 @@ const openCreateInvoiceIn = () => {
|
|||
totalPrice: total.value,
|
||||
}));
|
||||
|
||||
if (rowsToCreateInvoiceIn.length !== selectedRows.value.length) {
|
||||
if (dmsDialog.value.rowsToCreateInvoiceIn.length !== selectedRows.value.length) {
|
||||
dmsDialog.value.rowsToCreateInvoiceIn = [];
|
||||
dmsDialog.value.initialForm = null;
|
||||
return notify(t('Two autonomous cannot be counted at the same time'), 'negative');
|
||||
}
|
||||
|
||||
const params = encodeURI(JSON.stringify({
|
||||
supplierName: selectedRows.value?.[0].supplierName,
|
||||
rows: rowsToCreateInvoiceIn,
|
||||
}));
|
||||
const dmsType = await axios
|
||||
.get('DmsTypes/findOne', {
|
||||
filter: {
|
||||
where: { code: 'invoiceIn' },
|
||||
},
|
||||
})
|
||||
.then((res) => res.data);
|
||||
|
||||
router.push({ name: 'RouteAutonomousCreateInvoiceIn', query: { q: params } });
|
||||
dmsDialog.value.initialForm = {
|
||||
description: selectedRows.value?.[0].supplierName,
|
||||
companyFk: user.value.companyFk,
|
||||
warehouseFk: user.value.warehouseFk,
|
||||
dmsTypeFk: dmsType?.id,
|
||||
};
|
||||
dmsDialog.value.show = true;
|
||||
};
|
||||
|
||||
const onDmsSaved = async (dms, response) => {
|
||||
if (response) {
|
||||
await axios.post('AgencyTerms/createInvoiceIn', {
|
||||
rows: dmsDialog.value.rowsToCreateInvoiceIn,
|
||||
dms: response.data,
|
||||
});
|
||||
}
|
||||
dmsDialog.value.show = false;
|
||||
dmsDialog.value.initialForm = null;
|
||||
dmsDialog.value.rowsToCreateInvoiceIn = [];
|
||||
refreshKey.value++;
|
||||
};
|
||||
|
||||
function navigateToRouteSummary(event, row) {
|
||||
router.push({ name: 'RouteSummary', params: { id: row.routeFk } })
|
||||
router.push({ name: 'RouteSummary', params: { id: row.routeFk } });
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -238,7 +272,12 @@ function navigateToRouteSummary(event, row) {
|
|||
name="preview"
|
||||
size="xs"
|
||||
color="primary"
|
||||
@click.stop="viewSummary(props?.row?.routeFk, RouteSummary)"
|
||||
@click.stop="
|
||||
viewSummary(
|
||||
props?.row?.routeFk,
|
||||
RouteSummary
|
||||
)
|
||||
"
|
||||
>
|
||||
<QTooltip>{{ t('Preview') }}</QTooltip>
|
||||
</QIcon>
|
||||
|
@ -255,7 +294,7 @@ function navigateToRouteSummary(event, row) {
|
|||
fab
|
||||
icon="vn:invoice-in-create"
|
||||
color="primary"
|
||||
@click="openCreateInvoiceIn"
|
||||
@click="openDmsUploadDialog"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Create invoiceIn') }}
|
||||
|
@ -263,6 +302,14 @@ function navigateToRouteSummary(event, row) {
|
|||
</QBtn>
|
||||
</QPageSticky>
|
||||
</QPage>
|
||||
<QDialog v-model="dmsDialog.show">
|
||||
<VnDms
|
||||
url="dms/uploadFile"
|
||||
model="AgencyTerms"
|
||||
:form-initial-data="dmsDialog.initialForm"
|
||||
@on-data-saved="onDmsSaved"
|
||||
/>
|
||||
</QDialog>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
Loading…
Reference in New Issue