Discover: sidebarFilter Funnel button ApplyAll done.

This commit is contained in:
chiayin
2023-04-19 16:18:20 +08:00
parent 8f68e47c25
commit 3d5dba4c42
6 changed files with 119 additions and 81 deletions

View File

@@ -186,9 +186,9 @@ export default {
const loadingStore = LoadingStore();
const allMapDataStore = AllMapDataStore();
const { isLoading } = storeToRefs(loadingStore);
const { tempFilterId } = storeToRefs(allMapDataStore);
const { hasResultRule, postRuleData} = storeToRefs(allMapDataStore);
return { isLoading, tempFilterId, allMapDataStore }
return { isLoading, hasResultRule, postRuleData, allMapDataStore }
},
data() {
return {
@@ -395,7 +395,7 @@ export default {
massage ? this.$toast.success('Reset Success.') : null;
},
// header:Filter 發送選取的資料
submit(){
async submit(){
let data;
let sele = this.selectValue;
let isExclude = sele[5] === 'Exclude' ? true : false
@@ -458,24 +458,28 @@ export default {
}
// 將資料指向 Vue data 雙向綁定
const postData = Array.isArray(data) ? data : [data];
this.temporaryData.push(...postData);
// 結束後要清空資料
this.reset(false);
// 發送時isLoading
this.isLoading = true;
// 結束後,要跳出傳送成功的訊息
// 跳轉 this.tab = 'funnel';
setTimeout(() => {
// 快速檢查每一 filter 規則是否為空集合
// this.logId = this.$route.params.logId;
this.postRuleData = postData;
await this.allMapDataStore.checkHasResult();
// 有 Data 就加進 Funnel沒有 Data 不加進 Funnel 和跳錯誤訊息
if(this.hasResultRule === null) return;
else if(this.hasResultRule) {
this.temporaryData.push(...postData);
this.reset(false);
this.isLoading = true;
await new Promise(resolve => setTimeout(resolve, 1000));
this.isLoading = false;
this.$toast.success('Filter Success. Click on Funnel to view the configuration result.');
}, 1000);
// 快速檢查每一 filter 規則是否為空集合
let logId = this.$route.params.logId;
this.axios.post(`/api/filters/has-result?log_id=${logId}`, postData)
.then(res=>{
res.data.result ? null : this.$toast.warning('No result.');
}).catch(err=>{
})
}else {
this.reset(false);
this.isLoading = true;
await new Promise(resolve => setTimeout(resolve, 1000));
this.isLoading = false;
this.$toast.warning('No Data.');
};
},
// header:Funnel 刪除全部的 Funnel
deleteAll() {
@@ -483,16 +487,25 @@ export default {
this.$toast.success('All deleted.');
},
// header:Funnel 發送暫存的選取資料
submitAll() {
let logId = this.$route.params.logId;
this.axios.post(`/api/temp-filters?log_id=${logId}`, this.temporaryData)
.then(res=>{
console.log(res);
this.tempFilterId = res.data.id;
}).catch(err=>{
console.log(err);
})
}
async submitAll() {
if(this.temporaryData.length === 0) return this.$toast.error('No Filter.');
this.postRuleData = this.temporaryData;
await this.allMapDataStore.checkHasResult();
if(this.hasResultRule === null) return;
else if(this.hasResultRule) {
this.isLoading = true;
await this.allMapDataStore.addTempFilterId();
this.isLoading = false;
this.$toast.success('Filter Success. View the Map.');
}else {
this.isLoading = true;
await new Promise(resolve => setTimeout(resolve, 1000));
this.isLoading = false;
this.$toast.warning('No Data.');
};
},
},
}
</script>