mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
fix column order in result set #74
This commit is contained in:
@@ -8,10 +8,15 @@ const hintsByCode = {
|
||||
|
||||
export default {
|
||||
getResult (source) {
|
||||
const result = {}
|
||||
const result = {
|
||||
columns: []
|
||||
}
|
||||
const values = {}
|
||||
if (source.meta.fields) {
|
||||
source.meta.fields.forEach(col => {
|
||||
result[col.trim()] = source.data.map(row => {
|
||||
let colName = col.trim()
|
||||
result.columns.push(colName)
|
||||
values[colName] = source.data.map(row => {
|
||||
let value = row[col]
|
||||
if (value instanceof Date) {
|
||||
value = value.toISOString()
|
||||
@@ -21,7 +26,9 @@ export default {
|
||||
})
|
||||
} else {
|
||||
for (let i = 0; i <= source.data[0].length - 1; i++) {
|
||||
result[`col${i + 1}`] = source.data.map(row => {
|
||||
let colName = `col${i + 1}`
|
||||
result.columns.push(colName)
|
||||
values[colName] = source.data.map(row => {
|
||||
let value = row[i]
|
||||
if (value instanceof Date) {
|
||||
value = value.toISOString()
|
||||
@@ -30,6 +37,8 @@ export default {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
result.values = values
|
||||
return result
|
||||
},
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<tr v-for="rowIndex in currentPageData.count" :key="rowIndex">
|
||||
<td v-for="(col, colIndex) in columns" :key="colIndex">
|
||||
<div class="cell-data" :style="cellStyle">
|
||||
{{ dataSet[col][rowIndex - 1 + currentPageData.start] }}
|
||||
{{ dataSet.values[col][rowIndex - 1 + currentPageData.start] }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -74,10 +74,10 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
columns () {
|
||||
return Object.keys(this.dataSet)
|
||||
return this.dataSet.columns
|
||||
},
|
||||
rowCount () {
|
||||
return this.dataSet[this.columns[0]].length
|
||||
return this.dataSet.values[this.columns[0]].length
|
||||
},
|
||||
cellStyle () {
|
||||
const eq = this.tableWidth / this.columns.length
|
||||
|
||||
Reference in New Issue
Block a user