v1.0.22: 手机号/邮箱录入自动清洗 - 手机号去所有空格(含中间)如138 1234 5678->13812345678,邮箱去首尾空格(人员表单/媒体账号)
This commit is contained in:
@@ -111,6 +111,16 @@ function escHtml(str) {
|
|||||||
.replace(/"/g, '"').replace(/'/g, ''');
|
.replace(/"/g, '"').replace(/'/g, ''');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 手机号清洗:清除所有空白(含数字中间的空格),如 "138 1234 5678" -> "13812345678" */
|
||||||
|
function cleanPhone(v) {
|
||||||
|
return String(v == null ? '' : v).replace(/\s+/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 邮箱清洗:清除首尾空格 */
|
||||||
|
function cleanEmail(v) {
|
||||||
|
return String(v == null ? '' : v).trim();
|
||||||
|
}
|
||||||
|
|
||||||
/* ============ 会话与权限 ============ */
|
/* ============ 会话与权限 ============ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -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.21';
|
var APP_VERSION = 'v1.0.22';
|
||||||
|
|
||||||
/** 页脚版权/备案信息(在 config.js 中修改) */
|
/** 页脚版权/备案信息(在 config.js 中修改) */
|
||||||
var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号';
|
var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号';
|
||||||
|
|||||||
@@ -168,6 +168,25 @@ $(function () {
|
|||||||
$('#media-platform').on('change', bindGeo);
|
$('#media-platform').on('change', bindGeo);
|
||||||
bindGeo();
|
bindGeo();
|
||||||
|
|
||||||
|
// 录入自动清洗:平台为 phone 时账号去所有空格(含中间),为 email 时去首尾空格
|
||||||
|
var bindAccountClean = function () {
|
||||||
|
var plat = $('#media-platform').val();
|
||||||
|
if (plat === 'phone') {
|
||||||
|
$('#media-account').off('blur.clean').on('input.clean', function () {
|
||||||
|
var v = cleanPhone($(this).val());
|
||||||
|
if ($(this).val() !== v) $(this).val(v);
|
||||||
|
});
|
||||||
|
} else if (plat === 'email') {
|
||||||
|
$('#media-account').off('input.clean').on('blur.clean', function () {
|
||||||
|
$(this).val(cleanEmail($(this).val()));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('#media-account').off('input.clean blur.clean');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$('#media-platform').on('change', bindAccountClean);
|
||||||
|
bindAccountClean();
|
||||||
|
|
||||||
$('#media-form').on('submit', function (e) {
|
$('#media-form').on('submit', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var data = {};
|
var data = {};
|
||||||
@@ -182,6 +201,9 @@ $(function () {
|
|||||||
});
|
});
|
||||||
if (!data.platform || !data.account_id) { Dialog.error('平台和账号为必填项'); return; }
|
if (!data.platform || !data.account_id) { Dialog.error('平台和账号为必填项'); return; }
|
||||||
if (!isEdit && (!data.owner_type || !data.owner_id)) { Dialog.error('归属类型和归属ID为必填项'); return; }
|
if (!isEdit && (!data.owner_type || !data.owner_id)) { Dialog.error('归属类型和归属ID为必填项'); return; }
|
||||||
|
// 录入清洗:手机号去所有空格(含中间),邮箱去首尾空格
|
||||||
|
if (data.platform === 'phone') data.account_id = cleanPhone(data.account_id);
|
||||||
|
else if (data.platform === 'email') data.account_id = cleanEmail(data.account_id);
|
||||||
if (isEdit) data.id = m.id;
|
if (isEdit) data.id = m.id;
|
||||||
|
|
||||||
httpPost(isEdit ? 'media/update.php' : 'media/add.php', data).then(function () {
|
httpPost(isEdit ? 'media/update.php' : 'media/add.php', data).then(function () {
|
||||||
|
|||||||
+14
-5
@@ -299,7 +299,7 @@ $(function () {
|
|||||||
' <div class="form-item"><label>手机</label>' +
|
' <div class="form-item"><label>手机</label>' +
|
||||||
' <div><input type="text" name="phone" id="person-phone" value="' + escHtml(pPhone) + '" placeholder="常用手机号">' +
|
' <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="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><input type="text" name="email" id="person-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><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 class="form-item"><label>来源详情</label><input type="text" name="source_detail" value="' + escHtml(p.source_detail) + '" placeholder="如:华南工博会"></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
@@ -344,6 +344,13 @@ $(function () {
|
|||||||
// 手机号归属地自动识别
|
// 手机号归属地自动识别
|
||||||
bindPhoneGeo($('#person-phone'), $('#person-phone-geo'));
|
bindPhoneGeo($('#person-phone'), $('#person-phone-geo'));
|
||||||
|
|
||||||
|
// 录入自动清洗:手机号去所有空格(含中间),邮箱去首尾空格
|
||||||
|
$('#person-phone').on('input', function () {
|
||||||
|
var v = cleanPhone($(this).val());
|
||||||
|
if ($(this).val() !== v) $(this).val(v);
|
||||||
|
});
|
||||||
|
$('#person-email').on('blur', function () { $(this).val(cleanEmail($(this).val())); });
|
||||||
|
|
||||||
// 加载国籍字典 + 行政区划字典(省-市两级) + 来源渠道字典 + 任职公司
|
// 加载国籍字典 + 行政区划字典(省-市两级) + 来源渠道字典 + 任职公司
|
||||||
httpGet('common/dicts.php', { type: 'all' }).then(function (d) {
|
httpGet('common/dicts.php', { type: 'all' }).then(function (d) {
|
||||||
var $dl = $('#person-country-list');
|
var $dl = $('#person-country-list');
|
||||||
@@ -410,12 +417,14 @@ $(function () {
|
|||||||
if (!data.full_name) { Dialog.error('姓名为必填项'); return; }
|
if (!data.full_name) { Dialog.error('姓名为必填项'); return; }
|
||||||
|
|
||||||
// 联系方式(手机/邮箱,均为常用)
|
// 联系方式(手机/邮箱,均为常用)
|
||||||
|
data.phone = cleanPhone(data.phone);
|
||||||
|
data.email = cleanEmail(data.email);
|
||||||
var contacts = [];
|
var contacts = [];
|
||||||
if ($.trim(data.phone || '')) {
|
if (data.phone) {
|
||||||
contacts.push({ platform: 'phone', account_id: $.trim(data.phone), is_primary: 1, is_defult: 1 });
|
contacts.push({ platform: 'phone', account_id: data.phone, is_primary: 1, is_defult: 1 });
|
||||||
}
|
}
|
||||||
if ($.trim(data.email || '')) {
|
if (data.email) {
|
||||||
contacts.push({ platform: 'email', account_id: $.trim(data.email), is_primary: 1, is_defult: 1 });
|
contacts.push({ platform: 'email', account_id: data.email, is_primary: 1, is_defult: 1 });
|
||||||
}
|
}
|
||||||
data.contacts = JSON.stringify(contacts);
|
data.contacts = JSON.stringify(contacts);
|
||||||
delete data.phone;
|
delete data.phone;
|
||||||
|
|||||||
Reference in New Issue
Block a user