Merge branch 'dev' into 7031-zonePrice
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
91c9a4a559
|
@ -1,9 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { reactive, onMounted, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useState } from 'composables/useState';
|
|
||||||
import FormModelPopup from 'components/FormModelPopup.vue';
|
import FormModelPopup from 'components/FormModelPopup.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
import VnSelect from 'components/common/VnSelect.vue';
|
||||||
|
@ -11,29 +10,12 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
import { useDialogPluginComponent } from 'quasar';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const state = useState();
|
|
||||||
const ORDER_MODEL = 'order';
|
const ORDER_MODEL = 'order';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const agencyList = ref([]);
|
const agencyList = ref([]);
|
||||||
const addressList = ref([]);
|
|
||||||
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
defineEmits(['confirm', ...useDialogPluginComponent.emits]);
|
||||||
|
|
||||||
const fetchAddressList = async (addressId) => {
|
|
||||||
const { data } = await axios.get('addresses', {
|
|
||||||
params: {
|
|
||||||
filter: JSON.stringify({
|
|
||||||
fields: ['id', 'nickname', 'street', 'city'],
|
|
||||||
where: { id: addressId },
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
addressList.value = data;
|
|
||||||
if (addressList.value?.length === 1) {
|
|
||||||
state.get(ORDER_MODEL).addressId = addressList.value[0].id;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchAgencyList = async (landed, addressFk) => {
|
const fetchAgencyList = async (landed, addressFk) => {
|
||||||
if (!landed || !addressFk) {
|
if (!landed || !addressFk) {
|
||||||
return;
|
return;
|
||||||
|
@ -59,17 +41,9 @@ const initialFormState = reactive({
|
||||||
clientFk: $props.clientFk,
|
clientFk: $props.clientFk,
|
||||||
});
|
});
|
||||||
|
|
||||||
const onClientChange = async (clientId = $props.clientFk) => {
|
|
||||||
const { data } = await axios.get(`Clients/${clientId}`);
|
|
||||||
await fetchAddressList(data.defaultAddressFk);
|
|
||||||
};
|
|
||||||
|
|
||||||
async function onDataSaved(_, id) {
|
async function onDataSaved(_, id) {
|
||||||
await router.push({ path: `/order/${id}/catalog` });
|
await router.push({ path: `/order/${id}/catalog` });
|
||||||
}
|
}
|
||||||
onMounted(async () => {
|
|
||||||
await onClientChange();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -90,10 +64,9 @@ onMounted(async () => {
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
:filter="{
|
:filter="{
|
||||||
fields: ['id', 'name', 'defaultAddressFk'],
|
fields: ['id', 'name'],
|
||||||
}"
|
}"
|
||||||
hide-selected
|
hide-selected
|
||||||
@update:model-value="onClientChange"
|
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
@ -110,7 +83,7 @@ onMounted(async () => {
|
||||||
:label="t('order.form.addressFk')"
|
:label="t('order.form.addressFk')"
|
||||||
v-model="data.addressId"
|
v-model="data.addressId"
|
||||||
url="addresses"
|
url="addresses"
|
||||||
:fields="['id', 'nickname', 'defaultAddressFk', 'street', 'city']"
|
:fields="['id', 'nickname', 'street', 'city']"
|
||||||
sort-by="id"
|
sort-by="id"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="street"
|
option-label="street"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, ref, onMounted } from 'vue';
|
||||||
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
|
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
|
||||||
import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
|
import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
|
@ -15,14 +15,13 @@ import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vu
|
||||||
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
|
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
|
||||||
import { toDateTimeFormat } from 'src/filters/date';
|
import { toDateTimeFormat } from 'src/filters/date';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import dataByOrder from 'src/utils/dataByOrder';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const tableRef = ref();
|
const tableRef = ref();
|
||||||
const agencyList = ref([]);
|
const agencyList = ref([]);
|
||||||
const addressesList = ref([]);
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const addressOptions = ref([]);
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
@ -148,16 +147,12 @@ onMounted(() => {
|
||||||
const id = JSON.parse(clientId);
|
const id = JSON.parse(clientId);
|
||||||
fetchClientAddress(id.clientFk);
|
fetchClientAddress(id.clientFk);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function fetchClientAddress(id, formData = {}) {
|
async function fetchClientAddress(id, formData = {}) {
|
||||||
const { data } = await axios.get(`Clients/${id}`, {
|
const { data } = await axios.get(
|
||||||
params: {
|
`Clients/${id}/addresses?filter[order]=isActive DESC`
|
||||||
filter: {
|
);
|
||||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
addressOptions.value = data;
|
||||||
include: { relation: 'addresses' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
addressesList.value = data.addresses;
|
|
||||||
formData.addressId = data.defaultAddressFk;
|
formData.addressId = data.defaultAddressFk;
|
||||||
fetchAgencies(formData);
|
fetchAgencies(formData);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +163,7 @@ async function fetchAgencies({ landed, addressId }) {
|
||||||
const { data } = await axios.get('Agencies/landsThatDay', {
|
const { data } = await axios.get('Agencies/landsThatDay', {
|
||||||
params: { addressFk: addressId, landed },
|
params: { addressFk: addressId, landed },
|
||||||
});
|
});
|
||||||
agencyList.value = dataByOrder(data, 'agencyMode ASC');
|
agencyList.value = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDateColor = (date) => {
|
const getDateColor = (date) => {
|
||||||
|
@ -252,34 +247,29 @@ const getDateColor = (date) => {
|
||||||
</VnSelect>
|
</VnSelect>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
v-model="data.addressId"
|
v-model="data.addressId"
|
||||||
:options="addressesList"
|
:options="addressOptions"
|
||||||
:label="t('module.address')"
|
:label="t('module.address')"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="nickname"
|
option-label="nickname"
|
||||||
@update:model-value="() => fetchAgencies(data)"
|
@update:model-value="() => fetchAgencies(data)"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem
|
<QItem v-bind="scope.itemProps">
|
||||||
v-bind="scope.itemProps"
|
|
||||||
:class="{ disabled: !scope.opt.isActive }"
|
|
||||||
>
|
|
||||||
<QItemSection style="min-width: min-content" avatar>
|
|
||||||
<QIcon
|
|
||||||
v-if="
|
|
||||||
scope.opt.isActive && data.addressId === scope.opt.id
|
|
||||||
"
|
|
||||||
size="sm"
|
|
||||||
color="grey"
|
|
||||||
name="star"
|
|
||||||
class="fill-icon"
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<QItemLabel>
|
<QItemLabel
|
||||||
{{ scope.opt.nickname }}
|
:class="{
|
||||||
</QItemLabel>
|
'color-vn-label': !scope.opt?.isActive,
|
||||||
<QItemLabel caption>
|
}"
|
||||||
{{ `${scope.opt.street}, ${scope.opt.city}` }}
|
>
|
||||||
|
{{
|
||||||
|
`${
|
||||||
|
!scope.opt?.isActive
|
||||||
|
? t('basicData.inactive')
|
||||||
|
: ''
|
||||||
|
} `
|
||||||
|
}}
|
||||||
|
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
|
||||||
|
{{ scope.opt?.city }}
|
||||||
</QItemLabel>
|
</QItemLabel>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
Loading…
Reference in New Issue