Map Attributes: API Format converter.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { defineStore } from "pinia";
|
||||
import moment from "moment";
|
||||
import apiError from '@/module/apiError.js';
|
||||
import { Decimal } from 'decimal.js';
|
||||
|
||||
export default defineStore('allMapDataStore', {
|
||||
state: () => ({
|
||||
@@ -95,7 +96,25 @@ export default defineStore('allMapDataStore', {
|
||||
return state.allFilterTrace;
|
||||
},
|
||||
filterAttrs: state => {
|
||||
return state.allFilterAttrs;
|
||||
if(state.allFilterAttrs !== null){
|
||||
state.allFilterAttrs.map(att => {
|
||||
switch (att.type) {
|
||||
case 'date':
|
||||
att.min = att.min !== null ? moment(att.min).format('YYYY/MM/DD HH:mm') : null;
|
||||
att.max = att.max !== null ? moment(att.max).format('YYYY/MM/DD HH:mm') : null;
|
||||
break;
|
||||
case 'float':
|
||||
// Decimal.ROUND_UP|0: 無條件進位; Decimal.ROUND_DOWN|1: 無條件捨去。
|
||||
att.min = att.min !== null ? Number(new Decimal(att.min).toFixed(2, 0)) : null;
|
||||
att.max = att.max !== null ? Number(new Decimal(att.max).toFixed(2, 1)) : null;
|
||||
break
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return att;
|
||||
});
|
||||
return state.allFilterAttrs;
|
||||
}
|
||||
},
|
||||
allFunnels: state => {
|
||||
return state.allFunnelData;
|
||||
@@ -173,8 +192,8 @@ export default defineStore('allMapDataStore', {
|
||||
this.allTraceTaskSeq = response.data.task_seq;
|
||||
this.allCase = response.data.cases;
|
||||
this.allCase.map(c => {
|
||||
c.started_at = moment(c.started_at).format('YYYY-MM-DD HH:MM');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY-MM-DD HH:MM');
|
||||
c.started_at = moment(c.started_at).format('YYYY-MM-DD HH:mm');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY-MM-DD HH:mm');
|
||||
return this.allCase;
|
||||
});
|
||||
return this.allCase;
|
||||
@@ -197,8 +216,8 @@ export default defineStore('allMapDataStore', {
|
||||
this.allBaseTraceTaskSeq = response.data.task_seq;
|
||||
this.allBaseCase = response.data.cases;
|
||||
this.allBaseCase.map(c => {
|
||||
c.started_at = moment(c.started_at).format('YYYY-MM-DD HH:MM');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY-MM-DD HH:MM');
|
||||
c.started_at = moment(c.started_at).format('YYYY-MM-DD HH:mm');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY-MM-DD HH:mm');
|
||||
return this.allBaseCase;
|
||||
});
|
||||
return this.allBaseCase;
|
||||
@@ -222,6 +241,21 @@ export default defineStore('allMapDataStore', {
|
||||
this.allFilterTimeframe = response.data.timeframe;
|
||||
this.allFilterTrace = response.data.trace;
|
||||
this.allFilterAttrs = response.data.attrs;
|
||||
// this.allFilterAttrs.map(att => {
|
||||
// switch (att.type) {
|
||||
// case 'date':
|
||||
// att.min = att.min !== null ? moment(att.min).format('YYYY/MM/DD HH:mm:ss') : null;
|
||||
// att.max = att.max !== null ? moment(att.max).format('YYYY/MM/DD HH:mm:ss') : null;
|
||||
// break;
|
||||
// case 'float':
|
||||
// att.min = att.min !== null ? new Decimal(att.min).toFixed(2) : null;
|
||||
// att.max = att.max !== null ? new Decimal(att.max).toFixed(2) : null;
|
||||
// break
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// return att;
|
||||
// });
|
||||
} catch(error) {
|
||||
apiError(error, 'Failed to load the Filter Parameters.');
|
||||
};
|
||||
|
||||
@@ -112,8 +112,8 @@ export default defineStore('conformanceStore', {
|
||||
cases: state => {
|
||||
if(state.allCases !== null){
|
||||
const newData = state.allCases.map(c => {
|
||||
c.started_at = moment(c.started_at).format('YYYY/MM/DD HH:MM');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY/MM/DD HH:MM');
|
||||
c.started_at = moment(c.started_at).format('YYYY/MM/DD HH:mm');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY/MM/DD HH:mm');
|
||||
c.facets.map(fac => {
|
||||
switch(fac.type) {
|
||||
case 'duration-list':
|
||||
@@ -153,12 +153,12 @@ export default defineStore('conformanceStore', {
|
||||
loopCases: state => {
|
||||
if(state.allLoopCases !== null){
|
||||
const newData = state.allLoopCases.map(c => {
|
||||
c.started_at = moment(c.started_at).format('YYYY/MM/DD HH:MM');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY/MM/DD HH:MM');
|
||||
c.started_at = moment(c.started_at).format('YYYY/MM/DD HH:mm');
|
||||
c.completed_at = moment(c.completed_at).format('YYYY/MM/DD HH:mm');
|
||||
c.attributes.map(att => {
|
||||
switch (att.type) {
|
||||
case 'date':
|
||||
att.value = att.value !== null ? moment(att.value).format('YYYY/MM/DD HH:MM:ss') : null;
|
||||
att.value = att.value !== null ? moment(att.value).format('YYYY/MM/DD HH:mm:ss') : null;
|
||||
break;
|
||||
case 'float':
|
||||
att.value = att.value !== null ? new Decimal(att.value).toFixed(2) : null;
|
||||
|
||||
Reference in New Issue
Block a user