This commit is contained in:
parent
179ab30805
commit
6ce57d3c40
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, toRefs } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify';
|
import useNotify from 'src/composables/useNotify';
|
||||||
|
@ -7,8 +7,8 @@ import { useValidator } from 'src/composables/useValidator';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
|
import { watch } from 'vue';
|
||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
clients: {
|
clients: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
@ -23,27 +23,41 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { selectedRows } = toRefs($props);
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
const campaignParams = reactive({});
|
const campaignParams = ref(null);
|
||||||
const moreFields = ref([]);
|
const moreFields = ref([]);
|
||||||
|
const popupProxyRef = ref(null);
|
||||||
|
const upcomingOptions = ref(null);
|
||||||
|
|
||||||
|
watch(selectedRows, () => {
|
||||||
|
const from = new Date(upcomingOptions.value.dated);
|
||||||
|
from.setDate(from.getDate() - upcomingOptions.value.scopeDays);
|
||||||
|
campaignParams.value = {
|
||||||
|
code: upcomingOptions.value.code,
|
||||||
|
from: from,
|
||||||
|
to: upcomingOptions.value.dated,
|
||||||
|
};
|
||||||
|
});
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
clients: $props.clients.map((item) => item.id),
|
clients: $props.clients.map((item) => item.id),
|
||||||
from: campaignParams.from,
|
from: campaignParams.value.from,
|
||||||
to: campaignParams.to,
|
to: campaignParams.value.to,
|
||||||
};
|
};
|
||||||
const params = JSON.stringify(data);
|
const params = JSON.stringify(data);
|
||||||
await axios.post('ClientConsumptionQueues', { params });
|
await axios.post('ClientConsumptionQueues', { params });
|
||||||
|
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
|
popupProxyRef.value.hide();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notify(error.message, 'negative');
|
notify(error.message, 'negative');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const { models } = validationsStore;
|
const { models } = validationsStore;
|
||||||
const properties = models.Item?.properties || {};
|
const properties = models.Item?.properties || {};
|
||||||
|
@ -68,14 +82,20 @@ onMounted(async () => {
|
||||||
:filter="{ fields: ['id', 'code', 'dated'], order: 'code ASC', limit: 30 }"
|
:filter="{ fields: ['id', 'code', 'dated'], order: 'code ASC', limit: 30 }"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="Campaigns/upcoming"
|
||||||
|
@on-fetch="(data) => (upcomingOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<QBtn color="primary" icon="show_chart" :disable="!selectedRows">
|
<QBtn color="primary" icon="show_chart" :disable="!selectedRows">
|
||||||
<QPopupProxy ref="popupProxyRef">
|
<QPopupProxy ref="popupProxyRef">
|
||||||
<QCard class="column q-pa-md">
|
<QCard class="column q-pa-md">
|
||||||
|
{{ campaignParams }}
|
||||||
<span class="text-body1 q-mb-sm">{{ t('Campaign consumption') }}</span>
|
<span class="text-body1 q-mb-sm">{{ t('Campaign consumption') }}</span>
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<QSelect
|
<QSelect
|
||||||
:options="moreFields"
|
:options="moreFields"
|
||||||
v-model="campaignParams.campaign"
|
v-model="campaignParams.code"
|
||||||
:label="t('Campaign')"
|
:label="t('Campaign')"
|
||||||
option-label="label"
|
option-label="label"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue