on filtre les valeurs du select, pour n'afficher que celle possible
This commit is contained in:
parent
0a6ed4cc7d
commit
e287386eac
2 changed files with 46 additions and 39 deletions
|
@ -272,6 +272,19 @@ let monTableau = {
|
||||||
];
|
];
|
||||||
localStorage.setItem(this.nameLocalStorage, JSON.stringify($table));
|
localStorage.setItem(this.nameLocalStorage, JSON.stringify($table));
|
||||||
},
|
},
|
||||||
|
tableau() {
|
||||||
|
this.filtreCol.forEach((col) => {
|
||||||
|
let Tval = [''];
|
||||||
|
this.tableau.forEach((t) => {
|
||||||
|
let valCol = t.search[col];
|
||||||
|
if (Tval.indexOf(valCol) === -1) {
|
||||||
|
Tval.push(valCol);
|
||||||
|
this.filtreColValOk = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.filtreColVal[col] = Tval;
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
selectValCol() {
|
selectValCol() {
|
||||||
|
@ -333,16 +346,6 @@ let monTableau = {
|
||||||
}
|
}
|
||||||
if (config.filtreCol !== undefined) {
|
if (config.filtreCol !== undefined) {
|
||||||
this.filtreCol = config.filtreCol;
|
this.filtreCol = config.filtreCol;
|
||||||
this.filtreCol.forEach((col) => {
|
|
||||||
let Tval = [''];
|
|
||||||
this.table.forEach((t) => {
|
|
||||||
let valCol = t.search[col];
|
|
||||||
if (Tval.indexOf(valCol) === -1) {
|
|
||||||
Tval.push(valCol);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.filtreColVal[col] = Tval;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
this.chargement = false;
|
this.chargement = false;
|
||||||
|
|
|
@ -318,6 +318,24 @@ var monTableau = {
|
||||||
filtreCol: this.filtreCol
|
filtreCol: this.filtreCol
|
||||||
}].concat(_toConsumableArray(this.table));
|
}].concat(_toConsumableArray(this.table));
|
||||||
localStorage.setItem(this.nameLocalStorage, JSON.stringify($table));
|
localStorage.setItem(this.nameLocalStorage, JSON.stringify($table));
|
||||||
|
},
|
||||||
|
tableau: function tableau() {
|
||||||
|
var _this3 = this;
|
||||||
|
|
||||||
|
this.filtreCol.forEach(function (col) {
|
||||||
|
var Tval = [''];
|
||||||
|
|
||||||
|
_this3.tableau.forEach(function (t) {
|
||||||
|
var valCol = t.search[col];
|
||||||
|
|
||||||
|
if (Tval.indexOf(valCol) === -1) {
|
||||||
|
Tval.push(valCol);
|
||||||
|
_this3.filtreColValOk = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
_this3.filtreColVal[col] = Tval;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -332,7 +350,7 @@ var monTableau = {
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
chargerJson: function chargerJson(id) {
|
chargerJson: function chargerJson(id) {
|
||||||
var _this3 = this;
|
var _this4 = this;
|
||||||
|
|
||||||
var url = this.apiuri;
|
var url = this.apiuri;
|
||||||
|
|
||||||
|
@ -368,56 +386,42 @@ var monTableau = {
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
var config = data.shift();
|
var config = data.shift();
|
||||||
_this3.header = config.header;
|
_this4.header = config.header;
|
||||||
|
|
||||||
if (config.crayons !== undefined) {
|
if (config.crayons !== undefined) {
|
||||||
_this3.crayons = config.crayons;
|
_this4.crayons = config.crayons;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.classes !== undefined) {
|
if (config.classes !== undefined) {
|
||||||
_this3.classes = config.classes;
|
_this4.classes = config.classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(id) > 0) {
|
if (parseInt(id) > 0) {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
var i = trouver_index(_this3.table, id);
|
var i = trouver_index(_this4.table, id);
|
||||||
_this3.table[i] = data[0];
|
_this4.table[i] = data[0];
|
||||||
} else {
|
} else {
|
||||||
var _i2 = trouver_index(_this3.table, id);
|
var _i2 = trouver_index(_this4.table, id);
|
||||||
|
|
||||||
_this3.table.splice(_i2, 1);
|
_this4.table.splice(_i2, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_this3.table = data;
|
_this4.table = data;
|
||||||
|
|
||||||
if (data[0] && data[0].search) {
|
if (data[0] && data[0].search) {
|
||||||
_this3.champ_search = 'search';
|
_this4.champ_search = 'search';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.filtreCol !== undefined) {
|
if (config.filtreCol !== undefined) {
|
||||||
_this3.filtreCol = config.filtreCol;
|
_this4.filtreCol = config.filtreCol;
|
||||||
|
|
||||||
_this3.filtreCol.forEach(function (col) {
|
|
||||||
var Tval = [''];
|
|
||||||
|
|
||||||
_this3.table.forEach(function (t) {
|
|
||||||
var valCol = t.search[col];
|
|
||||||
|
|
||||||
if (Tval.indexOf(valCol) === -1) {
|
|
||||||
Tval.push(valCol);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
_this3.filtreColVal[col] = Tval;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.nextTick(function () {
|
Vue.nextTick(function () {
|
||||||
_this3.chargement = false;
|
_this4.chargement = false;
|
||||||
|
|
||||||
if ($_id > 0) {
|
if ($_id > 0) {
|
||||||
_this3.selectLigne($_id, 'id');
|
_this4.selectLigne($_id, 'id');
|
||||||
|
|
||||||
var _url = new URL(window.location);
|
var _url = new URL(window.location);
|
||||||
|
|
||||||
|
@ -502,7 +506,7 @@ var monTableau = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
exportCSV: function exportCSV() {
|
exportCSV: function exportCSV() {
|
||||||
var _this4 = this;
|
var _this5 = this;
|
||||||
|
|
||||||
var $csv = [];
|
var $csv = [];
|
||||||
var $header = [];
|
var $header = [];
|
||||||
|
@ -512,7 +516,7 @@ var monTableau = {
|
||||||
});
|
});
|
||||||
$tableau = this.tableau.reduce(function (acc, ligne) {
|
$tableau = this.tableau.reduce(function (acc, ligne) {
|
||||||
var $uneLigne = [];
|
var $uneLigne = [];
|
||||||
Object.values(ligne[_this4.champcsv]).forEach(function (l) {
|
Object.values(ligne[_this5.champcsv]).forEach(function (l) {
|
||||||
return $uneLigne.push(l);
|
return $uneLigne.push(l);
|
||||||
});
|
});
|
||||||
return [].concat(_toConsumableArray(acc), [[].concat($uneLigne)]);
|
return [].concat(_toConsumableArray(acc), [[].concat($uneLigne)]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue