vue+element-ui+springboot 在线表格编辑

这篇具有很好参考价值的文章主要介绍了vue+element-ui+springboot 在线表格编辑。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

方法:

  1. 编辑excel 格式为需要的样子,另存为html

  1. 打开files文件,复制html部分代码和样式到vue文件

  1. 将需要编辑的部分使用控件填入

代码:

<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="竞赛名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入竞赛名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="竞赛类别" prop="categoryType">
        <el-select v-model="queryParams.categoryType" placeholder="请选择" clearable>
          <el-option v-for="dict in dict.type.category_type" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="competitionList">
      <el-table-column label="id" align="center" prop="id" v-if="false" />
      <el-table-column label="编号" align="center" prop="competitionNo" width="100" />
      <el-table-column label="名称" align="center" prop="name" width="400" />
      <el-table-column label="类别" align="center" prop="categoryType" width="120">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.category_type" :value="scope.row.categoryType" />
        </template>
      </el-table-column>
      <el-table-column label="报名开始日期" align="center" prop="startDate" width="160" />
      <el-table-column label="报名截止日期" align="center" prop="endDate" width="160" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEnroll(scope.row)"
            v-hasPermi="['physicsmonitor:competition:enroll']">报名</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <el-dialog :visible.sync="enroll.open" width="950px">
      <el-form ref="enrollForm" :model="enrollForm" :rules="enrollRules">
        <table border=0 cellpadding=0 cellspacing=0 width=791 style='border-collapse:
 collapse;table-layout:fixed;width:595pt'>
          <col width=69 style='width:52pt'>
          <col width=90 style='mso-width-source:userset;mso-width-alt:2880;width:90pt'>
          <col width=101 style='mso-width-source:userset;mso-width-alt:3221;width:100pt'>
          <col width=131 style='mso-width-source:userset;mso-width-alt:4181;width:90pt'>
          <col width=125 style='mso-width-source:userset;mso-width-alt:4010;width:80pt'>
          <col width=169 style='mso-width-source:userset;mso-width-alt:5418;width:120pt'>
          <col width=106 style='mso-width-source:userset;mso-width-alt:3392;width:68pt'>
          <tr height=35 style='mso-height-source:userset;height:12.0pt'>
            <td colspan=6 height=35 class=xl73 width=685 style='height:12.0pt;width:515pt'>{{ this.competitionName }}</td>
            <td width=106 style='width:80pt'></td>
          </tr>
          <tr height=19 style='height:5.0pt'>
            <td height=19 colspan=7 style='height:5.0pt;mso-ignore:colspan'></td>
          </tr>
          <tr height=19 style='height:14.5pt'>
            <td height=19 class=xl68 style='height:14.5pt' :required="true">领队:</td>
            <td class=xl69>
              <el-input v-model="enrollForm.leaderName" placeholder="姓名"></el-input>
            </td>
            <td class=xl68>联系电话:</td>
            <td class=xl69>
              <el-input v-model="enrollForm.leaderPhone"></el-input>
            </td>
            <td class=xl68>队医:</td>
            <td class=xl69>
              <el-input v-model="enrollForm.doctorName" placeholder="姓名"></el-input>
            </td>
          </tr>
          <tr height=19 style='height:14.5pt'>
            <td height=19 class=xl68 style='height:14.5pt'>主教练:</td>
            <td class=xl69>
              <el-input v-model="enrollForm.headCoachName" placeholder="姓名"></el-input>
            </td>
            <td class=xl68>联系电话:</td>
            <td class=xl69>
              <el-input v-model="enrollForm.headCoachPhone"></el-input>
            </td>
            <td class=xl68>教练:</td>
            <td class=xl69>
              <el-input v-model="enrollForm.coachName" placeholder="姓名"></el-input>
            </td>
          </tr>

          <tr height=19 style='height:5.0pt'>
            <td height=19 colspan=7 style='height:5.0pt;mso-ignore:colspan'></td>
          </tr>

          <tr height=19 style='height:14.5pt'>
            <td height=19 class=xl71 style='height:14.5pt'>序号</td>
            <td class=xl71>姓名</td>
            <td class=xl71>年级</td>
            <td class=xl71>组别</td>
            <td class=xl71>号码</td>
            <td class=xl71>身份证号码</td>
            <td class=xl71>操作</td>
          </tr>

          <!--  成员遍历-->
          <tr height=19 style='height:14.5pt' v-for="(member, index) in memberList">
            <td height=19 class=xl72 style='height:14.5pt;border-top:none'>{{ index + 1 }}</td>
            <td class=xl72>
              <el-select v-model="member.studentNo" filterable @change="getStudentInfo(member)">
                <el-option v-for="item in studentList" :key="item.id" :label="item.name"
                  :value="item.id" />
              </el-select>
            </td>
            <td class=xl72>{{ member.gradeCodeName }}</td>
            <td class=xl72>
              <el-select v-model="member.teamNo" filterable >
                <el-option v-for="dict in dict.type.team_no" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </td>
            <td class=xl72>
              <el-input v-model="member.memberNo"></el-input>
            </td>
            <td class=xl72>
              {{ member.identityCard }}
            </td>
            <td class=xl72>
              <el-button size="mini" type="text" icon="el-icon-plus" @click="addLine()"></el-button>
              <el-button size="mini" type="text" icon="el-icon-minus" @click="removeLine(index)"></el-button>
            </td>
          </tr>
          <tr height=19 style='height:5.0pt'>
            <td height=19 colspan=7 style='height:5.0pt;mso-ignore:colspan'></td>
          </tr>
          <!--  遍历服装  -->
          <tr height=19 style='height:14.5pt' v-for="(clothes, i) in clothesList" v-if="i != 0">
            <td height=19 class=xl71 style='height:14.5pt;' v-for="(value, key, index) in clothes">
              <el-input v-model="clothes['col' + index]" v-if="index != 0 && i != 1"></el-input>
              <span v-else>{{ clothes['col' + index] }}</span>
            </td>
          </tr>
        </table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<style scoped>
@import '~@/assets/styles/clothes.css';
</style>

<script>
import { getEnrollList, getCompetition } from "@/api/physicsmonitor/competition";
import { listStudent } from "@/api/basic/student";
import { getClothesByCompetitionId } from "@/api/physicsmonitor/clothes";

export default {
  name: "Competitionenroll",
  dicts: ['category_type', 'team_no'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 竞赛表格数据
      competitionList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        competitionNo: null,
        name: null,
        categoryType: null,
        startDate: null,
        endDate: null,
        status: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      },

      // 报名弹框
      enroll: {
        open: false,
      },
      // 报名表单
      enrollForm: {},
      // 报名校验条件
      enrollRules: {
        enrollNo: [
          { required: true, message: "报名编号不能为空", trigger: "blur" }
        ],
        leaderName: [
          { required: true, message: "领队姓名不能为空", trigger: "blur" }
        ],
        headCoachName: [
          { required: true, message: "主教练姓名不能为空", trigger: "blur" }
        ],
        coachName: [
          { required: true, message: "教练姓名不能为空", trigger: "blur" }
        ],
        doctorName: [
          { required: true, message: "队医姓名不能为空", trigger: "blur" }
        ],
        leaderPhone: [
          { required: true, message: "领队联系电话不能为空", trigger: "blur" }
        ],
        headCoachPhone: [
          { required: true, message: "主教练联系电话不能为空", trigger: "blur" }
        ],
      },
      studentList: [],
      // 服装
      clothesList: [],
      // 参赛成员
      memberList: [{ 'studentNo': '', 'teamNo': '', 'memberNo': '', 'gradeCodeName': '', 'identityCard': '' }],
      // 竞赛id
      competitionId: null,
      competitionName: null
    };
  },
  created() {
    this.getList();
    listStudent().then(response => {
      this.studentList = response.rows;
    })
  },
  methods: {
    /** 查询竞赛列表 */
    getList() {
      this.loading = true;
      getEnrollList(this.queryParams).then(response => {
        this.competitionList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    }, 
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 提交按钮 */
    submitForm() {   
      this.$refs["enrollForm"].validate(valid => {
        if (valid) {
          console.log(this.enrollForm);
          console.log(this.memberList);
          console.log(this.clothesList);
        }
      });
    },

    /**竞赛报名    */
    handleEnroll(row) {
      this.enroll.open = true;
      this.competitionId = row.id;
      this.competitionName = row.name;
      getClothesByCompetitionId(row.id).then(response => {
        this.clothesList = response.data;
      })
    },

    // 删除指定行
    removeLine(i) {
      if (i != 0) {
        this.memberList.splice(i, 1);
      }
    },
    // 增加一个空行, 用于录入或显示第一行
    addLine() {
      this.memberList.push({ 'studentNo': '', 'teamNo': '', 'memberNo': '', 'gradeCodeName': '', 'identityCard': '' });
    },
    // 获取学生的班级和身份证号
    getStudentInfo(member){
      member.identityCard = '11111';
      member.gradeCodeName = '高一';
    }


  }
};
</script>

特别地:

  1. 服装列数可变,需要动态变换,同时有的可编辑,有的不可编辑

  1. 增加表格行数,可通过增加memberList 数据进行动态添加和删除,无需增加节点文章来源地址https://www.toymoban.com/news/detail-819736.html

element ui 在线编辑,vue,SpringBoot,element-ui,spring boot,Powered by 金山文档
element ui 在线编辑,vue,SpringBoot,element-ui,spring boot,Powered by 金山文档

到了这里,关于vue+element-ui+springboot 在线表格编辑的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • element-ui table表格双击行内编辑

    行内双击编辑的本质:点击后input框出现,保存后span标签出现 如果有编辑某一行的某列其他列随之变化的需求,则需要将上一步选中行存下来,不然双击后选中行就变了,随之修改的值也会产生错误 此外,因为用到了 tableRowClassName({row, rowIndex}){ row.index = rowIndex;}, ,所以导致

    2024年02月15日
    浏览(15)
  • element-ui中table表格标签编辑功能的实现

    element-ui中table表格标签编辑功能的实现

    表格实现编辑功能。在实际开发过程中,我们表格的表头往往很多,有的还会发生变化,所以本文参考一位博主的代码结合自己的项目进行了改编。 参考原文链接:vue element-ui实现table表格可编辑修改

    2024年02月13日
    浏览(16)
  • Vue+Element-ui+SpringBoot搭建后端汽车租赁管理系统

    Vue+Element-ui+SpringBoot搭建后端汽车租赁管理系统

    最近在做项目,花了一周的时间搭建了一个十分完备的汽车租赁后端管理系统。页面采用 纯Vue2+Element-ui搭建 ,后端采用 Springboot+Mybatis 搭建,数据库采用 Mysql 。包括了登录验证,根据不同权限进入不同界面、数据增删改查、表格分页、表格excel导出等等功能。已开源至git,在

    2024年02月09日
    浏览(17)
  • Vue+Element-ui实现表格嵌套表格(表头不同)

    Vue+Element-ui实现表格嵌套表格(表头不同)

    data中integrateList根据后端返回的json数据确定,其格式为:

    2024年02月14日
    浏览(21)
  • Vue Element-ui Table表格排序

    Vue Element-ui Table表格排序

    一.表格中有时候会有排序的需求,如果只针对当前页进行排序,那么前端就可以实现排序,在对应需要排序的字段中,使用sortable字段即可。 二.存在分页的情况时,前端仅仅使用sortable当前页排序已经不能满足我们的需求,无法对所有数据进行排序。这时候我们就要使用后端

    2024年02月11日
    浏览(12)
  • (vue)element-ui 表格实现勾选单选

    (vue)element-ui 表格实现勾选单选

    效果: 重选后: 解决参考:https://blog.csdn.net/m0_58373910/article/details/125912828

    2024年02月12日
    浏览(15)
  • vue element-ui表格组件动态多级表头

    vue element-ui表格组件动态多级表头

    实际项目的需求,需要根据后端动态获取的方式来初始化表格的表头包含哪些信息,且有很多信息是有规律的,所以我们需要Element UI动态生成多级表头。需要的效果图如下: 由于统计维度是可变化的(它可以是省市也可以是区县),所以需要专门设置一个表格的数据来保存

    2024年02月10日
    浏览(10)
  • Vue+element UI 可编辑表格

    Vue+element UI 可编辑表格

    前端开发过程中,我们都会尽量避免多层弹窗的嵌套,最多两层弹窗嵌套。这么做的原因是为了方便管理代码和防止多层嵌套弹窗造成bug。但是有时候,内层的弹窗可能展示了一个表格,并且需要操作表格中的数据,这个时候我们只能自己DIY一个表格,取代弹窗处理的方法。

    2024年02月04日
    浏览(11)
  • vue搭配element-ui前端实现表格分页

    如果不从后台请求数据,那么就需要在前端手动管理数据。可以使用以下步骤实现该功能: 在 Vue 组件的 data 中定义一个数组来存放所有数据(不分页)。 在 mounted 钩子函数中,手动获取数据并存放到上一步定义的数组中。 在模板中使用 element-ui 的表格组件来展示数据,同

    2024年02月11日
    浏览(14)
  • vue监听element-ui的table表格滚动事件

    这篇文章主要是讲述“如何监听element-ui table滚动事件”,按我自己尝试的方法去实现。 需求分析: 前两天做项目遇到一个问题,数据量大,然后表格渲染的很慢,而且很卡怎么办?有什么优化的方式? 那无非就是两种方法。 先加载一屏表格的数据,之后触底加载新的数据

    2024年02月12日
    浏览(16)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包