Files
database_render/web/templates/custom/_default/list.html
2025-08-07 20:03:53 +08:00

67 lines
2.6 KiB
HTML

{{define "content"}}
<div class="bg-white rounded-lg shadow overflow-hidden">
{{if .Data}}
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
{{range .Columns}}
{{if .ShowInList}}
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
{{.Alias}}
</th>
{{end}}
{{end}}
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
操作
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
{{range .Data}}
<tr class="hover:bg-gray-50">
{{range $.Columns}}
{{if .ShowInList}}
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{template "field" dict "Value" (index $.Data .Name) "Type" .RenderType "Column" .}}
</td>
{{end}}
{{end}}
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<button onclick="showDetail('{{.id}}')"
class="text-blue-600 hover:text-blue-900">
查看详情
</button>
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<div class="text-center py-8 text-gray-500">
暂无数据
</div>
{{end}}
</div>
<!-- 分页 -->
<div class="mt-4 flex justify-between items-center">
<div class="text-sm text-gray-700">
共 {{.Total}} 条记录,第 {{.Page}} / {{.Pages}} 页
</div>
<div class="flex space-x-2">
{{if gt .Page 1}}
<a href="?table={{.CurrentTable}}&page={{sub .Page 1}}&per_page={{.PerPage}}"
class="px-3 py-1 border rounded text-sm hover:bg-gray-50">
上一页
</a>
{{end}}
{{if lt .Page .Pages}}
<a href="?table={{.CurrentTable}}&page={{add .Page 1}}&per_page={{.PerPage}}"
class="px-3 py-1 border rounded text-sm hover:bg-gray-50">
下一页
</a>
{{end}}
</div>
</div>
{{end}}