You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
688 B
30 lines
688 B
2 years ago
|
import { useStore } from 'vuex';
|
||
|
|
||
|
const { state } = useStore();
|
||
|
export const getValue = (
|
||
|
row: any,
|
||
|
column: string,
|
||
|
value: any,
|
||
|
index?: number
|
||
|
) => {
|
||
|
if ((value == null || value == '') && value !== 0) {
|
||
|
return '--';
|
||
|
}
|
||
|
return value;
|
||
|
};
|
||
|
|
||
|
export const formatter = (row: any, column: any, value: any, index: number) => {
|
||
|
return formatterByDist(row.scheme + '-' + column.property, value);
|
||
|
};
|
||
|
|
||
|
export const formatterByDist = (dictKey, value) => {
|
||
|
if (!dictKey) {
|
||
|
return getValue(null, '', value);
|
||
|
}
|
||
|
const mapping = state.dict[dictKey];
|
||
|
if (mapping == null) {
|
||
|
return getValue(null, '', value);
|
||
|
}
|
||
|
return mapping[value] == null ? value : mapping[value];
|
||
|
};
|