| | |
| | | var treeCond; |
| | | var admin; |
| | | var planNeedXmlSelData; |
| | | var planNeedXmlFileId; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).extend({ |
| | |
| | | ,url: '/plan/insert/file/auth' //此处用的是第三方的 http 请求演示,实际使用时改成您自己的上传接口即可。 |
| | | ,accept: 'file' |
| | | ,multiple: true |
| | | ,number: 3 |
| | | ,number: 10 |
| | | ,auto: false |
| | | ,bindAction: '#testListAction' |
| | | ,choose: function(obj){ |
| | | // 赋值 |
| | | this.data.planId=$('.layui-layer-title').text() |
| | | var that = this; |
| | | var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列 |
| | | //读取本地文件 |
| | |
| | | case "uploadLink": |
| | | // 打开弹窗 |
| | | // 构建带参数的内容 |
| | | planNeedXmlFileId = data.id; |
| | | layer.open({ |
| | | type: 1, |
| | | title: '上传文件', |
| | | title: '上传文件-'+data.id, |
| | | content: $('#myModal') |
| | | }); |
| | | // 获取路径下的文件列表,使用 jQuery 的 ajax 方法 |
| | | $.ajax({ |
| | | url: '/plan/view/file/auth', |
| | | data:{ |
| | | planId:data.id |
| | | }, |
| | | success: function(response) { |
| | | if (response.code==200){ |
| | | var targetTable = document.getElementById("data-btn-file3"); |
| | | // var targetTable1 = document.getElementById("layui-layer2"); |
| | | // // 获取文本内容 |
| | | // var text = targetTable1.textContent.trim(); |
| | | // console.log(text); // 输出 '上传文件-20' |
| | | targetTable.innerHTML = ''; |
| | | // 将获取到的文件列表添加到文件队列中进行显示 |
| | | response.data.forEach(function(file,index) { |
| | | // 创建tr元素 |
| | | var tr = document.createElement("tr"); |
| | | tr.id = "upload-"+index; |
| | | tr.innerHTML = '<td>' + file.name + '</td>' |
| | | + '<td>' + (file.size / 1024).toFixed(1) + 'kb</td>' |
| | | + '<td><div class="layui-progress" lay-filter="progress-demo-' + index + '"><div class="layui-progress-bar" lay-percent=""></div></div></td>' |
| | | + '<td>' |
| | | + '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>' |
| | | + '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>' |
| | | + '</td>'; |
| | | |
| | | // 将tr元素添加到目标table中 |
| | | targetTable.appendChild(tr); |
| | | }); |
| | | }else { |
| | | console.log('Failed to get file list error.'); |
| | | } |
| | | }, |
| | | error: function() { |
| | | console.log('Failed to get file list.'); |
| | | } |
| | | }); |
| | | break; |
| | | } |
| | | }); |