tianheng-ui 0.0.5 → 0.0.9

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.
@@ -0,0 +1,111 @@
1
+ <template>
2
+ <div>
3
+ <template v-for="(item, index) in options">
4
+ <template v-if="!item.hide">
5
+ <el-table-column
6
+ v-if="item.type"
7
+ :key="index"
8
+ :type="item.type"
9
+ :label="item.label"
10
+ width="50"
11
+ >
12
+ </el-table-column>
13
+ <el-table-column
14
+ v-else-if="item.children"
15
+ :key="index"
16
+ :prop="item.prop"
17
+ :label="item.label"
18
+ :width="item.width"
19
+ :align="item.align"
20
+ :fixed="item.fixed"
21
+ :sortable="item.sortable"
22
+ :sort-method="item.sortMethod"
23
+ show-overflow-tooltip
24
+ >
25
+ <TableColumn :key="index" :options="item.children"></TableColumn>
26
+ </el-table-column>
27
+ <el-table-column
28
+ v-else
29
+ :key="index"
30
+ :prop="item.prop"
31
+ :label="item.label"
32
+ :width="item.width"
33
+ :align="item.align"
34
+ :fixed="item.fixed"
35
+ :sortable="item.sortable"
36
+ :sort-method="item.sortMethod"
37
+ show-overflow-tooltip
38
+ >
39
+ <template slot-scope="scope">
40
+ <slot v-if="item.slot" name="slot" :scope="scope" :option="item" />
41
+ <div v-else>{{ scope.row[item.prop] }}</div>
42
+ </template>
43
+ </el-table-column>
44
+ </template>
45
+ </template>
46
+ </div>
47
+ </template>
48
+
49
+ <script>
50
+ export default {
51
+ name: "TableColumn",
52
+ props: {
53
+ options: {
54
+ type: Array,
55
+ default: () => {
56
+ return [];
57
+ },
58
+ },
59
+ },
60
+ created(){
61
+ /**
62
+ *
63
+ * <template v-if={!item.hide}>
64
+ <el-table-column
65
+ v-if={item.type}
66
+ type={item.type}
67
+ label={item.label}
68
+ width="50"
69
+ ></el-table-column>
70
+ <el-table-column
71
+ v-else-if={item.children}
72
+ prop={item.prop}
73
+ label={item.label}
74
+ width={item.width}
75
+ align={item.align}
76
+ fixed={item.fixed}
77
+ sortable={item.sortable}
78
+ sort-method={item.sortMethod}
79
+ show-overflow-tooltip
80
+ >
81
+ {this.dynamicItem(item.children)}
82
+ </el-table-column>
83
+ <el-table-column
84
+ v-else
85
+ prop={item.prop}
86
+ label={item.label}
87
+ width={item.width}
88
+ align={item.align}
89
+ fixed={item.fixed}
90
+ sortable={item.sortable}
91
+ sort-method={item.sortMethod}
92
+ show-overflow-tooltip
93
+ >
94
+ <template slot-scope="scope">
95
+ <slot
96
+ v-if={item.slot}
97
+ name="slot"
98
+ scope={scope}
99
+ option={item}
100
+ />
101
+ <div v-else>{scope.row[item.prop]}</div>
102
+ </template>
103
+ </el-table-column>
104
+ </template>
105
+ */
106
+ console.log(this.options)
107
+ }
108
+ };
109
+ </script>
110
+
111
+ <style></style>
@@ -0,0 +1,8 @@
1
+ import Table from "./index.vue";
2
+
3
+ /* istanbul ignore next */
4
+ Table.install = function(Vue) {
5
+ Vue.component(Table.name, Table);
6
+ };
7
+
8
+ export default Table;
@@ -0,0 +1,257 @@
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="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
+ stripe: {
128
+ type: Boolean,
129
+ default: () => {
130
+ return false;
131
+ }
132
+ },
133
+ treeProps: {
134
+ type: Object,
135
+ default: function() {
136
+ return {};
137
+ }
138
+ },
139
+ // 对象,不传表示没有分页,包含三个参数,均必填pageSize:每页展示的条数。currentPage:当前页码。pageCount:总页数
140
+ pageInfo: {
141
+ type: Object,
142
+ default: function() {
143
+ return {};
144
+ }
145
+ },
146
+ loading: {
147
+ type: Boolean,
148
+ default: () => {
149
+ return false;
150
+ }
151
+ },
152
+ height: {
153
+ type: String,
154
+ default: () => {
155
+ return "";
156
+ }
157
+ },
158
+ rowKey: {
159
+ type: String,
160
+ default: () => {
161
+ return "";
162
+ }
163
+ },
164
+ showPage: {
165
+ type: Boolean,
166
+ default: () => {
167
+ return true;
168
+ }
169
+ },
170
+ emptyText: {
171
+ type: String,
172
+ default: () => {
173
+ return "暂无数据";
174
+ }
175
+ },
176
+ loadingText: {
177
+ type: String,
178
+ default: () => {
179
+ return "加载中";
180
+ }
181
+ }
182
+ },
183
+ data() {
184
+ return {};
185
+ },
186
+ methods: {
187
+ handleSelectionChange(currentRow) {
188
+ if (currentRow) {
189
+ this.$emit("selection-change", currentRow);
190
+ }
191
+ },
192
+ // 选中行--单选
193
+ handleSingleSelect(currentRow, oldCurrentRow) {
194
+ if (currentRow) {
195
+ this.$emit("select-row-change", currentRow);
196
+ }
197
+ },
198
+ // 每页展示的条数 改变时
199
+ handleSizeChange(val) {
200
+ this.pageInfo.pageSize = val;
201
+ this.$emit(
202
+ "pageNumberChange",
203
+ this.pageInfo.currentPage,
204
+ this.pageInfo.pageSize
205
+ );
206
+ },
207
+ // 当前页码 改变时
208
+ handleCurrentChange(val) {
209
+ this.pageInfo.currentPage = val;
210
+ this.$emit(
211
+ "pageNumberChange",
212
+ this.pageInfo.currentPage,
213
+ this.pageInfo.pageSize
214
+ );
215
+ },
216
+ // 点击上一页
217
+ handlePrevClick() {
218
+ if (this.pageInfo.currentPage === 1) return;
219
+ this.pageInfo.currentPage -= 1;
220
+ this.$emit(
221
+ "pageNumberChange",
222
+ this.pageInfo.currentPage,
223
+ this.pageInfo.pageSize
224
+ );
225
+ },
226
+ // 点击下一页
227
+ handleNextClick() {
228
+ if (this.pageInfo.currentPage === this.pageInfo.pageCount) return;
229
+ this.pageInfo.currentPage += 1;
230
+ this.$emit(
231
+ "pageNumberChange",
232
+ this.pageInfo.currentPage,
233
+ this.pageInfo.pageSize
234
+ );
235
+ },
236
+ getTable() {
237
+ return this.$refs["th_table"];
238
+ }
239
+ }
240
+ };
241
+ </script>
242
+
243
+ <style lang="less" scoped>
244
+ .th-table {
245
+ position: relative;
246
+ width: 100%;
247
+ .pagination {
248
+ margin-top: 20px;
249
+ }
250
+ &-more {
251
+ position: absolute;
252
+ top: 13px;
253
+ right: 5px;
254
+ cursor: pointer;
255
+ }
256
+ }
257
+ </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/App.vue DELETED
@@ -1,31 +0,0 @@
1
- <template>
2
- <div id="app">
3
- <th-cell
4
- v-for="(item, index) in list"
5
- :key="index"
6
- :title="item.title" :label="item.label"
7
- ></th-cell>
8
- </div>
9
- </template>
10
-
11
- <script>
12
- import ThCell from "../packages/cell/index.vue";
13
- export default {
14
- name: "app",
15
- components: { ThCell },
16
- data() {
17
- return {
18
- list: [{ title: "张三", label: "18岁" }]
19
- };
20
- }
21
- };
22
- </script>
23
-
24
- <style lang="scss">
25
- #app {
26
- font-family: "Avenir", Helvetica, Arial, sans-serif;
27
- -webkit-font-smoothing: antialiased;
28
- -moz-osx-font-smoothing: grayscale;
29
- color: #2c3e50;
30
- }
31
- </style>
Binary file
package/src/main.js DELETED
@@ -1,11 +0,0 @@
1
- import Vue from 'vue'
2
- import App from './App.vue'
3
-
4
- import ElementUI from 'element-ui';
5
- import 'element-ui/lib/theme-chalk/index.css';
6
- Vue.use(ElementUI);
7
-
8
- new Vue({
9
- el: '#app',
10
- render: h => h(App)
11
- })