layui多文件上传表格
{layout name="layout" /}<style>.ellipsis-cell {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}.fixed-table {table-layout: fixed;}
</style><div class="layui-card"><form class="layui-card-body layui-form"><div class="layui-form-item"><div class="layui-form-label required">项目名称</div><div class="layui-input-block"><span class="layui-form-mid">{$project.title}</span></div></div>{:input2('附件名称','title',$row.title,'required')}<div class="layui-form-item"><label class="layui-form-label required">文件列表</label><div class="layui-input-block"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="choose-btn">选择文件</button><div class="layui-upload-list"><table class="layui-table fixed-table" lay-size="sm"><colgroup><col><col width="80"><col width="60"><col width="80"><col width="100"></colgroup><thead><tr><th>文件名</th><th>大小</th><th>扩展名</th><th>上传进度</th><th>操作</th></tr></thead><tbody id="upload-files">{volist name="row.files_arr" id="vo"}<tr><td data-src="{$vo.src}" title="{$vo.name}" class="ellipsis-cell">{$vo.name}</td><td>{$vo.size}</td><td>{$vo.ext}</td><td><div class="layui-progress"><div class="layui-progress-bar" lay-percent="100%"></div></div></td><td><div class="layui-btn-group"><button type="button" class="layui-btn layui-btn-xs layui-btn-danger delete">删除</button><a href="{$vo.src}" target="_blank" class="layui-btn layui-btn-xs">查看</a></div></td></tr>{/volist}</tbody></table></div><button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="upload-btn">开始上传</button></div></div>{:switch2('是否披露','is_show',$row.is_show)}{:submit2('提交','id',$row.id)}<input type="hidden" name="project_id" value="{$project.id}"></form>
</div><script>function main() {var uploadListIns = upload.render({elem: '#choose-btn', elemList: $('#upload-files'), bindAction: '#upload-btn', url: '/upload/index', data: { 'path': '/project/' }, accept: 'file', multiple: true, number: 10, auto: false, choose: function (obj) {var that = thisvar files = this.files = obj.pushFile()obj.preview(function (index, file, result) {var tr = $(['<tr id="file-' + index + '">', ' <td title="' + file.name + '" class="ellipsis-cell">' + file.name + '</td>', ' <td>' + (file.size / 1024).toFixed(1) + 'kb</td>', '<td>' + file.ext + '</td>', ' <td><div class="layui-progress" lay-filter="progress-' + index + '"><div class="layui-progress-bar" lay-percent=""></div></div></td>', ' <td>', ' <div class="layui-btn-group">', ' <button type="button" class="layui-btn layui-btn-xs layui-btn-danger delete">删除</button>', ' <button type="button" class="layui-btn layui-btn-xs layui-hide reload">重试</button>', ' </div>', ' </td>', '</tr>'].join(''))// 单个重传tr.find('.reload').on('click', function () {obj.upload(index, file)})// 删除tr.find('.delete').on('click', function () {delete files[index]tr.remove()uploadListIns.config.elem.next()[0].value = ''})that.elemList.append(tr)element.render('progress')})}, done: function (res, index, upload) {var that = thisif (res.ok == 1) {var tr = that.elemList.find('tr#file-' + index)var tds = tr.children()tds.eq(0).data('src', res.data.fullSrc)tds.eq(4).find('.reload').remove()tds.eq(4).find('.layui-btn-group').append('<a href="' + res.data.fullSrc + '" target="_blank" class="layui-btn layui-btn-xs">查看</a>')delete this.files[index]return}this.error(index, upload)}, allDone: function (obj) {// console.log(obj)}, error: function (index, upload) {var that = thisvar tr = that.elemList.find('tr#file-' + index)var tds = tr.children()tds.eq(4).find('.reload').removeClass('layui-hide')element.progress('progress-' + index, '0%')}, progress: function (n, elem, e, index) {element.progress('progress-' + index, n + '%')}})$('.delete').on('click', function () {$(this).parents('tr').remove()})form.on('submit(*)', function (e) {// 判断 uploadListIns.config.files 是否有子元素var filesObj = uploadListIns.config.files || {};var hasFiles = Object.keys(filesObj).length > 0;console.log('是否有子元素:', hasFiles, filesObj);if (hasFiles) {layer.msg('有选择的文件尚未上传', { icon: 5 });return false;}// 获取上传的文件列表var files = []$.each($('#upload-files').children('tr'), function (i, v) {var tds = $(v).children()var src = tds.eq(0).data('src')var name = tds.eq(0).text()var size = tds.eq(1).text()var ext = tds.eq(2).text()if (src) {files.push({ src: src, name: name, size: size, ext: ext })}})if (files.length == 0) {layer.msg('请上传附件', { icon: 5 })return false}e.field.files = JSON.stringify(files)e.field.is_show = e.field.is_show == 'on' ? 1 : 0console.log(e.field)submit('', e)return false})}
</script>
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/946284.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!相关文章
「学习笔记」PHP 基础
PHP 基础
和 C 与 C++一比,PHP 好方便啊。
基础格式
<?php // 开始
# 相关的代码
?> // 结束
/*注释
*/PHP 代码以 <?php 开始,以 ?> 结束。
变量、作用域
变量
PHP 是一门弱类型语言,因此定义变量…
关于我:新的开始,新的记录
关于我:新的开始,新的记录
大家好,我是 mengzhishanghun 👋
一名普通的Unreal Engine(UE)开发人员。以后,我将把技术文章和开发记录持续更新在博客园,与大家一起学习、交流、成长。所有复杂,皆可封装;所有重复…
关于 NoiLinux 系统和 CodeBlocks 的考场使用
捣鼓了好久呀,网上感觉资料好少,而且好多英文我也看不懂a(
1.首先是文件夹的位置,要保存在主目录而不是桌面,在考场上交的时候就让老师去主目录拷贝就好了吧应该
2025 年知识库应用平台最新推荐排行榜!企业 / 个人 / 协同 / 智能等多场景适配,附权威测评与选择指南
引言
数字化转型加速推动下,知识库应用已成为企业整合资源、提升效率的核心工具,但市场产品同质化严重,选择难度显著增加。本次榜单依托中国软件行业协会 2025 年企业级知识库工具测评报告,采用 “三维九维度” 评…
深入解析:深度学习调参指南:Batch Size的选择策略与实践
深入解析:深度学习调参指南:Batch Size的选择策略与实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consola…
layui静态表格防止被内容撑开变形
layui静态表格防止被内容撑开变形.ellipsis-cell {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
}.fixed-table {table-layout: fixed;
}<table class="layui-table fixed-table" lay…
2025 年最新推荐工作服实力厂家排行榜权威发布,助力企业精准挑选优质定制厂商商务 / 车间 / 企业 / 透气工作服厂家推荐
引言
当前工作服市场需求愈发多元,企业不仅要求工作服具备基础穿戴功能,更希望其成为展现品牌形象、传递企业文化的载体。但市场上制造商数量繁杂,质量、工艺、定制能力与服务保障差异显著,部分厂商缺乏专业设计团…
2025年废水处理厂家权威推荐榜单:工业废水、生活污水处理设备及解决方案供应商深度解析
2025年废水处理厂家权威推荐榜单:工业废水、生活污水处理设备及解决方案供应商深度解析
随着环保政策的日益严格和可持续发展理念的深入,废水处理行业正迎来前所未有的发展机遇。工业废水与生活污水处理作为环境保护…
基于Springboot的教学课程管理系统 - 指南
基于Springboot的教学课程管理系统 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "…
深入解析:【从图片到3D几何体/动画】3DMAX像素几何体插件PixelGeometry使用方法
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …
你的excel二级三级多级下拉菜单为啥不好用?讲清楚INDIRECT函数用法!
资料:
https://support.microsoft.com/zh-cn/office/indirect-%E5%87%BD%E6%95%B0-474b3a3a-8a26-4f44-b491-92b6306fa261本文以office2019 excel 为例。
通俗讲,INDIRECT函数根据参数值在名称管理器中查找已定义名称…
死锁 (Deadlock) 深度解析 - 详解
死锁 (Deadlock) 深度解析 - 详解pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco&q…
2025年家具厂家推荐排行榜:实木家具、定制家具、办公家具、软体家具、智能家具源头厂家精选
2025年家具厂家推荐排行榜:实木家具、定制家具、办公家具、软体家具、智能家具源头厂家精选
随着消费升级和居住理念的转变,家具行业正迎来新一轮发展机遇。实木家具以其天然环保的特性持续受到青睐,定制家具凭借个…
2025 厨房排烟安装公司最新推荐榜:实力品牌服务与工艺解析及选择指南饭店/商用/罩/系统/厨房排烟管道专业服务公司推荐
引言
厨房排烟系统安装质量直接关系商用厨房的安全运营与人员健康,但行业内 38% 的企业存在工艺不规范问题,27% 使用劣质材料导致故障频发。为破解选择难题,本次联合中国商用厨具协会开展权威测评,参照 T/CAS848-2…
2025年仿石漆厂家推荐排行榜,外墙仿石漆,内墙仿石漆,防霉仿石漆,水包水/水包砂仿石漆,耐污自洁仿石漆公司精选
2025年仿石漆厂家推荐排行榜:外墙仿石漆、内墙仿石漆、防霉仿石漆、水包水/水包砂仿石漆、耐污自洁仿石漆公司精选
在建筑装饰材料领域,仿石漆凭借其卓越的装饰效果和实用性能,已成为现代建筑外墙与内墙装饰的重要选…
权威调研榜单:苏州吊车租赁公司TOP3榜单好评深度解析
随着长三角地区基建项目持续推进,苏州吊车租赁市场需求显著增长。据行业数据显示,2025年苏州地区吊车租赁规模同比提升18%,其中起重吊装、龙门吊租赁、登高车租赁三类业务占比超60%。本文基于对企业设备规模、服务能…
从零开始制作 MyOS(二)
从零开始制作 MyOS(二)
目标
一个简单的,能打印出字符串的 boot 已经做完了,那么接下来做一个加载多个磁盘扇区的功能。
原因
BIOS 在找到一个可引导设备后,加载该引导设备的第一个扇区,也就是扇区号为 0 的扇区…
【Linux网络】Socket编程:UDP网络编程达成ChatServer
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …
完整教程:告别内网困局:cpolar破解Websocket远程访问难题
pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …