vue el-table表格中每行上传文件(上传简历)操作
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
·
1、HTML中
<el-table :data="formInfo.userListDto" border stripe max-height="400">
<el-table-column type="index" label="序号" width="50"> </el-table-column>
<el-table-column prop="realName" label="姓名" show-overflow-tooltip></el-table-column>
<el-table-column prop="birthday" label="出生年月" show-overflow-tooltip></el-table-column>
<el-table-column prop="orgName" label="所在单位" show-overflow-tooltip></el-table-column>
<el-table-column prop="postName" label="职务" show-overflow-tooltip></el-table-column>
<el-table-column prop="jobRankName" label="职级" show-overflow-tooltip></el-table-column>
<el-table-column prop="jobExpertiseName" label="工作专长" show-overflow-tooltip></el-table-column>
<el-table-column prop="" label="操作" width="700">
<template slot-scope="scope">
<el-upload
ref="upload"
class="upload-demo"
action="#"
:on-change="
(file, fileList) => {
handleChange(file, fileList, scope)
}
"
:on-remove="
(file, fileList) => {
handleRemove(file, fileList, scope)
}
"
:limit="1"
:on-exceed="handleExceed"
:auto-upload="false"
>
<span class="opera-img">上传简历</span>
</el-upload>
</template>
</el-table-column>
</el-table>

2、JS中
//监控上传文件列表
handleChange(file, fileList, scope) {
this.formInfo.userListDto[scope.$index].fileIdList.push(file.name)
},
handleRemove(file, fileList, scope) {
this.formInfo.userListDto[scope.$index].fileIdList = []
},
handleExceed() {
this.$tips.tipWarning(`个人简历只能上传一个文件`)
},
3、注意点
1、通过scope把上传的文件和表格中的行一一对应
2、上传后要把返回的数据push到表格数组中,删除后要把表格数组中的数据删除
展示:
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:2 个月前 )
9e887079
[skip ci] 1 年前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)