v1.0.19: 修复人员编辑入口缺失(person.js addPerson/editPerson) + 渠道明细数量字段名(analysis.php cnt) + CDP全量验证43项PASS
This commit is contained in:
+419
-66
@@ -1,12 +1,24 @@
|
||||
/**
|
||||
* company.js - 企业数据管理逻辑(列表+筛选+分页 / 新增编辑弹窗 / 导入导出 / 详情)
|
||||
* company.js - 企业数据管理逻辑(列表+筛选+分页 / 新增编辑弹窗 / 产品 / 官媒 / 导入导出 / 详情)
|
||||
* v1.0.18:
|
||||
* - 检索区:筛选字段下拉(全部字段/指定字段,与检索词联动)+ 行业下拉 + 企业类型下拉(去掉国家/地区框)
|
||||
* - 新增/编辑:Tab 卡改为 基本信息|财务信息|资质认证;基本信息内左侧文字锚导航(工商信息/联系方式/行业归属/业务类型/来源)
|
||||
* - 表单字段:公司名称→企业名称、法律形式→企业类型(字典下拉)、删除英文名称;资质认证增加 级别/颁证机构
|
||||
* - 产品弹窗:展示 产品品类/基本定位/包含系列/状态/更新日期 + 新增产品按钮(EAV 参数)
|
||||
* - 新增「官媒」入口:公司媒体清单 + 新增官媒按钮
|
||||
*/
|
||||
$(function () {
|
||||
renderShell('企业数据', '数据管理 / 企业数据');
|
||||
renderPage();
|
||||
initPage('company', function (user) {
|
||||
if (!checkPagePermission('company')) return;
|
||||
loadList(1);
|
||||
loadDicts().then(function (dicts) {
|
||||
window._companyDicts = dicts;
|
||||
fillSearchDicts(dicts);
|
||||
loadList(1);
|
||||
}).catch(function () {
|
||||
loadList(1);
|
||||
});
|
||||
});
|
||||
|
||||
var currentPage = 1;
|
||||
@@ -16,13 +28,16 @@ $(function () {
|
||||
$('#page-content').html(
|
||||
'<div class="card">' +
|
||||
' <div class="toolbar">' +
|
||||
' <input type="text" data-filter="keyword" placeholder="公司名/注册号关键词">' +
|
||||
' <input type="text" data-filter="industry" placeholder="行业(精确匹配)">' +
|
||||
' <select data-filter="business_role"><option value="">全部业务角色</option>' +
|
||||
' <option value="manufacturer">生产型</option><option value="integrator">集成商</option>' +
|
||||
' <option value="distributor">代理商</option><option value="brand_operator">品牌运营</option>' +
|
||||
' <option value="others">其他</option></select>' +
|
||||
' <input type="text" data-filter="country" placeholder="国家/地区">' +
|
||||
' <select id="search-field"><option value="">全部字段</option>' +
|
||||
' <option value="name_zh">企业名称</option><option value="name_en">英文名称</option>' +
|
||||
' <option value="registration_number">注册号</option><option value="legal_representative">法定代表人</option>' +
|
||||
' <option value="address">注册地址</option><option value="industry">行业</option>' +
|
||||
' <option value="industry_subdivision">行业细分</option><option value="website">官网</option>' +
|
||||
' <option value="source_channel">来源渠道</option><option value="source_detail">来源详情</option>' +
|
||||
' <option value="business_scope">经营范围</option><option value="stock_code">股票代码</option></select>' +
|
||||
' <input type="text" id="search-keyword" placeholder="输入要检索的内容">' +
|
||||
' <select id="search-industry" data-filter="industry"><option value="">全部行业</option></select>' +
|
||||
' <select id="search-company-type" data-filter="company_type"><option value="">全部企业类型</option></select>' +
|
||||
' <button class="btn btn-primary" id="btn-search">搜索</button>' +
|
||||
' <button class="btn" id="btn-reset">重置</button>' +
|
||||
' <span class="spacer"></span>' +
|
||||
@@ -31,7 +46,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><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="company-tbody"></tbody>' +
|
||||
' </table></div>' +
|
||||
' <div class="pagination" id="pagination"></div>' +
|
||||
@@ -40,12 +55,36 @@ $(function () {
|
||||
$('#check-all').on('change', function () { $('.row-check').prop('checked', this.checked); });
|
||||
}
|
||||
|
||||
/** 填充检索区字典下拉(行业/企业类型) */
|
||||
function fillSearchDicts(dicts) {
|
||||
var indHtml = '<option value="">全部行业</option>';
|
||||
(dicts.industries || []).forEach(function (i) {
|
||||
indHtml += '<option value="' + escHtml(i.name) + '">' + escHtml(i.name) + '</option>';
|
||||
});
|
||||
$('#search-industry').html(indHtml);
|
||||
|
||||
var ctHtml = '<option value="">全部企业类型</option>';
|
||||
(dicts.company_types || []).forEach(function (t) {
|
||||
ctHtml += '<option value="' + escHtml(t.name) + '">' + escHtml(t.name) + '</option>';
|
||||
});
|
||||
$('#search-company-type').html(ctHtml);
|
||||
}
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
function loadList(page) {
|
||||
currentPage = page;
|
||||
var params = buildFilterParam();
|
||||
params.page = page;
|
||||
params.limit = PAGE_SIZE;
|
||||
var params = {
|
||||
field: $('#search-field').val(),
|
||||
keyword: $.trim($('#search-keyword').val()),
|
||||
industry: $('#search-industry').val(),
|
||||
company_type: $('#search-company-type').val(),
|
||||
page: page,
|
||||
limit: PAGE_SIZE
|
||||
};
|
||||
// 空值不传
|
||||
Object.keys(params).forEach(function (k) {
|
||||
if (params[k] === '') delete params[k];
|
||||
});
|
||||
|
||||
httpGet('company/list.php', params).then(function (data) {
|
||||
var rows = data.list || [];
|
||||
@@ -67,6 +106,7 @@ $(function () {
|
||||
' <a onclick="viewCompany(' + r.id + ')">详情</a>' +
|
||||
' <a onclick="viewEmployees(' + r.id + ')">员工</a>' +
|
||||
' <a onclick="viewProducts(' + r.id + ')">产品</a>' +
|
||||
' <a onclick="viewOfficialMedia(' + r.id + ')">官媒</a>' +
|
||||
' <a onclick="editCompany(' + r.id + ')">编辑</a>' +
|
||||
'</td></tr>';
|
||||
});
|
||||
@@ -80,8 +120,12 @@ $(function () {
|
||||
|
||||
/* ---------- 筛选 ---------- */
|
||||
$('#btn-search').on('click', function () { loadList(1); });
|
||||
$('#search-keyword').on('keydown', function (e) { if (e.keyCode === 13) loadList(1); });
|
||||
$('#btn-reset').on('click', function () {
|
||||
$('.toolbar [data-filter]').val('');
|
||||
$('#search-field').val('');
|
||||
$('#search-keyword').val('');
|
||||
$('#search-industry').val('');
|
||||
$('#search-company-type').val('');
|
||||
loadList(1);
|
||||
});
|
||||
|
||||
@@ -89,22 +133,24 @@ $(function () {
|
||||
$('#btn-add').on('click', function () {
|
||||
httpGet('company/cert_types.php').then(function (d) {
|
||||
loadDicts().then(function (dicts) {
|
||||
openForm(null, [], [], d.types || [], dicts);
|
||||
window._companyDicts = dicts;
|
||||
openForm(null, [], [], [], d.types || [], dicts);
|
||||
});
|
||||
});
|
||||
});
|
||||
window.editCompany = function (id) {
|
||||
httpGet('company/detail.php', { id: id }).then(function (d) {
|
||||
loadDicts().then(function (dicts) {
|
||||
openForm(d.company, d.financials, d.certifications, d.certification_types, dicts);
|
||||
window._companyDicts = dicts;
|
||||
openForm(d.company, d.financials, d.certifications, d.accounts || [], d.certification_types, dicts);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/** 拉取数据字典(国家/行业/来源渠道),供表单下拉使用 */
|
||||
/** 拉取数据字典(国家/行业/来源渠道/企业类型),供表单与检索使用 */
|
||||
function loadDicts() {
|
||||
return httpGet('common/dicts.php', { type: 'all' }).catch(function () {
|
||||
return { countries: [], industries: [], source_channels: [] };
|
||||
return { countries: [], industries: [], source_channels: [], company_types: [] };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -124,45 +170,91 @@ $(function () {
|
||||
return html;
|
||||
}
|
||||
|
||||
function openForm(company, financials, certifications, certTypes, dicts) {
|
||||
/* ============================================================
|
||||
* 新增/编辑弹窗:Tab = 基本信息 | 财务信息 | 资质认证
|
||||
* 基本信息内左侧文字锚导航:工商信息 / 联系方式 / 行业归属 / 业务类型 / 来源
|
||||
* ============================================================ */
|
||||
function openForm(company, financials, certifications, accounts, certTypes, dicts) {
|
||||
var isEdit = !!company;
|
||||
var c = company || {};
|
||||
financials = financials || [];
|
||||
certifications = certifications || [];
|
||||
accounts = accounts || [];
|
||||
certTypes = certTypes || [];
|
||||
dicts = dicts || {};
|
||||
|
||||
// Tab1 工商信息
|
||||
// ---- 基本信息 Tab(含左侧锚导航 + 5 个分区) ----
|
||||
var secBiz =
|
||||
'<div class="form-sec" id="sec-biz">' +
|
||||
' <div class="form-sec-title">工商信息</div>' +
|
||||
' <div class="form-grid">' +
|
||||
' <div class="form-item"><label>企业名称<span class="req">*</span></label>' +
|
||||
' <div style="display:flex;gap:8px;align-items:center;">' +
|
||||
' <input type="text" name="name_zh" value="' + escHtml(c.name_zh) + '" style="width:60%;flex:0 0 auto;">' +
|
||||
' <button type="button" class="btn btn-sm" id="btn-gongshang-query" title="预留:后续接入工商查询API,自动填写企业名称/注册号/注册地址等">工商查询</button>' +
|
||||
' </div></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><select name="legal_form">' + dictOptions(dicts.company_types, c.legal_form) + '</select></div>' +
|
||||
' <div class="form-item"><label>法定代表人</label><input type="text" name="legal_representative" value="' + escHtml(c.legal_representative) + '"></div>' +
|
||||
' <div class="form-item"><label>成立日期</label><input type="date" name="established_date" value="' + escHtml(c.established_date) + '"></div>' +
|
||||
' <div class="form-item"><label>注册资本(万元)</label><input type="text" name="registered_capital" value="' + escHtml(c.registered_capital) + '"></div>' +
|
||||
' <div class="form-item full"><label>经营范围</label><textarea name="business_scope">' + escHtml(c.business_scope) + '</textarea></div>' +
|
||||
' </div></div>';
|
||||
|
||||
// 联系方式(social_accounts,整表替换)
|
||||
var accountRowsHtml = '';
|
||||
if (!accounts.length) {
|
||||
accountRowsHtml = accountRowHtml(null);
|
||||
} else {
|
||||
accounts.forEach(function (a) { accountRowsHtml += accountRowHtml(a); });
|
||||
}
|
||||
var secContact =
|
||||
'<div class="form-sec" id="sec-contact">' +
|
||||
' <div class="form-sec-title">联系方式' +
|
||||
' <button type="button" class="btn btn-sm" id="add-account-row" style="margin-left:10px;">+ 添加</button></div>' +
|
||||
' <div id="account-rows">' + accountRowsHtml + '</div>' +
|
||||
' <div style="font-size:12px;color:#8a94a6;margin-top:6px;">如:官网、公众号、微博、抖音、领英等平台账号</div>' +
|
||||
'</div>';
|
||||
|
||||
var secIndustry =
|
||||
'<div class="form-sec" id="sec-industry">' +
|
||||
' <div class="form-sec-title">行业归属</div>' +
|
||||
' <div class="form-grid">' +
|
||||
' <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></div>';
|
||||
|
||||
var secBizType =
|
||||
'<div class="form-sec" id="sec-biztype">' +
|
||||
' <div class="form-sec-title">业务类型</div>' +
|
||||
' <div class="form-grid">' +
|
||||
' <div class="form-item"><label>业务角色</label><select name="business_role">' + roleOptions(c.business_role) + '</select></div>' +
|
||||
' </div></div>';
|
||||
|
||||
var secSource =
|
||||
'<div class="form-sec" id="sec-source">' +
|
||||
' <div class="form-sec-title">来源</div>' +
|
||||
' <div class="form-grid">' +
|
||||
' <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></div>';
|
||||
|
||||
var bizHtml =
|
||||
'<div class="form-grid">' +
|
||||
' <div class="form-item"><label>公司名称<span class="req">*</span></label>' +
|
||||
' <div style="display:flex;gap:8px;align-items:center;">' +
|
||||
' <input type="text" name="name_zh" value="' + escHtml(c.name_zh) + '" style="width:60%;flex:0 0 auto;">' +
|
||||
' <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><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>' +
|
||||
' <div class="form-item"><label>法定代表人</label><input type="text" name="legal_representative" value="' + escHtml(c.legal_representative) + '"></div>' +
|
||||
' <div class="form-item"><label>成立日期</label><input type="date" name="established_date" value="' + escHtml(c.established_date) + '"></div>' +
|
||||
' <div class="form-item"><label>注册资本(万元)</label><input type="text" name="registered_capital" value="' + escHtml(c.registered_capital) + '"></div>' +
|
||||
' <div class="form-item full"><label>经营范围</label><textarea name="business_scope">' + escHtml(c.business_scope) + '</textarea></div>' +
|
||||
'<div class="form-anchor-layout">' +
|
||||
' <div class="form-anchor-nav">' +
|
||||
' <a href="#sec-biz" class="anchor-link active">工商信息</a>' +
|
||||
' <a href="#sec-contact" class="anchor-link">联系方式</a>' +
|
||||
' <a href="#sec-industry" class="anchor-link">行业归属</a>' +
|
||||
' <a href="#sec-biztype" class="anchor-link">业务类型</a>' +
|
||||
' <a href="#sec-source" class="anchor-link">来源</a>' +
|
||||
' </div>' +
|
||||
' <div class="form-anchor-body">' + secBiz + secContact + secIndustry + secBizType + secSource + '</div>' +
|
||||
'</div>';
|
||||
|
||||
// Tab2 行业信息(业务角色/行业/行业细分/官网)
|
||||
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><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 财务信息:顶部独立字段(是否上市/股票代码/最新员工/最新营收)+ 年度财务明细列表
|
||||
// ---- 财务信息 Tab(保持不变) ----
|
||||
var finRowsHtml = '';
|
||||
if (!financials.length) {
|
||||
finRowsHtml = finRowHtml(null);
|
||||
@@ -187,7 +279,7 @@ $(function () {
|
||||
' <tbody id="fin-tbody">' + finRowsHtml + '</tbody>' +
|
||||
'</table></div>';
|
||||
|
||||
// Tab3 资质认证:列表形式(瞪羚企业等)
|
||||
// ---- 资质认证 Tab(含级别/颁证机构) ----
|
||||
var certRowsHtml = '';
|
||||
if (!certifications.length) {
|
||||
certRowsHtml = certRowHtml(null, certTypes);
|
||||
@@ -206,14 +298,12 @@ $(function () {
|
||||
'<form id="company-form" style="padding:14px 22px 4px;">' +
|
||||
' <div class="edit-tabs">' +
|
||||
' <div class="edit-tabs-head">' +
|
||||
' <span class="edit-tab active" data-tab="biz" onclick="switchEditTab(this)">工商信息</span>' +
|
||||
' <span class="edit-tab" data-tab="ind" onclick="switchEditTab(this)">行业信息</span>' +
|
||||
' <span class="edit-tab active" data-tab="biz" onclick="switchEditTab(this)">基本信息</span>' +
|
||||
' <span class="edit-tab" data-tab="fin" onclick="switchEditTab(this)">财务信息</span>' +
|
||||
' <span class="edit-tab" data-tab="cert" onclick="switchEditTab(this)">资质认证</span>' +
|
||||
' </div>' +
|
||||
' <div class="edit-tabs-body">' +
|
||||
' <div class="edit-pane" id="edit-pane-biz">' + bizHtml + '</div>' +
|
||||
' <div class="edit-pane" id="edit-pane-ind" style="display:none;">' + indHtml + '</div>' +
|
||||
' <div class="edit-pane" id="edit-pane-fin" style="display:none;">' + finHtml + '</div>' +
|
||||
' <div class="edit-pane" id="edit-pane-cert" style="display:none;">' + certHtml + '</div>' +
|
||||
' </div>' +
|
||||
@@ -224,27 +314,29 @@ $(function () {
|
||||
|
||||
var idx = Dialog.open({
|
||||
title: isEdit ? '编辑企业' : '新增企业',
|
||||
area: ['820px', 'auto'],
|
||||
area: ['860px', 'auto'],
|
||||
content: content,
|
||||
btn: false
|
||||
});
|
||||
|
||||
bindAnchorNav();
|
||||
|
||||
$('#form-cancel').on('click', function () { Dialog.close(idx); });
|
||||
$('#add-fin-row').on('click', function () { $('#fin-tbody').append(finRowHtml(null)); });
|
||||
$('#add-cert-row').on('click', function () { $('#cert-rows').append(certRowHtml(null, certTypes)); });
|
||||
$('#add-account-row').on('click', function () { $('#account-rows').append(accountRowHtml(null)); });
|
||||
// 工商查询按钮(预留:后续接入工商查询API自动填写)
|
||||
$('#btn-gongshang-query').on('click', function () {
|
||||
Dialog.alert('工商查询API预留中,接入后可通过企业名称自动查询并填写公司名称、注册号、注册地址等信息');
|
||||
Dialog.alert('工商查询API预留中,接入后可通过企业名称自动查询并填写企业名称、注册号、注册地址等信息');
|
||||
});
|
||||
|
||||
$('#company-form').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var fd = new FormData(this);
|
||||
var nameZh = fd.get('name_zh');
|
||||
var nameEn = fd.get('name_en');
|
||||
if (isEdit) fd.delete('display_name'); // 编辑不允许改显示名称
|
||||
if (!isEdit && !nameZh && !nameEn) {
|
||||
Dialog.error('公司名称或英文名称至少填写一项');
|
||||
if (!nameZh) {
|
||||
Dialog.error('企业名称为必填项');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,7 +363,7 @@ $(function () {
|
||||
});
|
||||
fd.append('financials', JSON.stringify(financials));
|
||||
|
||||
// 资质认证(整表替换)
|
||||
// 资质认证(整表替换,含级别/颁证机构)
|
||||
var certs = [];
|
||||
$('#cert-rows .cert-row').each(function () {
|
||||
var $r = $(this);
|
||||
@@ -280,12 +372,32 @@ $(function () {
|
||||
certs.push({
|
||||
certification_type_id: tid,
|
||||
certificate_number: $r.find('[name="cert-number"]').val(),
|
||||
level: $r.find('[name="cert-level"]').val(),
|
||||
issuing_authority: $r.find('[name="cert-issuer"]').val(),
|
||||
issue_date: $r.find('[name="cert-issue"]').val(),
|
||||
expiry_date: $r.find('[name="cert-expiry"]').val()
|
||||
});
|
||||
});
|
||||
fd.append('certifications', JSON.stringify(certs));
|
||||
|
||||
// 联系方式(整表替换)
|
||||
var accounts = [];
|
||||
$('#account-rows .account-row').each(function () {
|
||||
var $r = $(this);
|
||||
var platform = $.trim($r.find('[name="acc-platform"]').val());
|
||||
var accountId = $.trim($r.find('[name="acc-account"]').val());
|
||||
if (!platform || !accountId) return;
|
||||
accounts.push({
|
||||
platform: platform,
|
||||
account_id: accountId,
|
||||
profile_url: $r.find('[name="acc-url"]').val(),
|
||||
remark: $r.find('[name="acc-remark"]').val(),
|
||||
is_active: $r.find('[name="acc-active"]').val(),
|
||||
is_defult: $r.find('[name="acc-defult"]').prop('checked') ? 1 : 0
|
||||
});
|
||||
});
|
||||
fd.append('accounts', JSON.stringify(accounts));
|
||||
|
||||
httpPost(isEdit ? 'company/update.php' : 'company/add.php', fd, true).then(function () {
|
||||
Dialog.success('保存成功', function () {
|
||||
Dialog.close(idx);
|
||||
@@ -304,6 +416,40 @@ $(function () {
|
||||
$('#edit-pane-' + $(el).data('tab')).show();
|
||||
};
|
||||
|
||||
/** 基本信息内左侧锚点导航:点击平滑滚动 + 高亮 */
|
||||
function bindAnchorNav() {
|
||||
$('.form-anchor-nav .anchor-link').off('click').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $target = $($(this).attr('href'));
|
||||
var $body = $target.closest('.edit-pane');
|
||||
// 若锚点所在分区不在当前可见 Tab,先切到对应 Tab
|
||||
if (!$body.is(':visible')) {
|
||||
var tab = $body.attr('id').replace('edit-pane-', '');
|
||||
var $tabEl = $('.edit-tabs-head .edit-tab[data-tab="' + tab + '"]');
|
||||
if ($tabEl.length) switchEditTab($tabEl[0]);
|
||||
}
|
||||
var offset = $target.offset();
|
||||
if (offset) {
|
||||
$('.edit-tabs-body').animate({ scrollTop: $target.offset().top - $('.edit-tabs-body').offset().top + $('.edit-tabs-body').scrollTop() }, 200);
|
||||
}
|
||||
$('.form-anchor-nav .anchor-link').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
});
|
||||
// 滚动时高亮当前分区
|
||||
var $secs = $('.form-anchor-body .form-sec');
|
||||
$('.edit-tabs-body').off('scroll.anchor').on('scroll.anchor', function () {
|
||||
var top = $(this).scrollTop() + 60;
|
||||
var currentId = null;
|
||||
$secs.each(function () {
|
||||
if ($(this).position().top <= top) currentId = $(this).attr('id');
|
||||
});
|
||||
if (currentId) {
|
||||
$('.form-anchor-nav .anchor-link').removeClass('active');
|
||||
$('.form-anchor-nav .anchor-link[href="#' + currentId + '"]').addClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 年度财务明细行模板(列表形式,一行一个财年) */
|
||||
function finRowHtml(f) {
|
||||
f = f || {};
|
||||
@@ -325,7 +471,7 @@ $(function () {
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
/** 资质认证行模板 */
|
||||
/** 资质认证行模板(含级别/颁证机构) */
|
||||
function certRowHtml(ct, certTypes) {
|
||||
ct = ct || {};
|
||||
var opts = '<option value="">请选择认证类型</option>';
|
||||
@@ -335,12 +481,35 @@ $(function () {
|
||||
return '<div class="cert-row">' +
|
||||
'<select name="cert-type">' + opts + '</select>' +
|
||||
'<input type="text" name="cert-number" placeholder="证书编号" value="' + escHtml(ct.certificate_number || '') + '">' +
|
||||
'<input type="text" name="cert-level" placeholder="级别" value="' + escHtml(ct.level || '') + '">' +
|
||||
'<input type="text" name="cert-issuer" placeholder="颁证机构" value="' + escHtml(ct.issuing_authority || '') + '">' +
|
||||
'<input type="date" name="cert-issue" value="' + escHtml(ct.issue_date || '') + '">' +
|
||||
'<input type="date" name="cert-expiry" value="' + escHtml(ct.expiry_date || '') + '">' +
|
||||
'<button type="button" class="btn btn-sm btn-danger" onclick="$(this).closest(\'.cert-row\').remove()">删除</button>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
/** 联系方式行模板(企业 social_accounts) */
|
||||
function accountRowHtml(a) {
|
||||
a = a || {};
|
||||
var empty = function (v) { return (v === null || v === undefined) ? '' : v; };
|
||||
var platOpts = ['', '官网', '微信公众号', '微信', '微博', '抖音', '快手', 'B站', '小红书', '领英', 'Facebook', 'Twitter/X', 'YouTube', 'Instagram', '其他'];
|
||||
var platHtml = '';
|
||||
platOpts.forEach(function (p) {
|
||||
platHtml += '<option value="' + escHtml(p) + '"' + (String(p) === String(a.platform || '') ? ' selected' : '') + '>' + (p || '平台') + '</option>';
|
||||
});
|
||||
return '<div class="account-row">' +
|
||||
'<select name="acc-platform">' + platHtml + '</select>' +
|
||||
'<input type="text" name="acc-account" placeholder="账号名称/ID" value="' + escHtml(empty(a.account_id)) + '">' +
|
||||
'<input type="text" name="acc-url" placeholder="主页链接" value="' + escHtml(empty(a.profile_url)) + '">' +
|
||||
'<input type="text" name="acc-remark" placeholder="备注" value="' + escHtml(empty(a.remark)) + '">' +
|
||||
'<select name="acc-active" title="状态"><option value="1"' + (a.is_active !== 0 ? ' selected' : '') + '>启用</option>' +
|
||||
'<option value="0"' + (a.is_active === 0 ? ' selected' : '') + '>停用</option></select>' +
|
||||
'<label title="常用" style="font-size:12px;color:#5a6472;white-space:nowrap;"><input type="checkbox" name="acc-defult"' + (a.is_defult ? ' checked' : '') + '> 常用</label>' +
|
||||
'<button type="button" class="btn btn-sm btn-danger" onclick="$(this).closest(\'.account-row\').remove()">删除</button>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
function roleOptions(sel) {
|
||||
var opts = ['', 'manufacturer', 'integrator', 'distributor', 'brand_operator', 'others'];
|
||||
var labels = { 'manufacturer': '生产型', 'integrator': '集成商', 'distributor': '代理商', 'brand_operator': '品牌运营', 'others': '其他' };
|
||||
@@ -402,7 +571,7 @@ $(function () {
|
||||
'<div style="padding:18px 22px;">' +
|
||||
' <h3 style="margin-bottom:14px;">' + escHtml(c.name_zh || c.name_en || '企业 #' + c.id) + '</h3>' +
|
||||
' <div class="detail-grid" style="display:grid;grid-template-columns:1fr 1fr;gap:8px 24px;font-size:13px;">' +
|
||||
detailRow('公司名称', c.name_zh) + detailRow('英文名称', c.name_en) +
|
||||
detailRow('企业名称', c.name_zh) + detailRow('企业类型', c.legal_form) +
|
||||
detailRow('业务角色', c.business_role) + detailRow('国家/地区', c.country) +
|
||||
detailRow('注册号', c.registration_number) + detailRow('地址', c.address) +
|
||||
detailRow('法定代表人', c.legal_representative) + detailRow('行业', c.industry) +
|
||||
@@ -509,40 +678,224 @@ $(function () {
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- 产品品类弹窗(按企业查看产品品类,分页) ---------- */
|
||||
/* ---------- 产品弹窗(产品品类/基本定位/包含系列/状态/更新日期 + 新增产品) ---------- */
|
||||
var prodCompanyId = 0;
|
||||
|
||||
window.viewProducts = function (companyId) {
|
||||
prodCompanyId = companyId;
|
||||
var content =
|
||||
'<div style="padding:14px 18px 6px;overflow:hidden;height:330px;">' +
|
||||
'<div style="padding:14px 18px 6px;overflow:hidden;height:360px;">' +
|
||||
' <div class="toolbar" style="margin-bottom:10px;">' +
|
||||
' <span style="font-size:13px;color:#5a6472;">共 <b id="prod-total">0</b> 条产品记录</span>' +
|
||||
' <span class="spacer"></span>' +
|
||||
' <button class="btn btn-success btn-sm" id="btn-add-product">+ 新增产品</button>' +
|
||||
' </div>' +
|
||||
' <div class="table-wrap"><table class="grid" style="font-size:13px;">' +
|
||||
' <thead><tr><th>品类名称</th><th>品类描述</th><th>是否核心</th><th>状态</th></tr></thead>' +
|
||||
' <thead><tr><th>产品品类</th><th>基本定位</th><th>包含系列</th><th>状态</th><th>更新日期</th><th>参数</th></tr></thead>' +
|
||||
' <tbody id="prod-tbody"></tbody>' +
|
||||
' </table></div>' +
|
||||
' <div class="pagination" id="prod-pagination"></div>' +
|
||||
'</div>';
|
||||
Dialog.open({ title: '产品品类', area: ['720px', 'auto'], content: content, btn: ['关闭'] });
|
||||
Dialog.open({ title: '产品列表', area: ['860px', 'auto'], content: content, btn: ['关闭'] });
|
||||
loadProducts(1);
|
||||
|
||||
$('#btn-add-product').on('click', function () { openProductForm(null); });
|
||||
};
|
||||
|
||||
function loadProducts(page) {
|
||||
httpGet('company/products.php', { company_id: prodCompanyId, page: page, limit: 5 }).then(function (data) {
|
||||
$('#prod-total').text(data.total);
|
||||
var rows = data.list || [];
|
||||
var html = '';
|
||||
rows.forEach(function (r) {
|
||||
var attrHtml = (r.attrs && r.attrs.length)
|
||||
? r.attrs.map(function (a) { return '<div>' + escHtml(a.attr_name) + (a.unit ? '(' + escHtml(a.unit) + ')' : '') + ':' + escHtml(a.value) + '</div>'; }).join('')
|
||||
: '<span style="color:#b6bfcc;">-</span>';
|
||||
html += '<tr>' +
|
||||
'<td>' + escHtml(r.category_name) + '</td>' +
|
||||
'<td>' + escHtml(r.category_description || '-') + '</td>' +
|
||||
'<td>' + (r.is_core ? '<span class="tag">核心</span>' : '-') + '</td>' +
|
||||
'<td title="' + escHtml(r.positioning || '') + '">' + escHtml((r.positioning || '-').substring(0, 24)) + '</td>' +
|
||||
'<td>' + escHtml(r.series || '-') + '</td>' +
|
||||
'<td>' + (r.is_active ? '<span class="tag tag-green">在产</span>' : '<span class="tag tag-gray">停产</span>') + '</td>' +
|
||||
'<td>' + fmtDate(r.updated_at || r.created_at) + '</td>' +
|
||||
'<td style="font-size:12px;">' + attrHtml + '</td>' +
|
||||
'</tr>';
|
||||
});
|
||||
if (!rows.length) {
|
||||
html = '<tr><td colspan="4" class="empty-tip" style="padding:30px 0;">暂无产品品类</td></tr>';
|
||||
html = '<tr><td colspan="6" class="empty-tip" style="padding:30px 0;">暂无产品,点击右上角「+ 新增产品」添加</td></tr>';
|
||||
}
|
||||
$('#prod-tbody').html(html);
|
||||
renderPagination($('#prod-pagination'), data, loadProducts);
|
||||
});
|
||||
}
|
||||
|
||||
/** 新增产品弹窗(含 EAV 参数,按企业所属行业加载参数属性定义) */
|
||||
function openProductForm() {
|
||||
// 获取企业行业
|
||||
httpGet('company/detail.php', { id: prodCompanyId }).then(function (d) {
|
||||
var industry = (d.company && d.company.industry) || '';
|
||||
var content =
|
||||
'<form id="product-form" style="padding:18px 22px 4px;">' +
|
||||
'<div class="form-grid">' +
|
||||
' <div class="form-item"><label>产品品类<span class="req">*</span></label><input type="text" name="category_name" placeholder="如:工业机器人、手机"></div>' +
|
||||
' <div class="form-item"><label>包含系列</label><input type="text" name="series" placeholder="如:SUV、Gen 13"></div>' +
|
||||
' <div class="form-item"><label>状态</label><select name="is_active"><option value="1" selected>在产</option><option value="0">停产</option></select></div>' +
|
||||
' <div class="form-item"><label>是否核心</label><select name="is_core"><option value="0" selected>否</option><option value="1">是</option></select></div>' +
|
||||
' <div class="form-item full"><label>产品基本定位</label><textarea name="positioning" placeholder="介绍这一款产品的商业定位"></textarea></div>' +
|
||||
' <div class="form-item full"><label>品类描述</label><textarea name="category_description" placeholder="选填"></textarea></div>' +
|
||||
'</div>' +
|
||||
'<div id="product-attr-box" style="margin-top:6px;' + (industry ? '' : 'display:none;') + '">' +
|
||||
' <b style="font-size:13px;color:#1e2a3a;">产品参数' + (industry ? '(' + escHtml(industry) + ')' : '') + '</b>' +
|
||||
' <div id="product-attr-rows" style="margin-top:8px;"></div>' +
|
||||
'</div>' +
|
||||
'<div class="dialog-footer"><button type="button" class="btn" id="prod-form-cancel">取消</button>' +
|
||||
'<button type="submit" class="btn btn-primary">保存</button></div>' +
|
||||
'</form>';
|
||||
|
||||
var idx = Dialog.open({
|
||||
title: '新增产品',
|
||||
area: ['640px', 'auto'],
|
||||
content: content,
|
||||
btn: false
|
||||
});
|
||||
|
||||
$('#prod-form-cancel').on('click', function () { Dialog.close(idx); });
|
||||
|
||||
// 加载该行业参数属性定义(EAV)
|
||||
if (industry) {
|
||||
httpGet('company/product_attrs.php', { industry: industry }).then(function (rd) {
|
||||
var attrs = rd.attrs || [];
|
||||
var html = '';
|
||||
attrs.forEach(function (a) {
|
||||
html += '<div class="form-item" style="width:calc(50% - 10px);display:inline-block;margin-right:10px;">' +
|
||||
'<label>' + escHtml(a.attr_name) + (a.unit ? '(' + escHtml(a.unit) + ')' : '') + '</label>' +
|
||||
'<input type="text" data-attr-id="' + a.id + '" data-attr-type="' + escHtml(a.attr_type) + '" placeholder="' +
|
||||
(a.attr_type === 'boolean' ? '是/否' : a.attr_type === 'date' ? 'YYYY-MM-DD' : '') + '"></div>';
|
||||
});
|
||||
if (!attrs.length) {
|
||||
html = '<div style="font-size:12px;color:#b6bfcc;">该行业暂无参数属性定义(可在 company_products_attr 表中维护)</div>';
|
||||
}
|
||||
$('#product-attr-rows').html(html);
|
||||
}).catch(function () {});
|
||||
}
|
||||
|
||||
$('#product-form').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var data = {};
|
||||
$(this).find('input, select, textarea').each(function () {
|
||||
var name = $(this).attr('name');
|
||||
if (name) data[name] = $(this).val();
|
||||
});
|
||||
if (!data.category_name) { Dialog.error('产品品类为必填项'); return; }
|
||||
|
||||
// 收集 EAV 参数值
|
||||
var attrs = [];
|
||||
$('#product-attr-rows input[data-attr-id]').each(function () {
|
||||
var $this = $(this);
|
||||
var val = $.trim($this.val());
|
||||
if (!val) return;
|
||||
attrs.push({ attr_id: $this.data('attr-id'), value: val });
|
||||
});
|
||||
data.company_id = prodCompanyId;
|
||||
data.attrs = JSON.stringify(attrs);
|
||||
|
||||
httpPost('company/product_add.php', data).then(function () {
|
||||
Dialog.success('新增成功', function () {
|
||||
Dialog.close(idx);
|
||||
loadProducts(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- 官媒弹窗(该公司媒体清单 + 新增官媒) ---------- */
|
||||
var mediaCompanyId = 0;
|
||||
|
||||
window.viewOfficialMedia = function (companyId) {
|
||||
mediaCompanyId = companyId;
|
||||
var content =
|
||||
'<div style="padding:14px 18px 6px;overflow:hidden;height:360px;">' +
|
||||
' <div class="toolbar" style="margin-bottom:10px;">' +
|
||||
' <span style="font-size:13px;color:#5a6472;">共 <b id="media-total">0</b> 条官媒记录</span>' +
|
||||
' <span class="spacer"></span>' +
|
||||
' <button class="btn btn-success btn-sm" id="btn-add-media">+ 新增官媒</button>' +
|
||||
' </div>' +
|
||||
' <div class="table-wrap"><table class="grid" style="font-size:13px;">' +
|
||||
' <thead><tr><th>平台</th><th>账号名称</th><th>ID</th><th>主页链接</th><th>状态</th><th>更新日期</th></tr></thead>' +
|
||||
' <tbody id="media-tbody"></tbody>' +
|
||||
' </table></div>' +
|
||||
' <div class="pagination" id="media-pagination"></div>' +
|
||||
'</div>';
|
||||
Dialog.open({ title: '官媒列表', area: ['820px', 'auto'], content: content, btn: ['关闭'] });
|
||||
loadOfficialMedia(1);
|
||||
|
||||
$('#btn-add-media').on('click', function () { openOfficialMediaForm(); });
|
||||
};
|
||||
|
||||
function loadOfficialMedia(page) {
|
||||
httpGet('company/official_media_list.php', { company_id: mediaCompanyId, page: page, limit: 5 }).then(function (data) {
|
||||
$('#media-total').text(data.total);
|
||||
var rows = data.list || [];
|
||||
var html = '';
|
||||
rows.forEach(function (r) {
|
||||
html += '<tr>' +
|
||||
'<td>' + escHtml(r.platform || '-') + '</td>' +
|
||||
'<td>' + escHtml(r.account_id || '-') + '</td>' +
|
||||
'<td>' + r.id + '</td>' +
|
||||
'<td>' + (r.profile_url ? '<a href="' + escHtml(r.profile_url) + '" target="_blank">打开</a>' : '-') + '</td>' +
|
||||
'<td>' + (r.is_active ? '<span class="tag tag-green">启用</span>' : '<span class="tag tag-gray">停用</span>') + '</td>' +
|
||||
'<td>' + fmtDate(r.updated_at || r.created_at) + '</td>' +
|
||||
'</tr>';
|
||||
});
|
||||
if (!rows.length) {
|
||||
html = '<tr><td colspan="6" class="empty-tip" style="padding:30px 0;">暂无官媒,点击右上角「+ 新增官媒」添加</td></tr>';
|
||||
}
|
||||
$('#media-tbody').html(html);
|
||||
renderPagination($('#media-pagination'), data, loadOfficialMedia);
|
||||
});
|
||||
}
|
||||
|
||||
/** 新增官媒弹窗 */
|
||||
function openOfficialMediaForm() {
|
||||
var content =
|
||||
'<form id="media-form" style="padding:18px 22px 4px;">' +
|
||||
'<div class="form-grid">' +
|
||||
' <div class="form-item"><label>平台<span class="req">*</span></label><input type="text" name="platform" placeholder="如:微博、微信公众号、抖音"></div>' +
|
||||
' <div class="form-item"><label>账号名称<span class="req">*</span></label><input type="text" name="account_id" placeholder="账号名称/ID"></div>' +
|
||||
' <div class="form-item full"><label>主页链接</label><input type="text" name="profile_url" placeholder="https://..."></div>' +
|
||||
' <div class="form-item full"><label>备注</label><input type="text" name="remark"></div>' +
|
||||
' <div class="form-item"><label>状态</label><select name="is_active"><option value="1" selected>启用</option><option value="0">停用</option></select></div>' +
|
||||
' <div class="form-item"><label>是否常用</label><select name="is_defult"><option value="0" selected>否</option><option value="1">是</option></select></div>' +
|
||||
'</div>' +
|
||||
'<div class="dialog-footer"><button type="button" class="btn" id="media-form-cancel">取消</button>' +
|
||||
'<button type="submit" class="btn btn-primary">保存</button></div>' +
|
||||
'</form>';
|
||||
|
||||
var idx = Dialog.open({
|
||||
title: '新增官媒',
|
||||
area: ['620px', 'auto'],
|
||||
content: content,
|
||||
btn: false
|
||||
});
|
||||
|
||||
$('#media-form-cancel').on('click', function () { Dialog.close(idx); });
|
||||
|
||||
$('#media-form').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var data = {};
|
||||
$(this).find('input, select').each(function () {
|
||||
var name = $(this).attr('name');
|
||||
if (name) data[name] = $(this).val();
|
||||
});
|
||||
if (!data.platform || !data.account_id) { Dialog.error('平台与账号名称为必填项'); return; }
|
||||
data.company_id = mediaCompanyId;
|
||||
|
||||
httpPost('company/official_media_add.php', data).then(function () {
|
||||
Dialog.success('新增成功', function () {
|
||||
Dialog.close(idx);
|
||||
loadOfficialMedia(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user