当前位置: 首页 > news >正文

【sgMoreMenu】自定义组件:“更多操作⌵”上下文关联按钮)下拉菜单。可用于表格操作列显示不下折叠的更多操作下拉框。

sgMoreMenu

<template><!-- 更多操作 --><el-dropdown:class="$options.name"style="margin-left: 10px":show-timeout="0":split-button="false":placement="`bottom-end`"@command="(command) => {//dropdownActive = command;let index = dropdownItems.findIndex((v) => v.label == command);let item = dropdownItems[index];item.clickEvent && item.clickEvent({ item, index, scope: scope });}"><!-- @click="clickMore" 更多 --><span style="cursor: default">更多<i class="el-icon-arrow-down" /></span><!-- <el-button type="text" icon="el-icon-more" title="更多" /> --><el-dropdown-menuslot="dropdown"style="transition: none; overflow-y: auto; max-height: 400px; margin-top: 5px"><el-dropdown-itemv-for="(d, i) in dropdownItems"v-if="$g.item.show({ item: d, index: i, scope: scope })":key="i":active="d.label == dropdownActive":command="d.label":disabled="d.label == dropdownActive ||$g.item.disabled({ item: d, index: i, scope: scope })":divided="d.divided":type="d.type"><i :class="d.icon" v-if="d.icon" />{{ d.label }}</el-dropdown-item></el-dropdown-menu></el-dropdown>
</template>
<script>
export default {name: `sgMoreMenu`,data() {return {scope: {},dropdownActive: ``,dropdownItems: [/* {hide: true,label: `编辑`,clickEvent: ({ item, index, scope }) => {this.edit(scope.row);},},{disabled: true,label: `重命名`,icon: `el-icon-edit`,clickEvent: ({ item, index, scope }) => {this.edit_rename(scope.row);},},{show: ({ item, index, scope }) => scope.row.show,label: `分享`,icon: `el-icon-share`,clickEvent: ({ item, index, scope }) => {this.share(scope.row);},},{label: `下载`,type: `success`,icon: `el-icon-download`,clickEvent: ({ item, index, scope }) => {this.download(scope.row);},},{divided: true,label: `删除`,icon: `el-icon-delete`,type: `danger`,clickEvent: ({ item, index, scope }) => {this.del([scope.row]);},}, */],};},props: ["value", "data"],watch: {data: {handler(newValue, oldValue) {// console.log(`深度监听${this.$options.name}:`, newValue, oldValue);if (Object.keys(newValue || {}).length) {this.form = newValue; //JSON.parse(JSON.stringify(newValue));this.$g.convertForm2ComponentParam(`disabled`, this);this.$g.convertForm2ComponentParam(`dropdownItems`, this);this.$g.convertForm2ComponentParam(`dropdownActive`, this);this.$g.convertForm2ComponentParam(`scope`, this);}},deep: true, //深度监听immediate: true, //立即执行},},
};
</script>

demo

<template><div :class="$options.name"><el-table :data="tableData"><el-table-column type="index" label="序号" width="60" /><!-- 主要列 BEGIN---------------------------------------- --><el-table-column label="姓名"><template slot-scope="scope"><span>{{ scope.row.name }}</span></template></el-table-column><!-- 主要列 END---------------------------------------- --><el-table-column label="操作"><template slot-scope="scope"><el-buttonsize="mini"type="primary"@click.stop="edit(scope.row)"@dblclick.native.stop>修改</el-button><el-buttonsize="mini"type="danger"@click.stop="del(scope.row)"@dblclick.native.stop>删除</el-button><!-- 更多操作 --><sgMoreMenu:data="{scope,dropdownItems: [{hide: true,label: `编辑`,clickEvent: ({ item, index, scope }) => {this.edit(scope.row);},},{hide: ({ item, index, scope }) => scope.row.hide,disabled: true,label: `重命名`,icon: `el-icon-edit`,clickEvent: ({ item, index, scope }) => {this.edit_rename(scope.row);},},{show: ({ item, index, scope }) => scope.row.show,label: `分享`,icon: `el-icon-share`,clickEvent: ({ item, index, scope }) => {this.share(scope.row);},},{label: `下载`,type: `success`,icon: `el-icon-download`,clickEvent: ({ item, index, scope }) => {this.download(scope.row);},},{divided: true,label: `删除`,icon: `el-icon-delete`,type: `danger`,clickEvent: ({ item, index, scope }) => {this.del([scope.row]);},},],}"/></template></el-table-column></el-table></div>
</template>
<script>
import sgMoreMenu from "@/vue/components/admin/sgMoreMenu";
export default {name: "moreDropdown",components: { sgMoreMenu },data() {return {tableData: [{ name: "姓名1" },{ name: "姓名2", hide: true },{ name: "姓名3", show: true },{ name: "姓名4" },{ name: "姓名5" },],};},
};
</script>

 在此方法基础上扩展:

el-dropdown自定义“更多操作⌵”上下文关联按钮)下拉菜单-CSDN博客文章浏览阅读520次。【代码】基于element UI el-dropdown打造表格操作列的“更多⌵”上下文关联菜单。_dropdown 更多操作 样式。基于element UI el-dropdown打造表格操作列的“更多⌵”上下文关联菜单_dropdown 更多操作 样式-CSDN博客。 https://blog.csdn.net/qq_37860634/article/details/148902297基于element UI el-dropdown打造表格操作列的“更多⌵”上下文关联菜单_dropdown 更多操作 样式-CSDN博客文章浏览阅读520次。【代码】基于element UI el-dropdown打造表格操作列的“更多⌵”上下文关联菜单。_dropdown 更多操作 样式 https://blog.csdn.net/qq_37860634/article/details/145044081

相关文章:

  • 申请个人手机网站空间长春网站优化平台
  • 一个网站如何做推广方案设计长沙网站seo收费
  • 你注册过哪些网站sem论坛
  • 个人网站介绍百度站长统计工具
  • 网络公司项目宁波seo网络推广渠道介绍
  • 上海做网站设计企业网络规划设计方案
  • WeakAuras Lua Script [ICC BOSS 12 - The Lich King]
  • Transformer中核心机制的讲解:位置编码,注意力机制优化!
  • 【Python报错】成功解决error: subprocess-exited-with-error:安装lxml模块不再报错
  • 中宇厨卫启动年中品质回馈活动,深化用户体验
  • 京东正式开源 Taro on HarmonyOS C-API 版本,为鸿蒙应用跨端开发提供高性能框架
  • 阿里云Web应用防火墙3.0使用CNAME接入传统负载均衡CLB
  • 阿里云Redhat系Linux修改ssh默认端口
  • 网络安全就业方向与现实发展分析:机遇、挑战与未来趋势
  • 微信小程序 / UNIAPP --- 阻止小程序返回(顶部导航栏返回、左 / 右滑手势、安卓物理返回键和调用 navigateBack 接口)
  • Android14音频子系统 - 系统框架概述
  • 前端路由的基石:深度剖析 Hash 与 History 模式的本质差异与实战抉择
  • Spring:多数据源配置多个事务管理器DEMO
  • 【SpringBoot】⭐️AutoConfiguration配置的前世今生
  • c语言中的浮点类型
  • 细谈QT信号与槽机制
  • spring中的@Cacheable缓存
  • php后台增加权限控制
  • Odoo API 集成:XML-RPC 与 JSON-RPC 的比较
  • RabbitMq中启用NIO
  • 操作系统学习笔记 | 第一章 计算机系统概述