diff --git a/static/js/common.js b/static/js/common.js index d56938f..0e34958 100644 --- a/static/js/common.js +++ b/static/js/common.js @@ -111,6 +111,16 @@ function escHtml(str) { .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(); +} + /* ============ 会话与权限 ============ */ /** diff --git a/static/js/config.js b/static/js/config.js index 62b159f..67218c8 100644 --- a/static/js/config.js +++ b/static/js/config.js @@ -5,7 +5,7 @@ var BASE_URL = '/api/'; var PAGE_SIZE = 20; /** 系统版本号(logo旁展示):修改代码后运行 tools/bump_version.php 自动递增 */ -var APP_VERSION = 'v1.0.21'; +var APP_VERSION = 'v1.0.22'; /** 页脚版权/备案信息(在 config.js 中修改) */ var FOOTER_TEXT = '© 2026 SuperLink 管理系统 版权所有 | 备案号:请替换为真实备案号'; diff --git a/static/js/media.js b/static/js/media.js index d988682..18ae63e 100644 --- a/static/js/media.js +++ b/static/js/media.js @@ -168,6 +168,25 @@ $(function () { $('#media-platform').on('change', 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) { e.preventDefault(); var data = {}; @@ -182,6 +201,9 @@ $(function () { }); if (!data.platform || !data.account_id) { Dialog.error('平台和账号为必填项'); 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; httpPost(isEdit ? 'media/update.php' : 'media/add.php', data).then(function () { diff --git a/static/js/person.js b/static/js/person.js index 18ae41c..c4eaaff 100644 --- a/static/js/person.js +++ b/static/js/person.js @@ -299,7 +299,7 @@ $(function () { '
' + '
' + '
' + - '
' + + '
' + '
' + '
' + ''; @@ -344,6 +344,13 @@ $(function () { // 手机号归属地自动识别 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) { var $dl = $('#person-country-list'); @@ -410,12 +417,14 @@ $(function () { if (!data.full_name) { Dialog.error('姓名为必填项'); return; } // 联系方式(手机/邮箱,均为常用) + data.phone = cleanPhone(data.phone); + data.email = cleanEmail(data.email); var contacts = []; - if ($.trim(data.phone || '')) { - contacts.push({ platform: 'phone', account_id: $.trim(data.phone), is_primary: 1, is_defult: 1 }); + if (data.phone) { + contacts.push({ platform: 'phone', account_id: 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 }); + if (data.email) { + contacts.push({ platform: 'email', account_id: data.email, is_primary: 1, is_defult: 1 }); } data.contacts = JSON.stringify(contacts); delete data.phone;