No Description
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_edit.htm 36KB

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