mirror of
https://gitee.com/hoslay/ddei-editor.git
synced 2025-12-06 17:18:36 +08:00
将直接获取modeljson改为通过回调函数
This commit is contained in:
parent
aa802ad524
commit
66261878b6
12
package-lock.json
generated
12
package-lock.json
generated
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "ddei-editor",
|
"name": "ddei-editor",
|
||||||
"version": "1.2.41-121",
|
"version": "1.2.41-127",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ddei-editor",
|
"name": "ddei-editor",
|
||||||
"version": "1.2.41-121",
|
"version": "1.2.41-127",
|
||||||
"license": "Apache License 2.0",
|
"license": "Apache License 2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ddei-framework": "file:///Users/hoslay/work/ddei/ddei-framework/ddei-framework-1.2.41-121.tgz"
|
"ddei-framework": "file:///Users/hoslay/work/ddei/ddei-framework/ddei-framework-1.2.41-127.tgz"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node18": "^18.2.0",
|
"@tsconfig/node18": "^18.2.0",
|
||||||
@ -518,9 +518,9 @@
|
|||||||
"integrity": "sha512-tdMuLdcJyreope1BWfnYqTQaIkSIrU/KtY9yX5mNGd+tYeJ0Y99ARHDuYnEABPX/8yh/r0Kl169v5ODg2vr98g=="
|
"integrity": "sha512-tdMuLdcJyreope1BWfnYqTQaIkSIrU/KtY9yX5mNGd+tYeJ0Y99ARHDuYnEABPX/8yh/r0Kl169v5ODg2vr98g=="
|
||||||
},
|
},
|
||||||
"node_modules/ddei-framework": {
|
"node_modules/ddei-framework": {
|
||||||
"version": "1.2.41-121",
|
"version": "1.2.41-127",
|
||||||
"resolved": "file:../ddei-framework/ddei-framework-1.2.41-121.tgz",
|
"resolved": "file:../ddei-framework/ddei-framework-1.2.41-127.tgz",
|
||||||
"integrity": "sha512-M7/2QFzEjt1m4HUusaagSL17/G4UUT9ks75Cs4UXB5/SPls9xMqZCRu29Wb1kTQ4M9Z7xlO0ArcOju6dsvY/+w==",
|
"integrity": "sha512-SDIJ1vG6k1rTD1xXZI08zwbzgsnPB4JnMgUudT3chRTccxI9qsAhpgfUXuTazha1moYxB9VVAlJTirc56zo8lw==",
|
||||||
"license": "Apache License 2.0",
|
"license": "Apache License 2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ddei-autolink": "^1.1.1",
|
"ddei-autolink": "^1.1.1",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ddei-editor",
|
"name": "ddei-editor",
|
||||||
"version": "1.2.41-122",
|
"version": "1.2.41-128",
|
||||||
"private": false,
|
"private": false,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "hoslay <3697355039@qq.com>",
|
"author": "hoslay <3697355039@qq.com>",
|
||||||
@ -49,7 +49,7 @@
|
|||||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
|
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ddei-framework": "file:///Users/hoslay/work/ddei/ddei-framework/ddei-framework-1.2.41-121.tgz"
|
"ddei-framework": "file:///Users/hoslay/work/ddei/ddei-framework/ddei-framework-1.2.41-128.tgz"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/node18": "^18.2.0",
|
"@tsconfig/node18": "^18.2.0",
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import {DDeiEnumOperateType} from "ddei-framework";
|
|||||||
import {DDeiPolygon} from "ddei-framework";
|
import {DDeiPolygon} from "ddei-framework";
|
||||||
import {DDeiLink} from "ddei-framework";
|
import {DDeiLink} from "ddei-framework";
|
||||||
import {DDeiLineLink} from "ddei-framework";
|
import {DDeiLineLink} from "ddei-framework";
|
||||||
import {DDeiEditorState} from "ddei-framework";
|
import { DDeiEditorState, DDeiEditorUtil } from "ddei-framework";
|
||||||
/**
|
/**
|
||||||
* 键行为:粘贴
|
* 键行为:粘贴
|
||||||
* 粘贴剪切板内容
|
* 粘贴剪切板内容
|
||||||
@ -390,6 +390,11 @@ class DDeiKeyActionPaste extends DDeiKeyAction {
|
|||||||
DDeiUtil.convertChildrenJsonUnit(model, stage, unit);
|
DDeiUtil.convertChildrenJsonUnit(model, stage, unit);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//创建并初始化控件以及关系
|
||||||
|
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(stage.ddInstance, null, jsonArray)
|
||||||
|
if (!controlInitJSON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//当前选中控件是否为1且有表格,且选中表格的单元格,则作为表格单元格的内容粘贴
|
//当前选中控件是否为1且有表格,且选中表格的单元格,则作为表格单元格的内容粘贴
|
||||||
let createControl = true;
|
let createControl = true;
|
||||||
@ -400,7 +405,7 @@ class DDeiKeyActionPaste extends DDeiKeyAction {
|
|||||||
let cells = model.getSelectedCells();
|
let cells = model.getSelectedCells();
|
||||||
if (cells.length > 0) {
|
if (cells.length > 0) {
|
||||||
cells.forEach(cell => {
|
cells.forEach(cell => {
|
||||||
this.createControl(jsonArray, jsonLinkArray, offsetX, offsetY, stage, cell, mode, evt)
|
this.createControl(controlInitJSON, jsonLinkArray, offsetX, offsetY, stage, cell, mode, evt)
|
||||||
})
|
})
|
||||||
hasChange = true;
|
hasChange = true;
|
||||||
createControl = false
|
createControl = false
|
||||||
@ -408,14 +413,14 @@ class DDeiKeyActionPaste extends DDeiKeyAction {
|
|||||||
}
|
}
|
||||||
//添加到容器
|
//添加到容器
|
||||||
else if (model.baseModelType == 'DDeiContainer') {
|
else if (model.baseModelType == 'DDeiContainer') {
|
||||||
this.createControl(jsonArray, jsonLinkArray, offsetX, offsetY, stage, model, mode, evt)
|
this.createControl(controlInitJSON, jsonLinkArray, offsetX, offsetY, stage, model, mode, evt)
|
||||||
createControl = false
|
createControl = false
|
||||||
hasChange = true;
|
hasChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//如果没有粘贴到表格在最外层容器的鼠标位置,反序列化控件,重新设置ID,其他信息保留
|
//如果没有粘贴到表格在最外层容器的鼠标位置,反序列化控件,重新设置ID,其他信息保留
|
||||||
if (createControl) {
|
if (createControl) {
|
||||||
this.createControl(jsonArray, jsonLinkArray, offsetX, offsetY, stage, layer, mode, evt)
|
this.createControl(controlInitJSON, jsonLinkArray, offsetX, offsetY, stage, layer, mode, evt)
|
||||||
hasChange = true;
|
hasChange = true;
|
||||||
}
|
}
|
||||||
if (hasChange) {
|
if (hasChange) {
|
||||||
|
|||||||
@ -257,7 +257,11 @@ export default {
|
|||||||
if(control){
|
if(control){
|
||||||
if (editMode != 4){
|
if (editMode != 4){
|
||||||
//创建并初始化控件以及关系
|
//创建并初始化控件以及关系
|
||||||
let models = DDeiEditorUtil.createControl(control, this.editor)
|
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, null, [control])
|
||||||
|
if (!controlInitJSON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let models = DDeiEditorUtil.createControl(controlInitJSON[0], this.editor)
|
||||||
//加载事件的配置
|
//加载事件的配置
|
||||||
|
|
||||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
||||||
@ -458,7 +462,9 @@ export default {
|
|||||||
}
|
}
|
||||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { controls: [control] }, ddInstance, e)
|
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { controls: [control] }, ddInstance, e)
|
||||||
if (rsState == 0 || rsState == 1) {
|
if (rsState == 0 || rsState == 1) {
|
||||||
let models = this.editor.addControls([{model:control.id}])
|
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, null, [{ model: control.id }])
|
||||||
|
if (controlInitJSON){
|
||||||
|
let models = this.editor.addControls(controlInitJSON)
|
||||||
let pushDatas = []
|
let pushDatas = []
|
||||||
models.forEach((model, key) => {
|
models.forEach((model, key) => {
|
||||||
pushDatas.push({ id: model.id, value: DDeiEnumControlState.SELECTED });
|
pushDatas.push({ id: model.id, value: DDeiEnumControlState.SELECTED });
|
||||||
@ -469,6 +475,7 @@ export default {
|
|||||||
this.editor.bus.executeAll()
|
this.editor.bus.executeAll()
|
||||||
this.editor.changeState(DDeiEditorState.DESIGNING);
|
this.editor.changeState(DDeiEditorState.DESIGNING);
|
||||||
DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_AFTER", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_AFTER", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -331,9 +331,12 @@ export default {
|
|||||||
if ((layer.display == 0 && !layer.tempDisplay) || layer.lock) {
|
if ((layer.display == 0 && !layer.tempDisplay) || layer.lock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, null, [control])
|
||||||
|
if (!controlInitJSON) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//创建并初始化控件以及关系
|
//创建并初始化控件以及关系
|
||||||
let models = DDeiEditorUtil.createControl(control,this.editor)
|
let models = DDeiEditorUtil.createControl(controlInitJSON[0],this.editor)
|
||||||
//加载事件的配置
|
//加载事件的配置
|
||||||
|
|
||||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DDeiAbstractShape } from "ddei-framework";
|
import { DDeiAbstractShape } from "ddei-framework";
|
||||||
import { DDeiEditorUtil } from "ddei-framework";
|
import { DDeiEditorUtil } from "ddei-framework";
|
||||||
|
import { clone } from "lodash"
|
||||||
import DialogBase from "./dialog"
|
import DialogBase from "./dialog"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -143,11 +144,13 @@ export default {
|
|||||||
let type = this.editor.tempPopData['ddei-ext-dialog-quickchoosecontrol'].type
|
let type = this.editor.tempPopData['ddei-ext-dialog-quickchoosecontrol'].type
|
||||||
if (model){
|
if (model){
|
||||||
let outRect = DDeiAbstractShape.getOutRectByPV([model])
|
let outRect = DDeiAbstractShape.getOutRectByPV([model])
|
||||||
let controls = this.editor.addControls([
|
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, model, [
|
||||||
{
|
{
|
||||||
model: controlId
|
model: controlId
|
||||||
},
|
},
|
||||||
],true,false)
|
])
|
||||||
|
if (controlInitJSON){
|
||||||
|
let controls = this.editor.addControls(controlInitJSON,true,false)
|
||||||
//添加后的控件坐标,将其移动到特定位置
|
//添加后的控件坐标,将其移动到特定位置
|
||||||
let outRect1 = DDeiAbstractShape.getOutRectByPV(controls)
|
let outRect1 = DDeiAbstractShape.getOutRectByPV(controls)
|
||||||
let x,y,sx,sy,ex,ey
|
let x,y,sx,sy,ex,ey
|
||||||
@ -193,16 +196,30 @@ export default {
|
|||||||
}
|
}
|
||||||
controls[0].setPosition({x:x,y:y})
|
controls[0].setPosition({x:x,y:y})
|
||||||
//创建连线
|
//创建连线
|
||||||
let initLine = DDeiEditorUtil.getLineInitJSON()
|
let smodel ={ id: model.id, x: sx, y: sy, rate: 0.5, sita: startSita }
|
||||||
|
let emodel = { id: controls[0].id, x: ex, y: ey, rate: 0.5, sita: endSita }
|
||||||
|
let initLine = DDeiEditorUtil.getLineInitJSON(this.editor.ddInstance,smodel,emodel)
|
||||||
|
if (initLine){
|
||||||
|
let initJson = clone(initLine)
|
||||||
|
initJson.model = initLine.modelCode ? initLine.modelCode : initLine.model ? initLine.model : initLine.id ? initLine.id : '100401'
|
||||||
|
if (!initJson.type) {
|
||||||
|
initJson.type = 2
|
||||||
|
}
|
||||||
|
if (!initJson.startPoint) {
|
||||||
|
initJson.startPoint = { x: sx, y: sy }
|
||||||
|
}
|
||||||
|
if (!initJson.endPoint) {
|
||||||
|
initJson.endPoint = { x: ex, y: ey }
|
||||||
|
}
|
||||||
|
if (!initJson.smodel) {
|
||||||
|
initJson.smodel = smodel
|
||||||
|
}
|
||||||
|
if (!initJson.emodel) {
|
||||||
|
initJson.emodel = emodel
|
||||||
|
}
|
||||||
|
|
||||||
this.editor.addLines([
|
this.editor.addLines([
|
||||||
{
|
initJson
|
||||||
model: initLine.modelCode ? initLine.modelCode : initLine.model ? initLine.model : initLine.id ? initLine.id : '100401',
|
|
||||||
type:2,
|
|
||||||
startPoint: {x:sx,y:sy},
|
|
||||||
endPoint: {x:ex,y:ey},
|
|
||||||
smodel: { id: model.id,x:sx,y:sy ,rate:0.5,sita:startSita},
|
|
||||||
emodel:{id:controls[0].id,x:ex,y:ey,rate:0.5,sita:endSita}
|
|
||||||
},
|
|
||||||
],true,true,false)
|
],true,true,false)
|
||||||
this.editor.ddInstance.stage.makeSelectModels(controls);
|
this.editor.ddInstance.stage.makeSelectModels(controls);
|
||||||
this.editor.ddInstance.stage.notifyChange()
|
this.editor.ddInstance.stage.notifyChange()
|
||||||
@ -210,6 +227,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
import { DDeiEditor, DDeiEnumControlState, DDeiUtil } from "ddei-framework";
|
import { DDeiEditor, DDeiEnumControlState, DDeiUtil } from "ddei-framework";
|
||||||
import {DDeiEditorUtil} from "ddei-framework";
|
import {DDeiEditorUtil} from "ddei-framework";
|
||||||
import { DDeiAbstractShape } from "ddei-framework";
|
import { DDeiAbstractShape } from "ddei-framework";
|
||||||
import {DDeiEditorState} from "ddei-framework";
|
import { clone } from "lodash";
|
||||||
import { DDeiEnumBusCommandType } from "ddei-framework";
|
import { DDeiEnumBusCommandType } from "ddei-framework";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -243,17 +243,32 @@ export default {
|
|||||||
endSita = 0
|
endSita = 0
|
||||||
}
|
}
|
||||||
//创建连线
|
//创建连线
|
||||||
let initLine = DDeiEditorUtil.getLineInitJSON()
|
let smodel = { id: model.id, x: sx, y: sy, rate: 0.5, sita: startSita }
|
||||||
|
let emodel = { id: existsControl.id, x: ex, y: ey, rate: 0.5, sita: endSita }
|
||||||
|
let initLine = DDeiEditorUtil.getLineInitJSON(this.editor.ddInstance,smodel, emodel)
|
||||||
|
if (initLine){
|
||||||
|
let initJson = clone(initLine)
|
||||||
|
initJson.model = initLine.modelCode ? initLine.modelCode : initLine.model ? initLine.model : initLine.id ? initLine.id : '100401'
|
||||||
|
if (!initJson.type) {
|
||||||
|
initJson.type = 2
|
||||||
|
}
|
||||||
|
if (!initJson.dash) {
|
||||||
|
initJson.dash = [10, 5]
|
||||||
|
}
|
||||||
|
if (!initJson.startPoint) {
|
||||||
|
initJson.startPoint = { x: sx, y: sy }
|
||||||
|
}
|
||||||
|
if (!initJson.endPoint) {
|
||||||
|
initJson.endPoint = { x: ex, y: ey }
|
||||||
|
}
|
||||||
|
if (!initJson.smodel) {
|
||||||
|
initJson.smodel = smodel
|
||||||
|
}
|
||||||
|
if (!initJson.emodel) {
|
||||||
|
initJson.emodel = emodel
|
||||||
|
}
|
||||||
let lines = this.editor.addLines([
|
let lines = this.editor.addLines([
|
||||||
{
|
initJson
|
||||||
model: initLine.modelCode ? initLine.modelCode : initLine.model ? initLine.model : initLine.id ? initLine.id : '100401',
|
|
||||||
type: 2,
|
|
||||||
dash:[10,5],
|
|
||||||
startPoint: { x: sx, y: sy },
|
|
||||||
endPoint: { x: ex, y: ey },
|
|
||||||
smodel: { id: model.id, x: sx, y: sy, rate: 0.5, sita: startSita },
|
|
||||||
emodel: { id: existsControl.id, x: ex, y: ey, rate: 0.5, sita: endSita }
|
|
||||||
},
|
|
||||||
],true,true,false)
|
],true,true,false)
|
||||||
this.editor.tempLineModel = lines[0];
|
this.editor.tempLineModel = lines[0];
|
||||||
DDeiEditorUtil.closeDialog(this.editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
DDeiEditorUtil.closeDialog(this.editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
||||||
@ -262,6 +277,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createLineOk(){
|
createLineOk(){
|
||||||
|
|||||||
@ -198,7 +198,10 @@ export default {
|
|||||||
converters?.forEach(converter => {
|
converters?.forEach(converter => {
|
||||||
initData = converter.input(initData)
|
initData = converter.input(initData)
|
||||||
});
|
});
|
||||||
this.editor.addControls(initData.controls)
|
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, null, initData.controls)
|
||||||
|
if (controlInitJSON){
|
||||||
|
this.editor.addControls(controlInitJSON)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options?.config?.access){
|
if (options?.config?.access){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user