|
46 | 46 | </div> |
47 | 47 | <el-table v-else-if="requiredFilterSatisfied" |
48 | 48 | class="table-view" |
49 | | - :data="itemsStore.items[apiUrl]?.results" |
| 49 | + :data="resolvedTableRowProps" |
50 | 50 | :stripe="false" |
51 | 51 | :defaultSort="defaultSort" |
52 | 52 | sortable="custom" |
|
56 | 56 | v-for="(propInfo, prop) in tableProps" |
57 | 57 | :prop="prop" |
58 | 58 | :label="propInfo.name" |
59 | | - :formatter="(row, column) => propInfo.formatter ? propInfo.formatter(row, column.property) : solveRefPropValue(row, column.property, itemSchema)" |
| 59 | + :formatter="(row, column) => propInfo.formatter ? propInfo.formatter(row, column.property) : row[column.property]" |
60 | 60 | :width="propInfo.width ? propInfo.width : undefined" |
61 | 61 | :align="propInfo.align ? propInfo.align : undefined" |
62 | 62 | :sortable="propInfo.sortable" |
@@ -124,6 +124,7 @@ const deleteDialogVisible = ref(false) |
124 | 124 | const {schema} = storeToRefs(itemsStore) |
125 | 125 | const itemSchema = ref({}) |
126 | 126 | const route = useRoute() |
| 127 | +const resolvedTableRowProps = ref([]) |
127 | 128 |
|
128 | 129 | const props = defineProps({ |
129 | 130 | readableName: { |
@@ -209,11 +210,26 @@ async function loadItems() { |
209 | 210 | return |
210 | 211 | } |
211 | 212 | await itemsStore.retrieveItems($axios, props.apiUrl) |
| 213 | + await resolveTableRowProps(itemsStore.items[props.apiUrl]?.results) |
212 | 214 | itemsStore.loading = false |
213 | 215 | } |
214 | 216 |
|
215 | 217 | await initData() |
216 | 218 |
|
| 219 | +
|
| 220 | +async function resolveTableRowProps(results) { |
| 221 | + const res = [] |
| 222 | + for (const row of results) { |
| 223 | + const resolvedRow = {...row} |
| 224 | + for (const [prop, propInfo] of Object.entries(props.tableProps)) { |
| 225 | + const value = await solveRefPropValue(row, prop, itemSchema.value) |
| 226 | + resolvedRow[prop] = value |
| 227 | + } |
| 228 | + res.push(resolvedRow) |
| 229 | + } |
| 230 | + resolvedTableRowProps.value = res |
| 231 | +} |
| 232 | +
|
217 | 233 | function stateToAdd() { |
218 | 234 | itemsStore.adding = true |
219 | 235 | } |
|
0 commit comments