多语言
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<html lang="<?= $lang ?>">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>浏览页面</title>
|
||||
<title><?= $translations['title'] ?? '车辆管理' ?></title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
<?php if ($lang === 'ar'): ?>
|
||||
<style>
|
||||
body {
|
||||
direction: rtl;
|
||||
text-align: right;
|
||||
}
|
||||
.layui-table-cell {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
|
||||
<!-- 顶部查询表单 -->
|
||||
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
@@ -21,18 +28,18 @@
|
||||
<!-- 表格顶部工具栏 -->
|
||||
<script type="text/html" id="table-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.vehicle.insert">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
<i class="layui-icon layui-icon-add-1"></i><?= $translations['add'] ?? '新增' ?>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="app.admin.vehicle.delete">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
<i class="layui-icon layui-icon-delete"></i><?= $translations['delete'] ?? '删除' ?>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<!-- 表格行工具栏 -->
|
||||
<script type="text/html" id="table-bar">
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="view">查看</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.vehicle.update">编辑</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.vehicle.delete">删除</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.vehicle.update"><?= $translations['edit'] ?? '编辑' ?></button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.vehicle.delete"><?= $translations['remove'] ?? '删除' ?></button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="detail" permission="app.admin.vehicle.detail"><?= $translations['detail'] ?? '详情' ?></button>
|
||||
</script>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
@@ -41,7 +48,6 @@
|
||||
<script src="/app/admin/admin/js/common.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/vehicle/select";
|
||||
@@ -49,9 +55,12 @@
|
||||
const DELETE_API = "/app/admin/vehicle/delete";
|
||||
const INSERT_URL = "/app/admin/vehicle/insert";
|
||||
const UPDATE_URL = "/app/admin/vehicle/update";
|
||||
const DETAILE_URL = "/app/admin/vehicle/detail";
|
||||
const DETAIL_URL = "/app/admin/vehicle/detail";
|
||||
|
||||
// 表格渲染
|
||||
// 翻译文本
|
||||
const translations = <?= json_encode($translations) ?>;
|
||||
|
||||
// 初始化layui
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
@@ -59,89 +68,65 @@
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
// 表头参数
|
||||
let cols = [
|
||||
{
|
||||
type: "checkbox",
|
||||
align: "center"
|
||||
},{
|
||||
title: "ID",align: "center",
|
||||
field: "id",
|
||||
width: 10,
|
||||
},{
|
||||
title: "车架号(17位国际标准)",align: "center",
|
||||
field: "vin",
|
||||
},{
|
||||
title: "车辆品牌",align: "center",
|
||||
field: "brand",
|
||||
},{
|
||||
title: "车辆型号",align: "center",
|
||||
field: "model",
|
||||
},{
|
||||
title: "车辆状态",align: "center",
|
||||
field: "status",
|
||||
},{
|
||||
title: "手续办理地",align: "center",
|
||||
field: "procedure_location",
|
||||
},{
|
||||
title: "FBO港口",align: "center",
|
||||
field: "fbo_location_name",
|
||||
},{
|
||||
title: "车辆所在地",align: "center",
|
||||
field: "location_name",
|
||||
},{
|
||||
title: "最终目的地",align: "center",
|
||||
field: "final_location_name",
|
||||
// },{
|
||||
// title: "FBO发车时间",align: "center",
|
||||
// field: "departure_time",
|
||||
// },{
|
||||
// title: "FBO到达时间",align: "center",
|
||||
// field: "arrival_time",
|
||||
},{
|
||||
title: "图片",align: "center",
|
||||
field: "img_url",
|
||||
templet: function (d) {
|
||||
return '<img src="' + d['img_url'] + '" style="max-width:32px;max-height:32px;" />';
|
||||
}
|
||||
},{
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 150,
|
||||
}
|
||||
];
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.log('Layui initialized');
|
||||
|
||||
// 更新标签页标题
|
||||
try {
|
||||
if (window.parent && window.parent.layui) {
|
||||
window.parent.layui.use(['tab'], function() {
|
||||
let tab = window.parent.layui.tab;
|
||||
let currentTab = tab.getCurrentTab();
|
||||
if (currentTab) {
|
||||
tab.changeTitle(currentTab.id, translations.title);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to update tab title:', e);
|
||||
}
|
||||
|
||||
// 表头参数
|
||||
let cols = [[
|
||||
{type: "checkbox", align: "center"},
|
||||
{title: translations.id, align: "center", field: "id"},
|
||||
{title: translations.vin, align: "center", field: "vin"},
|
||||
{title: translations.status, align: "center", field: "status"},
|
||||
{title: translations.location, align: "center", field: "location_name"},
|
||||
{title: translations.final_location, align: "center", field: "final_location_name"},
|
||||
{title: translations.fbo_location, align: "center", field: "fbo_location_name"},
|
||||
{title: translations.created_at, align: "center", field: "created_at"},
|
||||
{title: translations.updated_at, align: "center", field: "updated_at"},
|
||||
{title: translations.operation, toolbar: "#table-bar", align: "center", fixed: "right", width: 150}
|
||||
]];
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: cols,
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: translations.refresh,
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, translations.filter, translations.print, translations.export],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
} else if (obj.event === "view") {
|
||||
view(obj);
|
||||
} else if (obj.event === "detail") {
|
||||
detail(obj);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -200,10 +185,10 @@
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "新增",
|
||||
title: translations.add,
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
area: [common.isModile()?"100%":"800px", common.isModile()?"100%":"600px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
@@ -213,10 +198,10 @@
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "修改",
|
||||
title: translations.edit,
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
area: [common.isModile()?"100%":"800px", common.isModile()?"100%":"600px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
@@ -230,7 +215,7 @@
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning("未选中数据");
|
||||
layui.popup.warning(translations.no_data_selected);
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(","));
|
||||
@@ -240,9 +225,9 @@
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm("确定删除?", {
|
||||
layer.confirm(translations.confirm_delete, {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
title: translations.title
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
@@ -256,7 +241,7 @@
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
return layui.popup.success(translations.operation_success, refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -280,15 +265,15 @@
|
||||
}
|
||||
|
||||
// 查看数据
|
||||
let view = function(obj) {
|
||||
let detail = function(obj) {
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "查看详情",
|
||||
title: translations.detail,
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: ["100%", "100%"],
|
||||
content: DETAILE_URL + "?" + PRIMARY_KEY + "=" + value + "&mode=view"
|
||||
area: [common.isModile()?"100%":"800px", common.isModile()?"100%":"600px"],
|
||||
content: DETAIL_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user