|
@@ -6,7 +6,7 @@
|
|
|
:pagination="false" @resizeColumn="handleResizeColumn" :rowClassName = "rowClassName"
|
|
|
bordered>
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
- <div v-html="record[column.key]"></div>
|
|
|
+ <div v-html="defaultIfNull(record[column.key])"></div>
|
|
|
</template>
|
|
|
</a-table>
|
|
|
</div>
|
|
@@ -46,8 +46,28 @@ export default defineComponent({
|
|
|
console.log(record);
|
|
|
return index % 2 === 0 ? 'even' : 'odd';
|
|
|
}
|
|
|
+ const isoDateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/;;
|
|
|
+
|
|
|
+ function convertIsoDateToYMD(isoString: string): string {
|
|
|
+ const date = new Date(isoString);
|
|
|
+ const year = date.getUTCFullYear();
|
|
|
+ const month = String(date.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-indexed
|
|
|
+ const day = String(date.getUTCDate()).padStart(2, '0');
|
|
|
+
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
+ }
|
|
|
+
|
|
|
+ const defaultIfNull = (value) => {
|
|
|
+ if (value == null || value == "") {
|
|
|
+ return "/";
|
|
|
+ }
|
|
|
+ if (isoDateRegex.test(value)) {
|
|
|
+ return convertIsoDateToYMD(value);
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
return {
|
|
|
- columns, data, title,rowClassName,
|
|
|
+ columns, data, title,rowClassName,defaultIfNull,
|
|
|
handleResizeColumn: (w, col) => {
|
|
|
col.width = w;
|
|
|
}
|