vxe简单表格

2024-05-15 04:04
文章标签 简单 表格 vxe

本文主要是介绍vxe简单表格,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

<div><vxe-grid ref="warnUpTable" border="none" stripe :data="riseData" empty-text="暂无数据" :height="returnTableHeight" :row-config="{ isCurrent: true, isHover: true,keyField:'lDailyInstructionNo' }":column-config="{ resizable: true }"  :scroll-y="{ mode: 'wheel', oSize: 200 }" @filter-visible="filterVisibleEvent" :columns="riseColumns" :checkbox-config="{ highlight: true ,checkField:'',reserve:true,}"@cell-click="handleClickShowModal" @checkbox-all="selectAllEvent"@checkbox-change="selectChangeEvent"show-overflow="title" show-header-overflow="title" :cell-class-name="cellClassName"><!-- checkMethod:true,报错不是方法不显示 --><!-- range:true无用--><!-- visibleMethod:true, 去掉后td都显示了--><!-- checkField:'vcReportCode', 去掉后td不显示了  框为不选中--><!-- indeterminateField:'vcReportCode', --><!-- @cell-click="handleClickShowModal" 点击没有调用去掉内容不显示--><!-- <vxe-column type="checkbox" width="30" align="center"></vxe-column> --><!-- <vxe-column v-for="(item, index) in riseColumns" :key="index" :field="item.key" :title="item.title":align="item.align == 1 ? 'left' : item.align == 2 ? 'right' : 'center' " :width="item.key == 'vcFundName' ? '150px' : ''" :sortable="item.sortable == 1" show-overflow="title" show-header-overflow="title" ><template #default="{ row }"><span>{{ row[item.key] }}</span></template></vxe-column> --></vxe-grid><!-- <vxe-table ref="warnUpTable" border="none" stripe :data="riseData" empty-text="暂无数据" :height="returnTableHeight" :row-config="{ isCurrent: true, isHover: true }":column-config="{ resizable: true }"  :scroll-y="{ mode: 'wheel', oSize: 200 }" @filter-visible="filterVisibleEvent"><vxe-column type="checkbox" width="30" align="center"></vxe-column><vxe-column v-for="(item, index) in riseColumns" :key="index" :field="item.key" :title="item.title":align="item.align == 1 ? 'left' : item.align == 2 ? 'right' : 'center' " :width="item.key == 'vcFundName' ? '150px' : ''" :sortable="item.sortable == 1" show-overflow="title" show-header-overflow="title" ><template #default="{ row }"><span>{{ row[item.key] }}</span></template></vxe-column></vxe-table> --></div>

data中数据结构

 riseData: [{checkField:"vcCombiNo",iStockFlag: 1,"lDailyInstructionNo":15,"lFundId":39,"vcFundName":"公共卫生健康ETF","vcCombiNo":39400810,"vcCombiName":"权益补券组合","lAssetId":309,"vcAssetName":"权益资产单元","vcStockName":"藏格矿业","vcReportCode":"000408","cEntrust_direction":"2","lBeginDate":"20231219","lBeginTime":"91500","lEndDate":"20231219","lEndTime":"180000","lAmount":221200,"enBalance":0,"cInstructionLevel":0,"vcSummary":null,"enPrice1":0,"cMarketNo":"2","cBusinClass":"1","cPriceYype":"5","cEtfAuto":"2","cInstructionType":"2","cFairTrade":"1","lTotalDealAmount":0,"lTotayEntrustAmount":0,"dailyCompletionRatio":100,},{checkField:"vcCombiNo","lDailyInstructionNo":8,"lFundId":39,"vcFundName":"泰康300","vcCombiNo":39400810,"vcCombiName":"权益补券组合","lAssetId":309,"vcAssetName":"权益资产单元","vcStockName":"紫光股份","vcReportCode":"000938","cEntrust_direction":"2","lBeginDate":"20231219","lBeginTime":"91500","lEndDate":"20231219","lEndTime":"180000","lAmount":0,"enBalance":0,"cInstructionLevel":0,"vcSummary":null,"enPrice1":0,"cMarketNo":"2","cBusinClass":"1","cPriceYype":"5","cEtfAuto":"2","cInstructionType":"2","cFairTrade":"1","lTotalDealAmount":0,"lTotayEntrustAmount":0,"dailyCompletionRatio":0},{checkField:"vcCombiNo","lDailyInstructionNo":10,"lFundId":39,"vcFundName":"泰康300","vcCombiNo":39400810,"vcCombiName":"权益补券组合","lAssetId":309,"vcAssetName":"权益资产单元","vcStockName":"华东医药","vcReportCode":"000963","cEntrust_direction":"2","lBeginDate":"20231219","lBeginTime":"91500","lEndDate":"20231219","lEndTime":"180000","lAmount":0,"enBalance":0,"cInstructionLevel":0,"vcSummary":null,"enPrice1":0,"cMarketNo":"2","cBusinClass":"1","cPriceYype":"5","cEtfAuto":"2","cInstructionType":"2","cFairTrade":"1","lTotalDealAmount":0,"lTotayEntrustAmount":0,"dailyCompletionRatio":0},],riseColumns: [  { type: 'checkbox', width: 30, fixed: 'key' },{"field":"vcFundName","id":60,"lPageId":null,"lTableId":null,"minWidth":null,"width":null,"title":"基金名称","lOrder":null,"key":"vcFundName","type":null,"align":null,"cState":null,"vcState":null,"_checked":true,"tooltip":false,"myhighlight":false,"columntype":"nomal","cShow":null,"sortable":0,"screen":false},{"field":"lDailyInstructionNo","id":61,"lPageId":null,"lTableId":null,"minWidth":null,"width":null,"title":"指令序号","lOrder":null,"key":"lDailyInstructionNo","type":null,"align":null,"cState":null,"vcState":null,"_checked":true,"tooltip":false,"myhighlight":false,"columntype":"nomal","cShow":null,"sortable":0,"screen":false},{"field":"lAmount","id":62,"lPageId":null,"lTableId":null,"minWidth":null,"width":null,"title":"指令数量","lOrder":null,"key":"lAmount","type":null,"align":null,"cState":null,"vcState":null,"_checked":true,"tooltip":false,"myhighlight":false,"columntype":"nomal","cShow":null,"sortable":0,"screen":false},{"field":"lTotalDealAmount","id":63,"lPageId":null,"lTableId":null,"minWidth":null,"width":null,"title":"累计成交数量","lOrder":null,"key":"lTotalDealAmount","type":null,"align":null,"cState":null,"vcState":null,"_checked":true,"tooltip":false,"myhighlight":false,"columntype":"nomal","cShow":null,"sortable":0,"screen":false},{"field":"dailyCompletionRatio","id":64,"lPageId":null,"lTableId":null,"minWidth":null,"width":null,"title":"成交完成比例(%)","lOrder":null,"key":"dailyCompletionRatio","type":null,"align":null,"cState":null,"vcState":null,"_checked":true,"tooltip":false,"myhighlight":false,"columntype":"nomal","cShow":null,"sortable":0,"screen":false}],

methods中方法

// 展开或关闭筛选框filterVisibleEvent({ column, visible, $event }) {let _this = this;if (visible) {this.$nextTick(() => {if (_this.$refs.filterInput && _this.$refs.filterInput.length > 0)_this.$refs.filterInput[0].focus();});}},//监听-etfhandleClickShowModal({ checked,row }){console.log('etf');console.log('checked1',checked);console.log('row1',row);},//全选-全部选时时才会触发--etfselectAllEvent ({ checked }) {console.log('checked2',checked);this.type='etf'let that = thislet broadcastFlag = checked ? '2' : '1'that.upIdsList = []that.riseData.forEach(item => {that.upIdsList.push(item.lDailyInstructionNo)})console.log('this.riseData2---',this.riseData);console.log('that.upIdsList',that.upIdsList)let str = that.upIdsList.join(',')that.setUpBroadcast(str,broadcastFlag)},//选中--etfselectChangeEvent ({ checked,row }) {this.type='etf'console.log('row3',row);let broadcastFlag = checked ? '2' : '1'let that = this// that.riseData.forEach(item => {//   if(item.lDailyInstructionNo==row.lDailyInstructionNo){//     item.broadcastFlag=broadcastFlag//   }// })console.log('checked3---',checked);console.log('row.lDailyInstructionNo',row.lDailyInstructionNo,checked)// this.broadcastFlag=broadcastFlagthat.setUpBroadcast(row.lDailyInstructionNo,broadcastFlag)},
//播报设置setUpBroadcast(vcReportCode,broadcastFlag){// console.log('vcReportCode',vcReportCode);// console.log('broadcastFlag',broadcastFlag);// console.log('this.idsList',this.idsList)let str = this.idsList.join(',')if(!this.userId){this.$Message.warning({content: '播报设置有误,请联系相关开发人员!',duration: 3});return false}this.$httpGet(`/setUpBroadcast?vcReportCode=${vcReportCode}&broadcastFlag=${broadcastFlag}&userId=${this.userId}&type=${this.type}`).then(res => {if(res){this.$Message.warning({content: res.data.data,duration: 3});}})},cellClassName({ row, rowIndex,column, columnIndex}){// console.log('row, rowIndex,column, columnIndex',row, rowIndex,column, columnIndex)if(row.iStockFlag == 1 && column.property == 'vcFundName'){return 'redCell'}},
//获取数据
getRiseData(){this.$httpGet(`/selectEtfOrder?userId=${that.userId}`).then(res => {if(res){// that.msgNew = res.data.datathat.riseData = res.datathat.$refs.warnUpTable.clearCheckboxRow()let arr = []console.log('that.riseData',that.riseData);that.riseData.forEach((item,index) => {if(item.broadcastFlag == 2){// item.checked = trueconsole.log('index',index)arr.push(that.riseData[index])}})console.log('arr',arr)that.$refs.warnUpTable.setCheckboxRow(arr, true)}})}

setCheckboxRow(rows, checked)

用于 type=checkbox 复选框,设置行为选中状态,第二个参数为选中与否

css样式

>>> .redCell{background: #d32f2f!important;
}

vxe-table 的 不一样的html结构

<vxe-table ref="warnUpTable" border="none" stripe :data="riseData" empty-text="暂无数据" :height="returnTableHeight" :row-config="{ isCurrent: true, isHover: true ,keyField: 'vcReportCode'}":column-config="{ resizable: true }" :checkbox-config="{ highlight: true,reserve:true }" :scroll-y="{ mode: 'wheel', oSize: 200 }" @filter-visible="filterVisibleEvent":cell-style="cellStyle" @checkbox-all="selectAllEvent"@checkbox-change="selectChangeEvent"><vxe-column type="checkbox" width="30" align="center"></vxe-column><vxe-column v-for="(item, index) in riseColumns" :key="index" :field="item.key" :title="item.title" :fixed="item.isFix == 1 ? 'left' : ''" :align="item.align == 1 ? 'left' : item.align == 2 ? 'right' : 'center' " :min-width="item.minWidth" :width="item.width" :sortable="item.sortable == 1"show-overflow="title" show-header-overflow="title" :filters="item.filters":filter-method="filterMethod" :filter-render="item.filterRender"><template #filter="{ $panel, column }" v-if="item.isFilter == 1"><template v-for="(option, index) in column.filters"><DatePicker v-if="column.title.indexOf('时间') > -1" type="date" placeholder="请选择" clearable format="yyyy-MM-dd" :key="index" v-model="option.data" @on-change="$panel.changeOption($event, !!option.data, option)" style="width:120px"></DatePicker><input v-else style="width:120px" ref="filterInput" class="my-input" type="type" :key="index" v-model="option.data" @input="$panel.changeOption($event, !!option.data, option)" @keyup.enter="$panel.confirmFilter()" placeholder="回车确认" /></template></template><template #default="{ row }"><span>{{ row[item.key] }}</span></template></vxe-column></vxe-table>

vxe中 选中后刷新页面还是选中状态,对应的方法补充

这篇关于vxe简单表格的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/990748

相关文章

利用Python编写一个简单的聊天机器人

《利用Python编写一个简单的聊天机器人》这篇文章主要为大家详细介绍了如何利用Python编写一个简单的聊天机器人,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 使用 python 编写一个简单的聊天机器人可以从最基础的逻辑开始,然后逐步加入更复杂的功能。这里我们将先实现一个简单的

使用SQL语言查询多个Excel表格的操作方法

《使用SQL语言查询多个Excel表格的操作方法》本文介绍了如何使用SQL语言查询多个Excel表格,通过将所有Excel表格放入一个.xlsx文件中,并使用pandas和pandasql库进行读取和... 目录如何用SQL语言查询多个Excel表格如何使用sql查询excel内容1. 简介2. 实现思路3

使用IntelliJ IDEA创建简单的Java Web项目完整步骤

《使用IntelliJIDEA创建简单的JavaWeb项目完整步骤》:本文主要介绍如何使用IntelliJIDEA创建一个简单的JavaWeb项目,实现登录、注册和查看用户列表功能,使用Se... 目录前置准备项目功能实现步骤1. 创建项目2. 配置 Tomcat3. 项目文件结构4. 创建数据库和表5.

使用PyQt5编写一个简单的取色器

《使用PyQt5编写一个简单的取色器》:本文主要介绍PyQt5搭建的一个取色器,一共写了两款应用,一款使用快捷键捕获鼠标附近图像的RGB和16进制颜色编码,一款跟随鼠标刷新图像的RGB和16... 目录取色器1取色器2PyQt5搭建的一个取色器,一共写了两款应用,一款使用快捷键捕获鼠标附近图像的RGB和16

四种简单方法 轻松进入电脑主板 BIOS 或 UEFI 固件设置

《四种简单方法轻松进入电脑主板BIOS或UEFI固件设置》设置BIOS/UEFI是计算机维护和管理中的一项重要任务,它允许用户配置计算机的启动选项、硬件设置和其他关键参数,该怎么进入呢?下面... 随着计算机技术的发展,大多数主流 PC 和笔记本已经从传统 BIOS 转向了 UEFI 固件。很多时候,我们也

基于Qt开发一个简单的OFD阅读器

《基于Qt开发一个简单的OFD阅读器》这篇文章主要为大家详细介绍了如何使用Qt框架开发一个功能强大且性能优异的OFD阅读器,文中的示例代码讲解详细,有需要的小伙伴可以参考一下... 目录摘要引言一、OFD文件格式解析二、文档结构解析三、页面渲染四、用户交互五、性能优化六、示例代码七、未来发展方向八、结论摘要

MyBatis框架实现一个简单的数据查询操作

《MyBatis框架实现一个简单的数据查询操作》本文介绍了MyBatis框架下进行数据查询操作的详细步骤,括创建实体类、编写SQL标签、配置Mapper、开启驼峰命名映射以及执行SQL语句等,感兴趣的... 基于在前面几章我们已经学习了对MyBATis进行环境配置,并利用SqlSessionFactory核

csu 1446 Problem J Modified LCS (扩展欧几里得算法的简单应用)

这是一道扩展欧几里得算法的简单应用题,这题是在湖南多校训练赛中队友ac的一道题,在比赛之后请教了队友,然后自己把它a掉 这也是自己独自做扩展欧几里得算法的题目 题意:把题意转变下就变成了:求d1*x - d2*y = f2 - f1的解,很明显用exgcd来解 下面介绍一下exgcd的一些知识点:求ax + by = c的解 一、首先求ax + by = gcd(a,b)的解 这个

hdu2289(简单二分)

虽说是简单二分,但是我还是wa死了  题意:已知圆台的体积,求高度 首先要知道圆台体积怎么求:设上下底的半径分别为r1,r2,高为h,V = PI*(r1*r1+r1*r2+r2*r2)*h/3 然后以h进行二分 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#includ

usaco 1.3 Prime Cryptarithm(简单哈希表暴搜剪枝)

思路: 1. 用一个 hash[ ] 数组存放输入的数字,令 hash[ tmp ]=1 。 2. 一个自定义函数 check( ) ,检查各位是否为输入的数字。 3. 暴搜。第一行数从 100到999,第二行数从 10到99。 4. 剪枝。 代码: /*ID: who jayLANG: C++TASK: crypt1*/#include<stdio.h>bool h