Browse Source

[完善]完善任务执行按钮

非煤矿山灾害智能感知和预警系统
邵佳豪 2 years ago
parent
commit
3315c71698
  1. 12
      src/app/home/home.module.ts
  2. 8
      src/app/home/task/station-task-apply/station-task-apply.component.html
  3. 9
      src/app/home/task/station-task-apply/station-task-apply.component.scss
  4. 5
      src/app/home/task/station-task-execution/station-task-execution.component.html
  5. 3
      src/app/home/task/station-task-execution/station-task-execution.component.scss
  6. 46
      src/app/home/task/station-task-execution/station-task-execution.component.ts
  7. 28
      src/app/home/task/station-task-execution/upload/upload.component.html
  8. 37
      src/app/home/task/station-task-execution/upload/upload.component.scss
  9. 127
      src/app/home/task/station-task-execution/upload/upload.component.ts
  10. 17
      src/app/pipe/cameraTypePipe.ts
  11. 9
      src/app/pipe/pipe.ts

12
src/app/home/home.module.ts

@ -70,8 +70,10 @@ import { NzListModule } from 'ng-zorro-antd/list';
import { OperationLogComponent } from './basic-info/unit-details/operation-log/operation-log.component';
import { NzDividerModule } from 'ng-zorro-antd/divider';
import { ChatWindowComponent } from './commonComponents/chat-window/chat-window.component';
import { AngularDraggableModule } from 'angular2-draggable';
import { AngularDraggableModule } from 'angular2-draggable';
import { HomeComponent } from './statistic-analysis/home/home.component';
import { UploadComponent } from './task/station-task-execution/upload/upload.component';
import { fileName } from '../pipe/pipe';
@NgModule({
declarations: [
NavComponent,
@ -111,7 +113,9 @@ import { HomeComponent } from './statistic-analysis/home/home.component';
CreateTaskComponent,
OperationLogComponent,
ChatWindowComponent,
HomeComponent
HomeComponent,
UploadComponent,
fileName
],
imports: [
CommonModule,
@ -151,7 +155,7 @@ import { HomeComponent } from './statistic-analysis/home/home.component';
NzDividerModule,
AngularDraggableModule
],
providers: [StationTaskExecutionComponent,StationWeeklyPlanComponent],
entryComponents: [AddroleComponent, EditroleComponent, AdduserComponent, EdituserComponent, AddorComponent, EditorComponent, ApplyComponent, ApplyLookComponent, LookTaskComponent, AllotPersonComponent, EditOrComponent, CreateTaskComponent]
providers: [StationTaskExecutionComponent, StationWeeklyPlanComponent],
entryComponents: [AddroleComponent, EditroleComponent, AdduserComponent, EdituserComponent, AddorComponent, EditorComponent, ApplyComponent, ApplyLookComponent, LookTaskComponent, AllotPersonComponent, EditOrComponent, CreateTaskComponent, UploadComponent]
})
export class HomeModule { }

8
src/app/home/task/station-task-apply/station-task-apply.component.html

@ -109,8 +109,8 @@
</span>
</div>
<div class="flexcol">
<span>
{{item.organization.name}}
<span class="ellipsi">
{{isSupervisor ? item.creator.name :item.organization.name}}
</span>
<span>
主负责人
@ -183,8 +183,8 @@
</div>
<div class="flexcol">
<span>
<span class="blue" style="margin-right: 6px;" (click)="look(item)">查看</span>
<span class="red" (click)="deleteTask(item, taskLIst)">删除</span>
<a class="blue" style="margin-right: 6px;" (click)="look(item)">查看</a>
<a class="red" (click)="deleteTask(item, taskLIst)">删除</a>
</span>
<span>
操作

9
src/app/home/task/station-task-apply/station-task-apply.component.scss

@ -174,7 +174,7 @@
span {
display: inline-block;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@ -191,6 +191,7 @@
.flexcol {
display: flex;
width: 100%;
flex-direction: column;
align-items: flex-start;
margin-right: 3%;
@ -204,9 +205,13 @@
}
}
.flexcollevel{
.flexcollevel {
flex: 2.5;
}
.ellipsi{
width: 100%;
}
.flexcolassistant {
flex: 2.5;
overflow: hidden;

5
src/app/home/task/station-task-execution/station-task-execution.component.html

@ -161,8 +161,9 @@
</span>
</div>
<div class="flexcol">
<span class="blue" (click)="look(item)">
查看
<span>
<a class="blue" (click)="look(item)" style="margin-right: 5px;">查看</a>
<a class="blue" (click)="complete(item)">完成</a>
</span>
<span>
操作

3
src/app/home/task/station-task-execution/station-task-execution.component.scss

@ -172,7 +172,6 @@
overflow:hidden;
span {
display: inline-block;
width: 100%;
height: 33px;
line-height: 33px;
text-align: left;
@ -191,7 +190,7 @@
flex-direction: column;
align-items: flex-start;
margin-right: 3%;
width: 100%;
span:nth-child(1) {
color: #303133;
}

46
src/app/home/task/station-task-execution/station-task-execution.component.ts

@ -7,6 +7,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
import { ThisReceiver } from '@angular/compiler';
import { MethodService } from 'src/app/service/method.service';
import { UploadComponent } from './upload/upload.component';
@Component({
selector: 'app-station-task-execution',
templateUrl: './station-task-execution.component.html',
@ -65,7 +66,7 @@ export class StationTaskExecutionComponent implements OnInit {
PageSize = 10
taskLIst = []
getTaskList() {
// this.isloading = true
this.isloading = true
let selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'
let params = {
Month: selectedTime,
@ -276,6 +277,49 @@ export class StationTaskExecutionComponent implements OnInit {
look(item) {
}
complete(item) {
const modal = this.modal.create({
nzTitle: '完成任务',
nzContent: UploadComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 450,
nzMaskClosable: false,
nzComponentParams: {
data: item,
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise((resolve, reject) => {
let body = {
inspectionResult: instance.validateForm.value.result,
resultAttachment: instance.fileList
}
this.http.patch(`/api/PlanTasks/${item.id}`, body).subscribe({
next: (data) => {
this.message.create('success', '已完成');
this.getTaskList()
resolve(data)
},
error: (err) => {
this.message.create('warning', '完成失败');
reject(err)
}
})
})
} else {
this.message.create('warning', '请选择结果!');
return false
}
}
});
const instance = modal.getContentComponent();
modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
}
ischat = false
taskId
openchat(item) {

28
src/app/home/task/station-task-execution/upload/upload.component.html

@ -0,0 +1,28 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSpan]="5" nzFor="result" nzRequired>检查结果</nz-form-label>
<nz-form-control [nzSpan]="12" nzErrorTip="请选择结果!" style="max-width: 100%;">
<nz-select id="result" formControlName="result" nzPlaceHolder="请选择结果">
<nz-option nzValue="未发现违法违规情况" nzLabel="未发现违法违规情况"></nz-option>
<nz-option nzValue="责令限期改正" nzLabel="责令限期改正"></nz-option>
<nz-option nzValue="因客观原因无法开展检查" nzLabel="因客观原因无法开展检查"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item style="margin-bottom: 0;">
<nz-form-label [nzSpan]="5" nzFor="file">上传附件</nz-form-label>
<div class="uploadbox">
<button nz-button [nzLoading]="isLoadingSave">
<span nz-icon nzType="upload"></span>
点击上传
</button>
<input type="file" name="" id="" (change)="filechange($event)" *ngIf="!isLoadingSave">
<ul>
<li *ngFor="let item of fileList" (click)="lookfile(item)">{{item | fileName}}</li>
</ul>
</div>
</nz-form-item>
</form>
</div>

37
src/app/home/task/station-task-execution/upload/upload.component.scss

@ -0,0 +1,37 @@
.uploadbox {
display: flex;
flex-direction: column;
position: relative;
width: 75%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
button {
margin-bottom: 8px;
width: 110px;
}
input {
opacity: 0;
width: 110px;
height: 32px;
position: absolute;
left: 0;
top: 0;
cursor: pointer;
}
ul {
margin-bottom: 0;
li{
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
li:hover {
text-decoration: underline;
cursor: pointer;
}
}
}

127
src/app/home/task/station-task-execution/upload/upload.component.ts

@ -0,0 +1,127 @@
import { HttpClient } from '@angular/common/http';
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { ObjectsSimpleService } from 'src/app/service/objectsSimple.service';
import Viewer from 'viewerjs';
@Component({
selector: 'app-upload',
templateUrl: './upload.component.html',
styleUrls: ['./upload.component.scss']
})
export class UploadComponent implements OnInit {
@Input() data?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private objectsSrv: ObjectsSimpleService) { }
ngOnInit(): void {
console.log(this.data)
this.data.resultAttachment ? this.fileList = this.data.resultAttachment : this.fileList = []
this.validateForm = this.fb.group({
result: [this.data.inspectionResult, [Validators.required]],
});
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}
fileList = []
isLoadingSave: boolean = false
uploadIndex: string
filechange(e) {
this.isLoadingSave = true
let file = e.target.files[0] || null //获取上传的文件
this.openFileSelect(file, `resultAttachment/${this.data.id}/`)
}
//设置文件路径并上传
postFilePath
async openFileSelect(file: File, extensionPath: string) {
this.postFilePath = extensionPath;
let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB 超过5MB要分块上传
if (fileSize >= shardSize) // 超过5MB要分块上传
{
await this.postFileByMul(file);
}
else //普通上传
{
await this.postFile(file);
}
}
//上传文件
async postFile(file: File) {
await new Promise((resolve, reject) => {
this.objectsSrv.postFile(this.postFilePath, file).subscribe(data => {
let dataObj = data as any;
let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName;
this.fileList.push(filePath)
this.isLoadingSave = false
resolve('success')
});
})
}
/**
*
* @param file
*/
postFileByMul(file: File) {
this.objectsSrv.postFile_MultipartUpload(this.postFilePath, file).then((value) => {
let dataObj = value as any;
let filePath = dataObj.filePath
this.fileList.push(filePath)
this.isLoadingSave = false
});
}
//获取文件格式
getFileType(name: string): string {
let suffix
if (name.substring(name.length - 4).includes('png') || name.substring(name.length - 4).includes('jpg') || name.substring(name.length - 4).includes('jpeg') || name.substring(name.length - 4).includes('webp')) {
suffix = 'img'
} else if (name.substring(name.length - 4).includes('doc') || name.substring(name.length - 4).includes('docx')) {
suffix = 'word'
} else if (name.substring(name.length - 4).includes('pdf')) {
suffix = 'pdf'
}
return suffix
}
lookfile(item) {
if (!item) {
return
}
if (this.getFileType(item) == 'word') {
let arr = item.split('.')
arr[arr.length - 1] = 'pdf'
window.open(arr.join('.'))
} else if (this.getFileType(item) == 'pdf') {
window.open(item)
} else {
this.viewImg(item)
}
}
//查看图片
viewImg(url) {
let dom = document.getElementById(`viewerjs`)
let pObjs = dom.childNodes;
let node = document.createElement("img")
node.style.display = "none";
node.src = url;
node.id = 'img'
dom.appendChild(node)
setTimeout(() => {
let viewer = new Viewer(document.getElementById(`viewerjs`), {
hidden: () => {
dom.removeChild(pObjs[0]);
viewer.destroy();
}
});
node.click();
}, 0);
}
}

17
src/app/pipe/cameraTypePipe.ts

@ -1,17 +0,0 @@
import { Pipe, PipeTransform } from '@angular/core';
/*
* Raise the value exponentially
* Takes an exponent argument that defaults to 1.
* Usage:
* value | exponentialStrength:exponent
* Example:
* {{ 2 | exponentialStrength:10 }}
* formats to: 1024
*/
@Pipe({ name: 'cameraType' })
export class cameraType implements PipeTransform {
transform(value: number): string {
let arr = ['进出口', '加油区', '卸油区', '便利店']
return arr[value]
}
}

9
src/app/pipe/pipe.ts

@ -0,0 +1,9 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'fileName' })
export class fileName implements PipeTransform {
transform(value: string): string {
let a = value.split('/')[value.split('/').length - 1]
return a
}
}
Loading…
Cancel
Save