午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術文章
文章詳情頁

vue+render+jsx實現可編輯動態多級表頭table的實例代碼

瀏覽:27日期:2023-01-29 10:17:02

最近項目需要實現可編輯的動態多級表頭表格,看了兩天的文章,始終沒有找到我想要的效果,在了解了render+jsx的基礎用法后,自己基于element-ui封裝了一個,數據格式參考element-ui table的數據。實現如下:

1.scoresTable

<script> import scoresColumn from './scoresColumn'; export default { components: { scoresColumn }, render: function(h) { return <div className='table-control'><el-table ref='table' size='small' {...{attrs: {data:this.tableData}}} border> { this.tableTitles.map(title => { return <scoresColumn on-dataChange={this.dataChange} {...{attrs: {column:title,unitScores: this.unitScores}}}></scoresColumn> }) }</el-table> </div>; }, props: { tableTitles: {type: Array,default: () => [] }, tableData: {type: Array,default: () => [] }, unitScores: {type: Object,default: () => {} } }, methods: { dataChange(id) {this.$emit(’dataChange’, id); } }, }</script><style> .el-table th, .el-table td { text-align: center; }</style>

2.scoresColumn

<script> export default { data() { return { style: { ’min-width’: '70', ’resizable’: true, ’show-overflow-tooltip’: true }, } }, props: { column: { type: Object }, unitScores: { type: Object, default: () => {} } }, name: 'scoresColumn', render: function (h) { let scopedSlots = {default: (scope) => { let col = scope.column.property; let value = scope.row[col]; return <div id={col+scope.$index} > <p onClick={this.clickHandle}>{value}</p> </div>;} }; if (this.column.children === undefined)if (this.column.label == ’序號’ || this.column.label == ’姓名’) { return <el-table-column fixed {...{style: this.style, scopedSlots: {default: (scope) => { let value = scope.row[scope.column.property]; return <p>{value}</p>;} }}} prop={this.column.prop} label={this.column.label}> </el-table-column>}else { return <el-table-column {...{style: this.style, scopedSlots: {default: (scope) => { let value = scope.row[scope.column.property]; if (/((?=d)|(^總計$)/g.test(this.column.label)) { let col = scope.column.property; return <div id={col+scope.$index} > <p onClick={this.clickHandle}>{value}</p> </div>; }else return <p>{value}</p>;} }}} prop={this.column.prop} label={this.column.label}> </el-table-column>} let buildTitles = (childList) => {let children = [];childList.map(child => { if (child.children != undefined && child.children.length > 0) { children.push(<el-table-column {...{style: this.style}} label={child.label}> {buildTitles(child.children)} </el-table-column>) } else { children.push( <el-table-column {...{style: this.style, scopedSlots: scopedSlots}} label={child.label} prop={child.prop}> </el-table-column>) }});return children; }; return <el-table-column{...{style: this.style}}label={this.column.label}prop={this.column.prop}>{buildTitles(this.column.children)} </el-table-column>; }, methods: { blurHandler(e) {let parent = e.target.parentNode;let child = parent.firstElementChild;let p = document.createElement(’p’);let value = child.value.match(/^d*(.{1}d+)?/)[0];if (value == ’’ || value == null) { value = 0;}p.innerHTML = value;p.addEventListener(’click’, this.clickHandle, false);child.replaceWith(p);this.$emit(’dataChange’, parent.id); }, clickHandle(e) {let parent = e.target.parentNode;let child = parent.firstElementChild;let input = document.createElement(’input’);input.style.lineHeight = ’23px’;input.style.textAlign = ’center’;input.style.fontSize = ’12px’;input.style.height = ’23px’input.style.width = ’100%’;input.value = child.innerHTML;input.addEventListener(’blur’, this.blurHandler, true);input.addEventListener(’keyup’, this.keyUpHandler, false);child.replaceWith(input);input.focus(); }, keyUpHandler(e) {let input = e.target;let parent = input.parentNode;let property = parent.id.replace(/d/g, ’’);let value = input.value.replace(/[^d.]/g,’’);if (Math.min(this.unitScores[property],value) != value) { value = this.unitScores[property];}input.value = value; } } }</script><style scoped></style>

3.實現效果

vue+render+jsx實現可編輯動態多級表頭table的實例代碼vue+render+jsx實現可編輯動態多級表頭table的實例代碼

總結

到此這篇關于vue+render+jsx實現可編輯動態多級表頭table的文章就介紹到這了,更多相關vue render jsx 多級表頭table內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Vue
相關文章:
主站蜘蛛池模板: 蜜桃传媒av | 爱av在线 | 国产一区二区91 | 久久久中文字幕 | 国产片91 | 国产精品一二三四五 | 四虎新网址 | 欧美 日韩 国产 在线 | 98国产在线| 夜夜视频| 亚洲视频大全 | 波多野结衣大片 | 亚洲欧洲中文字幕 | 麻豆网址| 精品日韩在线观看 | 婷婷综合久久 | 五月婷婷六月综合 | 日韩av高清| 中文字幕在线观看一区二区三区 | 成人国产一区 | 91人人爱| 精品久久一区二区三区 | 亚洲久久久 | 欧美视频免费在线 | 亚洲国产视频网站 | 全部免费毛片在线播放一个 | 成人一级免费视频 | 蜜桃av免费看 | 国产一区二区三区欧美 | 久操国产 | 国产高清网站 | 欧美黄色网页 | 成人公开免费视频 | 成人综合在线视频 | 中文字幕手机在线观看 | 天天操夜夜爽 | 国产又黄又爽免费视频 | 免费毛片a | 亚洲少妇激情 | 欧美色亚洲 | 夜夜躁天天躁很躁 |