初始化

This commit is contained in:
2026-08-08 18:28:49 +08:00
parent 9bef4420e0
commit f082037a6e
854 changed files with 217171 additions and 11 deletions
+131
View File
@@ -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);
}