Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {DatePipe} from '@angular/common';
import {InfomationService} from '../infomation.service';
import {UploadComponent} from '../../work/modal/upload/upload.component';
import {pageSize} from '../../app.constants';
import {CommonService} from '../../shared/common/common.service';
import {asset_type} from '../information.constans';
import {UploadAssetComponent} from '../modal/upload-asset/upload-asset.component';
import {CreatePropertyComponent} from '../modal/create-property/create-property.component';
selector: 'smart-asset-manage',
templateUrl: './asset-manage.component.html',
styles: []
@ViewChild('smartUploadAsset') smartUploadAsset: UploadAssetComponent;
@ViewChild('smartCreateProperty') smartCreateProperty: CreatePropertyComponent;
allChecked = false;
disabledButton = true;
indeterminate = false;
dataSet;
typeList = asset_type;
isLoading = false;
pageCount = pageSize;
pageNum = 1;
totalNum;
no: null,
name: null,
attributionProject: '',
contacts: '',
constructor(private infoSer: InfomationService, private message: NzMessageService,
private router: Router, private commonSer: CommonService, private datePipe: DatePipe) {
}
ngOnInit() {
this.getList();
}
checkAll(value: boolean): void {
this.dataSet.forEach(data => data.checked = value);
this.refreshStatus();
}
refreshStatus(): void {
const allChecked = this.dataSet.every(value => value.checked === true);
const allUnChecked = this.dataSet.every(value => !value.checked);
this.allChecked = allChecked;
this.indeterminate = (!allChecked) && (!allUnChecked);
this.disabledButton = !this.dataSet.some(value => value.checked);
}
//获取列表
getList() {
this.isLoading = true;
const obj = {
pageCount: this.pageCount,
pageNum: this.pageNum,
};
this.infoSer.propertyPage(obj).subscribe(
(res) => {
if (res.errCode == 10000) {
this.dataSet = res.data.data;
this.totalNum = res.data.totalNum;
}
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
}
);
}
//翻页
change(e) {
this.pageNum = e;
this.getList();
}
//查看详情
lookEvent(item) {
this.router.navigate(['app/main/handleDetail'], {
queryParams: {
eventId: item.id
}
});
}
//处理事件
goToHandle(item) {
this.router.navigate(['app/main/handleEvent'], {
queryParams: {
eventId: item.id
}
});
}
//新增事件
showAddModal() {
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
this.smartCreateProperty.showEditModal('编辑资产', item.id);
}
selectItem(item, e) {
if (e) {
this.selectList.push(item);
} else {
this.selectList.forEach((value, index) => {
if (value.id == item.id) {
this.selectList.splice(index, 1);
}
});
}
this.refreshStatus();
}
//批量删除
batchDelete() {
if (this.selectList.length == 0) {
this.message.warning('请选择需要删除的资产');
return false;
}
this.isLoading = true;
const data = {
ids: this.selectList.map(e => {
return e.id;
})
};
this.commonSer.confirmThing('批量删除', '确定删除选择的资产?', () => {
this.infoSer.propertyDelete(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.getList();
this.message.success('删除资产成功');
}
this.isLoading = false;
}
);
});
}
//删除资产
deleteHandle(data) {
const arr = {
ids: []
};
arr.ids.push(data.id);
this.commonSer.confirmThing('删除', '确定删除该资产', () => {
this.infoSer.propertyDelete(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
deleteMonitor(id) {
this.monitorSer.assetDelete(id, null).subscribe(
(res) => {
}
);
}
//转派
showTransforModal(item) {
// this.smartTransfor.showTransforModal('事件转派', item.id);
}
//搜索
search() {
this.pageNum = 1;
this.getList();
}
//上传资产
showUploadModal() {
this.isDownload = true;
this.infoSer.propertyExport().subscribe(