方法:
编辑excel 格式为需要的样子,另存为html
打开files文件,复制html部分代码和样式到vue文件
将需要编辑的部分使用控件填入
代码:
<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>
特别地:
服装列数可变,需要动态变换,同时有的可编辑,有的不可编辑文章来源:https://www.toymoban.com/news/detail-819736.html
增加表格行数,可通过增加memberList 数据进行动态添加和删除,无需增加节点文章来源地址https://www.toymoban.com/news/detail-819736.html


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