| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- {extend name="common/common2" /}
- {block name="main"}
- <div class="ibox-content">
- <div class="ibox">
- <div class="alert">
- <form action="daily" method="GET" id='search_form' class="form-inline">
- <span class="input-group-btn">
- <button title="导出" class="btn-sm btn-primary" onclick="exportTableToExcel(this)" type="button" ><i class="fa fa-cloud-download"></i></button>
- </span>
- </form>
- </div>
- <div class="panel-group">
- <div class="panel panel-default">
- <div class="panel-heading clearfix">
- <div class="btn-group pull-left">
- {$meta_title}
- </div>
- </div>
- <div class="panel-body" id="printer">
- <table class="table table-bordered" id="table">
- <thead>
- <tr>
- <th>任务地点</th>
- <th>总数</th>
- <th>本月</th>
- <th>本周</th>
- <th>今天</th>
- </tr>
- </thead>
- <tbody>
- {foreach $data.list as $k=>$v}
- <tr>
- <td>{$v['title']}</td>
- <td>{$v['count']}</td>
- <td>{$v['count1']}</td>
- <td>{$v['count2']}</td>
- <td>{$v['count3']}</td>
- </tr>
- {/foreach}
- <tr>
- <td style="text-align: right;"><strong>合计</strong></td>
- <td>{$data['count']}</td>
- <td>{$data['count1']}</td>
- <td>{$data['count2']}</td>
- <td>{$data['count3']}</td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- {/block}
- {block name="script"}
- <script src="/static/browser.js"></script>
- <script src="/static/xlsx.full.min.js"></script>
- <script type="text/javascript">
- function empty_search(){
- window.location.href = 'duration';
- }
- $(function () {
- laydate.render({
- elem: '#dialog-datetime1'
- ,type: 'month',
- theme:'#284a94'
- });
- })
- function exportTableToExcel() {
- // 获取表格元素
- const table = document.getElementById('table');
- // 将表格转换为工作表
- const ws = XLSX.utils.table_to_sheet(table);
- const filename = '日常工作量统计'+'.xlsx';
- // 设置单元格宽度
- // 示例:设置每列的宽度
- ws['!cols'] = [
- { wch: 20 },
- { wch: 10 },
- { wch: 10 },
- { wch: 10 },
- // 根据需要继续添加更多列的宽度设置
- ];
- // 设置订单编号列的格式为文本
- // 假设订单编号在第1列(A列)
- const range = XLSX.utils.decode_range(ws['!ref']);
- for (let R = range.s.r; R <= range.e.r; ++R) {
- for (let C = range.s.c; C <= range.e.c; ++C) {
- const cellRef = XLSX.utils.encode_cell({ r: R, c: C });
- if (!ws[cellRef]) continue;
- // 设置样式
- ws[cellRef].s = {
- alignment: {
- horizontal: 'left',
- vertical: 'center' // 可选:垂直居中
- }
- };
- }
- }
- // 创建工作簿并添加工作表
- const wb = XLSX.utils.book_new();
- XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
- // 导出为 Excel 文件
- XLSX.writeFile(wb, filename || 'tableExport.xlsx');
- }
- </script>
- {/block}
|