Change object id type
This commit is contained in:
parent
8e3330b398
commit
97202fe976
@ -28,8 +28,8 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
* 下一个需要分配的 ID
|
* 下一个需要分配的 ID
|
||||||
*/
|
*/
|
||||||
private idIndex: number = 1;
|
private idIndex: number = 1;
|
||||||
public get nextId(): number {
|
public nextId(label: string = "U"): string {
|
||||||
return this.idIndex ++;
|
return `${label}-${this.idIndex ++}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +55,7 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
*/
|
*/
|
||||||
public addLabel(name: string): Label {
|
public addLabel(name: string): Label {
|
||||||
console.log(`Model: Creat label with id ${this.idIndex}`);
|
console.log(`Model: Creat label with id ${this.idIndex}`);
|
||||||
let label = new Label(this, this.nextId, name);
|
let label = new Label(this, this.nextId("L"), name);
|
||||||
this.labelPool.push(label);
|
this.labelPool.push(label);
|
||||||
this.emit("labelAdd", label);
|
this.emit("labelAdd", label);
|
||||||
this.emit("labelChange", this.labelPool);
|
this.emit("labelChange", this.labelPool);
|
||||||
@ -95,7 +95,7 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
*/
|
*/
|
||||||
public addGroup(): Group {
|
public addGroup(): Group {
|
||||||
console.log(`Model: Creat group with id ${this.idIndex}`);
|
console.log(`Model: Creat group with id ${this.idIndex}`);
|
||||||
let group = new Group(this, this.nextId);
|
let group = new Group(this, this.nextId("G"));
|
||||||
this.objectPool.push(group);
|
this.objectPool.push(group);
|
||||||
this.emit("groupAdd", group);
|
this.emit("groupAdd", group);
|
||||||
this.emit("objectAdd", group);
|
this.emit("objectAdd", group);
|
||||||
@ -108,7 +108,7 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
*/
|
*/
|
||||||
public addRange(): Range {
|
public addRange(): Range {
|
||||||
console.log(`Model: Creat range with id ${this.idIndex}`);
|
console.log(`Model: Creat range with id ${this.idIndex}`);
|
||||||
let range = new Range(this, this.nextId);
|
let range = new Range(this, this.nextId("R"));
|
||||||
this.objectPool.push(range);
|
this.objectPool.push(range);
|
||||||
this.emit("rangeAdd", range);
|
this.emit("rangeAdd", range);
|
||||||
this.emit("objectAdd", range);
|
this.emit("objectAdd", range);
|
||||||
|
@ -35,7 +35,7 @@ interface ICommonParam {
|
|||||||
/**
|
/**
|
||||||
* 对象标识符
|
* 对象标识符
|
||||||
*/
|
*/
|
||||||
type ObjectID = Symbol | string | number;
|
type ObjectID = string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接收的数据类型
|
* 接收的数据类型
|
||||||
|
@ -113,7 +113,7 @@ class RangeDetails extends Component<IMixinStatusProps> {
|
|||||||
if (this.props.status.focusObject.size > 1) {
|
if (this.props.status.focusObject.size > 1) {
|
||||||
return <ErrorMessage i18nKey="Common.Attr.Key.Error.Multiple"/>;
|
return <ErrorMessage i18nKey="Common.Attr.Key.Error.Multiple"/>;
|
||||||
}
|
}
|
||||||
let id: ObjectID = 0;
|
let id: ObjectID = "";
|
||||||
this.props.status.focusObject.forEach((cid => id = cid));
|
this.props.status.focusObject.forEach((cid => id = cid));
|
||||||
|
|
||||||
let range = this.props.status!.model.getObjectById(id);
|
let range = this.props.status!.model.getObjectById(id);
|
||||||
|
Loading…
Reference in New Issue
Block a user