From e3fc022d46b4d8e0bc4d7ff5d6aa0f3a454306b9 Mon Sep 17 00:00:00 2001 From: yuanye Date: Tue, 16 Mar 2021 17:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store-detail/store-detail.component.html | 19 ++- .../store-detail/store-detail.component.ts | 27 ++++- .../store-edit/store-edit.component.html | 52 +++++++-- .../store-edit/store-edit.component.scss | 1 + .../store-edit/store-edit.component.ts | 108 ++++++++++++------ .../store-list/store-list.component.html | 53 +++------ .../store-list/store-list.component.ts | 90 +++++++-------- .../merchant-detail.component.ts | 3 +- .../merchant-edit/merchant-edit.component.ts | 2 +- .../merchant-list.component.html | 2 +- .../merchant-list/merchant-list.component.ts | 7 +- src/app/services/merchant-store.service.ts | 39 ++++--- src/index.html | 2 + tsconfig.json | 3 +- 14 files changed, 255 insertions(+), 153 deletions(-) diff --git a/src/app/admin/merchant-store/store-detail/store-detail.component.html b/src/app/admin/merchant-store/store-detail/store-detail.component.html index 0a0860f..18ed2bc 100644 --- a/src/app/admin/merchant-store/store-detail/store-detail.component.html +++ b/src/app/admin/merchant-store/store-detail/store-detail.component.html @@ -1 +1,18 @@ -

store-detail works!

+
+ + {{data.telephone}} + {{data['storeKey']}} + {{data.storeName}} + {{data.address}} + {{data.longitude}} + {{data.latitude}} + + {{data.createTime | date: 'yyyy-MM-dd'}} + + + {{data.updateTime | date: 'yyyy-MM-dd'}} + + {{data.operatorName }} + + +
diff --git a/src/app/admin/merchant-store/store-detail/store-detail.component.ts b/src/app/admin/merchant-store/store-detail/store-detail.component.ts index 52c49e9..8f1ac20 100644 --- a/src/app/admin/merchant-store/store-detail/store-detail.component.ts +++ b/src/app/admin/merchant-store/store-detail/store-detail.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import {NzMessageService} from 'ng-zorro-antd'; +import {ActivatedRoute} from '@angular/router'; +import {MerchantStoreService} from '../../../services/merchant-store.service'; @Component({ selector: 'app-store-detail', @@ -7,9 +10,31 @@ import { Component, OnInit } from '@angular/core'; }) export class StoreDetailComponent implements OnInit { - constructor() { } + data: any = {}; + id: number; + constructor( + private merchantStore: MerchantStoreService, + private message: NzMessageService, // 信息提示 + private activatedRoute: ActivatedRoute, + ) { } ngOnInit(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.storeId != null) { + this.id = queryParams.storeId; + this.getDetails(queryParams.storeId); + } + }); } + // 查询详情 + public getDetails(id: number) { + this.merchantStore.getMerchantStoreById(id , data => { + this.data = data['return_data']; + + }); + } + + + } diff --git a/src/app/admin/merchant-store/store-edit/store-edit.component.html b/src/app/admin/merchant-store/store-edit/store-edit.component.html index ccabe2f..783dc58 100644 --- a/src/app/admin/merchant-store/store-edit/store-edit.component.html +++ b/src/app/admin/merchant-store/store-edit/store-edit.component.html @@ -15,9 +15,9 @@
- 登录手机号 + 登录手机号 - +
@@ -36,25 +36,63 @@
- 门店编号 + 门店编号 - +
- 门店名称 + 门店名称 - +
+ + 地址维度 + + + + +
+
+ + 地址经度 + + + + +
+
门店地址 - + + + +
+
+ + 设置定位 + +
+
+ + + + + + + +
+ +
+ +
+
diff --git a/src/app/admin/merchant-store/store-edit/store-edit.component.scss b/src/app/admin/merchant-store/store-edit/store-edit.component.scss index ac60fb8..800400d 100644 --- a/src/app/admin/merchant-store/store-edit/store-edit.component.scss +++ b/src/app/admin/merchant-store/store-edit/store-edit.component.scss @@ -4,3 +4,4 @@ button { :host ::ng-deep .ant-upload { background-color: #ffffff; } +#container {width:800px; height: 500px; } diff --git a/src/app/admin/merchant-store/store-edit/store-edit.component.ts b/src/app/admin/merchant-store/store-edit/store-edit.component.ts index 105fbb8..4ec4c9d 100644 --- a/src/app/admin/merchant-store/store-edit/store-edit.component.ts +++ b/src/app/admin/merchant-store/store-edit/store-edit.component.ts @@ -2,9 +2,13 @@ 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, NzUploadFile} from 'ng-zorro-antd'; +import {NzMessageService} from 'ng-zorro-antd'; import {ActivatedRoute} from '@angular/router'; import {ValidatorsService} from '../../../services/validators.service'; +import {MerchantStoreService} from '../../../services/merchant-store.service'; + +declare var AMap: any; // 一定要声明AMap,要不然报错找不到AMap +declare var AMapUI: any; @Component({ selector: 'app-store-edit', @@ -20,12 +24,10 @@ export class StoreEditComponent implements OnInit { passwordVisible = false; logoFile = []; WEB_SERVE_URL = environment.baseUrl; - previewImage: string | undefined = ''; previewVisible = false; - constructor( private fb: FormBuilder, - private merchant: MerchantService, + private merchantStore: MerchantStoreService, private message: NzMessageService, // 信息提示 private activatedRoute: ActivatedRoute, ) { @@ -33,25 +35,29 @@ export class StoreEditComponent implements OnInit { ngOnInit(): void { this.activatedRoute.queryParams.subscribe(queryParams => { - if (queryParams.merchantId != null) { + if (queryParams.storeId != null) { this.editFlag = true; - this.id = queryParams.merchantId; - this.getDetails(queryParams.merchantId); + this.id = queryParams.storeId; + this.getDetails(queryParams.storeId); + } else { + this.getMap (); } }); this.validateForm = this.fb.group({ - loginTelephone: [null, [Validators.required, ValidatorsService.mobile]], + telephone: [null, [Validators.required, ValidatorsService.mobile]], password: [null, [Validators.required, ValidatorsService.minLength(6)]], storeKey: [null, [Validators.required, ValidatorsService.maxLength(10)]], - storeKeyName: [null, [Validators.required, ValidatorsService.pwdLength(2, 12)]], - telephone: [null, [Validators.required]], + storeName: [null, [Validators.required]], address: [null, [Validators.required]], - latitude: [null, [Validators.required]], - longitude: [null, [Validators.required]], + latitude: [29.553134, [Validators.required]], + longitude: [106.565428, [Validators.required]], status: [null], + companyId: [null], + merchantId: [null], createTime: [null], secUser: {}, }); + } // 返回 @@ -75,8 +81,8 @@ export class StoreEditComponent implements OnInit { return; } } - - this.validateForm.value['secUser']['telephone'] = this.validateForm.value.loginTelephone; + console.log(this.validateForm.value); + this.validateForm.value['secUser']['telephone'] = this.validateForm.value.telephone; this.validateForm.value['secUser']['password'] = this.validateForm.value.password; if (this.logoFile.length !== 0) { if (this.logoFile[0]['response'] != null) { @@ -85,10 +91,9 @@ export class StoreEditComponent implements OnInit { this.validateForm.value.merchantLogo = this.logoFile[0].name; } } - console.log(this.validateForm.value); if (this.editFlag) { this.validateForm.value.id = this.id; - this.merchant.updateMerchant(this.validateForm.value, data => { + this.merchantStore.updateMerchantStore(this.validateForm.value, data => { if (data['return_code'] === '000000') { this.getBack(); this.message.success('修改成功'); @@ -98,8 +103,7 @@ export class StoreEditComponent implements OnInit { }); } else { - this.merchant.insertMerchant(this.validateForm.value, data => { - console.log(data); + this.merchantStore.insertMerchantStore(this.validateForm.value, data => { if (data['return_code'] === '000000') { this.getBack(); this.message.success('添加成功'); @@ -111,26 +115,66 @@ export class StoreEditComponent implements OnInit { } public getDetails(id) { - this.merchant.getMerchantById(id, data => { + this.merchantStore.getMerchantStoreById(id, data => { if (data['return_code'] === '000000') { - data['return_data'].loginTelephone = data['return_data'].secUser.loginName; + data['return_data'].telephone = data['return_data'].secUser.loginName; data['return_data'].password = data['return_data'].secUser.password; - if (data['return_data']['merchantLogo'] != null && data['return_data']['merchantLogo'] !== '') { - const logo = String(data['return_data']['merchantLogo']); - const logoArray = []; - logoArray.push( - { - uid: 1, - name: logo, - status: 'done', - url: environment.imageUrl + logo - }); - this.logoFile = logoArray; - } this.validateForm.patchValue(data['return_data']); + this.getMap (); } else { this.message.create('error', data['return_msg']); } }); } + + // 地图要放到函数里。 + getMap() { + // tslint:disable-next-line:variable-name + AMapUI.loadUI(['misc/PositionPicker'], PositionPicker => { + console.log(this.validateForm.value); + const map = new AMap.Map('container', { + resizeEnable: true, + scrollWheel: false, + center: [this.validateForm.value.longitude, this.validateForm.value.latitude], // 初始化中心点坐标 + zoom: 13, + }); + AMap.plugin(['AMap.ToolBar', 'AMap.Autocomplete'], () => { + const toolbar = new AMap.ToolBar(); + map.addControl(toolbar); + }); + const autoOptions = { + // input 为绑定输入提示功能的input的DOM ID + input: 'input' + }; + const autoComplete = new AMap.Autocomplete(autoOptions); + const placeSearch = new AMap.PlaceSearch({ + map: map + }); // 构造地点查询类 + AMap.event.addListener(autoComplete, 'select', select); // 注册监听,当选中某条记录时会触发 + function select(e) { + placeSearch.setCity(e.poi.adcode); + placeSearch.search(e.poi.name); // 关键字查询查询 + } + const positionPicker = new PositionPicker({ + mode: 'dragMap', + map: map + }); + positionPicker.on('success', positionResult => { + positionResult['latitude'] = positionResult.position.lat; + positionResult['longitude'] = positionResult.position.lng; + this.validateForm.patchValue(positionResult); + }); + positionPicker.on('fail', positionResult => { + console.log(positionResult); + }); + positionPicker.setMode('dragMap'); + positionPicker.start(); + map.panBy(0, 1); + + map.addControl(new AMap.ToolBar({ + liteStyle: true + })); + }); + } + } 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 d3ee79b..ad94c54 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 @@ -6,41 +6,23 @@
+
- 商户编号 - - - - -
-
- - 商户名称 + 门店名称 - +
- 商户电话 + 门店电话
-
- - 商户状态 - - - - - - - -
@@ -55,6 +37,10 @@
共计 {{total}} 条数据 + + 商戶名称: + {{name}} +
@@ -74,35 +60,26 @@ 编号 - 商户编号 - 商户名称 - 商户LOGO - 商户电话 + 门店编号 + 门店名称 + 门店电话 创建时间 - 状态 操作 {{i+1}} - {{data.merchantKey}} - {{data.merchantName}} - - - + {{data.storeKey}} + {{data.storeName}} {{data.telephone}} {{data.createTime | date: 'yyyy-MM-dd HH:mm'}} - {{data.status ===1 ? '正常' : '禁用'}} - - - + - - + diff --git a/src/app/admin/merchant-store/store-list/store-list.component.ts b/src/app/admin/merchant-store/store-list/store-list.component.ts index 13d2c62..f8c7d2a 100644 --- a/src/app/admin/merchant-store/store-list/store-list.component.ts +++ b/src/app/admin/merchant-store/store-list/store-list.component.ts @@ -3,7 +3,7 @@ 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 {ActivatedRoute, Router} from '@angular/router'; import {CommonsService} from '../../../services/commons.service'; import {MerchantStoreService} from '../../../services/merchant-store.service'; @@ -20,31 +20,39 @@ export class StoreListComponent implements OnInit { pageNum = 1; // 页码 pageSize = 10; // 条码 loading = true; - + id = null; + name: string; constructor( private form: FormBuilder, private merchantStore: MerchantStoreService, private iconService: IconService, private message: NzMessageService, private router: Router, + private activatedRoute: ActivatedRoute, private common: CommonsService ) { } ngOnInit(): void { this.init(); + } public init(): void { + this.activatedRoute.queryParams.subscribe(queryParams => { + if (queryParams.merchantId != null) { + this.id = queryParams.merchantId; + this.name = queryParams.name; + } + }); this.searchForm = this.form.group({ - merchantKey: [null], - merchantName: [null], + storeName: [null], telephone: [null], - status: [null], }); this.getRequest(true, this.searchForm.value); } + // 查询列表 public getRequest(reset: boolean = false, whereObject: object) { @@ -54,14 +62,28 @@ export class StoreListComponent implements OnInit { } whereObject['pageNum'] = this.pageNum; whereObject['pageSize'] = this.pageSize; - this.merchantStore.getStoreListByMerchant(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']); - } - }); + if (this.id == null) { + this.merchantStore.getStoreListByMerchant(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']); + } + }); + } else { + whereObject['merchantId'] = this.id; + this.merchantStore.getStoreListByCompany(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']); + } + }); + } + + } // 重置 @@ -69,29 +91,12 @@ export class StoreListComponent implements OnInit { this.searchForm.reset(); } - // 禁用商户 - public disableMerchant(id): void { - const message = '是否禁用商户'; - this.common.showConfirm(message, data => { - if (data) { - this.merchantStore.disableMerchant(id, dataReturn => { - if (dataReturn['return_code'] === '000000') { - this.message.success('操作成功'); - this.getRequest(false , this.searchForm.value); - } else { - this.message.warning(dataReturn['return_msg']); - } - }); - } - }); - } - - // 启动商户 - public enableMerchant(id): void { - const message = '是否启用商户'; + // 禁用门店 + public getDelete(id): void { + const message = '是否删除门店'; this.common.showConfirm(message, data => { if (data) { - this.merchantStore.enableMerchant(id, dataReturn => { + this.merchantStore.deleteMerchantStore(id, dataReturn => { if (dataReturn['return_code'] === '000000') { this.message.success('操作成功'); this.getRequest(false , this.searchForm.value); @@ -103,31 +108,22 @@ export class StoreListComponent implements OnInit { }); } - // 修改 public getEdit(id: number): void { - this.router.navigate(['/admin/merchant/merchant-edit'], { + this.router.navigate(['/admin/merchantStore/store-edit'], { queryParams: { - merchantId: id + storeId: id } }).then(r => console.log(r)); } // 查看详情 public getDetail(id: number): void { - this.router.navigate(['/admin/merchant/merchant-detail'], { + this.router.navigate(['/admin/merchantStore/store-detail'], { queryParams: { - merchantId: id + storeId: id } }).then(r => console.log(r)); } - // 查看门店列表 - public getList(id: number): void { - this.router.navigate(['/admin/merchant/merchant-detail'], { - queryParams: { - merchantId: id - } - }).then(r => console.log(r)); - } } diff --git a/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts b/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts index f33cfad..88d34a1 100644 --- a/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts +++ b/src/app/admin/merchant/merchant-detail/merchant-detail.component.ts @@ -27,11 +27,10 @@ export class MerchantDetailComponent implements OnInit { }); } - // 查询课程详情 + // 查询详情 public getDetails(id: number) { this.merchant.getMerchantById(id , data => { this.data = data['return_data']; - console.log(data); }); } diff --git a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts index 13de7f4..f82331a 100644 --- a/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts +++ b/src/app/admin/merchant/merchant-edit/merchant-edit.component.ts @@ -96,7 +96,7 @@ export class MerchantEditComponent implements OnInit { this.validateForm.value.merchantLogo = this.logoFile[0].name; } } - console.log(this.validateForm.value); + if (this.editFlag) { this.validateForm.value.id = this.id; this.merchant.updateMerchant(this.validateForm.value, data => { diff --git a/src/app/admin/merchant/merchant-list/merchant-list.component.html b/src/app/admin/merchant/merchant-list/merchant-list.component.html index 1bbf77d..9ac6b71 100644 --- a/src/app/admin/merchant/merchant-list/merchant-list.component.html +++ b/src/app/admin/merchant/merchant-list/merchant-list.component.html @@ -99,7 +99,7 @@ - + diff --git a/src/app/admin/merchant/merchant-list/merchant-list.component.ts b/src/app/admin/merchant/merchant-list/merchant-list.component.ts index 7fff044..8a6d7fa 100644 --- a/src/app/admin/merchant/merchant-list/merchant-list.component.ts +++ b/src/app/admin/merchant/merchant-list/merchant-list.component.ts @@ -123,10 +123,11 @@ export class MerchantListComponent implements OnInit { } // 查看门店列表 - public getList(id: number): void { - this.router.navigate(['/admin/merchant/merchant-detail'], { + public getList(id: number , merchantName: string): void { + this.router.navigate(['/admin/merchantStore/store-list'], { queryParams: { - merchantId: id + merchantId: id, + name: merchantName, } }).then(r => console.log(r)); } diff --git a/src/app/services/merchant-store.service.ts b/src/app/services/merchant-store.service.ts index bf52d11..8c3a479 100644 --- a/src/app/services/merchant-store.service.ts +++ b/src/app/services/merchant-store.service.ts @@ -25,6 +25,18 @@ export class MerchantStoreService { }); } + /** + * 超级管理员查询门店列表 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getStoreListByCompany(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'highMerchantStore/getStoreListByCompany?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + /** * 新增商户 * @@ -32,8 +44,8 @@ export class MerchantStoreService { * @param callBack 回调 * @return data 返回结果 */ - public insertMerchant(params: object, callBack) { - this.http.post(environment.baseUrl + 'highMerchant/insertMerchant', params).subscribe(data => { + public insertMerchantStore(params: object, callBack) { + this.http.post(environment.baseUrl + 'highMerchantStore/insertMerchantStore', params).subscribe(data => { callBack(data); }); } @@ -45,8 +57,8 @@ export class MerchantStoreService { * @param callBack 回调 * @return data 返回结果 */ - public updateMerchant(params: object, callBack) { - this.http.post(environment.baseUrl + 'highMerchant/updateMerchant', params).subscribe(data => { + public updateMerchantStore(params: object, callBack) { + this.http.post(environment.baseUrl + 'highMerchantStore/updateMerchantStore', params).subscribe(data => { callBack(data); }); } @@ -57,8 +69,8 @@ export class MerchantStoreService { * @param merchantId 职位id * @param callBack 回调 */ - public getMerchantById(merchantId: number, callBack) { - this.http.get(environment.baseUrl + 'highMerchant/getMerchantById?id=' + merchantId).subscribe(data => { + public getMerchantStoreById(merchantId: number, callBack) { + this.http.get(environment.baseUrl + 'highMerchantStore/getMerchantStoreById?id=' + merchantId).subscribe(data => { callBack(data); }); } @@ -70,22 +82,11 @@ export class MerchantStoreService { * @param id 用户id * @param callBack 返回参数 */ - public disableMerchant(id: number, callBack) { - this.http.get(environment.baseUrl + 'highMerchant/disableMerchant?id=' + id).subscribe(data => { + public deleteMerchantStore(id: number, callBack) { + this.http.get(environment.baseUrl + 'highMerchantStore/deleteMerchantStore?id=' + id).subscribe(data => { callBack(data); }); } - /** - * 启用商户 - * - * @param id 用户id - * @param callBack 返回参数 - */ - public enableMerchant(id: number, callBack) { - this.http.get(environment.baseUrl + 'highMerchant/enableMerchant?id=' + id).subscribe(data => { - callBack(data); - }); - } } diff --git a/src/index.html b/src/index.html index 309f89b..268e126 100644 --- a/src/index.html +++ b/src/index.html @@ -5,6 +5,8 @@ 嗨商城 + + diff --git a/tsconfig.json b/tsconfig.json index 30956ae..9ddd180 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,8 @@ "lib": [ "es2018", "dom" - ] + ], + "allowSyntheticDefaultImports": true }, "angularCompilerOptions": { "fullTemplateTypeCheck": true,