This commit is contained in:
parent
6b3c510057
commit
e25896fa77
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { computed, ref, useAttrs, watch } from 'vue';
|
||||
import { useRouter, onBeforeRouteLeave } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
@ -17,6 +17,7 @@ const quasar = useQuasar();
|
|||
const stateStore = useStateStore();
|
||||
const { t } = useI18n();
|
||||
const { validate } = useValidator();
|
||||
const $attrs = useAttrs();
|
||||
|
||||
const $props = defineProps({
|
||||
model: {
|
||||
|
@ -113,9 +114,10 @@ onBeforeRouteLeave((to, from, next) => {
|
|||
});
|
||||
|
||||
async function fetch(data) {
|
||||
resetData(data);
|
||||
emit('onFetch', data);
|
||||
return data;
|
||||
const rows = $attrs['key-data'] ? data[$attrs['key-data']] : data;
|
||||
resetData(rows);
|
||||
emit('onFetch', rows);
|
||||
return rows;
|
||||
}
|
||||
|
||||
function resetData(data) {
|
||||
|
|
|
@ -314,7 +314,11 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) {
|
|||
show-if-above
|
||||
>
|
||||
<QScrollArea class="fit">
|
||||
<VnTableFilter :data-key="$attrs['data-key']" :columns="columns" :redirect="redirect" />
|
||||
<VnTableFilter
|
||||
:data-key="$attrs['data-key']"
|
||||
:columns="columns"
|
||||
:redirect="redirect"
|
||||
/>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<CrudModel
|
||||
|
|
|
@ -78,6 +78,10 @@ const props = defineProps({
|
|||
type: String,
|
||||
default: '',
|
||||
},
|
||||
keyData: {
|
||||
type: String,
|
||||
default: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['onFetch', 'onPaginate', 'onChange']);
|
||||
|
@ -255,7 +259,7 @@ defineExpose({
|
|||
:disable="disableInfiniteScroll || !store.hasMoreData"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<slot name="body" :rows="store.data"></slot>
|
||||
<slot name="body" :rows="keyData ? store.data[keyData] : store.data"></slot>
|
||||
<div v-if="isLoading" class="spinner info-row q-pa-md text-center">
|
||||
<QSpinner color="primary" size="md" />
|
||||
</div>
|
||||
|
|
|
@ -11,14 +11,14 @@ import VnInput from 'src/components/common/VnInput.vue';
|
|||
import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue';
|
||||
import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const dataRef = ref(null);
|
||||
|
||||
const balanceDueTotal = ref(0);
|
||||
const selected = ref([]);
|
||||
|
||||
const arrayData = useArrayData('CustomerDefaulter');
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
|
@ -165,26 +165,37 @@ const viewAddObservation = (rowsSelected) => {
|
|||
});
|
||||
};
|
||||
|
||||
const onFetch = async (data) => {
|
||||
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
|
||||
};
|
||||
|
||||
function exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'clientFk':
|
||||
return { [`d.${param}`]: value };
|
||||
case 'creditInsurance':
|
||||
case 'amount':
|
||||
case 'workerFk':
|
||||
case 'departmentFk':
|
||||
case 'countryFk':
|
||||
case 'payMethod':
|
||||
case 'salesPersonFk':
|
||||
case 'creditInsurance':
|
||||
case 'countryFk':
|
||||
return { [`c.${param}`]: value };
|
||||
case 'payMethod':
|
||||
return { [`c.payMethodFk`]: value };
|
||||
case 'workerFk':
|
||||
return { [`co.${param}`]: value };
|
||||
case 'departmentFk':
|
||||
return { [`wd.${param}`]: value };
|
||||
case 'amount':
|
||||
case 'clientFk':
|
||||
return { [`d.${param}`]: value };
|
||||
case 'created':
|
||||
return { 'd.created': { between: dateRange(value) } };
|
||||
case 'defaulterSinced':
|
||||
return { 'd.defaulterSinced': { between: dateRange(value) } };
|
||||
case 'isWorker': {
|
||||
if (value == undefined) return;
|
||||
const search = value ? 'worker' : { neq: 'worker' };
|
||||
return { 'c.businessTypeFk': search };
|
||||
}
|
||||
case 'hasRecovery': {
|
||||
if (value == undefined) return;
|
||||
const search = value ? null : { neq: null };
|
||||
return { 'r.finished': search };
|
||||
}
|
||||
case 'observation':
|
||||
return { 'co.text': { like: `%${value}%` } };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -192,7 +203,7 @@ function exprBuilder(param, value) {
|
|||
<template>
|
||||
<VnSubToolbar>
|
||||
<template #st-data>
|
||||
<CustomerBalanceDueTotal :amount="balanceDueTotal" />
|
||||
<CustomerBalanceDueTotal :amount="arrayData.store.data?.amount" />
|
||||
</template>
|
||||
<template #st-actions>
|
||||
<QBtn
|
||||
|
@ -211,8 +222,6 @@ function exprBuilder(param, value) {
|
|||
url="Defaulters/filter"
|
||||
:expr-builder="exprBuilder"
|
||||
:columns="columns"
|
||||
@on-fetch="onFetch"
|
||||
:use-model="true"
|
||||
:table="{
|
||||
'row-key': 'clientFk',
|
||||
selection: 'multiple',
|
||||
|
@ -221,6 +230,7 @@ function exprBuilder(param, value) {
|
|||
:disable-option="{ card: true }"
|
||||
auto-load
|
||||
:order="['amount DESC']"
|
||||
key-data="defaulters"
|
||||
>
|
||||
<template #column-clientFk="{ row }">
|
||||
<span class="link" @click.stop>
|
||||
|
|
Loading…
Reference in New Issue