@@ -121,7 +121,7 @@ export class M_calendar {
121
121
const msg = JSON . parse ( e . data ) ;
122
122
if ( msg . cmd === "transactions" ) {
123
123
// console.log(msg);
124
- if ( msg . data [ 0 ] . doOperations [ 0 ] . action === "updateAttrs" ) {
124
+ if ( msg . data [ 0 ] . doOperations [ 0 ] . action === "updateAttrs" ) {
125
125
console . log ( "updateAttrs" ) ;
126
126
this . avButton ( ) ;
127
127
}
@@ -174,11 +174,33 @@ export class M_calendar {
174
174
175
175
// 添加按钮点击事件
176
176
button . addEventListener ( 'click' , async ( ) => {
177
- steveTools . outlog ( '按钮被点击了' ) ;
177
+ console . log ( '按钮被点击了' ) ;
178
+ // Find the closest element with the specified classes
179
+ let dataId = '' ;
180
+ const avBlocks = document . querySelectorAll ( 'div.item.item--focus[data-id]' ) ;
181
+ if ( avBlocks . length > 0 ) {
182
+ // Get the closest AV block relative to the button
183
+ let closestBlock = avBlocks [ 0 ] ;
184
+ let minDistance = Infinity ;
185
+
186
+ avBlocks . forEach ( block => {
187
+ const rect = block . getBoundingClientRect ( ) ;
188
+ const distance = Math . abs ( rect . top - button . getBoundingClientRect ( ) . top ) ;
189
+ if ( distance < minDistance ) {
190
+ minDistance = distance ;
191
+ closestBlock = block ;
192
+ }
193
+ } ) ;
194
+
195
+ dataId = closestBlock . getAttribute ( 'data-id' ) ;
196
+ console . log ( 'data-id:' , dataId ) ;
197
+ steveTools . outlog ( 'Selected AV block ID:' , dataId ) ;
198
+ }
199
+
178
200
if ( front == "browser-mobile" || front == "mobile" ) {
179
- await this . openRiChengViewDialog ( true ) ;
201
+ await this . openRiChengViewDialog ( true , dataId ) ;
180
202
} else {
181
- await this . openRiChengViewDialog ( ) ;
203
+ await this . openRiChengViewDialog ( false , dataId ) ;
182
204
}
183
205
} ) ;
184
206
// 将按钮插入到目标 <span> 元素的右边
@@ -188,7 +210,7 @@ export class M_calendar {
188
210
} , 500 ) ; // 延迟 500 毫秒
189
211
}
190
212
191
- async openRiChengViewDialog ( isMobile : boolean = false ) {
213
+ async openRiChengViewDialog ( isMobile : boolean = false , viewID = "" ) {
192
214
193
215
const id = new Date ( ) . getTime ( ) . toString ( ) ;
194
216
let calendar : any ;
@@ -205,7 +227,7 @@ export class M_calendar {
205
227
} ) ;
206
228
207
229
setTimeout ( async ( ) => {
208
- calendar = await run ( id ) ;
230
+ calendar = await run ( id , 'dayGridMonth' , viewID ) ;
209
231
} , 100 ) ;
210
232
}
211
233
0 commit comments