refactor: refs #7274 changed CustomerNotificationsCampaignConsumption template and logic
This commit is contained in:
parent
c2ba7bfe22
commit
3467f30b12
|
@ -1,10 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import { QBtn } from 'quasar';
|
import { QBtn } from 'quasar';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import CustomerNotificationsFilter from './CustomerNotificationsFilter.vue';
|
import CustomerNotificationsFilter from './CustomerNotificationsFilter.vue';
|
||||||
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
|
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
|
||||||
|
@ -13,14 +10,10 @@ import { useStateStore } from 'stores/useStateStore';
|
||||||
import CustomerNotificationsCampaignConsumption from './CustomerNotificationsCampaignConsumption.vue';
|
import CustomerNotificationsCampaignConsumption from './CustomerNotificationsCampaignConsumption.vue';
|
||||||
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const rows = ref([]);
|
const rows = ref([]);
|
||||||
const selected = ref([]);
|
const selected = ref([]);
|
||||||
const selectedCustomerId = ref(0);
|
const selectedCustomerId = ref(0);
|
||||||
const quasar = useQuasar();
|
|
||||||
const dataRef = ref(null);
|
|
||||||
|
|
||||||
const tableColumnComponents = {
|
const tableColumnComponents = {
|
||||||
id: {
|
id: {
|
||||||
|
@ -86,19 +79,6 @@ const columns = computed(() => [
|
||||||
const selectCustomerId = (id) => {
|
const selectCustomerId = (id) => {
|
||||||
selectedCustomerId.value = id;
|
selectedCustomerId.value = id;
|
||||||
};
|
};
|
||||||
|
|
||||||
const campaignConsumption = () => {
|
|
||||||
quasar.dialog({
|
|
||||||
component: CustomerNotificationsCampaignConsumption,
|
|
||||||
componentProps: {
|
|
||||||
clients: selected,
|
|
||||||
promise: refreshData,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const refreshData = async () => {
|
|
||||||
await dataRef.value.fetch();
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -117,8 +97,8 @@ const refreshData = async () => {
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</div>
|
</div>
|
||||||
</Teleport></template
|
</Teleport>
|
||||||
>
|
</template>
|
||||||
<FetchData
|
<FetchData
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
@on-fetch="(data) => (rows = data)"
|
@on-fetch="(data) => (rows = data)"
|
||||||
|
@ -133,15 +113,11 @@ const refreshData = async () => {
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<VnSubToolbar class="justify-end">
|
<VnSubToolbar class="justify-end">
|
||||||
<template #st-data>
|
<template #st-data>
|
||||||
<QBtn
|
<CustomerNotificationsCampaignConsumption
|
||||||
icon="show_chart"
|
:selected-rows="selected.length > 0"
|
||||||
color="primary"
|
:clients="selected"
|
||||||
class="q-mr-sm"
|
:promise="refreshData"
|
||||||
:disabled="!selected.length"
|
/>
|
||||||
@click="campaignConsumption"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t('Campaign consumption') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
<QPage class="column items-center q-pa-md">
|
<QPage class="column items-center q-pa-md">
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useDialogPluginComponent } from 'quasar';
|
|
||||||
import useNotify from 'src/composables/useNotify';
|
import useNotify from 'src/composables/useNotify';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
@ -19,23 +18,24 @@ const $props = defineProps({
|
||||||
type: Function,
|
type: Function,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
selectedRows: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { dialogRef } = useDialogPluginComponent();
|
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const validationsStore = useValidator();
|
const validationsStore = useValidator();
|
||||||
const campaignParams = reactive({});
|
const campaignParams = reactive({});
|
||||||
const moreFields = ref([]);
|
const moreFields = ref([]);
|
||||||
|
|
||||||
async function onSubmit() {
|
const onSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const data = {
|
const data = {
|
||||||
clients: $props.clients._value.map((item) => item.id),
|
clients: $props.clients.map((item) => item.id),
|
||||||
from: this.campaignParams.from,
|
from: campaignParams.from,
|
||||||
to: this.campaignParams.to,
|
to: campaignParams.to,
|
||||||
};
|
};
|
||||||
|
|
||||||
const params = JSON.stringify(data);
|
const params = JSON.stringify(data);
|
||||||
await axios.post('ClientConsumptionQueues', { params });
|
await axios.post('ClientConsumptionQueues', { params });
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ async function onSubmit() {
|
||||||
} 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,44 +68,41 @@ 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
|
||||||
/>
|
/>
|
||||||
<QDialog ref="dialogRef">
|
<QBtn color="primary" icon="show_chart" :disable="!selectedRows">
|
||||||
<QCard class="q-pa-md q-mb-md">
|
<QPopupProxy ref="popupProxyRef">
|
||||||
<QCardSection>
|
<QCard class="column q-pa-md">
|
||||||
<QForm @submit="onSubmit()" class="q-pa-sm">
|
<span class="text-body1 q-mb-sm">{{ t('Campaign consumption') }}</span>
|
||||||
<div>
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
{{ t('Campaign consumption') }}
|
<QSelect
|
||||||
</div>
|
:options="moreFields"
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
v-model="campaignParams.campaign"
|
||||||
<QSelect
|
:label="t('Campaign')"
|
||||||
:options="moreFields"
|
option-label="label"
|
||||||
v-model="campaignParams.campaign"
|
/>
|
||||||
:label="t('Campaign')"
|
</VnRow>
|
||||||
option-label="label"
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
/>
|
<VnInputDate v-model="campaignParams.from" :label="t('From')" />
|
||||||
</VnRow>
|
<VnInputDate v-model="campaignParams.to" :label="t('To')" />
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
</VnRow>
|
||||||
<VnInputDate v-model="campaignParams.from" :label="t('From')" />
|
<div class="q-mt-lg row justify-end">
|
||||||
<VnInputDate v-model="campaignParams.to" :label="t('To')" />
|
<QBtn
|
||||||
</VnRow>
|
:label="t('globals.cancel')"
|
||||||
<div class="q-mt-lg row justify-end">
|
color="primary"
|
||||||
<QBtn
|
flat
|
||||||
:label="t('globals.cancel')"
|
class="q-mr-md"
|
||||||
color="primary"
|
v-close-popup
|
||||||
flat
|
/>
|
||||||
class="q-mr-md"
|
<QBtn
|
||||||
v-close-popup
|
:label="t('globals.save')"
|
||||||
/>
|
type="submit"
|
||||||
<QBtn
|
color="primary"
|
||||||
:label="t('globals.save')"
|
@click="onSubmit()"
|
||||||
type="submit"
|
/>
|
||||||
color="primary"
|
</div>
|
||||||
v-close-popup
|
</QCard>
|
||||||
/>
|
</QPopupProxy>
|
||||||
</div>
|
<QTooltip>{{ t('Campaign consumption') }}</QTooltip>
|
||||||
</QForm>
|
</QBtn>
|
||||||
</QCardSection>
|
|
||||||
</QCard>
|
|
||||||
</QDialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
Loading…
Reference in New Issue