| | |
| | | label-width="140px" |
| | | label-position="top" |
| | | :rules="rules" |
| | | @keydown.capture="handleTabScrollFollow" |
| | | ref="formRef"> |
| | | <!-- 报价单导入入口:放在表单顶部,选择后反显客户/业务员等 --> |
| | | <el-row v-if="operationType === 'add'" |
| | |
| | | const num = Number(cellValue); |
| | | return Number.isFinite(num) ? num.toFixed(2) : ""; |
| | | }; |
| | | |
| | | const scrollElementIntoVisibleArea = target => { |
| | | if (!target || !(target instanceof HTMLElement)) return; |
| | | let parent = target.parentElement; |
| | | while (parent && parent !== document.body) { |
| | | const style = window.getComputedStyle(parent); |
| | | const canScrollX = |
| | | (style.overflowX === "auto" || |
| | | style.overflowX === "scroll" || |
| | | style.overflowX === "overlay") && |
| | | parent.scrollWidth > parent.clientWidth; |
| | | const canScrollY = |
| | | (style.overflowY === "auto" || |
| | | style.overflowY === "scroll" || |
| | | style.overflowY === "overlay") && |
| | | parent.scrollHeight > parent.clientHeight; |
| | | |
| | | if (canScrollX || canScrollY) { |
| | | const parentRect = parent.getBoundingClientRect(); |
| | | const targetRect = target.getBoundingClientRect(); |
| | | if (canScrollX) { |
| | | const targetCenterX = targetRect.left + targetRect.width / 2; |
| | | const parentCenterX = parentRect.left + parentRect.width / 2; |
| | | const deltaX = targetCenterX - parentCenterX; |
| | | if (Math.abs(deltaX) > 2) { |
| | | parent.scrollLeft += deltaX; |
| | | } |
| | | } |
| | | |
| | | if (canScrollY) { |
| | | const targetCenterY = targetRect.top + targetRect.height / 2; |
| | | const parentCenterY = parentRect.top + parentRect.height / 2; |
| | | const deltaY = targetCenterY - parentCenterY; |
| | | if (Math.abs(deltaY) > 2) { |
| | | parent.scrollTop += deltaY; |
| | | } |
| | | } |
| | | } |
| | | |
| | | parent = parent.parentElement; |
| | | } |
| | | }; |
| | | |
| | | const handleTabScrollFollow = e => { |
| | | if (!e || e.key !== "Tab") return; |
| | | requestAnimationFrame(() => { |
| | | const active = document.activeElement; |
| | | if (active instanceof HTMLElement) { |
| | | scrollElementIntoVisibleArea(active); |
| | | } |
| | | }); |
| | | }; |
| | | // 获取tree子数据 |
| | | const getModels = value => { |
| | | // 产品大类变化时,重置规格型号与厚度,避免旧值残留 |