Preview.vue
3.43 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
<transition name="el-zoom-in-center">
<div class="NCC-preview-main">
<div class="NCC-common-page-header">
<el-page-header @back="goBack" :content="table+'表的数据'" />
<div class="options">
<el-button @click="goBack()">{{$t('common.cancelButton')}}</el-button>
</div>
</div>
<el-row class="NCC-common-search-box" :gutter="16">
<el-form @submit.native.prevent>
<el-col :span="6">
<el-form-item label="字段">
<el-select v-model="queryJson.field" placeholder="请选择字段">
<el-option v-for="item in options" :key="item.field" :label="item.field"
:value="item.field">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="关键词">
<el-input v-model="queryJson.keyword" placeholder="请输入关键词查询" clearable
@keyup.enter.native="search()" />
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="search()">
{{$t('common.search')}}</el-button>
<el-button icon="el-icon-refresh-right" @click="reset()">{{$t('common.reset')}}
</el-button>
</el-form-item>
</el-col>
</el-form>
</el-row>
<NCC-table v-loading="listLoading" :data="list">
<el-table-column :prop="item.field.toLowerCase()" :label="item.field" show-overflow-tooltip
v-for="item in options" :key="item.field" />
</NCC-table>
<pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
@pagination="initData" />
</div>
</transition>
</template>
<script>
import { DataModelData, DataModelFieldList } from '@/api/systemData/dataModel'
export default {
data() {
return {
visible: false,
options: [],
queryJson: {
field: '',
keyword: ""
},
total: 0,
listLoading: true,
listQuery: {
currentPage: 1,
pageSize: 20,
sort: 'desc'
},
dataBase: '',
table: '',
list: []
}
},
methods: {
goBack() {
this.$emit('close')
},
reset() {
this.queryJson.keyword = ''
this.search()
},
search() {
this.listQuery = {
currentPage: 1,
pageSize: 20,
sort: 'desc'
}
this.initData()
},
init(dataBase, table) {
if (!dataBase || !table) {
this.$emit('close')
return
}
this.dataBase = dataBase
this.table = table
this.$nextTick(() => {
DataModelFieldList(dataBase, table).then(res => {
this.options = res.data.list
this.queryJson.field = this.options[0].field
this.reset()
})
})
},
initData() {
let query = {
...this.listQuery,
...this.queryJson
}
this.listLoading = true
this.list = []
DataModelData(this.dataBase, this.table, query).then(res => {
this.list = res.data.list
this.total = res.data.pagination.total
this.listLoading = false
}).catch(() => {
this.listLoading = false
})
}
}
}
</script>
<style lang="scss" scoped>
.NCC-preview-main {
padding-bottom: 10px;
}
</style>