v1.0.47: 新增弹窗按类型动态字段(企业:名称/行业/注册号/联系人/电话邮箱/身份证/社媒;人员:姓名/电话邮箱/身份证/社媒;产品:名称/品类;需求:名称/需求类别)+各类型转软碎片要求(企业需名称+行业+注册号,人员需姓名+联系方式,产品需品类,需求需类别,前后端双校验)+preliminary_data加行业/注册号列

This commit is contained in:
nanguaboss
2026-08-10 00:45:29 +08:00
parent f8dfd0492b
commit 6cf2aabc91
6 changed files with 153 additions and 23 deletions
+11 -3
View File
@@ -29,6 +29,10 @@ $idNumber = trim($_POST['id_number'] ?? '');
$platform = trim($_POST['platform'] ?? ''); $platform = trim($_POST['platform'] ?? '');
$accountId = trim($_POST['account_id'] ?? ''); $accountId = trim($_POST['account_id'] ?? '');
$profileUrl = trim($_POST['profile_url'] ?? ''); $profileUrl = trim($_POST['profile_url'] ?? '');
$industry = trim($_POST['industry'] ?? ''); // 企业:行业
$registrationNum = trim($_POST['registration_number'] ?? ''); // 企业:注册号
$category = trim($_POST['target_product_category'] ?? ''); // 产品:品类(存 extra)
$needCategory = trim($_POST['need_category'] ?? ''); // 需求:需求类别(存 extra)
$sourceChannel = trim($_POST['source_channel'] ?? ''); $sourceChannel = trim($_POST['source_channel'] ?? '');
// 硬数据标准校验: // 硬数据标准校验:
@@ -70,12 +74,14 @@ if ($accountId !== '' && $platform !== '') {
} }
if (!empty($dups)) Response::duplicates($dups); if (!empty($dups)) Response::duplicates($dups);
// 额外信息(身份证/社媒平台/账号ID/主页链接)存 extra_info // 额外信息(身份证/社媒平台/账号ID/主页链接/产品品类/需求类别)存 extra_info
$extra = []; $extra = [];
if ($idNumber !== '') $extra['id_number'] = $idNumber; if ($idNumber !== '') $extra['id_number'] = $idNumber;
if ($platform !== '') $extra['platform'] = $platform; if ($platform !== '') $extra['platform'] = $platform;
if ($accountId !== '') $extra['account_id'] = $accountId; if ($accountId !== '') $extra['account_id'] = $accountId;
if ($profileUrl !== '') $extra['profile_url'] = $profileUrl; if ($profileUrl !== '') $extra['profile_url'] = $profileUrl;
if ($category !== '') $extra['category'] = $category;
if ($needCategory !== '') $extra['need_category'] = $needCategory;
// 至少有一项内容才能录为碎片 // 至少有一项内容才能录为碎片
if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && !$extra) { if ($companyName === '' && $personName === '' && $phone === '' && $email === '' && !$extra) {
@@ -84,12 +90,14 @@ if ($companyName === '' && $personName === '' && $phone === '' && $email === ''
$pdo->prepare( $pdo->prepare(
"INSERT INTO preliminary_data "INSERT INTO preliminary_data
(source_type, company_name, person_name, contact_phone, contact_email, (source_type, company_name, industry, registration_number, person_name, contact_phone, contact_email,
source_channel, recorded_by, status, extra_info) source_channel, recorded_by, status, extra_info)
VALUES (?, ?, ?, ?, ?, ?, ?, '待处理', ?)" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, '待处理', ?)"
)->execute([ )->execute([
$sourceType, $sourceType,
$companyName !== '' ? $companyName : null, $companyName !== '' ? $companyName : null,
$industry !== '' ? $industry : null,
$registrationNum !== '' ? $registrationNum : null,
$personName !== '' ? $personName : null, $personName !== '' ? $personName : null,
$phone !== '' ? $phone : null, $phone !== '' ? $phone : null,
$email !== '' ? $email : null, $email !== '' ? $email : null,
+55 -10
View File
@@ -41,15 +41,63 @@ $phone = trim($_POST['contact_phone'] ?? ($frag['contact_phone'] ?? ''));
$email = trim($_POST['contact_email'] ?? ($frag['contact_email'] ?? '')); $email = trim($_POST['contact_email'] ?? ($frag['contact_email'] ?? ''));
$category = trim($_POST['target_product_category'] ?? ''); // 仅补全录入表单提供(表中已无该字段) $category = trim($_POST['target_product_category'] ?? ''); // 仅补全录入表单提供(表中已无该字段)
$description = trim($_POST['description'] ?? ''); // 仅补全录入表单提供 $description = trim($_POST['description'] ?? ''); // 仅补全录入表单提供
$industry = trim($_POST['industry'] ?? ''); $industry = trim($_POST['industry'] ?? ($frag['industry'] ?? '')); // 企业:行业(转软碎片必填)
$registrationNum = trim($_POST['registration_number'] ?? ($frag['registration_number'] ?? '')); // 企业:注册号(转软碎片必填)
$sourceChannel = $frag['source_channel'] ?? null; $sourceChannel = $frag['source_channel'] ?? null;
// 补全表单额外信息(extra_info)
$fragExtra = json_decode($frag['extra_info'] ?? 'null', true);
if (!is_array($fragExtra)) {
$fragExtra = [];
}
if ($category === '') $category = trim((string)($fragExtra['category'] ?? ''));
$needCategory = trim($_POST['need_category'] ?? ($fragExtra['need_category'] ?? ''));
$convertedId = 0; $convertedId = 0;
// 格式校验:手机 / 邮箱 // 格式校验:手机 / 邮箱
checkFieldFormat('phone', $phone); checkFieldFormat('phone', $phone);
checkFieldFormat('email', $email); checkFieldFormat('email', $email);
// 各类型转软碎片基本要求
switch ($targetType) {
case 'company':
if ($companyName === '') {
Response::error('企业类型转软碎片:企业名称为必填项,请先「继续补全」', 400);
}
if ($industry === '') {
Response::error('企业类型转软碎片:行业为必填项,请先「继续补全」填写行业', 400);
}
if ($registrationNum === '') {
Response::error('企业类型转软碎片:注册号为必填项,请先「继续补全」填写注册号', 400);
}
break;
case 'person':
if ($personName === '') {
Response::error('人员类型转软碎片:姓名为必填项,请先「继续补全」', 400);
}
if ($phone === '' && $email === '') {
Response::error('人员类型转软碎片:手机号码、邮箱至少填写一项,请先「继续补全」', 400);
}
break;
case 'product':
if ($companyName === '') {
Response::error('产品类型转软碎片:公司名称为必填项,请先「继续补全」', 400);
}
if ($category === '') {
Response::error('产品类型转软碎片:产品品类为必填项,请先「继续补全」填写品类', 400);
}
break;
case 'need':
if ($companyName === '') {
Response::error('需求类型转软碎片:公司名称为必填项,请先「继续补全」', 400);
}
if ($needCategory === '') {
Response::error('需求类型转软碎片:需求类别为必填项,请先「继续补全」填写需求类别', 400);
}
break;
}
// 唯一性校验:按目标类型,收集全部重复 // 唯一性校验:按目标类型,收集全部重复
$dups = []; $dups = [];
if ($targetType === 'company' && $companyName !== '') { if ($targetType === 'company' && $companyName !== '') {
@@ -79,7 +127,7 @@ $saveContacts = function ($ownerType, $ownerId) use ($pdo, $phone, $email) {
}; };
/** 按名称找公司,找不到则自动创建 */ /** 按名称找公司,找不到则自动创建 */
$resolveCompany = function () use ($pdo, $companyName, $sourceChannel, $industry) { $resolveCompany = function () use ($pdo, $companyName, $sourceChannel, $industry, $registrationNum) {
$stmt = $pdo->prepare("SELECT id FROM companies WHERE display_name = ? AND is_active = 1 LIMIT 1"); $stmt = $pdo->prepare("SELECT id FROM companies WHERE display_name = ? AND is_active = 1 LIMIT 1");
$stmt->execute([$companyName]); $stmt->execute([$companyName]);
$cid = (int)$stmt->fetchColumn(); $cid = (int)$stmt->fetchColumn();
@@ -87,22 +135,20 @@ $resolveCompany = function () use ($pdo, $companyName, $sourceChannel, $industry
return $cid; return $cid;
} }
$pdo->prepare( $pdo->prepare(
"INSERT INTO companies (display_name, name_zh, industry, source_channel) VALUES (?, ?, ?, ?)" "INSERT INTO companies (display_name, name_zh, industry, registration_number, source_channel) VALUES (?, ?, ?, ?, ?)"
)->execute([$companyName, $companyName, $industry !== '' ? $industry : null, $sourceChannel]); )->execute([$companyName, $companyName, $industry !== '' ? $industry : null, $registrationNum !== '' ? $registrationNum : null, $sourceChannel]);
return (int)$pdo->lastInsertId(); return (int)$pdo->lastInsertId();
}; };
switch ($targetType) { switch ($targetType) {
case 'company': case 'company':
if ($companyName === '') {
Response::error('公司名称为必填项', 400);
}
$pdo->prepare( $pdo->prepare(
"INSERT INTO companies (display_name, name_zh, industry, business_scope, source_channel, source_detail) "INSERT INTO companies (display_name, name_zh, industry, registration_number, business_scope, source_channel, source_detail)
VALUES (?, ?, ?, ?, ?, ?)" VALUES (?, ?, ?, ?, ?, ?, ?)"
)->execute([ )->execute([
$companyName, $companyName, $companyName, $companyName,
$industry !== '' ? $industry : null, $industry !== '' ? $industry : null,
$registrationNum !== '' ? $registrationNum : null,
$description !== '' ? $description : null, $description !== '' ? $description : null,
$sourceChannel, $sourceChannel,
$description !== '' ? $description : null, $description !== '' ? $description : null,
@@ -149,7 +195,6 @@ switch ($targetType) {
} }
$companyId = $resolveCompany(); $companyId = $resolveCompany();
$contactPerson = trim($_POST['contact_person'] ?? ($frag['person_name'] ?? '')); $contactPerson = trim($_POST['contact_person'] ?? ($frag['person_name'] ?? ''));
$needCategory = trim($_POST['need_category'] ?? '');
$scenario = trim($_POST['application_scenario'] ?? ''); $scenario = trim($_POST['application_scenario'] ?? '');
$pdo->prepare( $pdo->prepare(
"INSERT INTO company_needs (company_id, contact_person, need_category, target_product_category, application_scenario, description) "INSERT INTO company_needs (company_id, contact_person, need_category, target_product_category, application_scenario, description)
+11 -2
View File
@@ -39,6 +39,10 @@ $idNumber = trim($_POST['id_number'] ?? '');
$platform = trim($_POST['platform'] ?? ''); $platform = trim($_POST['platform'] ?? '');
$accountId = trim($_POST['account_id'] ?? ''); $accountId = trim($_POST['account_id'] ?? '');
$profileUrl = trim($_POST['profile_url'] ?? ''); $profileUrl = trim($_POST['profile_url'] ?? '');
$industry = trim($_POST['industry'] ?? ''); // 企业:行业
$registrationNum = trim($_POST['registration_number'] ?? ''); // 企业:注册号
$category = trim($_POST['target_product_category'] ?? ''); // 产品:品类
$needCategory = trim($_POST['need_category'] ?? ''); // 需求:需求类别
if (!in_array($sourceType, ['company', 'person', 'product', 'need', 'mixed'], true)) { if (!in_array($sourceType, ['company', 'person', 'product', 'need', 'mixed'], true)) {
Response::error('碎片类型不合法', 400); Response::error('碎片类型不合法', 400);
} }
@@ -80,7 +84,7 @@ if ($accountId !== '' && $platform !== '') {
} }
if (!empty($dups)) Response::duplicates($dups); if (!empty($dups)) Response::duplicates($dups);
// extra_info 合并更新(身份证/平台/账号ID/主页链接) // extra_info 合并更新(身份证/平台/账号ID/主页链接/品类/需求类别)
$extra = json_decode($frag['extra_info'] ?? 'null', true); $extra = json_decode($frag['extra_info'] ?? 'null', true);
if (!is_array($extra)) { if (!is_array($extra)) {
$extra = []; $extra = [];
@@ -89,14 +93,19 @@ if ($idNumber !== '') $extra['id_number'] = $idNumber; else unset($extra['id_num
if ($platform !== '') $extra['platform'] = $platform; else unset($extra['platform']); if ($platform !== '') $extra['platform'] = $platform; else unset($extra['platform']);
if ($accountId !== '') $extra['account_id'] = $accountId; else unset($extra['account_id']); if ($accountId !== '') $extra['account_id'] = $accountId; else unset($extra['account_id']);
if ($profileUrl !== '') $extra['profile_url'] = $profileUrl; else unset($extra['profile_url']); if ($profileUrl !== '') $extra['profile_url'] = $profileUrl; else unset($extra['profile_url']);
if ($category !== '') $extra['category'] = $category; else unset($extra['category']);
if ($needCategory !== '') $extra['need_category'] = $needCategory; else unset($extra['need_category']);
$pdo->prepare( $pdo->prepare(
"UPDATE preliminary_data "UPDATE preliminary_data
SET source_type = ?, company_name = ?, person_name = ?, contact_phone = ?, contact_email = ?, extra_info = ? SET source_type = ?, company_name = ?, industry = ?, registration_number = ?, person_name = ?,
contact_phone = ?, contact_email = ?, extra_info = ?
WHERE id = ?" WHERE id = ?"
)->execute([ )->execute([
$sourceType, $sourceType,
$companyName !== '' ? $companyName : null, $companyName !== '' ? $companyName : null,
$industry !== '' ? $industry : null,
$registrationNum !== '' ? $registrationNum : null,
$personName !== '' ? $personName : null, $personName !== '' ? $personName : null,
$phone !== '' ? $phone : null, $phone !== '' ? $phone : null,
$email !== '' ? $email : null, $email !== '' ? $email : null,
+9
View File
@@ -0,0 +1,9 @@
-- ============================================================
-- SuperLink Web - v1.0.47 数据库结构变更
-- preliminary_data 增加企业重要字段:行业 / 注册号(转软碎片必要条件)
-- ============================================================
SET NAMES utf8mb4;
ALTER TABLE `preliminary_data`
ADD COLUMN `industry` varchar(100) DEFAULT NULL COMMENT '行业(企业转软碎片必填)' AFTER `company_name`,
ADD COLUMN `registration_number` varchar(100) DEFAULT NULL COMMENT '企业注册号(企业转软碎片必填)' AFTER `industry`;
+1 -1
View File
@@ -5,7 +5,7 @@ var BASE_URL = '/api/';
var PAGE_SIZE = 20; var PAGE_SIZE = 20;
/** 系统版本号(logo旁展示):修改代码后运行 tools/bump_version.php 自动递增 */ /** 系统版本号(logo旁展示):修改代码后运行 tools/bump_version.php 自动递增 */
var APP_VERSION = 'v1.0.46'; var APP_VERSION = 'v1.0.47';
/** 页脚版权/备案信息(在 config.js 中修改) */ /** 页脚版权/备案信息(在 config.js 中修改) */
var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号'; var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号';
+66 -7
View File
@@ -204,9 +204,13 @@ $(function () {
'<div class="form-grid">' + '<div class="form-grid">' +
' <div class="form-item"><label>碎片类型<span class="req">*</span></label>' + typeSel + '</div>' + ' <div class="form-item"><label>碎片类型<span class="req">*</span></label>' + typeSel + '</div>' +
' <div class="form-item" id="ha-f-company_name"><label>公司名称</label><input type="text" name="company_name" placeholder="如:深圳XX科技"></div>' + ' <div class="form-item" id="ha-f-company_name"><label>公司名称</label><input type="text" name="company_name" placeholder="如:深圳XX科技"></div>' +
' <div class="form-item" id="ha-f-person_name"><label>联系人</label><input type="text" name="person_name" placeholder="如:张三"></div>' + ' <div class="form-item" id="ha-f-person_name"><label>姓名</label><input type="text" name="person_name" placeholder="如:张三"></div>' +
' <div class="form-item"><label>联系电话</label><input type="text" name="contact_phone" placeholder="如:13812345678"></div>' + ' <div class="form-item"><label>联系电话</label><input type="text" name="contact_phone" placeholder="如:13812345678"></div>' +
' <div class="form-item"><label>联系邮箱</label><input type="text" name="contact_email" placeholder="如:a@b.com"></div>' + ' <div class="form-item"><label>联系邮箱</label><input type="text" name="contact_email" placeholder="如:a@b.com"></div>' +
' <div class="form-item" id="ha-f-industry"><label>行业</label><input type="text" name="industry" placeholder="转软碎片必填,如:工业机器人"></div>' +
' <div class="form-item" id="ha-f-regnum"><label>注册号</label><input type="text" name="registration_number" placeholder="转软碎片必填"></div>' +
' <div class="form-item" id="ha-f-category"><label>产品品类</label><input type="text" name="target_product_category" placeholder="转软碎片必填,如:工业机器人"></div>' +
' <div class="form-item" id="ha-f-needcat"><label>需求类别</label><input type="text" name="need_category" placeholder="转软碎片必填,如:设备采购"></div>' +
' <div class="form-item" id="ha-f-idnumber"><label>身份证号码</label><input type="text" name="id_number" placeholder="15 或 18 位"></div>' + ' <div class="form-item" id="ha-f-idnumber"><label>身份证号码</label><input type="text" name="id_number" placeholder="15 或 18 位"></div>' +
' <div class="form-item"><label>来源渠道</label><select name="source_channel" id="ha-source"><option value="">-</option></select></div>' + ' <div class="form-item"><label>来源渠道</label><select name="source_channel" id="ha-source"><option value="">-</option></select></div>' +
' <div class="form-item" id="ha-f-platform"><label>社媒平台</label><select name="platform" id="ha-platform"><option value="">-</option>' + ' <div class="form-item" id="ha-f-platform"><label>社媒平台</label><select name="platform" id="ha-platform"><option value="">-</option>' +
@@ -215,7 +219,6 @@ $(function () {
' <option value="other">其他</option></select></div>' + ' <option value="other">其他</option></select></div>' +
' <div class="form-item" id="ha-f-account"><label>账号ID</label><input type="text" name="account_id" placeholder="社媒账号ID"></div>' + ' <div class="form-item" id="ha-f-account"><label>账号ID</label><input type="text" name="account_id" placeholder="社媒账号ID"></div>' +
' <div class="form-item" id="ha-f-profile"><label>主页链接</label><input type="text" name="profile_url" placeholder="https://..."></div>' + ' <div class="form-item" id="ha-f-profile"><label>主页链接</label><input type="text" name="profile_url" placeholder="https://..."></div>' +
' <div class="form-item full"><label>原始描述</label><textarea name="description" style="height:70px;" placeholder="记录原始线索信息"></textarea></div>' +
'</div>' + '</div>' +
'<div class="dialog-footer"><button type="button" class="btn" id="ha-cancel">取消</button>' + '<div class="dialog-footer"><button type="button" class="btn" id="ha-cancel">取消</button>' +
'<button type="submit" class="btn btn-primary">保存碎片</button></div>' + '<button type="submit" class="btn btn-primary">保存碎片</button></div>' +
@@ -239,8 +242,23 @@ $(function () {
function syncFields() { function syncFields() {
var t = $('#ha-type').val(); var t = $('#ha-type').val();
// 公司名称:除人员外都显示
$('#ha-f-company_name').toggle(t !== 'person'); $('#ha-f-company_name').toggle(t !== 'person');
$('#ha-f-person_name').toggle(t === 'person' || t === 'mixed'); // 姓名/联系人:人员与混合显示「姓名」,其它类型显示「联系人」
$('#ha-f-person_name').toggle(true);
$('#ha-f-person_name label').text((t === 'person' || t === 'mixed') ? '姓名' : '联系人');
// 企业专属:行业 / 注册号
$('#ha-f-industry').toggle(t === 'company');
$('#ha-f-regnum').toggle(t === 'company');
// 产品:品类;需求:需求类别
$('#ha-f-category').toggle(t === 'product');
$('#ha-f-needcat').toggle(t === 'need');
// 身份证 / 社媒平台 / 账号 / 主页:企业与人员显示
var showIdSocial = (t === 'company' || t === 'person');
$('#ha-f-idnumber').toggle(showIdSocial);
$('#ha-f-platform').toggle(showIdSocial);
$('#ha-f-account').toggle(showIdSocial);
$('#ha-f-profile').toggle(showIdSocial);
} }
$('#ha-type').on('change', syncFields); $('#ha-type').on('change', syncFields);
syncFields(); syncFields();
@@ -314,13 +332,17 @@ $(function () {
' <div class="form-item" id="cv-f-person_name"><label>联系人</label><input type="text" name="person_name" value="' + escHtml(d.person_name || '') + '"></div>' + ' <div class="form-item" id="cv-f-person_name"><label>联系人</label><input type="text" name="person_name" value="' + escHtml(d.person_name || '') + '"></div>' +
' <div class="form-item"><label>联系电话</label><input type="text" name="contact_phone" value="' + escHtml(d.contact_phone || '') + '"></div>' + ' <div class="form-item"><label>联系电话</label><input type="text" name="contact_phone" value="' + escHtml(d.contact_phone || '') + '"></div>' +
' <div class="form-item"><label>联系邮箱</label><input type="text" name="contact_email" value="' + escHtml(d.contact_email || '') + '"></div>' + ' <div class="form-item"><label>联系邮箱</label><input type="text" name="contact_email" value="' + escHtml(d.contact_email || '') + '"></div>' +
' <div class="form-item"><label>身份证号码</label><input type="text" name="id_number" value="' + escHtml(ex.id_number || '') + '" placeholder="15 或 18 位"></div>' + ' <div class="form-item" id="cv-f-industry"><label>行业</label><input type="text" name="industry" value="' + escHtml(d.industry || '') + '" placeholder="转软碎片必填"></div>' +
' <div class="form-item"><label>社媒平台</label><select name="platform" id="cv-platform"><option value="">-</option>' + ' <div class="form-item" id="cv-f-regnum"><label>注册号</label><input type="text" name="registration_number" value="' + escHtml(d.registration_number || '') + '" placeholder="转软碎片必填"></div>' +
' <div class="form-item" id="cv-f-category"><label>产品品类</label><input type="text" name="target_product_category" value="' + escHtml(ex.category || '') + '" placeholder="转软碎片必填"></div>' +
' <div class="form-item" id="cv-f-needcat"><label>需求类别</label><input type="text" name="need_category" value="' + escHtml(ex.need_category || '') + '" placeholder="转软碎片必填"></div>' +
' <div class="form-item" id="cv-f-idnumber"><label>身份证号码</label><input type="text" name="id_number" value="' + escHtml(ex.id_number || '') + '" placeholder="15 或 18 位"></div>' +
' <div class="form-item" id="cv-f-platform"><label>社媒平台</label><select name="platform" id="cv-platform"><option value="">-</option>' +
' <option value="wechat">微信</option><option value="weibo">微博</option><option value="douyin">抖音</option>' + ' <option value="wechat">微信</option><option value="weibo">微博</option><option value="douyin">抖音</option>' +
' <option value="bilibili">B站</option><option value="linkedin">领英</option><option value="xiaohongshu">小红书</option>' + ' <option value="bilibili">B站</option><option value="linkedin">领英</option><option value="xiaohongshu">小红书</option>' +
' <option value="other">其他</option></select></div>' + ' <option value="other">其他</option></select></div>' +
' <div class="form-item"><label>账号ID</label><input type="text" name="account_id" value="' + escHtml(ex.account_id || '') + '" placeholder="社媒账号ID"></div>' + ' <div class="form-item" id="cv-f-account"><label>账号ID</label><input type="text" name="account_id" value="' + escHtml(ex.account_id || '') + '" placeholder="社媒账号ID"></div>' +
' <div class="form-item"><label>主页链接</label><input type="text" name="profile_url" value="' + escHtml(ex.profile_url || '') + '" placeholder="https://..."></div>' + ' <div class="form-item" id="cv-f-profile"><label>主页链接</label><input type="text" name="profile_url" value="' + escHtml(ex.profile_url || '') + '" placeholder="https://..."></div>' +
'</div>' + '</div>' +
'<div style="font-size:12px;color:#8a94a6;margin-top:4px;">补全仅保存到硬数据,点击「转软碎片」后才转换为主表数据。</div>' + '<div style="font-size:12px;color:#8a94a6;margin-top:4px;">补全仅保存到硬数据,点击「转软碎片」后才转换为主表数据。</div>' +
'<div class="dialog-footer"><button type="button" class="btn" id="cv-cancel">取消</button>' + '<div class="dialog-footer"><button type="button" class="btn" id="cv-cancel">取消</button>' +
@@ -335,6 +357,24 @@ $(function () {
}); });
$('#cv-platform').val(ex.platform || ''); $('#cv-platform').val(ex.platform || '');
function syncFields() {
var t = $('#cv-type').val();
$('#cv-f-company_name').toggle(t !== 'person');
$('#cv-f-person_name').toggle(true);
$('#cv-f-person_name label').text((t === 'person' || t === 'mixed') ? '姓名' : '联系人');
$('#cv-f-industry').toggle(t === 'company');
$('#cv-f-regnum').toggle(t === 'company');
$('#cv-f-category').toggle(t === 'product');
$('#cv-f-needcat').toggle(t === 'need');
var showIdSocial = (t === 'company' || t === 'person');
$('#cv-f-idnumber').toggle(showIdSocial);
$('#cv-f-platform').toggle(showIdSocial);
$('#cv-f-account').toggle(showIdSocial);
$('#cv-f-profile').toggle(showIdSocial);
}
$('#cv-type').on('change', syncFields);
syncFields();
function syncFields() { function syncFields() {
var t = $('#cv-type').val(); var t = $('#cv-type').val();
$('#cv-f-company_name').toggle(t !== 'person'); $('#cv-f-company_name').toggle(t !== 'person');
@@ -381,6 +421,25 @@ $(function () {
Dialog.error('该碎片缺少可转换信息,请使用「继续补全」'); Dialog.error('该碎片缺少可转换信息,请使用「继续补全」');
return; return;
} }
var ex = d.extra_info || {};
if (typeof ex === 'string') { try { ex = JSON.parse(ex); } catch (e) { ex = {}; } }
// 各类型转软碎片基本要求预检
if (target === 'company' && (!d.industry || !d.registration_number)) {
Dialog.error('企业类型转软碎片:请先「继续补全」填写行业和注册号');
return;
}
if (target === 'person' && !d.person_name) {
Dialog.error('人员类型转软碎片:请先「继续补全」填写姓名');
return;
}
if (target === 'product' && !ex.category) {
Dialog.error('产品类型转软碎片:请先「继续补全」填写产品品类');
return;
}
if (target === 'need' && !ex.need_category) {
Dialog.error('需求类型转软碎片:请先「继续补全」填写需求类别');
return;
}
Dialog.confirm('确定将该硬数据直接转换为软数据碎片吗?', function () { Dialog.confirm('确定将该硬数据直接转换为软数据碎片吗?', function () {
httpPost('fragment/hard_convert.php', { id: id, target_type: target }).then(function () { httpPost('fragment/hard_convert.php', { id: id, target_type: target }).then(function () {
Dialog.success('已转为软碎片', function () { Dialog.success('已转为软碎片', function () {