fix: #7274
gitea/salix-front/pipeline/pr-test This commit looks good Details

This commit is contained in:
Jon Elias 2024-05-06 14:59:23 +02:00
parent 179ab30805
commit 6ce57d3c40
1 changed files with 26 additions and 6 deletions

View File

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