parent
c84d06741e
commit
47912fc0b8
@ -0,0 +1,148 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
<!--条件搜索--> |
||||
|
||||
<nz-spin [nzSpinning]="loadingObject.spinning" nzTip="{{loadingObject.msg}}"> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="search(searchForm.value)"> |
||||
<div nz-row> |
||||
<!-- <div nz-col nzSpan="8" *ngIf="roleType == 5 && adminFlag == 1"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">所属部门</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select nzAllowClear formControlName="orgId"> |
||||
<nz-option *ngFor="let item of orgArray" nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div>--> |
||||
|
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="8">设备名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="deviceName" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
<div nz-row> |
||||
<div nz-col nzSpan="24" class="search-button"> |
||||
<button nz-button nzType="primary"><i nz-icon nzType="search" nzTheme="outline"></i>搜索</button> |
||||
<button nz-button nzType="default" (click)="resetForm()"><i nz-icon nzType="reload" nzTheme="outline"></i>重置</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
|
||||
<div class="inner-content"> |
||||
<span>共计 {{dataObject.total?dataObject.total:0}} 条数据</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" (click)="showConfigDeviceModal(null)" ><i nz-icon nzType="plus" nzTheme="outline"></i>新增设备</button> |
||||
</div> |
||||
|
||||
<!--数组表格 --> |
||||
<nz-table #basicTable |
||||
[nzData]="dataObject.list" |
||||
[nzTotal]="dataObject.total" |
||||
[nzFrontPagination]="false" |
||||
[nzLoading]="tableLoading" |
||||
[nzPageIndex]="whereObject.pageNum" |
||||
(nzPageIndexChange)="requestData($event)" |
||||
[nzScroll]="{ x: '1100px'}"> |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="50px">序号</th> |
||||
<th nzWidth="90px">设备类型</th> |
||||
<th nzWidth="100px">设备名称</th> |
||||
<th nzWidth="100px">设备SN</th> |
||||
<th nzWidth="100px">设备KEY</th> |
||||
<th nzWidth="100px">设备IMEI</th> |
||||
<th nzWidth="100px">设备ICCID</th> |
||||
<th nzWidth="110px">创建时间</th> |
||||
<th nzWidth="80px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of basicTable.data;let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td> |
||||
<span *ngIf="data.type == 1">商鹏云打印机</span> |
||||
<span *ngIf="data.type == 2">ZKC云打印机</span> |
||||
</td> |
||||
<td>{{data.deviceName}}</td> |
||||
<td>{{data.deviceSn?data.deviceSn:'未填写'}} </td> |
||||
<td>{{data.deviceKey?data.deviceKey:'未填写'}}</td> |
||||
<td>{{data.deviceImei?data.deviceImei:'未填写'}}</td> |
||||
<td>{{data.deviceIccid?data.deviceIccid:'未填写'}}</td> |
||||
<td>{{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a nz-dropdown [nzDropdownMenu]="menu"> 操作列表 <i nz-icon nzType="down"></i> </a> |
||||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
||||
<ul nz-menu nzSelectable> |
||||
<li nz-menu-item (click)="showDelConfirm(data.id)"><a>删除</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu> |
||||
</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
</nz-spin> |
||||
|
||||
<nz-modal [(nzVisible)]="configDeviceModal" nzTitle="{{configDeviceModalTitle}}" (nzOnCancel)="closeConfigDeviceModal()" nzWidth="500px" [nzFooter]="null"> |
||||
<form nz-form [formGroup]="configDeviceForm"> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired >设备类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<nz-select formControlName="type"> |
||||
<nz-option nzValue="1" nzLabel="商鹏云打印机"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="ZKC云打印机"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired >设备名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="deviceName" [placeholder]="'请输入设备名称'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item *ngIf="configDeviceForm.value.type == 1"> |
||||
<nz-form-label [nzSpan]="6" nzRequired >设备SN</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="deviceSn" [placeholder]="'请输入设备SN号'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item *ngIf="configDeviceForm.value.type == 1"> |
||||
<nz-form-label [nzSpan]="6" nzRequired >设备KEY</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="deviceKey" [placeholder]="'请输入设备KEY'"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item *ngIf="configDeviceForm.value.type == 2"> |
||||
<nz-form-label [nzSpan]="6" nzRequired >设备IMEI</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="deviceImei" [placeholder]="'请输入设备IMEI'"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item *ngIf="configDeviceForm.value.type == 2"> |
||||
<nz-form-label [nzSpan]="6" nzRequired >设备ICCID</nz-form-label> |
||||
<nz-form-control [nzSpan]="14"> |
||||
<input nz-input formControlName="deviceIccid" [placeholder]="'请输入设备ICCID'"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<div style="text-align: center;"> |
||||
<button nz-button nzType="primary" style="width: 150px;" (click)="submitConfigDevice()">确定</button> |
||||
</div> |
||||
</form> |
||||
</nz-modal> |
@ -0,0 +1,25 @@ |
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { DeviceListComponent } from './device-list.component'; |
||||
|
||||
describe('DeviceListComponent', () => { |
||||
let component: DeviceListComponent; |
||||
let fixture: ComponentFixture<DeviceListComponent>; |
||||
|
||||
beforeEach(async(() => { |
||||
TestBed.configureTestingModule({ |
||||
declarations: [ DeviceListComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
})); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(DeviceListComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -0,0 +1,196 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {NzMessageService, NzModalService} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {LocalStorageService} from '../../../services/local-storage.service'; |
||||
import {OilCardService} from '../../../services/oil-card.service'; |
||||
import {OrganizationService} from '../../../services/organization.service'; |
||||
import {CompanyAccountService} from '../../../services/company-account.service'; |
||||
import {ActivatedRoute, Router} from '_@angular_router@9.0.7@@angular/router'; |
||||
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace'; |
||||
import {ValidatorsService} from '../../../services/validators.service'; |
||||
import {DeviceService} from "../../../services/device.service"; |
||||
|
||||
@Component({ |
||||
selector: 'app-device-list', |
||||
templateUrl: './device-list.component.html', |
||||
styleUrls: ['./device-list.component.scss'] |
||||
}) |
||||
export class DeviceListComponent implements OnInit { |
||||
roleType; |
||||
adminFlag; |
||||
loadingObject = { |
||||
spinning: false, |
||||
msg: '加载中' |
||||
}; |
||||
|
||||
dataObject: any = {}; |
||||
tableLoading = true; |
||||
searchForm: FormGroup; |
||||
whereObject: any = {}; |
||||
|
||||
configDeviceModalTitle: string; |
||||
configDeviceModal = false; |
||||
configDeviceForm: FormGroup; |
||||
merStoreId: number; |
||||
|
||||
orgArray = []; |
||||
|
||||
constructor(private modal: NzModalService, |
||||
private message: NzMessageService, |
||||
private store: LocalStorageService, |
||||
private deviceService: DeviceService, |
||||
private organizationService: OrganizationService, |
||||
private activatedRoute: ActivatedRoute, |
||||
private form: FormBuilder) { |
||||
this.roleType = Number(this.store.get(ADMIN_INFO_OBJECT)['secRole'].roleType); |
||||
this.adminFlag = Number(this.store.get(ADMIN_INFO_OBJECT)['secUser'].adminFlag); |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams['merStoreId'] != null) { |
||||
this.merStoreId = queryParams['merStoreId']; |
||||
} |
||||
}); |
||||
|
||||
this.searchForm = this.form.group({ |
||||
companyId: [null], |
||||
merId: [null], |
||||
storeId: [null], |
||||
deviceName: [null], |
||||
}); |
||||
|
||||
this.configDeviceForm = this.form.group({ |
||||
merStoreId: [null], |
||||
type: [null, [Validators.required]], |
||||
deviceName: [null, [Validators.required]], |
||||
deviceSn: [null], |
||||
deviceKey: [null], |
||||
deviceImei: [null], |
||||
deviceIccid: [null], |
||||
}); |
||||
|
||||
this.requestData(1); |
||||
} |
||||
|
||||
/** |
||||
* 请求数据 |
||||
*/ |
||||
requestData(pageNum) { |
||||
this.tableLoading = true; |
||||
this.whereObject['storeId'] = this.merStoreId; |
||||
this.whereObject['pageNum'] = pageNum; |
||||
this.whereObject['pageSize'] = 10; |
||||
this.deviceService.getDeviceList(this.whereObject, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.dataObject = data['return_data']; |
||||
} else { |
||||
this.modal.error(data['return_msg']); |
||||
} |
||||
this.tableLoading = false; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 搜索 |
||||
* @param whereObject 条件 |
||||
*/ |
||||
search(whereObject: object) { |
||||
this.whereObject = whereObject; |
||||
this.requestData(1); |
||||
} |
||||
|
||||
/** |
||||
* 重置 |
||||
*/ |
||||
resetForm(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
|
||||
/** |
||||
* 展示配置设备模态框 |
||||
*/ |
||||
showConfigDeviceModal(deviceData: object) { |
||||
if (deviceData != null) { |
||||
this.configDeviceModalTitle = '修改设备'; |
||||
this.configDeviceForm.patchValue(deviceData); |
||||
} |
||||
if (deviceData == null) { |
||||
this.configDeviceModalTitle = '新增设备'; |
||||
} |
||||
this.configDeviceModal = true; |
||||
} |
||||
|
||||
/** |
||||
* 关闭配置设备模态框 |
||||
*/ |
||||
closeConfigDeviceModal() { |
||||
this.configDeviceModal = false; |
||||
} |
||||
|
||||
/** |
||||
* 提交生成数量 |
||||
*/ |
||||
submitConfigDevice() { |
||||
for (const i in this.configDeviceForm.controls) { |
||||
this.configDeviceForm.controls[i].markAsDirty(); |
||||
this.configDeviceForm.controls[i].updateValueAndValidity(); |
||||
} |
||||
if (this.configDeviceForm.status == null || this.configDeviceForm.status !== 'VALID') { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzContent: '请填写所有必填项', |
||||
}); |
||||
return; |
||||
} |
||||
this.configDeviceForm.value.merStoreId = this.merStoreId; |
||||
this.deviceService.editDevice(this.configDeviceForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.modal.success({ |
||||
nzTitle: '提示', |
||||
nzContent: '操作成功', |
||||
}); |
||||
this.closeConfigDeviceModal(); |
||||
this.requestData(this.whereObject['pageNum']); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'], |
||||
}); |
||||
} |
||||
this.loadingObject.spinning = false; |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 弹出删除对话框 |
||||
*/ |
||||
showDelConfirm(id: number): void { |
||||
this.modal.confirm({ |
||||
nzTitle: '警告', |
||||
nzContent: '确定删除设备吗?', |
||||
nzOkText: '是', |
||||
nzCancelText: '否', |
||||
nzOkType: 'danger', |
||||
nzOnOk: () => this.delData(id) |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 禁用数据 |
||||
*/ |
||||
delData(id: number) { |
||||
this.deviceService.delDevice(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.requestData(this.whereObject['pageNum']); |
||||
} else { |
||||
this.modal.error({ |
||||
nzTitle: '提示', |
||||
nzContent: data['return_msg'] |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,13 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {DeviceListComponent} from './device-list/device-list.component'; |
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'list', component: DeviceListComponent}, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class DeviceRoutingModule { } |
@ -0,0 +1,26 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { DeviceRoutingModule } from './device-routing.module'; |
||||
import { DeviceListComponent } from './device-list/device-list.component'; |
||||
import {FormsModule, ReactiveFormsModule} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {AppCommonModule} from '../../app-common.module'; |
||||
import {NgxEchartsModule} from '_ngx-echarts@4.2.2@ngx-echarts'; |
||||
import {NgZorroAntdModule} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [DeviceListComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
DeviceRoutingModule, |
||||
NgZorroAntdModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
AppCommonModule, |
||||
NgxEchartsModule |
||||
] |
||||
}) |
||||
export class DeviceModule { } |
@ -0,0 +1,65 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class DeviceService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
|
||||
/** |
||||
* 编辑设备 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public editDevice(paramsObject: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'device/editDevice', paramsObject).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 删除设备 |
||||
* |
||||
* @param id 设备id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public delDevice(id: number, callBack) { |
||||
this.http.post(environment.baseUrl + 'device/delDevice', { deviceId: id}).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询设备详情 |
||||
* |
||||
* @param id 设备id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getDetailById(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'device/getDetailById?deviceId=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询设备列表 |
||||
* |
||||
* @param id 设备id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getDeviceList(param: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'device/getDeviceList?' + this.common.getWhereCondition(param)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue