Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

article_download_add.htm 36KB

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