|
|
|
@ -17,18 +17,111 @@ export class examinationQuestions {
|
|
|
|
|
constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, |
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data) {} |
|
|
|
|
|
|
|
|
|
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; |
|
|
|
|
|
|
|
|
|
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
|
|
|
|
|
defaultExpandedKeys = []; //展开指定的树节点 key值
|
|
|
|
|
defaultSelectedKeys = []; //指定选中的树节点 key值
|
|
|
|
|
renderData:any |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
console.log(this.data.treeData) |
|
|
|
|
this.renderData = this.data.treeData |
|
|
|
|
if(JSON.parse(sessionStorage.getItem('tree型数据')) && JSON.parse(sessionStorage.getItem('tree型数据'))[this.data.buildFloorData.floorData.id]){ |
|
|
|
|
console.log(123,JSON.parse(sessionStorage.getItem('tree型数据'))[this.data.buildFloorData.floorData.id]) |
|
|
|
|
this.defaultCheckedKeys = JSON.parse(sessionStorage.getItem('tree型数据'))[this.data.buildFloorData.floorData.id] |
|
|
|
|
} |
|
|
|
|
this.data.treeData.forEach(element => { |
|
|
|
|
if(element.isTemplate){ |
|
|
|
|
element.isLeaf = false |
|
|
|
|
}else{ |
|
|
|
|
element.isLeaf = true |
|
|
|
|
} |
|
|
|
|
if(element.children && element.children.length != 0){ |
|
|
|
|
element.children.forEach(ele => { |
|
|
|
|
if(ele.isTemplate){ |
|
|
|
|
ele.isLeaf = false |
|
|
|
|
}else{ |
|
|
|
|
ele.isLeaf = true |
|
|
|
|
} |
|
|
|
|
if(ele.children && ele.children.length != 0){ |
|
|
|
|
ele.children.forEach(item => { |
|
|
|
|
if(item.isTemplate){ |
|
|
|
|
item.isLeaf = false |
|
|
|
|
}else{ |
|
|
|
|
item.isLeaf = true |
|
|
|
|
} |
|
|
|
|
nzEvent($event){ |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
nzEvent($event){ |
|
|
|
|
console.log($event) |
|
|
|
|
} |
|
|
|
|
//提交
|
|
|
|
|
submit () { |
|
|
|
|
console.log(this.data) |
|
|
|
|
|
|
|
|
|
let oldTreeData = this.nzTreeComponent.getCheckedNodeList() |
|
|
|
|
|
|
|
|
|
let alltreedata = JSON.parse(sessionStorage.getItem("tree型数据"))
|
|
|
|
|
let keyArr = [] |
|
|
|
|
oldTreeData.forEach(element => { |
|
|
|
|
keyArr.push(element.origin.key) |
|
|
|
|
}) |
|
|
|
|
if(alltreedata){ |
|
|
|
|
//如果已经保存过当前楼层则替换
|
|
|
|
|
alltreedata[this.data.buildFloorData.floorData.id] = keyArr |
|
|
|
|
sessionStorage.setItem('tree型数据',JSON.stringify(alltreedata)) |
|
|
|
|
}else{ |
|
|
|
|
alltreedata = {}
|
|
|
|
|
alltreedata[this.data.buildFloorData.floorData.id] = keyArr |
|
|
|
|
sessionStorage.setItem('tree型数据',JSON.stringify(alltreedata)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let checkList = [] //只存真实素材
|
|
|
|
|
for (const key in this.data.oldRealData.data) { |
|
|
|
|
let element = this.data.oldRealData.data[key] |
|
|
|
|
let isChecked = (this.nzTreeComponent.getTreeNodeByKey(key)).isChecked |
|
|
|
|
isChecked? checkList.push(element) : null |
|
|
|
|
} |
|
|
|
|
//存储真实素材数据
|
|
|
|
|
|
|
|
|
|
let obj = { |
|
|
|
|
name:this.data.buildFloorData.buildingData.name + '-' + this.data.buildFloorData.floorData.name, |
|
|
|
|
key:this.data.buildFloorData.floorData.id, |
|
|
|
|
children:checkList |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let data = JSON.parse(sessionStorage.getItem("试卷id"))
|
|
|
|
|
|
|
|
|
|
if(data && data.length != 0){ |
|
|
|
|
let ind = null |
|
|
|
|
data.forEach((item,index) => { |
|
|
|
|
if(item.key == obj.key){ |
|
|
|
|
ind = index |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if(ind){ |
|
|
|
|
if(checkList.length != 0){ |
|
|
|
|
data[ind].children = checkList |
|
|
|
|
}else{ |
|
|
|
|
data.splice(ind,1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
data.push(obj) |
|
|
|
|
} |
|
|
|
|
sessionStorage.setItem("试卷id",JSON.stringify(data)) |
|
|
|
|
}else{ |
|
|
|
|
data = [] |
|
|
|
|
data[0] = obj |
|
|
|
|
console.log(123,data) |
|
|
|
|
sessionStorage.setItem("试卷id",JSON.stringify(data)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -42,30 +135,23 @@ export class uploadQuestions {
|
|
|
|
|
|
|
|
|
|
constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>, |
|
|
|
|
@Inject(MAT_DIALOG_DATA) public data) {} |
|
|
|
|
// tree配置
|
|
|
|
|
private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数
|
|
|
|
|
return { |
|
|
|
|
expandable: !!node.children && node.children.length > 0, |
|
|
|
|
name: node.name || node.Name, |
|
|
|
|
level: level, |
|
|
|
|
id: node.id || node.Id, |
|
|
|
|
children:node.children, |
|
|
|
|
isTemplate:node.isTemplate, |
|
|
|
|
isNewElement:node.isNewElement, |
|
|
|
|
isLook:node.isLook, |
|
|
|
|
isLookPattern:node.isLookPattern || null |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); |
|
|
|
|
treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); |
|
|
|
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); |
|
|
|
|
hasChild = (_: number, node: any) => node.expandable; |
|
|
|
|
|
|
|
|
|
defaultCheckedKeys = []; //指定选中复选框的树节点 key值
|
|
|
|
|
defaultExpandedKeys = []; //展开指定的树节点 key值
|
|
|
|
|
defaultSelectedKeys = []; //指定选中的树节点 key值
|
|
|
|
|
renderData:any |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.dataSource.data = this.data.treeData |
|
|
|
|
this.treeControl.expandAll() |
|
|
|
|
let data = JSON.parse(sessionStorage.getItem("试卷id")) |
|
|
|
|
data.forEach(item => { |
|
|
|
|
item.children.forEach(i => { |
|
|
|
|
i.isLeaf = true |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
this.renderData = data |
|
|
|
|
} |
|
|
|
|
nzEvent($event){ |
|
|
|
|
console.log($event) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//上传
|
|
|
|
|
submit () { |
|
|
|
|
console.log(this.data.question) |
|
|
|
|