Browse Source

预案模板

dev
刘向辉 3 years ago
parent
commit
98964a07de
  1. 5
      src/app/babylon/controller/serve-manager.ts
  2. 17
      src/app/babylon/model/data/mark/mark-plan-data.ts
  3. 18
      src/app/babylon/view/mark-window/mark-window.ts
  4. 11
      src/app/service/babylon/building-basic-infos.service.ts

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

@ -170,7 +170,7 @@ export class ServeManager {
.subscribe(data => {
console.log("得到所有模板", data);
if (onSuccess) {
onSuccess(JSON.parse((data as any).items));
onSuccess((data as any).result.items);
}
}, error => {
console.error("From serve:AllMarkTemplate", error);
@ -188,7 +188,8 @@ export class ServeManager {
subscribe(data => {
console.log("得到单个模板" + id, data);
if (onSuccess) {
// onSuccess( JSON.parse((data as any).result));
onSuccess(JSON.parse((data as any).result.value));
}
}, error => {
console.error("From serve:OneMarkTemplate", error);

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

@ -1,4 +1,4 @@
import { Type } from "class-transformer";
import { classToClass, Type } from "class-transformer";
import { TsTool } from "src/app/babylon/tool/ts-tool";
@ -27,8 +27,6 @@ export class AllMarkPlanData {
datas: MarkPlanData[];
/**
*
* @param name
@ -40,6 +38,19 @@ export class AllMarkPlanData {
return data;
}
/**
*
* @param template
*/
createPlanDataByTemplate(template: MarkPlanData): MarkPlanData {
let id = this.getNextPlaneId();
let data = classToClass<MarkPlanData>(template);
data.id = id;
this.datas.push(data);
return data;
}
/**
*
*/

18
src/app/babylon/view/mark-window/mark-window.ts

@ -1,7 +1,7 @@
import { AbstractMesh, Vector3 } from "@babylonjs/core";
import { PointerEventTypes, PointerInfo } from "@babylonjs/core/Events/pointerEvents";
import { EventState, Observer } from "@babylonjs/core/Misc/observable";
import { classToClass } from "class-transformer";
import { classToClass, plainToClass } from "class-transformer";
import { PlanComponent } from "src/app/pages/plan/plan.component";
import { DataManager } from "../../controller/data-manager";
import { EventManager } from "../../controller/event-manager/event-manager";
@ -1597,24 +1597,26 @@ export class MarkWindow extends UIBase {
getAllSandBoxTemplate() {
let instance = this;
this.allSandBoxTemplate = [];
ServeManager.instance.getAllMarkTemplate((data: string) => {
ServeManager.instance.getAllMarkTemplate((data: any) => {
if (data == null) {
instance.allSandBoxTemplate = [];
}
else {
console.log("getAllSandBoxTemplate", data);
instance.allSandBoxTemplate = data;
}
});
}
/**
*
*
* @param id
*/
getOneSandBoxTemplate(id: number) {
addMarkPlanByTemplate(id: number) {
let instance = this;
ServeManager.instance.getOneMarkTemplate(id, (data: string) => {
ServeManager.instance.getOneMarkTemplate(id, (data: any) => {
let value = plainToClass(MarkPlanData, data);
instance.allMarkPlanData.createPlanDataByTemplate(value);
})
}
@ -1627,7 +1629,7 @@ export class MarkWindow extends UIBase {
*/
saveToSandBoxTemplate(data: MarkPlanData) {
let name: string = data.name;
let id: number = new Date().getTime();
let id: number = Math.ceil(new Date().getTime() * 0.001);
let instance = this;
ServeManager.instance.saveOneMarkTemplate(id, name, data, (data: string) => {

11
src/app/service/babylon/building-basic-infos.service.ts

@ -32,12 +32,12 @@ export class BuildingBasicInfosService {
/**
*
*/
readonly api_sandBoxTemplate = "api/Services/3D/SandboxTemplate";
readonly api_sandBoxTemplate = "api/Services/3D/SandboxTemplate";
/**
*
*/
readonly api_sandBoxTemplateGetAll = "api/Services/3D/SandboxTemplate/GetAll";
readonly api_sandBoxTemplateGetAll = "api/Services/3D/SandboxTemplate/GetAll";
@ -111,7 +111,7 @@ export class BuildingBasicInfosService {
* @param data
*/
postSandBoxTemplate(name: string, id: number, data: object) {
return this.postInfos(this.api_sandBoxTemplate, data, { name: name, "Id": id });
return this.postInfos(this.api_sandBoxTemplate, data, { name: name, "id": id });
}
@ -156,7 +156,10 @@ export class BuildingBasicInfosService {
let headers = this.headers;
return this.http.post<any>(api + this.c_post, `'${JSON.stringify(body)}'`, { headers, params })
let l_body = `'${JSON.stringify(body)}'`;
console.log("postInfos", l_body, api);
return this.http.post<any>(api + this.c_post, l_body, { headers, params })
.pipe(
catchError((err) => this.handleError(err))
);

Loading…
Cancel
Save