From 596ff57f2d370bb6b0ced8045c5e6ab8612b7fc0 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Sun, 28 Mar 2021 17:03:22 +0800 Subject: [PATCH] 1 --- .../coupon-list/coupon-list.component.html | 4 +- .../sinopec-config.component.html | 48 +++++++++ .../sinopec-config.component.scss | 0 .../sinopec-config.component.ts | 90 +++++++++++++++++ .../sinopec-edit/sinopec-edit.component.html | 48 +++++++++ .../sinopec-edit/sinopec-edit.component.scss | 6 ++ .../sinopec-edit/sinopec-edit.component.ts | 99 +++++++++++++++++++ src/app/admin/system/system-routing.module.ts | 4 + src/app/admin/system/system.module.ts | 4 +- src/app/services/system.service.ts | 59 ++++++++++- 10 files changed, 358 insertions(+), 4 deletions(-) create mode 100644 src/app/admin/system/sinopec-config/sinopec-config.component.html create mode 100644 src/app/admin/system/sinopec-config/sinopec-config.component.scss create mode 100644 src/app/admin/system/sinopec-config/sinopec-config.component.ts create mode 100644 src/app/admin/system/sinopec-edit/sinopec-edit.component.html create mode 100644 src/app/admin/system/sinopec-edit/sinopec-edit.component.scss create mode 100644 src/app/admin/system/sinopec-edit/sinopec-edit.component.ts diff --git a/src/app/admin/coupon/coupon-list/coupon-list.component.html b/src/app/admin/coupon/coupon-list/coupon-list.component.html index e75d625..c204da8 100644 --- a/src/app/admin/coupon/coupon-list/coupon-list.component.html +++ b/src/app/admin/coupon/coupon-list/coupon-list.component.html @@ -131,8 +131,8 @@ - - + + diff --git a/src/app/admin/system/sinopec-config/sinopec-config.component.html b/src/app/admin/system/sinopec-config/sinopec-config.component.html new file mode 100644 index 0000000..c72542e --- /dev/null +++ b/src/app/admin/system/sinopec-config/sinopec-config.component.html @@ -0,0 +1,48 @@ + + + + +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 编号 + 客户AppId + 客户密码 + 客户编码 + + 操作 + + + + + {{i+1}} + {{data.appId}} + {{data.appSecret}} + {{data.code}} + + + + + + +
+ + + diff --git a/src/app/admin/system/sinopec-config/sinopec-config.component.scss b/src/app/admin/system/sinopec-config/sinopec-config.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/system/sinopec-config/sinopec-config.component.ts b/src/app/admin/system/sinopec-config/sinopec-config.component.ts new file mode 100644 index 0000000..0658d46 --- /dev/null +++ b/src/app/admin/system/sinopec-config/sinopec-config.component.ts @@ -0,0 +1,90 @@ +import { Component, OnInit } from '@angular/core'; +import {environment} from '../../../../environments/environment'; +import {FormBuilder, FormGroup} from '@angular/forms'; +import {MerchantService} from '../../../services/merchant.service'; +import {IconService} from '../../../services/icon.service'; +import {NzMessageService} from 'ng-zorro-antd'; +import {Router} from '@angular/router'; +import {SystemService} from '../../../services/system.service'; + +@Component({ + selector: 'app-sinopec-config', + templateUrl: './sinopec-config.component.html', + styleUrls: ['./sinopec-config.component.scss'] +}) +export class SinopecConfigComponent implements OnInit { + + WEB_SERVE_URL = environment.imageUrl; + searchForm: FormGroup; // 搜索框 + requestData = []; // 列表数据 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + + constructor( + private form: FormBuilder, + private system: SystemService, + private iconService: IconService, + private message: NzMessageService, + private router: Router, + ) { + } + + ngOnInit(): void { + this.init(); + } + + public init(): void { + this.searchForm = this.form.group({ + merchantKey: [null], + merchantName: [null], + telephone: [null], + status: [null], + }); + this.getRequest(true, this.searchForm.value); + } + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + this.loading = false; + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.system.getListSinopecConfig(whereObject, data => { + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 重置 + public resetForm(): void { + this.searchForm.reset(); + } + + // 修改 + public getEdit(id: number): void { + this.router.navigate(['/admin/system/sinopec-edit'], { + queryParams: { + merchantId: id + } + }).then(r => console.log(r)); + } + + // 查看详情 + public getDetail(id: number): void { + this.router.navigate(['/admin/system/sinopec-detail'], { + queryParams: { + merchantId: id + } + }).then(r => console.log(r)); + } + +} diff --git a/src/app/admin/system/sinopec-edit/sinopec-edit.component.html b/src/app/admin/system/sinopec-edit/sinopec-edit.component.html new file mode 100644 index 0000000..9f000bb --- /dev/null +++ b/src/app/admin/system/sinopec-edit/sinopec-edit.component.html @@ -0,0 +1,48 @@ + + + + 系统管理 + + + 编辑配置 + + + + + +
+
+
+ + 客户AppId + + + + +
+
+ + 客户密码 + + + + +
+
+ + 客户编码 + + + + +
+
+
+
+ + +
+
+
+ +
diff --git a/src/app/admin/system/sinopec-edit/sinopec-edit.component.scss b/src/app/admin/system/sinopec-edit/sinopec-edit.component.scss new file mode 100644 index 0000000..ac60fb8 --- /dev/null +++ b/src/app/admin/system/sinopec-edit/sinopec-edit.component.scss @@ -0,0 +1,6 @@ +button { + margin-left: 8px; +} +:host ::ng-deep .ant-upload { + background-color: #ffffff; +} diff --git a/src/app/admin/system/sinopec-edit/sinopec-edit.component.ts b/src/app/admin/system/sinopec-edit/sinopec-edit.component.ts new file mode 100644 index 0000000..976a932 --- /dev/null +++ b/src/app/admin/system/sinopec-edit/sinopec-edit.component.ts @@ -0,0 +1,99 @@ +import { Component, OnInit } from '@angular/core'; +import {FormBuilder, FormGroup, Validators} from '@angular/forms'; +import {environment} from '../../../../environments/environment'; +import {MerchantService} from '../../../services/merchant.service'; +import {NzMessageService} from 'ng-zorro-antd'; +import {ActivatedRoute} from '@angular/router'; +import {SystemService} from '../../../services/system.service'; + +@Component({ + selector: 'app-sinopec-edit', + templateUrl: './sinopec-edit.component.html', + styleUrls: ['./sinopec-edit.component.scss'] +}) +export class SinopecEditComponent implements OnInit { + + validateForm!: FormGroup; + data: any; + editFlag = false; + id: number; + WEB_SERVE_URL = environment.baseUrl; + + constructor( + private fb: FormBuilder, + private system: SystemService, + private message: NzMessageService, // 信息提示 + private activatedRoute: ActivatedRoute, + ) { + } + + ngOnInit(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.sinopecId != null) { + this.editFlag = true; + this.id = queryParams.sinopecId; + this.getDetails(queryParams.sinopecId); + } + }); + this.validateForm = this.fb.group({ + appId: [null, [Validators.required]], + appSecret: [null, [Validators.required]], + code: [null, [Validators.required]], + }); + } + + // 返回 + getBack() { + history.back(); + } + + // 重置 + public resetForm(): void { + this.validateForm.reset(); + } + + // 保存 + public getSave(): void { + // tslint:disable-next-line:forin + for (const i in this.validateForm.controls) { + this.validateForm.controls[i].markAsDirty(); + this.validateForm.controls[i].updateValueAndValidity(); + if (this.validateForm.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + if (this.editFlag) { + this.validateForm.value.id = this.id; + this.system.updateMerchant(this.validateForm.value, data => { + if (data['return_code'] === '000000') { + this.getBack(); + this.message.success('修改成功'); + } else { + this.message.create('error', data['return_msg']); + } + }); + } else { + this.system.insertMerchant(this.validateForm.value, data => { + if (data['return_code'] === '000000') { + this.getBack(); + this.message.success('添加成功'); + } else { + this.message.create('error', data['return_msg']); + } + }); + } + } + + + + public getDetails(id) { + this.system.findById(id, data => { + if (data['return_code'] === '000000') { + this.validateForm.patchValue(data['return_data']); + } else { + this.message.create('error', data['return_msg']); + } + }); + } +} diff --git a/src/app/admin/system/system-routing.module.ts b/src/app/admin/system/system-routing.module.ts index 9b210c8..d682601 100644 --- a/src/app/admin/system/system-routing.module.ts +++ b/src/app/admin/system/system-routing.module.ts @@ -7,6 +7,8 @@ import {SystemUserComponent} from './system-user/system-user.component'; import {PermissionComponent} from './permission/permission.component'; import {MenuComponent} from './menu/menu.component'; import {PositionRelComponent} from './position-rel/position-rel.component'; +import {SinopecConfigComponent} from './sinopec-config/sinopec-config.component'; +import {SinopecEditComponent} from './sinopec-edit/sinopec-edit.component'; const routes: Routes = [ { path: 'systemorganization', component: SystemOrganizationComponent}, @@ -16,6 +18,8 @@ const routes: Routes = [ { path: 'menu', component: MenuComponent }, { path: 'permission', component: PermissionComponent }, { path: 'positionrel', component: PositionRelComponent }, + { path: 'sinopec-config', component: SinopecConfigComponent }, + { path: 'sinopec-edit', component: SinopecEditComponent }, ]; @NgModule({ diff --git a/src/app/admin/system/system.module.ts b/src/app/admin/system/system.module.ts index 516d838..1a39276 100644 --- a/src/app/admin/system/system.module.ts +++ b/src/app/admin/system/system.module.ts @@ -16,8 +16,10 @@ import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; import { PositionRelComponent } from './position-rel/position-rel.component'; import {AppCommonModule} from '../../app-common.module'; +import { SinopecConfigComponent } from './sinopec-config/sinopec-config.component'; +import { SinopecEditComponent } from './sinopec-edit/sinopec-edit.component'; @NgModule({ - declarations: [SystemOrganizationComponent, SystemRoleComponent, SystemRoleShowComponent, SystemUserComponent, MenuComponent, PermissionComponent, PositionRelComponent], + declarations: [SystemOrganizationComponent, SystemRoleComponent, SystemRoleShowComponent, SystemUserComponent, MenuComponent, PermissionComponent, PositionRelComponent, SinopecConfigComponent, SinopecEditComponent], imports: [ CommonModule, SystemRoutingModule, diff --git a/src/app/services/system.service.ts b/src/app/services/system.service.ts index f9b0e54..76fe726 100644 --- a/src/app/services/system.service.ts +++ b/src/app/services/system.service.ts @@ -1,6 +1,7 @@ import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {environment} from '../../environments/environment'; +import {CommonsService} from './commons.service'; /** * 胡锐 @@ -11,7 +12,10 @@ import {environment} from '../../environments/environment'; }) export class SystemService { - constructor(private http: HttpClient) { } + constructor( + private http: HttpClient, + private common: CommonsService + ) { } /** * 删除菜单 @@ -110,4 +114,57 @@ export class SystemService { callBack(data); }); } + + /** + * 查询中石化配置列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getListSinopecConfig(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'secSinopecConfig/getListSinopecConfig?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + /** + * 新增商户 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public insertMerchant(params: object, callBack) { + this.http.post(environment.baseUrl + 'secSinopecConfig/insertSinopec', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 修改商户 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public updateMerchant(params: object, callBack) { + this.http.post(environment.baseUrl + 'secSinopecConfig/updateSinopec', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 根据id查询详情 + * + * @param sinopecId id + * @param callBack 回调 + */ + public findById(sinopecId: number, callBack) { + this.http.get(environment.baseUrl + 'secSinopecConfig/findById?sinopecId=' + sinopecId).subscribe(data => { + callBack(data); + }); + } + + + }