new
This commit is contained in:
@@ -571,25 +571,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group hidden" id="group-company">
|
||||
<label id="label-company">单位名称</label>
|
||||
<input type="text" id="form-company" placeholder="点此输入">
|
||||
</div>
|
||||
|
||||
<div class="input-group hidden" id="group-position">
|
||||
<label id="label-position">职务</label>
|
||||
<input type="text" id="form-position" placeholder="点此输入">
|
||||
</div>
|
||||
|
||||
<div class="input-group hidden" id="group-business">
|
||||
<label id="label-business">公司主要经营 / 业务</label>
|
||||
<textarea id="form-business" rows="2" placeholder="点此输入"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="input-group hidden" id="group-vision">
|
||||
<label id="label-vision">2026年业务愿景</label>
|
||||
<textarea id="form-vision" rows="3" placeholder="点此输入 (为了业务更好对接,最好表述清晰)"></textarea>
|
||||
</div>
|
||||
<!-- 动态签到字段容器 - 根据 checkin_field_config 自动生成 -->
|
||||
<div id="dynamic-checkin-fields"></div>
|
||||
|
||||
<input type="hidden" id="form-location" value="">
|
||||
|
||||
@@ -730,6 +713,52 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态渲染签到表单字段
|
||||
* 根据 checkin_field_config 配置生成字段 HTML
|
||||
*/
|
||||
function renderDynamicCheckinFields() {
|
||||
const container = document.getElementById('dynamic-checkin-fields');
|
||||
if (!container) return;
|
||||
|
||||
const fc = CONFIG.checkin_field_config || {};
|
||||
container.innerHTML = '';
|
||||
|
||||
// 定义字段显示顺序
|
||||
const fieldOrder = ['company_name', 'position', 'business_scope', 'vision_2026'];
|
||||
|
||||
// 按顺序添加字段
|
||||
fieldOrder.forEach(key => {
|
||||
const field = fc[key];
|
||||
if (!field) return;
|
||||
|
||||
const div = document.createElement('div');
|
||||
div.className = 'input-group' + (field.show ? '' : ' hidden');
|
||||
div.id = 'group-' + key;
|
||||
|
||||
const isTextarea = (key === 'business_scope' || key === 'vision_2026');
|
||||
|
||||
let placeholder = '点此输入';
|
||||
if (key === 'business_scope') placeholder = '点此输入';
|
||||
if (key === 'vision_2026') placeholder = '点此输入 (为了业务更好对接,最好表述清晰)';
|
||||
|
||||
if (isTextarea) {
|
||||
const rows = key === 'vision_2026' ? 3 : 2;
|
||||
div.innerHTML = `
|
||||
<label id="label-${key}">${field.label || key}</label>
|
||||
<textarea id="form-${key}" rows="${rows}" placeholder="${placeholder}"></textarea>
|
||||
`;
|
||||
} else {
|
||||
div.innerHTML = `
|
||||
<label id="label-${key}">${field.label || key}</label>
|
||||
<input type="text" id="form-${key}" placeholder="${placeholder}">
|
||||
`;
|
||||
}
|
||||
|
||||
container.appendChild(div);
|
||||
});
|
||||
}
|
||||
|
||||
function applyConfigUI() {
|
||||
const smsGroup = document.getElementById('sms-verification-group');
|
||||
if (smsGroup) {
|
||||
@@ -740,38 +769,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Apply field config (Show/Hide/Required)
|
||||
const fc = CONFIG.checkin_field_config || {};
|
||||
const fields = [
|
||||
{ key: 'company_name', groupId: 'group-company', inputId: 'form-company', labelId: 'label-company' },
|
||||
{ key: 'position', groupId: 'group-position', inputId: 'form-position', labelId: 'label-position' },
|
||||
{ key: 'business_scope', groupId: 'group-business', inputId: 'form-business', labelId: 'label-business' },
|
||||
{ key: 'vision_2026', groupId: 'group-vision', inputId: 'form-vision', labelId: 'label-vision' }
|
||||
];
|
||||
|
||||
fields.forEach(field => {
|
||||
const conf = fc[field.key] || { show: false, required: false, label: '' };
|
||||
const group = document.getElementById(field.groupId);
|
||||
const input = document.getElementById(field.inputId);
|
||||
const label = document.getElementById(field.labelId);
|
||||
|
||||
if (group && input) {
|
||||
// Visibility
|
||||
if (conf.show) {
|
||||
group.classList.remove('hidden');
|
||||
} else {
|
||||
group.classList.add('hidden');
|
||||
}
|
||||
|
||||
// Required
|
||||
input.required = conf.required === true;
|
||||
|
||||
// Label
|
||||
if (label && conf.label) {
|
||||
label.textContent = conf.label;
|
||||
}
|
||||
}
|
||||
});
|
||||
// 动态渲染字段
|
||||
renderDynamicCheckinFields();
|
||||
}
|
||||
|
||||
function updateCheckinButtonState() {
|
||||
@@ -979,11 +978,14 @@
|
||||
|
||||
setVal('form-name', user.name);
|
||||
setVal('form-phone', user.phone);
|
||||
setVal('form-company', user.industry_company);
|
||||
// Clear other optional fields to avoid carrying over data if user switches
|
||||
setVal('form-position', user.position); // Note: user.position might not exist in search result
|
||||
setVal('form-business', user.business_scope);
|
||||
setVal('form-vision', user.vision_2026);
|
||||
// 动态字段填充
|
||||
const fc = CONFIG.checkin_field_config || {};
|
||||
Object.keys(fc).forEach(key => {
|
||||
if (key === 'name' || key === 'phone') return;
|
||||
// 特殊映射:company_name 字段填充 industry_company 的值
|
||||
const fieldKey = (key === 'company_name') ? 'industry_company' : key;
|
||||
setVal('form-' + key, user[fieldKey] || '');
|
||||
});
|
||||
|
||||
// Display preview
|
||||
if (document.getElementById('display-name')) document.getElementById('display-name').textContent = user.name;
|
||||
@@ -1014,18 +1016,22 @@
|
||||
return el ? el.value : '';
|
||||
};
|
||||
|
||||
// 构建 payload
|
||||
const payload = {
|
||||
gsdh_id: getVal('gsdh-id'),
|
||||
name: getVal('form-name'),
|
||||
phone: getVal('form-phone'),
|
||||
verification_code: getVal('form-verification-code'),
|
||||
company_name: getVal('form-company'),
|
||||
position: getVal('form-position'),
|
||||
business_scope: getVal('form-business'),
|
||||
vision_2026: getVal('form-vision'),
|
||||
location: getVal('form-location')
|
||||
};
|
||||
|
||||
// 动态收集签到字段数据
|
||||
const fc = CONFIG.checkin_field_config || {};
|
||||
Object.keys(fc).forEach(key => {
|
||||
if (key === 'name' || key === 'phone') return;
|
||||
payload[key] = getVal('form-' + key);
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/checkin', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user