|
|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
import { ControlComponent, ControlType } from '../../../dataset/enum/Control'
|
|
|
|
|
import { ElementType } from '../../../dataset/enum/Element'
|
|
|
|
|
import { IControlInitOption, IControlInstance, IControlOption } from '../../../interface/Control'
|
|
|
|
|
import { IControl, IControlInitOption, IControlInstance, IControlOption } from '../../../interface/Control'
|
|
|
|
|
import { IElement, IElementPosition } from '../../../interface/Element'
|
|
|
|
|
import { deepClone } from '../../../utils'
|
|
|
|
|
import { pickElementAttr, zipElementList } from '../../../utils/element'
|
|
|
|
|
import { Listener } from '../../listener/Listener'
|
|
|
|
|
import { RangeManager } from '../../range/RangeManager'
|
|
|
|
|
import { Draw } from '../Draw'
|
|
|
|
|
import { SelectControl } from './select/SelectControl'
|
|
|
|
|
@ -15,12 +18,14 @@ export class Control {
|
|
|
|
|
|
|
|
|
|
private draw: Draw
|
|
|
|
|
private range: RangeManager
|
|
|
|
|
private listener: Listener
|
|
|
|
|
private options: IControlOption
|
|
|
|
|
private activeControl: IControlInstance | null
|
|
|
|
|
|
|
|
|
|
constructor(draw: Draw) {
|
|
|
|
|
this.draw = draw
|
|
|
|
|
this.range = draw.getRange()
|
|
|
|
|
this.listener = draw.getListener()
|
|
|
|
|
this.options = draw.getOptions().control
|
|
|
|
|
this.activeControl = null
|
|
|
|
|
}
|
|
|
|
|
@ -97,6 +102,19 @@ export class Control {
|
|
|
|
|
this.activeControl = selectControl
|
|
|
|
|
selectControl.awake()
|
|
|
|
|
}
|
|
|
|
|
// 激活控件回调
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (this.listener.controlChange) {
|
|
|
|
|
let payload: IControl
|
|
|
|
|
const value = this.activeControl?.getValue()
|
|
|
|
|
if (value && value.length) {
|
|
|
|
|
payload = zipElementList(value)[0].control!
|
|
|
|
|
} else {
|
|
|
|
|
payload = pickElementAttr(deepClone(element)).control!
|
|
|
|
|
}
|
|
|
|
|
this.listener.controlChange(payload)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public destroyControl() {
|
|
|
|
|
@ -105,6 +123,12 @@ export class Control {
|
|
|
|
|
this.activeControl.destroy()
|
|
|
|
|
}
|
|
|
|
|
this.activeControl = null
|
|
|
|
|
// 销毁控件回调
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (this.listener.controlChange) {
|
|
|
|
|
this.listener.controlChange(null)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|