This commit is contained in:
nanguaboss
2026-08-06 00:50:23 +08:00
parent 595520822a
commit 2cb688ed46
29 changed files with 5227 additions and 186 deletions
+55 -16
View File
@@ -88,21 +88,49 @@ $(function () {
/* ---------- 新增/编辑 ---------- */
$('#btn-add').on('click', function () {
httpGet('company/cert_types.php').then(function (d) {
openForm(null, [], [], d.types || []);
loadDicts().then(function (dicts) {
openForm(null, [], [], d.types || [], dicts);
});
});
});
window.editCompany = function (id) {
httpGet('company/detail.php', { id: id }).then(function (d) {
openForm(d.company, d.financials, d.certifications, d.certification_types);
loadDicts().then(function (dicts) {
openForm(d.company, d.financials, d.certifications, d.certification_types, dicts);
});
});
};
function openForm(company, financials, certifications, certTypes) {
/** 拉取数据字典(国家/行业/来源渠道),供表单下拉使用 */
function loadDicts() {
return httpGet('common/dicts.php', { type: 'all' }).catch(function () {
return { countries: [], industries: [], source_channels: [] };
});
}
/** 生成下拉选项:value 与当前值匹配则选中;若当前值不在字典中则追加一个选项保留原值 */
function dictOptions(list, cur, labelKey) {
var html = '<option value="">-</option>';
var found = false;
(list || []).forEach(function (item) {
var name = item[labelKey || 'name'];
var sel = (String(name) === String(cur)) ? ' selected' : '';
if (sel) found = true;
html += '<option value="' + escHtml(name) + '"' + sel + '>' + escHtml(name) + '</option>';
});
if (cur && !found) {
html += '<option value="' + escHtml(cur) + '" selected>' + escHtml(cur) + '(自定义)</option>';
}
return html;
}
function openForm(company, financials, certifications, certTypes, dicts) {
var isEdit = !!company;
var c = company || {};
financials = financials || [];
certifications = certifications || [];
certTypes = certTypes || [];
dicts = dicts || {};
// Tab1 工商信息
var bizHtml =
@@ -113,7 +141,7 @@ $(function () {
' <button type="button" class="btn btn-sm" id="btn-gongshang-query" title="预留:后续接入工商查询API,自动填写公司名称/注册号/注册地址等">工商查询</button>' +
' </div></div>' +
' <div class="form-item"><label>英文名称</label><input type="text" name="name_en" value="' + escHtml(c.name_en) + '"></div>' +
' <div class="form-item"><label>国家/地区</label><input type="text" name="country" value="' + escHtml(c.country) + '"></div>' +
' <div class="form-item"><label>国家/地区</label><select name="country">' + dictOptions(dicts.countries, c.country) + '</select></div>' +
' <div class="form-item"><label>注册号</label><input type="text" name="registration_number" value="' + escHtml(c.registration_number) + '"></div>' +
' <div class="form-item"><label>注册地址</label><input type="text" name="address" value="' + escHtml(c.address) + '"></div>' +
' <div class="form-item"><label>法律形式</label><input type="text" name="legal_form" value="' + escHtml(c.legal_form) + '"></div>' +
@@ -127,9 +155,11 @@ $(function () {
var indHtml =
'<div class="form-grid">' +
' <div class="form-item"><label>业务角色</label><select name="business_role">' + roleOptions(c.business_role) + '</select></div>' +
' <div class="form-item"><label>行业</label><input type="text" name="industry" value="' + escHtml(c.industry) + '"></div>' +
' <div class="form-item"><label>行业</label><select name="industry">' + dictOptions(dicts.industries, c.industry) + '</select></div>' +
' <div class="form-item"><label>行业细分</label><input type="text" name="industry_subdivision" value="' + escHtml(c.industry_subdivision) + '"></div>' +
' <div class="form-item"><label>官网</label><input type="text" name="website" value="' + escHtml(c.website) + '"></div>' +
' <div class="form-item"><label>来源渠道</label><select name="source_channel">' + dictOptions(dicts.source_channels, c.source_channel) + '</select></div>' +
' <div class="form-item"><label>来源详情</label><input type="text" name="source_detail" value="' + escHtml(c.source_detail) + '" placeholder="如:华南工博会"></div>' +
'</div>';
// Tab3 财务信息:顶部独立字段(是否上市/股票代码/最新员工/最新营收)+ 年度财务明细列表
@@ -350,6 +380,24 @@ $(function () {
window.viewCompany = function (id) {
httpGet('company/detail.php', { id: id }).then(function (d) {
var c = d.company;
// 联系方式列表(social_accounts 中属于该公司的记录,仅展示)
var accountsHtml = '';
(d.accounts || []).forEach(function (a) {
var tag = '';
if (a.is_defult) tag = ' <span class="tag">常用</span>';
else if (a.is_primary) tag = ' <span class="tag">默认</span>';
accountsHtml += '<tr>' +
'<td>' + escHtml(a.platform || '-') + '</td>' +
'<td>' + escHtml(a.account_id || '-') + '</td>' +
'<td>' + (a.profile_url ? '<a href="' + escHtml(a.profile_url) + '" target="_blank">打开</a>' : '-') + '</td>' +
'<td>' + escHtml(a.remark || '-') + '</td>' +
'<td>' + (a.is_active ? '<span class="tag tag-green">启用</span>' : '<span class="tag tag-gray">停用</span>') + tag + '</td>' +
'</tr>';
});
var accountsSection = accountsHtml
? '<table class="grid" style="font-size:12px;"><tr><th>平台</th><th>账号/号码</th><th>主页链接</th><th>备注</th><th>状态</th></tr>' + accountsHtml + '</table>'
: '<div style="font-size:13px;color:#b6bfcc;">暂无联系方式</div>';
var html =
'<div style="padding:18px 22px;">' +
' <h3 style="margin-bottom:14px;">' + escHtml(c.name_zh || c.name_en || '企业 #' + c.id) + '</h3>' +
@@ -362,9 +410,10 @@ $(function () {
detailRow('注册资本', c.registered_capital) + detailRow('成立日期', c.established_date) +
detailRow('员工数', c.latest_employee_count) + detailRow('年营收', c.latest_annual_revenue) +
detailRow('是否上市', c.is_listed ? '是' : '否') + detailRow('股票代码', c.stock_code) +
detailRow('来源渠道', c.source_channel) + detailRow('来源详情', c.source_detail) +
'</div>' +
' <h4 style="margin:16px 0 8px;">经营范围</h4><div style="font-size:13px;color:#5a6472;">' + escHtml(c.business_scope || '-') + '</div>' +
' <h4 style="margin:16px 0 8px;">关联需求</h4>' + miniTable(['联系人', '需求大类', '意向品类', '场景'], d.needs.map(function (n) { return [n.contact_person || '-', n.need_category || '-', n.target_product_category || '-', n.application_scenario || '-']; })) +
' <h4 style="margin:16px 0 8px;">联系方式</h4>' + accountsSection +
'</div>';
Dialog.open({ title: '企业详情', area: ['820px', 'auto'], content: html, btn: ['关闭'] });
});
@@ -374,16 +423,6 @@ $(function () {
return '<div><b>' + label + ':</b>' + escHtml(val || '-') + '</div>';
}
function miniTable(headers, rows) {
if (!rows.length) return '<div style="font-size:13px;color:#b6bfcc;">暂无数据</div>';
var html = '<table class="grid" style="font-size:12px;">';
html += '<tr>' + headers.map(function (h) { return '<th>' + h + '</th>'; }).join('') + '</tr>';
rows.forEach(function (r) {
html += '<tr>' + r.map(function (v) { return '<td>' + escHtml(v) + '</td>'; }).join('') + '</tr>';
});
return html + '</table>';
}
/* ---------- 员工列表弹窗(按公司查看员工,分页 + 姓名/职级筛选) ---------- */
var empCompanyId = 0;
var empPage = 1;
+1 -1
View File
@@ -5,7 +5,7 @@ var BASE_URL = '/api/';
var PAGE_SIZE = 20;
/** 系统版本号(logo旁展示):修改代码后运行 tools/bump_version.php 自动递增 */
var APP_VERSION = 'v1.0.15';
var APP_VERSION = 'v1.0.17';
/** 页脚版权/备案信息(在 config.js 中修改) */
var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号';
+26 -2
View File
@@ -118,9 +118,14 @@ $(function () {
' <option value="company"' + (m.owner_type === 'company' ? ' selected' : '') + '>企业</option></select></div>' +
' <div class="form-item"><label>归属ID<span class="req">*</span></label><input type="number" name="owner_id" value="' + escHtml(m.owner_id) + '" ' + (isEdit ? 'disabled' : '') + '></div>' +
' <div class="form-item"><label>平台<span class="req">*</span></label>' +
' <select name="platform">' + platformOpts(m.platform) + '</select></div>' +
' <div class="form-item"><label>账号/号码<span class="req">*</span></label><input type="text" name="account_id" value="' + escHtml(m.account_id) + '"></div>' +
' <select name="platform" id="media-platform">' + platformOpts(m.platform) + '</select></div>' +
' <div class="form-item"><label>账号/号码<span class="req">*</span></label>' +
' <div><input type="text" name="account_id" id="media-account" value="' + escHtml(m.account_id) + '">' +
' <div class="geo-hint" id="media-account-geo" style="font-size:12px;color:#2f8f46;margin-top:4px;display:none;"></div></div></div>' +
' <div class="form-item"><label>主页链接</label><input type="text" name="profile_url" value="' + escHtml(m.profile_url) + '"></div>' +
' <div class="form-item"><label>是否常用</label><select name="is_defult">' +
' <option value="0"' + (!m.is_defult ? ' selected' : '') + '>备用</option>' +
' <option value="1"' + (m.is_defult ? ' selected' : '') + '>常用</option></select></div>' +
' <div class="form-item"><label>默认联系方式</label><select name="is_primary">' +
' <option value="0"' + (!m.is_primary ? ' selected' : '') + '>否</option>' +
' <option value="1"' + (m.is_primary ? ' selected' : '') + '>是</option></select></div>' +
@@ -144,6 +149,25 @@ $(function () {
$('#form-cancel').on('click', function () { Dialog.close(idx); });
// 手机号归属地自动识别(平台为 phone 时,录入号码自动识别归属地)
var $geo = $('#media-account-geo');
var bindGeo = function () {
if ($('#media-platform').val() !== 'phone') { $geo.text('').hide(); return; }
$('#media-account').off('blur.geo').on('blur.geo', function () {
var val = $.trim($(this).val());
if (!val) { $geo.text('').hide(); return; }
httpGet('common/phone_geo.php', { phone: val }).then(function (d) {
if (d && d.label && d.label !== '未知') {
$geo.text('归属地:' + d.label).show();
} else {
$geo.text('归属地:未能识别').show();
}
}).catch(function () { $geo.text('').hide(); });
});
};
$('#media-platform').on('change', bindGeo);
bindGeo();
$('#media-form').on('submit', function (e) {
e.preventDefault();
var data = {};
+197 -107
View File
@@ -30,7 +30,7 @@ $(function () {
' <button class="btn" id="btn-export">导出</button>' +
' </div>' +
' <div class="table-wrap"><table class="grid">' +
' <thead><tr><th><input type="checkbox" id="check-all"></th><th>ID</th><th>姓名</th><th>性别</th><th>国籍</th><th>工作所在地</th><th>家乡</th><th>学历</th><th>联系方式</th><th>创建时间</th><th>操作</th></tr></thead>' +
' <thead><tr><th><input type="checkbox" id="check-all"></th><th>ID</th><th>姓名</th><th>性别</th><th>国籍</th><th>工作所在地</th><th>家乡</th><th>学历</th><th>手机</th><th>邮箱</th><th>创建时间</th><th>操作</th></tr></thead>' +
' <tbody id="person-tbody"></tbody>' +
' </table></div>' +
' <div class="pagination" id="pagination"></div>' +
@@ -58,17 +58,17 @@ $(function () {
'<td>' + escHtml(r.work_location || '-') + '</td>' +
'<td>' + escHtml(r.hometown || '-') + '</td>' +
'<td>' + escHtml(r.education || '-') + '</td>' +
'<td title="' + escHtml(r.contacts || '') + '">' + escHtml((r.contacts || '-').substring(0, 40)) + '</td>' +
'<td>' + escHtml(r.phone || '-') + '</td>' +
'<td title="' + escHtml(r.email || '') + '">' + escHtml((r.email || '-').substring(0, 30)) + '</td>' +
'<td>' + fmtDate(r.created_at) + '</td>' +
'<td class="ops">' +
' <a onclick="viewPerson(' + r.id + ')">详情</a>' +
' <a onclick="viewCompanies(' + r.id + ')">公司</a>' +
' <a onclick="viewPersonProducts(' + r.id + ')">产品</a>' +
' <a onclick="viewResume(' + r.id + ')">履历</a>' +
' <a onclick="editPerson(' + r.id + ')">编辑</a>' +
'</td></tr>';
});
if (!rows.length) {
html = '<tr><td colspan="11" class="empty-tip" style="padding:40px 0;">暂无数据</td></tr>';
html = '<tr><td colspan="12" class="empty-tip" style="padding:40px 0;">暂无数据</td></tr>';
}
$('#person-tbody').html(html);
renderPagination($('#pagination'), data, loadList);
@@ -81,43 +81,155 @@ $(function () {
loadList(1);
});
$('#btn-add').on('click', function () { openForm(null); });
$('#btn-add').on('click', function () { openForm(null, null, null, null, null); });
window.editPerson = function (id) {
httpGet('person/detail.php', { id: id }).then(function (d) {
openForm(d.person, d.accounts);
openForm(d.person, d.accounts, d.phone, d.email, d.experiences);
});
};
function contactsInputHtml(accounts) {
accounts = accounts || [];
var html = '<div id="contacts-box">';
if (!accounts.length) {
accounts = [{ platform: 'email', account_id: '', is_primary: 1 }];
/** 手机号输入后自动识别归属地(录入手机号码时自动识别:国内-国家省-市;港澳台-中国香港/澳门/台湾;海外-国籍) */
function bindPhoneGeo($phoneInput, $geoHint) {
var timer = null;
$phoneInput.on('blur', function () {
var val = $.trim($(this).val());
if (!val) { $geoHint.text('').hide(); return; }
clearTimeout(timer);
timer = setTimeout(function () {
httpGet('common/phone_geo.php', { phone: val }).then(function (d) {
if (d && d.label && d.label !== '未知') {
$geoHint.text('归属地:' + d.label).show();
} else {
$geoHint.text('归属地:未能识别').show();
}
}).catch(function () { $geoHint.text('').hide(); });
}, 300);
});
}
/** 省市区三级联动下拉(数据来自 date_dict_area 字典)
* value 格式:"省-市-区县"(直辖市省略市,如 "北京市-东城区") */
function areaSelectsHtml(target, value) {
return '<div class="area-cascade" data-target="' + target + '" style="display:flex;gap:6px;">' +
'<select class="area-prov" style="flex:1;min-width:0;"><option value="">省</option></select>' +
'<select class="area-city" style="flex:1;min-width:0;"><option value="">市</option></select>' +
'<select class="area-dist" style="flex:1;min-width:0;"><option value="">区/县</option></select>' +
'</div>' +
'<input type="hidden" name="' + target + '" value="' + escHtml(value || '') + '">';
}
/** 构建省/市/区三级联动:填充选项并按已有值回选 */
function initAreaCascade(areas) {
var provMap = {}; // code -> name
var childMap = {}; // parent_code -> [{code,name}]
(areas || []).forEach(function (a) {
if (!a.parent_code) {
provMap[a.code] = a.name;
} else {
(childMap[a.parent_code] = childMap[a.parent_code] || []).push({ code: a.code, name: a.name });
}
});
var provCodes = Object.keys(provMap);
function fillProv($box) {
var html = '<option value="">省</option>';
provCodes.forEach(function (code) {
html += '<option value="' + code + '">' + escHtml(provMap[code]) + '</option>';
});
$box.find('.area-prov').html(html);
}
accounts.forEach(function (a, i) {
html += '<div class="contact-row" style="display:flex;gap:6px;margin-bottom:6px;">' +
'<select name="c-platform" style="width:110px;height:32px;border:1px solid #d9dee8;border-radius:4px;padding:0 6px;">' +
platformOpts(a.platform) + '</select>' +
'<input type="text" name="c-account" placeholder="账号/号码" value="' + escHtml(a.account_id) + '" style="flex:1;height:32px;border:1px solid #d9dee8;border-radius:4px;padding:0 8px;">' +
'<label style="line-height:32px;font-size:12px;"><input type="checkbox" name="c-primary" ' + (a.is_primary ? 'checked' : '') + '> 默认</label>' +
'<button type="button" class="btn btn-sm" onclick="$(this).parent().remove()">删除</button></div>';
function fillCity($box, provCode) {
var html = '<option value="">市</option>';
(childMap[provCode] || []).forEach(function (c) {
html += '<option value="' + c.code + '">' + escHtml(c.name) + '</option>';
});
$box.find('.area-city').html(html);
$box.find('.area-dist').html('<option value="">区/县</option>');
}
function fillDist($box, cityCode) {
var html = '<option value="">区/县</option>';
(childMap[cityCode] || []).forEach(function (c) {
html += '<option value="' + c.code + '">' + escHtml(c.name) + '</option>';
});
$box.find('.area-dist').html(html);
}
function combine($box) {
var target = $box.data('target');
var provName = $box.find('.area-prov option:selected').text();
var cityName = $box.find('.area-city option:selected').text();
var distName = $box.find('.area-dist option:selected').text();
var parts = [];
if ($box.find('.area-prov').val()) parts.push(provName);
if ($box.find('.area-city').val() && cityName !== provName) parts.push(cityName);
if ($box.find('.area-dist').val()) parts.push(distName);
$box.closest('.form-item').find('input[name="' + target + '"]').val(parts.join('-'));
}
$('.area-cascade').each(function () {
var $box = $(this);
var target = $box.data('target');
var current = $box.closest('.form-item').find('input[name="' + target + '"]').val() || '';
var parts = current.split('-');
var provName = parts[0] || '';
var cityName = parts[1] || '';
var distName = parts[2] || '';
fillProv($box);
// 回选省
var provCode = '';
provCodes.forEach(function (code) {
if (provMap[code] === provName) {
provCode = code;
$box.find('.area-prov').val(code);
}
});
if (!provCode) return;
fillCity($box, provCode);
var cityList = childMap[provCode] || [];
var cityCode = '';
// 直接按市名匹配;直辖市(省/市同名,如"北京市-东城区")时 parts[1] 实为区县
var direct = cityList.filter(function (c) { return c.name === cityName; });
if (direct.length) {
cityCode = direct[0].code;
$box.find('.area-city').val(cityCode);
} else if (cityList.length === 1 && cityList[0].name === provName) {
cityCode = cityList[0].code;
$box.find('.area-city').val(cityCode);
if (parts[1] && !distName) {
distName = parts[1]; // 直辖市:第二段实为区县
}
}
if (!cityCode) return;
fillDist($box, cityCode);
(childMap[cityCode] || []).forEach(function (c) {
if (c.name === distName) $box.find('.area-dist').val(c.code);
});
});
// 联动事件
$('.area-cascade').off('change.area').on('change.area', '.area-prov', function () {
var $box = $(this).closest('.area-cascade');
fillCity($box, $(this).val());
combine($box);
});
$('.area-cascade').off('change.areaCity').on('change.areaCity', '.area-city', function () {
var $box = $(this).closest('.area-cascade');
fillDist($box, $(this).val());
combine($box);
});
$('.area-cascade').off('change.areaDist').on('change.areaDist', '.area-dist', function () {
combine($(this).closest('.area-cascade'));
});
return html + '</div>' +
'<button type="button" class="btn btn-sm" id="add-contact">+ 添加联系方式</button>';
}
function platformOpts(sel) {
var list = ['phone', 'email', 'wechat', 'douyin', 'linkedin', 'x', 'facebook', 'instagram', 'tiktok', 'other'];
var html = '';
list.forEach(function (p) {
html += '<option value="' + p + '"' + (sel === p ? ' selected' : '') + '>' + p + '</option>';
});
return html;
}
function openForm(person, accounts) {
function openForm(person, accounts, phone, email, experiences) {
var isEdit = !!person;
var p = person || {};
var pPhone = phone || '';
var pEmail = email || '';
var content =
'<form id="person-form" style="padding:18px 22px 4px;">' +
'<div class="form-grid">' +
@@ -127,14 +239,20 @@ $(function () {
' <option value="男"' + (p.gender === '男' ? ' selected' : '') + '>男</option>' +
' <option value="女"' + (p.gender === '女' ? ' selected' : '') + '>女</option>' +
' <option value="其他"' + (p.gender === '其他' ? ' selected' : '') + '>其他</option></select></div>' +
' <div class="form-item"><label>国籍</label><input type="text" name="nationality" value="' + escHtml(p.nationality) + '"></div>' +
' <div class="form-item"><label>国籍</label><input type="text" name="nationality" value="' + escHtml(p.nationality) + '" list="person-country-list" placeholder="选择或输入">' +
' <datalist id="person-country-list"></datalist></div>' +
' <div class="form-item"><label>证件类型</label><input type="text" name="id_type" value="' + escHtml(p.id_type) + '"></div>' +
' <div class="form-item"><label>证件号码</label><input type="text" name="id_number" value="' + escHtml(p.id_number) + '"></div>' +
' <div class="form-item"><label>学历</label><input type="text" name="education" value="' + escHtml(p.education) + '"></div>' +
' <div class="form-item"><label>毕业院校</label><input type="text" name="graduated_from" value="' + escHtml(p.graduated_from) + '"></div>' +
' <div class="form-item"><label>家乡</label><input type="text" name="hometown" value="' + escHtml(p.hometown) + '"></div>' +
' <div class="form-item"><label>工作所在地</label><input type="text" name="work_location" value="' + escHtml(p.work_location) + '"></div>' +
' <div class="form-item full"><label>联系方式</label>' + contactsInputHtml(accounts) + '</div>' +
' <div class="form-item"><label>家乡</label>' + areaSelectsHtml('hometown', p.hometown) + '</div>' +
' <div class="form-item"><label>工作所在地</label>' + areaSelectsHtml('work_location', p.work_location) + '</div>' +
' <div class="form-item"><label>手机</label>' +
' <div><input type="text" name="phone" id="person-phone" value="' + escHtml(pPhone) + '" placeholder="常用手机号">' +
' <div class="geo-hint" id="person-phone-geo" style="font-size:12px;color:#2f8f46;margin-top:4px;display:none;"></div></div></div>' +
' <div class="form-item"><label>邮箱</label><input type="text" name="email" value="' + escHtml(pEmail) + '" placeholder="常用邮箱"></div>' +
' <div class="form-item"><label>来源渠道</label><select name="source_channel" id="person-source-channel"><option value="">-</option></select></div>' +
' <div class="form-item"><label>来源详情</label><input type="text" name="source_detail" value="' + escHtml(p.source_detail) + '" placeholder="如:华南工博会"></div>' +
'</div>' +
'<div class="dialog-footer"><button type="button" class="btn" id="form-cancel">取消</button>' +
'<button type="submit" class="btn btn-primary">保存</button></div>' +
@@ -147,16 +265,32 @@ $(function () {
btn: false
});
// 手机号归属地自动识别
bindPhoneGeo($('#person-phone'), $('#person-phone-geo'));
// 加载国籍字典 + 行政区划字典(三级联动) + 来源渠道字典
httpGet('common/dicts.php', { type: 'all' }).then(function (d) {
var $dl = $('#person-country-list');
var html = '';
(d.countries || []).forEach(function (c) { html += '<option value="' + escHtml(c.name) + '"></option>'; });
$dl.html(html);
// 省市区三级联动
initAreaCascade(d.areas || []);
var $sc = $('#person-source-channel');
var scHtml = '<option value="">-</option>';
var hasCur = false;
(d.source_channels || []).forEach(function (s) {
var sel = (s.name === p.source_channel) ? ' selected' : '';
if (sel) hasCur = true;
scHtml += '<option value="' + escHtml(s.name) + '"' + sel + '>' + escHtml(s.name) + '</option>';
});
if (p.source_channel && !hasCur) {
scHtml += '<option value="' + escHtml(p.source_channel) + '" selected>' + escHtml(p.source_channel) + '(自定义)</option>';
}
$sc.html(scHtml);
}).catch(function () {});
$('#form-cancel').on('click', function () { Dialog.close(idx); });
$('#add-contact').on('click', function () {
$('#contacts-box').append(
'<div class="contact-row" style="display:flex;gap:6px;margin-bottom:6px;">' +
'<select name="c-platform" style="width:110px;height:32px;border:1px solid #d9dee8;border-radius:4px;padding:0 6px;">' + platformOpts('') + '</select>' +
'<input type="text" name="c-account" placeholder="账号/号码" style="flex:1;height:32px;border:1px solid #d9dee8;border-radius:4px;padding:0 8px;">' +
'<label style="line-height:32px;font-size:12px;"><input type="checkbox" name="c-primary"> 默认</label>' +
'<button type="button" class="btn btn-sm" onclick="$(this).parent().remove()">删除</button></div>'
);
});
$('#person-form').on('submit', function (e) {
e.preventDefault();
@@ -164,27 +298,21 @@ $(function () {
$(this).find('input, select').each(function () {
var name = $(this).attr('name');
if (!name) return;
if (name.indexOf('c-') === 0) return;
if ($(this).attr('type') === 'checkbox') {
data[name] = $(this).prop('checked') ? 1 : 0;
} else {
data[name] = $(this).val();
}
data[name] = $(this).val();
});
if (!data.full_name) { Dialog.error('姓名为必填项'); return; }
// 联系方式
// 联系方式(手机/邮箱,均为常用)
var contacts = [];
$('#contacts-box .contact-row').each(function () {
var $row = $(this);
var account = $.trim($row.find('input[name="c-account"]').val());
var platform = $row.find('select[name="c-platform"]').val();
var primary = $row.find('input[name="c-primary"]').prop('checked') ? 1 : 0;
if (account) {
contacts.push({ platform: platform, account_id: account, is_primary: primary });
}
});
if ($.trim(data.phone || '')) {
contacts.push({ platform: 'phone', account_id: $.trim(data.phone), is_primary: 1, is_defult: 1 });
}
if ($.trim(data.email || '')) {
contacts.push({ platform: 'email', account_id: $.trim(data.email), is_primary: 1, is_defult: 1 });
}
data.contacts = JSON.stringify(contacts);
delete data.phone;
delete data.email;
if (isEdit) data.id = p.id;
httpPost(isEdit ? 'person/update.php' : 'person/add.php', data).then(function () {
@@ -223,11 +351,6 @@ $(function () {
window.viewPerson = function (id) {
httpGet('person/detail.php', { id: id }).then(function (d) {
var p = d.person;
var accountsHtml = '';
(d.accounts || []).forEach(function (a) {
accountsHtml += '<div style="font-size:13px;padding:3px 0;">' + escHtml(a.platform) + ':' + escHtml(a.account_id) +
(a.is_primary ? ' <span class="tag">默认</span>' : '') + '</div>';
});
var expHtml = '';
(d.experiences || []).forEach(function (e) {
expHtml += '<tr><td>' + escHtml(e.display_name || '-') + '</td><td>' + escHtml(e.position || '-') + '</td>' +
@@ -245,10 +368,14 @@ $(function () {
' <div><b>毕业院校:</b>' + escHtml(p.graduated_from || '-') + '</div>' +
' <div><b>家乡:</b>' + escHtml(p.hometown || '-') + '</div>' +
' <div><b>工作所在地:</b>' + escHtml(p.work_location || '-') + '</div>' +
' <div><b>来源渠道:</b>' + escHtml(p.source_channel || '-') + '</div>' +
' <div><b>来源详情:</b>' + escHtml(p.source_detail || '-') + '</div>' +
' <div><b>union_id:</b>' + escHtml(p.union_id) + '</div>' +
' </div>' +
' <h4 style="margin:16px 0 8px;">联系方式</h4>' + (accountsHtml || '<div style="font-size:13px;color:#b6bfcc;">暂无</div>') +
' <h4 style="margin:16px 0 8px;">工作经历</h4>' +
' <h4 style="margin:16px 0 8px;">联系方式</h4>' +
' <div style="font-size:13px;"><b>手机:</b>' + escHtml(d.phone || '-') + '</div>' +
' <div style="font-size:13px;margin-top:4px;"><b>邮箱:</b>' + escHtml(d.email || '-') + '</div>' +
' <h4 style="margin:16px 0 8px;">工作履历</h4>' +
' <table class="grid" style="font-size:12px;"><tr><th>公司</th><th>职位</th><th>部门</th><th>级别</th><th>时间</th></tr>' +
(expHtml || '<tr><td colspan="5" style="color:#b6bfcc;text-align:center;">暂无</td></tr>') + '</table>' +
'</div>';
@@ -256,10 +383,10 @@ $(function () {
});
}
/* ---------- 任职公司弹窗(按人员查看任职公司,分页) ---------- */
/* ---------- 任职履历弹窗(按人员查看任职公司/履历,分页) ---------- */
var compPersonId = 0;
window.viewCompanies = function (personId) {
window.viewResume = function (personId) {
compPersonId = personId;
var content =
'<div style="padding:14px 18px 6px;overflow:hidden;height:330px;">' +
@@ -276,7 +403,7 @@ $(function () {
' </table></div>' +
' <div class="pagination" id="comp-pagination"></div>' +
'</div>';
Dialog.open({ title: '任职公司', area: ['720px', 'auto'], content: content, btn: ['关闭'] });
Dialog.open({ title: '工作履历', area: ['720px', 'auto'], content: content, btn: ['关闭'] });
loadCompanies(1);
$('#comp-search').on('click', function () { loadCompanies(1); });
@@ -314,41 +441,4 @@ $(function () {
renderPagination($('#comp-pagination'), data, loadCompanies);
});
}
/* ---------- 产品品类弹窗(按人员任职公司查看产品,分页) ---------- */
var ppPersonId = 0;
window.viewPersonProducts = function (personId) {
ppPersonId = personId;
var content =
'<div style="padding:14px 18px 6px;overflow:hidden;height:330px;">' +
' <div class="table-wrap"><table class="grid" style="font-size:13px;">' +
' <thead><tr><th>公司</th><th>品类名称</th><th>品类描述</th><th>是否核心</th></tr></thead>' +
' <tbody id="pp-tbody"></tbody>' +
' </table></div>' +
' <div class="pagination" id="pp-pagination"></div>' +
'</div>';
Dialog.open({ title: '产品品类', area: ['760px', 'auto'], content: content, btn: ['关闭'] });
loadPersonProducts(1);
};
function loadPersonProducts(page) {
httpGet('person/products.php', { person_id: ppPersonId, page: page, limit: 5 }).then(function (data) {
var rows = data.list || [];
var html = '';
rows.forEach(function (r) {
html += '<tr>' +
'<td>' + escHtml(r.company_name) + '</td>' +
'<td>' + escHtml(r.category_name) + '</td>' +
'<td>' + escHtml(r.category_description || '-') + '</td>' +
'<td>' + (r.is_core ? '<span class="tag">核心</span>' : '-') + '</td>' +
'</tr>';
});
if (!rows.length) {
html = '<tr><td colspan="4" class="empty-tip" style="padding:30px 0;">暂无产品品类</td></tr>';
}
$('#pp-tbody').html(html);
renderPagination($('#pp-pagination'), data, loadPersonProducts);
});
}
});