v1.0.37: 碎片处理看板调整 - 删待处理碎片卡(4张)+硬碎片新增按钮与录入弹窗(hard_add.php)+综合概览待处理数据碎片=硬+软+看板操作后实时刷新

This commit is contained in:
nanguaboss
2026-08-09 22:49:47 +08:00
parent 48c996d1d2
commit 4ff4349ef5
5 changed files with 142 additions and 9 deletions
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* 硬碎片新增接口 POST /api/fragment/hard_add.php
* 入参:source_type(company|person|product|need|mixed,必填)/
* company_name / person_name / contact_phone / contact_email /
* target_product_category / description / source_channel
* 写入 preliminary_data,status=待处理,recorded_by=当前登录用户
*/
require_once __DIR__ . '/../common/db.php';
require_once __DIR__ . '/../common/response.php';
require_once __DIR__ . '/../common/auth.php';
require_once __DIR__ . '/../common/logger.php';
checkAjax();
checkPermission('preliminary');
$sourceType = trim($_POST['source_type'] ?? '');
if (!in_array($sourceType, ['company', 'person', 'product', 'need', 'mixed'], true)) {
Response::error('碎片类型(source_type)为必填项', 400);
}
$companyName = trim($_POST['company_name'] ?? '');
$personName = trim($_POST['person_name'] ?? '');
$phone = trim($_POST['contact_phone'] ?? '');
$email = trim($_POST['contact_email'] ?? '');
$category = trim($_POST['target_product_category'] ?? '');
$description = trim($_POST['description'] ?? '');
$sourceChannel = trim($_POST['source_channel'] ?? '');
if ($sourceChannel === '') {
$sourceChannel = '手动录入';
}
// 至少有一项内容才能录为碎片
if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && $category === '' && $description === '') {
Response::error('请至少填写一项内容', 400);
}
$pdo = DB::getInstance()->getPdo();
$pdo->prepare(
"INSERT INTO preliminary_data
(source_type, company_name, person_name, contact_phone, contact_email,
target_product_category, description, source_channel, recorded_by, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, '待处理')"
)->execute([
$sourceType,
$companyName !== '' ? $companyName : null,
$personName !== '' ? $personName : null,
$phone !== '' ? $phone : null,
$email !== '' ? $email : null,
$category !== '' ? $category : null,
$description !== '' ? $description : null,
$sourceChannel,
$_SESSION['username'] ?? null,
]);
$newId = (int)$pdo->lastInsertId();
logCurrent('add', 'fragment', 'preliminary_data', $newId, [
'source_type' => $sourceType,
'company_name' => $companyName,
'person_name' => $personName,
'phone' => $phone,
'email' => $email,
]);
Response::success(['id' => $newId], '新增成功');