初始化
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
$activeStation = '';
|
||||
// 确保 sysConfig 可用
|
||||
if (!isset($sysConfig)) {
|
||||
$cfgModel = new app\models\SysConfig();
|
||||
$sysConfig = $cfgModel->getConfig();
|
||||
}
|
||||
include APP_PATH . 'app/views/layouts/station_header.php';
|
||||
?>
|
||||
|
||||
<div class="content">
|
||||
<!-- 用户信息提示 -->
|
||||
<div class="alert alert-info" style="margin-bottom:16px; display:flex; align-items:center; gap:8px; flex-wrap:wrap;">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<span>当前登录:<strong><?php echo htmlspecialchars($user['emp_name']); ?></strong></span>
|
||||
<span style="color:var(--text-light);">| 角色:<?php echo htmlspecialchars(\core\base\Controller::ROLE_NAMES[$user['role']] ?? $user['role']); ?></span>
|
||||
<span style="color:var(--text-light);">| 选择下方工位开始操作</span>
|
||||
<span style="margin-left:auto;" class="column-adjuster" title="调整工位卡片列数">
|
||||
<button type="button" class="col-btn" data-cols="1" title="1列"><i class="fa fa-align-justify"></i></button>
|
||||
<button type="button" class="col-btn" data-cols="2" title="2列"><i class="fa fa-columns"></i>2</button>
|
||||
<button type="button" class="col-btn" data-cols="3" title="3列"><i class="fa fa-columns"></i>3</button>
|
||||
<button type="button" class="col-btn active" data-cols="auto" title="自适应"><i class="fa fa-arrows-h"></i> 自动</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- 工位网格 -->
|
||||
<div class="station-grid" id="stationGrid">
|
||||
<?php
|
||||
$stationIcons = [
|
||||
'inbound' => 'fa-sign-in',
|
||||
'pcb_test' => 'fa-microchip',
|
||||
'battery' => 'fa-battery-full',
|
||||
'assembly' => 'fa-cogs',
|
||||
'finished_test' => 'fa-check-circle',
|
||||
'warehouse' => 'fa-warehouse',
|
||||
'delivery' => 'fa-truck',
|
||||
'document_manage' => 'fa-folder-open',
|
||||
];
|
||||
$iconColors = [
|
||||
'inbound' => ['#10ac84', 'rgba(16,172,132,0.2)'],
|
||||
'pcb_test' => ['#0abde3', 'rgba(10,189,227,0.2)'],
|
||||
'battery' => ['#feca57', 'rgba(254,202,87,0.2)'],
|
||||
'assembly' => ['#a29bfe', 'rgba(162,155,254,0.2)'],
|
||||
'finished_test' => ['#55efc4', 'rgba(85,239,196,0.2)'],
|
||||
'warehouse' => ['#fd79a8', 'rgba(253,121,168,0.2)'],
|
||||
'delivery' => ['#74b9ff', 'rgba(116,185,255,0.2)'],
|
||||
'document_manage' => ['#e17055', 'rgba(225,112,85,0.2)'],
|
||||
];
|
||||
|
||||
foreach ($stations as $station):
|
||||
$type = $station['station_type'];
|
||||
$icon = $stationIcons[$type] ?? 'fa-circle-o';
|
||||
$color = $iconColors[$type] ?? ['#0abde3', 'rgba(10,189,227,0.2)'];
|
||||
$disabled = $station['status'] == 0;
|
||||
?>
|
||||
<a href="<?php echo $disabled ? '#' : BASE_URL . '/Front/' . $type; ?>"
|
||||
class="station-card"
|
||||
style="<?php echo $disabled ? 'opacity:0.5; cursor:not-allowed;' : ''; ?>"
|
||||
<?php echo $disabled ? 'onclick="return false;"' : ''; ?>>
|
||||
<div class="station-icon" style="background:<?php echo $color[1]; ?>; color:<?php echo $color[0]; ?>;">
|
||||
<i class="fa <?php echo $icon; ?>"></i>
|
||||
</div>
|
||||
<div class="station-name"><?php echo htmlspecialchars($station['station_name']); ?></div>
|
||||
<div class="station-code"><?php echo htmlspecialchars($station['station_code']); ?></div>
|
||||
<div class="station-status">
|
||||
<span style="color:<?php echo $station['status'] == 1 ? 'var(--success)' : 'var(--danger)'; ?>">
|
||||
<?php echo $station['status'] == 1 ? '● 启用' : '● 禁用'; ?>
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include APP_PATH . 'app/views/layouts/station_footer.php'; ?>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
if (!isset($sysConfig)) {
|
||||
$cfgModel = new app\models\SysConfig();
|
||||
$sysConfig = $cfgModel->getConfig();
|
||||
}
|
||||
include APP_PATH . 'app/views/layouts/station_header.php';
|
||||
?>
|
||||
|
||||
<div class="content">
|
||||
<div class="card" style="max-width:600px; margin:60px auto;">
|
||||
<div class="card-body" style="text-align:center; padding:60px 20px;">
|
||||
<i class="fa fa-lock" style="font-size:80px; color:var(--danger);"></i>
|
||||
<h2 style="margin-top:20px; color:var(--danger);">抱歉,您没有访问该工位的权限</h2>
|
||||
<p style="color:var(--text-light); font-size:16px; margin-top:12px;">
|
||||
工位类型:<code><?php echo htmlspecialchars($stationType ?? '未知'); ?></code>
|
||||
</p>
|
||||
<?php if (!empty($message)): ?>
|
||||
<p style="color:var(--text-light); font-size:16px;"><?php echo htmlspecialchars($message); ?></p>
|
||||
<?php else: ?>
|
||||
<p style="color:var(--text-light);">请联系管理员为您开通对应工位的访问权限。</p>
|
||||
<?php endif; ?>
|
||||
<br>
|
||||
<a href="<?php echo BASE_URL; ?>/Front/index" class="btn btn-primary btn-lg">
|
||||
<i class="fa fa-home"></i> 返回工位首页
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include APP_PATH . 'app/views/layouts/station_footer.php'; ?>
|
||||
@@ -0,0 +1,350 @@
|
||||
<?php
|
||||
/**
|
||||
* 文件管理工位视图
|
||||
*
|
||||
* 管理员:可上传、删除、打开文件
|
||||
* 操作员:只能查看和打开文件
|
||||
*
|
||||
* 所需变量:
|
||||
* $user - 当前用户
|
||||
* $sysConfig - 系统配置
|
||||
* $stations - 所有工位列表
|
||||
* $documents - 文档列表
|
||||
* $categories - 文档分类列表
|
||||
* $csrfToken - CSRF token
|
||||
* $isAdmin - 是否为管理员
|
||||
*/
|
||||
|
||||
$activeStation = 'document_manage';
|
||||
$title = '文件管理';
|
||||
include APP_PATH . 'app/views/layouts/station_header.php';
|
||||
|
||||
// 权限判断
|
||||
$isAdmin = ($user['role'] === \core\base\Controller::ROLE_SUPER_ADMIN
|
||||
|| $user['role'] === \core\base\Controller::ROLE_ADMIN);
|
||||
?>
|
||||
|
||||
<div class="content">
|
||||
<a href="<?php echo BASE_URL; ?>/Front/index" class="back-link"><i class="fa fa-arrow-left"></i> 返回工位选择</a>
|
||||
|
||||
<div class="page-title-bar">
|
||||
<div>
|
||||
<h1><i class="fa fa-folder-open"></i> 文件管理</h1>
|
||||
</div>
|
||||
<div class="today-count-badge">
|
||||
<i class="fa fa-user"></i> <?php echo htmlspecialchars($user['emp_name'] ?? ''); ?>
|
||||
共:<span class="count-num" id="docCount"><?php echo count($documents); ?></span> 个文件
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索和筛选区 -->
|
||||
<div class="card" style="margin-bottom:12px;">
|
||||
<div class="card-body" style="padding:12px 16px;">
|
||||
<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">
|
||||
<input type="text" id="searchInput" class="form-control" placeholder="搜索文件名称..."
|
||||
style="max-width:300px;">
|
||||
<select id="categoryFilter" class="form-control" style="max-width:200px;">
|
||||
<option value="">全部分类</option>
|
||||
<?php foreach ($categories as $cat): ?>
|
||||
<option value="<?php echo htmlspecialchars($cat['category']); ?>">
|
||||
<?php echo htmlspecialchars($cat['category']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if ($isAdmin): ?>
|
||||
<button type="button" class="btn btn-primary" id="uploadBtn" style="margin-left:auto;">
|
||||
<i class="fa fa-upload"></i> 上传文件
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($isAdmin): ?>
|
||||
<!-- 上传表单(默认隐藏) -->
|
||||
<div class="card" id="uploadCard" style="display:none;margin-bottom:12px;">
|
||||
<div class="card-header">
|
||||
<h3><i class="fa fa-upload"></i> 上传文件</h3>
|
||||
<button type="button" class="btn btn-sm btn-warning" id="cancelUploadBtn">
|
||||
<i class="fa fa-times"></i> 取消
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="uploadForm" method="post" enctype="multipart/form-data" action="<?php echo BASE_URL; ?>/Front/documentManageUpload">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<div class="row" style="display:flex;flex-wrap:wrap;gap:12px;">
|
||||
<div class="station-field-item" style="flex:1;min-width:200px;">
|
||||
<label>文档标题 <span class="text-danger">*</span></label>
|
||||
<input type="text" name="title" class="form-control" placeholder="输入文档标题" required>
|
||||
</div>
|
||||
<div class="station-field-item" style="flex:1;min-width:150px;">
|
||||
<label>文档编号</label>
|
||||
<input type="text" name="doc_no" class="form-control" placeholder="如:SOP-001">
|
||||
</div>
|
||||
<div class="station-field-item" style="flex:1;min-width:150px;">
|
||||
<label>分类</label>
|
||||
<input type="text" name="category" class="form-control" placeholder="如:操作规程" list="categoryList">
|
||||
<datalist id="categoryList">
|
||||
<?php foreach ($categories as $cat): ?>
|
||||
<option value="<?php echo htmlspecialchars($cat['category']); ?>">
|
||||
<?php endforeach; ?>
|
||||
</datalist>
|
||||
</div>
|
||||
<div class="station-field-item" style="flex:1;min-width:100px;">
|
||||
<label>版本</label>
|
||||
<input type="text" name="version" class="form-control" value="1.0" placeholder="版本号">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" style="display:flex;flex-wrap:wrap;gap:12px;margin-top:12px;">
|
||||
<div class="station-field-item" style="flex:1;min-width:200px;">
|
||||
<label>选择文件 <span class="text-danger">*</span></label>
|
||||
<input type="file" name="doc_file" class="form-control" required
|
||||
accept=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv,.zip,.rar,.jpg,.jpeg,.png,.gif">
|
||||
</div>
|
||||
<div class="station-field-item" style="flex:1;min-width:200px;">
|
||||
<label>描述</label>
|
||||
<input type="text" name="description" class="form-control" placeholder="简要描述">
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top:12px;">
|
||||
<button type="submit" class="btn btn-success btn-lg">
|
||||
<i class="fa fa-cloud-upload"></i> 确认上传
|
||||
</button>
|
||||
<span id="uploadStatus" style="margin-left:10px;color:var(--primary);display:none;">
|
||||
<i class="fa fa-spinner fa-spin"></i> 上传中...
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 文件列表 -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3><i class="fa fa-list"></i> 文件列表</h3>
|
||||
</div>
|
||||
<div class="card-body no-padding">
|
||||
<div class="table-wrap">
|
||||
<table class="table" id="docTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-col="title" style="text-align:left;padding-left:16px;">文件名称</th>
|
||||
<th data-col="category">分类</th>
|
||||
<th data-col="version">版本</th>
|
||||
<th data-col="file_size">大小</th>
|
||||
<th data-col="operator">上传人</th>
|
||||
<th data-col="created_at">上传时间</th>
|
||||
<th data-col="actions">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($documents)): ?>
|
||||
<?php foreach ($documents as $doc):
|
||||
$sizeStr = '';
|
||||
$fs = (int)($doc['file_size'] ?? 0);
|
||||
if ($fs > 1048576) $sizeStr = round($fs / 1048576, 1) . ' MB';
|
||||
elseif ($fs > 1024) $sizeStr = round($fs / 1024, 1) . ' KB';
|
||||
else $sizeStr = $fs . ' B';
|
||||
$fileExt = strtolower($doc['file_type'] ?? '');
|
||||
$fileIcon = 'fa-file-o';
|
||||
if (in_array($fileExt, ['pdf'])) $fileIcon = 'fa-file-pdf-o';
|
||||
elseif (in_array($fileExt, ['doc','docx'])) $fileIcon = 'fa-file-word-o';
|
||||
elseif (in_array($fileExt, ['xls','xlsx','csv'])) $fileIcon = 'fa-file-excel-o';
|
||||
elseif (in_array($fileExt, ['ppt','pptx'])) $fileIcon = 'fa-file-powerpoint-o';
|
||||
elseif (in_array($fileExt, ['jpg','jpeg','png','gif'])) $fileIcon = 'fa-file-image-o';
|
||||
elseif (in_array($fileExt, ['zip','rar'])) $fileIcon = 'fa-file-archive-o';
|
||||
elseif (in_array($fileExt, ['txt'])) $fileIcon = 'fa-file-text-o';
|
||||
?>
|
||||
<tr class="doc-row" data-title="<?php echo htmlspecialchars(mb_strtolower($doc['title'] ?? '')); ?>"
|
||||
data-category="<?php echo htmlspecialchars($doc['category'] ?? ''); ?>">
|
||||
<td data-col="title" style="text-align:left;padding-left:16px;">
|
||||
<i class="fa <?php echo $fileIcon; ?>" style="color:var(--primary);margin-right:6px;"></i>
|
||||
<strong><?php echo htmlspecialchars($doc['title']); ?></strong>
|
||||
<?php if (!empty($doc['description'])): ?>
|
||||
<br><small class="text-muted"><?php echo htmlspecialchars(mb_substr($doc['description'], 0, 60)); ?><?php echo mb_strlen($doc['description']) > 60 ? '...' : ''; ?></small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td data-col="category">
|
||||
<?php if (!empty($doc['category'])): ?>
|
||||
<span class="label label-info"><?php echo htmlspecialchars($doc['category']); ?></span>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">-</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td data-col="version"><?php echo htmlspecialchars($doc['version'] ?? '1.0'); ?></td>
|
||||
<td data-col="file_size"><?php echo $sizeStr; ?></td>
|
||||
<td data-col="operator"><?php echo htmlspecialchars($doc['operator'] ?? '-'); ?></td>
|
||||
<td data-col="created_at"><?php echo htmlspecialchars($doc['created_at'] ?? '-'); ?></td>
|
||||
<td data-col="actions">
|
||||
<?php if (!empty($doc['file_path'])): ?>
|
||||
<a href="<?php echo BASE_URL . htmlspecialchars($doc['file_path']); ?>"
|
||||
class="btn btn-xs btn-info" target="_blank" title="打开文件">
|
||||
<i class="fa fa-external-link"></i> 打开
|
||||
</a>
|
||||
<a href="<?php echo BASE_URL . htmlspecialchars($doc['file_path']); ?>"
|
||||
class="btn btn-xs btn-info" download title="下载文件">
|
||||
<i class="fa fa-download"></i> 下载
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="text-muted">无文件</span>
|
||||
<?php endif; ?>
|
||||
<?php if ($isAdmin): ?>
|
||||
<button type="button" class="btn btn-xs btn-danger doc-del-btn"
|
||||
data-id="<?php echo $doc['id']; ?>" data-title="<?php echo htmlspecialchars($doc['title'], ENT_QUOTES); ?>"
|
||||
title="删除文件">
|
||||
<i class="fa fa-trash"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<div class="empty-state">
|
||||
<i class="fa fa-folder-open-o"></i>
|
||||
<p>暂无文件,<?php echo $isAdmin ? '请点击「上传文件」添加' : '请联系管理员上传'; ?></p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script nonce="<?php echo csp_nonce(); ?>">
|
||||
var BASE_URL = '<?php echo BASE_URL; ?>';
|
||||
|
||||
// ========== 搜索和筛选 ==========
|
||||
function filterDocuments() {
|
||||
var searchText = ($('#searchInput').val() || '').toLowerCase();
|
||||
var category = $('#categoryFilter').val() || '';
|
||||
|
||||
var visibleCount = 0;
|
||||
$('#docTable .doc-row').each(function() {
|
||||
var title = $(this).data('title') || '';
|
||||
var rowCat = $(this).data('category') || '';
|
||||
var match = true;
|
||||
|
||||
if (searchText && title.indexOf(searchText) < 0) match = false;
|
||||
if (category && rowCat !== category) match = false;
|
||||
|
||||
if (match) {
|
||||
$(this).show();
|
||||
visibleCount++;
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
$('#docCount').text(visibleCount);
|
||||
}
|
||||
|
||||
// CSP:搜索/筛选事件绑定(替代内联 oninput/onchange)
|
||||
$('#searchInput').on('input', filterDocuments);
|
||||
$('#categoryFilter').on('change', filterDocuments);
|
||||
|
||||
<?php if ($isAdmin): ?>
|
||||
// ========== 上传表单 ==========
|
||||
function showUploadForm() {
|
||||
$('#uploadCard').slideDown(300);
|
||||
}
|
||||
function hideUploadForm() {
|
||||
$('#uploadCard').slideUp(300);
|
||||
}
|
||||
function updateFileName(input) {
|
||||
// 如果标题为空,自动用文件名填充
|
||||
var fileName = input.files[0] ? input.files[0].name.replace(/\.[^/.]+$/, '') : '';
|
||||
if (fileName && !$('#uploadForm input[name="title"]').val()) {
|
||||
$('#uploadForm input[name="title"]').val(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
// 上传表单提交
|
||||
$('#uploadForm').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
var $form = $(this);
|
||||
var title = $form.find('input[name="title"]').val().trim();
|
||||
if (!title) {
|
||||
alert('请输入文档标题');
|
||||
return;
|
||||
}
|
||||
if (!$form.find('input[name="doc_file"]').val()) {
|
||||
alert('请选择要上传的文件');
|
||||
return;
|
||||
}
|
||||
|
||||
$('#uploadStatus').show();
|
||||
|
||||
var formData = new FormData($form[0]);
|
||||
$.ajax({
|
||||
url: $form.attr('action'),
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
$('#uploadStatus').hide();
|
||||
if (res.success) {
|
||||
alert('文件上传成功!');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('上传失败: ' + (res.error || '未知错误'));
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
$('#uploadStatus').hide();
|
||||
var msg = '网络错误,请重试';
|
||||
try {
|
||||
var r = JSON.parse(xhr.responseText);
|
||||
if (r && r.error) msg = r.error;
|
||||
else if (xhr.responseText) msg = xhr.responseText;
|
||||
} catch (e) {
|
||||
if (xhr.responseText) msg = xhr.responseText;
|
||||
}
|
||||
alert(msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ========== 删除文件 ==========
|
||||
function deleteDocument(id, title) {
|
||||
if (!confirm('确定删除文件「' + title + '」吗?\n此操作不可撤销。')) return;
|
||||
|
||||
$.ajax({
|
||||
url: BASE_URL + '/Front/documentManageDelete',
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id,
|
||||
csrf_token: '<?php echo htmlspecialchars($csrfToken); ?>'
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if (res.success) {
|
||||
alert('文件已删除');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('删除失败: ' + (res.error || '未知错误'));
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('网络错误,请重试');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// CSP:上传/删除相关事件绑定(替代内联 onclick/onchange)
|
||||
$('#uploadBtn').on('click', showUploadForm);
|
||||
$('#cancelUploadBtn').on('click', hideUploadForm);
|
||||
$('#uploadForm input[name="doc_file"]').on('change', function () { updateFileName(this); });
|
||||
$('#docTable').on('click', '.doc-del-btn', function () {
|
||||
deleteDocument($(this).attr('data-id'), $(this).attr('data-title'));
|
||||
});
|
||||
<?php endif; ?>
|
||||
</script>
|
||||
|
||||
<?php include APP_PATH . 'app/views/layouts/station_footer.php'; ?>
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* 通用工位操作视图(唯一工位视图文件)
|
||||
*
|
||||
* 所有工位(内置和动态添加)都通过此视图渲染。
|
||||
*
|
||||
* 所需变量(由 FrontController::handleStation 传入):
|
||||
* $stationType - 工位类型标识
|
||||
* $currentStation - 当前工位的数据库记录
|
||||
* $bizConfig - 业务配置(内置工位有,动态工位为 null)
|
||||
* $fieldConfigs - 字段配置数组
|
||||
* $models - 产品型号列表
|
||||
* $types - 产品类型列表
|
||||
* $customers - 客户列表
|
||||
* $records - 操作记录
|
||||
* $filterType - 筛选类型
|
||||
* $filterModel - 筛选型号
|
||||
* $todayCount - 今日计数
|
||||
* $shellColors - 外壳颜色(assembly 工位)
|
||||
* $user - 当前用户
|
||||
* $sysConfig - 系统配置
|
||||
* $stations - 所有工位列表
|
||||
*/
|
||||
|
||||
require_once APP_PATH . 'app/helpers/station_template_helper.php';
|
||||
|
||||
// 获取工位名称
|
||||
$stationName = $currentStation['station_name'] ?? $stationType;
|
||||
$stationCode = $currentStation['station_code'] ?? $stationType;
|
||||
|
||||
// ========== 内置工位:使用 bizConfig ==========
|
||||
if ($bizConfig) {
|
||||
// 解析记录(内置工位使用专用表,记录结构已完整,无需 JSON 解析)
|
||||
$parsedRecords = $records;
|
||||
|
||||
// 构建 stationConfig(从 bizConfig.view 继承)
|
||||
$stationConfig = array_merge([
|
||||
'stationKey' => $stationType,
|
||||
'pageTitle' => $stationName,
|
||||
'pageIcon' => 'cube',
|
||||
'cardTitle' => '快速录入',
|
||||
'tableTitle' => '操作记录',
|
||||
'dataSources' => [
|
||||
'types' => $types ?? [],
|
||||
'models' => $models ?? [],
|
||||
'customers' => $customers ?? [],
|
||||
],
|
||||
'submitMode' => 'auto',
|
||||
'codeFields' => ['serial_no'],
|
||||
'labelFields' => [],
|
||||
'emptyText' => '暂无记录,请在扫描框中录入第一条数据',
|
||||
'reloadAfterSubmit' => true,
|
||||
'enableFilter' => false,
|
||||
], $bizConfig['view'] ?? []);
|
||||
|
||||
// 注入全局变量
|
||||
$GLOBALS['records'] = $parsedRecords;
|
||||
$GLOBALS['fieldConfigs'] = $fieldConfigs;
|
||||
$GLOBALS['types'] = $types ?? [];
|
||||
$GLOBALS['models'] = $models ?? [];
|
||||
$GLOBALS['customers'] = $customers ?? [];
|
||||
$GLOBALS['user'] = $user;
|
||||
$GLOBALS['sysConfig'] = $sysConfig;
|
||||
$GLOBALS['stationType'] = $stationType;
|
||||
$GLOBALS['bizConfig'] = $bizConfig;
|
||||
$GLOBALS['filterType'] = $filterType ?? '';
|
||||
$GLOBALS['filterModel'] = $filterModel ?? '';
|
||||
$GLOBALS['todayCount'] = $todayCount ?? 0;
|
||||
$GLOBALS['totalCount'] = $totalCount ?? 0;
|
||||
$GLOBALS['shellColors'] = $shellColors ?? [];
|
||||
$GLOBALS['csrfToken'] = $csrfToken;
|
||||
$GLOBALS['stationError'] = $stationError ?? '';
|
||||
|
||||
renderStationTemplate($stationConfig);
|
||||
|
||||
} else {
|
||||
// ========== 动态工位:使用 station_records 表(JSON 存储) ==========
|
||||
|
||||
// 解析记录中的 JSON 数据
|
||||
$parsedRecords = [];
|
||||
if (!empty($records)) {
|
||||
foreach ($records as $rec) {
|
||||
$row = ['id' => $rec['id'], 'operator' => $rec['operator'], 'created_at' => $rec['created_at']];
|
||||
$jsonData = json_decode($rec['record_data'], true);
|
||||
if (is_array($jsonData)) {
|
||||
$row = array_merge($row, $jsonData);
|
||||
}
|
||||
$parsedRecords[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// 配置工位模板
|
||||
$stationConfig = [
|
||||
'stationKey' => $stationType,
|
||||
'pageTitle' => $stationName,
|
||||
'pageIcon' => 'cube',
|
||||
'cardTitle' => '快速录入',
|
||||
'tableTitle' => '操作记录',
|
||||
'dataSources' => [
|
||||
'types' => $types ?? [],
|
||||
'models' => $models ?? [],
|
||||
'customers' => $customers ?? [],
|
||||
],
|
||||
'submitMode' => 'auto', // 扫描回车直接提交
|
||||
'codeFields' => ['serial_no'], // 序列号类字段 code 样式
|
||||
'labelFields' => [],
|
||||
'emptyText' => '暂无记录,请在扫描框中录入第一条数据',
|
||||
'reloadAfterSubmit' => true, // 提交后刷新页面
|
||||
'enableFilter' => false, // 不启用联动筛选
|
||||
];
|
||||
|
||||
// 将解析后的记录和字段配置注入全局,供 renderStationTemplate 使用
|
||||
$GLOBALS['records'] = $parsedRecords;
|
||||
$GLOBALS['fieldConfigs'] = $fieldConfigs;
|
||||
$GLOBALS['types'] = $types ?? [];
|
||||
$GLOBALS['models'] = $models ?? [];
|
||||
$GLOBALS['customers'] = $customers ?? [];
|
||||
$GLOBALS['user'] = $user;
|
||||
$GLOBALS['sysConfig'] = $sysConfig;
|
||||
$GLOBALS['stationType'] = $stationType;
|
||||
$GLOBALS['bizConfig'] = null;
|
||||
$GLOBALS['filterType'] = '';
|
||||
$GLOBALS['filterModel'] = '';
|
||||
$GLOBALS['todayCount'] = 0;
|
||||
$GLOBALS['totalCount'] = $totalCount ?? count($parsedRecords);
|
||||
$GLOBALS['shellColors'] = [];
|
||||
$GLOBALS['csrfToken'] = $csrfToken;
|
||||
$GLOBALS['stationError'] = '';
|
||||
|
||||
renderStationTemplate($stationConfig);
|
||||
}
|
||||
Reference in New Issue
Block a user