From 2c6b55c775d097da4f05f0813b23e299eeede3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=B4=E8=B5=9B=E9=9B=B7?= Date: Thu, 23 May 2024 17:23:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91bug?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../panels/openfilesview/OpenFilesView.vue | 129 ++++++++++-------- .../core/panels/propertyview/PropertyView.vue | 12 ++ src/App.vue | 2 +- 3 files changed, 88 insertions(+), 55 deletions(-) diff --git a/plugins/core/panels/openfilesview/OpenFilesView.vue b/plugins/core/panels/openfilesview/OpenFilesView.vue index d198234..455ae85 100644 --- a/plugins/core/panels/openfilesview/OpenFilesView.vue +++ b/plugins/core/panels/openfilesview/OpenFilesView.vue @@ -93,6 +93,10 @@ export default { max:{ type: Number, default: 0 + }, + beforeCloseFile:{ + type: Function, + default: null } , editor: { type: DDeiEditor, @@ -105,7 +109,7 @@ export default { openIndex: 0, //最大可以打开的数量 maxOpenSize: 1, - tempFile: null, + // tempFile: null, unitFileWidth: 160, // user: null, forceRefresh:true @@ -123,8 +127,6 @@ export default { for (let i = 0; i < this.editor.files.length; i++) { if (this.editor.files[i].active == DDeiActiveType.ACTIVE) { activeIndex = i; - // this.applyFilePromise(this.editor.files[i]) - this.editor.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts, { parts: ["toolbox", "property"] }); @@ -227,6 +229,7 @@ export default { this.editor.addFile(file); this.editor.currentFileIndex = this.editor.files.length - 1; let sheets = file?.sheets; + if (file && sheets && ddInstance) { let stage = sheets[0].stage; stage.ddInstance = ddInstance; @@ -254,6 +257,11 @@ export default { this.editor.changeState(DDeiEditorState.DESIGNING); ddInstance?.bus?.executeAll(); } + if (this.editor.files.length == 0) { + ddInstance.disabled = true + } else { + ddInstance.disabled = false + } } }, @@ -486,66 +494,78 @@ export default { ddInstance.bus.push(DDeiEditorEnumBusCommandType.RefreshEditorParts, {}); ddInstance.bus.executeAll(); } - - }, - - - /** - * 放弃并关闭确认弹框 - */ - abortAndCloseFileConfirmDialog() { - this.tempFile.state = DDeiFileState.NONE; - this.closeFile(this.tempFile); - }, - - /** - * 保存 - * @param evt - */ - saveAndCloseFileConfirmDialog() { - if (this.tempFile) { - //获取json信息 - let file = this.tempFile; - if (file) { - let json = file.toJSON(); - if (json) { - - //执行保存 - let storeIns = new DDeiStoreLocal(); - json.state = DDeiFileState.NONE; - storeIns.save(file.id, json).then((data) => { - //回写ID - file.id = data; - file.state = DDeiFileState.NONE; - this.closeFile(this.tempFile); - }); - } - } + if (this.editor.files.length == 0) { + ddInstance.disabled = true + } else { + ddInstance.disabled = false } + }, + + // /** + // * 放弃并关闭确认弹框 + // */ + // abortAndCloseFileConfirmDialog() { + // this.tempFile.state = DDeiFileState.NONE; + // this.closeFile(this.tempFile); + // }, + + // /** + // * 保存 + // * @param evt + // */ + // saveAndCloseFileConfirmDialog() { + // if (this.tempFile) { + // //获取json信息 + // let file = this.tempFile; + // if (file) { + // let json = file.toJSON(); + // if (json) { + + // //执行保存 + // let storeIns = new DDeiStoreLocal(); + // json.state = DDeiFileState.NONE; + // storeIns.save(file.id, json).then((data) => { + // //回写ID + // file.id = data; + // file.state = DDeiFileState.NONE; + // this.closeFile(this.tempFile); + // }); + // } + // } + // } + // }, + /** * 关闭文件 * @param instance */ closeFile(file, evt) { //如果文件为脏状态,询问是否保存,放弃,或取消 - if ( - file.state == DDeiFileState.NEW || - file.state == DDeiFileState.MODIFY - ) { - DDeiEditorUtil.showDialog(this.editor, "ddei-core-dialog-closefile", { - msg: '是否保存对"' + file.name + '"的更改?', - callback: { - abort: this.abortAndCloseFileConfirmDialog, - ok: this.saveAndCloseFileConfirmDialog, - }, - background: "white", - opacity: "1%", - event: -1 - }) - this.tempFile = file; - } else { + let canClose = true; + if (this.beforeCloseFile){ + canClose = this.beforeCloseFile(file) + } + if(canClose){ + + + // if ( + // file.state == DDeiFileState.NEW || + // file.state == DDeiFileState.MODIFY + // ) { + // DDeiEditorUtil.showDialog(this.editor, "ddei-core-dialog-closefile", { + // msg: '是否保存对"' + file.name + '"的更改?', + // callback: { + // abort: this.abortAndCloseFileConfirmDialog, + // ok: this.saveAndCloseFileConfirmDialog, + // }, + // background: "white", + // opacity: "1%", + // event: -1 + // }) + // this.tempFile = file; + // } else { //刷新画布 let index = this.editor.files.indexOf(file); this.editor.removeFile(file); @@ -571,6 +591,7 @@ export default { } } } + // } }, /** * 在存在显示隐藏的情况下移动tab diff --git a/plugins/core/panels/propertyview/PropertyView.vue b/plugins/core/panels/propertyview/PropertyView.vue index e346b5a..1ee0fd2 100644 --- a/plugins/core/panels/propertyview/PropertyView.vue +++ b/plugins/core/panels/propertyview/PropertyView.vue @@ -179,10 +179,21 @@ export default { firstControlDefine = this.editor.currentControlDefine } } + //获取第一个组件及其定义 if (firstControlDefine) { let topGroups = null; if (firstControlDefine.type == "DDeiStage") { + firstControlDefine.attrDefineMap.forEach((attrDefine, attrKey) => { + //当前属性的定义 + + attrDefine.value = DDeiUtil.getDataByPathList( + firstModel, + attrDefine.code, + attrDefine.mapping + ); + attrDefine.model = firstModel; + }); //加载layer的配置 let layerControlDefine = cloneDeep( this.editor.controls.get("DDeiLayer") @@ -190,6 +201,7 @@ export default { let layer = firstModel.layers[firstModel.layerIndex]; layerControlDefine.attrDefineMap.forEach((attrDefine, attrKey) => { //当前属性的定义 + attrDefine.value = DDeiUtil.getDataByPathList( layer, attrDefine.code, diff --git a/src/App.vue b/src/App.vue index 5ab4747..770c81f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,7 +34,7 @@ export default defineComponent({ }) const options1 = markRaw({ config: { - "readonly":true, + // "readonly":true, "mark": "水印文本", "grid": 2, "paper": {type:"A6",direct:1},