zartui 2.0.80 → 2.0.81

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/lib/index.js CHANGED
@@ -309,7 +309,7 @@ exports.Toast = _toast.default;
309
309
  var _uploader = _interopRequireDefault(require("./uploader"));
310
310
 
311
311
  exports.Uploader = _uploader.default;
312
- var version = '2.0.80';
312
+ var version = '2.0.81';
313
313
  exports.version = version;
314
314
 
315
315
  function install(Vue) {
package/lib/index.less CHANGED
@@ -3,6 +3,7 @@
3
3
  @import "./info/index.less";
4
4
  @import "./icon/index.less";
5
5
  @import "./tag/index.less";
6
+ @import "./table/index.less";
6
7
  @import "./tabbar-item/index.less";
7
8
  @import "./step/index.less";
8
9
  @import "./rate/index.less";
@@ -67,5 +68,4 @@
67
68
  @import "./stepper/index.less";
68
69
  @import "./steps/index.less";
69
70
  @import "./swipe-cell/index.less";
70
- @import "./tabbar/index.less";
71
- @import "./table/index.less";
71
+ @import "./tabbar/index.less";
@@ -1066,11 +1066,16 @@
1066
1066
  @backtop-box-shadow: 0 4px 12px 0 rgba(5,140,230,0.40);
1067
1067
 
1068
1068
  // Table
1069
- @table-border-radius: @border-radius-lg;
1070
1069
  @table-head-height: 40px;
1071
1070
  @table-head-font-size: 14px;
1071
+ @table-head-color: @blue;
1072
+ @table-head-background: #E6F5FF;
1073
+ @table-body-background: #F5FAFF;
1072
1074
  @table-row-height: 40px;
1073
1075
  @table-row-font-size: 14px;
1076
+ @table-row-color: #2D4B73;
1077
+ @table-row-background: #fff;
1078
+ @table-sort-default-color: #c8c9cc;
1074
1079
 
1075
1080
  // Fold-Dialog
1076
1081
  @foldDialog-padding: 0 16px 12px 16px;
@@ -1 +1 @@
1
- .zt2-table{position:relative;border-radius:8px;scrollbar-width:none;-ms-overflow-style:none}.zt2-table::-webkit-scrollbar{display:none;width:0;height:0}.zt2-table__normal-box{display:-webkit-box;display:-webkit-flex;display:flex;overflow-x:scroll;position:relative}.zt2-table__fixed-left-box{display:-webkit-box;display:-webkit-flex;display:flex;position:absolute;top:0;left:-1px;z-index:2}.zt2-table__fixed-right-box{display:-webkit-box;display:-webkit-flex;display:flex;position:absolute;top:0;right:-1px;z-index:2}.zt2-table__fixed-left-box.shadow::after{content:"";position:absolute;top:0;right:-10px;width:10px;height:100%;opacity:.06;background-image:-webkit-linear-gradient(left,#000 0,rgba(0,0,0,0) 100%);background-image:linear-gradient(90deg,#000 0,rgba(0,0,0,0) 100%)}.zt2-table__fixed-right-box.shadow::before{content:"";position:absolute;top:0;left:-10px;width:10px;height:100%;opacity:.06;background-image:-webkit-linear-gradient(left,#000 0,rgba(0,0,0,0) 100%);background-image:linear-gradient(90deg,#000 0,rgba(0,0,0,0) 100%)}.zt2-table__head{-webkit-flex-shrink:0;flex-shrink:0}.zt2-table__head-item{height:40px;font-weight:600;font-size:14px;text-align:center;line-height:40px}.zt2-table__table-data{height:40px;font-size:14px;text-align:center;line-height:40px}.zt2-table.zt2-table--no-border .zt2-table__fixed-head::after,.zt2-table.zt2-table--no-border .zt2-table__head-item::after,.zt2-table.zt2-table--no-border .zt2-table__head::after,.zt2-table.zt2-table--no-border .zt2-table__normal-box::after,.zt2-table.zt2-table--no-border .zt2-table__table-data::after{border:none}
1
+ .zt2-table table{border-collapse:separate;border-spacing:0;width:100%;table-layout:auto;box-sizing:border-box}.zt2-table--fixed{overflow:auto scroll}.zt2-table--fixed::-webkit-scrollbar{width:0;height:0}.zt2-table--fixed table{table-layout:fixed}.zt2-table--thead-fixed{position:-webkit-sticky!important;position:sticky!important;z-index:2}.zt2-table--fix-left{position:-webkit-sticky!important;position:sticky!important;z-index:2}.zt2-table--bordered{border-left:1px solid #f0f0f0}.zt2-table--bordered>table{border-top:1px solid #f0f0f0}.zt2-table--bordered .zt2-table__thead>tr>th{border-right:1px solid #f0f0f0;border-bottom:1px solid #f0f0f0}.zt2-table--bordered .zt2-table__tbody>tr>td{border-bottom:1px solid #f0f0f0;border-right:1px solid #f0f0f0}.zt2-table__thead>tr>th{box-sizing:border-box;overflow-wrap:break-word;height:40px;font-weight:600;font-size:14px;color:#0091fa;text-align:center;line-height:40px;background:#e6f5ff}.zt2-table__head{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center}.zt2-table__head-sort{display:-webkit-inline-box;display:-webkit-inline-flex;display:inline-flex;-webkit-box-align:center;-webkit-align-items:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;color:#c8c9cc}.zt2-table__sort-active{color:#0091fa}.zt2-table__tbody>tr>td{box-sizing:border-box;overflow-wrap:break-word;height:40px;font-size:14px;color:#2d4b73;text-align:center;line-height:40px;background:#fff}.zt2-table--striped .zt2-table__tbody>tr:nth-child(even)>td{background:#f5faff}.zt2-table--left-last{border-right:none!important}.zt2-table--left-last::after{content:"";position:absolute;top:0;right:-10px;width:10px;height:100%;opacity:.06;background-image:-webkit-linear-gradient(left,#000 0,rgba(0,0,0,0) 100%);background-image:linear-gradient(90deg,#000 0,rgba(0,0,0,0) 100%)}
@@ -1,20 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  exports.__esModule = true;
4
6
  exports.default = void 0;
5
7
 
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
6
10
  var _utils = require("../utils");
7
11
 
8
- var _constant = require("../utils/constant");
12
+ var _index = _interopRequireDefault(require("../icon/index"));
13
+
14
+ var _type = require("./type");
9
15
 
10
16
  var _createNamespace = (0, _utils.createNamespace)('table'),
11
17
  createComponent = _createNamespace[0],
12
18
  bem = _createNamespace[1];
13
19
 
14
- var defaultData = function defaultData() {
15
- return {};
16
- };
17
-
18
20
  var _default = createComponent({
19
21
  props: {
20
22
  headList: {
@@ -25,269 +27,198 @@ var _default = createComponent({
25
27
  type: Array,
26
28
  default: []
27
29
  },
28
- outline: {
30
+ bordered: {
29
31
  type: Boolean,
30
32
  default: true
31
33
  },
32
- headColor: {
33
- type: String,
34
- default: "#000"
35
- },
36
- headBackground: {
37
- type: String,
38
- default: "#fafafa"
39
- },
40
- dataColor: {
41
- type: String,
42
- default: "#000"
43
- },
44
- dataBackground: {
45
- type: String,
46
- default: "#fff"
47
- },
48
- hideTableHead: {
34
+ striped: {
49
35
  type: Boolean,
50
36
  default: false
51
37
  }
52
38
  },
53
39
  data: function data() {
54
- return defaultData();
40
+ return {
41
+ pingedLeft: false,
42
+ sortOrder: '',
43
+ sortKey: ''
44
+ };
55
45
  },
56
46
  computed: {
57
- fixedColumnLeft: function fixedColumnLeft() {
47
+ fixedColumn: function fixedColumn() {
58
48
  return this.headList.filter(function (v) {
59
- return v.fixedLeft;
49
+ return v.fixed;
60
50
  });
61
51
  },
62
- fixedColumnRight: function fixedColumnRight() {
63
- return this.headList.filter(function (v) {
64
- return v.fixedRight;
65
- });
66
- },
67
- resortHeadList: function resortHeadList() {
68
- // 对表头数组重新排序,需要固定的表头向左对齐
69
- return this.fixedColumnLeft.concat(this.headList.filter(function (v) {
70
- return !v.fixedLeft && !v.fixedRight;
71
- })).concat(this.fixedColumnRight);
52
+ fixed: function fixed() {
53
+ return this.fixedColumn.length > 0;
72
54
  },
73
- hasSummary: function hasSummary() {
74
- return this.headList.filter(function (v) {
75
- return v.showSummary;
76
- }).length > 0;
77
- }
78
- },
79
- mounted: function mounted() {
80
- var columnTotalWidth = 0;
81
- this.headList.forEach(function (v, i) {
82
- var dom = document.getElementById("tableHead" + i);
83
-
84
- if (dom) {
85
- columnTotalWidth += dom.clientWidth || 0;
86
- }
87
- });
88
- var box = document.getElementById("normalBoxID");
89
- var boxWidth = 0;
90
-
91
- if (box) {
92
- boxWidth = box.clientWidth;
93
- }
94
-
95
- if (this.fixedColumnLeft && this.fixedColumnLeft.length || this.fixedColumnRight && this.fixedColumnRight.length) {
96
- // 当表格横向出现滚动时,给固定列加一个box-shadow
97
- var fixedBoxRight = document.getElementById("fixedRightBoxID");
98
-
99
- if (fixedBoxRight && columnTotalWidth > boxWidth) {
100
- fixedBoxRight.classList.add("shadow");
101
- }
102
-
103
- if (box) {
104
- box.addEventListener("scroll", function (e) {
105
- var fixedBoxLeft = document.getElementById("fixedLeftBoxID");
106
-
107
- if (fixedBoxLeft) {
108
- if (e && e.target && e.target.scrollLeft > 0) {
109
- fixedBoxLeft.classList.add("shadow");
110
- } else {
111
- fixedBoxLeft.classList.remove("shadow");
112
- }
113
- }
114
-
115
- if (fixedBoxRight) {
116
- if (e && e.target && e.target.scrollLeft + e.target.clientWidth >= columnTotalWidth - 1) {
117
- fixedBoxRight.classList.remove("shadow");
118
- } else {
119
- fixedBoxRight.classList.add("shadow");
120
- }
121
- }
122
- });
123
- }
124
- } // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
125
-
126
-
127
- var fixedLeftIndexList = this.headList.map(function (v, i) {
128
- if (v.fixedLeft) {
129
- return "tableHead" + i;
130
- } else {
131
- return "";
132
- }
133
- }).filter(function (v) {
134
- return v !== "";
135
- });
136
-
137
- if (fixedLeftIndexList.length > 0) {
138
- fixedLeftIndexList.forEach(function (current, index) {
139
- var fixedDom = document.getElementById("fixedHeadLeft" + index);
140
- var normalDom = document.getElementById(current);
141
-
142
- if (fixedDom && normalDom) {
143
- fixedDom.style.width = normalDom.offsetWidth + "px";
55
+ formatColumns: function formatColumns() {
56
+ var _this = this;
57
+
58
+ var columns = [];
59
+ var left = 0;
60
+ this.headList.forEach(function (element, index) {
61
+ var column = {};
62
+ var preColumn = _this.headList[index - 1];
63
+ var nextColumn = _this.headList[index + 1];
64
+
65
+ if (element.sorter && element.defaultSortOrder) {
66
+ _this.sortOrder = element.defaultSortOrder || '';
67
+ _this.sortKey = element.key;
144
68
  }
145
- }, 0);
146
- } // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
147
69
 
148
-
149
- var fixedRightIndexList = this.headList.map(function (v, i) {
150
- if (v.fixedRight) {
151
- return "tableHead" + i;
152
- } else {
153
- return "";
154
- }
155
- }).filter(function (v) {
156
- return v !== "";
157
- });
158
-
159
- if (fixedRightIndexList.length > 0) {
160
- fixedRightIndexList.forEach(function (current, index) {
161
- var fixedDom = document.getElementById("fixedHeadRight" + index);
162
- var normalDom = document.getElementById(current);
163
-
164
- if (fixedDom && normalDom) {
165
- fixedDom.style.width = normalDom.offsetWidth + "px";
70
+ if (preColumn) {
71
+ left += Number(preColumn.width.split('px')[0]);
72
+ column.left = left + "px";
73
+ } else {
74
+ column.left = 0;
166
75
  }
167
- }, 0); // 当存在右侧固定列,且列宽度不足以撑满容器时,将最后一列宽度拉长到填满
168
76
 
169
- if (columnTotalWidth < boxWidth) {
170
- var lastColumn = document.getElementById("tableHead" + (this.headList.length - 1));
171
-
172
- if (lastColumn) {
173
- lastColumn.classList.add("widen");
174
- lastColumn.style.width = "unset";
175
- lastColumn.style.flex = "1";
77
+ if (element.fixed && !nextColumn.fixed) {
78
+ column.lastFixLeft = true;
176
79
  }
177
- }
80
+
81
+ columns.push((0, _extends2.default)({}, element, column));
82
+ });
83
+ return columns;
178
84
  }
179
85
  },
180
- watch: {},
181
86
  methods: {
182
- genColumn: function genColumn(headObj, index, isFixed) {
183
- var h = this.$createElement;
184
-
185
- var _ref = this,
186
- slots = _ref.slots,
187
- hideTableHead = _ref.hideTableHead;
188
-
189
- var headItemStyle = {
190
- color: this.headColor,
191
- background: this.headBackground
192
- };
193
- var dataStyle = {
194
- color: this.dataColor,
195
- background: this.dataBackground
196
- };
197
- var idName = "tableHead" + index;
198
-
199
- if (isFixed === "left") {
200
- idName = "fixedHeadLeft" + index;
87
+ onScroll: function onScroll(_ref) {
88
+ var currentTarget = _ref.currentTarget,
89
+ scrollLeft = _ref.scrollLeft;
90
+ var mergedScrollLeft = typeof scrollLeft === 'number' ? scrollLeft : currentTarget.scrollLeft;
91
+ this.pingedLeft = mergedScrollLeft > 0;
92
+ },
93
+ getNextSortOrder: function getNextSortOrder(type) {
94
+ if (!type) {
95
+ return _type.SortOrderEnum.ASCEND;
201
96
  }
202
97
 
203
- if (isFixed === "right") {
204
- idName = "fixedHeadRight" + index;
98
+ if (type === _type.SortOrderEnum.ASCEND) {
99
+ return _type.SortOrderEnum.DESCEND;
205
100
  }
206
101
 
207
- var headRender = slots("head" + headObj.id) || headObj.label;
102
+ return '';
103
+ },
104
+ onHeaderClick: function onHeaderClick(data) {
105
+ if (!data.sorter) return;
106
+ this.sortOrder = this.getNextSortOrder(data.key === this.sortKey ? this.sortOrder : '');
107
+ this.sortKey = data.key;
108
+ this.$emit('sort', {
109
+ order: this.sortOrder,
110
+ key: data.key
111
+ });
112
+ },
113
+ getHead: function getHead(colData) {
114
+ var _this2 = this;
208
115
 
209
- if ((headObj.fixedLeft || headObj.fixedRight) && !isFixed) {
210
- // 被固定列遮住的列不显示内容
211
- headRender = "";
116
+ var h = this.$createElement;
117
+
118
+ if ((colData == null ? void 0 : colData.colSpan) !== 0) {
119
+ return h("th", {
120
+ "class": bem({
121
+ 'fix-left': colData.fixed,
122
+ 'left-last': colData.lastFixLeft && this.pingedLeft
123
+ }),
124
+ "style": {
125
+ left: colData.fixed ? colData.left : ''
126
+ },
127
+ "attrs": {
128
+ "colspan": (colData == null ? void 0 : colData.colSpan) !== 1 ? colData == null ? void 0 : colData.colSpan : null
129
+ }
130
+ }, [h("div", {
131
+ "class": bem('head'),
132
+ "on": {
133
+ "click": function click() {
134
+ return _this2.onHeaderClick(colData);
135
+ }
136
+ }
137
+ }, [h("span", [colData.label]), colData.sorter ? h("span", {
138
+ "class": bem('head-sort')
139
+ }, [h(_index.default, {
140
+ "class": [colData.key === this.sortKey && this.sortOrder === _type.SortOrderEnum.ASCEND ? bem('sort-active') : ''],
141
+ "attrs": {
142
+ "name": "spinner-shrink",
143
+ "size": "12"
144
+ },
145
+ "style": {
146
+ marginBottom: '-3px'
147
+ }
148
+ }), h(_index.default, {
149
+ "class": [colData.key === this.sortKey && this.sortOrder === _type.SortOrderEnum.DESCEND ? bem('sort-active') : ''],
150
+ "attrs": {
151
+ "name": "spinner-expand",
152
+ "size": "12"
153
+ },
154
+ "style": {
155
+ marginTop: '-3px'
156
+ }
157
+ })]) : ''])]);
212
158
  }
159
+ },
160
+ onClick: function onClick() {},
161
+ getBody: function getBody(rowData, rowIndex) {
162
+ var _this3 = this;
213
163
 
214
- return h("div", {
215
- "class": [bem(isFixed ? "fixed-head" : "head"), isFixed ? _constant.BORDER_SURROUND : _constant.BORDER_RIGHT],
216
- "attrs": {
217
- "id": idName
218
- },
219
- "style": isFixed ? "" : headObj.width ? "width:" + headObj.width + ";" : ""
220
- }, [h("div", {
221
- "directives": [{
222
- name: "show",
223
- value: !hideTableHead
224
- }],
225
- "class": [bem("head-item"), _constant.BORDER_TOP_BOTTOM],
226
- "style": headItemStyle
227
- }, [headRender]), this.dataList.map(function (data) {
228
- var hide = (headObj.fixedLeft || headObj.fixedRight) && !isFixed;
164
+ var h = this.$createElement;
165
+ return h("tr", [this.formatColumns.map(function (colData) {
166
+ var _additionalCellProps, _additionalCellProps2, _additionalCellProps3, _additionalCellProps4, _additionalCellProps5, _additionalCellProps6;
229
167
 
230
- if (hide) {
231
- // 被固定列遮住的列不显示内容
232
- return h("div", {
233
- "class": [bem("table-data"), _constant.BORDER_BOTTOM],
234
- "style": dataStyle
235
- });
236
- } else if (data[headObj.key] && data[headObj.key].id && slots("data" + data[headObj.key].id)) {
237
- return slots("data" + data[headObj.key].id);
238
- } else {
239
- return h("div", {
240
- "class": [bem("table-data"), _constant.BORDER_BOTTOM],
241
- "style": dataStyle
242
- }, [data[headObj.key]]);
168
+ var additionalCellProps;
169
+
170
+ if (colData.customCell) {
171
+ additionalCellProps = colData.customCell(rowData, rowIndex);
243
172
  }
244
- }), this.hasSummary ? headObj.showSummary ? h("div", {
245
- "class": [bem("head-item"), _constant.BORDER_BOTTOM],
246
- "style": headItemStyle
247
- }, [this.dataList.reduce(function (prev, curr) {
248
- return prev + curr[headObj.key];
249
- }, 0)]) : h("div", {
250
- "class": [bem("head-item"), _constant.BORDER_BOTTOM],
251
- "style": headItemStyle
252
- }, [headObj.summaryLabel || ""]) : ""]);
173
+
174
+ var style = (0, _extends2.default)({}, colData.style);
175
+ style.left = colData.fixed ? colData.left : '';
176
+ return ((_additionalCellProps = additionalCellProps) == null ? void 0 : _additionalCellProps.rowSpan) !== 0 && ((_additionalCellProps2 = additionalCellProps) == null ? void 0 : _additionalCellProps2.colSpan) !== 0 && h("td", {
177
+ "on": {
178
+ "click": function click() {
179
+ return colData.onClick && colData.onClick(rowData, rowIndex);
180
+ }
181
+ },
182
+ "class": bem({
183
+ 'fix-left': colData.fixed,
184
+ 'left-last': colData.lastFixLeft && _this3.pingedLeft
185
+ }),
186
+ "attrs": {
187
+ "colspan": ((_additionalCellProps3 = additionalCellProps) == null ? void 0 : _additionalCellProps3.colSpan) !== 1 ? (_additionalCellProps4 = additionalCellProps) == null ? void 0 : _additionalCellProps4.colSpan : null,
188
+ "rowspan": ((_additionalCellProps5 = additionalCellProps) == null ? void 0 : _additionalCellProps5.rowSpan) !== 1 ? (_additionalCellProps6 = additionalCellProps) == null ? void 0 : _additionalCellProps6.rowSpan : null
189
+ },
190
+ "style": style
191
+ }, [rowData[colData.key]]);
192
+ })]);
253
193
  }
254
194
  },
255
195
  render: function render(h) {
256
- var _this = this;
196
+ var _this4 = this;
257
197
 
258
- var showFixed = this.dataList && this.dataList.length;
259
198
  return h("div", {
260
- "class": bem(["", this.outline ? "" : "no-border"])
261
- }, [h("div", {
262
- "attrs": {
263
- "id": "normalBoxID"
264
- },
265
- "class": [bem("normal-box"), _constant.BORDER_LEFT]
266
- }, [this.resortHeadList.map(function (x, i) {
267
- return _this.genColumn(x, i);
268
- })]), h("div", {
269
- "directives": [{
270
- name: "show",
271
- value: showFixed
272
- }],
273
- "attrs": {
274
- "id": "fixedLeftBoxID"
275
- },
276
- "class": bem("fixed-left-box")
277
- }, [this.fixedColumnLeft.map(function (x, i) {
278
- return _this.genColumn(x, i, "left");
279
- })]), h("div", {
280
- "directives": [{
281
- name: "show",
282
- value: showFixed
283
- }],
284
- "attrs": {
285
- "id": "fixedRightBoxID"
286
- },
287
- "class": bem("fixed-right-box")
288
- }, [this.fixedColumnRight.map(function (x, i) {
289
- return _this.genColumn(x, i, "right");
290
- })])]);
199
+ "class": bem({
200
+ fixed: this.fixed,
201
+ bordered: this.bordered,
202
+ striped: this.striped
203
+ }),
204
+ "on": {
205
+ "scroll": this.onScroll
206
+ }
207
+ }, [h("table", [h("colgroup", [this.headList.map(function (item) {
208
+ return h("col", {
209
+ "style": {
210
+ width: item.width
211
+ }
212
+ });
213
+ })]), h("thead", {
214
+ "class": bem('thead')
215
+ }, [h("tr", [this.formatColumns.map(function (colData) {
216
+ return _this4.getHead(colData);
217
+ })])]), h("tbody", {
218
+ "class": bem('tbody')
219
+ }, [this.dataList.map(function (rowData, rowIndex) {
220
+ return _this4.getBody(rowData, rowIndex);
221
+ })])])]);
291
222
  }
292
223
  });
293
224