完善生产查询与登录权限配置
This commit is contained in:
+98
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return new class {
|
||||
public function up(Builder $schema): void
|
||||
{
|
||||
$table = 'produce_repair_record';
|
||||
if (!$schema->hasTable($table)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hasProcessId = $schema->hasColumn($table, 'process_id');
|
||||
$hasStepId = $schema->hasColumn($table, 'step_id');
|
||||
$hasProcessName = $schema->hasColumn($table, 'process_name');
|
||||
$hasStepName = $schema->hasColumn($table, 'step_name');
|
||||
|
||||
$schema->table($table, function (Blueprint $blueprint) use ($hasProcessId, $hasStepId, $hasProcessName, $hasStepName): void {
|
||||
if (!$hasProcessId) {
|
||||
$blueprint->bigInteger('process_id')->nullable()->comment('维修工序ID快照');
|
||||
$blueprint->index('process_id', 'idx_repair_record_process_id');
|
||||
}
|
||||
if (!$hasStepId) {
|
||||
$blueprint->bigInteger('step_id')->nullable()->comment('维修步骤ID快照');
|
||||
$blueprint->index('step_id', 'idx_repair_record_step_id');
|
||||
}
|
||||
if (!$hasProcessName) {
|
||||
$blueprint->string('process_name', 100)->nullable()->comment('维修工序名称快照');
|
||||
}
|
||||
if (!$hasStepName) {
|
||||
$blueprint->string('step_name', 100)->nullable()->comment('维修步骤名称快照');
|
||||
}
|
||||
});
|
||||
|
||||
$this->backfillSnapshots($schema);
|
||||
}
|
||||
|
||||
private function backfillSnapshots(Builder $schema): void
|
||||
{
|
||||
$connection = $schema->getConnection();
|
||||
if (!$schema->hasTable('produce_exception_record')) {
|
||||
$connection->table('produce_repair_record')->update([
|
||||
'process_name' => '历史数据未记录',
|
||||
'step_name' => '历史数据未记录',
|
||||
]);
|
||||
return;
|
||||
}
|
||||
$records = $connection->table('produce_repair_record')->get(['id', 'exception_id']);
|
||||
foreach ($records as $record) {
|
||||
$exception = $connection->table('produce_exception_record')
|
||||
->where('id', $record->exception_id)
|
||||
->first(['process_id', 'step_id']);
|
||||
$processId = $exception?->process_id;
|
||||
$stepId = $exception?->step_id;
|
||||
$processName = $processId
|
||||
? (string) ($connection->table('produce_process')->where('id', $processId)->value('process_name') ?? '')
|
||||
: '';
|
||||
$stepName = $stepId
|
||||
? (string) ($connection->table('produce_process_step')->where('id', $stepId)->value('step_name') ?? '')
|
||||
: '';
|
||||
|
||||
$connection->table('produce_repair_record')->where('id', $record->id)->update([
|
||||
'process_id' => $processId,
|
||||
'step_id' => $stepId,
|
||||
'process_name' => $processName ?: '历史数据未记录',
|
||||
'step_name' => $stepName ?: '历史数据未记录',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(Builder $schema): void
|
||||
{
|
||||
$table = 'produce_repair_record';
|
||||
if (!$schema->hasTable($table)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$schema->table($table, function (Blueprint $blueprint) use ($schema): void {
|
||||
if ($schema->hasColumn('produce_repair_record', 'process_id')) {
|
||||
$blueprint->dropIndex('idx_repair_record_process_id');
|
||||
$blueprint->dropColumn('process_id');
|
||||
}
|
||||
if ($schema->hasColumn('produce_repair_record', 'step_id')) {
|
||||
$blueprint->dropIndex('idx_repair_record_step_id');
|
||||
$blueprint->dropColumn('step_id');
|
||||
}
|
||||
if ($schema->hasColumn('produce_repair_record', 'process_name')) {
|
||||
$blueprint->dropColumn('process_name');
|
||||
}
|
||||
if ($schema->hasColumn('produce_repair_record', 'step_name')) {
|
||||
$blueprint->dropColumn('step_name');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
+20
@@ -152,6 +152,8 @@ export const crudSchema = (): CrudSchema => ({
|
||||
{ field: "order_product", title: "订单号/商品编码" },
|
||||
{ field: "exception_type_name", title: "异常分类" },
|
||||
{ field: "exception_reason", title: "异常原因" },
|
||||
{ field: "process_name", title: "维修工序" },
|
||||
{ field: "step_name", title: "维修步骤" },
|
||||
{ field: "part_category", title: "物料分类" },
|
||||
{ field: "part_code", title: "物料编码" },
|
||||
{ field: "part_name", title: "更换备件" },
|
||||
@@ -221,6 +223,8 @@ export const crudSchema = (): CrudSchema => ({
|
||||
},
|
||||
{ prop: "exception_type_name", label: "异常分类", minWidth: 120, cellStyle: { whiteSpace: "nowrap" } },
|
||||
{ prop: "exception_reason", label: "异常原因", minWidth: 180, cellStyle: { whiteSpace: "nowrap" } },
|
||||
{ prop: "process_name", label: "维修工序", minWidth: 140, cellStyle: { whiteSpace: "nowrap" } },
|
||||
{ prop: "step_name", label: "维修步骤", minWidth: 140, cellStyle: { whiteSpace: "nowrap" } },
|
||||
{
|
||||
prop: "part_category",
|
||||
label: "物料分类",
|
||||
@@ -380,6 +384,22 @@ export const crudSchema = (): CrudSchema => ({
|
||||
ifDetail: true,
|
||||
colSpan: 24,
|
||||
},
|
||||
{
|
||||
component: "Input",
|
||||
prop: "process_name",
|
||||
label: "维修工序",
|
||||
componentProps: { readonly: true },
|
||||
ifDetail: true,
|
||||
colSpan: 12,
|
||||
},
|
||||
{
|
||||
component: "Input",
|
||||
prop: "step_name",
|
||||
label: "维修步骤",
|
||||
componentProps: { readonly: true },
|
||||
ifDetail: true,
|
||||
colSpan: 12,
|
||||
},
|
||||
{
|
||||
component: "Input",
|
||||
prop: "fault_descriptions",
|
||||
|
||||
Reference in New Issue
Block a user