feat: Conformance Save Log Done.
This commit is contained in:
@@ -48,11 +48,27 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import filesStore from '@/stores/files.js';
|
||||
import AllMapDataStore from '@/stores/allMapData.js';
|
||||
import ConformanceStore from '@/stores/conformance.js';
|
||||
import IconSearch from '@/components/icons/IconSearch.vue';
|
||||
import IconSetting from '@/components/icons/IconSetting.vue';
|
||||
import { saveFilter, savedSuccessfully } from '@/module/alertModal.js';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const store = filesStore();
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const conformanceStore = ConformanceStore();
|
||||
const { logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter } = storeToRefs(allMapDataStore);
|
||||
const { conformanceRuleData, conformanceLogId, conformanceFilterId, conformanceLogTempCheckId, conformanceFilterTempCheckId, conformanceLogCreateCheckId, conformanceFilterCreateCheckId, isUpdataConformance, conformanceFileName } = storeToRefs(conformanceStore);
|
||||
|
||||
return { store, allMapDataStore, logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter, conformanceStore, conformanceRuleData, conformanceLogId, conformanceFilterId, conformanceLogTempCheckId, conformanceFilterTempCheckId, conformanceLogCreateCheckId, conformanceFilterCreateCheckId, isUpdataConformance, conformanceFileName }
|
||||
},
|
||||
components: {
|
||||
IconSearch,
|
||||
IconSetting,
|
||||
saveFilter,
|
||||
savedSuccessfully
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showNavbarBreadcrumb: false,
|
||||
@@ -67,9 +83,16 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 沒有 filter Id, 沒有暫存 tempFilterId Id 就不能存檔
|
||||
disabledSave: function () {
|
||||
return this.tempFilterId ? false : true;
|
||||
switch (this.$route.name) {
|
||||
case 'Map':
|
||||
case 'CheckMap':
|
||||
// 沒有 filter Id, 沒有暫存 tempFilterId Id 就不能存檔
|
||||
return this.tempFilterId ? false : true;
|
||||
case 'Conformance':
|
||||
case 'CheckConformance':
|
||||
return this.conformanceFilterTempCheckId || this.conformanceLogTempCheckId ? false : true;
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -78,19 +101,6 @@ export default {
|
||||
this.filterName = newVal;
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const store = filesStore();
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const { logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter } = storeToRefs(allMapDataStore);
|
||||
|
||||
return { store, allMapDataStore, logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter}
|
||||
},
|
||||
components: {
|
||||
IconSearch,
|
||||
IconSetting,
|
||||
saveFilter,
|
||||
savedSuccessfully
|
||||
},
|
||||
mounted() {
|
||||
if(this.$route.params.type === 'filter') this.createFilterId= this.$route.params.fileId;
|
||||
this.showNavbarBreadcrumb = this.$route.matched[0].name !== ('AuthContainer')? true : false;
|
||||
@@ -125,17 +135,37 @@ export default {
|
||||
async saveModal() {
|
||||
// 傳給 Map,通知 Sidebar 要關閉。
|
||||
this.$emitter.emit('saveModal', false);
|
||||
// 先判斷有沒有 filter Id,有就儲存 return,沒有就往下走
|
||||
// 沒有 filter Id, 有暫存 tempFilterId Id 可以另存新檔
|
||||
if(this.createFilterId) {
|
||||
await this.allMapDataStore.updataFilter();
|
||||
if(this.isUpdataFilter) await savedSuccessfully(this.filterName);
|
||||
this.tempFilterId = null;
|
||||
}else if(this.logId){
|
||||
await saveFilter(this.allMapDataStore.addFilterId);
|
||||
// 存檔後為 filterID,換網址不跳頁,使用 push 記錄歷史路由
|
||||
await this.$router.push(`/discover/map/filter/${this.createFilterId}`);
|
||||
};
|
||||
// 判斷在哪個子頁面
|
||||
switch (this.$route.name) {
|
||||
case 'Map':
|
||||
// 先判斷有沒有 filter Id,有就儲存 return,沒有就往下走
|
||||
// 沒有 filter Id, 有暫存 tempFilterId Id 可以另存新檔
|
||||
if(this.createFilterId) {
|
||||
await this.allMapDataStore.updataFilter();
|
||||
if(this.isUpdataFilter) await savedSuccessfully(this.filterName);
|
||||
this.tempFilterId = null;
|
||||
}else if(this.logId){
|
||||
await saveFilter(this.allMapDataStore.addFilterId);
|
||||
// 存檔後為 filterID,換網址不跳頁,使用 push 記錄歷史路由
|
||||
await this.$router.push(`/discover/map/filter/${this.createFilterId}`);
|
||||
};
|
||||
break;
|
||||
case 'Conformance':
|
||||
case 'CheckMap':
|
||||
case 'CheckConformance':
|
||||
// 先判斷有沒有 check Id,有就儲存 return,沒有就往下走
|
||||
// 沒有 check Id, 有暫存 temp Id 可以另存新檔
|
||||
if(this.conformanceFilterCreateCheckId || this.conformanceLogCreateCheckId){
|
||||
await this.conformanceStore.updataConformance();
|
||||
if(this.isUpdataConformance) await savedSuccessfully(this.conformanceFileName);
|
||||
} else {
|
||||
await saveFilter(this.conformanceStore.addConformanceCreateCheckId);
|
||||
// 存檔後為 checkID,換網址不跳頁,使用 push 記錄歷史路由
|
||||
if(this.conformanceLogId) await this.$router.push(`/rule/log/${this.conformanceLogCreateCheckId}/conformance/${this.conformanceLogId}`);
|
||||
else if(this.conformanceFilterId) await this.$router.push(`/rule/filter/${this.conformanceFilterCreateCheckId}/conformance/${this.conformanceFilterId}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user