邵佳豪 3 years ago
parent
commit
531951a406
  1. 6
      src/app/babylon/controller/serve-manager.ts
  2. 36
      src/app/babylon/controller/status/login-status.ts
  3. 1
      src/app/babylon/model/data/institution/institution-data-simple.ts
  4. 15
      src/app/babylon/model/data/mark/mark-plan-data.ts
  5. 12
      src/app/babylon/model/info/mark/mark-plan-info.ts
  6. 2
      src/app/babylon/view/institution/institution-create-window.ts
  7. 2
      src/app/babylon/view/toolbar-window/toobar-window.ts
  8. 55
      src/app/pages/plan/plan.component.ts
  9. 5
      yarn.lock

6
src/app/babylon/controller/serve-manager.ts

@ -47,13 +47,13 @@ export class ServeManager {
}
//保存单位信息
saveInstitutionData(institutionData: any, key: string = 'test', onSuccess?: (key: string,
saveInstitutionData(institutionData: any, key: string = 'test', institutionID: number = 1, onSuccess?: (key: string,
result: string
) => void, onError?: (key: string, error: string) => void) {
let l_data = classToPlain(institutionData);
console.log("保存单位", l_data);
this.buildingBISrv.postBuildingBasicInfos(key, 1, l_data)
this.buildingBISrv.postBuildingBasicInfos(key, institutionID, l_data)
.subscribe(data => {
console.log("保存单位成功:" + key, l_data);
if (onSuccess) {
@ -73,7 +73,7 @@ export class ServeManager {
saveInstitutionListData(institutionList: InsitutionDataSimple[], onSucess?: () => void) {
// console.log("======保存单位");
ServeManager.instance.saveInstitutionData(institutionList, "InsList", () => {
ServeManager.instance.saveInstitutionData(institutionList, "InsList", -1, () => {
//alert("保存单位列表成功");
if (onSucess) {
onSucess();

36
src/app/babylon/controller/status/login-status.ts

@ -23,7 +23,7 @@ export class LoginSatus extends StatusBase {
institutionCreateWindow: InstitutionCreateWindow;
institutionList: InsitutionDataSimple[];//单位简易信息列表
institutionList: InsitutionDataSimple[] = [];//单位简易信息列表
//#region 前端对接
@ -32,7 +32,7 @@ export class LoginSatus extends StatusBase {
*
* @param insData
*/
createInsitution(key: string, name: string, onSuccess?: (insDataSimple: InsitutionDataSimple) => void) {
createInsitution(key: string, name: string, id: number, onSuccess?: (insDataSimple: InsitutionDataSimple) => void) {
if (key == null) {
console.error("创建单位key为null");
@ -42,7 +42,7 @@ export class LoginSatus extends StatusBase {
let insData = new InstitutionData();
insData.normalData = new NormalData(key, name);
this.saveNewIns(this, insData, key, onSuccess);
this.saveNewIns(this, insData, key, id, onSuccess);
}
//#endregion
@ -71,15 +71,15 @@ export class LoginSatus extends StatusBase {
console.error("获取单位列表失败");
console.log(error);
if (error instanceof HttpErrorResponse && error.status === 404) {
let isAdd = confirm('数据库为空,是否进行初始化?')
if (isAdd) {
//数据库没有数据,新建
this.institutionList = [];
if (onSuccess) {
onSuccess(this.institutionList, this.institutionList);
let isAdd = confirm('数据库为空,是否进行初始化?')
if (isAdd) {
//数据库没有数据,新建
this.institutionList = [];
if (onSuccess) {
onSuccess(this.institutionList, this.institutionList);
}
console.log("新建数据列表");
}
console.log("新建数据列表");
}
}
else {
console.log("单纯报错", error instanceof HttpErrorResponse, error.status === 404)
@ -194,10 +194,12 @@ export class LoginSatus extends StatusBase {
let status = this;
ServeManager.instance.saveInstitutionListData(this.institutionList, () => {
//进入新单位
status.onSelectInsSuccess(insData);
});
//不再自己存列表
// ServeManager.instance.saveInstitutionListData(this.institutionList, () => {
// //进入新单位
// status.onSelectInsSuccess(insData);
// });
status.onSelectInsSuccess(insData);
}
//#endregion
@ -225,9 +227,9 @@ export class LoginSatus extends StatusBase {
//保存新单位信息至服务器
saveNewIns(status: LoginSatus, insData: InstitutionData, key: string, onSuccess?: (insDataSimple: InsitutionDataSimple) => void) {
saveNewIns(status: LoginSatus, insData: InstitutionData, key: string, id: number, onSuccess?: (insDataSimple: InsitutionDataSimple) => void) {
console.log("准备保存新单位");
ServeManager.instance.saveInstitutionData(insData, key, (key, result) => {
ServeManager.instance.saveInstitutionData(insData, key, id, (key, result) => {
console.log("在服务器新建单位" + key);
let insDataSimple = new InsitutionDataSimple();
insDataSimple.key = key;

1
src/app/babylon/model/data/institution/institution-data-simple.ts

@ -2,4 +2,5 @@
export class InsitutionDataSimple {
key: string;//唯一身份key
name: string;//自定义的名称
id: number;//保存时要用到,前后端需要,必须是number
}

15
src/app/babylon/model/data/mark/mark-plan-data.ts

@ -351,6 +351,21 @@ export class MarkNodeData {
return newEnvironment;
}
/**
*
*/
getShowTime() {
let textNum = 0;
if (this.describe != null) {
textNum = this.describe.length;
}
let timeScale = 1;
return textNum * timeScale;
}
}
/**

12
src/app/babylon/model/info/mark/mark-plan-info.ts

@ -99,19 +99,7 @@ export class MarkNodeInfo {
return this.currentMarkDataIndex;
}
/**
*
*/
getShowTime() {
let textNum = 0;
if (this.nodeData.describe != null) {
textNum = this.nodeData.describe.length;
}
let timeScale = 1;
return textNum * timeScale;
}
/**
*

2
src/app/babylon/view/institution/institution-create-window.ts

@ -68,7 +68,7 @@ export class InstitutionCreateWindow extends UIBase {
saveNewIns() {
let window = this;
let loginStatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
loginStatus.saveNewIns(loginStatus, window.insData, window.insDataSimple.key, (insDataSimple) => {
loginStatus.saveNewIns(loginStatus, window.insData, window.insDataSimple.key, window.insDataSimple.id, (insDataSimple) => {
loginStatus.closeCreateWindow();
});
}

2
src/app/babylon/view/toolbar-window/toobar-window.ts

@ -49,7 +49,7 @@ export class ToolbarWindow extends UIBase {
onBtnSave() {
let data = DataManager.institutionData;
ModeManager.log(data);
ServeManager.instance.saveInstitutionData(data, DataManager.institutionData_simple.key, () => {
ServeManager.instance.saveInstitutionData(data, DataManager.institutionData_simple.key, DataManager.institutionData_simple.id, () => {
ModeManager.log("保存成功" + DataManager.institutionData_simple.key);
});
}

55
src/app/pages/plan/plan.component.ts

@ -69,32 +69,41 @@ export class PlanComponent implements OnInit {
}
ngAfterViewInit(): void {
let simpleData: InsitutionDataSimple = new InsitutionDataSimple();
simpleData.id = 1;
simpleData.key = "ceshi";
simpleData.name = "测试";
let loginStatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
loginStatus.getInstitutionListFromServe((result: InsitutionDataSimple[], data: any) => {
if (ModeManager.institutionDemoKey == ModeManager.c_demoKey_null) { //无指定测试单位,则为正式启动,根据当前单位key寻找
let key = 'ceshi';
let find = data.find(item => { return item.key === key })
if (find) { //如果在data中找到了对应的单位key,则表示已经有三维数据,直接进入
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
this.beforeOneSatus.onSelectInsSuccess(find)
} else { //如果没有找到对应的单位key,则调用新建单位
let isAdd = confirm('没有单位' + key + ',是否进行初始化?')
if (isAdd) {
let name = key;
loginStatus.createInsitution(key, name);
}
//loginStatus.getInstitutionListFromServe((result: InsitutionDataSimple[], data: any) => {
if (ModeManager.institutionDemoKey == ModeManager.c_demoKey_null) { //无指定测试单位,则为正式启动,根据当前单位key寻找
let key = 'ceshi';
//let find = data.find(item => { return item.key === key })
let find = simpleData;
if (find) { //如果在data中找到了对应的单位key,则表示已经有三维数据,直接进入
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
this.beforeOneSatus.onSelectInsSuccess(find)
} else { //如果没有找到对应的单位key,则调用新建单位
let isAdd = confirm('没有单位' + key + ',是否进行初始化?')
if (isAdd) {
let name = key;
let id = 2;// 单位id
loginStatus.createInsitution(key, name, id);
}
}
} else {
//let find = data.find(item => { return item.key === ModeManager.institutionDemoKey })
let find = simpleData; //测试单位
if (find) {
sessionStorage.setItem('unitId', find.key)
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
this.beforeOneSatus.onSelectInsSuccess(find)
} else {
let find = data.find(item => { return item.key === ModeManager.institutionDemoKey })
if (find) {
sessionStorage.setItem('unitId', find.key)
this.beforeOneSatus = StatusManager.getStatus<LoginSatus>(LoginSatus);
this.beforeOneSatus.onSelectInsSuccess(find)
} else {
this.modelInit(data) //开发模式 选择单位 弹窗
}
//this.modelInit(data) //开发模式 选择单位 弹窗
}
});
}
//});
}
ngOnDestroy(): void { //组件销毁前 销毁canvas
@ -310,7 +319,7 @@ export class PlanComponent implements OnInit {
selectProperty(e: FacilityInfoUIItem) {
this.isShowNature = true
this.beforeOnePropertyData = e
console.log(e.getPropertyData(),'选中设备')
console.log(e.getPropertyData(), '选中设备')
if (this.isShowChildComponent && this.leftDomain) {
this.leftDomain.selectFacilityId = e.getID()
}

5
yarn.lock

@ -6889,6 +6889,11 @@ jest-worker@^25.1.0:
merge-stream "^2.0.0"
supports-color "^7.0.0"
js-base64@^3.7.2:
version "3.7.2"
resolved "https://registry.npmmirror.com/js-base64/download/js-base64-3.7.2.tgz?cache=0&sync_timestamp=1632308301843&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fjs-base64%2Fdownload%2Fjs-base64-3.7.2.tgz#816d11d81a8aff241603d19ce5761e13e41d7745"
integrity sha1-gW0R2BqK/yQWA9Gc5XYeE+Qdd0U=
js-levenshtein@^1.1.3:
version "1.1.6"
resolved "https://registry.npm.taobao.org/js-levenshtein/download/js-levenshtein-1.1.6.tgz#c6cee58eb3550372df8deb85fad5ce66ce01d59d"

Loading…
Cancel
Save