Commit 6da8f84d by 周业恒

media_list

parent 87e99257
Pipeline #20524 passed with stages
in 1 minute 0 seconds
......@@ -168,27 +168,19 @@
<script type="text/javascript">
var media_export_name="<?php $export_values='<tr><td>id</td><td>名称</td>></tr>'; foreach ($medias as $key => $media) { $export_values=$export_values.'<tr><td>${'.$media['_id'].`'\t'}</td>'`.'<td>${'.$media['media_name'].`'\t'}</td>'`.'</tr>'; } echo $export_values; ?>"
var media_export_name="<?php $export_values='id,名称'; foreach ($medias as $key => $media) { $export_values=$export_values.'${'.$media['_id'].`'\t'},'`.'${'.$media['media_name'].`'\t'}'`.'\n'; } echo $export_values; ?>"
function export_media_id(){
//alert(media_export_name)
const uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(media_export_name);
// 通过创建a标签实现
const link = document.createElement("a");
link.href = uri;
// 对下载的文件命名
link.download = "json数据表.csv";
link.click();
const worksheet = 'Sheet1'
const uri = 'data:application/vnd.ms-excel;base64,';
// 下载的表格模板数据
const template = `<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>${worksheet}</x:Name>
<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
</head><body><table>${media_export_name}</table></body></html>`;
// 下载模板
window.location.href = uri + base64(template);
}
const base64 = s => window.btoa(unescape(encodeURIComponent(s)));
function x_admin_show(url){
window.location.href = url;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment