@flexem/fc-gui 3.0.0-alpha.144 → 3.0.0-alpha.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39306,8 +39306,6 @@ class text_state_element_TextStateElement {
39306
39306
  return;
39307
39307
  }
39308
39308
  const textElement = this.getforeignObjectElement();
39309
- // 清空旧内容
39310
- textElement.textContent = '';
39311
39309
  // 设置 text-anchor 和 dominant-baseline
39312
39310
  textElement.setAttribute('text-anchor', 'middle');
39313
39311
  textElement.setAttribute('dominant-baseline', 'middle');
@@ -39320,9 +39318,15 @@ class text_state_element_TextStateElement {
39320
39318
  const totalHeight = lines.length * lineHeight;
39321
39319
  // 调整文本整体垂直居中(通过 dy)
39322
39320
  const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
39323
- // 添加每行文本
39321
+ // 复用已有 tspan,不足则新建,多余则隐藏——避免删除 touch 目标节点导致 touchend 丢失
39322
+ const existingTspans = Array.from(textElement.children);
39324
39323
  for (let i = 0; i < lines.length; i++) {
39325
- const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
39324
+ let tspan = existingTspans[i];
39325
+ if (!tspan) {
39326
+ tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
39327
+ textElement.appendChild(tspan);
39328
+ }
39329
+ tspan.setAttribute('display', 'inline');
39326
39330
  tspan.setAttribute('x', (this.width / 2).toString());
39327
39331
  tspan.setAttribute('y', startY + i * lineHeight + 'px');
39328
39332
  tspan.textContent = lines[i].replace(/ /g, '\u00A0');
@@ -39334,7 +39338,10 @@ class text_state_element_TextStateElement {
39334
39338
  tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
39335
39339
  tspan.setAttribute('text-anchor', 'middle');
39336
39340
  tspan.setAttribute('dominant-baseline', 'middle');
39337
- textElement.appendChild(tspan);
39341
+ }
39342
+ // 隐藏多余的 tspan(不删除)
39343
+ for (let i = lines.length; i < existingTspans.length; i++) {
39344
+ existingTspans[i].setAttribute('display', 'none');
39338
39345
  }
39339
39346
  this.doFaultFlicker(textElement, stateId);
39340
39347
  }
@@ -39377,12 +39384,13 @@ class text_state_element_TextStateElement {
39377
39384
  this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
39378
39385
  this._element.appendChild(this.textElement);
39379
39386
  }
39387
+ this.textElement.setAttribute('display', 'block');
39380
39388
  return this.textElement;
39381
39389
  }
39382
39390
  removeForeignObjectlement() {
39383
39391
  if (this.textElement) {
39384
- this._element.removeChild(this.textElement);
39385
- delete this.textElement;
39392
+ this.textElement.setAttribute('display', 'none');
39393
+ this.textElement.textContent = '';
39386
39394
  }
39387
39395
  }
39388
39396
  doFaultFlicker(textElement, stateId) {
@@ -42309,18 +42317,6 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42309
42317
  this.initDisplayContainer();
42310
42318
  // 获取字体设置
42311
42319
  this.headerFont = ((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.headerFont) || {};
42312
- // 构建符合 CSS font 属性规范的字符串
42313
- let fontString = '';
42314
- if (this.headerFont.isItalic) {
42315
- fontString += 'italic ';
42316
- }
42317
- if (this.headerFont.isBold) {
42318
- fontString += 'bold ';
42319
- }
42320
- const fontSize = this.headerFont.fontSize || '16px';
42321
- const lineHeight = parseInt(fontSize, 10) + 5;
42322
- fontString += `${fontSize}/${lineHeight}px ${this.headerFont.fontFamily || 'Microsoft YaHei'}`;
42323
- this.fontString = fontString;
42324
42320
  // 使用静态显示逻辑:只显示字段标签
42325
42321
  this.renderStaticDisplay();
42326
42322
  this.setStatusAsNormal();
@@ -42353,19 +42349,6 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42353
42349
  this.initDisplayContainer();
42354
42350
  // 获取字体设置 - 参考 text-element.ts 的实现方式
42355
42351
  this.headerFont = ((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.headerFont) || {};
42356
- // 构建符合 CSS font 属性规范的字符串
42357
- // 格式:font-style font-weight font-size/line-height font-family
42358
- let fontString = '';
42359
- if (this.headerFont.isItalic) {
42360
- fontString += 'italic ';
42361
- }
42362
- if (this.headerFont.isBold) {
42363
- fontString += 'bold ';
42364
- }
42365
- const fontSize = this.headerFont.fontSize || '16px';
42366
- const lineHeight = parseInt(fontSize, 10) + 5;
42367
- fontString += `${fontSize}/${lineHeight}px ${this.headerFont.fontFamily || 'Microsoft YaHei'}`;
42368
- this.fontString = fontString;
42369
42352
  this.getAlarmData();
42370
42353
  }
42371
42354
  }
@@ -42375,7 +42358,9 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42375
42358
  // 初始化显示容器以显示空内容
42376
42359
  this.initDisplayContainer();
42377
42360
  if (this.allAlarmsContainer) {
42378
- this.allAlarmsContainer.innerHTML = '';
42361
+ while (this.allAlarmsContainer.firstChild) {
42362
+ this.allAlarmsContainer.removeChild(this.allAlarmsContainer.firstChild);
42363
+ }
42379
42364
  this.totalWidth = 0;
42380
42365
  this.pageWidths = [];
42381
42366
  }
@@ -42453,8 +42438,8 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42453
42438
  const oldPageWidth = this.pageWidths.pop() || 0;
42454
42439
  this.totalWidth -= oldPageWidth;
42455
42440
  const elementsToRemove = Array.from(this.allAlarmsContainer.children).slice(startIndex, startIndex + itemsPerPage);
42456
- elementsToRemove.forEach(element => {
42457
- this.allAlarmsContainer.removeChild(element);
42441
+ elementsToRemove.forEach(el => {
42442
+ this.allAlarmsContainer.removeChild(el);
42458
42443
  });
42459
42444
  // 插入新的当前页数据
42460
42445
  this.displayedItems.splice(startIndex, 0, ...newPage);
@@ -42494,7 +42479,9 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42494
42479
  // 清空显示
42495
42480
  this.displayedItems = [];
42496
42481
  if (this.allAlarmsContainer) {
42497
- this.allAlarmsContainer.innerHTML = '';
42482
+ while (this.allAlarmsContainer.firstChild) {
42483
+ this.allAlarmsContainer.removeChild(this.allAlarmsContainer.firstChild);
42484
+ }
42498
42485
  this.totalWidth = 0;
42499
42486
  this.pageWidths = [];
42500
42487
  }
@@ -42521,121 +42508,153 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42521
42508
  var _a;
42522
42509
  const elementHeight = this.model.size.height;
42523
42510
  const elementWidth = this.model.size.width;
42524
- // 创建foreignObject作为容器
42525
- this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
42526
- this.element.setAttribute('width', elementWidth.toString());
42527
- this.element.setAttribute('height', elementHeight.toString());
42528
- this.$element.append(this.element);
42529
- // 创建背景容器,应用headerFillColor背景色
42530
- this.container = document.createElement('div');
42531
- this.container.style.cssText = `
42532
- height: ${elementHeight}px;
42533
- width: 100%;
42534
- background-color: ${((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.headerFillColor) || '#ffffff'};
42535
- display: flex;
42536
- align-items: center;
42537
- overflow: hidden;
42538
- position: relative;
42539
- border: 1px solid #8ea0aa;
42540
- border-radius: 2px;
42541
- `;
42542
- this.element.appendChild(this.container);
42543
- // 创建一个大容器来包含所有告警项,初始位置在容器右侧(从右边开始滚入)
42544
- this.allAlarmsContainer = document.createElement('div');
42545
- this.allAlarmsContainer.style.cssText = `
42546
- position: absolute;
42547
- top: 50%;
42548
- transform: translateY(-50%);
42549
- display: flex;
42550
- align-items: center;
42551
- gap: 80px;
42552
- `;
42553
- this.container.appendChild(this.allAlarmsContainer);
42554
- // 设置初始位置为容器宽度,让内容从右侧滚入
42511
+ const bgColor = ((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.headerFillColor) || '#ffffff';
42512
+ const clipId = 'scroll-alarm-clip-' + Math.random().toString(36).slice(2);
42513
+ // 背景矩形
42514
+ this.bgRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
42515
+ this.bgRect.setAttribute('x', '0');
42516
+ this.bgRect.setAttribute('y', '0');
42517
+ this.bgRect.setAttribute('width', elementWidth.toString());
42518
+ this.bgRect.setAttribute('height', elementHeight.toString());
42519
+ this.bgRect.setAttribute('fill', bgColor);
42520
+ this.bgRect.setAttribute('stroke', '#8ea0aa');
42521
+ this.bgRect.setAttribute('stroke-width', '1');
42522
+ this.$element[0].appendChild(this.bgRect);
42523
+ // clipPath 限制文字滚动区域
42524
+ const defs = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
42525
+ const clipPath = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
42526
+ clipPath.setAttribute('id', clipId);
42527
+ const clipRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
42528
+ clipRect.setAttribute('x', '2');
42529
+ clipRect.setAttribute('y', '0');
42530
+ clipRect.setAttribute('width', (elementWidth - 4).toString());
42531
+ clipRect.setAttribute('height', elementHeight.toString());
42532
+ clipPath.appendChild(clipRect);
42533
+ defs.appendChild(clipPath);
42534
+ this.$element[0].appendChild(defs);
42535
+ // 滚动内容的 g 容器,套上 clipPath
42536
+ this.scrollGroup = document.createElementNS('http://www.w3.org/2000/svg', 'g');
42537
+ this.scrollGroup.setAttribute('clip-path', `url(#${clipId})`);
42538
+ this.$element[0].appendChild(this.scrollGroup);
42539
+ // 内部 g 用于整体平移(滚动动画改这个的 transform)
42540
+ this.allAlarmsContainer = document.createElementNS('http://www.w3.org/2000/svg', 'g');
42541
+ this.scrollGroup.appendChild(this.allAlarmsContainer);
42542
+ // 初始位置在右侧屏幕外
42555
42543
  this.currentLeft = elementWidth;
42556
- this.allAlarmsContainer.style.left = `${elementWidth}px`;
42557
- // 添加鼠标悬停暂停和恢复滚动功能
42558
- this.container.addEventListener('mouseenter', () => this.pauseScroll());
42559
- this.container.addEventListener('mouseleave', () => this.resumeScroll());
42544
+ this.allAlarmsContainer.setAttribute('transform', `translate(${elementWidth}, 0)`);
42545
+ }
42546
+ _buildFontAttrs() {
42547
+ const f = this.headerFont || {};
42548
+ const fontSize = parseInt((f.fontSize || '16px'), 10);
42549
+ return {
42550
+ fontSize,
42551
+ fontFamily: f.fontFamily || 'Microsoft YaHei',
42552
+ color: f.color || '#e33c39',
42553
+ isBold: !!f.isBold,
42554
+ isItalic: !!f.isItalic,
42555
+ isUnderline: !!f.isUnderline
42556
+ };
42557
+ }
42558
+ _createSvgTextNode(textContent) {
42559
+ const elementHeight = this.model.size.height;
42560
+ const fa = this._buildFontAttrs();
42561
+ const text = document.createElementNS('http://www.w3.org/2000/svg', 'text');
42562
+ text.setAttribute('y', (elementHeight / 2).toString());
42563
+ text.setAttribute('dominant-baseline', 'central');
42564
+ text.setAttribute('fill', fa.color);
42565
+ text.setAttribute('font-size', fa.fontSize.toString());
42566
+ text.setAttribute('font-family', fa.fontFamily);
42567
+ if (fa.isBold) {
42568
+ text.setAttribute('font-weight', 'bold');
42569
+ }
42570
+ if (fa.isItalic) {
42571
+ text.setAttribute('font-style', 'italic');
42572
+ }
42573
+ if (fa.isUnderline) {
42574
+ text.setAttribute('text-decoration', 'underline');
42575
+ }
42576
+ text.textContent = textContent;
42577
+ return text;
42560
42578
  }
42561
42579
  renderNewPage(pageData) {
42580
+ const GAP = 80;
42562
42581
  let pageWidth = 0;
42563
- // 为每个告警数据创建文本容器
42582
+ // 新页的起始 x = 已有总宽度 + gap(如果已有内容)
42583
+ let xOffset = this.totalWidth > 0 ? this.totalWidth + GAP : 0;
42564
42584
  pageData.forEach((alarm) => {
42565
42585
  var _a, _b, _c, _d, _e, _f, _g, _h;
42566
- // 创建告警文本容器
42567
- const textContainer = document.createElement('div');
42568
- textContainer.style.cssText = `
42569
- font: ${this.fontString};
42570
- color: ${this.headerFont.color || '#e33c39'};
42571
- white-space: nowrap;
42572
- overflow: visible;
42573
- `;
42574
- // 应用下划线样式(参考 text-element.ts 的实现)
42575
- if (this.headerFont.isUnderline) {
42576
- textContainer.style.textDecoration = 'underline';
42577
- }
42578
- // 构建告警信息内容,根据配置决定显示哪些字段
42579
42586
  const contentParts = [];
42580
- // 显示触发时间
42581
42587
  if (((_a = this.model.generalSetting) === null || _a === void 0 ? void 0 : _a.showTriggerTime) && alarm.triggeredTime) {
42582
- const formattedTime = moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss');
42583
- contentParts.push(formattedTime);
42588
+ contentParts.push(moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss'));
42584
42589
  }
42585
- // 获取当前语言环境
42586
42590
  const language = ((_d = (_c = (_b = window.abp) === null || _b === void 0 ? void 0 : _b.localization) === null || _c === void 0 ? void 0 : _c.currentLanguage) === null || _d === void 0 ? void 0 : _d.name) || 'zh-Hans';
42587
42591
  const isChinese = language === 'zh-Hans' || language === 'zh';
42588
- // 显示告警等级
42589
42592
  if (((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.showAlarmLevel) && alarm.alarmLevel !== undefined) {
42590
42593
  const levelMap = isChinese ? ['警告', '次要', '主要', '严重'] : ['Warning', 'Minor', 'Major', 'Critical'];
42591
- const alarmLevel = levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning');
42592
- contentParts.push(alarmLevel);
42594
+ contentParts.push(levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning'));
42593
42595
  }
42594
- // 显示告警名称
42595
42596
  if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) && alarm.name) {
42596
42597
  contentParts.push(alarm.name);
42597
42598
  }
42598
- // 显示告警内容
42599
42599
  if (((_g = this.model.generalSetting) === null || _g === void 0 ? void 0 : _g.showAlarmContent) && alarm.message) {
42600
42600
  contentParts.push(alarm.message);
42601
42601
  }
42602
- // 显示告警状态
42603
42602
  if (((_h = this.model.generalSetting) === null || _h === void 0 ? void 0 : _h.showAlarmState) && alarm.state !== undefined) {
42604
- const stateMap = isChinese ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认'] : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
42605
- const alarmState = stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
42606
- contentParts.push(alarmState);
42607
- }
42608
- // 将所有显示字段用空格连接,确保一行显示
42609
- const textContent = contentParts.join(' ');
42610
- textContainer.textContent = textContent;
42611
- this.allAlarmsContainer.appendChild(textContainer);
42612
- // 计算文本宽度
42613
- const textWidth = textContainer.offsetWidth;
42614
- pageWidth += textWidth + 80; // 80是gap大小
42603
+ const stateMap = isChinese
42604
+ ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认']
42605
+ : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
42606
+ contentParts.push(stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed'));
42607
+ }
42608
+ const textNode = this._createSvgTextNode(contentParts.join(' '));
42609
+ textNode.setAttribute('x', xOffset.toString());
42610
+ this.allAlarmsContainer.appendChild(textNode);
42611
+ const textWidth = textNode.getComputedTextLength
42612
+ ? textNode.getComputedTextLength()
42613
+ : (textNode.getBBox ? textNode.getBBox().width : 100);
42614
+ xOffset += textWidth + GAP;
42615
+ pageWidth += (pageWidth > 0 ? GAP : 0) + textWidth;
42615
42616
  });
42616
- // 移除最后一个gap
42617
- if (pageWidth > 0) {
42618
- pageWidth -= 80;
42619
- }
42620
- // 保存页宽度
42621
42617
  this.pageWidths.push(pageWidth);
42622
- this.totalWidth += pageWidth;
42618
+ this.totalWidth += (this.totalWidth > 0 && pageWidth > 0 ? GAP : 0) + pageWidth;
42619
+ }
42620
+ _rebaseTextNodes() {
42621
+ const GAP = 80;
42622
+ let x = 0;
42623
+ Array.from(this.allAlarmsContainer.children).forEach(node => {
42624
+ node.setAttribute('x', x.toString());
42625
+ const w = node.getComputedTextLength
42626
+ ? node.getComputedTextLength()
42627
+ : (node.getBBox ? node.getBBox().width : 100);
42628
+ x += w + GAP;
42629
+ });
42630
+ const newTotal = x > 0 ? x - GAP : 0;
42631
+ this.totalWidth = newTotal;
42632
+ this.pageWidths = [newTotal];
42623
42633
  }
42624
42634
  removeOldestPage() {
42625
42635
  // 移除最旧的一页数据
42626
42636
  this.displayedItems.splice(0, this.maxResultCount);
42627
42637
  const oldPageWidth = this.pageWidths.shift() || 0;
42628
- // 更新总宽度
42629
- this.totalWidth -= oldPageWidth;
42638
+ this.totalWidth -= oldPageWidth + (this.pageWidths.length > 0 ? 80 : 0);
42630
42639
  // 从DOM中移除最旧的元素
42631
42640
  const elementsToRemove = Array.from(this.allAlarmsContainer.children).slice(0, this.maxResultCount);
42632
- elementsToRemove.forEach(element => {
42633
- this.allAlarmsContainer.removeChild(element);
42641
+ elementsToRemove.forEach(el => {
42642
+ this.allAlarmsContainer.removeChild(el);
42643
+ });
42644
+ // SVG text 的 x 坐标从 0 重排(DOM删除后剩余节点要重新编排 x)
42645
+ const GAP = 80;
42646
+ let x = 0;
42647
+ Array.from(this.allAlarmsContainer.children).forEach(node => {
42648
+ node.setAttribute('x', x.toString());
42649
+ const w = node.getComputedTextLength
42650
+ ? node.getComputedTextLength()
42651
+ : (node.getBBox ? node.getBBox().width : 100);
42652
+ x += w + GAP;
42634
42653
  });
42635
- // 调整当前left位置(保持视觉位置不变)- 这里需要等DOM更新完成后再调整
42654
+ // currentLeft 补偿被移除页的宽度(含 gap),保持视觉位置不变
42636
42655
  requestAnimationFrame(() => {
42637
- this.currentLeft += oldPageWidth;
42638
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42656
+ this.currentLeft += oldPageWidth + 80;
42657
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42639
42658
  });
42640
42659
  }
42641
42660
  scrollContent() {
@@ -42658,21 +42677,19 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42658
42677
  // 说明所有内容都已经滚出视图(不开启自动循环时多滚动50px确保最后一个字完全滚出)
42659
42678
  if (this.currentLeft + this.totalWidth < -50) {
42660
42679
  if (this.autoCycle) {
42661
- // 自动循环模式:无缝衔接回到容器右侧
42662
42680
  if (this.hasMoreData) {
42663
- // 有更多数据:继续加载(但实际上已经在上面预加载了)
42664
- // 重置到容器宽度,让内容从右侧重新滚入
42665
- this.currentLeft = this.container.clientWidth;
42681
+ // 有更多数据:重置到容器宽度,让内容从右侧重新滚入
42682
+ this.currentLeft = this.model.size.width;
42666
42683
  }
42667
42684
  else {
42668
- // 没有更多数据了:重置
42669
42685
  if (this.currentPage > 2) {
42670
42686
  // 数据总数超过一页:重置到第一页并重新查询
42671
42687
  this.resetToFirstPage();
42672
42688
  }
42673
42689
  else {
42674
- // 数据总数只有一页:直接重置到容器右侧,循环滚动当前数据
42675
- this.currentLeft = this.container.clientWidth;
42690
+ // 单页循环:重排 x 从 0 开始,currentLeft 重置到右侧
42691
+ this._rebaseTextNodes();
42692
+ this.currentLeft = this.model.size.width;
42676
42693
  }
42677
42694
  }
42678
42695
  }
@@ -42684,7 +42701,7 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42684
42701
  }
42685
42702
  }
42686
42703
  // 更新显示位置
42687
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42704
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42688
42705
  }
42689
42706
  initScrolling() {
42690
42707
  clearInterval(this.scrollIntervalId);
@@ -42695,8 +42712,8 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42695
42712
  // 确保初始位置在容器右侧(从右边滚入)
42696
42713
  if (this.currentPage === 1 && this.displayedItems.length <= this.maxResultCount) {
42697
42714
  // 第一页初始加载时,确保从右侧开始
42698
- this.currentLeft = this.container.clientWidth;
42699
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42715
+ this.currentLeft = this.model.size.width;
42716
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42700
42717
  }
42701
42718
  const scrollInterval = 100; // 默认100ms,滚动更流畅
42702
42719
  // 延迟启动滚动确保内容渲染完成
@@ -42709,12 +42726,6 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42709
42726
  }, scrollInterval);
42710
42727
  }, 500);
42711
42728
  }
42712
- pauseScroll() {
42713
- this.isScrolling = false;
42714
- }
42715
- resumeScroll() {
42716
- this.isScrolling = true;
42717
- }
42718
42729
  resetToFirstPage() {
42719
42730
  // 重置到第一页并重新查询数据
42720
42731
  this.currentPage = 1;
@@ -42722,13 +42733,15 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42722
42733
  this.hasTriedFirstPage = false;
42723
42734
  this.displayedItems = [];
42724
42735
  if (this.allAlarmsContainer) {
42725
- this.allAlarmsContainer.innerHTML = '';
42736
+ while (this.allAlarmsContainer.firstChild) {
42737
+ this.allAlarmsContainer.removeChild(this.allAlarmsContainer.firstChild);
42738
+ }
42726
42739
  this.totalWidth = 0;
42727
42740
  this.pageWidths = [];
42728
42741
  }
42729
42742
  // 重置到容器右侧,让内容从右边滚入
42730
- this.currentLeft = this.container.clientWidth;
42731
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42743
+ this.currentLeft = this.model.size.width;
42744
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42732
42745
  this.getAlarmData();
42733
42746
  }
42734
42747
  updateQueryTimeRange() {
@@ -42772,16 +42785,18 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42772
42785
  // 确保宽度和高度为正值,避免 SVG 错误
42773
42786
  const width = Math.max(this.model.size.width || 100, 0);
42774
42787
  const height = Math.max(this.model.size.height || 50, 0);
42788
+ // 先移除旧的 StateFrame,避免重复追加
42789
+ this.$element.find('rect#StateFrame').remove();
42775
42790
  this.rootElement.append('rect').attr('id', 'StateFrame').attr('fill', 'transparent')
42776
42791
  .attr('width', width)
42777
42792
  .attr('height', height);
42778
- const document = this.$element[0].ownerDocument;
42793
+ const doc = this.$element[0].ownerDocument;
42779
42794
  const currentRect = this.$element.find('rect#StateFrame').first();
42780
42795
  if (!currentRect.length) {
42781
42796
  return;
42782
42797
  }
42783
42798
  this.$element.find('image#StateImage').remove();
42784
- const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
42799
+ const imgObj = doc.createElementNS('http://www.w3.org/2000/svg', 'image');
42785
42800
  if (imgObj) {
42786
42801
  let x = Number(currentRect[0].getAttribute('width')) - 20;
42787
42802
  const currentRectX = currentRect[0].getAttribute('x');
@@ -42796,20 +42811,13 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42796
42811
  imgObj.setAttributeNS(null, 'y', '0');
42797
42812
  imgObj.setAttributeNS(null, 'height', '20px');
42798
42813
  imgObj.setAttributeNS(null, 'width', '20px');
42799
- const titleElement = document.createElementNS('http://www.w3.org/2000/svg', 'title');
42814
+ const titleElement = doc.createElementNS('http://www.w3.org/2000/svg', 'title');
42800
42815
  imgObj.appendChild(titleElement);
42801
42816
  this.$element.append(imgObj);
42802
42817
  }
42803
42818
  }
42804
42819
  clearStatus() {
42805
- const currentRect = this.$element.find('rect#StateFrame').first();
42806
- if (!currentRect.length) {
42807
- return;
42808
- }
42809
- const stroke = currentRect[0].getAttribute('stroke');
42810
- if (stroke) {
42811
- currentRect[0].removeAttribute('stroke');
42812
- }
42820
+ this.$element.find('rect#StateFrame').remove();
42813
42821
  this.$element.find('image#StateImage').remove();
42814
42822
  }
42815
42823
  /**
@@ -42848,36 +42856,20 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42848
42856
  const isChinese = language === 'zh-Hans' || language === 'zh';
42849
42857
  textParts.push(isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
42850
42858
  }
42851
- // 创建文本容器
42852
- const textContainer = document.createElement('div');
42853
- textContainer.style.cssText = `
42854
- font: ${this.fontString};
42855
- color: ${this.headerFont.color || '#e33c39'};
42856
- white-space: nowrap;
42857
- overflow: visible;
42858
- `;
42859
- // 应用下划线样式
42860
- if (this.headerFont.isUnderline) {
42861
- textContainer.style.textDecoration = 'underline';
42862
- }
42863
- // 设置文本内容
42864
- textContainer.textContent = textParts.join(' ');
42865
- // 使用配置的宽度,而不是 clientWidth(因为DOM可能还没渲染完成)
42866
- const containerWidth = this.model.size.width;
42867
- // 先设置容器位置到右侧(屏幕外),这样添加元素时不会闪烁
42868
- this.currentLeft = containerWidth;
42869
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42870
- // 添加到DOM以便计算宽度
42871
- this.allAlarmsContainer.appendChild(textContainer);
42872
- // 使用 setTimeout 确保 DOM 渲染完成后再计算宽度
42873
- setTimeout(() => {
42874
- // 计算文本宽度
42875
- const textWidth = textContainer.offsetWidth;
42876
- this.totalWidth = textWidth;
42877
- this.pageWidths.push(textWidth);
42878
- // 启动滚动(autoCycle 只控制是否循环,不控制是否滚动)
42879
- this.initStaticScrolling();
42880
- }, 50);
42859
+ // 创建 SVG text 节点(与真实运行模式一致,不依赖 foreignObject)
42860
+ const textNode = this._createSvgTextNode(textParts.join(' '));
42861
+ textNode.setAttribute('x', '0');
42862
+ this.currentLeft = this.model.size.width;
42863
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42864
+ this.allAlarmsContainer.appendChild(textNode);
42865
+ // SVG text 宽度可直接通过 getComputedTextLength 同步获取,无需 setTimeout
42866
+ const textWidth = textNode.getComputedTextLength
42867
+ ? textNode.getComputedTextLength()
42868
+ : (textNode.getBBox ? textNode.getBBox().width : 200);
42869
+ this.totalWidth = textWidth;
42870
+ this.pageWidths.push(textWidth);
42871
+ // 启动滚动(autoCycle 只控制是否循环,不控制是否滚动)
42872
+ this.initStaticScrolling();
42881
42873
  }
42882
42874
  /**
42883
42875
  * 模拟运行时的静态滚动逻辑
@@ -42904,7 +42896,7 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42904
42896
  // 更新位置 - 从右往左滚动
42905
42897
  this.currentLeft -= scrollStep;
42906
42898
  // 更新显示位置
42907
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42899
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42908
42900
  // 当内容完全滚出容器左侧时(内容右边缘完全移出容器左边缘)
42909
42901
  // currentLeft + totalWidth 表示内容右边缘的位置
42910
42902
  // 当这个值 <= -50 时,表示内容完全不可见(不开启自动循环时多滚动50px确保最后一个字完全滚出)
@@ -42913,7 +42905,7 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42913
42905
  if (this.autoCycle) {
42914
42906
  // 自动循环模式:重置到容器右侧(使用配置宽度)
42915
42907
  this.currentLeft = this.model.size.width;
42916
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42908
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42917
42909
  }
42918
42910
  else {
42919
42911
  // 非循环模式:停止滚动
@@ -42950,7 +42942,6 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42950
42942
  const input = new _tmp_config["c" /* GetAlarmsArgs */](this.alarmNames, this.startTime, this.endTime, queryCount, 0, // skipCount
42951
42943
  stateFilter, sorting);
42952
42944
  this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
42953
- var _a, _b, _c, _d, _e, _f, _g, _h;
42954
42945
  if (!result.error && result.items) {
42955
42946
  const newItems = result.items;
42956
42947
  // 如果没有数据,清空显示
@@ -42963,24 +42954,27 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42963
42954
  this.hasMoreData = true;
42964
42955
  // 清空DOM
42965
42956
  if (this.allAlarmsContainer) {
42966
- this.allAlarmsContainer.innerHTML = '';
42967
- const containerWidth = this.model.size.width;
42968
- this.currentLeft = containerWidth;
42969
- this.allAlarmsContainer.style.left = `${containerWidth}px`;
42957
+ while (this.allAlarmsContainer.firstChild) {
42958
+ this.allAlarmsContainer.removeChild(this.allAlarmsContainer.firstChild);
42959
+ }
42960
+ this.currentLeft = this.model.size.width;
42961
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42970
42962
  }
42971
42963
  return;
42972
42964
  }
42973
42965
  // 如果是首次加载或当前没有数据,直接渲染并启动滚动
42974
42966
  if (this.displayedItems.length === 0) {
42975
42967
  this.displayedItems = newItems;
42976
- this.allAlarmsContainer.innerHTML = '';
42968
+ while (this.allAlarmsContainer.firstChild) {
42969
+ this.allAlarmsContainer.removeChild(this.allAlarmsContainer.firstChild);
42970
+ }
42977
42971
  this.totalWidth = 0;
42978
42972
  this.pageWidths = [];
42979
42973
  // 设置 hasMoreData 状态,防止滚动时误触发 getAlarmData
42980
42974
  this.hasMoreData = result.totalCount > newItems.length;
42981
42975
  // 设置初始位置到容器右侧
42982
- this.currentLeft = this.container.clientWidth;
42983
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42976
+ this.currentLeft = this.model.size.width;
42977
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
42984
42978
  this.renderNewPage(newItems);
42985
42979
  // 启动滚动
42986
42980
  if (!this.isScrolling) {
@@ -42990,71 +42984,19 @@ class scroll_alarm_element_ScrollAlarmElement extends conditional_dynamic_displa
42990
42984
  }
42991
42985
  // 保存当前的滚动位置
42992
42986
  const currentScrollPosition = this.currentLeft;
42993
- // 清空所有DOM元素
42994
- this.allAlarmsContainer.innerHTML = '';
42995
- // 获取语言设置
42996
- const language = ((_c = (_b = (_a = window.abp) === null || _a === void 0 ? void 0 : _a.localization) === null || _b === void 0 ? void 0 : _b.currentLanguage) === null || _c === void 0 ? void 0 : _c.name) || 'zh-Hans';
42997
- const isChinese = language === 'zh-Hans' || language === 'zh';
42998
- // 重新创建所有新数据的DOM元素
42999
- for (let i = 0; i < newItems.length; i++) {
43000
- const alarm = newItems[i];
43001
- const textContainer = document.createElement('div');
43002
- textContainer.style.cssText = `
43003
- font: ${this.fontString};
43004
- color: ${this.headerFont.color || '#e33c39'};
43005
- white-space: nowrap;
43006
- overflow: visible;
43007
- `;
43008
- if (this.headerFont.isUnderline) {
43009
- textContainer.style.textDecoration = 'underline';
43010
- }
43011
- const contentParts = [];
43012
- // 显示触发时间
43013
- if (((_d = this.model.generalSetting) === null || _d === void 0 ? void 0 : _d.showTriggerTime) && alarm.triggeredTime) {
43014
- const formattedTime = moment(alarm.triggeredTime).format('YYYY/MM/DD HH:mm:ss');
43015
- contentParts.push(formattedTime);
43016
- }
43017
- // 显示告警等级
43018
- if (((_e = this.model.generalSetting) === null || _e === void 0 ? void 0 : _e.showAlarmLevel) && alarm.alarmLevel !== undefined) {
43019
- const levelMap = isChinese ? ['警告', '次要', '主要', '严重'] : ['Warning', 'Minor', 'Major', 'Critical'];
43020
- const alarmLevel = levelMap[alarm.alarmLevel] || (isChinese ? '警告' : 'Warning');
43021
- contentParts.push(alarmLevel);
43022
- }
43023
- // 显示告警名称
43024
- if (((_f = this.model.generalSetting) === null || _f === void 0 ? void 0 : _f.showAlarmName) && alarm.name) {
43025
- contentParts.push(alarm.name);
43026
- }
43027
- // 显示告警内容
43028
- if (((_g = this.model.generalSetting) === null || _g === void 0 ? void 0 : _g.showAlarmContent) && alarm.message) {
43029
- contentParts.push(alarm.message);
43030
- }
43031
- // 显示告警状态
43032
- if (((_h = this.model.generalSetting) === null || _h === void 0 ? void 0 : _h.showAlarmState) && alarm.state !== undefined) {
43033
- const stateMap = isChinese ? ['触发/未确认', '触发/已确认', '恢复/未确认', '恢复/已确认'] : ['Triggered/Unconfirmed', 'Triggered/Confirmed', 'Restored/Unconfirmed', 'Restored/Confirmed'];
43034
- const alarmState = stateMap[alarm.state] || (isChinese ? '触发/未确认' : 'Triggered/Unconfirmed');
43035
- contentParts.push(alarmState);
43036
- }
43037
- textContainer.textContent = contentParts.join(' ');
43038
- textContainer.setAttribute('data-index', i.toString());
43039
- this.allAlarmsContainer.appendChild(textContainer);
43040
- }
43041
- // 重新计算totalWidth
43042
- const allChildren = Array.from(this.allAlarmsContainer.children);
43043
- let newTotalWidth = 0;
43044
- allChildren.forEach(child => {
43045
- newTotalWidth += child.offsetWidth + 80;
43046
- });
43047
- if (newTotalWidth > 0) {
43048
- newTotalWidth -= 80; // 移除最后一个gap
42987
+ // 清空所有SVG text节点,重新用 renderNewPage 渲染
42988
+ while (this.allAlarmsContainer.firstChild) {
42989
+ this.allAlarmsContainer.removeChild(this.allAlarmsContainer.firstChild);
43049
42990
  }
42991
+ this.totalWidth = 0;
42992
+ this.pageWidths = [];
42993
+ this.renderNewPage(newItems);
43050
42994
  // 更新状态
43051
42995
  this.displayedItems = newItems;
43052
- this.totalWidth = newTotalWidth;
43053
- this.pageWidths = [newTotalWidth]; // 重置为单页
43054
42996
  this.hasMoreData = result.totalCount > newItems.length;
43055
42997
  // 保持滚动位置不变,继续滚动
43056
42998
  this.currentLeft = currentScrollPosition;
43057
- this.allAlarmsContainer.style.left = `${this.currentLeft}px`;
42999
+ this.allAlarmsContainer.setAttribute('transform', `translate(${this.currentLeft}, 0)`);
43058
43000
  }
43059
43001
  });
43060
43002
  }