Commit 06ee0eadafd9ebdda95925b70b7da4cfd4d827ec
1 parent
c02ed998
Exists in
master
and in
1 other branch
调整插槽开放方法绑定
Showing
1 changed file
with
18 additions
and
8 deletions
Show diff stats
packages/scheme/index.vue
| ... | ... | @@ -67,12 +67,12 @@ |
| 67 | 67 | </div> |
| 68 | 68 | <!-- 操作按钮栏 --> |
| 69 | 69 | <div v-if="option.showActionBar !== false" class="eagle-scheme__action" v-loading="tableLoading" element-loading-spinner="none" element-loading-background="rgba(255, 255, 255, 0.6)"> |
| 70 | - <slot v-if="$scopedSlots['action-bar'] || $slots['action-bar']" name="action-bar" :handleNew="handleNew" :handleDelete="handleDelete" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot> | |
| 70 | + <slot v-if="$scopedSlots['action-bar'] || $slots['action-bar']" name="action-bar" v-bind="slotMethod" :model="formModel" :selection="tableSelection"></slot> | |
| 71 | 71 | <template v-else> |
| 72 | - <slot v-if="$scopedSlots['action-btn-new'] || $slots['action-btn-new']" name="action-btn-new" :handleNew="handleNew" :handleEdit="handleEdit" :handleDelete="handleDelete" :handleView="handleView" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot> | |
| 72 | + <slot v-if="$scopedSlots['action-btn-new'] || $slots['action-btn-new']" name="action-btn-new" v-bind="slotMethod" :model="formModel" :selection="tableSelection"></slot> | |
| 73 | 73 | <el-button v-else class="eagle-scheme__action-btn" type="primary" size="small" @click="handleNew">{{ i18n('eagle.scheme.new') || '新增' }}</el-button> |
| 74 | 74 | <el-button v-if="hasSelectionSlot && option.showActionBtnDelete !== false" :disabled="tableSelection && tableSelection.length <= 0" class="eagle-scheme__action-btn" plain size="small" @click="handleDelete('more')">{{ i18n('eagle.scheme.delete') || '删除' }}</el-button> |
| 75 | - <slot v-if="$scopedSlots['action-button'] || $slots['action-button']" name="action-button" class="eagle-scheme__action-btn" :handleNew="handleNew" :handleEdit="handleEdit" :handleDelete="handleDelete" :handleView="handleView" :model="formModel" :selection="tableSelection" :setDialog="setDialog"></slot> | |
| 75 | + <slot v-if="$scopedSlots['action-button'] || $slots['action-button']" name="action-button" class="eagle-scheme__action-btn" :model="formModel" :selection="tableSelection" v-bind="slotMethod"></slot> | |
| 76 | 76 | <div v-if="hasSelectionSlot && tableSelection && tableSelection.length > 0 && option.showActionBtnDelete !== false" class="eagle-scheme__action-btn eagle-scheme__text-selection">{{ i18n('eagle.scheme.checked') || '已选中' }}<span class="eagle-scheme__text-selection-highlight">{{ tableSelection.length }}</span>{{ i18n('eagle.scheme.item') || '项' }}</div> |
| 77 | 77 | </template> |
| 78 | 78 | </div> |
| ... | ... | @@ -90,7 +90,7 @@ |
| 90 | 90 | <slot></slot> |
| 91 | 91 | <!-- 表格具名插槽 --> |
| 92 | 92 | <template v-for="item in _tableList"> |
| 93 | - <slot v-if="$scopedSlots[`table-${item.key}`] || $slots[`table-${item.key}`]" :name="`table-${item.key}`" :slot="item.key" :setDialog="setDialog"></slot> | |
| 93 | + <slot v-if="$scopedSlots[`table-${item.key}`] || $slots[`table-${item.key}`]" :name="`table-${item.key}`" :slot="item.key" v-bind="slotMethod"></slot> | |
| 94 | 94 | </template> |
| 95 | 95 | <!-- 表格后置插槽 --> |
| 96 | 96 | <template v-if="$scopedSlots['table-append'] || $slots['table-append']"> |
| ... | ... | @@ -98,21 +98,21 @@ |
| 98 | 98 | </template> |
| 99 | 99 | <!-- 表格操作栏插槽 - 自定义 --> |
| 100 | 100 | <template v-if="$scopedSlots['table-operation'] || $slots['table-operation']"> |
| 101 | - <slot name="table-operation" slot="$end" :handleView="handleView" :handleEdit="handleEdit" :handleDelete="handleDelete"></slot> | |
| 101 | + <slot name="table-operation" slot="$end" v-bind="slotMethod"></slot> | |
| 102 | 102 | </template> |
| 103 | 103 | <!-- 表格操作栏插槽 - 默认 --> |
| 104 | 104 | <el-table-column v-else slot="$end" prop="$operation" :label="i18n('eagle.scheme.operation') || '操作'" min-width="140" fixed="right"> |
| 105 | 105 | <div class="eagle-scheme__table-operation" slot-scope="slotScope"> |
| 106 | 106 | <!-- 表格操作栏插槽 - 前置插槽 --> |
| 107 | - <slot v-if="$scopedSlots['table-operation-btn'] || $slots['table-operation-btn']" name="table-operation-btn" :slotScope="slotScope" :handleNew="handleNew" :handleEdit="handleEdit" :handleDelete="handleDelete" :handleView="handleView"></slot> | |
| 107 | + <slot v-if="$scopedSlots['table-operation-btn'] || $slots['table-operation-btn']" name="table-operation-btn" :slotScope="slotScope" v-bind="slotMethod"></slot> | |
| 108 | 108 | <el-button v-if="option.showViewBtn !== false" class="eagle-scheme__table-btn" type="text" icon="el-icon-view" :title="i18n('eagle.scheme.detail') || '详情'" @click="handleView(slotScope)"></el-button> |
| 109 | - <slot v-if="$scopedSlots['table-operation-btn-edit'] || $slots['table-operation-btn-edit']" name="table-operation-btn-edit" :slotScope="slotScope" :handleNew="handleNew" :handleEdit="handleEdit" :handleDelete="handleDelete" :handleView="handleView"></slot> | |
| 109 | + <slot v-if="$scopedSlots['table-operation-btn-edit'] || $slots['table-operation-btn-edit']" name="table-operation-btn-edit" :slotScope="slotScope" v-bind="slotMethod"></slot> | |
| 110 | 110 | <el-button v-else-if="option.showEditBtn !== false" class="eagle-scheme__table-btn" type="text" icon="el-icon-edit" :title="i18n('eagle.scheme.edit') || '编辑'" @click="handleEdit(slotScope)"></el-button> |
| 111 | 111 | <eagle-confirm v-if="option.showDeleteBtn !== false" class="eagle-scheme__table-btn" :title="i18n('eagle.scheme.deleteConfirm') || '是否删除?'" @confirm="handleDelete('one', slotScope)"> |
| 112 | 112 | <el-button type="text" icon="el-icon-delete" :title="i18n('eagle.scheme.delete') || '删除'"></el-button> |
| 113 | 113 | </eagle-confirm> |
| 114 | 114 | <!-- 表格操作栏插槽 - 后置插槽 --> |
| 115 | - <slot v-if="$scopedSlots['table-operation-btn-append'] || $slots['table-operation-btn-append']" name="table-operation-btn-append" :slotScope="slotScope" :handleNew="handleNew" :handleEdit="handleEdit" :handleDelete="handleDelete" :handleView="handleView"></slot> | |
| 115 | + <slot v-if="$scopedSlots['table-operation-btn-append'] || $slots['table-operation-btn-append']" name="table-operation-btn-append" :slotScope="slotScope" v-bind="slotMethod"></slot> | |
| 116 | 116 | </div> |
| 117 | 117 | </el-table-column> |
| 118 | 118 | </eagle-table> |
| ... | ... | @@ -288,6 +288,16 @@ export default { |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | return result; |
| 291 | + }, | |
| 292 | + // 插槽开放方法 | |
| 293 | + slotMethod() { | |
| 294 | + return { | |
| 295 | + handleNew: this.handleNew, | |
| 296 | + handleView: this.handleView, | |
| 297 | + handleEdit: this.handleEdit, | |
| 298 | + handleDelete: this.handleDelete, | |
| 299 | + setDialog: this.setDialog, | |
| 300 | + } | |
| 291 | 301 | } |
| 292 | 302 | }, |
| 293 | 303 | methods: { | ... | ... |