修复生产统计与维修记录用户数据

This commit is contained in:
2026-09-06 21:06:36 +08:00
parent 02c8fb7021
commit 5ca6ef2d5a
41 changed files with 1838 additions and 205 deletions
@@ -0,0 +1,46 @@
<?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_member_notification';
if ($schema->hasTable($table)) {
return;
}
$schema->create($table, function (Blueprint $table): void {
$table->bigInteger('id')->primary()->comment('主键');
$table->bigInteger('member_id')->nullable()->comment('接收会员ID');
$table->string('user_code', 64)->comment('接收用户编码');
$table->string('type', 32)->default('repair_responsibility')->comment('通知类型');
$table->string('title', 120)->comment('通知标题');
$table->text('content')->comment('通知内容');
$table->bigInteger('repair_id')->nullable()->comment('维修记录ID');
$table->string('repair_no', 64)->nullable()->comment('维修单号');
$table->string('order_no', 64)->nullable()->comment('订单号');
$table->tinyInteger('status')->default(0)->comment('阅读状态:0未读,1已读');
$table->bigInteger('read_at')->nullable()->comment('阅读时间');
$table->bigInteger('created_at')->nullable()->comment('创建时间');
$table->bigInteger('updated_at')->nullable()->comment('更新时间');
$table->bigInteger('deleted_at')->nullable()->comment('删除时间');
$table->index(['member_id', 'status'], 'idx_member_notification_status');
$table->index(['user_code', 'created_at'], 'idx_member_notification_user_code');
$table->index('repair_id', 'idx_member_notification_repair_id');
});
}
public function down(Builder $schema): void
{
$table = 'produce_member_notification';
if (!$schema->hasTable($table)) {
return;
}
$schema->drop($table);
}
};
@@ -400,6 +400,33 @@ const matchSpecificRule = (rule: ProduceDataEntrySpecificRule, valueMap: Record<
}
}
const hasExistingRecordForRule = (rule: ProduceDataEntrySpecificRule) => {
const matchField = rule.match_field || 'process_order_no'
const currentValue = String(({
process_order_no: processOrderNo.value,
order_no: processOrderNo.value,
product_code: productCode.value,
user_code: userCode.value,
} as Record<string, string>)[matchField] || '').trim()
if (!currentValue) return false
const matched = recentRecords.value.some((record) => {
const recordValue = String((record as Record<string, any>)[matchField] || (matchField === 'order_no' ? record.process_order_no : '')).trim()
return recordValue === currentValue
})
return matched
}
const getDuplicateRuleMessage = (rule: ProduceDataEntrySpecificRule) => {
const fieldLabels: Record<string, string> = {
order_no: '加工单号',
process_order_no: '加工单号',
product_code: '商品编码',
user_code: '用户编码',
}
const field = rule.match_field || 'process_order_no'
return `${fieldLabels[field] || '当前数据'}已录入,当前规则不允许重复扫码`
}
const validateSpecificRules = () => {
if (!specificRules.value.length) {
return true
@@ -415,11 +442,11 @@ const validateSpecificRules = () => {
if ((rule.apply_mode || 'order') !== 'machine' && rule.apply_mode !== 'both') {
return false
}
return Number(rule.rule_type) === 2 && matchSpecificRule(rule, context)
return Number(rule.rule_type) === 2 && matchSpecificRule(rule, context) && hasExistingRecordForRule(rule)
})
if (blockedRule) {
ElMessage.warning(blockedRule.rule_name || '当前整机数据命中特定规则,禁止提交')
ElMessage.warning(getDuplicateRuleMessage(blockedRule))
const matchField = blockedRule.match_field || 'process_order_no'
if (matchField === 'product_code') {
focusProductCodeInput()
@@ -484,12 +511,13 @@ const resetForm = () => {
}
const submitEntry = async () => {
if (submitting.value) return
if (!validateBeforeSubmit()) return
const passed = await runUserCodeCheck(userCode.value)
if (!passed) { emit('play-error'); nextTick(() => focusUserCodeInput()); return }
submitting.value = true
try {
const result = await submitProductRecord({
const payload = {
process_order_no: processOrderNo.value.trim(),
product_code: productCode.value.trim(),
quantity: Number(quantity.value) || 1,
@@ -497,7 +525,8 @@ const submitEntry = async () => {
step_id: props.selectedStep,
user_code: userCode.value.trim(),
scan_result: 1,
})
}
const result = await submitProductRecord(payload)
if (Number(result?.code) !== 0) throw new Error(result?.msg || '录入失败')
ElMessage.success('录入成功')
emit('play-success')