Browse Source

折叠工具条正常,按钮正常

qdy 1 month ago
parent
commit
98e318a175

+ 9
- 74
src/app/pages/service-register-config/service-register-config.component.html View File

@@ -1,84 +1,19 @@
1 1
 <!-- 页面容器 - 采用与工作示例相同的布局结构 -->
2 2
 <div class="page-container">
3 3
   <!-- Sticky Header组件 -->
4
-  <app-sticky-header [collapseThreshold]="50" [scrollContainer]="'#service-register-content'">
5
-    <!-- 工具条区域 - 保持固定 -->
6
-    <div toolbar class="page-toolbar">
7
-      <div class="toolbar-content">
8
-        <!-- 标题区域 -->
9
-        <div class="title-section">
10
-          <mat-icon class="title-icon">description</mat-icon>
11
-          <h1 class="page-title">{{ title }}</h1>
12
-        </div>
13
-      </div>
14
-      
15
-      <!-- 按钮区域 -->
16
-      <div class="button-section">
17
-        <!-- 注册按钮 -->
18
-        <button 
19
-          type="button"
20
-          class="btn btn-primary"
21
-          (click)="onRegister()"
22
-          [disabled]="isRegistering"
23
-        >
24
-          @if (isRegistering) {
25
-            <mat-icon class="mr-1">hourglass_empty</mat-icon>
26
-            <span>处理中...</span>
27
-          } @else {
28
-            <mat-icon class="mr-1">add_circle</mat-icon>
29
-            <span>注册</span>
30
-          }
31
-        </button>
32
-        
33
-        <!-- 刷新按钮 -->
34
-        <button 
35
-          type="button"
36
-          class="btn btn-secondary"
37
-          (click)="refresh()"
38
-          [disabled]="isRefreshing"
39
-        >
40
-          @if (isRefreshing) {
41
-            <mat-icon class="mr-1 spin-icon">refresh</mat-icon>
42
-            <span>刷新中...</span>
43
-          } @else {
44
-            <mat-icon class="mr-1">refresh</mat-icon>
45
-            <span>刷新</span>
46
-          }
47
-        </button>
48
-      </div>
49
-    </div>
50
-    
51
-    <!-- 提示区域 - 可折叠 -->
52
-    <div hint class="page-hint">
53
-      <!-- 提示信息区域 -->
54
-      <div class="hint-section">
55
-        <div class="hint-content">
56
-          <p>点击"注册"按钮将同步所有配置元信息到数据库,并显示配置列表。</p>
57
-        </div>
58
-      </div>
59
-      
60
-      <!-- 调试信息区域 -->
61
-      <div class="debug-section">
62
-        <div class="debug-item">
63
-          <span class="debug-label">数据源:</span>
64
-          <span class="debug-value">{{ config.useMockData ? '模拟数据' : 'API数据' }}</span>
65
-        </div>
66
-        <div class="debug-item">
67
-          <span class="debug-label">记录条数:</span>
68
-          <span class="debug-value">{{ recordCount }}</span>
69
-        </div>
70
-        <div class="debug-item">
71
-          <span class="debug-label">更新时间:</span>
72
-          <span class="debug-value">{{ currentTime | date:'yyyy-MM-dd HH:mm:ss' }}</span>
73
-        </div>
74
-      </div>
75
-    </div>
76
-  </app-sticky-header>
4
+  <app-sticky-header
5
+    [title]="title"
6
+    [hintText]="hintText"
7
+    [buttons]="headerButtons"
8
+    [collapseThreshold]="50"
9
+    [scrollContainer]="'#service-register-content'"
10
+    (buttonAction)="onHeaderButtonAction($event)"
11
+  ></app-sticky-header>
77 12
   
78 13
   <!-- 内容区域 - 内部滚动 -->
79 14
   <div id="service-register-content" class="content-area">
80 15
     <!-- Tabulator 表格组件 -->
81
-    <app-tabulator-grid id="tabulator-table" #matCard
16
+    <app-tabulator-grid id="tabulator-table" 
82 17
       [columns]="columns"
83 18
       [dataLoader]="dataLoader"
84 19
       [height]="'1000px'"

+ 22
- 165
src/app/pages/service-register-config/service-register-config.component.scss View File

@@ -1,14 +1,16 @@
1 1
 /* Service Register Config 页面样式 */
2
-/* 采用与工作示例相同的布局结构 */
3 2
 
4
-/* 组件宿主元素 - 继承父容器高度 */
3
+/* ==================== 页面容器 ==================== */
4
+/* 专门为 sticky header 设置的容器 */
5 5
 :host {
6 6
   display: block;
7 7
   height: 100%;
8 8
 }
9 9
 
10
-/* ==================== 页面容器 ==================== */
11 10
 .page-container {
11
+  /* 左右间距 */
12
+  padding-left: 16px;
13
+  padding-right: 16px;
12 14
   display: flex;
13 15
   flex-direction: column;
14 16
   height: 100%;
@@ -18,172 +20,20 @@
18 20
   position: relative; /* 为sticky定位创建定位上下文 */
19 21
 }
20 22
 
21
-/* ==================== 工具条内容样式 ==================== */
22
-.page-toolbar {
23
-  display: flex;
24
-  justify-content: space-between;
25
-  align-items: center;
26
-  width: 100%;
27
-  min-height: 48px; /* 与组件最小高度匹配 */
28
-  padding: 0 16px; /* 与组件toolbar-area内边距匹配 */
29
-}
30
-
31
-.toolbar-content {
32
-  display: flex;
33
-  align-items: center;
34
-}
35
-
36
-/* 标题区域 */
37
-.title-section {
38
-  display: flex;
39
-  align-items: center;
40
-  gap: 8px;
41
-}
42
-
43
-.title-icon {
44
-  color: #3b82f6; /* 蓝色图标 */
45
-  font-size: 1.5rem;
46
-  width: 1.5rem;
47
-  height: 1.5rem;
48
-}
49
-
50
-.page-title {
51
-  margin: 0;
52
-  font-size: 1.25rem; /* text-xl */
53
-  font-weight: 600; /* font-semibold */
54
-  color: #1f2937; /* text-gray-800 */
55
-}
56
-
57
-/* 按钮区域 */
58
-.button-section {
59
-  display: flex;
60
-  gap: 8px;
61
-}
62
-
63
-/* 按钮基础样式 */
64
-.btn {
65
-  display: inline-flex;
66
-  align-items: center;
67
-  gap: 4px;
68
-  padding: 0.5rem 1rem; /* px-4 py-2 */
69
-  border: none;
70
-  border-radius: 0.375rem; /* rounded-md */
71
-  font-weight: 500;
72
-  cursor: pointer;
73
-  transition: background-color 0.2s;
74
-  outline: none;
75
-}
76
-
77
-.btn:disabled {
78
-  opacity: 0.5;
79
-  cursor: not-allowed;
80
-}
81
-
82
-/* 主要按钮 */
83
-.btn-primary {
84
-  background-color: #2563eb; /* bg-blue-600 */
85
-  color: white;
86
-}
87
-
88
-.btn-primary:hover:not(:disabled) {
89
-  background-color: #1d4ed8; /* hover:bg-blue-700 */
90
-}
91
-
92
-.btn-primary:focus {
93
-  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5); /* focus:ring-2 focus:ring-blue-500 */
94
-}
95
-
96
-/* 次要按钮 */
97
-.btn-secondary {
98
-  background-color: #e5e7eb; /* bg-gray-200 */
99
-  color: #1f2937; /* text-gray-800 */
100
-}
101
-
102
-.btn-secondary:hover:not(:disabled) {
103
-  background-color: #d1d5db; /* hover:bg-gray-300 */
104
-}
105
-
106
-.btn-secondary:focus {
107
-  box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.5); /* focus:ring-2 focus:ring-gray-500 */
108
-}
109
-
110
-/* 旋转加载指示器 */
111
-.spinner {
112
-  display: inline-block;
113
-  width: 1rem;
114
-  height: 1rem;
115
-  border: 2px solid currentColor;
116
-  border-radius: 50%;
117
-  border-top-color: transparent;
118
-  animation: spin 1s linear infinite;
119
-}
120
-
121
-@keyframes spin {
122
-  to { transform: rotate(360deg); }
123
-}
124
-
125
-/* ==================== 提示区域样式 ==================== */
126
-.page-hint .hint-section {
127
-  padding: 1rem; /* p-4 */
128
-  background-color: #eff6ff; /* bg-blue-50 */
129
-  border-bottom: 1px solid #dbeafe; /* border-blue-100 */
130
-}
131
-
132
-.hint-content {
133
-  font-size: 0.875rem; /* text-sm */
134
-  color: #1e40af; /* text-blue-800 */
135
-}
136
-
137
-.hint-content p {
138
-  margin: 0;
139
-  font-weight: 500; /* font-medium */
140
-}
141
-
142
-/* 调试信息区域 */
143
-.debug-section {
144
-  padding: 0.75rem; /* p-3 */
145
-  background-color: #fffbeb; /* bg-amber-50 */
146
-  border-bottom: 1px solid #fef3c7; /* border-amber-100 */
147
-  display: grid;
148
-  grid-template-columns: 1fr;
149
-  gap: 0.75rem; /* gap-3 */
150
-}
151
-
152
-@media (min-width: 768px) {
153
-  .debug-section {
154
-    grid-template-columns: repeat(3, 1fr); /* md:grid-cols-3 */
155
-  }
156
-}
157
-
158
-.debug-item {
159
-  font-size: 0.875rem; /* text-sm */
160
-  color: #92400e; /* text-amber-800 */
161
-}
162
-
163
-.debug-label {
164
-  font-weight: 500; /* font-medium */
165
-}
166
-
167
-.debug-value {
168
-  margin-left: 0.5rem; /* ml-2 */
169
-  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
170
-}
171
-
172 23
 /* ==================== 内容区域 ==================== */
173 24
 /* 内部滚动容器,确保 sticky header 能正确检测滚动 */
174
-/* 采用工作示例的精确配置 */
175 25
 .content-area {
176
-  flex: 1 1 0%; /* 工作示例使用的精确值 */
26
+  flex: 1 1 0%; /* 占据剩余空间 */
177 27
   overflow-y: auto !important; /* 确保优先级 */
178 28
   overflow-x: hidden; /* 防止水平滚动 */
179
-  padding: 16px;
180
-  background: white;
29
+  border: 0px solid #ddd;
30
+  background: rgb(247, 245, 245);
181 31
   min-height: 0; /* flex容器关键设置,防止内容溢出 */
182 32
   -webkit-overflow-scrolling: touch; /* 移动端平滑滚动 */
183 33
   position: relative; /* 创建新的堆叠上下文 */
184 34
 }
185 35
 
186
-/* Tabulator 表格样式 */
36
+/* ==================== Tabulator 表格样式 ==================== */
187 37
 #tabulator-table {
188 38
   border: 1px solid #ddd;
189 39
   border-radius: 4px;
@@ -191,12 +41,19 @@
191 41
   min-height: 600px; /* 确保有足够内容产生滚动 */
192 42
 }
193 43
 
194
-/* 旋转图标 - 用于刷新按钮加载状态 */
195
-.spin-icon {
196
-  animation: spin 1s linear infinite;
44
+/* ==================== 响应式调整 ==================== */
45
+@media (max-width: 768px) {
46
+  .content-area {
47
+    padding: 12px;
48
+  }
49
+  
50
+  #tabulator-table {
51
+    min-height: 400px;
52
+  }
197 53
 }
198 54
 
199
-@keyframes spin {
200
-  from { transform: rotate(0deg); }
201
-  to { transform: rotate(360deg); }
55
+@media (max-width: 480px) {
56
+  .content-area {
57
+    padding: 8px;
58
+  }
202 59
 }

+ 30
- 9
src/app/pages/service-register-config/service-register-config.component.ts View File

@@ -1,7 +1,7 @@
1 1
 
2 2
 import { Component, inject, ViewChild, OnInit, AfterViewInit } from '@angular/core';
3 3
 import { ConfigMetaService } from '../../services/config-meta.service';
4
-import { ConfigService, StickyHeaderComponent, TabulatorGridComponent } from 'base-core';
4
+import { ConfigService, StickyHeaderComponent, TabulatorGridComponent, StickyHeaderButton } from 'base-core';
5 5
 import { CommonModule } from '@angular/common';
6 6
 import { MatIconModule } from '@angular/material/icon';
7 7
 import { Observable } from 'rxjs';
@@ -34,9 +34,13 @@ export class ServiceRegisterConfigComponent implements OnInit, AfterViewInit {
34 34
   }
35 35
 
36 36
   title = '注册服务配置';
37
+  hintText = '1.点击"注册"按钮将同步所有配置元信息到数据库,并显示配置列表。\n 2.更多的状态处理(单行、空内容、折叠状态.\n 3.更多的交互细节(过渡效果优化'
38
+
39
+  headerButtons: StickyHeaderButton[] = [
40
+    { title: '注册', name: 'register', icon: 'add', color: 'primary', loading: false },
41
+    { title: '刷新', name: 'refresh', icon: 'refresh', color: 'accent', loading: false }
42
+  ];
37 43
   recordCount = 0; // 用于动态区域变量绑定
38
-  isRegistering = false;
39
-  isRefreshing = false;
40 44
   currentTime = new Date();
41 45
   
42 46
   // 外部查询条件预留字段(用于将来扩展)
@@ -149,18 +153,35 @@ export class ServiceRegisterConfigComponent implements OnInit, AfterViewInit {
149 153
      console.groupEnd();
150 154
      
151 155
      return this.configMetaService.listForTabulator(safeParams);
152
-   };
156
+    };
157
+
158
+  /**
159
+   * 处理头部按钮点击事件
160
+   */
161
+  onHeaderButtonAction(name: string): void {
162
+    console.log(`头部按钮点击: ${name}`);
163
+    switch (name) {
164
+      case 'register':
165
+        this.onRegister();
166
+        break;
167
+      case 'refresh':
168
+        this.refresh();
169
+        break;
170
+      default:
171
+        console.warn(`未知按钮操作: ${name}`);
172
+    }
173
+  }
153 174
 
154 175
   /**
155 176
    * 注册配置元信息
156 177
    */
157 178
   onRegister(): void {
158 179
     console.log('注册按钮被点击');
159
-    this.isRegistering = true;
180
+    this.headerButtons[0].loading = true;
160 181
 
161 182
     this.configMetaService.initConfigMeta().subscribe({
162 183
       next: (result: any) => {
163
-        this.isRegistering = false;
184
+        this.headerButtons[0].loading = false;
164 185
         if (result.success) {
165 186
           console.log('注册完成:', result.data);
166 187
           // 注册成功后刷新表格数据
@@ -171,7 +192,7 @@ export class ServiceRegisterConfigComponent implements OnInit, AfterViewInit {
171 192
         }
172 193
       },
173 194
       error: (error) => {
174
-        this.isRegistering = false;
195
+        this.headerButtons[0].loading = false;
175 196
         console.error('注册请求失败:', error);
176 197
       }
177 198
     });
@@ -184,11 +205,11 @@ export class ServiceRegisterConfigComponent implements OnInit, AfterViewInit {
184 205
    */
185 206
   refresh(): void {
186 207
     if (this.tabulatorGrid) {
187
-      this.isRefreshing = true;
208
+      this.headerButtons[1].loading = true;
188 209
       this.tabulatorGrid.refresh();
189 210
       // 简单延迟后清除loading状态
190 211
       setTimeout(() => {
191
-        this.isRefreshing = false;
212
+        this.headerButtons[1].loading = false;
192 213
       }, 500);
193 214
     }
194 215
   }

Loading…
Cancel
Save