在avue基础上修改的源码,点击进入git地址

一、crud 组件,想搜索显示顺序、表单显示顺序、和表格列表显示顺序互不影响

源码分析:
form/index.vue 文件

修改代码:

使用:

二、缓存表格列表配置

源码分析:avue\packages\core\common\init.js
需要页面自己去监听defaults的变化,我们业务基本所有页面都需要缓存,所有为了避免代码的重复性,重新进行的封装


修改代码


使用:

三、avue 中未导出hearderSearch、dialogForm,table的单独组件

实践的三种方式:
1、直接复制组件进行修改(参考集抄平台)
2、直接导出组件,但是报错(因为单组件中注入了值“”curd)
3、直接通过v-if控制显示
修改代码
文件:curd/index.vue
使用方法:


四、单独使用avue中的dialog(里面封装了拖动、全屏功能),添加插槽功能

1、分析源码 dialog-form

源代码中dialog-form 没有插槽功能,在修改代码中添加插槽功能

2、修改源码,添加插槽

3、使用

五、修改dialog 样式,设置max-height,并添加内容滚动条

修改样式源码

六、avue解决日期范围选择框不联动

1、修改源码 packages/core/components/form/index

2、使用

七、avue 通过配置方法,快速修改单元格的展示内容 (拼接字符串,字符串转标签)

1、修改代码 文件packages/element-ui/crud/column.vue

2、使用方法

八、avue 提交表单是否显示loading

1、修改源码(1、监听allDisabled 的变化)


2、使用方法(可通过配置提交表单时是否显示loading)

九、修改搜索组件样式(搜索按钮固定、一行固定3列)

1、修改源码 (参照git提交代码 )1、packages\element-ui\crud\header-search.vue;2、packages\element-ui\form\vue

2、使用方法

十、elementUI table 实现表格的多列排序

1、效果图

2、主要实现代码

2.1、el-table组件

  :default-sort="getDefaultSortParams" //设置排序默认值:header-cell-class-name="headerCellClassNameFun" //设置头部样式方法@sort-change="sortChange" //排序事件

2.2、data

 sortParams: {},//记录排序参数isFirstTableSort: true,//是否首次排序

2.3、props

 //是否多列排序isMultiOrder: {type: Boolean,default: false,},headerCellClassName: Function,//头部样式方法tableOption.defaultSort:Onject,//默认排序

2.4、处理默认排序computed

 getDefaultSortParams() {let sortParams = {};if (this.isFirstTableSort) {sortParams = this.vaildData(this.tableOption.defaultSort, {prop: "createTime",order: "descending",});let name = sortParams.prop;this.sortParams = {[name]: sortParams.order,};this.formateOrderData(this.sortParams, false);this.isFirstTableSort = false;}return sortParams;},

2.5、headerCellClassNameFun 方法

 headerCellClassNameFun({ column, rowIndex }) {//处理默认值的情况if (this.isMultiOrder) {if (!this.validatenull(column.order) &&this.validatenull(column.multiOrder)) {column.multiOrder = column.order;} else {column.order = column.multiOrder;}}if (typeof this.headerCellClassName == "function") {return this.headerCellClassName({ column, rowIndex });}},

2.6、驼峰转下划线方法

 camecaseToLine(name) {return name.replace(/([A-Z])/g, "_$1").toLowerCase();},

2.7、排序回调

   sortChange({ column, prop, order }) {if (this.isMultiOrder) {column.multiOrder = order;} else {//清空缓存的数据this.sortParams = {};}this.sortParams[prop] = order;//格式化数据this.formateOrderData(this.sortParams, true);},

2.8、格式化数据

 formateOrderData(sortParams, isAutoRequest) {let val = {descending: [],ascending: [],};for (let key in sortParams) {let order = sortParams[key];if (!this.validatenull(order)) {let name = this.camecaseToLine(key);val[order].push(name);}}let newValue = {};if (val.descending.length != 0) {newValue.descs = val.descending.join(",");}if (val.ascending.length != 0) {newValue.ascs = val.ascending.join(",");}this.$emit("sort-change", newValue, isAutoRequest);},

2.9 监听隐藏以及排序对排序参数的处理

 columnInit() {this.propOption.forEach((column) => {if (this.defaultBind[column.prop] === true) return;this.defaultColumn.forEach((ele) => {//   if (["hide", "filters", "order"].includes(ele.prop)) {//     this.$watch(`objectOption.${column.prop}.${ele.prop}`, () =>//       this.refreshTable()//     );//   }function updateSortParams(column, type) {//如果地段是默认排序字段,则按原来的字段排序//1、隐藏了并且没有取消排序let order = "";//判断是否取消排序//if( this.validatenull(this.$refs.table)) return;let isSort = this.objectOption[column.prop].sortable;if (type == "hide" && isSort) {let sortParams = this.getDefaultSort;let name = sortParams.prop;if (name == column.prop) {//设置值this.sortParams = {[name]: sortParams.order,};order = sortParams.order;} else {if (!this.validatenull(this.sortParams[column.prop])) {delete this.sortParams[column.prop];}}} else {//处理sortParams中的值if (!this.validatenull(this.sortParams[column.prop])) {delete this.sortParams[column.prop];}}this.formateOrderData(this.sortParams, false);//处理样式let columns = this.$refs.table.columns.filter((item) => {return item.property == column.prop;});if (columns.length > 0) {columns[0].multiOrder = order;columns[0].order = order;}}if (["hide", "filters", "order", "sortable"].includes(ele.prop)) {this.$watch(`objectOption.${column.prop}.${ele.prop}`,(newVal, oldVal) => {if (ele.prop != "sortable") {if (ele.prop == "hide") {if (typeof oldVal == "undefined") return;updateSortParams.call(this, column, "hide");}this.refreshTable();} else {if (typeof oldVal == "undefined") return;updateSortParams.call(this, column, "sortable");}});}});this.defaultBind[column.prop] = true;});},

2.10 处理默认排序的显示按钮问题

3、使用方法

//排序事件sortChange(val, isAutoRequest) {sortDefault = val;if (isAutoRequest) this.onLoad();},
//请求列表事件onLoad(params) {let values = {...params,...this.query,...sortDefault};console.log("values", values);}
 <avue-crud:data="list":option="option":is-multi-order="true":header-cell-class-name="headerCellClassName"@search-change="searchChange"@sort-change="sortChange"@sortable-change="sortableChange"@on-load="onLoad"></avue-crud>
 option: {name: "sortable",defaultSort: { prop: "name", order: "descending" },...}

十一、上传文件自定义提交请求处理

1、修改源码

//是否自己请求,为false,按原来的方法。true,按业务方法isSelfHttp: {type: Boolean,default: true},
//主要处理回显数据if(this.isSelfHttp) {let freader = new FileReader();freader.readAsDataURL(uploadfile);freader.onload =(e)=> {this.res = {name:uploadfile.name,url:e.target.result}if (typeof this.uploadAfter === "function")this.uploadAfter(uploadfile,this.show,() => {this.loading = false;},this.column);else this.show(uploadfile);};}

2.1、使用方法(dataType:‘array’)

  {label: '数组图片组',prop: 'img',dataType: 'array',type: 'upload',accept:["image/*"],//接收文件类型// listType: 'picture-img',//一张图片// limit:2,//最大允许上传个数fileSize:100, //1KB k为单位bpropsHttp: {res: 'data',},span: 24,listType: 'picture-card',//多张图片tip: '只能上传jpg/png文件,且不超过500kb',},uploadDelete(file, column) {let uid = file.uid;this.form.file.splice(parseInt(uid),1) },uploadAfter(res, done, loading, column) {done()this.form.file.push(res);    },

3、注意事项;
3.1、提交的数据格式为formate
3.2、回显数据时,直接赋值img为图片服务器地址;并赋值this.form.file = this.form.img
3.3、如果file中的值为File则为新添加的文件,如果file中的值为字符串,则为回显数据,是否删除文件由后端判断(与后端讨论)

2.2、使用方法(dataType:默认值)
修改源码:


使用方法:

 img:[{ "label": "avue@226d5c1a_logo.png", "value": "https://avuejs.com/images/logo-bg.jpg",file:"https://avuejs.com/images/logo-bg.jpg"}],
//取text的值
this.$refs.form.$refs.img[0].text

input accept值

十二、avue-echart-table 实现当字符串过长时,显示省略号,鼠标悬浮上去,显示完整内容

html代码

  <span v-html="citem[item.prop]"   @mouseenter="handleDivMouseEnter($event, item.showOverflowTooltip)"@mouseleave="handleDivMouseleave($event, item.showOverflowTooltip)"></span><el-tooltipclass="item"effect="dark"ref="ellipse_tooltip":content="tooltipContent"placement="top-start"></el-tooltip>

methods

 handleDivMouseEnter(event, showOverflowTooltip) {//if (!showOverflowTooltip) return;const cell = event.target;if (cell.scrollWidth > cell.clientWidth) {const tooltip = this.$refs.ellipse_tooltip;this.tooltipContent = cell.innerText || cell.textContent;tooltip.referenceElm = cell;tooltip.doDestroy();tooltip.setExpectedState(true);this.activateTooltip(tooltip);}},handleDivMouseleave(event, showOverflowTooltip) {//if (!showOverflowTooltip) return;const tooltip = this.$refs.ellipse_tooltip;if (tooltip) {tooltip.setExpectedState(false);tooltip.handleClosePopper();}},

十三、内容大屏页实现全屏 基于saber框架

所在页面page/index/index
1、触发网页大屏原来的方法

containerFullScreen() {this.$refs.top.handleScreen();},

2、监听大屏状态的变化,添加全屏类

  ...mapGetters(["isMenu","isLock","isCollapse","isFullScren", //大屏状态"website","menu","refresh",]),
 <divstyle="height: 100%; overflow-y: auto; overflow-x: hidden"id="avue-view":class="isFullScren?'fullScren':''"v-show="!isSearch">

3、更改内容页面样式

.fullScren {position: fixed;z-index: 9999999;width: 100%;top:0;left:0;.fullScren-container {padding:0px !important;.basic-container {padding:0px !important;}}
}

十四、element UI 表格发生错位

  watch: {currentView(val) {if (val == "list") {this.$nextTick(() => {this.$refs.crud.doLayout();});}},},

avue源码修改过程(持续更新)相关推荐

  1. Telegram Android源码问题汇总 持续更新

    libtgvoip目录为空 git clone下来的工程中带有submodule时,submodule的内容没有下载下来,执行如下命令 cd Telegram git submodule update ...

  2. 代刷网php怎么改,记录一次彩虹代刷网源码修改过程

    不知道彩虹代刷源码是何种的,请看:彩虹代刷网5.01无需授权版本源码下载.一个站长同学找我帮他改的,目的是为了能有多个页面设置不同的TDK,以便搜索引擎收录排行.其实这个东西使用代码来生成页面很快的, ...

  3. Spring源码系列-第1章-Spring源码纵览【持续更新中】

    文章目录 必读 第1章-Spring源码纵览 概述 简单的继承关系图 Spring框架整体流程 核心组件接口分析 Resource资源 方法 实现类 ResourceLoader资源加载器 方法 实现 ...

  4. HashMap源码总结(持续更新中)

    可以存放多少个数据: 源码:MAXIMUM_CAPACITY = 1 << 30 2的29次方 初始状态数组的大小: 源码static final int DEFAULT_INITIAL_ ...

  5. 微信运动_刷步思路+Python源码+云部署(持续更新)_一蓑烟雨任平生

    文章目录-3.x版本 前言 一.思路 二.电脑发数据(碰壁) 三.使用手机抓包 四.部署云函数(阿里,腾讯都可以) 1.登录阿里云 2.配置函数 3.执行代码 4.设置定时 废话不多说了,直接上脚本吧 ...

  6. Android Dialer,Mms,Contacts源码修改笔记,移动端混合开发经验

    ②在AndroidManifest.xml中修改相应Activity的theme <activity android:name=".HomeActivity" android ...

  7. chosen.jquery.js 、chosen-select 源码修改控制 chosen:updated 方法动态更新下拉框选项不更新搜索框值 ,chosen 实现远程搜索加载下拉选项

    chosen.jquery.js .chosen-select 源码修改控制 chosen:updated 方法动态更新下拉框选项不更新搜索框值,chosen 实现远程搜索加载下拉选项 chosen. ...

  8. Deep Compression阅读理解及Caffe源码修改

    Deep Compression阅读理解及Caffe源码修改 作者:may0324 更新:  没想到这篇文章写出后有这么多人关注和索要源码,有点受宠若惊.说来惭愧,这个工作当时做的很粗糙,源码修改的比 ...

  9. LNMP架构详解(2)——Mysql、PHP、Nginx源码编译过程

    前言 本文将介绍LNMP架构中Mysql.PHP.Nginx的源码编译过程:这时有人不仅会问:在我们使用的Linux系统中,可以从yum源中获得mysql.php,为什么要进行如此漫长复杂的过程进行编 ...

最新文章

  1. python写入数据到excel中_Python写入数据到Excel
  2. 【转】c++中的sizeof
  3. Win系统复制粘贴失效解决办法
  4. 详解linux系列之sendmail邮箱服务的安装及配置
  5. Java ConcurrentHashMap Example and Iterator--转
  6. Angular应用里input字段后面的_ngcontent-hqi是什么含义
  7. 【medium】220. Contains Duplicate III
  8. 1.Kubernetes权威指南 --- Kubernetes入门
  9. 拓端tecdat荣获腾讯云+社区年度最佳作者奖
  10. ubuntu下tftp服务器环境搭建
  11. 天然气阶梯是按年还是按月_天然气阶梯不是明年1月1号开始么?怎么现在充气就限量了...
  12. 项目管理44个过程输入输出工具技术巧记法
  13. 2021年计算机保研记录 (中南,南理工,重大软,东华)
  14. 如何打造领英朋友圈_有哪些领英快速扩充人脉的技巧?
  15. 使用C++ opencv将16位图像映射到8位
  16. FastDfs分布式文件存储系统
  17. 微信扫码登入 改变二维码样式
  18. 单点登录(SSO)、CAS介绍
  19. 【性能优化】-多线程实现百万级导出/导入到excel
  20. jQuery----日期比较

热门文章

  1. 中软国际有限公司c语言笔试,【求助】中软国际C++程序员笔试题
  2. 基于JAVA的中软国际物资管理系统
  3. [转]虚拟现实和现实增强技术带来的威胁
  4. php金钱换算函数,php 资金格式转换函数
  5. Python的下标如何获取
  6. 重磅:国产 SegmentFault 被收购。。
  7. Kafka Ack应答机制理解
  8. ElasticSearch之ES8新特性及集群安装
  9. 【Ansys】错误:The files shown in details are missing from the project.
  10. 英语中从句的引导词【。。。】