forked from verdnatura/salix-front
Merge pull request 'Se mejora logica de descarga csv' (#14) from features/ms_32_descargar_csv_2 into dev
Reviewed-on: hyervoni/salix-front-mindshore#14
This commit is contained in:
commit
ac39a2d398
|
@ -2,6 +2,8 @@
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
addElement: { type: Function, required: true },
|
||||||
|
element: { type: Object, default: null },
|
||||||
id: { type: Number, default: null },
|
id: { type: Number, default: null },
|
||||||
isSelected: { type: Boolean, default: false },
|
isSelected: { type: Boolean, default: false },
|
||||||
title: { type: String, default: null },
|
title: { type: String, default: null },
|
||||||
|
@ -14,6 +16,10 @@ watch(
|
||||||
checkSelect.value = value;
|
checkSelect.value = value;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectedItem = (item) => {
|
||||||
|
$props.addElement(item);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -29,7 +35,10 @@ watch(
|
||||||
ID: {{ $props.id }}
|
ID: {{ $props.id }}
|
||||||
</QChip>
|
</QChip>
|
||||||
</div>
|
</div>
|
||||||
<QCheckbox v-model="checkSelect" />
|
<QCheckbox
|
||||||
|
v-model="checkSelect"
|
||||||
|
@click="selectedItem($props.element)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</slot>
|
</slot>
|
||||||
<div class="card-list-body">
|
<div class="card-list-body">
|
||||||
|
|
|
@ -13,10 +13,11 @@ import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import CardList2 from 'src/components/ui/CardList2.vue';
|
import CardList2 from 'src/components/ui/CardList2.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const arrayElements = ref([]);
|
||||||
const manageCheckboxes = ref(false);
|
const manageCheckboxes = ref(false);
|
||||||
const showSelect = ref(false);
|
|
||||||
const quasar = useQuasar();
|
const quasar = useQuasar();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const showSelect = ref(false);
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
|
|
||||||
onMounted(() => (stateStore.rightDrawer = true));
|
onMounted(() => (stateStore.rightDrawer = true));
|
||||||
|
@ -43,14 +44,26 @@ const setManageCheckboxes = (downloadType) => {
|
||||||
console.log(downloadType);
|
console.log(downloadType);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addElement = (element) => {
|
||||||
|
if (arrayElements.value.length >= 0) {
|
||||||
|
const index = arrayElements.value.findIndex((item) => item.id === element.id);
|
||||||
|
if (index >= 0) {
|
||||||
|
arrayElements.value.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
arrayElements.value.push(element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const downloadCsv = (rows) => {
|
const downloadCsv = (rows) => {
|
||||||
|
const data = arrayElements.value.length ? arrayElements.value : rows;
|
||||||
let file;
|
let file;
|
||||||
for (var i = 0; i < rows.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
if (i == 0) file += Object.keys(rows[i]).join(';') + '\n';
|
if (i == 0) file += Object.keys(data[i]).join(';') + '\n';
|
||||||
file +=
|
file +=
|
||||||
Object.keys(rows[i])
|
Object.keys(data[i])
|
||||||
.map(function (key) {
|
.map(function (key) {
|
||||||
return rows[i][key];
|
return data[i][key];
|
||||||
})
|
})
|
||||||
.join(';') + '\n';
|
.join(';') + '\n';
|
||||||
}
|
}
|
||||||
|
@ -159,6 +172,8 @@ const downloadCsv = (rows) => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<CardList2
|
<CardList2
|
||||||
|
:addElement="addElement"
|
||||||
|
:element="row"
|
||||||
:id="row.id"
|
:id="row.id"
|
||||||
:isSelected="manageCheckboxes"
|
:isSelected="manageCheckboxes"
|
||||||
:key="row.id"
|
:key="row.id"
|
||||||
|
|
Loading…
Reference in New Issue