0806
This commit is contained in:
+55
-16
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user