Are you sure you want to go to an external site to donate a monetary value?
WARNING: Some countries laws may supersede the payment processors policy such as the GDPR and PayPal. While it is highly appreciated to donate, please check with your countries privacy and identity laws regarding privacy of information first. Use at your utmost discretion.
ERP 供应商搜索工具脚本信息
基本信息
功能描述
该脚本是一个为ERP系统设计的供应商搜索工具,提供了以下核心功能:
1. 浮动搜索窗口
2. 窗口交互功能
3. 供应商搜索功能
4. 供应商备注获取
5. 表格复制按钮
6. 自动选择表格行
技术实现
1. 界面构建
// 创建搜索容器 const searchContainer = document.createElement('div'); searchContainer.style.cssText = ` position: fixed; top: 10px; right: auto; z-index: 9999; display: flex; flex-direction: column; gap: 0; background: white; padding: 0; border: 2px solid #4A90E2; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); user-select: none; font-family: Arial, sans-serif; `;2. 拖拽实现
dragHeader.addEventListener('mousedown', (e) => { isDragging = true; startX = e.clientX - searchContainer.offsetLeft; startY = e.clientY - searchContainer.offsetTop; searchContainer.style.zIndex = '10000'; // 拖动时提高层级 // 如果窗口处于折叠状态,先展开 if (isCollapsed) { expandWindow(); } });3. 边缘吸附检查
function checkEdgeSnap() { const threshold = 10; // 距离边缘的阈值 const currentLeft = parseInt(searchContainer.style.left); const currentTop = parseInt(searchContainer.style.top); // 保存原始位置 originalPosition = { left: searchContainer.style.left, top: searchContainer.style.top }; openStatePosition = { left: searchContainer.style.left, top: searchContainer.style.top }; // 检查是否靠近左侧边缘 if (currentLeft <= threshold) { collapseWindow('left'); } // 检查是否靠近右侧边缘 else if (currentLeft >= window.innerWidth - searchContainer.offsetWidth - threshold) { collapseWindow('right'); } }4. 数据持久化
// 保存位置到本地存储 const position = { left: searchContainer.style.left, top: searchContainer.style.top }; localStorage.setItem('erpSearchPosition', JSON.stringify(position)); // 保存折叠状态 const collapseState = { isCollapsed: true, side: edge, position: collapseStatePosition }; localStorage.setItem('erpSearchCollapseState', JSON.stringify(collapseState));5. API调用
// 发送供应商搜索请求 const response = await fetch(apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(requestData), credentials: 'include' // 包含cookie });使用说明
注意事项
更新日志
版本 2.3:修复供应商名称处理
/[()()][^()()]*新[^()()]*[()()]/gi版本 2.2:优化复制按钮功能
版本 2.1:OpenUserJS平台适配
版本 2.0:增强功能版本
版本 1.0:核心功能完善
版本 0.1:初始版本发布