clearAllControl() {
if (this.tableParam.region_id) {
delete this.tableParam.region_id;
this.searchForm.get('regionName').patchValue(null);
}
if (this.tableParam.district_id) {
delete this.tableParam.district_id;
this.searchForm.get('districtName').patchValue(null);
}
if (this.tableParam.area_id) {
delete this.tableParam.area_id;
this.searchForm.get('areaName').patchValue(null);
}
if (this.tableParam.city_id) {
delete this.tableParam.city_id;
this.searchForm.get('cityName').patchValue(null);
}
if (this.tableParam.place_id) {
delete this.tableParam.place_id;
this.searchForm.get('cityName').patchValue(null);
}
if (this.tableParam.name) {
delete this.tableParam.name;
this.searchForm.get('streetName').patchValue(null);
}
this.generateAddressesTable(this.tableParam);
}
[
[ 'region_id', 'regionName' ],
[ 'district_id', 'districtName' ],
[ 'area_id', 'areaName' ],
[ 'city_id', 'cityName' ],
[ 'place_id', 'cityName' ],
[ 'name', 'streetName' ],
].forEach(([ del, search ]) => {
if (this.tableParam[del]) {
delete this.tableParam[del];
this.searchForm.get(search).patchValue(null);
}
});
const config = [
'region', 'district', 'area', 'city',
{id:'place_id', name:'cityName'}, {id:'name', name:'streetName'},
];
clearAllControl() {
config.forEach(x=>{
let id = x.id || (x + '_id');
let name = x.name || (x + 'Name');
if (this.tableParam[id]) {
delete this.tableParam[id];
this.searchForm.get(name).patchValue(null);
}
});
this.generateAddressesTable(this.tableParam);
}