From f3938adcc07ccf0ea012214fc7f0ef2640dadaf9 Mon Sep 17 00:00:00 2001 From: nanguaboss <602995148@qq.com> Date: Mon, 10 Aug 2026 00:28:45 +0800 Subject: [PATCH] =?UTF-8?q?v1.0.44:=20=E7=BB=A7=E7=BB=AD=E8=A1=A5=E5=85=A8?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E7=9B=B4=E6=8E=A5=E8=BD=AC=E6=8D=A2=20-=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9Ehard=5Fupdate.php=E4=BB=85=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=A1=AC=E7=A2=8E=E7=89=87=E5=AD=97=E6=AE=B5(=E5=90=ABextra?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E8=AF=81/=E5=B9=B3=E5=8F=B0/=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7/=E4=B8=BB=E9=A1=B5,=E6=A0=87=E5=87=86+=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F+=E5=94=AF=E4=B8=80=E6=80=A7=E6=A0=A1=E9=AA=8C),?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=BB=A7=E7=BB=AD=E8=A1=A5=E5=85=A8=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=94=B9=E4=B8=BA=E4=BF=9D=E5=AD=98=E8=A1=A8=E5=8D=95?= =?UTF-8?q?,=E8=BD=AC=E6=8D=A2=E4=BB=85=E7=94=B1=E8=BD=AC=E8=BD=AF?= =?UTF-8?q?=E7=A2=8E=E7=89=87=E8=A7=A6=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/fragment/hard_update.php | 116 +++++++++++++++++++++++++++++++++++ static/js/config.js | 2 +- static/js/fragment.js | 49 ++++++++------- 3 files changed, 144 insertions(+), 23 deletions(-) create mode 100644 api/fragment/hard_update.php diff --git a/api/fragment/hard_update.php b/api/fragment/hard_update.php new file mode 100644 index 0000000..562cb74 --- /dev/null +++ b/api/fragment/hard_update.php @@ -0,0 +1,116 @@ +getPdo(); +$stmt = $pdo->prepare("SELECT * FROM preliminary_data WHERE id = ? AND is_active = 1"); +$stmt->execute([$id]); +$frag = $stmt->fetch(); +if (!$frag) { + Response::error('碎片不存在'); +} +if (in_array($frag['status'], ['已转换', '已废弃'], true)) { + Response::error('该碎片已处理(' . $frag['status'] . ')'); +} + +$sourceType = trim($_POST['source_type'] ?? ($frag['source_type'] ?? '')); +$companyName = trim($_POST['company_name'] ?? ''); +$personName = trim($_POST['person_name'] ?? ''); +$phone = trim($_POST['contact_phone'] ?? ''); +$email = trim($_POST['contact_email'] ?? ''); +$idNumber = trim($_POST['id_number'] ?? ''); +$platform = trim($_POST['platform'] ?? ''); +$accountId = trim($_POST['account_id'] ?? ''); +$profileUrl = trim($_POST['profile_url'] ?? ''); +if (!in_array($sourceType, ['company', 'person', 'product', 'need', 'mixed'], true)) { + Response::error('碎片类型不合法', 400); +} + +// 硬数据标准校验:企业/产品/需求 → 企业名称必填;人员 → 手机、邮箱至少一项 +if (in_array($sourceType, ['company', 'product', 'need'], true) && $companyName === '') { + Response::error('企业类型硬数据:企业名称为必填项', 400); +} +if ($sourceType === 'person' && $phone === '' && $email === '') { + Response::error('人员类型硬数据:手机号码、邮箱至少填写一项', 400); +} + +// 格式校验 +checkFieldFormat('phone', $phone); +checkFieldFormat('email', $email); +checkFieldFormat('id_number', $idNumber); +if ($profileUrl !== '' && !preg_match('/^https?:\/\//i', $profileUrl)) { + Response::error('主页链接格式不正确(应以 http:// 或 https:// 开头)', 400); +} + +// 唯一性校验(收集全部重复) +$dups = []; +if ($companyName !== '') { + $dup = findDuplicate($pdo, 'company_name', $companyName); + if ($dup) $dups[] = $dup; +} +$dups = array_merge($dups, checkSingleAccountDuplicate($pdo, $phone !== '' ? 'phone' : '', $phone, $profileUrl)); +if ($email !== '') { + $dup = findDuplicate($pdo, 'email', $email); + if ($dup) $dups[] = $dup; +} +if ($idNumber !== '') { + $dup = findDuplicate($pdo, 'id_number', $idNumber); + if ($dup) $dups[] = $dup; +} +if ($accountId !== '' && $platform !== '') { + $dup = findDuplicate($pdo, 'account_id', $accountId, [], $platform); + if ($dup) $dups[] = $dup; +} +if (!empty($dups)) Response::duplicates($dups); + +// extra_info 合并更新(身份证/平台/账号ID/主页链接) +$extra = json_decode($frag['extra_info'] ?? 'null', true); +if (!is_array($extra)) { + $extra = []; +} +if ($idNumber !== '') $extra['id_number'] = $idNumber; else unset($extra['id_number']); +if ($platform !== '') $extra['platform'] = $platform; else unset($extra['platform']); +if ($accountId !== '') $extra['account_id'] = $accountId; else unset($extra['account_id']); +if ($profileUrl !== '') $extra['profile_url'] = $profileUrl; else unset($extra['profile_url']); + +$pdo->prepare( + "UPDATE preliminary_data + SET source_type = ?, company_name = ?, person_name = ?, contact_phone = ?, contact_email = ?, extra_info = ? + WHERE id = ?" +)->execute([ + $sourceType, + $companyName !== '' ? $companyName : null, + $personName !== '' ? $personName : null, + $phone !== '' ? $phone : null, + $email !== '' ? $email : null, + $extra ? json_encode($extra, JSON_UNESCAPED_UNICODE) : null, + $id, +]); + +logCurrent('update', 'fragment', 'preliminary_data', $id, [ + 'source_type' => $sourceType, + 'company_name' => $companyName, + 'person_name' => $personName, + 'phone' => $phone, + 'email' => $email, + 'extra' => $extra, +]); + +Response::success(null, '已保存,点击「转软碎片」完成转换'); diff --git a/static/js/config.js b/static/js/config.js index 48f1b41..79ada9b 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.43'; +var APP_VERSION = 'v1.0.44'; /** 页脚版权/备案信息(在 config.js 中修改) */ var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号'; diff --git a/static/js/fragment.js b/static/js/fragment.js index be2ff1e..656c944 100644 --- a/static/js/fragment.js +++ b/static/js/fragment.js @@ -298,44 +298,47 @@ $(function () { /* ================= 硬碎片:补全录入(转换) ================= */ window.convertHard = function (id) { httpGet('fragment/hard_detail.php', { id: id }).then(function (d) { + var ex = d.extra_info || {}; + if (typeof ex === 'string') { try { ex = JSON.parse(ex); } catch (e) { ex = {}; } } var typeSel = ''; + '' + + ''; var content = '
' + '
' + - '
' + typeSel + '
' + + '
' + typeSel + '
' + '
' + '
' + '
' + '
' + - '
' + - '
' + - '
' + - '
' + - '
' + + '
' + + '
' + + '
' + + '
' + '
' + + '
补全仅保存到硬数据,点击「转软碎片」后才转换为主表数据。
' + '' + + '' + '
'; var idx = Dialog.open({ - title: '硬碎片补全录入', + title: '硬数据继续补全', area: ['640px', 'auto'], content: content, btn: false }); + $('#cv-platform').val(ex.platform || ''); function syncFields() { var t = $('#cv-type').val(); $('#cv-f-company_name').toggle(t !== 'person'); - $('#cv-f-person_name').toggle(t === 'person'); - $('#cv-f-category').toggle(t === 'product' || t === 'need'); - $('#cv-f-industry').toggle(t === 'company'); - $('#cv-f-needcat').toggle(t === 'need'); - $('#cv-f-scenario').toggle(t === 'need'); + $('#cv-f-person_name').toggle(t === 'person' || t === 'mixed'); } $('#cv-type').on('change', syncFields); syncFields(); @@ -344,21 +347,23 @@ $(function () { $('#cv-form').on('submit', function (e) { e.preventDefault(); var fd = {}; - $(this).find('input, select, textarea').each(function () { + $(this).find('input, select').each(function () { var name = $(this).attr('name'); if (name) fd[name] = $(this).val(); }); fd.id = id; - fd.target_type = $('#cv-type').val(); - // 格式校验:手机 / 邮箱 + // 类型标准校验 + if (fd.source_type !== 'person' && fd.source_type !== 'mixed' && !$.trim(fd.company_name)) { Dialog.error('企业类型硬数据:企业名称为必填项'); return; } + if (fd.source_type === 'person' && !$.trim(fd.contact_phone) && !$.trim(fd.contact_email)) { Dialog.error('人员类型硬数据:手机号码、邮箱至少填写一项'); return; } + // 格式校验:手机 / 邮箱 / 身份证 / 主页链接 if (fd.contact_phone && !validatePhoneCN(fd.contact_phone)) { Dialog.error('手机号码格式不正确(应为国内 11 位手机号,如 13812345678)'); return; } if (fd.contact_email && !validateEmail(fd.contact_email)) { Dialog.error('邮箱格式不正确'); return; } - httpPost('fragment/hard_convert.php', fd).then(function () { - Dialog.success('转换成功', function () { + if (fd.id_number && !validateIdCard(fd.id_number)) { Dialog.error('身份证号码格式不正确(应为 15 或 18 位)'); return; } + if (fd.profile_url && !/^https?:\/\//.test(fd.profile_url)) { Dialog.error('主页链接格式不正确(应以 http:// 或 https:// 开头)'); return; } + httpPost('fragment/hard_update.php', fd).then(function () { + Dialog.success('已保存,点击「转软碎片」完成转换', function () { Dialog.close(idx); - loadStats(); loadHardList(hardPage); - loadSoftList(1); }); }); });