邵佳豪 4 years ago
parent
commit
da34ad1027
  1. 53
      src/app/working-area/working-area.component.ts

53
src/app/working-area/working-area.component.ts

@ -257,6 +257,57 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
this.backgroundImage.addChild(enterPaintEndButton);
enterPaintEndButton.zIndex = this.backgroundImage.children.length;
}
/**
* json的key值进行大小写转换
* @param json json对象
* @param type ==>;1 ==>;2 ==>
*/
jsonKeysToCase(json, type) {
if (typeof json === 'object') {
const tempJson = JSON.parse(JSON.stringify(json));
toCase(tempJson);
return tempJson;
} else {
return json;
}
// tslint:disable-next-line: no-shadowed-variable
function toCase(json) {
// tslint:disable-next-line: triple-equals
if (typeof json == 'object') {
if (Array.isArray(json)) {
// tslint:disable-next-line: only-arrow-functions
json.forEach(function(item) {
toCase(item);
});
} else {
// tslint:disable-next-line: forin
for (const key in json) {
const item = json[key];
// tslint:disable-next-line: triple-equals
if (typeof item == 'object') {
toCase(item);
}
delete (json[key]);
switch (type) {
case 1:
// key值全部大写
json[key.toLocaleUpperCase()] = item;
break;
case 2:
// key值首字母大写,其余小写
json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item;
break;
default:
// 默认key值全部小写
json[key.toLocaleLowerCase()] = item;
break;
}
}
}
}
}
}
/**
*
*/
@ -306,7 +357,7 @@ export class WorkingAreaComponent extends EventEmitter implements OnInit, AfterV
MultiPoint : null,
Point: new PIXI.Point(this.previewSinglePointIcon.x, this.previewSinglePointIcon.y),
Name : this.canvasData.selectTemplateData.name,
PropertyInfos: JSON.parse(JSON.stringify(this.canvasData.selectTemplateData.propertyInfos)),
PropertyInfos: this.jsonKeysToCase(this.canvasData.selectTemplateData.propertyInfos, 2),
Border : this.canvasData.selectTemplateData.border,
DrawMode : this.canvasData.selectTemplateData.drawMode,
Thickness : this.canvasData.selectTemplateData.thickness,

Loading…
Cancel
Save