Commit 85945f80 authored by 胡小根's avatar 胡小根

完成基本的表格呈现

parent 7b74808d
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
<!-- 表格 --> <!-- 表格 -->
<el-table :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row <el-table :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
style="width: 100%"> style="width: 100%">
<el-table-column v-for="" align="center" :label="$t('table.id')" width="65"> <el-table-column v-for="column in showColumns" align="center" :label="column.name">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{scope.row.id}}</span> <span>{{ scope.row[column.code] }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -113,19 +113,27 @@ ...@@ -113,19 +113,27 @@
sort_item: 'create_time', sort_item: 'create_time',
sort_order: 'desc' sort_order: 'desc'
}, },
downloadLoading: false downloadLoading: false,
showColumns: []
} }
}, },
created() { created() {
// @TODO init this.init()
this.getList() this.getList()
}, },
methods: { methods: {
init() { init() {
let self = this const self = this
if(!self.columns || !self.columns.length){ if (!self.columns || !self.columns.length) {
self.columns = _.each(self.schema['columns'], function(column){
const tmp = JSON.parse(JSON.stringify(column))
self.$set(tmp, 'code', tmp.code.toLowerCase())
self.showColumns.push(tmp)
})
} else {
self.showColumns = JSON.parse(JSON.stringify(self.columns))
} }
}, },
getList() { getList() {
...@@ -134,7 +142,7 @@ ...@@ -134,7 +142,7 @@
request(self.schema.modelUnderscorePlural).then(resp => { request(self.schema.modelUnderscorePlural).then(resp => {
console.log(resp) console.log(resp)
self.list = resp.data self.list = resp.data
self.total = resp.headers.total self.total = parseInt(resp.headers.total)
self.listLoading = false self.listLoading = false
}) })
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment