Commit cd21e8f7 authored by wangqinghua's avatar wangqinghua

commonService

parent 2df735af
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {OverAllService} from '../../../overAll/overAll.service'; import {OverAllService} from '../../../overAll/overAll.service';
import {NzMessageService, NzTreeNode, NzFormatEmitEvent} from 'ng-zorro-antd'; import {NzMessageService, NzTreeNode, NzFormatEmitEvent} from 'ng-zorro-antd';
import {ToTree} from '../../../shared/common/toTree'; import {CommonService} from '../../../shared/common/common.service';
@Component({ @Component({
selector: 'smart-alarm-target', selector: 'smart-alarm-target',
...@@ -15,7 +15,7 @@ export class AlarmTargetComponent implements OnInit { ...@@ -15,7 +15,7 @@ export class AlarmTargetComponent implements OnInit {
nodes; nodes;
constructor(private overAllSer:OverAllService,private message:NzMessageService, constructor(private overAllSer:OverAllService,private message:NzMessageService,
private toTree:ToTree) { private commonSer:CommonService) {
} }
ngOnInit() { ngOnInit() {
...@@ -40,7 +40,6 @@ export class AlarmTargetComponent implements OnInit { ...@@ -40,7 +40,6 @@ export class AlarmTargetComponent implements OnInit {
} }
toNode(data){ toNode(data){
// const arr = this.toTree.listToTree(1,2,data)
this.nodes = data.map(res=>{ this.nodes = data.map(res=>{
return new NzTreeNode(res); return new NzTreeNode(res);
}) })
......
...@@ -3,8 +3,7 @@ import {Router} from '@angular/router'; ...@@ -3,8 +3,7 @@ import {Router} from '@angular/router';
import {Http} from '@angular/http'; import {Http} from '@angular/http';
import {LayoutService} from '../layout.service'; import {LayoutService} from '../layout.service';
import {LocalStorageService, SessionStorageService} from 'ngx-webstorage'; import {LocalStorageService, SessionStorageService} from 'ngx-webstorage';
import {ToTree} from '../../shared/common/toTree'; import {CommonService} from '../../shared/common/common.service';
@Component({ @Component({
selector: 'jhi-sidebar', selector: 'jhi-sidebar',
...@@ -20,7 +19,7 @@ export class SidebarComponent implements OnInit { ...@@ -20,7 +19,7 @@ export class SidebarComponent implements OnInit {
constructor(public router: Router, private http: Http, constructor(public router: Router, private http: Http,
public layoutSer: LayoutService, public layoutSer: LayoutService,
public toTreeSer: ToTree, public commonSer: CommonService,
private $localStorage: LocalStorageService, private $localStorage: LocalStorageService,
private $sessionStorage: SessionStorageService) { private $sessionStorage: SessionStorageService) {
} }
...@@ -35,7 +34,7 @@ export class SidebarComponent implements OnInit { ...@@ -35,7 +34,7 @@ export class SidebarComponent implements OnInit {
this.layoutSer.getMenu().subscribe( this.layoutSer.getMenu().subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.menuList = this.toTreeSer.listToTree('id', 'parentId', res.data); this.menuList = this.commonSer.listToTree('id', 'parentId', res.data);
} }
} }
); );
......
import {Component, EventEmitter, OnInit, Output} from '@angular/core'; import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {NzTreeNode} from 'ng-zorro-antd'; import {NzTreeNode} from 'ng-zorro-antd';
import {SystemService} from '../../system/system.service'; import {SystemService} from '../../system/system.service';
import {ToTree} from '../../shared/common/toTree'; import {CommonService} from '../../shared/common/common.service';
@Component({ @Component({
selector: 'smart-select-person', selector: 'smart-select-person',
...@@ -23,7 +23,7 @@ export class SelectPersonComponent implements OnInit { ...@@ -23,7 +23,7 @@ export class SelectPersonComponent implements OnInit {
indeterminate = false; indeterminate = false;
displayData: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }> = []; displayData: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }> = [];
constructor(private systemSer: SystemService, private toTreeSer: ToTree) { constructor(private systemSer: SystemService, private commonSer: CommonService) {
} }
checkAll(value: boolean): void { checkAll(value: boolean): void {
...@@ -111,7 +111,7 @@ export class SelectPersonComponent implements OnInit { ...@@ -111,7 +111,7 @@ export class SelectPersonComponent implements OnInit {
} }
nodeTree() { nodeTree() {
const tree = this.toTreeSer.listToTree('id', 'parentId', this.groupList,); const tree = this.commonSer.listToTree('id', 'parentId', this.groupList,);
const list = tree.map(res => { const list = tree.map(res => {
return new NzTreeNode(res); return new NzTreeNode(res);
}); });
......
import {Injectable, OnInit} from "@angular/core"; import {Injectable, OnInit} from "@angular/core";
import {NzModalService} from 'ng-zorro-antd';
@Injectable() @Injectable()
export class ToTree implements OnInit { export class CommonService implements OnInit {
constructor() { constructor(private modalSer:NzModalService) {
// 定义发射事件 // 定义发射事件
} }
...@@ -62,4 +63,16 @@ export class ToTree implements OnInit { ...@@ -62,4 +63,16 @@ export class ToTree implements OnInit {
str = str.substring(0, str.length - 1); str = str.substring(0, str.length - 1);
return str; return str;
} }
deleteThing(title,callback){
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">title</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: callback,
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel'),
})
}
} }
...@@ -3,8 +3,8 @@ import {NzMessageService, NzModalService, NzTreeNode, NzTreeNodeOptions} from 'n ...@@ -3,8 +3,8 @@ import {NzMessageService, NzModalService, NzTreeNode, NzTreeNodeOptions} from 'n
import {SystemService} from '../system.service'; import {SystemService} from '../system.service';
import {UserComponent} from '../modal/user/user.component'; import {UserComponent} from '../modal/user/user.component';
import {GroupModalComponent} from '../modal/group-modal/group-modal.component'; import {GroupModalComponent} from '../modal/group-modal/group-modal.component';
import {ToTree} from '../../shared/common/toTree';
import {SelectRoleComponent} from '../../modal/select-role/select-role.component'; import {SelectRoleComponent} from '../../modal/select-role/select-role.component';
import {CommonService} from '../../shared/common/common.service';
@Component({ @Component({
selector: 'jhi-group', selector: 'jhi-group',
...@@ -29,7 +29,7 @@ export class GroupComponent implements OnInit { ...@@ -29,7 +29,7 @@ export class GroupComponent implements OnInit {
displayData: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }> = []; displayData: Array<{ key1: string; key2: number; key3: string; key4: string; checked: boolean }> = [];
constructor(private systemSer: SystemService, private message: NzMessageService, constructor(private systemSer: SystemService, private message: NzMessageService,
private modalSer: NzModalService, private toTreeSer: ToTree) { private modalSer: NzModalService, private commonSer: CommonService) {
} }
checkAll(value: boolean): void { checkAll(value: boolean): void {
...@@ -90,7 +90,7 @@ export class GroupComponent implements OnInit { ...@@ -90,7 +90,7 @@ export class GroupComponent implements OnInit {
} }
nodeTree() { nodeTree() {
const tree = this.toTreeSer.listToTree('id', 'parentId', this.groupList,); const tree = this.commonSer.listToTree('id', 'parentId', this.groupList,);
const list = tree.map(res => { const list = tree.map(res => {
return new NzTreeNode(res); return new NzTreeNode(res);
}); });
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
import {SystemService} from '../../system.service'; import {SystemService} from '../../system.service';
import {NzMessageService, NzTreeNode} from 'ng-zorro-antd'; import {NzMessageService, NzTreeNode} from 'ng-zorro-antd';
import {LayoutService} from '../../../layouts/layout.service'; import {LayoutService} from '../../../layouts/layout.service';
import {ToTree} from '../../../shared/common/toTree'; import {CommonService} from '../../../shared/common/common.service';
@Component({ @Component({
selector: 'smart-role', selector: 'smart-role',
...@@ -28,7 +28,7 @@ export class RoleComponent implements OnInit { ...@@ -28,7 +28,7 @@ export class RoleComponent implements OnInit {
nodeList; nodeList;
constructor(private fb: FormBuilder, private message: NzMessageService, constructor(private fb: FormBuilder, private message: NzMessageService,
private systemSer: SystemService,private layoutSer:LayoutService,private toTreeSer:ToTree) { private systemSer: SystemService,private layoutSer:LayoutService,private commonSer:CommonService) {
} }
ngOnInit() { ngOnInit() {
...@@ -49,7 +49,7 @@ export class RoleComponent implements OnInit { ...@@ -49,7 +49,7 @@ export class RoleComponent implements OnInit {
this.layoutSer.getMenu().subscribe( this.layoutSer.getMenu().subscribe(
(res)=>{ (res)=>{
if(res.errCode == 10000){ if(res.errCode == 10000){
this.menuList =this.toTreeSer.listToTree('id','parentId',res.data); this.menuList =this.commonSer.listToTree('id','parentId',res.data);
this.menuList.forEach(res => { this.menuList.forEach(res => {
res.title = res.name; res.title = res.name;
res.key = res.id; res.key = res.id;
......
...@@ -2,12 +2,12 @@ import { HttpClient } from "@angular/common/http"; ...@@ -2,12 +2,12 @@ import { HttpClient } from "@angular/common/http";
import {Observable} from "rxjs/Rx"; import {Observable} from "rxjs/Rx";
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {SERVER_API_URL} from "../app.constants"; import {SERVER_API_URL} from "../app.constants";
import {ToTree} from '../shared/common/toTree'; import {CommonService} from '../shared/common/common.service';
@Injectable() @Injectable()
export class SystemService { export class SystemService {
constructor(private http: HttpClient,private toTree:ToTree) { constructor(private http: HttpClient,private commonSer:CommonService) {
} }
//角色列表 //角色列表
...@@ -67,7 +67,7 @@ export class SystemService { ...@@ -67,7 +67,7 @@ export class SystemService {
//审计列表 //审计列表
logList(data): Observable<any>{ logList(data): Observable<any>{
return this.http.get(SERVER_API_URL + '/log?'+this.toTree.toQuery(data)); return this.http.get(SERVER_API_URL + '/log?'+this.commonSer.toQuery(data));
} }
//对单一角色批量添加用户 //对单一角色批量添加用户
...@@ -97,27 +97,27 @@ export class SystemService { ...@@ -97,27 +97,27 @@ export class SystemService {
//单个用户角色获取 //单个用户角色获取
roleList(data): Observable<any>{ roleList(data): Observable<any>{
return this.http.get(SERVER_API_URL + '/user/roleList?'+this.toTree.toQuery(data) ); return this.http.get(SERVER_API_URL + '/user/roleList?'+this.commonSer.toQuery(data) );
} }
//获取当前安全管理员已审批记录 //获取当前安全管理员已审批记录
approveListSafeManager(data): Observable<any>{ approveListSafeManager(data): Observable<any>{
return this.http.get(SERVER_API_URL + '/approval/approveListSafeManager?'+this.toTree.toQuery(data) ); return this.http.get(SERVER_API_URL + '/approval/approveListSafeManager?'+this.commonSer.toQuery(data) );
} }
//获取当前安全管理员未审批记录 //获取当前安全管理员未审批记录
unapproveListSafeManager(data): Observable<any>{ unapproveListSafeManager(data): Observable<any>{
return this.http.get(SERVER_API_URL + '/approval/unapproveListSafeManager?'+this.toTree.toQuery(data) ); return this.http.get(SERVER_API_URL + '/approval/unapproveListSafeManager?'+this.commonSer.toQuery(data) );
} }
//获取当前系统管理员的已审批记录 //获取当前系统管理员的已审批记录
approveListSystemManager(data): Observable<any>{ approveListSystemManager(data): Observable<any>{
return this.http.get(SERVER_API_URL + '/approval/approveListSystemManager?'+this.toTree.toQuery(data) ); return this.http.get(SERVER_API_URL + '/approval/approveListSystemManager?'+this.commonSer.toQuery(data) );
} }
//获取当前系统管理员的未审批记录 //获取当前系统管理员的未审批记录
unApproveListSystemManager(data): Observable<any>{ unApproveListSystemManager(data): Observable<any>{
return this.http.get(SERVER_API_URL + '/approval/unApproveListSystemManager?'+this.toTree.toQuery(data) ); return this.http.get(SERVER_API_URL + '/approval/unApproveListSystemManager?'+this.commonSer.toQuery(data) );
} }
//批量审批通过 //批量审批通过
......
...@@ -57,8 +57,9 @@ ...@@ -57,8 +57,9 @@
{{data.name}} {{data.name}}
</td> </td>
<td> <td>
{{data.inventorycount}} {{data.name}}
</td> </td>
<td>{{data.inventorycount}}</td>
<td>{{data.stock}}</td> <td>{{data.stock}}</td>
<td> <td>
{{data.usedcount}} {{data.usedcount}}
...@@ -73,7 +74,7 @@ ...@@ -73,7 +74,7 @@
<td>关联事件</td> <td>关联事件</td>
<td class="handle text-center"> <td class="handle text-center">
<span (click)="showEditModal(data)">查看</span> <span (click)="showEditModal(data)">查看</span>
<span (click)="deleteSend(data)">删除</span> <span (click)="deleteInVentory(data)">删除</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {WorkService} from '../../work.service'; import {WorkService} from '../../work.service';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service';
@Component({ @Component({
selector: 'smart-child-assets', selector: 'smart-child-assets',
templateUrl: './child-assets.component.html', templateUrl: './child-assets.component.html',
styles: [] styles: []
}) })
export class ChildAssetsComponent implements OnInit { export class ChildAssetsComponent implements OnInit {
childId; childId;
childrenList;
constructor(private workSer:WorkService,private routerInfo:ActivatedRoute) { constructor(private workSer: WorkService, private routerInfo: ActivatedRoute,
this.routerInfo.queryParams.subscribe( private conmonSer:CommonService) {
(res)=>{ this.routerInfo.queryParams.subscribe(
this.childId = res.id; (res) => {
} this.childId = res.id;
) }
} );
}
ngOnInit() {
this.getList();
}
ngOnInit() { getList() {
this.getList(); this.workSer.findInventory(this.childId).subscribe(
} (res) => {
this.childrenList = res.data;
}
);
}
getList(){ //删除资产
// this.workSer.create() deleteInVentory(){
this.conmonSer.deleteThing("确定删除该资产?",()=>{
// this.workSer.
})
} }
} }
...@@ -119,5 +119,9 @@ export class WorkService { ...@@ -119,5 +119,9 @@ export class WorkService {
return this.http.post(SERVER_API_URL + '/inventory/createInventory' ,data); return this.http.post(SERVER_API_URL + '/inventory/createInventory' ,data);
} }
// //根据资产类型id查询资产
findInventory(params): Observable<any>{
return this.http.get(SERVER_API_URL + '/inventory/findInventory/' +params);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment