diff --git a/api/fragment/soft_update.php b/api/fragment/soft_update.php index 7e7cb42..ac0b943 100644 --- a/api/fragment/soft_update.php +++ b/api/fragment/soft_update.php @@ -11,6 +11,7 @@ require_once __DIR__ . '/../common/auth.php'; require_once __DIR__ . '/../common/logger.php'; require_once __DIR__ . '/../common/helpers.php'; require_once __DIR__ . '/../common/completeness.php'; +require_once __DIR__ . '/../common/duplicate_check.php'; checkAjax(); checkPermission('preliminary'); @@ -56,6 +57,20 @@ switch ($table) { 'graduated_from' => 's', 'hometown' => 's', 'work_location' => 's', 'id_type' => 's', 'id_number' => 's', 'source_channel' => 's', 'source_detail' => 's', ]); + // 唯一性校验(排除自身):身份证 / 手机 / 邮箱 + $dups = []; + if (!empty($fields['id_number'])) { + $dup = findDuplicate($pdo, 'id_number', $fields['id_number'], [$id]); + if ($dup) $dups[] = $dup; + } + $ownAccountIds = $pdo->query("SELECT id FROM social_accounts WHERE owner_type = 'person' AND owner_id = $id")->fetchAll(PDO::FETCH_COLUMN); + if (isset($_POST['phone'])) { + $dups = array_merge($dups, checkSingleAccountDuplicate($pdo, $_POST['phone'] !== '' ? 'phone' : '', $_POST['phone'], '', $ownAccountIds)); + } + if (isset($_POST['email'])) { + $dups = array_merge($dups, checkSingleAccountDuplicate($pdo, $_POST['email'] !== '' ? 'email' : '', $_POST['email'], '', $ownAccountIds)); + } + if (!empty($dups)) Response::duplicates($dups); if (!empty($fields)) { [$sets, $params] = buildUpdate($fields); $params[] = $id; @@ -96,6 +111,17 @@ switch ($table) { 'latest_employee_count' => 'i', 'latest_annual_revenue' => 's', 'is_listed' => 'i', 'stock_code' => 's', 'website' => 's', ]); + // 唯一性校验(排除自身):企业名称 / 注册号 + $dups = []; + if (!empty($fields['name_zh']) || !empty($fields['display_name'])) { + $dup = findDuplicate($pdo, 'company_name', $fields['name_zh'] ?? $fields['display_name'] ?? '', [$id]); + if ($dup) $dups[] = $dup; + } + if (!empty($fields['registration_number'])) { + $dup = findDuplicate($pdo, 'registration_number', $fields['registration_number'], [$id]); + if ($dup) $dups[] = $dup; + } + if (!empty($dups)) Response::duplicates($dups); if (!empty($fields)) { [$sets, $params] = buildUpdate($fields); $params[] = $id; @@ -108,6 +134,15 @@ switch ($table) { $collect([ 'platform' => 's', 'account_id' => 's', 'is_primary' => 'i', 'profile_url' => 's', 'remark' => 's', ]); + // 唯一性校验(排除自身):社媒账号ID(同平台,取当前行 platform)/ 主页链接 + $curAcc = $pdo->prepare("SELECT * FROM social_accounts WHERE id = ?"); + $curAcc->execute([$id]); + $curAccRow = $curAcc->fetch(); + $platformVal = $fields['platform'] ?? ($curAccRow['platform'] ?? ''); + $accountIdVal = $fields['account_id'] ?? ($curAccRow['account_id'] ?? ''); + $profileUrlVal = $fields['profile_url'] ?? ($curAccRow['profile_url'] ?? ''); + $dups = checkSingleAccountDuplicate($pdo, $platformVal, $accountIdVal, $profileUrlVal, [$id]); + if (!empty($dups)) Response::duplicates($dups); if (!empty($fields)) { [$sets, $params] = buildUpdate($fields); $params[] = $id; diff --git a/static/js/config.js b/static/js/config.js index 49331eb..147f0ad 100644 --- a/static/js/config.js +++ b/static/js/config.js @@ -5,7 +5,7 @@ var BASE_URL = '/api/'; var PAGE_SIZE = 20; /** 系统版本号(logo旁展示):修改代码后运行 tools/bump_version.php 自动递增 */ -var APP_VERSION = 'v1.0.35'; +var APP_VERSION = 'v1.0.36'; /** 页脚版权/备案信息(在 config.js 中修改) */ var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号';