vue el-form中添加el-checkbox多选框,实现将所选内容保存到后台,并能回显到前端的解决(如果有更好的方法欢迎评论)
先说下需求,
1、el-table的单元格不仅要能点击,而且需要显示后台数据(由于我保存的是数字形式到后台,但是展示到前端时需要将这些数字翻译成对应的中文),下面的是一个简单的实现方法
测试一 测试二 测试三 {{ scope.row.zhengjuselect }}
实现的效果图,证据这一栏可以点击
2、点击完单元格出现dialog弹框,然后勾选相应的信息,点击保存就可以啦
测试1 测试2 测试3 取 消 确 定
以上的各种方法的代码
data() { return { AddzhengjuInfoForm: {}, zhengjuInfoData: [], } } AddzhengjuInfo(row) { this.AddzhengjuInfoForm = row this.AddzhengjuInfodialogFormVisible = true }, AddzhengjuInformation() { // this.$refs['AddzhengjuInfoForm'].validate((valid) =>{ console.log(this.AddzhengjuInfoForm.id + "id++++++++++++++++++++++++++++++") // }) this.AddzhengjuInfodialogFormVisible = false let data = this.zhengjuInfoData.join(",") console.log(data) request.get("/WES/savezhengjuSelectInformation", { params: { id: this.AddzhengjuInfoForm.id, zhengjuselect: data } }).then(res => { console.log(res) }) // console.log(row.id) },
后台返回的数据主要是这个函数
load() { request.get("/WES/page", { params: { pageNum: this.pageNum, pageSize: this.pageSize, zhengju: this.zhengju, zhengjuselect: this.zhengjuselect, } }).then(res => { this.tableData = res.records this.total = res.total this.tableData.forEach((index) => this.disableArr.push({isDisable: false})); this.tableData.forEach((index) => this.disableArr1.push({isDisable: false})); }) },
springboot后端的两个接口的代码:
@GetMapping("/page") public IPage SelectByPage(@RequestParam Integer pageSize, @RequestParam Integer pageNum, @RequestParam String chr, @RequestParam String start) { IPage page = new Page(pageNum, pageSize); QueryWrapper WesdeafnessEntityQueryWrapper = new QueryWrapper(); if (!"".equals(chr)) { WesdeafnessEntityQueryWrapper.like("chr", chr); } if (!"".equals(start)) WesdeafnessEntityQueryWrapper.like("start", start); WesdeafnessEntityQueryWrapper.orderByDesc("id"); return wesDeafnessService.page(page, WesdeafnessEntityQueryWrapper); } @GetMapping("/savezhengjuSelectInformation") public WesdeafnessEntity savezhengjuSelectInformation(@RequestParam Integer id, @RequestParam String zhengjuselect){ UpdateWrapper wrapper = new UpdateWrapper(); wrapper.set("zhengjuselect",zhengjuselect).eq("id",id); int result = wesDeafnessMapper.update(null,wrapper); WesdeafnessEntity entity = wesDeafnessMapper.selectById(id); // String zhengju = entity.getZhengju(); //根据ID查出这些数据,然后回传给前端,前端在进行相应展示 return entity; }
最后也顺便说下这个一个单元格显示多行数据是如何实现的,很简单直接看代码
{{ scope.row.genotype }}
{{ scope.row.depth }}
{{ scope.row.vaf }}
效果图:
免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理!
部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理!
图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!