1 files deleted
12 files modified
| | |
| | | import { TranslateModule, TranslateLoader, TranslateService } from '@ngx-translate/core'; |
| | | import { TranslateHttpLoader } from '@ngx-translate/http-loader'; |
| | | import { HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http'; |
| | | |
| | | import { CoreModule } from './core/core.module'; |
| | | import { SharedModule } from './shared/shared.module'; |
| | | import { AppComponent } from './app.component'; |
| | |
| | | export interface Column { |
| | | text?: string; |
| | | name?: string; |
| | | value?: any; |
| | | width?: string; |
| | | sort?: boolean; |
| | | type?: DataType; |
| | |
| | | pageSize?: number ; // 一页多少条 |
| | | total?: number; |
| | | data?: any[]; |
| | | queryParams?: string; |
| | | queryParams?: string; |
| | | } |
| | | export class Grid implements PageBean { |
| | | export class Grid<T> implements PageBean { |
| | | title = ''; |
| | | pageIndex = 0; // 页码 |
| | | pageSize = 10; // 每页几行数据 |
| | | data: any[] = []; |
| | | data: T[] = []; |
| | | total = 0; |
| | | queryParams = ''; |
| | | pages = 0; // 总页数 |
| | |
| | | |
| | | checkAll(value: boolean) { |
| | | this.data.forEach( |
| | | row => {row.checked = value; } |
| | | row => {row['checked'] = value; } |
| | | ); |
| | | this.refreshStatus(); |
| | | } |
| | |
| | | } |
| | | refreshStatus() { |
| | | const data = this.data; |
| | | const allChecked = data.every(value => value.checked); |
| | | const allUnChecked = data.every(value => !value.checked); |
| | | const allChecked = data.every(value => value['checked']); |
| | | const allUnChecked = data.every(value => !value['checked']); |
| | | this.allChecked = allChecked; |
| | | this.indeterminate = (!allChecked) && (!allUnChecked); |
| | | this.selectedIndexs = data.filter(value => value.checked).map( |
| | | this.selectedIndexs = data.filter(value => value['checked']).map( |
| | | row => { |
| | | return row['index'] != null ? row['index'] : 0; |
| | | } |
| | |
| | | private _default = 'en'; |
| | | |
| | | private _langs = [ |
| | | { code: 'en', text: 'English' }, |
| | | { code: 'zh-CN', text: '中文' } |
| | | { code: 'zh-CN', text: '中文' }, |
| | | { code: 'en', text: 'English' } |
| | | ]; |
| | | |
| | | constructor(settings: SettingsService, |
| | |
| | | transform(value: any, col?: Column): any { |
| | | const t = Types.Date; |
| | | const type = col.type; |
| | | if(type!=null&&type.name!=null){ |
| | | value = this.transformHandle(value,type.name,type.format); |
| | | if (type != null && type.name != null) { |
| | | value = this.transformHandle(value, type.name, type.format); |
| | | } |
| | | return value; |
| | | } |
| | | private transformHandle(value:any,type: Types,format:any):any{ |
| | | switch(type){ |
| | | private transformHandle(value: any, type: Types, format: any): any{ |
| | | switch (type) { |
| | | case Types.Date: |
| | | return this.dateService.date_format(value,format); |
| | | return this.dateService.date_format(value, format); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import { Injectable } from '@angular/core'; |
| | | import { Column } from '@core/entity/grid'; |
| | | |
| | | export class Criteria{ |
| | | private static CONDITION_SPLIT = "||"; |
| | | private static CONDITION_SPLIT = '||'; |
| | | private conditions: string[] = []; |
| | | public getConditions(): string[]{ |
| | | return this.conditions; |
| | | } |
| | | |
| | | public addCondition(condition: string,colName:string,...values: any[]){ |
| | | const split = Criteria.CONDITION_SPLIT;//'||' |
| | | const split = Criteria.CONDITION_SPLIT; // '||' |
| | | this.conditions.push(condition+split+colName+split+ values.join(split)); |
| | | } |
| | | public andLike(col:Column): Criteria{ |
| | | public andLike(col: { name: string, value: any}): Criteria{ |
| | | this.addCondition('andLike',col.name,col.value); |
| | | return this; |
| | | } |
| | | public andEqualTo(col:Column): Criteria{ |
| | | public andEqualTo(col: { name: string, value: any}): Criteria{ |
| | | this.addCondition('andEqualTo',col.name,col.value); |
| | | return this; |
| | | } |
| | |
| | | import { _HttpClient } from '@delon/theme/services/http/http.client'; |
| | | import { AddOrEditComponent } from './version/add-or-edit/add-or-edit.component'; |
| | | import { PipeModule } from '@core/pipe/pipe.module'; |
| | | import { FormBuilder } from '@angular/forms'; |
| | | |
| | | const COMPONENTS_NOROUNT = [ AddOrEditComponent ]; |
| | | |
| | |
| | | |
| | | @NgModule({ |
| | | imports: [ |
| | | //管道模块必须当前模块导入 |
| | | // 管道模块必须当前模块导入 |
| | | PipeModule, |
| | | CommonModule, |
| | | SharedModule, |
| | |
| | | BasicInfoComponent, |
| | | VersionComponent, |
| | | MonitorPointComponent, |
| | | ...COMPONENTS_NOROUNT, |
| | | AddOrEditComponent |
| | | ...COMPONENTS_NOROUNT |
| | | ], |
| | | providers: [ToolsService, VersionService, _HttpClient], |
| | | providers: [ToolsService, VersionService, _HttpClient, FormBuilder], |
| | | entryComponents: COMPONENTS_NOROUNT |
| | | }) |
| | | export class DevicesModule { } |
| | |
| | | <p> |
| | | add-or-edit works! |
| | | </p> |
| | | <div class="modal-header"> |
| | | <div class="modal-title">{{ data.id != null ? '编辑' : '添加'}} - 安装用户</div> |
| | | </div> |
| | | <form [formGroup]="validateForm" (ngSubmit)="save($event,validateForm.value,validateForm.valid)" nz-form [nzType]="'horizontal'"> |
| | | <div nz-form-item nz-row class="mb-sm"> |
| | | <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> |
| | | <label nz-form-item-required>{{ cols.name.text }}</label> |
| | | </div> |
| | | <div nz-form-control nz-col [nzSpan]="6" nzHasFeedback> |
| | | <input nz-input formControlName="{{ cols.name.name }}" maxlength="20" /> |
| | | </div> |
| | | <div nz-form-label nz-col [nzSpan]="4"> |
| | | <label nz-form-item-required> |
| | | {{ cols.version.text }} |
| | | </label> |
| | | </div> |
| | | <div nz-form-control nz-col [nzSpan]="3" nzHasFeedback> |
| | | <nz-input-number formControlName="{{ cols.version.name }}" [nzMin]="1" [nzMax]="100" [nzStep]="1"> |
| | | </nz-input-number> |
| | | </div> |
| | | </div> |
| | | <div nz-form-item nz-row class="mb-sm"> |
| | | <div nz-form-label nz-col [nzSm]="4" [nzXs]="24"> |
| | | <label nz-form-item-required>{{ cols.createTime.text }}</label> |
| | | </div> |
| | | <div nz-form-control nz-col [nzSpan]="6" nzHasFeedback> |
| | | <nz-datepicker formControlName="{{ cols.createTime.name }}" nzShowTime [nzPlaceHolder]="'选择时间'" |
| | | [nzFormat]="'YYYY-MM-DD HH:mm:ss'" ></nz-datepicker> |
| | | </div> |
| | | <div nz-form-label nz-col [nzSpan]="4"> |
| | | <label>{{ cols.description.text }}</label> |
| | | </div> |
| | | <div nz-form-control nz-col [nzSpan]="8" nzHasFeedback> |
| | | <input nz-input formControlName="{{ cols.description.name }}" maxlength="20" /> |
| | | </div> |
| | | </div> |
| | | <div class="modal-footer"> |
| | | <button nz-button type="button" (click)="close()">关闭</button> |
| | | <button nz-button [nzType]="'primary'" [nzLoading]="isSaving"> |
| | | <span > |
| | | 保存<span *ngIf="isSaving" >中</span> |
| | | </span> |
| | | </button> |
| | | </div> |
| | | </form> |
| | |
| | | import { DeviceVersion } from './../version.component'; |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { HttpClient } from '@angular/common/http'; |
| | | import { NzMessageService, NzModalSubject } from 'ng-zorro-antd'; |
| | | import { DateService } from '@core/services/date.service'; |
| | | import { FormGroup, FormBuilder, Validators } from '@angular/forms'; |
| | | |
| | | @Component({ |
| | | selector: 'app-add-or-edit', |
| | |
| | | styles: [] |
| | | }) |
| | | export class AddOrEditComponent implements OnInit { |
| | | |
| | | cols: DeviceVersion; |
| | | |
| | | constructor() { } |
| | | data: DeviceVersion; |
| | | isSaving = false; |
| | | validateForm: FormGroup; |
| | | constructor( |
| | | private subject: NzModalSubject, |
| | | private formBuilder: FormBuilder |
| | | ) { } |
| | | |
| | | ngOnInit() { |
| | | const validates: DeviceVersion = { |
| | | name: [this.data.name, [Validators.required] ], |
| | | version: [this.data.version == null ? 1 : this.data.version, [Validators.required] ], |
| | | createTime: [this.data.createTime, [Validators.required] ], |
| | | description: [this.data.description, [Validators.required] ] |
| | | }; |
| | | this.validateForm = this.formBuilder.group( |
| | | validates |
| | | ); |
| | | } |
| | | |
| | | close() { |
| | | this.subject.destroy(); |
| | | } |
| | | save($event, value, valid) { |
| | | $event.preventDefault(); |
| | | if (valid) { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[ i ].disable(); |
| | | } |
| | | this.isSaving = true; |
| | | this.data = value; |
| | | this.subject.next( this ); |
| | | }else { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[ i ].markAsDirty(); |
| | | } |
| | | } |
| | | } |
| | | validate() { |
| | | for (const i in this.validateForm.controls) { |
| | | this.validateForm.controls[ i ].markAsDirty(); |
| | | } |
| | | } |
| | | } |
| | |
| | | <pro-header [title]="grid.title"></pro-header> |
| | | <nz-card [nzBordered]="false"> |
| | | <div class="mb-md"> |
| | | <button nz-button (click)="add()" [nzType]="'primary'" [nzSize]="'large'"> |
| | | <button nz-button (click)="addOrModify()" [nzType]="'primary'" [nzSize]="'large'"> |
| | | <i class="anticon anticon-plus"></i><span>新建</span> |
| | | </button> |
| | | <ng-container *ngIf="grid.selectedIndexs.length > 0"> |
| | | <button nz-button [nzSize]="'large'" (click)="remove()">批量删除</button> |
| | | <button nz-button [nzSize]="'large'" (click)="deleteSelected()">批量删除</button> |
| | | </ng-container> |
| | | <nz-input [ngStyle]="{'width': '280px','float':'right'}" [(ngModel)]="queryMap.value" name="" [nzPlaceHolder]="queryMap.text" |
| | | (keyup)="queryTextChanged($event)" (change)="queryTextChanged($event)" ></nz-input> |
| | |
| | | [nzTotal]="grid.total" |
| | | [(nzPageIndex)]="grid.pageIndex" |
| | | [(nzPageSize)]="grid.pageSize" |
| | | [nzLoading]="http.loading" |
| | | [nzLoading]="versionService.loading" |
| | | [nzShowTotal]="true" |
| | | (nzPageIndexChange)="load()" |
| | | (nzDataChange)="dataChange($event)"> |
| | |
| | | [ngStyle]="{'width':col.width,'text-align':col['align'] === undefined?'left':col.align}" > |
| | | <span>{{ col.text }}</span> |
| | | </th> |
| | | <th nz-th><span>操作</span></th> |
| | | </tr> |
| | | </thead> |
| | | <tbody nz-tbody> |
| | |
| | | <!-- 要使用管道,无法自动生成 --> |
| | | </span> |
| | | </td> |
| | | <td nz-td> |
| | | <a (click)="addOrModify(row)">编辑</a> |
| | | <span nz-table-divider></span> |
| | | <nz-popconfirm [nzTitle]="'确定要删除该用户吗?'" [nzOkText]="'Yes'" [nzCancelText]="'No'" (nzOnConfirm)="delete(row.id)" > |
| | | <a nz-popconfirm>删除</a> |
| | | </nz-popconfirm> |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | | </nz-table> |
| | |
| | | import { DataType } from './../../../core/entity/grid'; |
| | | import { AddOrEditComponent } from './add-or-edit/add-or-edit.component'; |
| | | import { Version } from '@angular/compiler/src/util'; |
| | | import { Subject } from 'rxjs/Subject'; |
| | | import '../../../rxjs-operators'; |
| | | import { ToolsService } from '@core/services/tools.service'; |
| | | import { Component, OnInit } from '@angular/core'; |
| | | import { NzMessageService } from 'ng-zorro-antd'; |
| | | import { NzMessageService, NzModalService } from 'ng-zorro-antd'; |
| | | import { ModalHelper } from '@delon/theme'; |
| | | import { HttpClient } from '@angular/common/http'; |
| | | import { environment } from '../../../../environments/environment'; |
| | |
| | | import { Types } from '@core/enum/types.enum'; |
| | | import { Column, Grid, PageBean } from '@core/entity/grid'; |
| | | |
| | | interface DeviceVersion { |
| | | createTime: Column; |
| | | description: Column; |
| | | id?: Column; |
| | | name: Column; |
| | | version: Column; |
| | | export interface DeviceVersion { |
| | | createTime?: Column|any; |
| | | description?: Column|any; |
| | | id?: Column|any; |
| | | name?: Column|any; |
| | | version?: Column|any; |
| | | } |
| | | @Component({ |
| | | selector: 'app-version', |
| | |
| | | styles: [] |
| | | }) |
| | | export class VersionComponent implements OnInit { |
| | | |
| | | grid: Grid = new Grid(null); |
| | | private version: DeviceVersion; |
| | | grid: Grid<DeviceVersion> = new Grid(null); |
| | | queryMap = { text: '请输入名称或型号', value: ''}; |
| | | queryTextStream: Subject<string> = new Subject<string>(); |
| | | private initPage() { |
| | | const columns: DeviceVersion = { |
| | | this.version = { |
| | | name: { |
| | | text: '名称', |
| | | width: '22%' |
| | | width: '18%' |
| | | }, |
| | | version: { |
| | | text: '型号', |
| | | width: '22%' |
| | | width: '18%' |
| | | }, |
| | | createTime: { |
| | | text: '创建时间', |
| | | width: '22%', |
| | | width: '18%', |
| | | type: { |
| | | name: Types.Date, |
| | | format: 'YYYY-MM-DD HH:mm:ss' |
| | |
| | | }, |
| | | description: { |
| | | text: '备注', |
| | | width: '22%' |
| | | width: '18%' |
| | | } |
| | | }; |
| | | this.grid.title = '设备型号'; |
| | | this.grid.setColumns(columns); |
| | | this.grid.setColumns(this.version); |
| | | this.grid.pageSize = 10; |
| | | } |
| | | constructor( |
| | | public http: HttpClient, |
| | | private versionService: VersionService, |
| | | public dateSrv: DateService, |
| | | |
| | | private confirmServ: NzModalService, |
| | | public msgSrv: NzMessageService, |
| | | private modalHelper: ModalHelper, |
| | | private toolsService: ToolsService) {} |
| | | ) {} |
| | | |
| | | ngOnInit() { |
| | | this.initPage(); |
| | |
| | | // this.msgSrv.success('安装用户修改成功!'); |
| | | // }); |
| | | } |
| | | |
| | | add() { |
| | | // const user = {}; |
| | | // this.modalHelper.static(VersionEditComponent, { user }).subscribe(() => { |
| | | // this.load(true); |
| | | // this.msgSrv.success('安装用户保存成功!'); |
| | | // }); |
| | | } |
| | | |
| | | delete(user) { |
| | | this.http.delete(environment.SERVER_BASH_URL + '/user/operate_user/' + user.id).subscribe((res: any) => { |
| | | this.msgSrv.success('安装用户删除成功!'); |
| | | this.load(true); |
| | | // rowData为null时,为新增 |
| | | addOrModify(data) { |
| | | if ( data == null) { |
| | | data = {}; |
| | | } |
| | | const cols = this.version; |
| | | this.modalHelper.static(AddOrEditComponent, { cols , data }).subscribe( |
| | | ( ret: { data: any, close: Function} ) => { |
| | | this.versionService.save(ret.data).subscribe( |
| | | ( res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(true); |
| | | ret.close(); |
| | | this.msgSrv.success('设备型号保存成功!'); |
| | | } |
| | | } |
| | | ); |
| | | }); |
| | | } |
| | | |
| | | remove() { |
| | | delete(...id: number[]) { |
| | | this.versionService.delete( ...id ).subscribe( |
| | | ( res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(true); |
| | | this.msgSrv.success('设备型号删除成功!'); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | |
| | | deleteSelected() { |
| | | this.confirmServ.confirm({ |
| | | title: '批量删除', |
| | | content: '注意:数据一旦删除,将不可恢复!', |
| | | okText: '确定', |
| | | cancelText: '取消' |
| | | }).on('onOk', () => { |
| | | if (this.grid.selectedIndexs != null && this.grid.selectedIndexs.length > 0) { |
| | | const ids = this.grid.selectedIndexs.map( |
| | | (index: number) => { |
| | | return Number.parseInt(this.grid.data[index].id); |
| | | } |
| | | ); |
| | | this.delete( ...ids ); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | import { DeviceVersion } from './version.service'; |
| | | import { ExampleService } from './../../../core/services/example.service'; |
| | | import { _HttpClient } from '@delon/theme'; |
| | | import { environment } from './../../../../environments/environment.prod'; |
| | |
| | | import { PageBean } from '@core/entity/grid'; |
| | | |
| | | |
| | | export interface DeviceVersion { |
| | | createTime?: any; |
| | | description?: string; |
| | | id?: number; |
| | | name?: string; |
| | | version?: number; |
| | | } |
| | | |
| | | @Injectable() |
| | | export class VersionService { |
| | | private urls = { |
| | | edit: environment.SERVER_BASH_URL + '/device-version/page-list' |
| | | edit: environment.SERVER_BASH_URL + '/device-version/page-list', |
| | | save: environment.SERVER_BASH_URL + '/device-version/add-or-modify', |
| | | delete: environment.SERVER_BASH_URL + '/device-version/delete-by-ids' |
| | | }; |
| | | public loading = this.http.loading; |
| | | constructor(private http: _HttpClient) { } |
| | | public getPagingList(page: PageBean, queryText: string): Observable<PageBean> { |
| | | const example = new ExampleService(); |
| | |
| | | const param: PageBean = {pageSize: page.pageSize, pageIndex: page.pageIndex, queryParams: example.getSqlParam()}; |
| | | return this.http.get(this.urls.edit, param); |
| | | } |
| | | public save(data: any): Observable<any> { |
| | | return this.http.post(this.urls.save, data); |
| | | } |
| | | public delete(...ids: number[]): Observable<any> { |
| | | return this.http.post(this.urls.delete, ids); |
| | | } |
| | | } |
| | |
| | | import { I18NService } from '@core/i18n/i18n.service'; |
| | | |
| | | // region: zorro modules |
| | | // Statics |
| | | import 'rxjs/add/observable/throw'; |
| | | |
| | | // Operators |
| | | import 'rxjs/add/operator/catch'; |
| | | import 'rxjs/add/operator/debounceTime'; |
| | | import 'rxjs/add/operator/distinctUntilChanged'; |
| | | import 'rxjs/add/operator/map'; |
| | | import 'rxjs/add/operator/switchMap'; |
| | | import 'rxjs/add/operator/toPromise'; |
| | | |
| | | import { |
| | | // LoggerModule, |