index.vue
4.39 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<style>
.eagle-scheme {
padding: 0px;
}
.eagle-scheme__card {
border: 1px solid #F5F5F5;
border-radius: 2px;
background-color: #fff;
padding: 10px;
transition: all .3s ease;
margin-bottom: 10px;
}
.eagle-scheme__card .eagle-search {
padding-top: 20px;
padding-bottom: 10px;
}
.eagle-scheme__action {
padding-bottom: 10px;
}
.eagle-scheme__table .eagle-scheme__table-btn:not(:first-child) {
padding-left: 10px;
margin-left: 0px;
}
.eagle-scheme__pagination {
text-align: right;
padding-top: 10px;
}
</style>
<template>
<div class="eagle-scheme">
<div class="eagle-scheme__card">
<eagle-search :list="_searchList"></eagle-search>
</div>
<div class="eagle-scheme__action">
<el-button type="primary" size="small" @click="showDialog">新增</el-button>
</div>
<div class="eagle-scheme__table">
<eagle-table :list="_tableList" :tableProps="tableProps" :value="tableData">
<template v-if="$scopedSlots['table-append'] || $slots['table-append']">
<slot name="table-append" slot="append"></slot>
</template>
<template v-else>
<el-table-column slot="append" prop="$operation" label="操作" min-width="140">
<slot v-if="$scopedSlots['table-append-btn'] || $slots['table-append-btn']" name="table-append-btn"></slot>
<el-button class="eagle-scheme__table-btn" type="text" icon="el-icon-edit" title="编辑" @click="showDialog"></el-button>
<eagle-confirm class="eagle-scheme__table-btn" title="是否删除?">
<el-button type="text" icon="el-icon-delete" title="删除"></el-button>
</eagle-confirm>
</el-table-column>
</template>
</eagle-table>
<div class="eagle-scheme__pagination">
<el-pagination size="small" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
:page-size="100" :total="400" v-bind="paginationProps"></el-pagination>
</div>
</div>
<el-dialog :title="dialogProps.title || '标题'" :visible.sync="dialogVisible" v-bind="dialogProps">
<eagle-form :list="_formList" :formProps="formProps" :span="12" @cancel="hideDialog"></eagle-form>
</el-dialog>
</div>
</template>
<script>
import { format, objExclude, generateListSpace } from './parser';
export default {
name: 'Scheme',
props: {
// 配置列表
list: Array,
// 搜索表单配置
searchList: Array,
// 表单配置
formList: Array,
// 表格配置
tableList: Array,
// 表格参数
tableProps: {
type: Object,
default() {
return { size: 'small', border: true }
}
},
// 表单参数
formProps: {
type: Object,
default() {
return { size: 'small', 'label-width': '90px' }
}
},
// 分页参数
paginationProps: {
type: Object,
default() {
return { 'page-sizes': [10, 20, 50], layout: 'total, sizes, prev, pager, next, jumper' }
}
},
// 弹出框参数
dialogProps: {
type: Object,
default() {
return { width: '65%' }
}
}
},
data() {
return {
// 搜索表单配置
_searchList: [],
// 表单配置
_formList: [],
// 表格配置
_tableList: [],
// 当前页
currentPage: 1,
// 弹出框状态
dialogVisible: false,
tableData: [
{ name: '赵伯', code: 'U00001', type: 'admin', sort: 0, status: 'active' },
{ name: '钱仲', code: 'U00002', type: 'user', sort: 1, status: 'active' },
{ name: '孙叔', code: 'U00003', type: 'user', sort: 2, status: 'active' },
{ name: '李季', code: 'U00004', type: 'user', sort: 3, status: 'active' },
]
};
},
created() {
if (this.list instanceof Array) {
const { search = [], form = [], table = [] } = generateListSpace(this.list);
this._searchList = search;
this._formList = form;
this._tableList = table;
} else {
this._searchList = this.searchList || [];
this._formList = this.formList || [];
this._tableList = this.tableList || [];
}
},
methods: {
showDialog() {
this.dialogVisible = true;
},
hideDialog() {
this.dialogVisible = false;
},
handleSizeChange(val) {
console.log(`每页 ${val} 条`);
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
}
}
};
</script>