|
|
@@ -23,11 +23,27 @@
|
|
23
|
23
|
label="身份名称"
|
|
24
|
24
|
min-width="150"
|
|
25
|
25
|
/>
|
|
26
|
|
- <el-table-column
|
|
27
|
|
- prop="rule_name"
|
|
28
|
|
- label="权限名称"
|
|
29
|
|
- min-width="250"
|
|
30
|
|
- />
|
|
|
26
|
+<!-- <el-table-column-->
|
|
|
27
|
+<!-- prop="rule_name"-->
|
|
|
28
|
+<!-- label="权限名称"-->
|
|
|
29
|
+<!-- min-width="250"-->
|
|
|
30
|
+<!-- />-->
|
|
|
31
|
+ <el-table-column prop="rule_name" label="权限名称" min-width="250">
|
|
|
32
|
+ <template v-slot="{ row }">
|
|
|
33
|
+ <div v-if="row.isExpanded">
|
|
|
34
|
+ {{ row.rule_name }}
|
|
|
35
|
+ <el-button
|
|
|
36
|
+ type="text"
|
|
|
37
|
+ size="small"
|
|
|
38
|
+ @click="row.isExpanded = false"
|
|
|
39
|
+ >收起</el-button>
|
|
|
40
|
+ </div>
|
|
|
41
|
+ <div v-else>
|
|
|
42
|
+ {{ getTruncatedText(row.rule_name, 40) }}
|
|
|
43
|
+ <el-button type="text" size="small" @click="row.isExpanded = true" v-if="row.rule_name && row.rule_name.length > 40" >展开</el-button>
|
|
|
44
|
+ </div>
|
|
|
45
|
+ </template>
|
|
|
46
|
+ </el-table-column>
|
|
31
|
47
|
<el-table-column
|
|
32
|
48
|
prop="status"
|
|
33
|
49
|
label="是否显示"
|
|
|
@@ -107,19 +123,26 @@ export default {
|
|
107
|
123
|
this.getList()
|
|
108
|
124
|
},
|
|
109
|
125
|
methods: {
|
|
|
126
|
+ // 新增的文本截断方法
|
|
|
127
|
+ getTruncatedText(text, limit = 40) { // 默认截断长度可调整
|
|
|
128
|
+ if (!text) return '';
|
|
|
129
|
+ if (text.length <= limit) {
|
|
|
130
|
+ return text;
|
|
|
131
|
+ }
|
|
|
132
|
+ return text.slice(0, limit) + '...';
|
|
|
133
|
+ },
|
|
|
134
|
+
|
|
110
|
135
|
// 列表
|
|
111
|
136
|
getList() {
|
|
112
|
137
|
this.listLoading = true
|
|
113
|
138
|
menuRoleApi(this.tableFrom).then(res => {
|
|
114
|
139
|
this.tableData.data = res.data.list.map(item => {
|
|
115
|
|
- // 判断 rule_name 是否超过 20 个字符
|
|
116
|
|
- if (item.rule_name && item.rule_name.length > 20) {
|
|
117
|
|
- // 超过 20 个字符,则截取前 20 个字符并加上省略号
|
|
118
|
|
- item.rule_name = item.rule_name.slice(0, 20) + '...';
|
|
119
|
|
- }
|
|
|
140
|
+ // 为每项数据添加一个控制展开/收起状态的属性
|
|
|
141
|
+ item.isExpanded = false;
|
|
|
142
|
+ // 确保 rule_name 是字符串
|
|
|
143
|
+ item.rule_name = item.rule_name || '';
|
|
120
|
144
|
return item;
|
|
121
|
145
|
});
|
|
122
|
|
-
|
|
123
|
146
|
this.tableData.total = res.data.count
|
|
124
|
147
|
this.listLoading = false
|
|
125
|
148
|
}).catch(res => {
|