123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712 |
- <div class="item-from-flex">
- <div class="item-flex-l">
- <div class="item-tit">下载限制:</div>
- <div class="item-con">
- <div class="select">
- <select name="arc_level_id" id="arc_level_id"></select>
- </div>
- </div>
- </div>
- <div class="item-flex-r"> <i class="el-icon-arrow-right"></i> </div>
- </div>
-
- <div class="item-from-flex">
- <div class="item-flex-l">
- <div class="item-tit">上传文件:</div>
- <div class="item-con">
- <div class="layui-upload" id="download-layui-upload">
- <button type="button" class="addr_y none" id="buttonList">选择多文件</button>
- <label><input type="checkbox" value="1" onclick="ClickRemoteFile(this);">远程地址</label>
- </div>
- </div>
- </div>
- </div>
-
- <div class="item-from-flex pt0">
- <div class="layui-upload-list mt0" style="overflow: auto;">
- <div class="layui-upload-list mt0">
- <table class="layui-table article-download-table mt0">
- <thead>
- <tr>
- <th>文件名</th>
- <th class="th_server_name" style="display: none;">服务器名称</th>
- <th class="th_server_size">大小</th>
- <th class="th_server_state">状态</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody id="demoList"></tbody>
- </table>
- </div>
-
- <div style="display: none;" id='ClickRemoteFile'>
- <div id='Template20210507'>
-
- </div>
- <a class="add_download" onclick="GetTemplateAddr(2);">
- +添加远程地址
- </a>
- </div>
- <button style="display:none;" type="button" class="layui-btn" id="buttonListAction">批量重传</button>
- </div>
- </div>
- <script type="text/javascript">
- var admin_id = "{$Think.session.users_id|default='1'}";
- var t2_1598602098 = '';
-
- function search_mouseover(th)
- {
- var sinput_id = $(th).attr('data-sinput_id');
- $('#search_keywords_list_'+sinput_id).show();
- try{
- clearTimeout(t2_1598602098);
- }catch(e){}
- }
-
- function search_mouseout(th)
- {
- var sinput_id = $(th).attr('data-sinput_id');
- var setFunc = $("#search_keywords_list_"+sinput_id).hide();
- t2_1598602098 = setTimeout('"'+setFunc+'"',1000);
- }
- function select_sname(th) {
- var sinput_id = $(th).attr('data-sinput_id');
- var sname = $(th).attr('data-sname');
- $("#"+sinput_id).val(sname);
- }
- function searchServername(th) {
- var sinput_id = $(th).attr('id');
- $.ajax({
- type: "POST",
- url: "{:url('Download/search_servername')}",
- data: {keyword:'',_ajax:1},
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.code == 1){
- if (res.data.length > 0) {
- var html='';
- res.data.forEach(function(i,e) {
- var e_num = e+1;
- html += '<a href="javascript:void(0);" onclick="select_sname(this);" onmouseover="search_mouseover(this);" onmouseout="search_mouseout(this);" data-sname="'+i+'" data-sinput_id="'+sinput_id+'" style="cursor: pointer;">';
- html += '<div class="number c'+e_num+'">'+e_num+'</div>';
- html += '<div class="hottxt">'+i+'</div>';
- html += '</a>';
- });
- // return false;
-
- $('#search_keywords_list_'+sinput_id).html(html).show();
- } else {
- $('#search_keywords_list_'+sinput_id).hide();
- }
- } else {
- $('#search_keywords_list_'+sinput_id).hide();
- }
- }
- });
- }
- function round_num() {
- var num = '';
- for(var i=0;i<3;i++)
- {
- num+=Math.floor(Math.random()*10);
- }
- return num;
- }
- function judgeExt(ext) {
- var extArr = [];
- extArr = type20210507.split("|");
- var ext = ext.replace(".","");
-
- return extArr.indexOf(ext);
- }
- function cos_download__upload() {
- var cosFileObj = document.getElementById("cosFile").files;
- var formData = new FormData();
- formData.append('file_num', cosFileObj.length);
- for (var i = 0; i < cosFileObj.length; i++) {
- var file = cosFileObj[i];
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExt(fileExt);
- if (ext > -1) {
- // 追加显示在页面上
- var timestamp = new Date().getTime() + '-' + Math.ceil(Math.random()*100);
- var append_html = '';
- append_html += '<tr>';
- append_html += '<td>'+ file.name +'</td>';
- if (1 == servername_use20210507){
- append_html += '<td class="th_server_name">';
- } else {
- append_html += '<td class="th_server_name" style="display: none;">';
- }
- append_html += '<input type="text" name="fileupload[server_name][]" value="腾讯云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
- append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
- append_html += '</td>';
- append_html += '<td class="th_server_size">'+ (file.size/1014).toFixed(1) +' KB</td>';
- append_html += '<td class="th_server_state" id="upload-'+ timestamp +'">上传腾讯云…请稍等</td>';
- append_html += '<td><button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</button>';
- append_html += '</td>';
- append_html += '</tr>';
- $("#demoList").append(append_html);
-
- // 表单提交数据
- formData.append('file_' + [i], cosFileObj[i]);
- formData.append('file_mime_' + [i], file.type);
- formData.append('file_name_' + [i], file.name);
- formData.append('file_size_' + [i], file.size);
- formData.append('file_ext_' + [i], fileExt);
- formData.append('file_tdid_' + [i], "#upload-" + timestamp);
- } else {
- showErrorMsg('不支持选中的文件格式,仅支持' + type20210507);
- }
- }
- // 上传提示
- layer.msg('上传腾讯云…… <font id="upgrade_backup_speed">0.01</font>%,请勿刷新', {icon: 1, time: 3600000, shade: [0.2]});
- layer.load(3, {shade: [0.1,'#fff']});
- $.ajax({
- type: 'post',
- url : "{:url('plugins/Cos/cos_multiple_upload')}",
- data: formData,
- contentType: false,
- processData: false,
- dataType: 'json',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e) {
- var curr = e.loaded;
- var total = e.total;
- var process = parseInt(curr / total * 100);
- process = 100 == process ? 99 : process;
- $('#upgrade_backup_speed').html(process);
-
- });
- }
- return myXhr;
- },
- success: function(res) {
- layer.closeAll();
- try {
- if (1 == res.code) {
- var file_url = res.data.file_url;
- $.each(file_url, function(i, item) {
- var html = '';
- html += '<input type="hidden" name="fileupload[file_url][]" value="'+ file_url[i] +'">';
- html += '<input type="hidden" name="fileupload[file_mime][]" value="'+ res.data.file_mime[i] +'">';
- html += '<input type="hidden" name="fileupload[file_name][]" value="'+ res.data.file_name[i] +'">';
- html += '<input type="hidden" name="fileupload[file_size][]" value="'+ res.data.file_size[i] +'">';
- html += '<input type="hidden" name="fileupload[file_ext][]" value="'+ res.data.file_ext[i] +'">';
- $(res.data.file_tdid[i]).html('<span style="color: #5FB878;">上传成功</span>' + html);
- });
- } else {
- showErrorAlert('接口超时,部分上传腾讯云失败,请移除未上传成功的文件重新上传。');
- }
- } catch(e) {}
- },
- error: function(e){
- layer.closeAll();
- showErrorAlert(e.responseText);
- }
- });
- }
- function qny_download__upload() {
- var arr = [];
- for(var i = 0 ;i<document.getElementById("qnyFile").files.length;i++){
- file=document.getElementById("qnyFile").files[i];
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExt(fileExt);
- if (ext>-1) {
- var timestamp = new Date().getTime()+'-'+ Math.ceil(Math.random()*100);
- arr[i] = timestamp;
- var append_html = '';
- append_html += '<tr id="upload-'+ timestamp +'">';
- append_html += '<td>'+ file.name +'</td>';
- if (1 == servername_use20210507){
- append_html += '<td class="th_server_name">';
- }else{
- append_html += '<td class="th_server_name" style="display: none;">';
- }
- append_html += '<input type="text" name="fileupload[server_name][]" value="七牛云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
- append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
- append_html += '</td>';
- append_html += '<td class="th_server_size">'+ (file.size/1014).toFixed(1) +' KB</td>';
- append_html += '<td class="th_server_state">等待上传</td>';
- append_html += '<td><button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</button>';
- append_html += '</td>';
- append_html += '</tr>';
- $("#demoList").append(append_html);
- }else{
- showErrorMsg('不支持选中的文件格式,仅支持'+type20210507);
- }
- }
-
- var date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? '0' + m : m;
- var d = date.getDate();
- d = d < 10 ? ('0' + d) : d;
- $.ajax({
- type: 'POST',
- url: "{:url('plugins/Qiniuyun/qiniu_upload')}",
- data: {_ajax:1,down:1},
- dataType: "JSON",
- success: function(res1){
- if (1 == res1.code){
- var token = res1.data.token;
- for(var i = 0 ;i<document.getElementById("qnyFile").files.length;i++) {
- file = document.getElementById("qnyFile").files[i];
-
- var fileName = file.name;
- var formData = new FormData();
- formData.append('token', token);
- formData.append('file', file);
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var num = round_num();
- var name = 'U'+admin_id+'-'+ new Date().getTime()+num+ fileExt;
- fileName = res1.data.filePath + y + m + d + "/"+ name;
- formData.append('key', fileName);
- var tr = $("#upload-" + arr[i]);
- new Promise(function() {
- var tr = $("#upload-" + arr[i]);
- var file_mime = file.type;
- var file_name = file.name;
- var file_size = file.size;
- var file_ext = fileExt;
- $.ajax({
- url: res1.data.uphost,
- type: 'POST',
- dataType: 'JSON',
- data: formData,
- timeout: 1200000,
- // async: false,
- cache: false,
- processData: false,
- contentType: false,
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function (e) {
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- tr.children("td").eq(3).text('上传中...' + process + "%");
- });
- }
- return myXhr;
- },
- success: function (res2) {
- var video_url = res1.data.domain + "/" + res2.key;
- //
- var html = '';
- html += '<input type="hidden" name="fileupload[file_url][]" value="'+ video_url +'">';
- html += '<input type="hidden" name="fileupload[file_mime][]" value="'+ file_mime +'">';
- html += '<input type="hidden" name="fileupload[file_name][]" value="'+ file_name +'">';
- html += '<input type="hidden" name="fileupload[file_ext][]" value="'+ file_ext +'">';
- html += '<input type="hidden" name="fileupload[file_size][]" value="'+ file_size +'">';
-
- var tds = tr.children();
- tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
- tds.eq(4).html('<span class="layui-btn layui-btn-xs layui-btn-danger" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</span>'+html);
-
- },
- error: function (e) {
- showErrorMsg(e.responseText);
- return false;
- }
- });
- })
- }
- }else{
- showErrorMsg(res1.msg);
- }
- },
- error: function(e){
- showErrorMsg(e.responseText);
- }
- });
-
- }
-
- function oss_download__upload() {
- var arr = [];
- for(var i = 0 ;i<document.getElementById("ossFile").files.length;i++){
- file=document.getElementById("ossFile").files[i];
-
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExt(fileExt);
- if (ext>-1) {
- //此时取出这个文件进行处理,这里只是显示文件名
- var timestamp = new Date().getTime() + '-' + Math.ceil(Math.random()*100);
- arr[i] = timestamp;
- var append_html = '';
- append_html += '<tr id="upload-'+ timestamp +'">';
- append_html += '<td>'+ file.name +'</td>';
- if (1 == servername_use20210507){
- append_html += '<td class="th_server_name">';
- }else{
- append_html += '<td class="th_server_name" style="display: none;">';
- }
- append_html += '<input type="text" name="fileupload[server_name][]" value="阿里云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
- append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
- append_html += '</td>';
- append_html += '<td class="th_server_size">'+ (file.size/1014).toFixed(1) +' KB</td>';
- append_html += '<td class="th_server_state">等待上传</td>';
- append_html += '<td><button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</button>';
- append_html += '</td>';
- append_html += '</tr>';
- $("#demoList").append(append_html);
- }else{
- showErrorMsg('不支持选中的文件格式,仅支持'+type20210507);
- }
- }
- var date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? '0' + m : m;
- var d = date.getDate();
- d = d < 10 ? ('0' + d) : d;
-
- $.ajax({
- type: 'POST',
- url : "{:url('plugins/AliyunOss/oss_upload')}",
- data: {_ajax:1,down:1},
- dataType: "JSON",
- success: function(res1){
- if (1 == res1.code){
- var accessid = res1.data.accessid;
- var policy = res1.data.policy;
- var signature = res1.data.signature;
- var filePath = res1.data.filePath;
- for(var i = 0 ;i<document.getElementById("ossFile").files.length;i++) {
- file = document.getElementById("ossFile").files[i];
- var fileName = file.name;
-
- var request = new FormData();
- request.append("OSSAccessKeyId",accessid);
- request.append("policy",policy);
- request.append("Signature",signature);
- request.append("success_action_status",201);
-
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var num = round_num();
- //存储文件名
- var name = 'U'+admin_id+'-'+ new Date().getTime()+num+ fileExt;
- fileName = filePath + y + m + d + "/"+ name;
-
- request.append("key", fileName);
- request.append('file', file);
-
- var tr = $("#upload-" + arr[i]);
- new Promise(function() {
- var tr = $("#upload-" + arr[i]);
- var file_mime = file.type;
- var file_name = file.name;
- var file_size = file.size;
- var file_ext = fileExt;
- $.ajax({
- url: res1.data.host,
- data: request,
- processData: false,
- cache: false,
- contentType: false,
- dataType: 'xml',
- type : 'post',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function (e) {
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- tr.children("td").eq(3).text('上传中...' + process + "%");
- });
- }
-
- return myXhr;
- },
- success: function (res2) {
- var res = $(res2).find('PostResponse');
- if (res) {
- var key = res.find('Key').text();
- var video_url = res1.data.domain + "/" + key;
- var html = '';
- html += '<input type="hidden" name="fileupload[file_url][]" value="' + video_url + '">';
- html += '<input type="hidden" name="fileupload[file_mime][]" value="' + file_mime + '">';
- html += '<input type="hidden" name="fileupload[file_name][]" value="' + file_name + '">';
- html += '<input type="hidden" name="fileupload[file_ext][]" value="' + file_ext + '">';
- html += '<input type="hidden" name="fileupload[file_size][]" value="' + file_size + '">';
-
- var tds = tr.children();
- tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
- tds.eq(4).html('<span class="layui-btn layui-btn-xs layui-btn-danger" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</span>' + html);
- }
-
- },
- error: function (e) {
- showErrorMsg(e.responseText);
- return false;
- }
- });
- })
- }
- }else{
- showErrorMsg(res1.msg);
- }
- },
- error: function(e){
- showErrorMsg(e.responseText);
- }
- });
- }
-
- // 远程/本地上传文件切换
- function ClickRemoteFile(obj)
- {
- if ($(obj).is(':checked')) {
- var length = $(".template_div20210507").length;
- if (0 == length){
- var template_div20210507_html = '';
- for (var i=1;i<4;i++) {
- template_div20210507_html += '<div class="template_div20210507"><div style=" display: block; margin-bottom: 5px; ">远程地址'+i+':<input type="text" name="remote_file[]" value="" placeholder="http://" style="width: 250px;"></div>\n' ;
- $.each(attr_field20210507, function (index, value) {
- var field_use_style = '';
- if(1 != value.field_use){
- field_use_style = ' style="display: none;" ';
- }
- if('server_name' == value.field_name){
- template_div20210507_html += '<span class="ey_'+value.field_name+'" '+field_use_style+'>\n' +
- '<span class="title_'+value.field_name+'">'+value.field_title+'</span>:' +
- '<input type="text" name="'+value.field_name+'[]" id="'+value.field_name+'_remote_'+i+'" style="width: 80px;" onclick="searchServername(this);" autocomplete="off" value="'+default_servername20210507+'" >\n' +
- '<div class="help-hot-list remote-hot-list" style="display: none;" data-test_val="5434" id="search_keywords_list_'+value.field_name+'_remote_'+i+'"></div>\n' +
- '</span>\n' ;
- }else{
- template_div20210507_html += '<span class="ey_'+value.field_name+'" '+field_use_style+'>\n' +
- '<span class="title_'+value.field_name+'">'+value.field_title+'</span>:' +
- '<input type="text" name="'+value.field_name+'[]" id="'+value.field_name+'_remote_'+i+'" style="width: 80px;"></span>\n' ;
- }
- });
-
- template_div20210507_html += '</div>';
- }
- $("#Template20210507").html(template_div20210507_html);
- }
- $('#ClickRemoteFile').show();
- } else {
- $('#ClickRemoteFile').hide();
- }
- }
-
- // 获取模板属性数据
- function GetTemplateAddr(num){
- if (!num) {
- num = 1;
- }
- $.ajax({
- url: "{:url('Download/get_template', ['_ajax'=>1])}",
- data: {num:num},
- type:'post',
- dataType:'json',
- success: function(res){
- // 拼装模板属性并追加
- AddTemplateAddr(num,res.data);
- },
- });
- }
-
- // 删除对应的文件及文件信息
- function DeleteFile(obj){
- var filenames = $(obj).next().val();
- $(obj).parent().parent().remove();
- if (filenames) {
- var type20210507 = $('#download-layui-upload').attr('data-type');
- var url = '';
- if ('qny' == type20210507) {
- url = "{:url('plugins/Qiniuyun/deleteQny')}";
- }else if ('oss' == type20210507) {
- url = "{:url('plugins/AliyunOss/deleteOss')}";
- }else if ('cos' == type20210507) {
- url = "{:url('plugins/Cos/deleteCos')}";
- }else{
- url = "{:url('user/Uploadify/del_local')}";
- }
- $.ajax({
- type: 'GET',
- url: url,
- data: {_ajax: 1, filenames: filenames},
- success: function (res1) {
- }
- });
- }
- }
-
- // 拼装模板属性并追加
- function AddTemplateAddr(num,data){
- if (!num) {
- num = 1;
- }
- var SerialNum = $('#Template20210507 div.template_div20210507').length;
- var default_servername = default_servername20210507;
- var html_div = [];
- if (num > 1) {
- for (var i = 0; i < num; i++) {
- SerialNum++;
- html_div +=['<div class="template_div20210507"><div style=" display: block; margin-bottom: 8px; ">远程地址'+SerialNum+':<input type="text" name="remote_file[]" value="" placeholder="http://" style="width: 250px;"></div> '];
-
- if (data) {
- for (var j = 0; j < data.length; j++) {
- if (data[j]['field_name'] == 'server_name') {
- if (data[j]['field_use'] == 1){
- html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
- }else {
- html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
- }
- html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>:<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_remote_'+SerialNum+'" style="width: 80px;" onclick="searchServername(this);" autocomplete="off" value="'+default_servername+'">'+
- '<div class="help-hot-list" style="display: none;" id="search_keywords_list_'+data[j]['field_name']+'_remote_'+SerialNum+'"></div>'+
- '</span>'];
- }else{
- if (data[j]['field_use'] == 1){
- html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
- }else {
- html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
- }
- html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>:<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_'+SerialNum+'" style="width: 80px;"></span>'];
- }
- }
- }
-
- html_div +=['</div>'];
- }
- }else{
- SerialNum++;
- html_div +=
- ['<div class="template_div20210507"><div style=" display: block; margin-bottom: 8px; ">远程地址'+SerialNum+':<input type="text" name="remote_file[]" value="" placeholder="http://" style="width: 250px;"></div>'];
- if (data) {
- for (var j = 0; j < data.length; j++) {
- if (data[j]['field_name'] == 'server_name') {
- if (data[j]['field_use'] == 1){
- html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
- }else {
- html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
- }
- html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>:<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_remote_'+SerialNum+'" style="width: 80px;" onclick="searchServername(this);" autocomplete="off" value="'+default_servername+'">'+
- '<div class="help-hot-list" style="display: none;" id="search_keywords_list_'+data[j]['field_name']+'_remote_'+SerialNum+'"></div>'+
- '</span>'];
- }else{
- if (data[j]['field_use'] == 1){
- html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
- }else {
- html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
- }
- html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>:<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_'+SerialNum+'" style="width: 80px;"></span>'];
- }
- }
- }
- html_div += ['</div>'];
- }
-
- // 追加html
- $('#Template20210507').append(html_div);
- }
-
- // 文件上传JS
- layui.use('upload', function(){
- var $ = layui.jquery,upload = layui.upload;
- // 多文件列表示例
- var demoListView = $('#demoList'),uploadListIns = upload.render({
- elem: '#buttonList',
- url: "{:url('user/Uploadify/DownloadUploadFile')}",
- accept: 'file',
- exts: type20210507,
- multiple: true,
- auto: true,
- bindAction: '#buttonListAction',
- choose: function(obj){
- // 将每次选择的文件追加到文件队列
- var files = this.files = obj.pushFile();
- // 读取本地文件
- obj.preview(function(index, file, result){
- if (1 == servername_use20210507) {
- var tr = $(
- [
- '<tr id="upload-' + index + '">',
- '<td>' + file.name + '</td>',
- '<td class="th_server_name"><input type="text" name="fileupload[server_name][]" value="'+default_servername20210507+'" id="severname_local_' + index + '" onclick="searchServername(this);" autocomplete="off">',
- '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_local_' + index + '"></div>',
- '</td>',
- '<td class="th_server_size">' + (file.size / 1014).toFixed(1) + ' KB</td>',
- '<td class="th_server_state">等待上传</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" style="line-height:unset;height: unset;">移除</button>',
- '</td>',
- '</tr>'
- ].join(''));
- }else{
- var tr = $(
- [
- '<tr id="upload-' + index + '">',
- '<td>' + file.name + '</td>',
- '<td class="th_server_name" style="display: none;"><input type="text" name="fileupload[server_name][]" value="'+default_servername20210507+'" id="severname_local_' + index + '" onclick="searchServername(this);" autocomplete="off">',
- '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_local_' + index + '"></div>',
- '</td>',
- '<td class="th_server_size">' + (file.size / 1014).toFixed(1) + ' KB</td>',
- '<td class="th_server_state">等待上传</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" style="line-height:unset;height: unset;">移除</button>',
- '</td>',
- '</tr>'
- ].join(''));
- }
-
- // 单个重传
- tr.find('.demo-reload').on('click', function(){
- obj.upload(index, file);
- });
-
- // 删除
- tr.find('.demo-delete').on('click', function(){
- // 删除对应的文件
- delete files[index];
- tr.remove();
- // 清空 input file 值,以免删除后出现同名文件不可选
- uploadListIns.config.elem.next()[0].value = '';
- });
- demoListView.append(tr);
- });
- },
- done: function(res, index, upload){
- if(res.code == 1){
- // 上传成功
- var html = '';
- html += '<input type="hidden" name="fileupload[file_url][]" value="'+res.file_url+'">';
- html += '<input type="hidden" name="fileupload[file_mime][]" value="'+res.file_mime+'">';
- html += '<input type="hidden" name="fileupload[file_name][]" value="'+res.file_name+'">';
- html += '<input type="hidden" name="fileupload[file_ext][]" value="'+res.file_ext+'">';
- html += '<input type="hidden" name="fileupload[file_size][]" value="'+res.file_size+'">';
- html += '<input type="hidden" name="fileupload[uhash][]" value="'+res.uhash+'">';
- html += '<input type="hidden" name="fileupload[md5file][]" value="'+res.md5file+'">';
-
- var tr = demoListView.find('tr#upload-'+ index),
- tds = tr.children();
- tds.eq(0).html(res.file_name);
- tds.eq(3).html('<span style="color: #5FB878;">'+res.msg+'</span>');
- tds.eq(4).html('<span class="layui-btn layui-btn-xs layui-btn-danger" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</span>'+html);
-
- // 清空操作
- return delete this.files[index];// 删除文件队列已经上传成功的文件
- }
- this.error(res, index, upload);
- },
- error: function(res, index, upload){
- var tr = demoListView.find('tr#upload-'+ index),
- tds = tr.children();
- tds.eq(3).html('<span style="color: #FF5722;">'+res.msg+'</span>');
- }
- });
- });
- </script>
|