antdvuetable跨行合并單元格,并且自定義內容實例_第1頁
antdvuetable跨行合并單元格,并且自定義內容實例_第2頁
antdvuetable跨行合并單元格,并且自定義內容實例_第3頁
antdvuetable跨行合并單元格,并且自定義內容實例_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

555555antdvuetable跨行合并單元格,并且自定義內容實例ant-de版本ant-de版本nvue555555555555需求:表格實現跨行合并,并且在合并完的單元格中顯示圖片效果圖:卿詒卿詒R/凈資產IB151.69m%5B29L94103416.70和嘆20357^.047J06^IB370.64454湍5E463.335磁103輕豹7.75^42031233.9515.11%etdedataetdedatareturaultvaablelou置信度',天數',equ

equassetassetduitduittitle:dataIndeclass:usto

letRendebj=ildrenfiden

idence'

(value,ndeattattattetundeldrencla

an:ndeldrencla

an:5attr5anndevaablelou置信度',天數',equ

equassetassetduitduittitle:dataIndeclass:usto

letRendebj=ildrenfiden

idence'

(value,ndeattattattetundeldrencla

an:ndeldrencla

an:5attr5anndendetitle:dataIndewidth:enc@(tetext555555555555萬元va'ti,tle:dataIndewidth:萬元vatitle:'VaR/凈資產',dataIndex:'var_rate',width:'25%',customRender:(text)=>fmtRatio(text,2)}],data:[{window_length:1,var:151.69,var_rate:0.01858},{window_length:5,var:298.94,var_rate:0.03661},{window_length:10,var:416.70,var_rate:0.05104},{window_length:20,var:576.04,var_rate:0.07055},{window_length:1,var:370.64,var_rate:0.045398},{window_length:5,var:463.33,var_rate:0.056751},{window_length:10,var:632.91,var_rate:0.077523},{window_length:20,var:1233.95,var_rate:0.15114}]}}},methods:{//百分數設置fmtRatio(val,index,def){//index默認值為2varindex=arguments[1]?arguments[1]:2if(val==null||isNaN(val)||typeof(val)==='string'&&val===''){returndef||'--'}varratio=(val*100).toFixed(index)returnratio+'%'}}}導入圖片的方式還有importpic95from'@/assets/produit/95.png'importpic99from'@/assets/produit/99.png'如果有問題,歡迎提出,一起交流~~!補充知識:ant-designvuetable可選列、自定義列實現實現ant-designforvue自定義列實現。點擊按鈕,彈窗顯示所有列的checkbox,選擇checkbox,確定即可實現自定義列。先上代碼<script>/***該組件為實現table可選列。*具體操作見下方注釋。*全部集成原a-table功能,使用方式與原a-table完全相同,擴展增加了可選列功能*該組件已注冊至全局,使用方式只需將a-table變為zyx-table即可,等等一系列原寫法不變,即可增加該功能*采用rande函數模式寫,為了實現a-table中slot可動態。*/exportdefault{name:'Table',data(){return{modalVisible:false,//彈窗columns:[],//表格的列,根據條件來操作該字段selectList:[],//已選擇的列temporarySelectData:[],//暫時選擇的列,點擊checkbox暫存到該字段,點確定同步到selectListcheckboxList:[]//checkbox的list,也做總數據來使用}},mounted(){/**掛載后,將原columns復制到本頁columns,checkboxList將selectList賦值全選狀態*/this.columns=this.deepClone(this.$attrs.columns)this.checkboxList=this.deepClone(this.$attrs.columns)this.selectList=this.columns.map(ele=>ele.dataIndex)},methods:{/***打開modal,將checkbox默認值或者是選擇值(暫存)重新賦值*/handelOpenSelect(){this.temporarySelectData=this.deepClone(this.selectList)this.modalVisible=true},/***點擊確定,將暫存值賦值(temporarySelectData)給已選擇的列(selectList)*將列(columns)根據已選擇的列(selectList)篩選出來*/handleOk(){this.selectList=this.deepClone(this.temporarySelectData)this.modalVisible=falsethis.columns=this.checkboxList.filter(ele=>this.selectList.includes(ele.dataIndex))},handleCancel(){this.modalVisible=false},handelChange(e){this.temporarySelectData=this.deepClone(e)},deepClone(target){letresultif(typeoftarget==='object'){if(Array.isArray(target)){result=[]for(constiintarget){result.push(this.deepClone(target[i]))}}elseif(target===null){result=null}elseif(target.constructor===RegExp){result=target}else{result={}for(constiintarget){result[i]=this.deepClone(target[i])}}}else{result=target}returnresult}},render(){constprops={...this.$attrs,...this.$props,...{columns:this.columns}}conston={...this.$listeners}constslots=Object.keys(this.$slots).map(slot=>{return(<templateslot={slot}>{this.$slots[slot]}</template>)})consttable=(<a-tableprops={props}scopedSlots={this.$scopedSlots}on={on}ref="zyxTable">{slots}</a-table>)constchangeDiv=(va-buttonclass="select-columns"size="small"onClick={this.handelOpenSele?t}>/a-button>)constcheckboxArr=[]for(leti=0;ivthis.checkboxList.length;i++){checkboxArr.push(va-colspan={8}>va-checkboxvalue={this.checkboxList[i].dataIndex}>{this.checkboxList[i].title}v/a-checkbox>v/a-col>)}constmodal=(va-modaltitle="設置列"visible={this.modalVisible}onOk={this.handleOk}onCancel={this.handleCancel}><a-checkbox-groupvalue={this.temporarySelectData}onChange={this.handelChange}><a-row>{checkboxArr}</a-row></a-checkbox-group></a-modal>)return(<divclass="zyx-table">{table}{changeDiv}{modal}</div>)}}</script><stylelang="less"scoped>.zyx-table{position:relative;margin-top:20px;.select-columns{position:absolute;right:0;top:-30px;}}.ant-row{width:100%;.ant-col-8{margin-bottom:10px;}}.ant-checkbox-group

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論