|
@@ -1,19 +1,19 @@
|
|
|
import { SGraphItem } from "./SGraphItem";
|
|
|
+import { SObject } from "@saga-web/base/lib";
|
|
|
+import { SGraphLayoutType } from "./enums/SGraphLayoutType";
|
|
|
|
|
|
|
|
|
* 基本选择器
|
|
|
*
|
|
|
* @author 郝建龙
|
|
|
*/
|
|
|
-export class SGraphSelectContainer {
|
|
|
+export class SGraphSelectContainer extends SObject {
|
|
|
|
|
|
private itemList: SGraphItem[] = [];
|
|
|
-
|
|
|
-
|
|
|
- * 构造函数
|
|
|
- *
|
|
|
- * */
|
|
|
- constructor() {}
|
|
|
+
|
|
|
+ get count(): number {
|
|
|
+ return this.itemList.length;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
* 添加item到list
|
|
@@ -21,13 +21,14 @@ export class SGraphSelectContainer {
|
|
|
* @param item 当前选中的item
|
|
|
* */
|
|
|
addItem(item: SGraphItem): void {
|
|
|
- for (let i = 0; i < this.itemList.length - 1; i++) {
|
|
|
+ for (let i = 0; i < this.itemList.length; i++) {
|
|
|
if (this.itemList[i] == item) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
item.selected = true;
|
|
|
this.itemList.push(item);
|
|
|
+ this.$emit("listChange", this.itemList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -36,12 +37,10 @@ export class SGraphSelectContainer {
|
|
|
* @param item 当前选中的item
|
|
|
* */
|
|
|
setItem(item: SGraphItem): void {
|
|
|
- for (let i = 0; i < this.itemList.length - 1; i++) {
|
|
|
- item.selected = false;
|
|
|
- }
|
|
|
- this.itemList.length = 0;
|
|
|
+ this.clear();
|
|
|
item.selected = true;
|
|
|
this.itemList.push(item);
|
|
|
+ this.$emit("listChange", this.itemList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -53,6 +52,7 @@ export class SGraphSelectContainer {
|
|
|
t.selected = false;
|
|
|
});
|
|
|
this.itemList.length = 0;
|
|
|
+ this.$emit("listChange", this.itemList);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -61,19 +61,22 @@ export class SGraphSelectContainer {
|
|
|
* @param item 当前选中的item
|
|
|
* */
|
|
|
toggleItem(item: SGraphItem): void {
|
|
|
- let index = -1;
|
|
|
- for (let i = 0; i < this.itemList.length - 1; i++) {
|
|
|
+ for (let i = 0; i < this.itemList.length; i++) {
|
|
|
if (this.itemList[i] == item) {
|
|
|
- index = i;
|
|
|
- item.selected = false;
|
|
|
- break;
|
|
|
+ this.itemList[i].selected = false;
|
|
|
+ this.itemList.splice(i, 1);
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
- if (index > -1) {
|
|
|
- this.itemList.splice(index, 1);
|
|
|
- } else {
|
|
|
- item.selected = true;
|
|
|
- this.itemList.push(item);
|
|
|
- }
|
|
|
+ item.selected = true;
|
|
|
+ this.itemList.push(item);
|
|
|
+ this.$emit("listChange", this.itemList);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ * 对齐
|
|
|
+ *
|
|
|
+ * @param type 对齐方式
|
|
|
+ * */
|
|
|
+ layout(type: SGraphLayoutType): void {}
|
|
|
}
|