Issues #191: done.

This commit is contained in:
chiayin
2023-11-13 13:02:06 +08:00
parent dd7057c2b1
commit 00a1931189
4 changed files with 37 additions and 24 deletions

View File

@@ -79,6 +79,7 @@ export default {
showTraceId: null, showTraceId: null,
infiniteData: null, infiniteData: null,
maxItems: false, maxItems: false,
infiniteFinish: true, // 無限滾動是否載入完成
startNum: 0, startNum: 0,
processMap:{ processMap:{
nodes:[], nodes:[],
@@ -153,10 +154,7 @@ export default {
this.infiniteData = newValue; this.infiniteData = newValue;
}, },
infinite404: function(newValue, oldValue){ infinite404: function(newValue, oldValue){
if (newValue === 404) { if (newValue === 404) this.maxItems = true;
this.maxItems = true;
this.loading = false;
}
}, },
}, },
methods: { methods: {
@@ -182,15 +180,16 @@ export default {
* @param {number} id * @param {number} id
*/ */
async switchCaseData(id) { async switchCaseData(id) {
if(id == this.showTraceId) return;
this.infinite404 = null; this.infinite404 = null;
this.maxItems = false; this.maxItems = false;
this.showTraceId = id;
this.startNum = 0; this.startNum = 0;
let result; let result;
if(this.category === 'issue') result = await this.conformanceStore.getConformanceTraceDetail(this.listNo, id, 0); if(this.category === 'issue') result = await this.conformanceStore.getConformanceTraceDetail(this.listNo, id, 0);
else if(this.category === 'loop') result = await this.conformanceStore.getConformanceLoopsTraceDetail(this.listNo, id, 0); else if(this.category === 'loop') result = await this.conformanceStore.getConformanceLoopsTraceDetail(this.listNo, id, 0);
this.infiniteData = await result; this.infiniteData = await result;
this.showTraceId = id; // 放 getDetail 為了 case table 載入完再切換 showTraceId
}, },
/** /**
* 將 trace element nodes 資料彙整 * 將 trace element nodes 資料彙整
@@ -252,14 +251,13 @@ export default {
*/ */
async fetchData() { async fetchData() {
try { try {
this.loading = true; this.infiniteFinish = false;
this.startNum += 20 this.startNum += 20
const result = await this.conformanceStore.getConformanceTraceDetail(this.listNo, this.showTraceId, this.startNum); const result = await this.conformanceStore.getConformanceTraceDetail(this.listNo, this.showTraceId, this.startNum);
this.infiniteData = [...this.infiniteData, ...result]; this.infiniteData = await [...this.infiniteData, ...result];
this.infiniteFinish = await true;
} catch(error) { } catch(error) {
// console.error('Failed to load data:', error); console.error('Failed to load data:', error);
} finally {
this.loading = false;
} }
}, },
/** /**
@@ -267,15 +265,12 @@ export default {
* @param {element} event * @param {element} event
*/ */
handleScroll(event) { handleScroll(event) {
if(this.loading || this.maxItems || this.infiniteData.length < 20) return; if(this.maxItems || this.infiniteData.length < 20 || this.infiniteFinish === false) return;
const container = event.target; const container = event.target;
const overScrollHeight = container.scrollTop + container.clientHeight + 20 >= container.scrollHeight; const overScrollHeight = container.scrollTop + container.clientHeight + 20 >= container.scrollHeight;
if (overScrollHeight) { if (overScrollHeight) this.fetchData();
this.fetchData();
this.loading = true;
}
}, },
}, },
} }

View File

@@ -92,6 +92,7 @@ export default {
showTraceId: null, showTraceId: null,
infinitMaxItems: false, infinitMaxItems: false,
infiniteData: [], infiniteData: [],
infiniteFinish: true, // 無限滾動是否載入完成
chartOptions: null, chartOptions: null,
selectArea: [0, 1] selectArea: [0, 1]
} }
@@ -251,13 +252,16 @@ export default {
* @param {number} id * @param {number} id
*/ */
async switchCaseData(id, count) { async switchCaseData(id, count) {
if(count >= 1000) this.isLoading = true; // 點同一筆 id 不要有動作
if(id == this.showTraceId) return;
// if(count >= 1000) this.isLoading = true; // 超過 1000 筆要 loading 畫面
this.isLoading = true; // 都要 loading 畫面
this.infinit404 = null; this.infinit404 = null;
this.infinitMaxItems = false; this.infinitMaxItems = false;
this.showTraceId = id;
this.baseInfiniteStart = 0; this.baseInfiniteStart = 0;
this.allMapDataStore.baseTraceId = id; this.allMapDataStore.baseTraceId = id;
this.infiniteData = await this.allMapDataStore.getBaseTraceDetail(); this.infiniteData = await this.allMapDataStore.getBaseTraceDetail();
this.showTraceId = id; // 放 getDetail 為了 case table 載入完再切換 showTraceId
this.createCy(); this.createCy();
this.isLoading = false; this.isLoading = false;
}, },
@@ -315,7 +319,7 @@ export default {
* @param {element} event * @param {element} event
*/ */
handleScroll(event) { handleScroll(event) {
if(this.infinitMaxItems || this.baseCases.length < 20) return; if(this.infinitMaxItems || this.baseCases.length < 20 || this.infiniteFinish === false) return;
const container = event.target; const container = event.target;
const overScrollHeight = container.scrollTop + container.clientHeight >= container.scrollHeight; const overScrollHeight = container.scrollTop + container.clientHeight >= container.scrollHeight;
@@ -327,9 +331,13 @@ export default {
*/ */
async fetchData() { async fetchData() {
try { try {
this.isLoading = true;
this.infiniteFinish = false;
this.baseInfiniteStart += 20; this.baseInfiniteStart += 20;
await this.allMapDataStore.getBaseTraceDetail(); await this.allMapDataStore.getBaseTraceDetail();
this.infiniteData = [...this.infiniteData, ...this.baseCases]; this.infiniteData = await [...this.infiniteData, ...this.baseCases];
this.infiniteFinish = await true;
this.isLoading = await false;
} catch(error) { } catch(error) {
console.error('Failed to load data:', error); console.error('Failed to load data:', error);
} }

View File

@@ -83,6 +83,7 @@ export default {
showTraceId: null, showTraceId: null,
infinitMaxItems: false, infinitMaxItems: false,
infiniteData: [], infiniteData: [],
infiniteFinish: true, // 無限滾動是否載入完成
} }
}, },
computed: { computed: {
@@ -171,12 +172,15 @@ export default {
* @param {number} id * @param {number} id
*/ */
async switchCaseData(id, count) { async switchCaseData(id, count) {
if(count >= 1000) this.isLoading = true; // 點同一筆 id 不要有動作
if(id == this.showTraceId) return;
// if(count >= 1000) this.isLoading = true; // 超過 1000 筆要 loading 畫面
this.isLoading = true; // 都要 loading 畫面
this.infinit404 = null; this.infinit404 = null;
this.infinitMaxItems = false; this.infinitMaxItems = false;
this.showTraceId = id; this.showTraceId = id;
this.infiniteStart = 0; this.infiniteStart = 0;
this.$emit('switch-Trace-Id', {id: this.showTraceId, count: count}); this.$emit('switch-Trace-Id', {id: this.showTraceId, count: count}); // 傳遞到 Map index 再關掉 loading
}, },
/** /**
* 將 trace element nodes 資料彙整 * 將 trace element nodes 資料彙整
@@ -245,7 +249,7 @@ export default {
* @param {element} event * @param {element} event
*/ */
handleScroll(event) { handleScroll(event) {
if(this.infinitMaxItems || this.cases.length < 20) return; if(this.infinitMaxItems || this.cases.length < 20 || this.infiniteFinish === false) return;
const container = event.target; const container = event.target;
const overScrollHeight = container.scrollTop + container.clientHeight >= container.scrollHeight; const overScrollHeight = container.scrollTop + container.clientHeight >= container.scrollHeight;
@@ -257,9 +261,13 @@ export default {
*/ */
async fetchData() { async fetchData() {
try { try {
this.isLoading = true;
this.infiniteFinish = false;
this.infiniteStart += 20; this.infiniteStart += 20;
await this.allMapDataStore.getTraceDetail(); await this.allMapDataStore.getTraceDetail();
this.infiniteData = [...this.infiniteData, ...this.cases]; this.infiniteData = await [...this.infiniteData, ...this.cases];
this.infiniteFinish = await true;
this.isLoading = await false;
} catch(error) { } catch(error) {
console.error('Failed to load data:', error); console.error('Failed to load data:', error);
} }

View File

@@ -180,7 +180,9 @@ export default {
* @param {string} id * @param {string} id
*/ */
async switchTraceId(e) { async switchTraceId(e) {
if(e.count >= 1000) this.isLoading = true; if(e.id == this.traceId) return;
// if(e.count >= 1000) this.isLoading = true; // 超過 1000 筆要 loading 畫面
this.isLoading = true; // 都要 loading 畫面
this.traceId = e.id; this.traceId = e.id;
await this.allMapDataStore.getTraceDetail(); await this.allMapDataStore.getTraceDetail();
this.$refs.tracesView.createCy(); this.$refs.tracesView.createCy();