| | |
| | | import { VersionService } from 'app/routes/devices/version/version.service'; |
| | | import { Types } from '@core/enum/types.enum'; |
| | | import { Column, Grid, PageBean } from '@core/entity/grid'; |
| | | import { filter } from 'rxjs/operators/filter'; |
| | | |
| | | export interface DeviceVersion { |
| | | createTime?: Column|any; |
| | |
| | | }, |
| | | version: { |
| | | text: '型号', |
| | | width: '18%' |
| | | width: '18%', |
| | | isSort: true |
| | | }, |
| | | createTime: { |
| | | text: '创建时间', |
| | |
| | | type: { |
| | | name: Types.Date, |
| | | format: 'YYYY-MM-DD HH:mm:ss' |
| | | } |
| | | }, |
| | | isSort: true |
| | | }, |
| | | description: { |
| | | text: '备注', |
| | |
| | | queryTextChanged($event) { |
| | | this.queryTextStream.next(this.queryMap.value); |
| | | } |
| | | load(reload: boolean = false) { |
| | | load(reload: boolean = false) { |
| | | if (reload) { |
| | | this.grid.pageIndex = 1 ; |
| | | } |
| | | // 延时加载避免ExpressionChangedAfterItHasBeenCheckedError |
| | | setTimeout(() => { |
| | | this.grid.loading = true; |
| | | }, 1); |
| | | this.versionService.getPagingList(this.grid, this.queryMap.value).subscribe( |
| | | (res: PageBean) => { |
| | | this.grid.loading = true; |
| | | if (res != null && res.data != null) { |
| | | this.grid.initData(res); |
| | | this.grid.refreshStatus(); |
| | | setTimeout(() => { |
| | | this.grid.loading = false; |
| | | }, 1); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | |
| | | edit() { |
| | | // this.modalHelper.static(VersionEditComponent, { user }).subscribe(() => { |
| | | // this.load(true); |
| | | // this.msgSrv.success('安装用户修改成功!'); |
| | | // }); |
| | | } |
| | | // rowData为null时,为新增 |
| | | addOrModify(data) { |
| | | if ( data == null) { |
| | |
| | | this.versionService.save(ret.data).subscribe( |
| | | ( res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(true); |
| | | this.load(); |
| | | ret.close(); |
| | | this.msgSrv.success('设备型号保存成功!'); |
| | | } |
| | |
| | | this.versionService.delete( ...id ).subscribe( |
| | | ( res: any) => { |
| | | if (res.code === 1) { |
| | | this.load(true); |
| | | this.load(); |
| | | this.msgSrv.success('设备型号删除成功!'); |
| | | } |
| | | } |
| | |
| | | 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); |
| | | const id = this.grid.data[index].id; |
| | | return Number.parseInt(id); |
| | | } |
| | | ); |
| | | this.delete( ...ids ); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | dataChange(res: any) { |
| | | |
| | | } |
| | | |
| | | sort(field: string, value: any) { |
| | | // this.sortMap = {}; |
| | | // this.sortMap[field] = value; |
| | | // this.q.sorter = value ? `${field}_${value}` : ''; |
| | | // this.load(true); |
| | | sort(field: string, value: string) { |
| | | // 删除当前field |
| | | this.grid.sorts = this.grid.sorts.filter( |
| | | (fn: string) => { |
| | | return fn !== field; |
| | | } |
| | | ); |
| | | // 如果value不为null,在排序数组最后加上filed |
| | | if ( value != null ) { |
| | | this.grid.sorts.push(field); |
| | | } |
| | | this.load(); |
| | | } |
| | | |
| | | reset(ls: any[]) { |