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

【sgImportBtn】自定义组件:导入按钮(支持上下文关联导出菜单,配置下载导入Excel模板按钮命令、样式、图标路径等) - 实践

  

sgImportBtn.vue

                    {{ dropdownItems[0].label }}                                            {{ item.label              }}                                          export default {  name: "sgExportBtn",  components: {},  data() {    return {      form: {},      disabled: false,      placement_dropdown: `bottom-end`,      placement_tooltip: `top-end`,      tooltipContent: null,      dropdownItems: [        // 第一个是默认按钮点击触发        {          label: `导出`,          command: `xls`,          icon: `el-icon-download`,        },        // 后面以此是下拉框里面的按钮        {          label: `导出Excel`,          command: `xls`,          icon: `el-icon-download`,          src: `~@/../static/img/fileType/xls.svg`,        },        {          label: `导出CSV`,          command: `csv`,          icon: `el-icon-download`,          src: `~@/../static/img/fileType/document/csv.svg`,        },      ],    };  },  props: ["data"],  computed: {},  watch: {    data: {      handler(newValue, oldValue) {        //console.log('深度监听:', newValue, oldValue);        if (newValue && Object.keys(newValue).length) {          this.form = newValue;          this.$g.convertForm2ComponentParam(`disabled`, this);          this.$g.convertForm2ComponentParam(`placement_dropdown`, this);          this.$g.convertForm2ComponentParam(`placement_tooltip`, this);          this.$g.convertForm2ComponentParam(`tooltipContent`, this);          this.$g.convertForm2ComponentParam(`dropdownItems`, this);        }      },      deep: true, //深度监听      immediate: true, //立即执行    },  },  created() {},  mounted() {},  methods: {    getShow({ item, index, _this = this } = {}) {      return typeof item.show === "function"        ? item.show({ item, index, _this })        : item.show;    },    getHide({ item, index, _this = this } = {}) {      return typeof item.hide === "function"        ? item.hide({ item, index, _this })        : item.hide;    },    getBtnShow({ item, index, _this = this } = {}) {      if (item.hasOwnProperty("show")) return this.getShow({ item, index, _this });      if (item.hasOwnProperty("hide")) return !this.getHide({ item, index, _this });      return true;    },     exportData(d) {      this.$emit(`exportData`, d);    },    command(d) {      let item = this.dropdownItems.find((v) => v.command == d);      let data = { ...item, fileType: item.command };      item.clickEvent ? item.clickEvent(data) : this.exportData(data);    },  },  beforeDestroy() {},};.sgExportBtn {  display: inline-block;}.export-dropdown-menu {  .export-item-btn {    img {      width: 16px;      height: 16px;      object-position: center;      object-fit: contain;      transform: translateY(2px);      margin-left: 2px;    }  }}

demo

  ...   importData({ command } = {}) {  switch (command) {    case `import`:      this.uploadBtn.click();      break;    case `downloadImportTemplate`:      console.log(`触发下载导入模板Excel文件`);      break;    default:  }},

导出按钮组件【sgExportBtn】自定义组件:导出按钮(支持上下文关联导出菜单,配置导出按钮命令、样式、图标路径等)-CSDN博客文章浏览阅读169次。【代码】【sgExportBtn】自定义组件:导出按钮(支持上下文关联导出菜单,配置导出按钮命令、样式、图标路径等) https://blog.csdn.net/qq_37860634/article/details/147271278

http://www.jsqmd.com/news/10216/

相关文章:

  • WPS word 已有多级列表序号 - 指南
  • 数据增强操作
  • HTML5实现简洁的端午节节日网站源码 - 实践
  • Visio的图片,粘到word中显示不全,右边和下面显示不出来
  • 25国庆总结
  • 详细介绍:Spring 统一异常处理怎么做?
  • 某平台增强排序脚本
  • 印度乡村AI计划:用JAN AI打造人工智能优先村庄
  • 兼论spatial和simulink,PTX及其他
  • # Java方法学习:动手动脑与课后实验整理
  • CF2155D Batteries
  • JAVA语法基础》动手动脑与实验问题全整理
  • 崩铁壁纸
  • PotPlayer 播放器
  • 10.8动手动孬
  • [迷宫寻路 Round 3] 七连击
  • 网课一
  • 规模化网站SSL证书终极方案
  • 极智项目 | 基于PyQT+Whisper实现的语音识别软件设计 - 指南
  • 详细介绍:saveOrUpdate 有个缺点,不会把值赋值为null,解决办法
  • 【OpenGL ES】光栅化插值原理和射线拾取原理
  • HTML 速查列表 - 教程
  • Exp1
  • 20_uv_wsl_installation
  • 学习问题日记-4
  • Codeforces Round 1042 (CF2131) 补题笔记(A-E)
  • 在AI技术唾手可得的时代,挖掘新需求成为核心竞争力——某知名AI编程助手框架需求探索
  • 表格数据自动机器学习技术解析
  • 10/8
  • 2025.10.8