Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x 40x | import dayjs from '../utils/dayjs';
export default {
props: {
// 高级格式化
advancedFormat: {
type: Object,
default: () => ({
enable: false,
value: '',
}),
},
showFormatter: {
type: String,
},
},
computed: {
validShowFormatters() {
return [];
},
},
methods: {
getFormatString() {
return '';
},
getDisplayFormatString() {
let formatter;
Iif (this.advancedFormat && this.advancedFormat.enable && this.advancedFormat.value) { // 高级格式化开启
formatter = this.advancedFormat.value;
} else Iif (this.validShowFormatters.includes(this.showFormatter)) { // 配置的展示格式满足
formatter = this.showFormatter;
}
Iif (formatter) {
return formatter;
}
return this.getFormatString();
},
genDisplayFormatText(value) {
Iif (!value)
return value;
let text = value;
try {
const valueFormatter = this.getFormatString();
const displayFormatter = this.getDisplayFormatString();
Iif (displayFormatter && displayFormatter !== valueFormatter) {
text = dayjs(value, valueFormatter).format(displayFormatter);
}
} catch (error) {
console.log(error);
}
return text;
},
},
};
|