pagination users, locations, vehicles, loads
This commit is contained in:
@@ -5,59 +5,90 @@
|
||||
import AttachmentsModal from '../components/AttachmentsModal.vue';
|
||||
import { useLoadsStore } from '../stores/loads';
|
||||
import FormLoadModal from '../components/FormLoadModal.vue';
|
||||
import ProposalsModal from '../components/ProposalsModal.vue';
|
||||
import CardEmpty from '../components/CardEmpty.vue';
|
||||
import ProposalsModal from '../components/ProposalsModal.vue';
|
||||
import CardEmpty from '../components/CardEmpty.vue';
|
||||
import Pagination from '../components/Pagination.vue';
|
||||
|
||||
const loadStore = useLoadsStore();
|
||||
const loading = ref(false);
|
||||
const query = ref('');
|
||||
const filterQuery = ref([]);
|
||||
const limit = 3;
|
||||
|
||||
onMounted(() =>{
|
||||
getDataLoadsInit();
|
||||
console.log('init')
|
||||
getDataLoadsInit(false);
|
||||
})
|
||||
|
||||
///loads?company=64fa70c130d2650011ac4f3a&$limit=3&$skip=0&status[$ne]=Closed&$sort%5BcreatedAt%5D=-1
|
||||
|
||||
watch(query, () => {
|
||||
filterQuery.value.skip = "$skip="+ 0;
|
||||
filterQuery.value.limit = "$limit="+ 100;
|
||||
if(query.value.length === 0){
|
||||
console.log('Clear manueal')
|
||||
// console.log(loadStore.loadsTotal)
|
||||
clearRequest();
|
||||
filterQuery.value.search = "";
|
||||
getLoadWithFilters(filterQuery.value);
|
||||
}
|
||||
});
|
||||
|
||||
const getDataLoadsInit = async() => {
|
||||
const getDataLoadsInit = async(reload) => {
|
||||
filterQuery.value.limit = '$limit=' + limit;
|
||||
filterQuery.value.skip = "$skip=0"
|
||||
filterQuery.value.status = "status[$ne]="+"Closed";
|
||||
loading.value = true;
|
||||
await loadStore.getCompanyLoads(filterQuery.value);
|
||||
await loadStore.getCompanyLoads(filterQuery.value, reload);
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const getLoadsByPage = async(data) => {
|
||||
console.log(data);
|
||||
loading.value = true;
|
||||
filterQuery.value.skip = "$skip="+ data.skip;
|
||||
loadStore.loadsCurrentPage = data.page
|
||||
await loadStore.getCompanyLoads(filterQuery.value, true)
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const getLoadWithFilters = async(filter) => {
|
||||
loading.value = true;
|
||||
await loadStore.getCompanyLoads(filter);
|
||||
await loadStore.getCompanyLoads(filter, true);
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const search = () => {
|
||||
if(query.value.length >= 2){
|
||||
// filterQuery.value = "company_name[$regex]=" + query.value + "&company_name[$options]=i";
|
||||
filterQuery.value.search = "posted_by_name[$regex]="+query.value+"&posted_by_name[$options]=i";
|
||||
getLoadWithFilters(filterQuery.value);
|
||||
}
|
||||
setTimeout(() => {
|
||||
if(query.value.length >= 2){
|
||||
// filterQuery.value = "company_name[$regex]=" + query.value + "&company_name[$options]=i";
|
||||
filterQuery.value.search = "posted_by_name[$regex]="+query.value+"&posted_by_name[$options]=i";
|
||||
getLoadWithFilters(filterQuery.value);
|
||||
}
|
||||
}, 100)
|
||||
|
||||
}
|
||||
|
||||
const clearFilter = () => {
|
||||
clearRequest();
|
||||
filterQuery.value.search = ""
|
||||
filterQuery.value.status = "status[$ne]="+"Closed";
|
||||
|
||||
console.log('click here');
|
||||
if(query.value == ''){
|
||||
getDataLoadsInit();
|
||||
getDataLoadsInit(true);
|
||||
} else {
|
||||
query.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
const clearRequest = () => {
|
||||
filterQuery.value.skip = "$skip="+ 0;
|
||||
filterQuery.value.limit = "$limit="+ limit;
|
||||
loadStore.loadsCurrentPage = 1;
|
||||
}
|
||||
|
||||
const loadHistory = () => {
|
||||
clearRequest();
|
||||
filterQuery.value.status = ""
|
||||
filterQuery.value.status = "status="+ "Closed";
|
||||
getLoadWithFilters(filterQuery.value);
|
||||
@@ -99,6 +130,12 @@ import CardEmpty from '../components/CardEmpty.vue';
|
||||
:load="load"
|
||||
/>
|
||||
<CardEmpty v-else text="No hay cargas agregadas"/>
|
||||
<Pagination
|
||||
:limit="limit"
|
||||
:total="loadStore.loadsTotal"
|
||||
:current-page="loadStore.loadsCurrentPage"
|
||||
@get-elements="getLoadsByPage"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user