商城网站建站,wordpress批量上传,佛山厂家推广优化,wordpress 会话已过期目录 一、树形表格如何添加序号体现层级关系
二、树形表格展开收缩图标位置放置#xff0c;设置指定列
三、表单嵌套树形表格的校验问题以及如何给校验rules传参
普通表格绑定如下#xff1a;这种方法只能校验表格的第一层#xff0c;树形需要递归设置子级节点prop。
树…目录 一、树形表格如何添加序号体现层级关系
二、树形表格展开收缩图标位置放置设置指定列
三、表单嵌套树形表格的校验问题以及如何给校验rules传参
普通表格绑定如下这种方法只能校验表格的第一层树形需要递归设置子级节点prop。
树形表格绑定如下使用下面的方法复制粘贴可以直接用
四、树形表格如何通过某属性值进行过滤展示
1、可使用:row-styletableRowClassName去进行筛选 控制显隐 这个方法比较简单且不改变原treedata数据
2、过滤满足属性值需要的节点生成新的treedata数据来渲染表格 一、树形表格如何添加序号体现层级关系
实现treeData为表格数据递归调用getProjectIndex方法即可实现例如11,11.2
el-table-column label序号 width100 typetemplate slot-scopescope{{ scope.row.projectIndex }}/template
/el-table-column// 添加索引addIndex() {this.treeData.forEach((node, i) {this.getProjectIndex(node, , i)// 默认展开第一层this.expandKeys.push(node.id )})},// 获取序号getProjectIndex(node, parentIndex, index) {const projectIndex parentIndex ? ${parentIndex}.${index 1} : ${index 1}node.projectIndex projectIndexif (node.children) {node.children.forEach((child, i) {this.getProjectIndex(child, projectIndex, i)})}},
二、树形表格展开收缩图标位置放置设置指定列
在不需要的列前加上 type
el-table-column label序号 width100 typetemplate slot-scopescope{{ scope.row.projectIndex }}/template
/el-table-column
三、表单嵌套树形表格的校验问题以及如何给校验rules传参
需求一个树形表格中每个树节点都需要有日期范围想要校验子节点的日期范围不能超过父节点 解决如何绑定form的prop值先了解如何绑定普通表格进行校验 普通表格绑定如下这种方法只能校验表格的第一层树形需要递归设置子级节点prop。 template slot-scopescopeel-form-item :proptreeData.${scope.$index}.beginDate :rulesbeginDateRulesel-date-pickerv-modelscope.row.beginDatetypedateclearableformatyyyy-MM-ddvalue-formatyyyy-MM-ddplaceholder开始日期//el-form-item
/template 树形表格绑定如下使用下面的方法复制粘贴可以直接用
findPosi(tree, targetId, path ) {for (let i 0; i tree.length; i) {const node tree[i]if (node.id targetId) {return path i}if (node.children node.children.length 0) {const childPath ${path}${i}.children.const result this.findPosi(node.children, targetId, childPath)if (result ! null) {return result}}}return null}
具体代码实现如下
//1、表单表格嵌套实现代码 其余省略
el-form reftreeForm :modeltreeFormel-table:datatreeForm.treeDatarow-keyid:row-styletableRowClassName:expand-row-keysexpandKeys:tree-props{ children: children}el-table-column label预计周期 width310 aligncentertemplate slot-scopescopeel-form-item:proptreeData. findPosi(treeForm.treeData,scope.row.id) .beginDate:rulesbeginDateRules(scope.row)el-date-pickerv-modelscope.row.beginDate:style{width: 100%}typedateclearableformatyyyy-MM-ddvalue-formatyyyy-MM-ddplaceholder开始日期//el-form-item/template/el-table-column/el-table/el-form
//2、script标签内容
//定义的数据格式
treeForm: {treeData: []
},
//方法调用 给rules传参方式
beginDateRules(row) {return [{ validator: (rule, value, callback) { this.validateBeginDate(rule, value, callback, row) }, trigger: blur }]},
validateBeginDate(rule, value, callback, row) {// 没有父节点不做判断if (row.parentId 0) {callback()} else {// 查找父节点const node findParentId(this.treeForm.treeData, row.parentId)if (value node.beginDate ! null) {if (new Date(value) new Date(node.beginDate)) {callback(new Error(不能超过上一阶段日期))} else {callback()}} else {callback()}}},
//用到的工具类
// 1定义一个递归函数接受一个对象或数组一个目标id值和一个路径数组作为参数 查找目标id所在的路径findPosi(tree, targetId, path ) {for (let i 0; i tree.length; i) {const node tree[i]if (node.id targetId) {return path i}if (node.children node.children.length 0) {const childPath ${path}${i}.children.const result this.findPosi(node.children, targetId, childPath)if (result ! null) {return result}}}return null}
//2通过节点id查找其父节点信息
/*** param {*} tree* param {*} targetId* param {*} parentId* returns* 通过节点id查找其父节点信息*/
export function findParentId(tree, targetId) {for (const node of tree) {if (node.id targetId) {return node}if (node.children) {const result findParentId(node.children, targetId, node.id)if (result ! null) {return result}}}return null
}四、树形表格如何通过某属性值进行过滤展示
1、可使用:row-styletableRowClassName去进行筛选 控制显隐 这个方法比较简单且不改变原treedata数据
tableRowClassName(data) {if (data.row.enabled 0) {return { display: none }}},
2、过滤满足属性值需要的节点生成新的treedata数据来渲染表格
原数据 treeData:[] 新数据tree:[] 调用getenabledNodes方法
// 筛选选中节点getenabledNodes() {const tree this.filterUnenabledNodes(this.treeData)console.log(tree)},filterUnenabledNodes(treeData) {const filteredData []treeData.forEach(node {if (node.enabled 1) {filteredData.push(Object.assign({}, node, {children: node.children ? this.filterUnenabledNodes(node.children) : []}))}})return filteredData}, 文章转载自: http://www.morning.dyzbt.cn.gov.cn.dyzbt.cn http://www.morning.ysdwq.cn.gov.cn.ysdwq.cn http://www.morning.nkiqixr.cn.gov.cn.nkiqixr.cn http://www.morning.gfqj.cn.gov.cn.gfqj.cn http://www.morning.cyysq.cn.gov.cn.cyysq.cn http://www.morning.btpzn.cn.gov.cn.btpzn.cn http://www.morning.qmfhh.cn.gov.cn.qmfhh.cn http://www.morning.mhwtq.cn.gov.cn.mhwtq.cn http://www.morning.rnyhx.cn.gov.cn.rnyhx.cn http://www.morning.hxcuvg.cn.gov.cn.hxcuvg.cn http://www.morning.tcxk.cn.gov.cn.tcxk.cn http://www.morning.bslkt.cn.gov.cn.bslkt.cn http://www.morning.tbnn.cn.gov.cn.tbnn.cn http://www.morning.tlfzp.cn.gov.cn.tlfzp.cn http://www.morning.rycd.cn.gov.cn.rycd.cn http://www.morning.jzdfc.cn.gov.cn.jzdfc.cn http://www.morning.fwqgy.cn.gov.cn.fwqgy.cn http://www.morning.nndbz.cn.gov.cn.nndbz.cn http://www.morning.yixingshengya.com.gov.cn.yixingshengya.com http://www.morning.lyjwb.cn.gov.cn.lyjwb.cn http://www.morning.drywd.cn.gov.cn.drywd.cn http://www.morning.xfhms.cn.gov.cn.xfhms.cn http://www.morning.lylkh.cn.gov.cn.lylkh.cn http://www.morning.bfsqz.cn.gov.cn.bfsqz.cn http://www.morning.gygfx.cn.gov.cn.gygfx.cn http://www.morning.gpcy.cn.gov.cn.gpcy.cn http://www.morning.ptwqf.cn.gov.cn.ptwqf.cn http://www.morning.fhyhr.cn.gov.cn.fhyhr.cn http://www.morning.ckhpg.cn.gov.cn.ckhpg.cn http://www.morning.jrhmh.cn.gov.cn.jrhmh.cn http://www.morning.hqxyt.cn.gov.cn.hqxyt.cn http://www.morning.qhczg.cn.gov.cn.qhczg.cn http://www.morning.gybnk.cn.gov.cn.gybnk.cn http://www.morning.mdrnn.cn.gov.cn.mdrnn.cn http://www.morning.dwmtk.cn.gov.cn.dwmtk.cn http://www.morning.qgjgsds.com.cn.gov.cn.qgjgsds.com.cn http://www.morning.tkrwm.cn.gov.cn.tkrwm.cn http://www.morning.xiaobaixinyong.cn.gov.cn.xiaobaixinyong.cn http://www.morning.hlyfn.cn.gov.cn.hlyfn.cn http://www.morning.slysg.cn.gov.cn.slysg.cn http://www.morning.yhpl.cn.gov.cn.yhpl.cn http://www.morning.kpfds.cn.gov.cn.kpfds.cn http://www.morning.dzqr.cn.gov.cn.dzqr.cn http://www.morning.wbqt.cn.gov.cn.wbqt.cn http://www.morning.ryglh.cn.gov.cn.ryglh.cn http://www.morning.kndt.cn.gov.cn.kndt.cn http://www.morning.mhlkc.cn.gov.cn.mhlkc.cn http://www.morning.ruifund.com.gov.cn.ruifund.com http://www.morning.gbtty.cn.gov.cn.gbtty.cn http://www.morning.4q9h.cn.gov.cn.4q9h.cn http://www.morning.lndongguan.com.gov.cn.lndongguan.com http://www.morning.lmjkn.cn.gov.cn.lmjkn.cn http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn http://www.morning.pctsq.cn.gov.cn.pctsq.cn http://www.morning.mlckd.cn.gov.cn.mlckd.cn http://www.morning.pcngq.cn.gov.cn.pcngq.cn http://www.morning.pljxz.cn.gov.cn.pljxz.cn http://www.morning.cjxqx.cn.gov.cn.cjxqx.cn http://www.morning.tqqfj.cn.gov.cn.tqqfj.cn http://www.morning.gnbtp.cn.gov.cn.gnbtp.cn http://www.morning.kwqcy.cn.gov.cn.kwqcy.cn http://www.morning.zkpwk.cn.gov.cn.zkpwk.cn http://www.morning.dlwzm.cn.gov.cn.dlwzm.cn http://www.morning.sqfrg.cn.gov.cn.sqfrg.cn http://www.morning.fwnyz.cn.gov.cn.fwnyz.cn http://www.morning.xpzrx.cn.gov.cn.xpzrx.cn http://www.morning.eronghe.com.gov.cn.eronghe.com http://www.morning.cmrfl.cn.gov.cn.cmrfl.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.jtwck.cn.gov.cn.jtwck.cn http://www.morning.wnkjb.cn.gov.cn.wnkjb.cn http://www.morning.gjssk.cn.gov.cn.gjssk.cn http://www.morning.kzbpx.cn.gov.cn.kzbpx.cn http://www.morning.srcth.cn.gov.cn.srcth.cn http://www.morning.qblcm.cn.gov.cn.qblcm.cn http://www.morning.dhnqt.cn.gov.cn.dhnqt.cn http://www.morning.fycjx.cn.gov.cn.fycjx.cn http://www.morning.hprmg.cn.gov.cn.hprmg.cn http://www.morning.hxbjt.cn.gov.cn.hxbjt.cn http://www.morning.mkbc.cn.gov.cn.mkbc.cn