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';
|
||||
|
||||
const $props = defineProps({
|
||||
addElement: { type: Function, required: true },
|
||||
element: { type: Object, default: null },
|
||||
id: { type: Number, default: null },
|
||||
isSelected: { type: Boolean, default: false },
|
||||
title: { type: String, default: null },
|
||||
|
@ -14,6 +16,10 @@ watch(
|
|||
checkSelect.value = value;
|
||||
}
|
||||
);
|
||||
|
||||
const selectedItem = (item) => {
|
||||
$props.addElement(item);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -29,7 +35,10 @@ watch(
|
|||
ID: {{ $props.id }}
|
||||
</QChip>
|
||||
</div>
|
||||
<QCheckbox v-model="checkSelect" />
|
||||
<QCheckbox
|
||||
v-model="checkSelect"
|
||||
@click="selectedItem($props.element)"
|
||||
/>
|
||||
</div>
|
||||
</slot>
|
||||
<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';
|
||||
|
||||
const { t } = useI18n();
|
||||
const arrayElements = ref([]);
|
||||
const manageCheckboxes = ref(false);
|
||||
const showSelect = ref(false);
|
||||
const quasar = useQuasar();
|
||||
const router = useRouter();
|
||||
const showSelect = ref(false);
|
||||
const stateStore = useStateStore();
|
||||
|
||||
onMounted(() => (stateStore.rightDrawer = true));
|
||||
|
@ -43,14 +44,26 @@ const setManageCheckboxes = (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 data = arrayElements.value.length ? arrayElements.value : rows;
|
||||
let file;
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
if (i == 0) file += Object.keys(rows[i]).join(';') + '\n';
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (i == 0) file += Object.keys(data[i]).join(';') + '\n';
|
||||
file +=
|
||||
Object.keys(rows[i])
|
||||
Object.keys(data[i])
|
||||
.map(function (key) {
|
||||
return rows[i][key];
|
||||
return data[i][key];
|
||||
})
|
||||
.join(';') + '\n';
|
||||
}
|
||||
|
@ -159,6 +172,8 @@ const downloadCsv = (rows) => {
|
|||
/>
|
||||
</div>
|
||||
<CardList2
|
||||
:addElement="addElement"
|
||||
:element="row"
|
||||
:id="row.id"
|
||||
:isSelected="manageCheckboxes"
|
||||
:key="row.id"
|
||||
|
|
Loading…
Reference in New Issue