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 {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: '',
modal = {
isVisible: false,
title: '',
modalType: null,
};
constructor(private infoSer: InfomationService, private message: NzMessageService,
private router: Router, private commonSer: CommonService, private datePipe: DatePipe) {
}
ngOnInit() {
this.getList();
}
checkAll(value: boolean): void {
this.selectList = [];
this.dataSet.forEach(data => {
this.selectList.push(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;
}
queryParams: {
eventId: item.id
}
});
}
//处理事件
goToHandle(item) {
queryParams: {
eventId: item.id
}
});
}
//新增事件
showAddModal() {
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
157
158
159
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;
}
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();
//搜索
search() {
this.pageNum = 1;
this.getList();
}
//上传资产
showUploadModal() {
this.isDownload = true;
this.infoSer.propertyExport().subscribe(
//模版下载
handleOk() {
this.isDownload = true;
if (!this.modal.modalType) {
this.message.info('请选择需要下载的模版');
return;
}
const item = this.typeList.filter(e => e.value == this.modal.modalType);
console.log(item);
this.workSer.dowloadTemplateByProperty(item[0].value).subscribe(
(res) => {
this.isDownload = false;
this.commonSer.downloadFile(`${item[0].label}.xlsx`, res);
}
);
}