提交代码

pull/1/head
胡锐 2 years ago
parent c84d06741e
commit 47912fc0b8
  1. 148
      src/app/admin/device/device-list/device-list.component.html
  2. 0
      src/app/admin/device/device-list/device-list.component.scss
  3. 25
      src/app/admin/device/device-list/device-list.component.spec.ts
  4. 196
      src/app/admin/device/device-list/device-list.component.ts
  5. 13
      src/app/admin/device/device-routing.module.ts
  6. 26
      src/app/admin/device/device.module.ts
  7. 2
      src/app/admin/merchant-store/store-list/store-list.component.html
  8. 2
      src/app/admin/oil-card/oil-card-routing.module.ts
  9. 5
      src/app/app-routing.module.ts
  10. 65
      src/app/services/device.service.ts

@ -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 { }

@ -94,6 +94,8 @@
<a *ngIf="'BTN_add_blance' | button" (click)="getRecharge(data.id)">增加余额</a> <a *ngIf="'BTN_add_blance' | button" (click)="getRecharge(data.id)">增加余额</a>
<nz-divider *ngIf="'BTN_add_blance' | button" nzType="vertical"></nz-divider> <nz-divider *ngIf="'BTN_add_blance' | button" nzType="vertical"></nz-divider>
<a (click)="getDelete(data.id)">删除</a> <a (click)="getDelete(data.id)">删除</a>
<nz-divider nzType="vertical"></nz-divider>
<a [routerLink]="['/admin/device/list']" [queryParams]="{ merStoreId: data.id}">设备管理</a>
</td> </td>
</tbody> </tbody>
</nz-table> </nz-table>

@ -3,7 +3,7 @@ import { Routes, RouterModule } from '@angular/router';
import {OilCardListComponent} from './oil-card-list/oil-card-list.component'; import {OilCardListComponent} from './oil-card-list/oil-card-list.component';
import {OilCardRecordListComponent} from './oil-card-record-list/oil-card-record-list.component'; import {OilCardRecordListComponent} from './oil-card-record-list/oil-card-record-list.component';
import {OilCardOpRecordListComponent} from './oil-card-op-record-list/oil-card-op-record-list.component'; import {OilCardOpRecordListComponent} from './oil-card-op-record-list/oil-card-op-record-list.component';
import {OilCardOrderComponent} from "./oil-card-order/oil-card-order.component"; import {OilCardOrderComponent} from './oil-card-order/oil-card-order.component';
const routes: Routes = [ const routes: Routes = [
{ path: 'list', component: OilCardListComponent}, { path: 'list', component: OilCardListComponent},

@ -127,6 +127,11 @@ const routes: Routes = [
loadChildren: () => import('./admin/gas-oil-price/gas-oil-price.module').then(m => m.GasOilPriceModule), loadChildren: () => import('./admin/gas-oil-price/gas-oil-price.module').then(m => m.GasOilPriceModule),
canActivate: [InitGuardService] canActivate: [InitGuardService]
}, },
{
path: 'device',
loadChildren: () => import('./admin/device/device.module').then(m => m.DeviceModule),
canActivate: [InitGuardService]
},
{ {
path: 'api-product', path: 'api-product',
loadChildren: () => import('./admin/api-product/api-product.module').then(m => m.ApiProductModule), loadChildren: () => import('./admin/api-product/api-product.module').then(m => m.ApiProductModule),

@ -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…
Cancel
Save