From bdabd5f13cc925d029805257bc11c9c53a6af461 Mon Sep 17 00:00:00 2001
From: SHAOJIAHAO <55341701@qq.com>
Date: Tue, 22 Dec 2020 14:41:39 +0800
Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E5=AE=8C=E6=88=90=E4=BF=9D?=
=?UTF-8?q?=E5=AD=98=E8=AF=95=E5=8D=B7=EF=BC=88=E6=8F=90=E4=BA=A4=E9=A2=84?=
=?UTF-8?q?=E6=A1=88=E5=88=86=E6=95=B0=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../create-test-score.component.html | 6 +-
.../create-test-score.component.ts | 285 +++++++++++++++---
.../examiner-index.component.ts | 3 +-
.../collection-tools/examinationQuestions.ts | 20 +-
4 files changed, 250 insertions(+), 64 deletions(-)
diff --git a/src/app/examiner/create-test-score/create-test-score.component.html b/src/app/examiner/create-test-score/create-test-score.component.html
index d747395..e694bb2 100644
--- a/src/app/examiner/create-test-score/create-test-score.component.html
+++ b/src/app/examiner/create-test-score/create-test-score.component.html
@@ -279,13 +279,13 @@
- {{item.name}} |
+ {{item.title}} |
{{item.creatorName}} |
{{item.modifiedTime | date:'yyyy-MM-dd'}} |
- {{item.openRange}} |
+ {{item.isPublic ? '已公开' : '未公开'}} |
{{item.planLevel | planlevel}} |
-
+
|
编辑
diff --git a/src/app/examiner/create-test-score/create-test-score.component.ts b/src/app/examiner/create-test-score/create-test-score.component.ts
index 49fe135..54b1ef1 100644
--- a/src/app/examiner/create-test-score/create-test-score.component.ts
+++ b/src/app/examiner/create-test-score/create-test-score.component.ts
@@ -9,7 +9,9 @@ import { DisabledTimeFn, DisabledTimePartial } from 'ng-zorro-antd/date-picker';
import getISOWeek from 'date-fns/getISOWeek';
import setHours from 'date-fns/setHours';
import { NzFormatEmitEvent, NzTreeComponent } from 'ng-zorro-antd/tree';
-import { Router } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
+import { async } from '@angular/core/testing';
+import { functions } from 'firebase';
@Component({
selector: 'app-create-test-score',
templateUrl: './create-test-score.component.html',
@@ -17,7 +19,7 @@ import { Router } from '@angular/router';
})
export class CreateTestScoreComponent implements OnInit {
- constructor(private router:Router,public dialog: MatDialog,private http: HttpClient,public snackBar: MatSnackBar) { }
+ constructor(private router:Router,public dialog: MatDialog,private http: HttpClient,public snackBar: MatSnackBar,private route:ActivatedRoute) { }
selectedTab:number = 1 //选中的选项卡
selectTab(index){
setTimeout(() => {
@@ -25,7 +27,7 @@ export class CreateTestScoreComponent implements OnInit {
}, 0);
}
- ngOnInit(): void {
+ async ngOnInit(): Promise {
for (let y = 0, length = this.unitId.length; y < length; y++){
let element = this.unitId[y]
element.score = 0
@@ -45,6 +47,7 @@ export class CreateTestScoreComponent implements OnInit {
element.fireFacItemScore = 0
element.fireFacNodes = []
}
+
this.getUnitData().then(()=>{
this.getAround().then(()=>{
this.getKeySite().then(()=>{
@@ -54,7 +57,34 @@ export class CreateTestScoreComponent implements OnInit {
})
})
})
+
+ this.getPaperPlans().then(()=>{
+ this.planItemScore()
+ })
}
+
+ //获取所有考试设定
+ async getPaperPlans(){
+
+ for (let y = 0, length = this.unitId.length; y < length; y++){
+ let element = this.unitId[y]
+ await new Promise((resolve,reject)=>{
+ this.http.get('/api/PaperPlans',{params:{
+ paperId : sessionStorage.getItem('paperId'),
+ companyId : element.id
+ }}).subscribe(data => {
+ console.log('当前试卷的预案列表',data)
+ element.planList = data
+ resolve(1)
+ })
+ })
+
+ }
+
+
+ }
+
+
//当前选中的单位
selectedUnitIndex = 0
clickUnitName(key){
@@ -314,14 +344,14 @@ export class CreateTestScoreComponent implements OnInit {
let result1 = await new Promise((resolve, reject) => {
this.http.get('/api/CompanyImportantLocations',{params:id}).subscribe((data:any)=>{
- //如果存在单位毗邻
+ //如果存在单位重点部位
let newData = []
data.forEach(item => {
item.isLeaf = true
item.key = item.id
item.name ? newData.push(item) : null
})
- if(data.length != 0){
+ if(newData.length != 0){
this.unitId[y].keySiteNodes.push({
name: '单位重点部位',
key: (Math.random()*10000000).toString(16).substr(0,4)+(new Date()).getTime()+Math.random().toString().substr(2,5),
@@ -347,7 +377,7 @@ export class CreateTestScoreComponent implements OnInit {
})
-
+ console.log(element)
//获取当前单位所有建筑重点部位
@@ -592,7 +622,7 @@ export class CreateTestScoreComponent implements OnInit {
//tree的选择事件
nzEvent(event: NzFormatEmitEvent,key): void {
-
+
if(event.node.origin.type == '基本信息' || (event.node.parentNode && event.node.parentNode.origin.type == '基本信息')){
let selectedNum = []
@@ -696,6 +726,7 @@ export class CreateTestScoreComponent implements OnInit {
}
}
if(type == '重点部位'){
+ console.log('重点部位')
let selectedNum = 0
this.unitId[key].keySiteNodes.forEach(item => {
item.children.forEach(i => {
@@ -721,7 +752,7 @@ export class CreateTestScoreComponent implements OnInit {
this.unitId[key].funDivItemScore = 0
}
}
- if(type == '消防设施'){
+ if(type == '数据核验'){
let selectedNum = 0
this.unitId[key].fireFacNodes.forEach(item => {
item.children.forEach(i => {
@@ -762,9 +793,8 @@ export class CreateTestScoreComponent implements OnInit {
}
//每条预案分数增加在试卷分数
- planItemScore(item){
+ planItemScore(){
//计算整个试卷的总分
- console.log(item)
let examScore = 0
this.unitId.forEach(element => {
examScore += element.score
@@ -792,18 +822,87 @@ export class CreateTestScoreComponent implements OnInit {
//删除每条预案试卷
deletePlan(item){
- this.unitId[this.selectedUnitIndex].planList.forEach((element,key)=>{
- if(item == element){
- this.unitId[this.selectedUnitIndex].planList.splice(key,1)
- }
- })
- const config = new MatSnackBarConfig();
- config.verticalPosition = 'top';
- config.duration = 3000
- this.snackBar.open('删除成功','确定',config);
+ if(window.confirm('你确定要删除该预案设定吗?')){
+ this.http.delete(`/api/PaperPlans/${item.id}`).subscribe(data => {
+ const config = new MatSnackBarConfig();
+ config.verticalPosition = 'top';
+ config.duration = 3000
+ this.snackBar.open('删除成功','确定',config);
+ this.unitId[this.selectedUnitIndex].planList.forEach((element,key)=>{
+ if(item == element){
+ this.unitId[this.selectedUnitIndex].planList.splice(key,1)
+ }
+ })
+ this.planItemScore()
+ })
+ }else{
+
+
+ }
+
+ console.log(item)
+
}
//保存
save(){
+ this.unitId.forEach(item => {
+ //建筑的基本信息选中key集合
+ item.basicInfoNodesKey = []
+ item.basicInfoNodes.forEach((i,key) => {
+ if(i.checked){
+ item.basicInfoNodesKey.push(i.key)
+ }else{
+ i.children.forEach(ele => {
+ ele.checked ? item.basicInfoNodesKey.push(ele.key) : null
+ })
+ }
+ })
+ //四周毗邻选中key集合
+ item.aroundNodesKey = []
+ item.aroundNodes.forEach((i,key) => {
+ if(i.checked){
+ item.aroundNodesKey.push(i.key)
+ }else{
+ i.children.forEach(ele => {
+ ele.checked ? item.aroundNodesKey.push(ele.key) : null
+ })
+ }
+ })
+ //重点部位选中key集合
+ item.keySiteNodesKey = []
+ item.keySiteNodes.forEach((i,key) => {
+ if(i.checked){
+ item.keySiteNodesKey.push(i.key)
+ }else{
+ i.children.forEach(ele => {
+ ele.checked ? item.keySiteNodesKey.push(ele.key) : null
+ })
+ }
+ })
+ //功能分区选中key集合
+ item.funDivNodesKey = []
+ item.funDivNodes.forEach((i,key) => {
+ if(i.checked){
+ item.funDivNodesKey.push(i.key)
+ }else{
+ i.children.forEach(ele => {
+ ele.checked ? item.funDivNodesKey.push(ele.key) : null
+ })
+ }
+ })
+ //数据核验选中key集合
+ item.fireFacNodesKey = []
+ item.fireFacNodes.forEach((i,key) => {
+ if(i.checked){
+ item.fireFacNodesKey.push(i.key)
+ }else{
+ i.children.forEach(ele => {
+ ele.checked ? item.fireFacNodesKey.push(ele.key) : null
+ })
+ }
+ })
+ })
+
let copyDatas = JSON.parse(JSON.stringify(this.unitId))
//循环每个建筑处理数据筛选出选中数据
copyDatas.forEach(item => {
@@ -900,7 +999,7 @@ export class CreateTestScoreComponent implements OnInit {
i.children = newChildren
delete i.selected
})
- console.log(111,item)
+ // console.log(111,item)
//建筑的重点部位模块处理
item.keySiteNodes ? item.keySiteNodes.forEach((i,key) => {
i.selected ? i.selected = null : null
@@ -1068,7 +1167,7 @@ export class CreateTestScoreComponent implements OnInit {
copyDatas.forEach((item,key) =>{
paperDataInfo[key] = {}
paperDataInfo[key].id = null
- paperDataInfo[key].paperId = null
+ paperDataInfo[key].paperId = sessionStorage.getItem('paperId')
paperDataInfo[key].companyId = item.id
paperDataInfo[key].basicInfoData = item.basicInfoNodes ? JSON.stringify(item.basicInfoNodes) : '[]'
paperDataInfo[key].basicInfoScore = item.basicInfoScore
@@ -1079,12 +1178,13 @@ export class CreateTestScoreComponent implements OnInit {
paperDataInfo[key].functionalDivisionData = item.funDivNodes ? JSON.stringify(item.funDivNodes) : '[]'
paperDataInfo[key].functionalDivisionScore = item.funDivScore
paperDataInfo[key].facilityData = item.fireFacNodes ? JSON.stringify(item.fireFacNodes) : '[]'
- paperDataInfo[key].facilityScore = item.fireFacScore
- paperDataInfo[key].planList = item.planList
+ paperDataInfo[key].facilityScore = item.fireFacScore,
+ paperDataInfo[key].originalData = JSON.stringify(this.unitId[key])
})
//判断是否存在总分填写后没有勾选 或者勾选了没有填写总分的情况
- paperDataInfo.forEach(element => {
+ for (let index = 0; index < paperDataInfo.length; index++) {
+ const element = paperDataInfo[index];
element.planList ? element.planList.forEach(item => {
if(!item.score || item.score == 0){
element.isPlanScore = false
@@ -1119,29 +1219,61 @@ export class CreateTestScoreComponent implements OnInit {
return
}else
//存在预案没有填写总分
- if(!element.isPlanScore){
+ if(element.isPlanScore == false){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('存在预案未填写总分的分组','确定',config);
return
- }else{
-
- if(window.confirm('你确定要创建该试卷吗?')){
- console.log(555,this.unitId)
+ }
+ }
- console.log(666,paperDataInfo)
-
- }else{
-
+ //设置paperPlan的分数
+ console.log(123,this.unitId)
+ console.log(456,paperDataInfo)
+ let _this = this
+ async function setPlansScore(){
+ for (let index = 0; index < _this.unitId.length; index++) {
+ const element = _this.unitId[index];
+ for (let i = 0; i < element.planList.length; i++) {
+ await new Promise((resolve, reject) => {
+ const item = element.planList[i];
+ _this.http.put(`/api/PaperPlans/ModifyScore/${item.id}`,'',{params:{
+ score : item.score
+ }}).subscribe(((data) => {
+ resolve(i)
+ console.log('修改分数成功'+i,item.score)
+ }))
+ })
}
-
- }
+ }
+
+ }
+
+
+
+ setPlansScore().then(()=>{
+ console.log('修改分数成功2222')
+
+ let body = {
+ id:sessionStorage.getItem('paperId'),
+ paperDataInfo:paperDataInfo
+ }
+ this.http.put(`/api/Papers/UpdatePaperData/${sessionStorage.getItem('paperId')}`,body).subscribe(data => {
+ const config = new MatSnackBarConfig();
+ config.verticalPosition = 'top';
+ config.duration = 3000
+ this.snackBar.open('创建试卷成功','确定',config);
+ })
})
+
+
+
+
}
//上一步
goBack(){
@@ -1211,7 +1343,7 @@ export class AddPlanTwoDialog {
}
ngOnInit(): void {
this.get2DPlan()
- console.log(this.data)
+ console.log(1,this.data.companyData.companyData.id)
}
//获取当前公司的二维预案
@@ -1235,12 +1367,37 @@ export class AddPlanTwoDialog {
confirm(){
if(this.planType){//如果选择的是已存在预案
if(this.selectedRadioData){
- this.dialogRef.close(this.selectedRadioData);
- sessionStorage.setItem('companyName',this.data.companyData.companyData.name)
- sessionStorage.setItem('planId',this.selectedRadioData.id)
- sessionStorage.setItem('buildingTypeId',this.data.companyData.companyData.buildingTypes[0].id)
- sessionStorage.setItem('companyId',this.data.companyData.companyData.id)
- window.open(`/canvasTool?openType=1&planName=${this.selectedRadioData.name}`)
+ console.log(this.selectedRadioData)
+ let paperPlansBody = {
+ id: null,
+ paperId: sessionStorage.getItem('paperId'),
+ planComponentId: this.selectedRadioData.id,
+ examPlanType: 0,
+ creatorId: JSON.parse(sessionStorage.getItem('creatorData')).id,
+ modifiedTime: new Date(),
+ isPublic: this.selectedRadioData.openRange == "未公开" ? false : true,
+ title: this.selectedRadioData.name,
+ mainPoint: null,
+ score: 0,
+ examFacilityAssetsData: null,
+ examDisposalNodesData: null,
+ companyId:this.data.companyData.companyData.id,
+ creatorName:this.selectedRadioData.creatorName,
+ planLevel:Number(this.selectedRadioData.planLevel)
+ }
+ let paperPlansParams:any = {
+ paperId:sessionStorage.getItem('paperId'),
+ }
+ this.http.post('/api/PaperPlans',paperPlansBody,{params:paperPlansParams}).subscribe((data2:any) => {
+ this.dialogRef.close(data2);
+ sessionStorage.setItem('companyName',this.data.companyData.companyData.name)
+ sessionStorage.setItem('planId',this.selectedRadioData.id)
+ sessionStorage.setItem('buildingTypeId',this.data.companyData.companyData.buildingTypes[0].id)
+ sessionStorage.setItem('companyId',this.data.companyData.companyData.id)
+ window.open(`/canvasTool?openType=1&planName=${this.selectedRadioData.name}&paperplanId=${data2.id}`)
+ })
+
+
}else{
if(this.dataSource.length == 0){
this.dialogRef.close();
@@ -1255,6 +1412,12 @@ export class AddPlanTwoDialog {
}else{//如果选择的是自定义预案
+
+
+
+
+
+
let level = sessionStorage.getItem('level')
let body = {
id: null,
@@ -1268,13 +1431,37 @@ export class AddPlanTwoDialog {
this.http.post("/api/ExamPlanComponents2D",body,{params:{
companyId : this.data.companyData.companyData.id
}}).subscribe((data:any)=>{
- // console.log("创建成功")
- this.dialogRef.close(data);
- sessionStorage.setItem("planId",data.id);
- sessionStorage.setItem("companyId",this.data.companyData.companyData.id)
- sessionStorage.setItem("buildingTypeId",this.data.companyData.companyData.buildingTypes[0].id)
- sessionStorage.setItem("editable","1")
- window.open(`/canvasTool?openType=2&planName=${this.customPlanName}`)
+ console.log("创建自定义二维成功")
+
+ let paperPlansBody = {
+ id: null,
+ paperId: sessionStorage.getItem('paperId'),
+ planComponentId: data.id,
+ examPlanType: 1,
+ creatorId: JSON.parse(sessionStorage.getItem('creatorData')).id,
+ modifiedTime: new Date(),
+ isPublic: true,
+ title: this.customPlanName,
+ mainPoint: null,
+ score: 0,
+ examFacilityAssetsData: null,
+ examDisposalNodesData: null,
+ companyId:this.data.companyData.companyData.id,
+ creatorName:sessionStorage.getItem('realName'),
+ planLevel:Number(sessionStorage.getItem('level'))
+ }
+ let paperPlansParams:any = {
+ paperId:sessionStorage.getItem('paperId')
+ }
+ console.log(this)
+ this.http.post('/api/PaperPlans',paperPlansBody,{params:paperPlansParams}).subscribe((data2:any) => {
+ this.dialogRef.close(data2);
+ sessionStorage.setItem("planId",data.id);
+ sessionStorage.setItem("companyId",this.data.companyData.companyData.id)
+ sessionStorage.setItem("buildingTypeId",this.data.companyData.companyData.buildingTypes[0].id)
+ sessionStorage.setItem("editable","1")
+ window.open(`/canvasTool?openType=2&planName=${this.customPlanName}&paperplanId=${data2.id}`)
+ })
})
}
}
diff --git a/src/app/examiner/examiner-index/examiner-index.component.ts b/src/app/examiner/examiner-index/examiner-index.component.ts
index 56b309a..813f26f 100644
--- a/src/app/examiner/examiner-index/examiner-index.component.ts
+++ b/src/app/examiner/examiner-index/examiner-index.component.ts
@@ -287,9 +287,10 @@ export class FinishDia{
//获取登录账号的个人资料
Profiles:any
getProfiles(){
- this.http.get('/api/ExamAccounts/Profiles').subscribe(data => {
+ this.http.get('/api/ExamAccounts/Profiles').subscribe((data:any) => {
console.log(data)
this.Profiles = data
+ sessionStorage.setItem('creatorData',JSON.stringify(data))
})
}
diff --git a/src/app/ui/collection-tools/examinationQuestions.ts b/src/app/ui/collection-tools/examinationQuestions.ts
index 35ce3ac..db4bc15 100644
--- a/src/app/ui/collection-tools/examinationQuestions.ts
+++ b/src/app/ui/collection-tools/examinationQuestions.ts
@@ -210,7 +210,7 @@ export class uploadQuestions {
submit () {
console.log(this.data.question)
let body:any = {
- id: null,
+ id: this.route.snapshot.queryParams.paperplanId,
paperId: sessionStorage.getItem('paperId'),
planComponentId: sessionStorage.getItem('planId'),
examPlanType: this.route.snapshot.queryParams.openType == 1 ? 0 : 1,
@@ -219,23 +219,21 @@ export class uploadQuestions {
isPublic: true,
title: this.route.snapshot.queryParams.planName,
mainPoint: this.data.question.keynote,
- score: null,
+ score: 0,
examFacilityAssetsData: sessionStorage.getItem('消防设施' + sessionStorage.getItem('paperId')) ? sessionStorage.getItem('消防设施' + sessionStorage.getItem('paperId')) : null,
- examDisposalNodesData: sessionStorage.getItem('examNodeList') ? sessionStorage.getItem('examNodeList') : null
+ examDisposalNodesData: sessionStorage.getItem('examNodeList') ? sessionStorage.getItem('examNodeList') : null,
+ companyId:sessionStorage.getItem('companyId')
}
- let params:any = {
- paperId:sessionStorage.getItem('paperId'),
- examPlanType:this.route.snapshot.queryParams.openType == 1 ? 0 : 1
- }
- this.http.post("/api/PaperPlans",body,{params:params}).subscribe(data => {
+
+ this.http.put(`/api/PaperPlans/${this.route.snapshot.queryParams.paperplanId}`,body).subscribe(data => {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('设置完成,页面将于一秒后关闭','确定',config);
- setTimeout(() => {
- window.close()
- }, 1000);
+ // setTimeout(() => {
+ // window.close()
+ // }, 1000);
})
|