mirror of
https://gitee.com/hoslay/ddei-editor.git
synced 2025-12-07 01:28:28 +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",
|
||||
"version": "1.2.41-121",
|
||||
"version": "1.2.41-127",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ddei-editor",
|
||||
"version": "1.2.41-121",
|
||||
"version": "1.2.41-127",
|
||||
"license": "Apache License 2.0",
|
||||
"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": {
|
||||
"@tsconfig/node18": "^18.2.0",
|
||||
@ -518,9 +518,9 @@
|
||||
"integrity": "sha512-tdMuLdcJyreope1BWfnYqTQaIkSIrU/KtY9yX5mNGd+tYeJ0Y99ARHDuYnEABPX/8yh/r0Kl169v5ODg2vr98g=="
|
||||
},
|
||||
"node_modules/ddei-framework": {
|
||||
"version": "1.2.41-121",
|
||||
"resolved": "file:../ddei-framework/ddei-framework-1.2.41-121.tgz",
|
||||
"integrity": "sha512-M7/2QFzEjt1m4HUusaagSL17/G4UUT9ks75Cs4UXB5/SPls9xMqZCRu29Wb1kTQ4M9Z7xlO0ArcOju6dsvY/+w==",
|
||||
"version": "1.2.41-127",
|
||||
"resolved": "file:../ddei-framework/ddei-framework-1.2.41-127.tgz",
|
||||
"integrity": "sha512-SDIJ1vG6k1rTD1xXZI08zwbzgsnPB4JnMgUudT3chRTccxI9qsAhpgfUXuTazha1moYxB9VVAlJTirc56zo8lw==",
|
||||
"license": "Apache License 2.0",
|
||||
"dependencies": {
|
||||
"ddei-autolink": "^1.1.1",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ddei-editor",
|
||||
"version": "1.2.41-122",
|
||||
"version": "1.2.41-128",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"author": "hoslay <3697355039@qq.com>",
|
||||
@ -49,7 +49,7 @@
|
||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false"
|
||||
},
|
||||
"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": {
|
||||
"@tsconfig/node18": "^18.2.0",
|
||||
|
||||
@ -12,7 +12,7 @@ import {DDeiEnumOperateType} from "ddei-framework";
|
||||
import {DDeiPolygon} from "ddei-framework";
|
||||
import {DDeiLink} 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);
|
||||
});
|
||||
}
|
||||
//创建并初始化控件以及关系
|
||||
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(stage.ddInstance, null, jsonArray)
|
||||
if (!controlInitJSON) {
|
||||
return;
|
||||
}
|
||||
|
||||
//当前选中控件是否为1且有表格,且选中表格的单元格,则作为表格单元格的内容粘贴
|
||||
let createControl = true;
|
||||
@ -400,7 +405,7 @@ class DDeiKeyActionPaste extends DDeiKeyAction {
|
||||
let cells = model.getSelectedCells();
|
||||
if (cells.length > 0) {
|
||||
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;
|
||||
createControl = false
|
||||
@ -408,14 +413,14 @@ class DDeiKeyActionPaste extends DDeiKeyAction {
|
||||
}
|
||||
//添加到容器
|
||||
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
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
//如果没有粘贴到表格在最外层容器的鼠标位置,反序列化控件,重新设置ID,其他信息保留
|
||||
if (createControl) {
|
||||
this.createControl(jsonArray, jsonLinkArray, offsetX, offsetY, stage, layer, mode, evt)
|
||||
this.createControl(controlInitJSON, jsonLinkArray, offsetX, offsetY, stage, layer, mode, evt)
|
||||
hasChange = true;
|
||||
}
|
||||
if (hasChange) {
|
||||
|
||||
@ -257,7 +257,11 @@ export default {
|
||||
if(control){
|
||||
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)
|
||||
@ -458,17 +462,20 @@ export default {
|
||||
}
|
||||
let rsState = DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_BEFORE", DDeiEnumOperateType.CREATE, { controls: [control] }, ddInstance, e)
|
||||
if (rsState == 0 || rsState == 1) {
|
||||
let models = this.editor.addControls([{model:control.id}])
|
||||
let pushDatas = []
|
||||
models.forEach((model, key) => {
|
||||
pushDatas.push({ id: model.id, value: DDeiEnumControlState.SELECTED });
|
||||
});
|
||||
this.editor.ddInstance?.bus?.push(DDeiEnumBusCommandType.CancelCurLevelSelectedModels, null, e);
|
||||
this.editor.ddInstance?.bus?.push(DDeiEnumBusCommandType.ModelChangeSelect, pushDatas, e);
|
||||
this.editor.ddInstance?.bus?.push(DDeiEnumBusCommandType.StageChangeSelectModels);
|
||||
this.editor.bus.executeAll()
|
||||
this.editor.changeState(DDeiEditorState.DESIGNING);
|
||||
DDeiUtil.invokeCallbackFunc("EVENT_CONTROL_CREATE_AFTER", DDeiEnumOperateType.CREATE, { models: models }, ddInstance, e)
|
||||
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, null, [{ model: control.id }])
|
||||
if (controlInitJSON){
|
||||
let models = this.editor.addControls(controlInitJSON)
|
||||
let pushDatas = []
|
||||
models.forEach((model, key) => {
|
||||
pushDatas.push({ id: model.id, value: DDeiEnumControlState.SELECTED });
|
||||
});
|
||||
this.editor.ddInstance?.bus?.push(DDeiEnumBusCommandType.CancelCurLevelSelectedModels, null, e);
|
||||
this.editor.ddInstance?.bus?.push(DDeiEnumBusCommandType.ModelChangeSelect, pushDatas, e);
|
||||
this.editor.ddInstance?.bus?.push(DDeiEnumBusCommandType.StageChangeSelectModels);
|
||||
this.editor.bus.executeAll()
|
||||
this.editor.changeState(DDeiEditorState.DESIGNING);
|
||||
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) {
|
||||
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)
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
<script lang="ts">
|
||||
import { DDeiAbstractShape } from "ddei-framework";
|
||||
import { DDeiEditorUtil } from "ddei-framework";
|
||||
import { clone } from "lodash"
|
||||
import DialogBase from "./dialog"
|
||||
|
||||
export default {
|
||||
@ -143,69 +144,87 @@ export default {
|
||||
let type = this.editor.tempPopData['ddei-ext-dialog-quickchoosecontrol'].type
|
||||
if (model){
|
||||
let outRect = DDeiAbstractShape.getOutRectByPV([model])
|
||||
let controls = this.editor.addControls([
|
||||
let controlInitJSON = DDeiEditorUtil.getModelInitJSON(this.editor.ddInstance, model, [
|
||||
{
|
||||
model: controlId
|
||||
},
|
||||
],true,false)
|
||||
//添加后的控件坐标,将其移动到特定位置
|
||||
let outRect1 = DDeiAbstractShape.getOutRectByPV(controls)
|
||||
let x,y,sx,sy,ex,ey
|
||||
let startSita, endSita
|
||||
let weight = 60
|
||||
//创建控件
|
||||
if(type == 1){
|
||||
x = (outRect.x+outRect.x1)/2
|
||||
y = outRect.y - weight - outRect1.height / 2
|
||||
sx = x
|
||||
sy = outRect.y
|
||||
ex = x
|
||||
ey = y + outRect1.height / 2
|
||||
startSita = -90
|
||||
endSita = 90
|
||||
} else if (type == 2) {
|
||||
x = outRect.x1 + weight + outRect1.width/2,
|
||||
y =(outRect.y1 + outRect.y) / 2
|
||||
sx = outRect.x1
|
||||
sy = y
|
||||
ex = x - outRect1.width / 2
|
||||
ey = y
|
||||
startSita = 0
|
||||
endSita = 180
|
||||
} else if (type == 3) {
|
||||
x = (outRect.x + outRect.x1) / 2,
|
||||
y = outRect.y1 + weight + outRect1.height / 2
|
||||
sx = x
|
||||
sy = outRect.y1
|
||||
ex = x
|
||||
ey = y - outRect1.height / 2
|
||||
startSita = 90
|
||||
endSita = -90
|
||||
} else if (type == 4) {
|
||||
x = outRect.x - weight -outRect1.width/2
|
||||
y = (outRect.y1 + outRect.y) / 2
|
||||
sx = outRect.x
|
||||
sy = y
|
||||
ex = x+outRect1.width / 2
|
||||
ey = y
|
||||
startSita = 180
|
||||
endSita = 0
|
||||
])
|
||||
if (controlInitJSON){
|
||||
let controls = this.editor.addControls(controlInitJSON,true,false)
|
||||
//添加后的控件坐标,将其移动到特定位置
|
||||
let outRect1 = DDeiAbstractShape.getOutRectByPV(controls)
|
||||
let x,y,sx,sy,ex,ey
|
||||
let startSita, endSita
|
||||
let weight = 60
|
||||
//创建控件
|
||||
if(type == 1){
|
||||
x = (outRect.x+outRect.x1)/2
|
||||
y = outRect.y - weight - outRect1.height / 2
|
||||
sx = x
|
||||
sy = outRect.y
|
||||
ex = x
|
||||
ey = y + outRect1.height / 2
|
||||
startSita = -90
|
||||
endSita = 90
|
||||
} else if (type == 2) {
|
||||
x = outRect.x1 + weight + outRect1.width/2,
|
||||
y =(outRect.y1 + outRect.y) / 2
|
||||
sx = outRect.x1
|
||||
sy = y
|
||||
ex = x - outRect1.width / 2
|
||||
ey = y
|
||||
startSita = 0
|
||||
endSita = 180
|
||||
} else if (type == 3) {
|
||||
x = (outRect.x + outRect.x1) / 2,
|
||||
y = outRect.y1 + weight + outRect1.height / 2
|
||||
sx = x
|
||||
sy = outRect.y1
|
||||
ex = x
|
||||
ey = y - outRect1.height / 2
|
||||
startSita = 90
|
||||
endSita = -90
|
||||
} else if (type == 4) {
|
||||
x = outRect.x - weight -outRect1.width/2
|
||||
y = (outRect.y1 + outRect.y) / 2
|
||||
sx = outRect.x
|
||||
sy = y
|
||||
ex = x+outRect1.width / 2
|
||||
ey = y
|
||||
startSita = 180
|
||||
endSita = 0
|
||||
}
|
||||
controls[0].setPosition({x:x,y:y})
|
||||
//创建连线
|
||||
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([
|
||||
initJson
|
||||
],true,true,false)
|
||||
this.editor.ddInstance.stage.makeSelectModels(controls);
|
||||
this.editor.ddInstance.stage.notifyChange()
|
||||
}
|
||||
}
|
||||
controls[0].setPosition({x:x,y:y})
|
||||
//创建连线
|
||||
let initLine = DDeiEditorUtil.getLineInitJSON()
|
||||
this.editor.addLines([
|
||||
{
|
||||
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)
|
||||
this.editor.ddInstance.stage.makeSelectModels(controls);
|
||||
this.editor.ddInstance.stage.notifyChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
import { DDeiEditor, DDeiEnumControlState, DDeiUtil } from "ddei-framework";
|
||||
import {DDeiEditorUtil} from "ddei-framework";
|
||||
import { DDeiAbstractShape } from "ddei-framework";
|
||||
import {DDeiEditorState} from "ddei-framework";
|
||||
import { clone } from "lodash";
|
||||
import { DDeiEnumBusCommandType } from "ddei-framework";
|
||||
|
||||
export default {
|
||||
@ -243,22 +243,38 @@ export default {
|
||||
endSita = 0
|
||||
}
|
||||
//创建连线
|
||||
let initLine = DDeiEditorUtil.getLineInitJSON()
|
||||
let lines = this.editor.addLines([
|
||||
{
|
||||
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)
|
||||
this.editor.tempLineModel = lines[0];
|
||||
DDeiEditorUtil.closeDialog(this.editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
||||
this.editor.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||
this.editor.bus.executeAll();
|
||||
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([
|
||||
initJson
|
||||
],true,true,false)
|
||||
this.editor.tempLineModel = lines[0];
|
||||
DDeiEditorUtil.closeDialog(this.editor, 'ddei-ext-dialog-quickchoosecontrol', true)
|
||||
this.editor.bus.push(DDeiEnumBusCommandType.RefreshShape);
|
||||
this.editor.bus.executeAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,10 @@ export default {
|
||||
converters?.forEach(converter => {
|
||||
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){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user