ct-component-plus 0.0.43 → 0.0.44

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.
Files changed (96) hide show
  1. package/README.md +3 -3
  2. package/package.json +36 -36
  3. package/packages/components/button/index.js +8 -8
  4. package/packages/components/button/src/button.vue +171 -171
  5. package/packages/components/cascader/index.js +7 -7
  6. package/packages/components/cascader/src/cascader.vue +247 -247
  7. package/packages/components/cascader/src/ct-cascader.vue +260 -260
  8. package/packages/components/cascader/src/index.js +50 -50
  9. package/packages/components/checkbox/index.js +7 -7
  10. package/packages/components/checkbox/src/checkbox.vue +51 -51
  11. package/packages/components/checkbox/src/index.js +12 -12
  12. package/packages/components/date-picker/index.js +8 -8
  13. package/packages/components/date-picker/src/clear-icon.vue +2 -2
  14. package/packages/components/date-picker/src/date-icon.vue +2 -2
  15. package/packages/components/date-picker/src/date-picker.vue +77 -77
  16. package/packages/components/date-picker/src/index.js +33 -33
  17. package/packages/components/dialog/index.js +8 -8
  18. package/packages/components/dialog/src/dialog.vue +103 -103
  19. package/packages/components/empty/index.js +8 -8
  20. package/packages/components/empty/src/empty.vue +97 -97
  21. package/packages/components/index.js +81 -81
  22. package/packages/components/input/index.js +7 -7
  23. package/packages/components/input/src/index.js +13 -13
  24. package/packages/components/input/src/input.vue +106 -106
  25. package/packages/components/input-range/index.js +7 -7
  26. package/packages/components/input-range/src/index.js +29 -29
  27. package/packages/components/input-range/src/input-range.vue +233 -233
  28. package/packages/components/loading/index.js +7 -7
  29. package/packages/components/loading/src/CtLoading.vue +74 -74
  30. package/packages/components/loading/src/beating.vue +71 -71
  31. package/packages/components/loading/src/progress.vue +120 -120
  32. package/packages/components/loading/src/spinner.vue +38 -38
  33. package/packages/components/menu/index.js +7 -7
  34. package/packages/components/menu/src/item.vue +46 -46
  35. package/packages/components/menu/src/link.vue +28 -28
  36. package/packages/components/menu/src/logo.vue +25 -25
  37. package/packages/components/menu/src/menu-item.vue +103 -103
  38. package/packages/components/menu/src/menu.vue +191 -191
  39. package/packages/components/menu/src/utils/index.js +4 -4
  40. package/packages/components/message/icon/ErrorIcon.vue +25 -25
  41. package/packages/components/message/icon/InfoIcon.vue +25 -25
  42. package/packages/components/message/icon/SuccessIcon.vue +25 -25
  43. package/packages/components/message/icon/WarningIcon.vue +25 -25
  44. package/packages/components/message/index.js +8 -8
  45. package/packages/components/message/src/method.js +54 -54
  46. package/packages/components/message-box/index.js +7 -7
  47. package/packages/components/message-box/src/message-box.vue +107 -107
  48. package/packages/components/page/index.js +7 -7
  49. package/packages/components/page/src/modules/DownloadButton.vue +21 -21
  50. package/packages/components/page/src/modules/TableTitle.vue +151 -151
  51. package/packages/components/page/src/page.vue +382 -382
  52. package/packages/components/pagination/index.js +7 -7
  53. package/packages/components/pagination/src/pagination.vue +36 -36
  54. package/packages/components/radio/index.js +7 -7
  55. package/packages/components/radio/src/index.js +12 -12
  56. package/packages/components/radio/src/radio.vue +47 -47
  57. package/packages/components/search-box/index.js +24 -24
  58. package/packages/components/search-box/src/index.js +29 -29
  59. package/packages/components/search-box/src/search-box.vue +250 -250
  60. package/packages/components/search-box/src/slot.vue +4 -4
  61. package/packages/components/select/index.js +7 -7
  62. package/packages/components/select/src/arrow-down.vue +2 -2
  63. package/packages/components/select/src/clear-icon.vue +2 -2
  64. package/packages/components/select/src/empty.vue +13 -13
  65. package/packages/components/select/src/index.js +51 -51
  66. package/packages/components/select/src/select.vue +380 -380
  67. package/packages/components/table/index.js +7 -7
  68. package/packages/components/table/src/TableSort.vue +179 -179
  69. package/packages/components/table/src/index.js +78 -70
  70. package/packages/components/table/src/table.vue +288 -287
  71. package/packages/components/tabs/index.js +7 -7
  72. package/packages/components/tabs/src/tabs.vue +225 -225
  73. package/packages/components/year-select/index.js +7 -7
  74. package/packages/components/year-select/src/index.js +44 -44
  75. package/packages/components/year-select/src/year-select.vue +273 -273
  76. package/packages/constants/aria.ts +17 -17
  77. package/packages/constants/index.ts +1 -1
  78. package/packages/directives/click-outside/index.ts +118 -118
  79. package/packages/echarts/bar/index.js +63 -63
  80. package/packages/echarts/base.js +99 -99
  81. package/packages/echarts/line/index.js +106 -106
  82. package/packages/hooks/index.js +5 -5
  83. package/packages/hooks/use-buried/index.js +46 -46
  84. package/packages/hooks/use-checked-all/index.js +37 -37
  85. package/packages/hooks/use-echarts/index.js +1 -1
  86. package/packages/hooks/use-echarts/use-bar/index.js +72 -72
  87. package/packages/hooks/use-echarts/use-line/index.js +88 -88
  88. package/packages/hooks/use-namespace/index.js +65 -65
  89. package/packages/hooks/use-search-component/index.js +28 -28
  90. package/packages/style/element.less +725 -725
  91. package/packages/style/index.js +2 -2
  92. package/packages/style/init.less +114 -114
  93. package/packages/utils/index.js +1 -1
  94. package/packages/utils/operate.js +77 -77
  95. package/packages/utils/table.js +135 -0
  96. package/packages/utils/types.js +35 -35
@@ -1,3 +1,3 @@
1
- import "element-plus/dist/index.css";
2
- import './init.less';
1
+ import "element-plus/dist/index.css";
2
+ import './init.less';
3
3
  import './element.less'
@@ -1,114 +1,114 @@
1
-
2
- :root {
3
- // --命名空间-主题-具体内容-修饰,同一块内容的多个单词用_链接
4
- // 字体
5
- --ct-font-label: 12px; //标签字号
6
- --ct-font-special: 13px; //特殊应用
7
- --ct-font-size: 14px; //常用字号-小
8
- --ct-font-large: 15px; //常用字号-大
9
- --ct-font-title-s: 16px; //标题-小(small)
10
- --ct-font-title-m: 17px; //标题-中(medium)
11
- --ct-font-title-l: 18px; //标题-大(large)
12
- --ct-font-system-s: 19px; //系统标题-小
13
- --ct-font-system-l: 20px; //系统标题-大
14
- --ct-font-color: #141617; //字体默认颜色
15
-
16
- // 主色
17
- --ct-color-primary: var(--ct-color-blue); //系统默认主色,这里取的的蓝色
18
- --ct-color-blue: #4D64FF; //主色-蓝
19
- --ct-color-yellow: #FFAD2C; //主色-黄
20
- --ct-color-green: #1EB7AD; //主色-绿
21
- --ct-color-purple: #664FFF; //主色-紫
22
- --ct-color-orange: #FF9218; //主色-橙
23
- --ct-color-sky: #42A6FF; //主色-天蓝
24
- --ct-color-red: #FF643E; //主色-橘红
25
- --ct-color-grass: #88CE77; //主色-草绿
26
- --ct-color-sub-blue: #3A45FF; //辅色-蓝色
27
- --ct-color-sub-purple: #7B4CF4; //辅色-紫色
28
- // 中性色
29
- --ct-color-black: #141617; //标准黑
30
- --ct-color-grey-sub: #535C66; //辅助灰(sub)
31
- --ct-color-grey-transition: #8F99A3; //过渡灰(transition)
32
- --ct-color-grey-tip: #A4AFBB; //提示灰
33
- --ct-color-separator: #D8DEE8; //分隔线
34
- --ct-color-bg: #F0F3F9; //背景色
35
- // 状态色
36
- --ct-color-primary-border: #B1BBFF; //主色边框色
37
- --ct-color-primary-bg: #ECF1FF; //主色背景色
38
- --ct-color-success: #07C47E; //成功色
39
- --ct-color-success-border: #9BE0CA; //成功边框色
40
- --ct-color-success-bg: #F1FDF9; //成功背景色
41
- --ct-color-danger: #FF4D4D; //危险色
42
- --ct-color-danger-border: #FFA39E; //危险边框色
43
- --ct-color-danger-bg: #FFF1F0; //危险背景色
44
- --ct-color-warning: #FFAD2C; //警告色
45
- --ct-color-warning-border: #FFD28B; //警告边框色
46
- --ct-color-warning-bg: #FFFBE6; //警告背景色
47
- --ct-color-disabled: var(--ct-color-grey-tip); //禁用颜色(文字)
48
- --ct-color-placeholder: var(--ct-color-grey-tip); //placeholder颜色
49
- // 边框
50
- --ct-border-color: #A4AFBB; //边框色(默认、深色)
51
- --ct-border-color-light: #D8DEE8; //边框色(浅色)
52
- --ct-border-radius: 4px; //默认圆角
53
- --ct-border-radius-s: 2px; //小圆角
54
- --ct-border-radius-l: 6px; //大圆角
55
- // 基础布局
56
- --ct-layout-menu-width: 224px; //左侧菜单宽
57
- --ct-layout-menu-width_collapse: 68px; //收起左侧菜单宽
58
- --ct-layout-header-height: 68px; //顶部导航高
59
- --ct-layout-margin: 16px; //页面边距
60
-
61
- --ct-hover-opacity: 0.8; //hover改变透明度
62
-
63
- --ct-component-size: 32px; //数据录入类组件的size
64
- --ct-component-width: 248px;
65
- --ct-component-inner-height: calc(var(--ct-component-size) - 2px);
66
- --ct-component-inner-padding: 12px;
67
- --ct-component-border-color: var(--ct-border-color);
68
- --ct-component-border: 0 0 0 1px var(--ct-component-border-color) inset;
69
- --ct-component-border-radius: var(--ct-border-radius);
70
- --ct-component-fill-color: #ffffff;
71
- --ct-component-color: var(--ct-color-black);
72
- --ct-component-disabled-bg-color: #F6F7F9;
73
- --ct-component-hover-color: #F5F7FC;
74
- --ct-component-hover-border-color: var(--ct-color-grey-sub);
75
-
76
- --ct-popper-light-border: none;
77
- }
78
-
79
- body {
80
- margin: 0;
81
- padding: 0;
82
- color: var(--ct-font-color);
83
- font-size: var(--ct-font-size);
84
- font-family: 'Helvetica Neue','PingFang SC',Arial,'Microsoft YaHei',WenQuanYiMicroHei;
85
- font-smoothing: antialiased;
86
- -webkit-font-smoothing: antialiased;
87
-
88
- }
89
- :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
90
- color: var(--ct-color-placeholder);
91
- }
92
- ::-moz-placeholder { /* Mozilla Firefox 19+ */
93
- color: var(--ct-color-placeholder);
94
- }
95
- input {
96
- &::placeholder,
97
- &::-webkit-input-placeholder,
98
- &:-ms-input-placeholder,
99
- &::-ms-input-placeholder {
100
- color: var(--ct-color-placeholder);
101
- }
102
- }
103
- ::-webkit-scrollbar {
104
- width: 7px;
105
- height: 7px;
106
- }
107
-
108
- ::-webkit-scrollbar-thumb {
109
- border-radius: 10px;
110
- -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
111
- background: rgba(0, 0, 0, 0.45);
112
- }
113
-
114
-
1
+
2
+ :root {
3
+ // --命名空间-主题-具体内容-修饰,同一块内容的多个单词用_链接
4
+ // 字体
5
+ --ct-font-label: 12px; //标签字号
6
+ --ct-font-special: 13px; //特殊应用
7
+ --ct-font-size: 14px; //常用字号-小
8
+ --ct-font-large: 15px; //常用字号-大
9
+ --ct-font-title-s: 16px; //标题-小(small)
10
+ --ct-font-title-m: 17px; //标题-中(medium)
11
+ --ct-font-title-l: 18px; //标题-大(large)
12
+ --ct-font-system-s: 19px; //系统标题-小
13
+ --ct-font-system-l: 20px; //系统标题-大
14
+ --ct-font-color: #141617; //字体默认颜色
15
+
16
+ // 主色
17
+ --ct-color-primary: var(--ct-color-blue); //系统默认主色,这里取的的蓝色
18
+ --ct-color-blue: #4D64FF; //主色-蓝
19
+ --ct-color-yellow: #FFAD2C; //主色-黄
20
+ --ct-color-green: #1EB7AD; //主色-绿
21
+ --ct-color-purple: #664FFF; //主色-紫
22
+ --ct-color-orange: #FF9218; //主色-橙
23
+ --ct-color-sky: #42A6FF; //主色-天蓝
24
+ --ct-color-red: #FF643E; //主色-橘红
25
+ --ct-color-grass: #88CE77; //主色-草绿
26
+ --ct-color-sub-blue: #3A45FF; //辅色-蓝色
27
+ --ct-color-sub-purple: #7B4CF4; //辅色-紫色
28
+ // 中性色
29
+ --ct-color-black: #141617; //标准黑
30
+ --ct-color-grey-sub: #535C66; //辅助灰(sub)
31
+ --ct-color-grey-transition: #8F99A3; //过渡灰(transition)
32
+ --ct-color-grey-tip: #A4AFBB; //提示灰
33
+ --ct-color-separator: #D8DEE8; //分隔线
34
+ --ct-color-bg: #F0F3F9; //背景色
35
+ // 状态色
36
+ --ct-color-primary-border: #B1BBFF; //主色边框色
37
+ --ct-color-primary-bg: #ECF1FF; //主色背景色
38
+ --ct-color-success: #07C47E; //成功色
39
+ --ct-color-success-border: #9BE0CA; //成功边框色
40
+ --ct-color-success-bg: #F1FDF9; //成功背景色
41
+ --ct-color-danger: #FF4D4D; //危险色
42
+ --ct-color-danger-border: #FFA39E; //危险边框色
43
+ --ct-color-danger-bg: #FFF1F0; //危险背景色
44
+ --ct-color-warning: #FFAD2C; //警告色
45
+ --ct-color-warning-border: #FFD28B; //警告边框色
46
+ --ct-color-warning-bg: #FFFBE6; //警告背景色
47
+ --ct-color-disabled: var(--ct-color-grey-tip); //禁用颜色(文字)
48
+ --ct-color-placeholder: var(--ct-color-grey-tip); //placeholder颜色
49
+ // 边框
50
+ --ct-border-color: #A4AFBB; //边框色(默认、深色)
51
+ --ct-border-color-light: #D8DEE8; //边框色(浅色)
52
+ --ct-border-radius: 4px; //默认圆角
53
+ --ct-border-radius-s: 2px; //小圆角
54
+ --ct-border-radius-l: 6px; //大圆角
55
+ // 基础布局
56
+ --ct-layout-menu-width: 224px; //左侧菜单宽
57
+ --ct-layout-menu-width_collapse: 68px; //收起左侧菜单宽
58
+ --ct-layout-header-height: 68px; //顶部导航高
59
+ --ct-layout-margin: 16px; //页面边距
60
+
61
+ --ct-hover-opacity: 0.8; //hover改变透明度
62
+
63
+ --ct-component-size: 32px; //数据录入类组件的size
64
+ --ct-component-width: 248px;
65
+ --ct-component-inner-height: calc(var(--ct-component-size) - 2px);
66
+ --ct-component-inner-padding: 12px;
67
+ --ct-component-border-color: var(--ct-border-color);
68
+ --ct-component-border: 0 0 0 1px var(--ct-component-border-color) inset;
69
+ --ct-component-border-radius: var(--ct-border-radius);
70
+ --ct-component-fill-color: #ffffff;
71
+ --ct-component-color: var(--ct-color-black);
72
+ --ct-component-disabled-bg-color: #F6F7F9;
73
+ --ct-component-hover-color: #F5F7FC;
74
+ --ct-component-hover-border-color: var(--ct-color-grey-sub);
75
+
76
+ --ct-popper-light-border: none;
77
+ }
78
+
79
+ body {
80
+ margin: 0;
81
+ padding: 0;
82
+ color: var(--ct-font-color);
83
+ font-size: var(--ct-font-size);
84
+ font-family: 'Helvetica Neue','PingFang SC',Arial,'Microsoft YaHei',WenQuanYiMicroHei;
85
+ font-smoothing: antialiased;
86
+ -webkit-font-smoothing: antialiased;
87
+
88
+ }
89
+ :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
90
+ color: var(--ct-color-placeholder);
91
+ }
92
+ ::-moz-placeholder { /* Mozilla Firefox 19+ */
93
+ color: var(--ct-color-placeholder);
94
+ }
95
+ input {
96
+ &::placeholder,
97
+ &::-webkit-input-placeholder,
98
+ &:-ms-input-placeholder,
99
+ &::-ms-input-placeholder {
100
+ color: var(--ct-color-placeholder);
101
+ }
102
+ }
103
+ ::-webkit-scrollbar {
104
+ width: 7px;
105
+ height: 7px;
106
+ }
107
+
108
+ ::-webkit-scrollbar-thumb {
109
+ border-radius: 10px;
110
+ -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
111
+ background: rgba(0, 0, 0, 0.45);
112
+ }
113
+
114
+
@@ -1,2 +1,2 @@
1
- export * from './types'
1
+ export * from './types'
2
2
  export * from './operate'
@@ -1,78 +1,78 @@
1
- import { isString, isArray, isObject, isFunction } from './types';
2
-
3
- export const toFirstUpperCase = (str) => {
4
- if (str && isString(str)) {
5
- const res = str;
6
- return res[0].toUpperCase() + res.substring(1)
7
- } else {
8
- return str
9
- }
10
- }
11
-
12
- export function copyObj(obj) {
13
- if (obj === null || typeof obj !== 'object') {
14
- return obj;
15
- }
16
-
17
- const clone = Array.isArray(obj) ? [] : {};
18
-
19
- Object.keys(obj).forEach((key) => {
20
- if (typeof obj[key] === 'object') {
21
- clone[key] = copyObj(obj[key]);
22
- } else {
23
- clone[key] = obj[key];
24
- }
25
- });
26
-
27
- const symbols = Object.getOwnPropertySymbols(obj);
28
- symbols.forEach((symbol) => {
29
- if (typeof obj[symbol] === 'object') {
30
- clone[symbol] = copyObj(obj[symbol]);
31
- } else {
32
- clone[symbol] = obj[symbol];
33
- }
34
- });
35
-
36
- const functions = Object.getOwnPropertyNames(obj).filter(
37
- (prop) => typeof obj[prop] === 'function'
38
- );
39
- functions.forEach((func) => {
40
- clone[func] = obj[func];
41
- });
42
-
43
- return clone;
44
- }
45
-
46
- export const getOpacityColor = (color, opacity) => {
47
- const reg = /rgba\((.*)\)/;
48
- let str = color.replace(reg, (match, p1) => {
49
- let arr = p1.split(',');
50
- arr[arr.length - 1] = opacity;
51
- return `rgba(${arr.join()})`
52
- });
53
- return str;
54
- }
55
-
56
- /**
57
- * Merges two objects, giving the last one precedence(相同取后面的)
58
- * @param {Object} target
59
- * @param {(Object|Array)} source
60
- * @returns {Object}
61
- */
62
- export function objectMerge(target, source) {
63
- if (typeof target !== 'object') {
64
- target = {}
65
- }
66
- if (Array.isArray(source)) {
67
- return source.slice()
68
- }
69
- Object.keys(source).forEach(property => {
70
- const sourceProperty = source[property]
71
- if (typeof sourceProperty === 'object') {
72
- target[property] = objectMerge(target[property], sourceProperty)
73
- } else {
74
- target[property] = sourceProperty
75
- }
76
- })
77
- return target
1
+ import { isString, isArray, isObject, isFunction } from './types';
2
+
3
+ export const toFirstUpperCase = (str) => {
4
+ if (str && isString(str)) {
5
+ const res = str;
6
+ return res[0].toUpperCase() + res.substring(1)
7
+ } else {
8
+ return str
9
+ }
10
+ }
11
+
12
+ export function copyObj(obj) {
13
+ if (obj === null || typeof obj !== 'object') {
14
+ return obj;
15
+ }
16
+
17
+ const clone = Array.isArray(obj) ? [] : {};
18
+
19
+ Object.keys(obj).forEach((key) => {
20
+ if (typeof obj[key] === 'object') {
21
+ clone[key] = copyObj(obj[key]);
22
+ } else {
23
+ clone[key] = obj[key];
24
+ }
25
+ });
26
+
27
+ const symbols = Object.getOwnPropertySymbols(obj);
28
+ symbols.forEach((symbol) => {
29
+ if (typeof obj[symbol] === 'object') {
30
+ clone[symbol] = copyObj(obj[symbol]);
31
+ } else {
32
+ clone[symbol] = obj[symbol];
33
+ }
34
+ });
35
+
36
+ const functions = Object.getOwnPropertyNames(obj).filter(
37
+ (prop) => typeof obj[prop] === 'function'
38
+ );
39
+ functions.forEach((func) => {
40
+ clone[func] = obj[func];
41
+ });
42
+
43
+ return clone;
44
+ }
45
+
46
+ export const getOpacityColor = (color, opacity) => {
47
+ const reg = /rgba\((.*)\)/;
48
+ let str = color.replace(reg, (match, p1) => {
49
+ let arr = p1.split(',');
50
+ arr[arr.length - 1] = opacity;
51
+ return `rgba(${arr.join()})`
52
+ });
53
+ return str;
54
+ }
55
+
56
+ /**
57
+ * Merges two objects, giving the last one precedence(相同取后面的)
58
+ * @param {Object} target
59
+ * @param {(Object|Array)} source
60
+ * @returns {Object}
61
+ */
62
+ export function objectMerge(target, source) {
63
+ if (typeof target !== 'object') {
64
+ target = {}
65
+ }
66
+ if (Array.isArray(source)) {
67
+ return source.slice()
68
+ }
69
+ Object.keys(source).forEach(property => {
70
+ const sourceProperty = source[property]
71
+ if (typeof sourceProperty === 'object') {
72
+ target[property] = objectMerge(target[property], sourceProperty)
73
+ } else {
74
+ target[property] = sourceProperty
75
+ }
76
+ })
77
+ return target
78
78
  }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * 思路:通过简单的 el-table的 thead和tbody父级别区域,进行设置对于的fixed
3
+ * 1.复制一份 thead 设置为fixed,先隐藏掉。
4
+ * 2.创建滚动条监听事件,根据滚动条计算表格所在可视窗口位置。设置thead副本是否显示
5
+ * 3.创建横向滚动条的属性变化监听。当监听变化时,说明在拖动横向滚动条,需要将设置对应副本的表头位置,防止错位
6
+ */
7
+
8
+ function getElParentBySelector(el, queryClassSelector) {
9
+ if (!el) {
10
+ return el
11
+ }
12
+ if ([...el.classList].includes(queryClassSelector)) {
13
+ return el
14
+ }
15
+ return getElParentBySelector(el.parentNode, queryClassSelector)
16
+ }
17
+
18
+ function getTableShowWidth(thead) {
19
+ const tableBox = getElParentBySelector(thead, 'el-table')
20
+ return tableBox.getBoundingClientRect().width
21
+ }
22
+
23
+ //使用setTime来确保不会重复设置
24
+
25
+ function createTableSticky(el, binding, vNode) {
26
+ let stickyTop = binding.value.top || 0
27
+ const zIndex = binding.value.zIndex || 0
28
+ stickyTop = parseFloat(stickyTop)
29
+ // 获取表格(element)
30
+ let thead = el.querySelector('.el-table__header')
31
+ thead = getElParentBySelector(thead, 'el-table__header-wrapper')
32
+ const tbody = el.querySelector('.el-scrollbar') || el.querySelector('.el-table__body')
33
+ // const tableBox = el.querySelector('.el-table__inner-wrapper')
34
+
35
+ const elBodyBox = el.querySelector('.el-table__body-wrapper')
36
+
37
+ /**
38
+ * 插入副本元素,确保文档流不塌陷
39
+ */
40
+ const copyThead = thead.cloneNode(true)
41
+ copyThead.classList.add('el-table_header-copy')
42
+ copyThead.style.display = 'none'
43
+ copyThead.style.position = 'fixed'
44
+ copyThead.style.zIndex = zIndex || 1994
45
+ copyThead.style.top = stickyTop + 'px'
46
+ copyThead.style.backgroundColor = '#fff'
47
+ copyThead.style.borderTop = '1px solid #999999'
48
+
49
+ thead.parentNode.insertBefore(copyThead, elBodyBox)
50
+
51
+ //获取thead 的显示宽度
52
+ const headerShowWidth = getTableShowWidth(thead)
53
+
54
+ // 获取滚动元素
55
+ const scrollParent = document.querySelector(binding.value.parent || 'body')
56
+ if (!scrollParent || binding.value.disabled === true) {
57
+ return
58
+ }
59
+
60
+ scrollParent.addEventListener('scroll', function () {
61
+ const theadHeight = thead.clientHeight
62
+ // 获取thead距离顶部的距离
63
+ const theadTop = thead.getBoundingClientRect().top
64
+ // 判断是否需要回归原来位置
65
+ const originally = tbody.getBoundingClientRect().top
66
+ // 判断底部距离是否超过表头
67
+ const goBeyond = tbody.getBoundingClientRect().bottom
68
+
69
+ if (theadTop <= stickyTop) {
70
+ copyThead.style.display = 'block'
71
+ copyThead.style.width =
72
+ (tbody.offsetWidth < headerShowWidth ? tbody.offsetWidth : headerShowWidth) + 'px'
73
+ }
74
+
75
+ if (originally - theadHeight > stickyTop || goBeyond - theadHeight / 2 <= stickyTop) {
76
+ //影藏副本
77
+ copyThead.style.display = 'none'
78
+ }
79
+ })
80
+
81
+ try {
82
+ //启动底部滚动条监控,防止横向滚动条滚动,表头没有动的问题
83
+ const elThumbBut = el.querySelector(
84
+ '.el-table__body-wrapper .el-scrollbar .el-scrollbar__bar.is-horizontal .el-scrollbar__thumb'
85
+ )
86
+ if (elThumbBut) {
87
+ const observer = new MutationObserver(mutationsList => {
88
+ for (const mutation of mutationsList) {
89
+ if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
90
+ // CSS样式发生了变化
91
+ // 将 thumb 滚动条的
92
+ const transformX = elThumbBut.style.transform
93
+ if (transformX) {
94
+ copyThead.querySelector(
95
+ '.el-table__header'
96
+ ).style.marginLeft = `-${transformX.replace(/[a-zA-Z()]/g, '')}`
97
+ }
98
+ }
99
+ }
100
+ })
101
+ //开始监听横向滚动条
102
+ observer.observe(elThumbBut, { attributes: true })
103
+ }
104
+ } catch (error) { }
105
+ }
106
+
107
+ export function createSticky(vue) {
108
+ let clearTimeId = 0
109
+ // el-table表头吸顶效果
110
+ vue.directive('sticky', {
111
+ // 当被绑定的元素插入到 DOM 中时……
112
+ mounted(el, binding) {
113
+ const random = parseInt(Math.random() * 10 + '')
114
+ //TIP 延时设置,确保表格进行渲染成功!
115
+ clearTimeId = setTimeout(() => {
116
+ createTableSticky(el, binding)
117
+ // clearTimeout(clearTimeId)
118
+ }, 1000 + random)
119
+ },
120
+
121
+ update(el, binding) {
122
+ const random = parseInt(Math.random() * 10 + '')
123
+ //TIP 延时设置,确保表格进行渲染成功!
124
+ clearTimeId = setTimeout(() => {
125
+ createTableSticky(el, binding)
126
+ // clearTimeout(clearTimeId)
127
+ }, 1000 + random)
128
+ },
129
+
130
+ unmounted(el, binding) {
131
+ clearTimeId && clearTimeout(clearTimeId)
132
+ }
133
+ })
134
+ }
135
+
@@ -1,35 +1,35 @@
1
- import { isArray, isObject, isString } from '@vue/shared'
2
- export {
3
- isArray,
4
- isFunction,
5
- isObject,
6
- isString,
7
- isDate,
8
- isPromise,
9
- isSymbol,
10
- } from '@vue/shared' //这个@vue/shared是装了vue3一定会安装的
11
-
12
- export { isClient, isIOS } from '@vueuse/core'
13
-
14
-
15
- export const isUndefined = (val) => val === undefined
16
- export const isBoolean = (val) => typeof val === 'boolean'
17
- export const isNumber = (val) => typeof val === 'number'
18
-
19
- export const isEmpty = (val) =>
20
- (!val && val !== 0) ||
21
- (isArray(val) && val.length === 0) ||
22
- (isObject(val) && !Object.keys(val).length)
23
-
24
- export const isElement = (e) => {
25
- if (typeof Element === 'undefined') return false
26
- return e instanceof Element
27
- }
28
-
29
- export const isStringNumber = (val) => {
30
- if (!isString(val)) {
31
- return false
32
- }
33
- return !Number.isNaN(Number(val))
34
- }
35
-
1
+ import { isArray, isObject, isString } from '@vue/shared'
2
+ export {
3
+ isArray,
4
+ isFunction,
5
+ isObject,
6
+ isString,
7
+ isDate,
8
+ isPromise,
9
+ isSymbol,
10
+ } from '@vue/shared' //这个@vue/shared是装了vue3一定会安装的
11
+
12
+ export { isClient, isIOS } from '@vueuse/core'
13
+
14
+
15
+ export const isUndefined = (val) => val === undefined
16
+ export const isBoolean = (val) => typeof val === 'boolean'
17
+ export const isNumber = (val) => typeof val === 'number'
18
+
19
+ export const isEmpty = (val) =>
20
+ (!val && val !== 0) ||
21
+ (isArray(val) && val.length === 0) ||
22
+ (isObject(val) && !Object.keys(val).length)
23
+
24
+ export const isElement = (e) => {
25
+ if (typeof Element === 'undefined') return false
26
+ return e instanceof Element
27
+ }
28
+
29
+ export const isStringNumber = (val) => {
30
+ if (!isString(val)) {
31
+ return false
32
+ }
33
+ return !Number.isNaN(Number(val))
34
+ }
35
+