Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/app/pages/goods/goods-type/goods-type.component.ts
#	src/app/pages/merchant/mer-add/mer-add.component.less
master
袁野 6 months ago
commit 92c9be9422
  1. 4
      src/app/pages/account/account.routes.ts
  2. 2
      src/app/pages/account/sys-role/sys-role.component.html
  3. 3
      src/app/pages/account/sys-role/sys-role.component.less
  4. 81
      src/app/pages/account/user/user.component.html
  5. 6
      src/app/pages/account/user/user.component.less
  6. 173
      src/app/pages/account/user/user.component.ts
  7. 40
      src/app/pages/merchant/mer-add/mer-add.component.html
  8. 6
      src/app/pages/merchant/mer-add/mer-add.component.less
  9. 38
      src/app/pages/merchant/mer-add/mer-add.component.ts
  10. 197
      src/app/pages/merchant/mer-list/mer-list.component.html
  11. 9
      src/app/pages/merchant/mer-list/mer-list.component.less
  12. 306
      src/app/pages/merchant/mer-list/mer-list.component.ts
  13. 45
      src/app/services/account/user.service.ts
  14. 13
      src/app/services/merchant/mer.service.ts

@ -1,8 +1,10 @@
import { Routes } from '@angular/router';
import {SysAccountComponent} from "./sys-account/sys-account.component";
import {SysRoleComponent} from "./sys-role/sys-role.component";
import {UserComponent} from "./user/user.component";
export const ACCOUNT_ROUTES: Routes = [
{ path: 'sys_account', component: SysAccountComponent},
{ path: 'sys_role', component: SysRoleComponent}
{ path: 'sys_role', component: SysRoleComponent},
{ path: 'user_list', component: UserComponent},
];

@ -8,7 +8,7 @@
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6" style="margin-top: 30px;">
<div nz-col [nzSpan]="6" class="search-area">
<button nz-button [nzType]="'primary'" (click)="searchFormSubmit()">查询</button>
<button nz-button (click)="searchFormReset()">重置</button>
<button nz-button [nzType]="'primary'" (click)="showEditRole(true, null)">创建</button>

@ -7,3 +7,6 @@ button {
.submit-btn {
width: 150px;
}
.search-area {
margin-top: 30px;
}

@ -0,0 +1,81 @@
<form nz-form [formGroup]="searchForm" [nzLayout]="'vertical'">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>用户名</nz-form-label>
<nz-form-control>
<input nz-input formControlName="name" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>手机号</nz-form-label>
<nz-form-control>
<input nz-input formControlName="phone" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>状态</nz-form-label>
<nz-form-control>
<nz-select formControlName="status" nzAllowClear [nzPlaceHolder]="'请选择'">
<nz-option *ngFor="let item of userStatusArray" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6" class="search-area">
<button nz-button [nzType]="'primary'" (click)="searchFormSubmit()">查询</button>
<button nz-button (click)="searchFormReset()">重置</button>
</div>
</div>
</form>
<nz-table #basicTable
[nzBordered]="true"
[nzFrontPagination]="false"
[nzShowQuickJumper]="true"
[nzShowTotal]="totalTemplate"
[(nzPageIndex)]="tablePageNum"
(nzPageIndexChange)="queryData()"
[nzTotal]="tableData.total"
[nzData]="tableData.list" >
<thead>
<tr>
<th nzWidth="80px">用户名</th>
<th nzWidth="80px">手机号</th>
<th nzWidth="50px">积分数量</th>
<th nzWidth="50px">状态</th>
<th nzWidth="50px">注册时间</th>
<th nzWidth="70px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td>{{data.name}}</td>
<td>{{data.phone}}</td>
<td>{{data.integral}}</td>
<td>{{data.status | dictionary: 'USER_STATUS'}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>
<a *ngIf="data.status == 1" (click)="showDisable(data.id)">禁用账户</a>
<a *ngIf="data.status == 2" (click)="showRestore(data.id)">恢复账户</a>
<!-- <nz-divider nzType="vertical"></nz-divider>
<a nz-dropdown [nzDropdownMenu]="menu">
更多
<span nz-icon nzType="down"></span>
</a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item ></li>
</ul>
</nz-dropdown-menu>-->
</td>
</tr>
</tbody>
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template>
</nz-table>

@ -0,0 +1,6 @@
.search-area {
margin-top: 30px;
}
button {
margin-left: 8px;
}

@ -0,0 +1,173 @@
import { Component } from '@angular/core';
import {FormGroup, NonNullableFormBuilder, ReactiveFormsModule} from "@angular/forms";
import {NzMessageService} from "ng-zorro-antd/message";
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal";
import {DatePipe, NgForOf, NgIf} from "@angular/common";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzInputDirective} from "ng-zorro-antd/input";
import {
NzTableCellDirective,
NzTableComponent,
NzTbodyComponent,
NzTheadComponent,
NzThMeasureDirective, NzTrDirective
} from "ng-zorro-antd/table";
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {UserService} from "../../../services/account/user.service";
@Component({
selector: 'app-user',
standalone: true,
imports: [
DatePipe,
NgForOf,
NzButtonComponent,
NzColDirective,
NzDividerComponent,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
NzRowDirective,
NzTableCellDirective,
NzTableComponent,
NzTbodyComponent,
NzThMeasureDirective,
NzTheadComponent,
NzTrDirective,
ReactiveFormsModule,
DictionaryPipe,
NzSelectComponent,
NzOptionComponent,
NzModalModule,
NgIf,
NzDropDownADirective,
NzDropDownDirective,
NzDropdownMenuComponent,
NzIconDirective,
NzMenuDirective,
NzMenuItemComponent,
],
templateUrl: './user.component.html',
styleUrl: './user.component.less'
})
export class UserComponent {
// 表单页数
tablePageNum = 1;
// 表单数据
tableData: any = {
total: 0,
list: [],
};
// 搜索表单
searchForm: FormGroup;
// 用户状态
userStatusArray = new DictionaryPipe().getDictionaryList("USER_STATUS");
constructor(private fb: NonNullableFormBuilder,
private userService: UserService,
private message: NzMessageService,
private modal: NzModalService) {
// 初始化搜索框
this.searchForm = this.fb.group({
name: [''],
phone: [''],
status: [''],
});
this.queryData();
}
queryData() {
this.searchForm.value.pageNum = this.tablePageNum;
this.searchForm.value.pageSize = 10;
this.searchForm.value.time = new Date().getTime();
this.userService.queryUserList(this.searchForm.value, (data: any) => {
if (data['return_code'] == '000000') {
this.tableData = data['return_data'];
}
});
}
/**
*
*/
searchFormSubmit(): void {
this.tablePageNum = 1;
this.queryData();
}
/**
*
*/
searchFormReset(): void {
this.searchForm.reset();
}
/**
*
*/
showRestore(dataId: number) {
this.modal.confirm({
nzTitle: '提示',
nzContent: '确定恢复账户状态?',
nzOnOk: () => this.restore(dataId)
});
}
/**
*
*/
restore(dataId: number) {
const param = {
userId: dataId
}
this.userService.restore(param, (data: any) => {
if (data['return_code'] == '000000') {
// 刷新数据
this.queryData();
this.message.success("操作成功");
} else {
this.message.create('error', data['return_msg']);
}
});
}
/**
*
*/
showDisable(dataId: number) {
this.modal.confirm({
nzTitle: '提示',
nzContent: '确定禁用账户吗?禁用后无法登录、交易!',
nzOnOk: () => this.disable(dataId)
});
}
/**
*
*/
disable(dataId: number) {
const param = {
userId: dataId
}
this.userService.disable(param, (data: any) => {
if (data['return_code'] == '000000') {
// 刷新数据
this.queryData();
this.message.success("操作成功");
} else {
this.message.create('error', data['return_msg']);
}
});
}
}

@ -1,27 +1,11 @@
<form nz-form [formGroup]="form" (ngSubmit)="submitForm()">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>登录账户</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="登录账户填写有误!">
<input nz-input formControlName="loginName"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>角色权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="角色权限选择有误!">
<nz-select nzShowSearch formControlName="roleId">
<nz-option *ngFor="let item of roleData" nzValue="{{item.id}}" nzLabel="{{item.roleName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24">logo</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24">商家标志</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-upload
class="logo-uploader"
nzAction="https://www.mocky.io/v2/5cc8019d300000980a055e76"
nzAction="{{BASE_URL}}fileUpload/uploadfile"
nzName="avatar"
nzListType="picture-card"
[nzShowUploadList]="false"
@ -37,10 +21,26 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>登录账户</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="登录账户填写有误!">
<input nz-input formControlName="loginName"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>角色权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="角色权限选择有误!">
<nz-select nzShowSearch formControlName="roleId">
<nz-option *ngFor="let item of roleData" nzValue="{{item.id}}" nzLabel="{{item.roleName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>商户名称</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="directorName"/>
<input nz-input formControlName="merName"/>
</nz-form-control>
</nz-form-item>
@ -59,7 +59,7 @@
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>负责人电话</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>联系电话</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="directorTel"/>
</nz-form-control>

@ -1,11 +1,9 @@
form {
text-align: center;
width: 500px;
}
.logo-uploader {
text-align: left;
}
:host ::ng-deep .avatar-uploader > .ant-upload {
width: 128px;
height: 128px;
.submit-btn {
width: 150px;
}

@ -18,7 +18,9 @@ import {NzUploadFile, NzUploadModule} from "ng-zorro-antd/upload";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {Observable, Observer} from "rxjs";
import {NzMessageService} from "ng-zorro-antd/message";
import {environment} from "../../../../environments/environment";
import {MerService} from "../../../services/merchant/mer.service";
import {RoleService} from "../../../services/role/role.service";
@Component({
selector: 'app-mer-add',
@ -47,7 +49,7 @@ import {MerService} from "../../../services/merchant/mer.service";
styleUrl: './mer-add.component.less'
})
export class MerAddComponent {
BASE_URL = environment.baseUrl;
loading = false;
logoUrl?: string;
@ -57,6 +59,7 @@ export class MerAddComponent {
constructor(private fb: NonNullableFormBuilder,
private merService: MerService,
private roleService: RoleService,
private message: NzMessageService,
private modal: NzModalService) {
// 初始化表单
@ -70,10 +73,36 @@ export class MerAddComponent {
customerServiceTel: [''],
address: [''],
});
// 获取角色数据
this.roleService.queryAllRole((data: any) => {
this.roleData = data['return_data'];
});
}
submitForm() {
console.log(this.logoUrl);
if (this.form.valid) {
this.merService.create(this.form.value, (data: any) => {
if (data['return_code'] == '000000') {
this.message.create('success', '操作成功');
// 清空表单
this.form.reset();
this.logoUrl = '';
} else {
this.message.create('error', data['return_msg']);
}
});
} else {
Object.values(this.form.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
}
}
private getBase64(img: File, callback: (img: string) => void): void {
@ -93,9 +122,10 @@ export class MerAddComponent {
this.loading = false;
this.logoUrl = img;
});
this.form.patchValue({ merLogo: info.file.response['return_data'][0]});
break;
case 'error':
this.message.error('Network error');
this.message.error('网络错误!');
this.loading = false;
break;
}
@ -105,13 +135,13 @@ export class MerAddComponent {
return new Observable((observer: Observer<boolean>) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isJpgOrPng) {
this.message.error('You can only upload JPG file!');
this.message.error('只能上传JPG文件!');
observer.complete();
return;
}
const isLt2M = file.size! / 1024 / 1024 < 2;
if (!isLt2M) {
this.message.error('Image must smaller than 2MB!');
this.message.error('图片必须小于2MB!');
observer.complete();
return;
}

@ -1 +1,196 @@
<p>mer-list works!</p>
<form nz-form [formGroup]="searchForm" class="search_form" [nzLayout]="'vertical'">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>商户号</nz-form-label>
<nz-form-control>
<input nz-input formControlName="merNo" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>商户名称</nz-form-label>
<nz-form-control>
<input nz-input formControlName="merName" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>创建人</nz-form-label>
<nz-form-control>
<input nz-input formControlName="opUserName" placeholder="请输入" />
</nz-form-control>
</nz-form-item>
</div>
<!-- <div nz-col [nzSpan]="6">
<nz-form-item>
<nz-form-label>商户状态</nz-form-label>
<nz-form-control>
<nz-select formControlName="status" nzAllowClear [nzPlaceHolder]="'请选择'">
<nz-option *ngFor="let item of merStatus" nzValue="{{item.codeValue}}" nzLabel="{{item.codeName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>-->
<div nz-col [nzSpan]="6" class="search-area">
<button nz-button [nzType]="'primary'" (click)="searchFormSubmit()">查询</button>
<button nz-button (click)="searchFormReset()">重置</button>
</div>
</div>
</form>
<nz-table #basicTable
[nzScroll]="{ x: '1100px' }"
[nzBordered]="true"
[nzFrontPagination]="false"
[nzShowQuickJumper]="true"
[nzShowTotal]="totalTemplate"
[(nzPageIndex)]="tablePageNum"
(nzPageIndexChange)="queryData()"
[nzTotal]="tableData.total"
[nzData]="tableData.list" >
<thead>
<tr>
<th nzWidth="30px">商户号</th>
<th nzWidth="50px">商户名称</th>
<th nzWidth="30px">负责人</th>
<th nzWidth="30px">联系电话</th>
<th nzWidth="30px">创建人</th>
<th nzWidth="30px">创建时间</th>
<th nzWidth="30px">更新时间</th>
<th nzRight nzWidth="50px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of basicTable.data">
<td>{{data.merNo}}</td>
<td>{{data.merName}}</td>
<td>{{data.directorName}}</td>
<td>{{data.directorTel}}</td>
<td>{{data.opUserName}}</td>
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td>{{data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td>
<td nzRight>
<a (click)="showMerDetail(data.merNo)">详情</a>
<nz-divider nzType="vertical"></nz-divider>
<a (click)="showUpdateMer(data.merNo)">修改资料</a>
<nz-divider nzType="vertical"></nz-divider>
<a nz-dropdown [nzDropdownMenu]="menu">
更多
<span nz-icon nzType="down"></span>
</a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li nz-menu-item><a (click)="showResetPwd(data.merNo)">密码重置</a></li>
</ul>
</nz-dropdown-menu>
</td>
</tr>
</tbody>
<ng-template #totalTemplate let-total>总计 {{ total }} 条</ng-template>
</nz-table>
<nz-modal [(nzVisible)]="merDetailVisible" [nzWidth]="1000" nzTitle="商户详情" [nzFooter]="null" (nzOnCancel)="closeMerDetail()">
<ng-container *nzModalContent>
<nz-descriptions nzBordered [nzColumn]="{ xxl: 2, xl: 2, lg: 2, md: 2, sm: 2, xs: 1 }">
<nz-descriptions-item nzSpan="2" nzTitle="商户标志">
<nz-avatar *ngIf="merDetailObject.merLogo" [nzShape]="'square'" [nzSize]="64" nzText="商户标志" nzSrc="{{IMAGE_URL+merDetailObject.merLogo}}"></nz-avatar>
<span *ngIf="!merDetailObject.merLogo"></span>
</nz-descriptions-item>
<nz-descriptions-item nzTitle="登录账号">{{merDetailObject.loginName}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="账户角色">{{merDetailObject.roleName}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="商户号">{{merDetailObject.merNo}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="商户名称">{{merDetailObject.merName}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="负责人">{{merDetailObject.directorName}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="联系电话">{{merDetailObject.directorTel}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="客服电话">{{merDetailObject.customerServiceTel}}</nz-descriptions-item>
<nz-descriptions-item nzTitle="详情地址">{{merDetailObject.address}}</nz-descriptions-item>
</nz-descriptions>
</ng-container>
</nz-modal>
<nz-modal [(nzVisible)]="updateMerVisible" [nzWidth]="500" nzTitle="修改商户资料" [nzFooter]="null" (nzOnCancel)="closeUpdateMer()">
<ng-container *nzModalContent>
<form nz-form [formGroup]="updateMerForm" (ngSubmit)="submitUpdateMerForm()">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24">商家标志</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-upload
class="logo-uploader"
nzAction="{{BASE_URL}}fileUpload/uploadfile"
nzName="avatar"
nzListType="picture-card"
[nzShowUploadList]="false"
[nzBeforeUpload]="beforeUpload"
(nzChange)="handleChange($event)"
>
<ng-container *ngIf="!updateMerForm.controls['merLogo'].value">
<i class="upload-icon" nz-icon [nzType]="uploadLoading ? 'loading' : 'plus'"></i>
<div class="ant-upload-text">上传</div>
</ng-container>
<img *ngIf="updateMerForm.controls['merLogo'].value" [src]="IMAGE_URL + updateMerForm.controls['merLogo'].value" style="width: 100%" />
</nz-upload>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>登录账户</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="登录账户填写有误!">
<input nz-input formControlName="loginName"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>角色权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" nzErrorTip="角色权限选择有误!">
<nz-select nzShowSearch formControlName="roleId">
<nz-option *ngFor="let item of roleData" nzValue="{{item.id}}" nzLabel="{{item.roleName}}"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>商户名称</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="merName"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>负责人</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="directorName"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired>联系电话</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="directorTel"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24">商户地址</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="address"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24">客服电话</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="customerServiceTel"/>
</nz-form-control>
</nz-form-item>
<div nz-flex [nzJustify]="'center'">
<button nz-button nzType="primary" class="submit-btn">保存</button>
</div>
</form>
</ng-container>
</nz-modal>

@ -0,0 +1,9 @@
button {
margin-left: 8px;
}
.search-area {
margin-top: 30px;
}
.submit-btn {
width: 150px;
}

@ -1,12 +1,316 @@
import { Component } from '@angular/core';
import {DatePipe, NgForOf, NgIf} from "@angular/common";
import {DictionaryPipe} from "../../../pipes/common/dictionary.pipe";
import {FormGroup, FormsModule, NonNullableFormBuilder, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzButtonComponent} from "ng-zorro-antd/button";
import {
NzCellFixedDirective,
NzTableCellDirective,
NzTableComponent, NzTableModule,
NzTbodyComponent, NzTheadComponent,
NzThMeasureDirective, NzTrDirective
} from "ng-zorro-antd/table";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzDropDownADirective, NzDropDownDirective, NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzInputDirective} from "ng-zorro-antd/input";
import {NzMenuDirective, NzMenuItemComponent} from "ng-zorro-antd/menu";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzMessageService} from "ng-zorro-antd/message";
import {NzModalModule, NzModalService} from "ng-zorro-antd/modal";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzDescriptionsModule} from "ng-zorro-antd/descriptions";
import {NzUploadComponent, NzUploadFile} from "ng-zorro-antd/upload";
import {environment} from "../../../../environments/environment";
import {Observable, Observer} from "rxjs";
import {NzAvatarModule} from "ng-zorro-antd/avatar";
import {MerService} from "../../../services/merchant/mer.service";
import {RoleService} from "../../../services/role/role.service";
@Component({
selector: 'app-mer-list',
standalone: true,
imports: [],
imports: [
DatePipe,
DictionaryPipe,
FormsModule,
NgForOf,
NgIf,
NzButtonComponent,
NzCellFixedDirective,
NzColDirective,
NzDividerComponent,
NzDropDownADirective,
NzDropDownDirective,
NzDropdownMenuComponent,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzIconDirective,
NzInputDirective,
NzMenuDirective,
NzMenuItemComponent,
NzOptionComponent,
NzRowDirective,
NzSelectComponent,
NzTableCellDirective,
NzTableComponent,
NzTbodyComponent,
NzThMeasureDirective,
NzTheadComponent,
NzTrDirective,
ReactiveFormsModule,
NzTableModule,
NzModalModule,
NzFlexDirective,
NzDescriptionsModule,
NzUploadComponent,
NzAvatarModule
],
templateUrl: './mer-list.component.html',
styleUrl: './mer-list.component.less'
})
export class MerListComponent {
BASE_URL = environment.baseUrl;
IMAGE_URL = environment.imageUrl;
// 表单页数
tablePageNum = 1;
// 表单数据
tableData: any = {
total: 0,
list: [],
};
// 搜索表单
searchForm: FormGroup;
roleData: any = []
merDetailVisible = false;
merDetailObject: any = {};
merLogo = '';
uploadLoading = false;
updateMerVisible = false;
updateMerForm: FormGroup;
constructor(private fb: NonNullableFormBuilder,
private merService: MerService,
private roleService: RoleService,
private message: NzMessageService,
private modal: NzModalService) {
// 初始化搜索框
this.searchForm = this.fb.group({
merNo: [''],
merName: [''],
opUserName: [''],
status: [''],
});
this.updateMerForm = this.fb.group({
loginName: [{ value: '', disabled: true}, [Validators.required]],
roleId: ['', [Validators.required]],
merLogo: [''],
merNo: [''],
merName: ['', [Validators.required]],
directorName: ['',[Validators.required]],
directorTel: ['',[Validators.required]],
customerServiceTel: [''],
address: [''],
});
// 获取角色数据
this.roleService.queryAllRole((data: any) => {
this.roleData = data['return_data'];
});
this.queryData();
}
/**
*
*/
queryData() {
this.searchForm.value.pageNum = this.tablePageNum;
this.searchForm.value.pageSize = 10;
this.searchForm.value.time = new Date().getTime();
this.merService.queryList(this.searchForm.value, (data: any) => {
if (data['return_code'] == '000000') {
this.tableData = data['return_data'];
}
});
}
/**
*
*/
searchFormSubmit(): void {
this.tablePageNum = 1;
this.queryData();
}
/**
*
*/
searchFormReset(): void {
this.searchForm.reset();
}
/**
*
* @param merNo
*/
showMerDetail(merNo: string) {
this.merService.queryMer(merNo, (data: any) => {
if (data['return_code'] == '000000') {
this.merDetailObject = data['return_data'];
} else {
this.message.error(data['return_msg']);
}
});
this.merDetailVisible = true;
}
/**
*
*/
closeMerDetail() {
this.merDetailObject = {};
this.merDetailVisible = false;
}
/**
*
* @param merData
*/
showUpdateMer(merNo: string) {
this.merService.queryMer(merNo, (data: any) => {
if (data['return_code'] == '000000') {
data['return_data']['roleId'] = String(data['return_data']['roleId']);
this.updateMerForm.patchValue(data['return_data']);
console.log(this.updateMerForm.controls['merLogo'].value);
} else {
this.message.error(data['return_msg']);
}
});
this.updateMerVisible = true;
}
/**
*
*/
submitUpdateMerForm() {
if (this.updateMerForm.valid) {
this.merService.update(this.updateMerForm.value, (data: any) => {
if (data['return_code'] == '000000') {
this.message.create('success', '操作成功');
// 关闭弹窗
this.closeUpdateMer();
// 刷新列表
this.queryData();
} else {
this.message.create('error', data['return_msg']);
}
});
} else {
Object.values(this.updateMerForm.controls).forEach(control => {
if (control.invalid) {
control.markAsDirty();
control.updateValueAndValidity({ onlySelf: true });
}
});
}
}
/**
*
*/
closeUpdateMer() {
this.updateMerForm.reset();
this.updateMerVisible = false;
}
/**
*
*/
showResetPwd(merNo: string) {
this.modal.confirm({
nzTitle: '提示',
nzContent: '确定重置商户账户登录密码吗?',
nzOnOk: () => this.resetPwd(merNo)
});
}
/**
*
*/
resetPwd(merNo: string) {
const param = {
merNo: merNo
}
this.merService.resetPwd(param, (data: any) => {
if (data['return_code'] == '000000') {
// 刷新数据
this.queryData();
this.modal.success({
nzTitle: '提示',
nzContent: '密码重置成功,新密码:123456'
});
} else {
this.message.create('error', data['return_msg']);
}
});
}
private getBase64(img: File, callback: (img: string) => void): void {
const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result!.toString()));
reader.readAsDataURL(img);
}
handleChange(info: { file: NzUploadFile }): void {
switch (info.file.status) {
case 'uploading':
this.uploadLoading = true;
break;
case 'done':
// Get this url from response in real world.
this.getBase64(info.file!.originFileObj!, (img: string) => {
this.uploadLoading = false;
this.merLogo = img;
});
this.updateMerForm.patchValue({ merLogo: info.file.response['return_data'][0]});
break;
case 'error':
this.message.error('网络错误!');
this.uploadLoading = false;
break;
}
}
beforeUpload = (file: NzUploadFile, _fileList: NzUploadFile[]) => {
return new Observable((observer: Observer<boolean>) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isJpgOrPng) {
this.message.error('只能上传JPG文件!');
observer.complete();
return;
}
const isLt2M = file.size! / 1024 / 1024 < 2;
if (!isLt2M) {
this.message.error('图片必须小于2MB!');
observer.complete();
return;
}
observer.next(isJpgOrPng && isLt2M);
observer.complete();
});
};
}

@ -0,0 +1,45 @@
import { Injectable } from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {environment} from "../../../environments/environment";
import {ObjectData} from "../../utils/objectData.service";
@Injectable({
providedIn: 'root'
})
export class UserService {
constructor(private http: HttpClient) { }
/**
*
* @param param
* @param callBack
*/
public restore(param: object, callBack:any) {
this.http.post(environment.baseUrl + 'user/restore', param).subscribe(data => {
callBack(data);
});
}
/**
*
* @param param
* @param callBack
*/
public disable(param: object, callBack:any) {
this.http.post(environment.baseUrl + 'user/disable', param).subscribe(data => {
callBack(data);
});
}
/**
*
* @param params
* @param callBack
*/
public queryUserList(params: object, callBack:any) {
this.http.get(environment.baseUrl + 'user/queryUserList?'+ObjectData.objectByString(params)).subscribe(data => {
callBack(data);
});
}
}

@ -32,13 +32,24 @@ export class MerService {
});
}
/**
*
* @param params
* @param callBack
*/
public resetPwd(params: object, callBack:any) {
this.http.post(environment.baseUrl + 'mer/resetPwd', params).subscribe(data => {
callBack(data);
});
}
/**
*
* @param merNo
* @param callBack
*/
public queryMer(merNo: string, callBack:any) {
this.http.get(environment.baseUrl + 'mer/queryMer?merNo=' + merNo).subscribe(data => {
this.http.get(environment.baseUrl + 'mer/queryMer?merNo=' + merNo + '&dt=' + new Date().getTime()).subscribe(data => {
callBack(data);
});
}

Loading…
Cancel
Save