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

抚顺网站网站建设浦江县建设局网站

抚顺网站网站建设,浦江县建设局网站,英文网站建设 淮安,首饰盒东莞网站建设用过若依的都知道#xff0c;在使用el-table 时候#xff0c;实现列显隐效果是要给每个列加v-if 判断的#xff0c;这种代码过于繁琐#xff0c;于是翻看el-table包的代码#xff0c;调试后发现内部的【插入】和【删除】两个方法可以达到我们要的效果。 项目不提供源码在使用el-table 时候实现列显隐效果是要给每个列加v-if 判断的这种代码过于繁琐于是翻看el-table包的代码调试后发现内部的【插入】和【删除】两个方法可以达到我们要的效果。 项目不提供源码核心代码都贴上了 代码动刀看似有点多实则一个地方就一点块。el-table的源码若依RightToolBar本身组件不过轮子造完都是有用的。 没有rightBar的项目可以自己对应数据模拟一个交互操作的方式来实现 上图可以看到基于若依的RightBar组件去实现列显隐并且存到vuex的持久化中vuex本地存储中并且去掉了原先若依的RightBar组件弹窗方式。 项目是用tailwindcss 部分class类名自己去计算 RightBar的使用方法和修改内容 right-toolbar:showSearch.syncshowSearchqueryTablegetList:checkTableInfo.synccheckTableInfointeractionx (hiddenColumns x):componentName$options.name/templatediv classtop-right-btn :stylestyleel-rowel-tooltip classitem effectdark :contentshowSearch ? 隐藏搜索 : 显示搜索 placementtop v-ifsearchel-button sizemini circle iconel-icon-search click$emit(update:showSearch, !showSearch) //el-tooltipel-tooltip classitem effectdark content刷新 placementtopel-button sizemini circle iconel-icon-refresh click$emit(queryTable) //el-tooltipel-tooltip v-ifcheckTableInfo.length classitem effectdark content显隐列 placementbottom-startel-popover v-modelvisible placementright triggerclickel-checkbox-group v-modelcheckListel-checkbox classblock v-for(item, index) in checkTableInfo :disableditem selection || item 操作 :keyindex :labelitem //el-checkbox-groupel-divider classmy-4 /divel-button sizemini typeprimary clicksubmit确定/el-buttonel-button v-ifcomponentName sizemini clickcancel取消/el-button/divel-button classml-2.5 slotreference sizemini circle iconel-icon-menu //el-popover/el-tooltip/el-row/div /templatescript import { mapState, mapMutations } from vuexexport default {name: RightToolbar,data() {return {checkList: Array.from(this.checkTableInfo),visible: false,}},props: {showSearch: { type: Boolean, default: true },search: { type: Boolean, default: true },gutter: { type: Number, default: 10 },checkTableInfo: { type: Array, default: () [] },componentName: { type: String, default: },},mounted() {if (this.componentName this.tableColumns[this.componentName]) {this.tableColumns[this.componentName]?.length (this.checkList this.tableColumns[this.componentName])this.$emit(interaction, this.checkList)}},methods: {...mapMutations(tablecolumn, [setTableCache]),submit() {this.$emit(interaction, this.checkList)this.visible falseif (!this.componentName) returnthis.setTableCache({ key: [this.componentName], value: this.checkList })},cancel() {this.tableColumns[this.componentName]?.length (this.checkList this.tableColumns[this.componentName])},},computed: {...mapState(tablecolumn, [tableColumns]),style() {const ret {}if (this.gutter) {ret.marginRight ${this.gutter / 2}px}return ret},}, } /scriptstyle langscss scoped ::v-deep .el-transfer__button {border-radius: 50%;padding: 12px;display: block;margin-left: 0px; } ::v-deep .el-transfer__button:first-child {margin-bottom: 10px; } /style 主页面 给table传递props 属性checkTableInfo 属性即可 一定是包括column的所有列的label templatedivright-toolbar :showSearch.syncshowSearch queryTablegetList :checkTableInfo.synccheckTableInfo interaction(x) (hiddenColumns x) :componentName$options.name /el-table reftable :datatable.data v-loadingtable.loading :hiddenColumnshiddenColumns selection-change(ids) (table.ids ids)el-table-column aligncenter typeselection width55 /el-table-column aligncenter label类型 proptype /el-table-column aligncenter label名称 propname /el-table-column aligncenter label描述信息 propdesp /el-table-column aligncenter label值 propvalue /el-table-column aligncenter label默认值 propdefaultValue /el-table-column aligncenter label操作 class-namesmall-padding fixed-widthtemplate slot-scope{ row, column: col }el-button sizemini typetext iconel-icon-edit clickedit(row)修改/el-buttonel-button sizemini typetext iconel-icon-delete clickdel(row)删除/el-button/template/el-table-column/el-table/div /templatescript // import {} from export default {name: Untitled-1,data() {return {showSearch: true,table: {ids: [],table: [{type: FilePath,name: probeEnforcement,desp: 文件生成路径,value: /home/qchen/,defaultValue: 3,}],loading: false,},hiddenColumns: [],checkTableInfo: [selection, 类型, 名称, 描述信息, 值, 默认值, 操作],};},mounted() {},methods: {getList() {}edit(row) {}del(row) {}},// End }; /scriptstyle langcss scoped/style将node_modules中将table的源码找到打开里面的table.vue 将package里面的table源码导出,复制到components/ElementUI目录下即可修改代码需要在main.js中覆盖element的el-table最底下贴过一个链接有覆盖的路径 script import { cloneDeep } from lodash-es // watch 和props 里面加入下列两个属性 export default {props: {hiddenColumns: {type: Array,default: () [],},// ... 其他props},watch: {hiddenColumns: {immediate: true,handler(value) {const { states } this.store;const { columns, _columns } states;requestAnimationFrame(() {requestAnimationFrame(() {if (!this.cache_columns || !this.cache_columns.length) {this.cache_columns cloneDeep(columns);}if (!value.length) return;const show this.cache_columns.filter((x) value.includes(x.label));const hide this.cache_columns.filter((x) !value.includes(x.label) x.type ! selection);if (show.length) {const current_label _columns.map((item) item.label);const control_label show.map((item) item.label);control_label.forEach((item) {if (!current_label.includes(item)) {const column show.find((x) x.label item);this.store.commit(insertColumn, column, column.insertColumnIndex);}});}if (hide.length) {this.cache_columns.forEach((item) {hide.forEach((ite) {if (item.label ite.label) {const column _columns.find((x) x.label item.label);column this.store.commit(removeColumn, column);}});});}});});},},// ... 其他监听},// End }; /script将el-table的源码找到翻开/El-Table/store/index.js。 约30行的位置 insertColumn(states, column, index, parent) {let array states._columnsif (parent) {array parent.childrenif (!array) array parent.children []}if (typeof index ! undefined) {array.splice(index, 0, column)} else {array.push(column)}if (column.type selection) {states.selectable column.selectablestates.reserveSelection column.reserveSelection}if (!column.insertColumnIndex) { // 加入 index 标识插入时用到column.insertColumnIndex index}if (this.table.$ready) {this.updateColumns() // hack for dynamics insert columnthis.scheduleLayout()}},最后将重新注册的el-table 整个文件重新注册一下这里有操作
http://www.hkea.cn/news/14453978/

相关文章:

  • 佛山网页网站制作高柏企业管理咨询有限公司
  • 抖音平台建站工具北京网站定制建设
  • 录像网站怎么做ppt模板包含哪些内容
  • 广州网站制作开发公司设计网站可能遇到的问题
  • 国内建网站公司深圳兼职做网站
  • 做网赌需要在哪些网站投广告网站开发职业生涯规划范文
  • 美德的网站建设网站建设捌金手指花总二九
  • 有哪些做外贸的网站天津专业做网站公司
  • 青岛公司网站设计自助建站系统源码 资源网
  • 济南槐荫网站开发公司教学网站在线自测功能怎么做
  • 自己怎么开发网站百度搜国外服务器Wordpress
  • 民非企业网站建设费怎么记账php免费网站系统
  • 深圳建设银行网站首页网络营销是什么意思啊
  • 建材 东莞网站建设个人做淘宝客网站好做吗
  • 网站规划与建设 ppt大连百度推广公司
  • 网站如何做中英文效果合肥 网站建设公司哪家好
  • 焦作网站建设服务个人网站需求分析
  • 手机网站建设要多少钱广告信息发布平台
  • 移动端比较好的网站承接电商网站建设
  • 一个专门做特卖的网站网络公司推广
  • vs平台做网站上海做建材上什么网站好
  • 关于网站建设投稿做网站映射tcp
  • 设计素材网站千图网网站开发网上教学
  • 怎样做网站卖自己的产品鲜花网站建设策划方案
  • 企业网站建设 会计分录微信客户管理系统
  • 网站实施过程网络工程师可以从事什么工作
  • 承德网站制作公司html免费素材
  • 网站开发与技术分析广告发布者是指
  • 如何网站做外贸生意老域名对做网站的
  • 网站备案中是什么意思江山市建设局网站