tianheng-ui 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tianheng-ui.js +1 -1
- package/dist/tianheng-ui.js.map +1 -1
- package/package.json +1 -1
- package/src/component/icons/index.js +8 -0
- package/src/component/icons/index.vue +360 -0
- package/src/component/table/action.vue +126 -0
- package/src/component/table/column.vue +111 -0
- package/src/component/table/index.js +8 -0
- package/src/component/table/index.vue +251 -0
- package/src/component/table/search.vue +105 -0
- package/src/component/table/tools.vue +98 -0
- package/src/index.js +21 -0
- package/webpack.config.js +1 -1
@@ -0,0 +1,251 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="th-table">
|
3
|
+
<el-table
|
4
|
+
ref="th_table"
|
5
|
+
v-loading="loading"
|
6
|
+
:data="data"
|
7
|
+
:row-key="rowKey"
|
8
|
+
stripe
|
9
|
+
:highlight-current-row="selectType === 'single'"
|
10
|
+
:tree-props="treeProps"
|
11
|
+
@current-change="handleSingleSelect"
|
12
|
+
@row-dblclick="dblclick"
|
13
|
+
@selection-change="handleSelectionChange"
|
14
|
+
>
|
15
|
+
<template v-for="(item, index) in options">
|
16
|
+
<template v-if="!item.hide">
|
17
|
+
<el-table-column
|
18
|
+
v-if="item.type"
|
19
|
+
:key="index"
|
20
|
+
:type="item.type"
|
21
|
+
:label="item.label"
|
22
|
+
width="50"
|
23
|
+
>
|
24
|
+
</el-table-column>
|
25
|
+
<el-table-column
|
26
|
+
v-else-if="item.children"
|
27
|
+
:key="index"
|
28
|
+
:prop="item.prop"
|
29
|
+
:label="item.label"
|
30
|
+
:width="item.width"
|
31
|
+
:align="item.align || 'left'"
|
32
|
+
:fixed="item.fixed || null"
|
33
|
+
:sortable="item.sortable"
|
34
|
+
:sort-method="item.sortMethod"
|
35
|
+
show-overflow-tooltip
|
36
|
+
>
|
37
|
+
<table-column :options="item.children"></table-column>
|
38
|
+
</el-table-column>
|
39
|
+
<el-table-column
|
40
|
+
v-else
|
41
|
+
:key="index"
|
42
|
+
:prop="item.prop"
|
43
|
+
:label="item.label"
|
44
|
+
:width="item.width"
|
45
|
+
:align="item.align || 'left'"
|
46
|
+
:fixed="item.fixed || null"
|
47
|
+
:sortable="item.sortable"
|
48
|
+
:sort-method="item.sortMethod"
|
49
|
+
show-overflow-tooltip
|
50
|
+
>
|
51
|
+
<template slot-scope="scope">
|
52
|
+
<slot
|
53
|
+
v-if="item.slot"
|
54
|
+
:name="item.slot"
|
55
|
+
:scope="scope"
|
56
|
+
:option="item"
|
57
|
+
/>
|
58
|
+
<div v-else>{{ scope.row[item.prop] }}</div>
|
59
|
+
</template>
|
60
|
+
</el-table-column>
|
61
|
+
</template>
|
62
|
+
</template>
|
63
|
+
<!-- <table-column :options="options">
|
64
|
+
<template #slot="{ scope,option }">
|
65
|
+
<slot :name="option.slot" :scope="scope" :option="option" />
|
66
|
+
</template>
|
67
|
+
</table-column> -->
|
68
|
+
<template #empty>
|
69
|
+
<div>
|
70
|
+
{{ loading ? loadingText || "加载中" : emptyText || "暂无数据" }}
|
71
|
+
</div>
|
72
|
+
</template>
|
73
|
+
</el-table>
|
74
|
+
<!-- <i class="th-table-more el-icon-setting"></i> -->
|
75
|
+
|
76
|
+
<div v-if="Object.keys(pageInfo).length > 0 && showPage" class="pagination">
|
77
|
+
<el-pagination
|
78
|
+
:current-page="pageInfo.currentPage"
|
79
|
+
:page-sizes="pageInfo.sizes"
|
80
|
+
:page-size="pageInfo.pageSize"
|
81
|
+
layout="total, prev, pager, next, sizes"
|
82
|
+
:total="pageInfo.total"
|
83
|
+
@size-change="handleSizeChange"
|
84
|
+
@current-change="handleCurrentChange"
|
85
|
+
@prev-click="handlePrevClick"
|
86
|
+
@next-click="handleNextClick"
|
87
|
+
/>
|
88
|
+
</div>
|
89
|
+
</div>
|
90
|
+
</template>
|
91
|
+
|
92
|
+
<script>
|
93
|
+
import TableColumn from "./column.vue";
|
94
|
+
|
95
|
+
export default {
|
96
|
+
name:'ThTable',
|
97
|
+
components: {
|
98
|
+
TableColumn,
|
99
|
+
},
|
100
|
+
props: {
|
101
|
+
data: {
|
102
|
+
type: Array,
|
103
|
+
default: () => {
|
104
|
+
return [];
|
105
|
+
},
|
106
|
+
},
|
107
|
+
options: {
|
108
|
+
type: Array,
|
109
|
+
default: () => {
|
110
|
+
return [];
|
111
|
+
},
|
112
|
+
},
|
113
|
+
// single:单行选中 multiple:多行选中
|
114
|
+
selectType: {
|
115
|
+
type: String,
|
116
|
+
default: () => {
|
117
|
+
return "";
|
118
|
+
},
|
119
|
+
},
|
120
|
+
// 行双击事件
|
121
|
+
dblclick: {
|
122
|
+
type: Function,
|
123
|
+
default: () => {
|
124
|
+
return null;
|
125
|
+
},
|
126
|
+
},
|
127
|
+
treeProps: {
|
128
|
+
type: Object,
|
129
|
+
default: function() {
|
130
|
+
return {};
|
131
|
+
},
|
132
|
+
},
|
133
|
+
// 对象,不传表示没有分页,包含三个参数,均必填pageSize:每页展示的条数。currentPage:当前页码。pageCount:总页数
|
134
|
+
pageInfo: {
|
135
|
+
type: Object,
|
136
|
+
default: function() {
|
137
|
+
return {};
|
138
|
+
},
|
139
|
+
},
|
140
|
+
loading: {
|
141
|
+
type: Boolean,
|
142
|
+
default: () => {
|
143
|
+
return false;
|
144
|
+
},
|
145
|
+
},
|
146
|
+
height: {
|
147
|
+
type: String,
|
148
|
+
default: () => {
|
149
|
+
return "";
|
150
|
+
},
|
151
|
+
},
|
152
|
+
rowKey: {
|
153
|
+
type: String,
|
154
|
+
default: () => {
|
155
|
+
return "";
|
156
|
+
},
|
157
|
+
},
|
158
|
+
showPage: {
|
159
|
+
type: Boolean,
|
160
|
+
default: () => {
|
161
|
+
return true;
|
162
|
+
},
|
163
|
+
},
|
164
|
+
emptyText: {
|
165
|
+
type: String,
|
166
|
+
default: () => {
|
167
|
+
return "暂无数据";
|
168
|
+
},
|
169
|
+
},
|
170
|
+
loadingText: {
|
171
|
+
type: String,
|
172
|
+
default: () => {
|
173
|
+
return "加载中";
|
174
|
+
},
|
175
|
+
},
|
176
|
+
},
|
177
|
+
data() {
|
178
|
+
return {};
|
179
|
+
},
|
180
|
+
methods: {
|
181
|
+
handleSelectionChange(currentRow) {
|
182
|
+
if (currentRow) {
|
183
|
+
this.$emit("selection-change", currentRow);
|
184
|
+
}
|
185
|
+
},
|
186
|
+
// 选中行--单选
|
187
|
+
handleSingleSelect(currentRow, oldCurrentRow) {
|
188
|
+
if (currentRow) {
|
189
|
+
this.$emit("select-row-change", currentRow);
|
190
|
+
}
|
191
|
+
},
|
192
|
+
// 每页展示的条数 改变时
|
193
|
+
handleSizeChange(val) {
|
194
|
+
this.pageInfo.pageSize = val;
|
195
|
+
this.$emit(
|
196
|
+
"pageNumberChange",
|
197
|
+
this.pageInfo.currentPage,
|
198
|
+
this.pageInfo.pageSize
|
199
|
+
);
|
200
|
+
},
|
201
|
+
// 当前页码 改变时
|
202
|
+
handleCurrentChange(val) {
|
203
|
+
this.pageInfo.currentPage = val;
|
204
|
+
this.$emit(
|
205
|
+
"pageNumberChange",
|
206
|
+
this.pageInfo.currentPage,
|
207
|
+
this.pageInfo.pageSize
|
208
|
+
);
|
209
|
+
},
|
210
|
+
// 点击上一页
|
211
|
+
handlePrevClick() {
|
212
|
+
if (this.pageInfo.currentPage === 1) return;
|
213
|
+
this.pageInfo.currentPage -= 1;
|
214
|
+
this.$emit(
|
215
|
+
"pageNumberChange",
|
216
|
+
this.pageInfo.currentPage,
|
217
|
+
this.pageInfo.pageSize
|
218
|
+
);
|
219
|
+
},
|
220
|
+
// 点击下一页
|
221
|
+
handleNextClick() {
|
222
|
+
if (this.pageInfo.currentPage === this.pageInfo.pageCount) return;
|
223
|
+
this.pageInfo.currentPage += 1;
|
224
|
+
this.$emit(
|
225
|
+
"pageNumberChange",
|
226
|
+
this.pageInfo.currentPage,
|
227
|
+
this.pageInfo.pageSize
|
228
|
+
);
|
229
|
+
},
|
230
|
+
getTable() {
|
231
|
+
return this.$refs["th_table"];
|
232
|
+
},
|
233
|
+
},
|
234
|
+
};
|
235
|
+
</script>
|
236
|
+
|
237
|
+
<style lang="less" scoped>
|
238
|
+
.th-table {
|
239
|
+
position: relative;
|
240
|
+
width: 100%;
|
241
|
+
.pagination {
|
242
|
+
margin-top: 20px;
|
243
|
+
}
|
244
|
+
&-more {
|
245
|
+
position: absolute;
|
246
|
+
top: 13px;
|
247
|
+
right: 5px;
|
248
|
+
cursor: pointer;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
</style>
|
@@ -0,0 +1,105 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="table-search">
|
3
|
+
<template v-for="(item, index) in options">
|
4
|
+
<el-input
|
5
|
+
v-if="item.type === 'input'"
|
6
|
+
class="table-search-item"
|
7
|
+
v-model="params[item.value]"
|
8
|
+
:key="index"
|
9
|
+
:style="{ width: item.width + 'px' }"
|
10
|
+
:placeholder="item.placeholder || '请输入'"
|
11
|
+
:size="item.size || 'mini'"
|
12
|
+
clearable
|
13
|
+
></el-input>
|
14
|
+
<el-date-picker
|
15
|
+
v-if="item.type === 'date'"
|
16
|
+
class="table-search-item"
|
17
|
+
v-model="params[item.value]"
|
18
|
+
:key="index"
|
19
|
+
:style="{ width: item.width + 'px' }"
|
20
|
+
:type="item.dateType || 'date'"
|
21
|
+
:format="item.format"
|
22
|
+
:value-format="item.valueFormat"
|
23
|
+
:size="item.size || 'mini'"
|
24
|
+
range-separator="至"
|
25
|
+
start-placeholder="开始日期"
|
26
|
+
end-placeholder="结束日期"
|
27
|
+
>
|
28
|
+
</el-date-picker>
|
29
|
+
</template>
|
30
|
+
|
31
|
+
<el-button
|
32
|
+
type="primary"
|
33
|
+
icon="el-icon-search"
|
34
|
+
size="mini"
|
35
|
+
plain
|
36
|
+
@click="doSearch"
|
37
|
+
>查询</el-button
|
38
|
+
>
|
39
|
+
<el-button
|
40
|
+
type="primary"
|
41
|
+
icon="el-icon-refresh-right"
|
42
|
+
size="mini"
|
43
|
+
plain
|
44
|
+
@click="doReset"
|
45
|
+
>重置</el-button
|
46
|
+
>
|
47
|
+
</div>
|
48
|
+
</template>
|
49
|
+
|
50
|
+
<script>
|
51
|
+
export default {
|
52
|
+
props: {
|
53
|
+
options: {
|
54
|
+
type: Array,
|
55
|
+
default: () => {
|
56
|
+
return [];
|
57
|
+
},
|
58
|
+
},
|
59
|
+
params: {
|
60
|
+
type: Object,
|
61
|
+
default: () => {
|
62
|
+
return {};
|
63
|
+
},
|
64
|
+
},
|
65
|
+
},
|
66
|
+
data() {
|
67
|
+
return {
|
68
|
+
datePickerTypes: [
|
69
|
+
"year",
|
70
|
+
"month",
|
71
|
+
"date",
|
72
|
+
"dates",
|
73
|
+
"week",
|
74
|
+
"datetime",
|
75
|
+
"datetimerange",
|
76
|
+
"daterange",
|
77
|
+
"monthrange",
|
78
|
+
],
|
79
|
+
};
|
80
|
+
},
|
81
|
+
methods: {
|
82
|
+
doSearch() {
|
83
|
+
this.$emit("on-search", this.params);
|
84
|
+
},
|
85
|
+
doReset() {
|
86
|
+
this.params = {};
|
87
|
+
this.$emit("on-reset", this.params);
|
88
|
+
},
|
89
|
+
},
|
90
|
+
};
|
91
|
+
</script>
|
92
|
+
|
93
|
+
<style lang="less" scoped>
|
94
|
+
.table-search {
|
95
|
+
display: flex;
|
96
|
+
align-items: center;
|
97
|
+
margin-bottom: 10px;
|
98
|
+
&-item {
|
99
|
+
margin-right: 10px;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
.table-search-item:last-child {
|
103
|
+
margin-right: 20px !important;
|
104
|
+
}
|
105
|
+
</style>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="tableTools">
|
3
|
+
<template v-for="(item, index) in options">
|
4
|
+
<el-button
|
5
|
+
v-if="item.act_type === 'add'"
|
6
|
+
:key="index"
|
7
|
+
:style="{ color: item.btn_color }"
|
8
|
+
:type="item.btn_type"
|
9
|
+
:icon="item.btn_icon"
|
10
|
+
:disabled="item.btn_disabled"
|
11
|
+
@click="doAdd(item)"
|
12
|
+
>{{ item.btn_name }}</el-button
|
13
|
+
>
|
14
|
+
<el-button
|
15
|
+
v-if="item.act_type === 'refresh'"
|
16
|
+
:key="index"
|
17
|
+
:style="{ color: item.btn_color }"
|
18
|
+
:type="item.btn_type"
|
19
|
+
:icon="item.btn_icon"
|
20
|
+
:disabled="item.btn_disabled"
|
21
|
+
@click="doRefresh(item)"
|
22
|
+
>{{ item.btn_name }}</el-button
|
23
|
+
>
|
24
|
+
<el-button
|
25
|
+
v-if="item.act_type === 'export'"
|
26
|
+
:key="index"
|
27
|
+
:style="{ color: item.btn_color }"
|
28
|
+
:type="item.btn_type"
|
29
|
+
:icon="item.btn_icon"
|
30
|
+
:disabled="item.btn_disabled"
|
31
|
+
@click="doExport(item)"
|
32
|
+
>{{ item.btn_name }}</el-button
|
33
|
+
>
|
34
|
+
<el-button
|
35
|
+
v-if="item.act_type === 'batch'"
|
36
|
+
:key="index"
|
37
|
+
:style="{ color: item.btn_color }"
|
38
|
+
:type="item.btn_type"
|
39
|
+
:icon="item.btn_icon"
|
40
|
+
:disabled="item.btn_disabled || selectionDisabled"
|
41
|
+
:loading="loadingDel"
|
42
|
+
@click="doBatch(item)"
|
43
|
+
>{{ item.btn_name }}</el-button
|
44
|
+
>
|
45
|
+
</template>
|
46
|
+
</div>
|
47
|
+
</template>
|
48
|
+
|
49
|
+
<script>
|
50
|
+
export default {
|
51
|
+
props: {
|
52
|
+
options: {
|
53
|
+
type: Array,
|
54
|
+
default: () => {
|
55
|
+
return [];
|
56
|
+
},
|
57
|
+
},
|
58
|
+
selectionDisabled: {
|
59
|
+
type: Boolean,
|
60
|
+
default: () => {
|
61
|
+
return true;
|
62
|
+
},
|
63
|
+
},
|
64
|
+
},
|
65
|
+
data() {
|
66
|
+
return {
|
67
|
+
loadingDel: false,
|
68
|
+
};
|
69
|
+
},
|
70
|
+
methods: {
|
71
|
+
doEval(item) {
|
72
|
+
this.$emit("on-eval", item);
|
73
|
+
},
|
74
|
+
doAdd(item) {
|
75
|
+
this.$emit("on-add", item);
|
76
|
+
},
|
77
|
+
doRefresh(item) {
|
78
|
+
this.$emit("on-refresh", item);
|
79
|
+
},
|
80
|
+
doExport(item) {
|
81
|
+
this.$emit("on-export", item);
|
82
|
+
},
|
83
|
+
doBatch(item) {
|
84
|
+
this.loadingDel = true;
|
85
|
+
const callback = (bool) => {
|
86
|
+
this.loadingDel = false;
|
87
|
+
};
|
88
|
+
this.$emit("on-batch", item, callback);
|
89
|
+
},
|
90
|
+
},
|
91
|
+
};
|
92
|
+
</script>
|
93
|
+
|
94
|
+
<style lang="less">
|
95
|
+
.tableTools {
|
96
|
+
margin-bottom: 10px;
|
97
|
+
}
|
98
|
+
</style>
|
package/src/index.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import Cell from "./component/cell/index.js";
|
2
|
+
import Icons from "./component/icons/index.js";
|
3
|
+
import Table from "./component/table/index.js";
|
4
|
+
|
5
|
+
const components = [Cell, Icons, Table];
|
6
|
+
|
7
|
+
const install = function(Vue, opts = {}) {
|
8
|
+
components.forEach(component => {
|
9
|
+
Vue.component(component.name, component);
|
10
|
+
});
|
11
|
+
};
|
12
|
+
|
13
|
+
if (typeof window !== "undefined" && window.Vue) {
|
14
|
+
install(window.Vue);
|
15
|
+
}
|
16
|
+
|
17
|
+
export default {
|
18
|
+
version: "0.0.3",
|
19
|
+
install,
|
20
|
+
...components
|
21
|
+
};
|