正在显示
1 个修改的文件
包含
47 行增加
和
7 行删除
| @@ -109,7 +109,7 @@ class DocApe extends Ape { | @@ -109,7 +109,7 @@ class DocApe extends Ape { | ||
| 109 | let docDataModelPdu=this.packPdu(_docDataModel,_itemIdx); | 109 | let docDataModelPdu=this.packPdu(_docDataModel,_itemIdx); |
| 110 | let tableItemPdu = new pdu['RCRegistryTableItemPdu']; | 110 | let tableItemPdu = new pdu['RCRegistryTableItemPdu']; |
| 111 | tableItemPdu.itemIdx=_itemIdx;//直接用时间戳作为id | 111 | tableItemPdu.itemIdx=_itemIdx;//直接用时间戳作为id |
| 112 | - tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; | 112 | + //tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID;// tableItemPdu.registerObjId=ApeConsts.DOCSHARING_OBJ_TABLE_ID_H5; |
| 113 | tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 | 113 | tableItemPdu.owner = 0;//收到flash的是这个值,不清楚先写固定 |
| 114 | tableItemPdu.itemData =docDataModelPdu.toArrayBuffer(); | 114 | tableItemPdu.itemData =docDataModelPdu.toArrayBuffer(); |
| 115 | 115 | ||
| @@ -181,7 +181,27 @@ class DocApe extends Ape { | @@ -181,7 +181,27 @@ class DocApe extends Ape { | ||
| 181 | 181 | ||
| 182 | //切换文档 | 182 | //切换文档 |
| 183 | documentSwitchDoc(paramInfo){ | 183 | documentSwitchDoc(paramInfo){ |
| 184 | - //console.log(this.docList); | 184 | + if(paramInfo==null||paramInfo.itemIdx==null){ |
| 185 | + loger.warn('documentSwitch失败,参数错误',paramInfo); | ||
| 186 | + this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | ||
| 187 | + return; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + if(paramInfo.itemIdx==GlobalConfig.activeDocId&&GlobalConfig.activeDocId!=0){ | ||
| 191 | + loger.warn('文档已经显示',paramInfo.itemIdx,GlobalConfig.activeDocId); | ||
| 192 | + return; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + //更新切换之前的文档的数据,要显示当前切换的文档,上一个文档需要隐藏 | ||
| 196 | + let oldDocModel; | ||
| 197 | + if(GlobalConfig.activeDocId!=0){ | ||
| 198 | + oldDocModel=this.docList[GlobalConfig.activeDocId]; | ||
| 199 | + if(oldDocModel){ | ||
| 200 | + oldDocModel.action=ApeConsts.DOC_ACTION_NORMAL; | ||
| 201 | + oldDocModel.visible=false;//设置为不可见 | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + | ||
| 185 | //获取已经存在的数据 | 205 | //获取已经存在的数据 |
| 186 | let docDataModel= this.docList[paramInfo.itemIdx]; | 206 | let docDataModel= this.docList[paramInfo.itemIdx]; |
| 187 | if(docDataModel==null){ | 207 | if(docDataModel==null){ |
| @@ -189,12 +209,23 @@ class DocApe extends Ape { | @@ -189,12 +209,23 @@ class DocApe extends Ape { | ||
| 189 | this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); | 209 | this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_APE_INTERFACE_PARAM_WRONG); |
| 190 | return; | 210 | return; |
| 191 | } | 211 | } |
| 192 | - //更新数据的字段 | 212 | + |
| 213 | + //更新当前选择的文档数据的字段 | ||
| 193 | docDataModel.action=ApeConsts.DOC_ACTION_SWITCH_DOC; | 214 | docDataModel.action=ApeConsts.DOC_ACTION_SWITCH_DOC; |
| 194 | docDataModel.visible=paramInfo.visible||false;//默认是false | 215 | docDataModel.visible=paramInfo.visible||false;//默认是false |
| 216 | + | ||
| 217 | + loger.log('切换文档,当前文档和上一个显示的文档都需要更新状态'); | ||
| 218 | + console.log({"oldDoc":oldDocModel,"nowDoc":docDataModel}); | ||
| 219 | + //更新当前选择的文档 | ||
| 195 | this.updaterDoc(docDataModel,docDataModel.itemIdx); | 220 | this.updaterDoc(docDataModel,docDataModel.itemIdx); |
| 221 | + | ||
| 222 | + //更新上一个文档 隐藏 | ||
| 223 | + if(oldDocModel){ | ||
| 224 | + this.updaterDoc(oldDocModel,oldDocModel.itemIdx); | ||
| 225 | + } | ||
| 196 | } | 226 | } |
| 197 | 227 | ||
| 228 | + | ||
| 198 | //文档翻页 | 229 | //文档翻页 |
| 199 | documentSwitchPage(paramInfo){ | 230 | documentSwitchPage(paramInfo){ |
| 200 | //console.log(this.docList); | 231 | //console.log(this.docList); |
| @@ -277,10 +308,12 @@ class DocApe extends Ape { | @@ -277,10 +308,12 @@ class DocApe extends Ape { | ||
| 277 | let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); | 308 | let itemDataInfo = this.unPackPdu(owner, itemIdx, itemData); |
| 278 | this.docList[itemIdx] = itemDataInfo; | 309 | this.docList[itemIdx] = itemDataInfo; |
| 279 | 310 | ||
| 280 | - if(itemDataInfo.visible==="true"||itemDataInfo.visible===true){ | 311 | + if(itemDataInfo.visible=="true"||itemDataInfo.visible==true){ |
| 281 | GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | 312 | GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID |
| 282 | GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | 313 | GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 |
| 314 | + loger.log('tableInsertHandler 设置当前激活的文档id'); | ||
| 283 | } | 315 | } |
| 316 | + | ||
| 284 | loger.log('tableInsertHandler 发送给客户端'); | 317 | loger.log('tableInsertHandler 发送给客户端'); |
| 285 | console.log(itemDataInfo); | 318 | console.log(itemDataInfo); |
| 286 | this._emit(MessageTypes.DOC_UPDATE,itemDataInfo);//用添加和更新都统一DOC_UPDATE | 319 | this._emit(MessageTypes.DOC_UPDATE,itemDataInfo);//用添加和更新都统一DOC_UPDATE |
| @@ -299,6 +332,12 @@ class DocApe extends Ape { | @@ -299,6 +332,12 @@ class DocApe extends Ape { | ||
| 299 | if(this.docList[itemIdxs[i]]){ | 332 | if(this.docList[itemIdxs[i]]){ |
| 300 | loger.log("删除文档数据:",itemIdxs[i]); | 333 | loger.log("删除文档数据:",itemIdxs[i]); |
| 301 | this._emit(MessageTypes.DOC_DELETE,itemIdxs[i]); | 334 | this._emit(MessageTypes.DOC_DELETE,itemIdxs[i]); |
| 335 | + let itemDataInfo=this.docList[itemIdxs[i]]; | ||
| 336 | + if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 337 | + GlobalConfig.activeDocId=0;//当前激活的文档ID | ||
| 338 | + GlobalConfig.activeDocCurPage=1;//当前激活的文档的当前页 | ||
| 339 | + loger.log('tableDeleteHandler 设置当前激活的文档id'); | ||
| 340 | + } | ||
| 302 | delete this.docList[itemIdxs[i]]; | 341 | delete this.docList[itemIdxs[i]]; |
| 303 | } | 342 | } |
| 304 | } | 343 | } |
| @@ -320,11 +359,12 @@ class DocApe extends Ape { | @@ -320,11 +359,12 @@ class DocApe extends Ape { | ||
| 320 | default : | 359 | default : |
| 321 | break; | 360 | break; |
| 322 | }*/ | 361 | }*/ |
| 323 | - GlobalConfig.activeDocId=0;//默认id | ||
| 324 | - GlobalConfig.activeDocCurPage=1;//默认页数 | ||
| 325 | - if(itemDataInfo&&(itemDataInfo.visible==="true"||itemDataInfo.visible===true)){ | 362 | + //GlobalConfig.activeDocId=0;//默认id |
| 363 | + // GlobalConfig.activeDocCurPage=1;//默认页数 | ||
| 364 | + if(itemDataInfo&&(itemDataInfo.visible=="true"||itemDataInfo.visible==true)){ | ||
| 326 | GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID | 365 | GlobalConfig.activeDocId=itemDataInfo.itemIdx;//当前激活的文档ID |
| 327 | GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 | 366 | GlobalConfig.activeDocCurPage=itemDataInfo.curPageNo;//当前激活的文档的当前页 |
| 367 | + loger.log('tableUpdateHandler 设置当前激活的文档id'); | ||
| 328 | } | 368 | } |
| 329 | loger.log('tableUpdateHandler 发送给客户端'); | 369 | loger.log('tableUpdateHandler 发送给客户端'); |
| 330 | console.log(itemDataInfo); | 370 | console.log(itemDataInfo); |
-
请 注册 或 登录 后发表评论