feat : suite refactoring

This commit is contained in:
Christophe 2023-01-12 12:11:05 +01:00
parent 910cf503d8
commit 778f9a2c44
3 changed files with 297 additions and 339 deletions

View file

@ -123,7 +123,7 @@ th .vue-select {
background-color: rgba(179, 209, 67, 0.27);
}
#app .select {
.vue-gamutable .select {
background-color: rgba(179, 209, 67, 0.47);
}

View file

@ -45,7 +45,7 @@
includespip="#ENV{includespip}"
ref="montableau"
filtrer="#ENV{filtrer}"
_id="#ENV{_id}"
:_id="[(#ENV{_id}|intval)]"
filtreselect="[(#ENV{filtrerselect})]"
></gamu-table>
</div>
@ -76,7 +76,7 @@
includespip="#ENV{includespip}"
ref="montableau_deux"
filtrer="#ENV{filtrer}"
_id="#ENV{_id}"
:_id="[(#ENV{_id}|intval)]"
filtreselect="[(#ENV{filtrerselect_deux})]"
></gamu-table>
</div>

View file

@ -653,84 +653,8 @@ function gererConfig(config) {
}
return filtreCol;
}
function chargerJson(id) {
console.log("chargerJson pour ", id);
chargement.value = true;
let url = props.apiuri;
if (parseInt(id) > 0) {
url += "&id=" + id;
} else if (id === "maj") {
url += "&maj=" + maj.value;
} else {
let config = localStorage.getItem("header_" + nameLocalStorage.value);
config = recupJson(config);
if (config && config.header !== undefined) {
let filtreColRecup = gererConfig(config);
localforage
.getItem(nameLocalStorage.value)
.then(function (data) {
data = recupJson(data);
if (data && data.length) {
table.value = data;
if (data[0].search) {
champ_search.value = "search";
}
if (filtreColRecup !== undefined) {
filtreColType.value = filtreColRecup;
Object.keys(filtreColType.value).forEach((col) => {
let Tval = [];
// let Tval = [''];
table.value.forEach((t) => {
let valCol = t[champ_search.value][col];
if (Tval.indexOf(valCol) === -1) {
Tval.push(valCol);
}
});
// filtreCol.value.push(col);
filtreColVal.value[col] = Tval.sort();
filtreColSelected.value[col] = [];
});
}
}
if (props.nomblocajaxreload) {
ajaxReload(props.nomblocajaxreload);
}
})
.catch(function (err) {
console.log(err);
});
}
}
fetch(url)
.then((response) => response.json())
.then((data) => {
let config = data.shift();
let filtreColRecup = gererConfig(config);
// header.value = config.header;
// if (config.maj !== undefined) {
// maj.value = config.maj?.lastMAJ;
// }
// if (config.crayons !== undefined) {
// crayons.value = config.crayons;
// } else {
// crayons.value = [];
// }
// if (config.classes !== undefined) {
// classes.value = config.classes;
// } else {
// classes.value = [];
// }
// if (config.checkbox !== undefined) {
// checkbox.value = config.checkbox;
// Object.keys(checkbox.value).forEach((head) => {
// Tcheckbox.value[head] = [];
// });
// }
// if (config.ordreCol !== undefined) {
// ordreCol.value = config.ordreCol;
// } else {
// ordreCol.value = [];
// }
function gererData(filtreColRecup, data, id = null) {
if (parseInt(id) > 0) {
if (data.length > 0) {
let i = trouver_index(table.value, id);
@ -767,6 +691,40 @@ function chargerJson(id) {
filtreColSelected.value[col] = [];
});
}
}
function chargerJson(id) {
console.log("chargerJson pour ", id);
chargement.value = true;
let url = props.apiuri;
if (parseInt(id) > 0) {
url += "&id=" + id;
} else if (id === "maj") {
url += "&maj=" + maj.value;
} else {
let config = localStorage.getItem("header_" + nameLocalStorage.value);
config = recupJson(config);
if (config && config.header !== undefined) {
let filtreColRecup = gererConfig(config);
localforage
.getItem(nameLocalStorage.value)
.then(function (data) {
data = recupJson(data);
gererData(filtreColRecup, data, id);
if (props.nomblocajaxreload) {
ajaxReload(props.nomblocajaxreload);
}
})
.catch(function (err) {
console.log(err);
});
}
}
fetch(url)
.then((response) => response.json())
.then((data) => {
let config = data.shift();
let filtreColRecup = gererConfig(config);
gererData(filtreColRecup, data, id);
nextTick(() => {
chargement.value = false;