1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| <template>
| <div>
| <el-popover v-if="wordInfo[0]" placement="top" width="360" trigger="hover" :content="text">
| <div slot="reference">
| {{wordInfo[1] | fRecord(header)}}
| <i
| style="color: #409EFF;"
| class="el-icon-arrow-down el-icon--right"
| ></i>
| </div>
| </el-popover>
|
| <div v-else>{{wordInfo[1] | fRecord(header)}}</div>
| </div>
| </template>
| <script>
| export default {
| props: {
| text: {
| type: [String, Number],
| default: ''
| },
| header: {
| type: Object,
| default: () => ({})
| },
| columnWidth: {
| type: [String, Number],
| default: ''
| },
| propsWidth: {
| type: Object,
| default: () => ({})
| }
| },
| data() {
| return {
| isHide: true
| }
| },
| computed: {
| wordInfo() {
| const { text, header, columnWidth, propsWidth, isHide } = this
| const { label, isMoney = false, attrs = {} } = header
| const width = propsWidth[label] ? propsWidth[label] : columnWidth
| const { width: mixWidth } = {
| width,
| ...attrs
| }
| const parseWidth = parseInt(mixWidth)
| if (isHide && !isMoney && !isNaN(parseWidth)) {
| let maxWord = (parseWidth * 2) / 14 - 4
| if (/^[\w/\\/\\:;-\s]*$/g.test(text.toString())) {
| maxWord = maxWord * 2
| }
|
| if (text.toString().length > maxWord) {
| return [true, `${text.substring(0, maxWord - 1)}…`, maxWord]
| }
| }
| // 是否超出字符长度限制,处理后文本,最大字符长度
| return [false, text, 0]
| }
| }
| }
| </script>
|
|