ocpview-pro 0.1.3 → 0.1.5
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/index.js +98 -62
- package/dist/ocpviewplus.min.js +13 -13
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/label/showtext.vue +152 -85
package/package.json
CHANGED
|
@@ -1,95 +1,162 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
</
|
|
9
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="showTooltip ? 'Tooltip' : 'div'"
|
|
4
|
+
v-bind="showTooltip ? { transfer: true, content: labeltext, maxWidth: maxWidth, disabled: tooltipDisabled } : {}"
|
|
5
|
+
class="ivu-table-cell-tooltip"
|
|
6
|
+
>
|
|
7
|
+
<template v-if="showTooltip" #content>
|
|
8
|
+
<span class="showtext-tooltip-content">{{ labeltext }}</span>
|
|
9
|
+
</template>
|
|
10
|
+
<span
|
|
11
|
+
ref="content"
|
|
12
|
+
class="ivu-table-cell-tooltip-content"
|
|
13
|
+
:class="{ 'showtext-link': textLink }"
|
|
14
|
+
v-html="displayText"
|
|
15
|
+
:style="{ textAlign: contentAlign, width: '100%' }"
|
|
16
|
+
v-on="hasOverflow ? { mouseenter: handleTooltipIn, mouseleave: handleTooltipOut } : {}"
|
|
17
|
+
@click.prevent="textLink && linkTo()"
|
|
18
|
+
/>
|
|
19
|
+
</component>
|
|
10
20
|
</template>
|
|
11
21
|
<script>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
export default {
|
|
23
|
+
name: "showText",
|
|
24
|
+
data() {
|
|
25
|
+
return {
|
|
26
|
+
showTooltip: false,
|
|
27
|
+
tooltipDisabled: true,
|
|
28
|
+
tooltipTimer: null,
|
|
29
|
+
hasOverflow: false,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
props: {
|
|
33
|
+
label: {
|
|
34
|
+
type: [String, Number],
|
|
35
|
+
default: "",
|
|
22
36
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
maxWidth: {
|
|
38
|
+
type: [String, Number],
|
|
39
|
+
default: 300,
|
|
40
|
+
},
|
|
41
|
+
contentAlign: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: "center",
|
|
44
|
+
},
|
|
45
|
+
resetText: {
|
|
46
|
+
type: Function,
|
|
47
|
+
default: null,
|
|
48
|
+
},
|
|
49
|
+
config: {
|
|
50
|
+
type: Object,
|
|
51
|
+
default: () => ({}),
|
|
52
|
+
},
|
|
53
|
+
rowIndex: {
|
|
54
|
+
type: [String, Number],
|
|
55
|
+
default: "",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
computed: {
|
|
59
|
+
labeltext() {
|
|
60
|
+
return this.label;
|
|
61
|
+
},
|
|
62
|
+
textLink() {
|
|
63
|
+
return !!(this.config && this.config.textLink);
|
|
64
|
+
},
|
|
65
|
+
displayText() {
|
|
66
|
+
if (this.resetText) {
|
|
67
|
+
return this.resetText(
|
|
68
|
+
this.doSpecialSymbols(this.label),
|
|
69
|
+
this.label
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return this.doSpecialSymbols(this.label);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
mounted() {
|
|
76
|
+
this.$nextTick(() => {
|
|
77
|
+
this.checkOverflow();
|
|
78
|
+
this.setupResizeObserver();
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
beforeUnmount() {
|
|
82
|
+
if (this.tooltipTimer) {
|
|
83
|
+
clearTimeout(this.tooltipTimer);
|
|
84
|
+
this.tooltipTimer = null;
|
|
85
|
+
}
|
|
86
|
+
if (this.resizeObserver) {
|
|
87
|
+
this.resizeObserver.disconnect();
|
|
88
|
+
this.resizeObserver = null;
|
|
89
|
+
}
|
|
90
|
+
if (this.checkOverflowDebounced) {
|
|
91
|
+
this.checkOverflowDebounced.cancel();
|
|
92
|
+
this.checkOverflowDebounced = null;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
methods: {
|
|
96
|
+
checkOverflow() {
|
|
97
|
+
const content = this.$refs.content;
|
|
98
|
+
this.hasOverflow = !!(
|
|
99
|
+
content && content.scrollWidth > content.offsetWidth
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
setupResizeObserver() {
|
|
103
|
+
const content = this.$refs.content;
|
|
104
|
+
if (!content || !window.ResizeObserver) return;
|
|
105
|
+
this.checkOverflowDebounced = this.$utils.debounce(
|
|
106
|
+
this.checkOverflow, 150
|
|
107
|
+
);
|
|
108
|
+
this.resizeObserver = new ResizeObserver(
|
|
109
|
+
this.checkOverflowDebounced
|
|
110
|
+
);
|
|
111
|
+
this.resizeObserver.observe(content.parentElement);
|
|
112
|
+
},
|
|
113
|
+
handleTooltipIn() {
|
|
114
|
+
if (this.tooltipTimer) {
|
|
115
|
+
clearTimeout(this.tooltipTimer);
|
|
116
|
+
this.tooltipTimer = null;
|
|
47
117
|
}
|
|
118
|
+
this.showTooltip = true;
|
|
119
|
+
this.tooltipTimer = setTimeout(() => {
|
|
120
|
+
this.tooltipDisabled = false;
|
|
121
|
+
this.tooltipTimer = null;
|
|
122
|
+
}, 300);
|
|
48
123
|
},
|
|
49
|
-
|
|
50
|
-
if (this.
|
|
51
|
-
this.
|
|
124
|
+
handleTooltipOut() {
|
|
125
|
+
if (this.tooltipTimer) {
|
|
126
|
+
clearTimeout(this.tooltipTimer);
|
|
127
|
+
this.tooltipTimer = null;
|
|
52
128
|
}
|
|
129
|
+
this.tooltipDisabled = true;
|
|
130
|
+
this.tooltipTimer = setTimeout(() => {
|
|
131
|
+
this.showTooltip = false;
|
|
132
|
+
this.tooltipTimer = null;
|
|
133
|
+
}, 300);
|
|
53
134
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.showTooltip = false;
|
|
61
|
-
},
|
|
62
|
-
doSpecialSymbols(str) {
|
|
63
|
-
if (str) {
|
|
64
|
-
str = str + '';
|
|
65
|
-
//替换所有的换行符
|
|
66
|
-
str = str.replace(/\r\n/g,'<br>');
|
|
67
|
-
str = str.replace(/\n/g,'<br>');
|
|
68
|
-
//替换所有的空格(中文空格、英文空格都会被替换)
|
|
69
|
-
str = str.replace(/\s/g,' ');
|
|
70
|
-
}
|
|
71
|
-
return str;
|
|
72
|
-
},
|
|
73
|
-
linkTo() {
|
|
74
|
-
if (this.config.onLinkTo) {
|
|
75
|
-
let obj = this.$Method.copy(this.config);
|
|
76
|
-
obj.rowIndex = this.rowIndex;
|
|
77
|
-
this.config.onLinkTo(obj);
|
|
78
|
-
}
|
|
135
|
+
doSpecialSymbols(str) {
|
|
136
|
+
if (str) {
|
|
137
|
+
str = str + "";
|
|
138
|
+
str = str.replace(/\r\n/g, "<br>");
|
|
139
|
+
str = str.replace(/\n/g, "<br>");
|
|
140
|
+
str = str.replace(/\s/g, " ");
|
|
79
141
|
}
|
|
142
|
+
return str;
|
|
80
143
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.showText = this.resetText(this.doSpecialSymbols(data),data);
|
|
87
|
-
} else {
|
|
88
|
-
this.showText = this.doSpecialSymbols(data);
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
immediate: true
|
|
144
|
+
linkTo() {
|
|
145
|
+
if (this.config && this.config.onLinkTo) {
|
|
146
|
+
let obj = this.$Method.copy(this.config);
|
|
147
|
+
obj.rowIndex = this.rowIndex;
|
|
148
|
+
this.config.onLinkTo(obj);
|
|
92
149
|
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
</script>
|
|
154
|
+
<style scoped>
|
|
155
|
+
.showtext-tooltip-content {
|
|
156
|
+
white-space: pre-wrap;
|
|
157
|
+
}
|
|
158
|
+
.showtext-link {
|
|
159
|
+
text-decoration: underline;
|
|
160
|
+
cursor: pointer;
|
|
161
|
+
}
|
|
162
|
+
</style>
|