From 47912fc0b8ce886d0b37b145e59c3add0f0f7078 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 15 Jun 2022 23:23:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device-list/device-list.component.html | 148 +++++++++++++ .../device-list/device-list.component.scss | 0 .../device-list/device-list.component.spec.ts | 25 +++ .../device-list/device-list.component.ts | 196 ++++++++++++++++++ src/app/admin/device/device-routing.module.ts | 13 ++ src/app/admin/device/device.module.ts | 26 +++ .../store-list/store-list.component.html | 2 + .../admin/oil-card/oil-card-routing.module.ts | 2 +- src/app/app-routing.module.ts | 5 + src/app/services/device.service.ts | 65 ++++++ 10 files changed, 481 insertions(+), 1 deletion(-) create mode 100644 src/app/admin/device/device-list/device-list.component.html create mode 100644 src/app/admin/device/device-list/device-list.component.scss create mode 100644 src/app/admin/device/device-list/device-list.component.spec.ts create mode 100644 src/app/admin/device/device-list/device-list.component.ts create mode 100644 src/app/admin/device/device-routing.module.ts create mode 100644 src/app/admin/device/device.module.ts create mode 100644 src/app/services/device.service.ts diff --git a/src/app/admin/device/device-list/device-list.component.html b/src/app/admin/device/device-list/device-list.component.html new file mode 100644 index 0000000..24c2f38 --- /dev/null +++ b/src/app/admin/device/device-list/device-list.component.html @@ -0,0 +1,148 @@ + + + + + + +
+
+
+ + +
+ + 设备名称 + + + + +
+ +
+ +
+
+ + +
+
+
+
+ +
+ 共计 {{dataObject.total?dataObject.total:0}} 条数据 +
+ +
+ + + + + + 序号 + 设备类型 + 设备名称 + 设备SN + 设备KEY + 设备IMEI + 设备ICCID + 创建时间 + 操作 + + + + + {{i+1}} + + 商鹏云打印机 + ZKC云打印机 + + {{data.deviceName}} + {{data.deviceSn?data.deviceSn:'未填写'}} + {{data.deviceKey?data.deviceKey:'未填写'}} + {{data.deviceImei?data.deviceImei:'未填写'}} + {{data.deviceIccid?data.deviceIccid:'未填写'}} + {{data.createTime | date : 'yyyy-MM-dd HH:mm:ss'}} + + 操作列表 + + + + + + + +
+
+ + +
+ + + 设备类型 + + + + + + + + + + 设备名称 + + + + + + + 设备SN + + + + + + + 设备KEY + + + + + + + 设备IMEI + + + + + + + 设备ICCID + + + + + +
+ +
+
+
diff --git a/src/app/admin/device/device-list/device-list.component.scss b/src/app/admin/device/device-list/device-list.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/device/device-list/device-list.component.spec.ts b/src/app/admin/device/device-list/device-list.component.spec.ts new file mode 100644 index 0000000..23d9bbc --- /dev/null +++ b/src/app/admin/device/device-list/device-list.component.spec.ts @@ -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; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DeviceListComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DeviceListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/admin/device/device-list/device-list.component.ts b/src/app/admin/device/device-list/device-list.component.ts new file mode 100644 index 0000000..25bc491 --- /dev/null +++ b/src/app/admin/device/device-list/device-list.component.ts @@ -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'] + }); + } + }); + } + +} diff --git a/src/app/admin/device/device-routing.module.ts b/src/app/admin/device/device-routing.module.ts new file mode 100644 index 0000000..f0305f5 --- /dev/null +++ b/src/app/admin/device/device-routing.module.ts @@ -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 { } diff --git a/src/app/admin/device/device.module.ts b/src/app/admin/device/device.module.ts new file mode 100644 index 0000000..78d71f6 --- /dev/null +++ b/src/app/admin/device/device.module.ts @@ -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 { } diff --git a/src/app/admin/merchant-store/store-list/store-list.component.html b/src/app/admin/merchant-store/store-list/store-list.component.html index 5bcf915..da6e1e2 100644 --- a/src/app/admin/merchant-store/store-list/store-list.component.html +++ b/src/app/admin/merchant-store/store-list/store-list.component.html @@ -94,6 +94,8 @@ 增加余额 删除 + + 设备管理 diff --git a/src/app/admin/oil-card/oil-card-routing.module.ts b/src/app/admin/oil-card/oil-card-routing.module.ts index 882af56..702e618 100644 --- a/src/app/admin/oil-card/oil-card-routing.module.ts +++ b/src/app/admin/oil-card/oil-card-routing.module.ts @@ -3,7 +3,7 @@ import { Routes, RouterModule } from '@angular/router'; import {OilCardListComponent} from './oil-card-list/oil-card-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 {OilCardOrderComponent} from "./oil-card-order/oil-card-order.component"; +import {OilCardOrderComponent} from './oil-card-order/oil-card-order.component'; const routes: Routes = [ { path: 'list', component: OilCardListComponent}, diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 31a72a3..1e9d55f 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -127,6 +127,11 @@ const routes: Routes = [ loadChildren: () => import('./admin/gas-oil-price/gas-oil-price.module').then(m => m.GasOilPriceModule), canActivate: [InitGuardService] }, + { + path: 'device', + loadChildren: () => import('./admin/device/device.module').then(m => m.DeviceModule), + canActivate: [InitGuardService] + }, { path: 'api-product', loadChildren: () => import('./admin/api-product/api-product.module').then(m => m.ApiProductModule), diff --git a/src/app/services/device.service.ts b/src/app/services/device.service.ts new file mode 100644 index 0000000..7a9703a --- /dev/null +++ b/src/app/services/device.service.ts @@ -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); + }); + } + +}