설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

article_download_add.htm 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <div id="xiazai">
  2. <div class="item-from-row">
  3. <div class="from-row-l">
  4. 下载限制:
  5. </div>
  6. <div class="from-row-r">
  7. <div class="w300 select">
  8. <select name="arc_level_id" id="arc_level_id">
  9. </select>
  10. </div>
  11. <span class="err"></span>
  12. <p class="notic"></p>
  13. </div>
  14. </div>
  15. <div class="item-from-row">
  16. <div class="from-row-l">
  17. 上传文件:
  18. </div>
  19. <div class="from-row-r">
  20. <div class="layui-upload" id="download-layui-upload">
  21. <button type="button" class="el-button el-button--primary is-plain el-button--small" id="buttonList" style="display: none;">选择多文件</button>
  22. <label><input type="checkbox" value="1" onclick="ClickRemoteFile(this);">远程地址</label>
  23. <div class="layui-upload-list">
  24. <table class="layui-table">
  25. <thead>
  26. <tr>
  27. <th>文件名</th>
  28. <th class="th_server_name" style="display: none;">服务器名称</th>
  29. <th>大小</th>
  30. <th>状态</th>
  31. <th>操作</th>
  32. </tr>
  33. </thead>
  34. <tbody id="demoList"></tbody>
  35. </table>
  36. </div>
  37. <div style="display: none;" id='ClickRemoteFile'>
  38. <div id='Template20210507'>
  39. </div>
  40. <a onclick="GetTemplateAddr(2);" class="fc-colours cursor-pointer">
  41. +更多远程地址
  42. </a>
  43. </div>
  44. <button style="display:none;" type="button" class="layui-btn" id="buttonListAction">批量重传</button>
  45. </div>
  46. <span class="err"></span>
  47. <p class="notic"></p>
  48. </div>
  49. </div>
  50. </div>
  51. <script type="text/javascript">
  52. var admin_id = "{$Think.session.users_id|default='1'}";
  53. var t2_1598602098 = '';
  54. function search_mouseover(th)
  55. {
  56. var sinput_id = $(th).attr('data-sinput_id');
  57. $('#search_keywords_list_'+sinput_id).show();
  58. try{
  59. clearTimeout(t2_1598602098);
  60. }catch(e){}
  61. }
  62. function search_mouseout(th)
  63. {
  64. var sinput_id = $(th).attr('data-sinput_id');
  65. var setFunc = $("#search_keywords_list_"+sinput_id).hide();
  66. t2_1598602098 = setTimeout('"'+setFunc+'"',1000);
  67. }
  68. function select_sname(th) {
  69. var sinput_id = $(th).attr('data-sinput_id');
  70. var sname = $(th).attr('data-sname');
  71. $("#"+sinput_id).val(sname);
  72. }
  73. function searchServername(th) {
  74. var sinput_id = $(th).attr('id');
  75. $.ajax({
  76. type: "POST",
  77. url: "{:url('Download/search_servername')}",
  78. data: {keyword:'',_ajax:1},
  79. dataType: 'json',
  80. cache: false,
  81. success: function (res) {
  82. if(res.code == 1){
  83. if (res.data.length > 0) {
  84. var html='';
  85. res.data.forEach(function(i,e) {
  86. var e_num = e+1;
  87. 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;">';
  88. html += '<div class="number c'+e_num+'">'+e_num+'</div>';
  89. html += '<div class="hottxt">'+i+'</div>';
  90. html += '</a>';
  91. });
  92. // return false;
  93. $('#search_keywords_list_'+sinput_id).html(html).show();
  94. } else {
  95. $('#search_keywords_list_'+sinput_id).hide();
  96. }
  97. } else {
  98. $('#search_keywords_list_'+sinput_id).hide();
  99. }
  100. }
  101. });
  102. }
  103. function round_num() {
  104. var num = '';
  105. for(var i=0;i<3;i++)
  106. {
  107. num+=Math.floor(Math.random()*10);
  108. }
  109. return num;
  110. }
  111. function judgeExt(ext) {
  112. var extArr = [];
  113. extArr = type20210507.split("|");
  114. var ext = ext.replace(".","");
  115. return extArr.indexOf(ext);
  116. }
  117. function cos_download__upload() {
  118. var cosFileObj = document.getElementById("cosFile").files;
  119. var formData = new FormData();
  120. formData.append('file_num', cosFileObj.length);
  121. for (var i = 0; i < cosFileObj.length; i++) {
  122. var file = cosFileObj[i];
  123. var fileName = file.name;
  124. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  125. var ext = judgeExt(fileExt);
  126. if (ext > -1) {
  127. // 追加显示在页面上
  128. var timestamp = new Date().getTime() + '-' + Math.ceil(Math.random()*100);
  129. var append_html = '';
  130. append_html += '<tr>';
  131. append_html += '<td>'+ file.name +'</td>';
  132. if (1 == servername_use20210507){
  133. append_html += '<td class="th_server_name">';
  134. } else {
  135. append_html += '<td class="th_server_name" style="display: none;">';
  136. }
  137. append_html += '<input type="text" name="fileupload[server_name][]" value="腾讯云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
  138. append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
  139. append_html += '</td>';
  140. append_html += '<td>'+ (file.size/1014).toFixed(1) +' KB</td>';
  141. append_html += '<td id="upload-'+ timestamp +'">上传腾讯云…请稍等</td>';
  142. append_html += '<td><a class="fc-colours cursor-pointer" onclick="DeleteFile(this);">移除</a>';
  143. append_html += '</td>';
  144. append_html += '</tr>';
  145. $("#demoList").append(append_html);
  146. // 表单提交数据
  147. formData.append('file_' + [i], cosFileObj[i]);
  148. formData.append('file_mime_' + [i], file.type);
  149. formData.append('file_name_' + [i], file.name);
  150. formData.append('file_size_' + [i], file.size);
  151. formData.append('file_ext_' + [i], fileExt);
  152. formData.append('file_tdid_' + [i], "#upload-" + timestamp);
  153. } else {
  154. showErrorMsg('不支持选中的文件格式,仅支持' + type20210507);
  155. }
  156. }
  157. // 上传提示
  158. layer.msg('上传腾讯云……&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font id="upgrade_backup_speed">0.01</font>%,请勿刷新', {icon: 1, time: 3600000, shade: [0.2]});
  159. layer.load(3, {shade: [0.1,'#fff']});
  160. $.ajax({
  161. type: 'post',
  162. url : "{:url('plugins/Cos/cos_multiple_upload')}",
  163. data: formData,
  164. contentType: false,
  165. processData: false,
  166. dataType: 'json',
  167. xhr: function () {
  168. myXhr = $.ajaxSettings.xhr();
  169. if (myXhr.upload) {
  170. myXhr.upload.addEventListener('progress', function(e) {
  171. var curr = e.loaded;
  172. var total = e.total;
  173. var process = parseInt(curr / total * 100);
  174. process = 100 == process ? 99 : process;
  175. $('#upgrade_backup_speed').html(process);
  176. });
  177. }
  178. return myXhr;
  179. },
  180. success: function(res) {
  181. layer.closeAll();
  182. try {
  183. if (1 == res.code) {
  184. var file_url = res.data.file_url;
  185. console.log(res.data)
  186. $.each(file_url, function(i, item) {
  187. var html = '';
  188. html += '<input type="hidden" name="fileupload[file_url][]" value="'+ file_url[i] +'">';
  189. html += '<input type="hidden" name="fileupload[file_mime][]" value="'+ res.data.file_mime[i] +'">';
  190. html += '<input type="hidden" name="fileupload[file_name][]" value="'+ res.data.file_name[i] +'">';
  191. html += '<input type="hidden" name="fileupload[file_size][]" value="'+ res.data.file_size[i] +'">';
  192. html += '<input type="hidden" name="fileupload[file_ext][]" value="'+ res.data.file_ext[i] +'">';
  193. $(res.data.file_tdid[i]).html('<span style="color: #5FB878;">上传成功</span>');
  194. $(res.data.file_tdid[i]).next().append(html);
  195. });
  196. } else {
  197. showErrorAlert('接口超时,部分上传腾讯云失败,请移除未上传成功的文件重新上传。');
  198. }
  199. } catch(e) {}
  200. },
  201. error: function(e){
  202. layer.closeAll();
  203. showErrorAlert(e.responseText);
  204. }
  205. });
  206. }
  207. function qny_download__upload() {
  208. var arr = [];
  209. for(var i = 0 ;i<document.getElementById("qnyFile").files.length;i++){
  210. file=document.getElementById("qnyFile").files[i];
  211. var fileName = file.name;
  212. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  213. var ext = judgeExt(fileExt);
  214. if (ext>-1) {
  215. var timestamp = new Date().getTime()+'-'+ Math.ceil(Math.random()*100);
  216. arr[i] = timestamp;
  217. var append_html = '';
  218. append_html += '<tr id="upload-'+ timestamp +'">';
  219. append_html += '<td>'+ file.name +'</td>';
  220. if (1 == servername_use20210507){
  221. append_html += '<td class="th_server_name">';
  222. }else{
  223. append_html += '<td class="th_server_name" style="display: none;">';
  224. }
  225. append_html += '<input type="text" name="fileupload[server_name][]" value="七牛云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
  226. append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
  227. append_html += '</td>';
  228. append_html += '<td>'+ (file.size/1014).toFixed(1) +' KB</td>';
  229. append_html += '<td>等待上传</td>';
  230. append_html += '<td><a class="fc-colours cursor-pointer" onclick="DeleteFile(this);">移除</a>';
  231. append_html += '</td>';
  232. append_html += '</tr>';
  233. $("#demoList").append(append_html);
  234. }else{
  235. showErrorMsg('不支持选中的文件格式,仅支持'+type20210507);
  236. }
  237. }
  238. var date = new Date();
  239. var y = date.getFullYear();
  240. var m = date.getMonth() + 1;
  241. m = m < 10 ? '0' + m : m;
  242. var d = date.getDate();
  243. d = d < 10 ? ('0' + d) : d;
  244. $.ajax({
  245. type: 'POST',
  246. url: "{:url('plugins/Qiniuyun/qiniu_upload')}",
  247. data: {_ajax:1,down:1},
  248. dataType: "JSON",
  249. success: function(res1){
  250. if (1 == res1.code){
  251. var token = res1.data.token;
  252. for(var i = 0 ;i<document.getElementById("qnyFile").files.length;i++) {
  253. file = document.getElementById("qnyFile").files[i];
  254. var fileName = file.name;
  255. var formData = new FormData();
  256. formData.append('token', token);
  257. formData.append('file', file);
  258. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  259. var num = round_num();
  260. var name = 'U'+admin_id+'-'+ new Date().getTime()+num+ fileExt;
  261. fileName = res1.data.filePath + y + m + d + "/"+ name;
  262. formData.append('key', fileName);
  263. var tr = $("#upload-" + arr[i]);
  264. new Promise(function() {
  265. var tr = $("#upload-" + arr[i]);
  266. var file_mime = file.type;
  267. var file_name = file.name;
  268. var file_size = file.size;
  269. var file_ext = fileExt;
  270. $.ajax({
  271. url: res1.data.uphost,
  272. type: 'POST',
  273. dataType: 'JSON',
  274. data: formData,
  275. timeout: 1200000,
  276. // async: false,
  277. cache: false,
  278. processData: false,
  279. contentType: false,
  280. xhr: function () {
  281. myXhr = $.ajaxSettings.xhr();
  282. if (myXhr.upload) {
  283. myXhr.upload.addEventListener('progress', function (e) {
  284. var curr = e.loaded;
  285. var total = e.total;
  286. process = parseInt(curr / total * 100);
  287. tr.children("td").eq(3).text('上传中...' + process + "%");
  288. });
  289. }
  290. return myXhr;
  291. },
  292. success: function (res2) {
  293. var video_url = res1.data.domain + "/" + res2.key;
  294. var html = '';
  295. html += '<input type="hidden" name="fileupload[file_url][]" value="'+ video_url +'">';
  296. html += '<input type="hidden" name="fileupload[file_mime][]" value="'+ file_mime +'">';
  297. html += '<input type="hidden" name="fileupload[file_name][]" value="'+ file_name +'">';
  298. html += '<input type="hidden" name="fileupload[file_ext][]" value="'+ file_ext +'">';
  299. html += '<input type="hidden" name="fileupload[file_size][]" value="'+ file_size +'">';
  300. var tds = tr.children();
  301. tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
  302. tds.eq(4).html('<a class="fc-colours cursor-pointer" onclick="DeleteFile(this);">移除</a>'+html);
  303. },
  304. error: function (e) {
  305. showErrorMsg(e.responseText);
  306. return false;
  307. }
  308. });
  309. })
  310. }
  311. }else{
  312. showErrorMsg(res1.msg);
  313. }
  314. },
  315. error: function(e){
  316. showErrorMsg(e.responseText);
  317. }
  318. });
  319. }
  320. function oss_download__upload() {
  321. var arr = [];
  322. for(var i = 0 ;i<document.getElementById("ossFile").files.length;i++){
  323. file=document.getElementById("ossFile").files[i];
  324. var fileName = file.name;
  325. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  326. var ext = judgeExt(fileExt);
  327. if (ext>-1) {
  328. //此时取出这个文件进行处理,这里只是显示文件名
  329. var timestamp = new Date().getTime() + '-' + Math.ceil(Math.random()*100);
  330. arr[i] = timestamp;
  331. var append_html = '';
  332. append_html += '<tr id="upload-'+ timestamp +'">';
  333. append_html += '<td>'+ file.name +'</td>';
  334. if (1 == servername_use20210507){
  335. append_html += '<td class="th_server_name">';
  336. }else{
  337. append_html += '<td class="th_server_name" style="display: none;">';
  338. }
  339. append_html += '<input type="text" name="fileupload[server_name][]" value="阿里云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
  340. append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
  341. append_html += '</td>';
  342. append_html += '<td>'+ (file.size/1014).toFixed(1) +' KB</td>';
  343. append_html += '<td>等待上传</td>';
  344. append_html += '<td><a class="fc-colours cursor-pointer" onclick="DeleteFile(this);">移除</a>';
  345. append_html += '</td>';
  346. append_html += '</tr>';
  347. $("#demoList").append(append_html);
  348. }else{
  349. showErrorMsg('不支持选中的文件格式,仅支持'+type20210507);
  350. }
  351. }
  352. var date = new Date();
  353. var y = date.getFullYear();
  354. var m = date.getMonth() + 1;
  355. m = m < 10 ? '0' + m : m;
  356. var d = date.getDate();
  357. d = d < 10 ? ('0' + d) : d;
  358. $.ajax({
  359. type: 'POST',
  360. url : "{:url('plugins/AliyunOss/oss_upload')}",
  361. data: {_ajax:1,down:1},
  362. dataType: "JSON",
  363. success: function(res1){
  364. if (1 == res1.code){
  365. var accessid = res1.data.accessid;
  366. var policy = res1.data.policy;
  367. var signature = res1.data.signature;
  368. var filePath = res1.data.filePath;
  369. for(var i = 0 ;i<document.getElementById("ossFile").files.length;i++) {
  370. file = document.getElementById("ossFile").files[i];
  371. var fileName = file.name;
  372. var request = new FormData();
  373. request.append("OSSAccessKeyId",accessid);
  374. request.append("policy",policy);
  375. request.append("Signature",signature);
  376. request.append("success_action_status",201);
  377. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  378. var num = round_num();
  379. //存储文件名
  380. var name = 'U'+admin_id+'-'+ new Date().getTime()+num+ fileExt;
  381. fileName = filePath + y + m + d + "/"+ name;
  382. request.append("key", fileName);
  383. request.append('file', file);
  384. var tr = $("#upload-" + arr[i]);
  385. new Promise(function() {
  386. var tr = $("#upload-" + arr[i]);
  387. var file_mime = file.type;
  388. var file_name = file.name;
  389. var file_size = file.size;
  390. var file_ext = fileExt;
  391. $.ajax({
  392. url: res1.data.host,
  393. data: request,
  394. processData: false,
  395. cache: false,
  396. contentType: false,
  397. dataType: 'xml',
  398. type : 'post',
  399. xhr: function () {
  400. myXhr = $.ajaxSettings.xhr();
  401. if (myXhr.upload) {
  402. myXhr.upload.addEventListener('progress', function (e) {
  403. var curr = e.loaded;
  404. var total = e.total;
  405. process = parseInt(curr / total * 100);
  406. tr.children("td").eq(3).text('上传中...' + process + "%");
  407. });
  408. }
  409. return myXhr;
  410. },
  411. success: function (res2) {
  412. var res = $(res2).find('PostResponse');
  413. if (res) {
  414. var key = res.find('Key').text();
  415. var video_url = res1.data.domain + "/" + key;
  416. var html = '';
  417. html += '<input type="hidden" name="fileupload[file_url][]" value="' + video_url + '">';
  418. html += '<input type="hidden" name="fileupload[file_mime][]" value="' + file_mime + '">';
  419. html += '<input type="hidden" name="fileupload[file_name][]" value="' + file_name + '">';
  420. html += '<input type="hidden" name="fileupload[file_ext][]" value="' + file_ext + '">';
  421. html += '<input type="hidden" name="fileupload[file_size][]" value="' + file_size + '">';
  422. var tds = tr.children();
  423. tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
  424. tds.eq(4).html('<a class="fc-colours cursor-pointer" onclick="DeleteFile(this);">移除</a>' + html);
  425. }
  426. },
  427. error: function (e) {
  428. showErrorMsg(e.responseText);
  429. return false;
  430. }
  431. });
  432. })
  433. }
  434. }else{
  435. showErrorMsg(res1.msg);
  436. }
  437. },
  438. error: function(e){
  439. showErrorMsg(e.responseText);
  440. }
  441. });
  442. }
  443. // 远程/本地上传文件切换
  444. function ClickRemoteFile(obj)
  445. {
  446. if ($(obj).is(':checked')) {
  447. var length = $(".template_div20210507").length;
  448. if (0 == length){
  449. var template_div20210507_html = '';
  450. for (var i=1;i<4;i++) {
  451. template_div20210507_html += '<div class="template_div20210507">\n' ;
  452. template_div20210507_html += '<div class="addrs">远程地址'+i+':<input type="text" name="remote_file[]" value="" placeholder="http://"></div>\n' ;
  453. $.each(attr_field20210507, function (index, value) {
  454. var field_use_style = '';
  455. if(1 != value.field_use){
  456. field_use_style = ' style="display: none;" ';
  457. }
  458. if('server_name' == value.field_name){
  459. template_div20210507_html += '<span class="ey_'+value.field_name+'" '+field_use_style+'>\n' +
  460. '<span class="title_'+value.field_name+'">'+value.field_title+'</span>:' +
  461. '<input type="text" name="'+value.field_name+'[]" id="'+value.field_name+'_remote_'+i+'" onclick="searchServername(this);" autocomplete="off" value="'+default_servername20210507+'" >\n' +
  462. '<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' +
  463. '</span>\n' ;
  464. }else{
  465. template_div20210507_html += '<span class="ey_'+value.field_name+'" '+field_use_style+'>\n' +
  466. '<span class="title_'+value.field_name+'">'+value.field_title+'</span>:' +
  467. '<input type="text" name="'+value.field_name+'[]" id="'+value.field_name+'_remote_'+i+'"></span>\n' ;
  468. }
  469. });
  470. template_div20210507_html += '</div>';
  471. }
  472. $("#Template20210507").html(template_div20210507_html);
  473. }
  474. $('#ClickRemoteFile').show();
  475. } else {
  476. $('#ClickRemoteFile').hide();
  477. }
  478. }
  479. // 获取模板属性数据
  480. function GetTemplateAddr(num){
  481. if (!num) {
  482. num = 1;
  483. }
  484. $.ajax({
  485. url: "{:url('Download/get_template', ['_ajax'=>1])}",
  486. data: {num:num},
  487. type:'post',
  488. dataType:'json',
  489. success: function(res){
  490. // 拼装模板属性并追加
  491. AddTemplateAddr(num,res.data);
  492. },
  493. });
  494. }
  495. // 删除对应的文件及文件信息
  496. function DeleteFile(obj){
  497. var filenames = $(obj).next().val();
  498. $(obj).parent().parent().remove();
  499. if (filenames) {
  500. var type20210507 = $('#download-layui-upload').attr('data-type');
  501. var url = '';
  502. if ('qny' == type20210507) {
  503. url = "{:url('plugins/Qiniuyun/deleteQny')}";
  504. }else if ('oss' == type20210507) {
  505. url = "{:url('plugins/AliyunOss/deleteOss')}";
  506. }else if ('cos' == type20210507) {
  507. url = "{:url('plugins/Cos/deleteCos')}";
  508. }else{
  509. url = "{:url('user/Uploadify/del_local')}";
  510. }
  511. $.ajax({
  512. type: 'GET',
  513. url: url,
  514. data: {_ajax: 1, filenames: filenames},
  515. success: function (res1) {
  516. }
  517. });
  518. }
  519. }
  520. // 拼装模板属性并追加
  521. function AddTemplateAddr(num,data){
  522. if (!num) {
  523. num = 1;
  524. }
  525. var SerialNum = $('#Template20210507 div.template_div20210507').length;
  526. var default_servername = default_servername20210507;
  527. var html_div = [];
  528. if (num > 1) {
  529. for (var i = 0; i < num; i++) {
  530. SerialNum++;
  531. html_div +=['<div class="template_div20210507">'];
  532. html_div +=['<div class="addrs">远程地址'+SerialNum+':<input type="text" name="remote_file[]" value="" placeholder="http://"></div> '];
  533. if (data) {
  534. for (var j = 0; j < data.length; j++) {
  535. if (data[j]['field_name'] == 'server_name') {
  536. if (data[j]['field_use'] == 1){
  537. html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
  538. }else {
  539. html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
  540. }
  541. 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+'" onclick="searchServername(this);" autocomplete="off" value="'+default_servername+'">'+
  542. '<div class="help-hot-list" style="display: none;" id="search_keywords_list_'+data[j]['field_name']+'_remote_'+SerialNum+'"></div>'+
  543. '</span>'];
  544. }else{
  545. if (data[j]['field_use'] == 1){
  546. html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
  547. }else {
  548. html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
  549. }
  550. 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+'"></span>'];
  551. }
  552. }
  553. }
  554. html_div +=['</div>'];
  555. }
  556. }else{
  557. SerialNum++;
  558. html_div +=
  559. ['<div class="template_div20210507">'];
  560. html_div +=
  561. ['<div class="addrs">远程地址'+SerialNum+':<input type="text" name="remote_file[]" value="" placeholder="http://"></div>'];
  562. if (data) {
  563. for (var j = 0; j < data.length; j++) {
  564. if (data[j]['field_name'] == 'server_name') {
  565. if (data[j]['field_use'] == 1){
  566. html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
  567. }else {
  568. html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
  569. }
  570. 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+'" onclick="searchServername(this);" autocomplete="off" value="'+default_servername+'">'+
  571. '<div class="help-hot-list" style="display: none;" id="search_keywords_list_'+data[j]['field_name']+'_remote_'+SerialNum+'"></div>'+
  572. '</span>'];
  573. }else{
  574. if (data[j]['field_use'] == 1){
  575. html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
  576. }else {
  577. html_div += ['<span style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
  578. }
  579. 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+'"></span>'];
  580. }
  581. }
  582. }
  583. html_div += ['</div>'];
  584. }
  585. // 追加html
  586. $('#Template20210507').append(html_div);
  587. }
  588. // 文件上传JS
  589. layui.use('upload', function(){
  590. var $ = layui.jquery,upload = layui.upload;
  591. // 多文件列表示例
  592. var demoListView = $('#demoList'),uploadListIns = upload.render({
  593. elem: '#buttonList',
  594. url: "{:url('user/Uploadify/DownloadUploadFile')}",
  595. accept: 'file',
  596. exts: type20210507,
  597. multiple: true,
  598. auto: true,
  599. bindAction: '#buttonListAction',
  600. choose: function(obj){
  601. // 将每次选择的文件追加到文件队列
  602. var files = this.files = obj.pushFile();
  603. // 读取本地文件
  604. obj.preview(function(index, file, result){
  605. if (1 == servername_use20210507) {
  606. var tr = $(
  607. [
  608. '<tr id="upload-' + index + '">',
  609. '<td>' + file.name + '</td>',
  610. '<td class="th_server_name"><input type="text" name="fileupload[server_name][]" value="'+default_servername20210507+'" id="severname_local_' + index + '" onclick="searchServername(this);" autocomplete="off">',
  611. '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_local_' + index + '"></div>',
  612. '</td>',
  613. '<td>' + (file.size / 1014).toFixed(1) + ' KB</td>',
  614. '<td>等待上传</td>',
  615. '<td>',
  616. // '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>',
  617. '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;">移除</button>',
  618. '</td>',
  619. '</tr>'
  620. ].join(''));
  621. }else{
  622. var tr = $(
  623. [
  624. '<tr id="upload-' + index + '">',
  625. '<td>' + file.name + '</td>',
  626. '<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">',
  627. '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_local_' + index + '"></div>',
  628. '</td>',
  629. '<td>' + (file.size / 1014).toFixed(1) + ' KB</td>',
  630. '<td>等待上传</td>',
  631. '<td>',
  632. // '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>',
  633. '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;">移除</button>',
  634. '</td>',
  635. '</tr>'
  636. ].join(''));
  637. }
  638. // 单个重传
  639. tr.find('.demo-reload').on('click', function(){
  640. obj.upload(index, file);
  641. });
  642. // 删除
  643. tr.find('.demo-delete').on('click', function(){
  644. // 删除对应的文件
  645. delete files[index];
  646. tr.remove();
  647. // 清空 input file 值,以免删除后出现同名文件不可选
  648. uploadListIns.config.elem.next()[0].value = '';
  649. });
  650. demoListView.append(tr);
  651. });
  652. },
  653. done: function(res, index, upload){
  654. console.log(res)
  655. if(res.code == 1){
  656. // 上传成功
  657. var html = '';
  658. html += '<input type="hidden" name="fileupload[file_url][]" value="'+res.file_url+'">';
  659. html += '<input type="hidden" name="fileupload[file_mime][]" value="'+res.file_mime+'">';
  660. html += '<input type="hidden" name="fileupload[file_name][]" value="'+res.file_name+'">';
  661. html += '<input type="hidden" name="fileupload[file_ext][]" value="'+res.file_ext+'">';
  662. html += '<input type="hidden" name="fileupload[file_size][]" value="'+res.file_size+'">';
  663. html += '<input type="hidden" name="fileupload[uhash][]" value="'+ res.uhash +'">';
  664. html += '<input type="hidden" name="fileupload[md5file][]" value="'+ res.md5file +'">';
  665. var tr = demoListView.find('tr#upload-'+ index),
  666. tds = tr.children();
  667. tds.eq(0).html(res.file_name);
  668. tds.eq(3).html('<span style="color: #5FB878;">'+res.msg+'</span>');
  669. tds.eq(4).html('<a class="fc-colours cursor-pointer" onclick="DeleteFile(this);">移除</a>'+html);
  670. // 清空操作
  671. return delete this.files[index];// 删除文件队列已经上传成功的文件
  672. }
  673. this.error(res, index, upload);
  674. },
  675. error: function(res, index, upload){
  676. var tr = demoListView.find('tr#upload-'+ index),
  677. tds = tr.children();
  678. tds.eq(3).html('<span style="color: #FF5722;">'+res.msg+'</span>');
  679. }
  680. });
  681. });
  682. </script>