Commit 152f14b3699c004eab155e4e015f472b75ef3939
1 parent
d0e13360
Exists in
master
and in
2 other branches
fix: 修复SchemaSelect插槽
Showing
1 changed file
with
20 additions
and
0 deletions
Show diff stats
packages/schema-select/index.vue
| ... | ... | @@ -48,12 +48,18 @@ |
| 48 | 48 | <cell-highlight v-if="highlight" :value="value" :keyword="query" :key="index"></cell-highlight> |
| 49 | 49 | <template v-else>{{ value }}</template> |
| 50 | 50 | </template> |
| 51 | + <template v-for="item in getSlotKeys('table-')" #[item.name]="slotScope"> | |
| 52 | + <slot :name="item.slot" v-bind="slotScope"></slot> | |
| 53 | + </template> | |
| 51 | 54 | </z-schema-page> |
| 52 | 55 | <z-schema-table v-else ref="table" :value="options" :schema="selectTableSchema" :size="selectSize"> |
| 53 | 56 | <template v-for="(item, index) in tableColumns" #[`cell-${item.prop}`]="{ value }"> |
| 54 | 57 | <cell-highlight v-if="highlight" :value="value" :keyword="query" :key="index"></cell-highlight> |
| 55 | 58 | <template v-else>{{ value }}</template> |
| 56 | 59 | </template> |
| 60 | + <template v-for="item in getSlotKeys('table-', true)" #[item.name]="slotScope"> | |
| 61 | + <slot :name="item.slot" v-bind="slotScope"></slot> | |
| 62 | + </template> | |
| 57 | 63 | </z-schema-table> |
| 58 | 64 | </div> |
| 59 | 65 | </el-popover> |
| ... | ... | @@ -224,6 +230,9 @@ export default { |
| 224 | 230 | } |
| 225 | 231 | return true; |
| 226 | 232 | }, |
| 233 | + slotKeys() { | |
| 234 | + return Object.keys(this.$scopedSlots); | |
| 235 | + }, | |
| 227 | 236 | }, |
| 228 | 237 | watch: { |
| 229 | 238 | value(val) { |
| ... | ... | @@ -234,6 +243,17 @@ export default { |
| 234 | 243 | }, |
| 235 | 244 | }, |
| 236 | 245 | methods: { |
| 246 | + getSlotKeys(prefix, fixed) { | |
| 247 | + return this.slotKeys.reduce((result, current) => { | |
| 248 | + if (current.indexOf(prefix) === 0) { | |
| 249 | + result.push({ | |
| 250 | + slot: current, | |
| 251 | + name: fixed ? current.substring(prefix.length) : current, | |
| 252 | + }); | |
| 253 | + } | |
| 254 | + return result; | |
| 255 | + }, []); | |
| 256 | + }, | |
| 237 | 257 | // 手动设置当前value对应的label |
| 238 | 258 | setLabel(val) { |
| 239 | 259 | this.currentLabel = val; | ... | ... |