pull/1/head
commit
c8cf38ca8e
@ -0,0 +1,117 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
|
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">审核对象名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="objectName"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">审核类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select formControlName="objectType"> |
||||
<nz-option nzValue="1" nzLabel="Jack"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="Lucy"></nz-option> |
||||
<nz-option nzValue="disabled" nzLabel="Disabled" nzDisabled></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">审核流水号</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="approveSerialNo"/> |
||||
</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>共计 {{total}} 条数据</span> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="120px">审核流水号</th> |
||||
<th nzWidth="80px">审核对象名称</th> |
||||
<th nzWidth="80px">审核类型</th> |
||||
<th nzWidth="100px">提交人员</th> |
||||
<th nzWidth="100px">创建时间</th> |
||||
<th nzWidth="80px">状态</th> |
||||
<th nzWidth="80px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.approveSerialNo}}</td> |
||||
<td>{{data.objectName}}</td> |
||||
<td>{{data.objectType | auditType}}</td> |
||||
<td>{{data.submitOperatorName}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.status | auditStatus}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a (click)="getDetail(data.id)"><i nz-icon [nzIconfont]="'icon-xiangqing'" nz-tooltip="审核详情"></i></a> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
<nz-modal [(nzVisible)]="isVisible" nzWidth="900" nzTitle="审核详情" (nzOnCancel)="handleCancel()"> |
||||
<ng-container> |
||||
<nz-descriptions nzBordered> |
||||
<nz-descriptions-item nzTitle="审核类型" >{{data['approve']['objectType'] | auditType}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="审核状态">{{data['approve']['status'] | auditStatus}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="申请人员">{{data['approve']['submitOperatorName']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="审核名称">{{data['approve']['objectName']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="卡券KEY">{{data['object']['couponKey']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="卡券面值">¥{{data['object']['couponPrice']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="销售价格">¥{{data['object']['salesPrice']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="折扣价格">¥{{data['object']['salesPrice']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="销售数量">{{data['object']['salesCount']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="限购数量">{{data['object']['limitNumber']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="归库天数">{{data['object']['recycleDay']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="卡券类型">{{data['object']['couponType'] === 1 ? '内部卷' : '外部卷'}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="销售截至时间">{{data['object']['salesEndTime'] | date : 'yyyy-MM-dd'}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="创建时间">{{data['object']['createTime'] | date : 'yyyy-MM-dd'}}</nz-descriptions-item> |
||||
</nz-descriptions> |
||||
</ng-container> |
||||
<div *nzModalFooter> |
||||
<button nz-button nzType="default" (click)="approveProcessed(2)">审核驳回</button> |
||||
<button nz-button nzType="primary" (click)="approveProcessed(3)">审核通过</button> |
||||
</div> |
||||
</nz-modal> |
||||
|
@ -0,0 +1,116 @@ |
||||
import {Component, OnInit} from '@angular/core'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {ActivatedRoute, Router} from '@angular/router'; |
||||
import {AuditService} from '../../../services/audit.service'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
|
||||
@Component({ |
||||
selector: 'app-audit-coupon', |
||||
templateUrl: './audit-coupon.component.html', |
||||
styleUrls: ['./audit-coupon.component.scss'] |
||||
}) |
||||
export class AuditCouponComponent implements OnInit { |
||||
|
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
isVisible = false; |
||||
id: number; |
||||
data = { |
||||
approve: {}, |
||||
object: {} |
||||
}; |
||||
constructor( |
||||
private form: FormBuilder, |
||||
private audit: AuditService, |
||||
private iconService: IconService, |
||||
private message: NzMessageService, |
||||
private common: CommonsService, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.init(); |
||||
|
||||
} |
||||
|
||||
public init(): void { |
||||
this.searchForm = this.form.group({ |
||||
objectType: [null], |
||||
objectName: [null], |
||||
approveSerialNo: [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.audit.getApproveList(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 getDetail(id: number): void { |
||||
this.id = id; |
||||
this.audit.getApproveDetail(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.data = data['return_data']; |
||||
this.isVisible = true; |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
handleCancel(): void { |
||||
this.isVisible = false; |
||||
} |
||||
|
||||
public approveProcessed(statusD: number): void { |
||||
const p = { |
||||
approveId: this.id, |
||||
status: statusD, |
||||
remarks: '', |
||||
}; |
||||
this.common.showConfirm('是否确定' , r => { |
||||
if (r) { |
||||
|
||||
this.audit.approveProcessed(p , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.isVisible = false; |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.message.success('操作成功'); |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {AuditCouponComponent} from './audit-coupon/audit-coupon.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'coupon-audit', component: AuditCouponComponent }, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class AuditRoutingModule { } |
@ -0,0 +1,26 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { AuditRoutingModule } from './audit-routing.module'; |
||||
import { AuditCouponComponent } from './audit-coupon/audit-coupon.component'; |
||||
import {NgZorroAntdModule} from 'ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {AppCommonModule} from '../../app-common.module'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [AuditCouponComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
AuditRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
AppCommonModule |
||||
] |
||||
}) |
||||
export class AuditModule { } |
@ -0,0 +1,33 @@ |
||||
<!-- start 面包屑 --> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
系统管理 |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
公司详情 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<div class="inner-content"> |
||||
<nz-tabset> |
||||
<nz-tab nzTitle="账号信息"> |
||||
<nz-descriptions nzBordered> |
||||
<nz-descriptions-item nzTitle="登录账户" [nzSpan]="1.5">{{data.user.loginName}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="用户名" [nzSpan]="1.5">{{data.user.userName}}</nz-descriptions-item> |
||||
</nz-descriptions> |
||||
</nz-tab> |
||||
<nz-tab nzTitle="单位信息"> |
||||
<nz-descriptions nzBordered> |
||||
<nz-descriptions-item nzTitle="所属地区">{{data.company.regionName}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="单位logo"> |
||||
<img class="head_img" src="{{FILE_URL +data.logo}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt=""> |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="公司名称">{{data.company.name}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="联系方式">{{data.company.phone}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="创建时间">{{data.company.createTime | date: 'yyyy-MM-dd HH:mm'}} </nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="更新时间">{{data.company.updateTime | date: 'yyyy-MM-dd HH:mm'}} </nz-descriptions-item> |
||||
</nz-descriptions> |
||||
</nz-tab> |
||||
</nz-tabset> |
||||
</div> |
@ -0,0 +1,4 @@ |
||||
.head_img { |
||||
height: 60px; |
||||
width: 60px; |
||||
} |
@ -0,0 +1,38 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {ActivatedRoute} from '@angular/router'; |
||||
import {CompanyService} from '../../../services/company.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-company-detail', |
||||
templateUrl: './company-detail.component.html', |
||||
styleUrls: ['./company-detail.component.scss'] |
||||
}) |
||||
export class CompanyDetailComponent implements OnInit { |
||||
FILE_URL = environment.imageUrl; |
||||
data: any = {}; |
||||
id: number; |
||||
constructor( |
||||
private company: CompanyService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { } |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.companyId != null) { |
||||
this.id = queryParams.companyId; |
||||
this.getDetails(queryParams.companyId); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 查询详情
|
||||
public getDetails(id: number) { |
||||
this.company.companyView(id , data => { |
||||
console.log(data); |
||||
this.data = data['return_data']; |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,109 @@ |
||||
<!-- start 面包屑 --> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
系统管理 |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
增加公司 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<div class="inner-content"> |
||||
|
||||
<div nz-row> |
||||
<div nz-col nzSpan="2"></div> |
||||
<div nz-col nzSpan="20"> |
||||
<form nz-form [formGroup]="validateForm" > |
||||
<div nz-row [nzGutter]="24"> |
||||
<nz-divider nzText="账号信息"></nz-divider> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'loginName'" nzRequired>用户名</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入用户名!"> |
||||
<input nz-input placeholder="请输入用户名..." [formControlName]="'loginName'" id="'loginName'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'password'" nzRequired>登录密码</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入登录密码!"> |
||||
<nz-input-group [nzSuffix]="suffixTemplate"> |
||||
<input [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="请输入登录密码..." [formControlName]="'password'" id="'password'" /> |
||||
</nz-input-group> |
||||
<ng-template #suffixTemplate> |
||||
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i> |
||||
</ng-template> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'phone'" nzRequired>联系电话</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入联系电话!"> |
||||
<input nz-input placeholder="请输入联系电话..." [formControlName]="'phone'" id="'phone'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<nz-divider nzText="公司信息"></nz-divider> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'telephone'" nzRequired>所属地区</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入所属地区!"> |
||||
<app-region-selector *ngIf="!editFlag" [selectLevel]="2" (selectedRegionIdChange)="regionChange($event)"></app-region-selector> |
||||
<input readonly="readonly" *ngIf="editFlag" nz-input [formControlName]="'regionName'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'name'" nzRequired>公司名称</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入公司名称!"> |
||||
<input nz-input placeholder="请输入公司名称..." [formControlName]="'name'" id="'name'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'address'" nzRequired>公司地址</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入公司地址!"> |
||||
<input nz-input placeholder="请输入公司地址..." [formControlName]="'address'" id="'address'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="20"> |
||||
<nz-form-item> |
||||
<nz-form-label>公司LOGO</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-upload |
||||
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="logoFile" |
||||
[nzShowButton]="logoFile.length < 1" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传LOGO</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
</div> |
||||
<div nz-row> |
||||
<div nz-col [nzSpan]="24" class="search-area"> |
||||
<button nz-button (click)="resetForm()">重置</button> |
||||
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
<div nz-col nzSpan="2"></div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,6 @@ |
||||
button { |
||||
margin-left: 8px; |
||||
} |
||||
:host ::ng-deep .ant-upload { |
||||
background-color: #ffffff; |
||||
} |
@ -0,0 +1,171 @@ |
||||
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 {ActivatedRoute} from '@angular/router'; |
||||
import {ValidatorsService} from '../../../services/validators.service'; |
||||
import {CompanyService} from '../../../services/company.service'; |
||||
|
||||
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
||||
return new Promise((resolve, reject) => { |
||||
const reader = new FileReader(); |
||||
reader.readAsDataURL(file); |
||||
reader.onload = () => resolve(reader.result); |
||||
reader.onerror = error => reject(error); |
||||
}); |
||||
} |
||||
|
||||
@Component({ |
||||
selector: 'app-company-edit', |
||||
templateUrl: './company-edit.component.html', |
||||
styleUrls: ['./company-edit.component.scss'] |
||||
}) |
||||
export class CompanyEditComponent implements OnInit { |
||||
|
||||
validateForm!: FormGroup; |
||||
data: any; |
||||
editFlag = false; |
||||
id: number; |
||||
passwordVisible = false; |
||||
logoFile = []; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
previewImage: string | undefined = ''; |
||||
previewVisible = false; |
||||
regionId; |
||||
userId: number; |
||||
time; |
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private company: CompanyService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.companyId != null) { |
||||
this.editFlag = true; |
||||
this.id = queryParams.companyId; |
||||
this.getDetails(queryParams.companyId); |
||||
} |
||||
}); |
||||
this.validateForm = this.fb.group({ |
||||
loginName: [null, [Validators.required, ValidatorsService.maxLength(20)]], |
||||
password: [null, [Validators.required]], |
||||
phone: [null, [Validators.required, ValidatorsService.mobile]], |
||||
regionId: [null], |
||||
name: [null, [Validators.required, ValidatorsService.maxLength(50)]], |
||||
address: [null, [Validators.required, ValidatorsService.maxLength(80)]], |
||||
logo: [null], |
||||
regionName: [null], |
||||
company: {}, |
||||
user: {}, |
||||
}); |
||||
} |
||||
|
||||
// 返回
|
||||
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.logoFile.length !== 0) { |
||||
if (this.logoFile[0]['response'] != null) { |
||||
this.validateForm.value.logo = this.logoFile[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateForm.value.logo = this.logoFile[0].name; |
||||
} |
||||
} |
||||
this.validateForm.value['company']['name'] = this.validateForm.value.name; |
||||
this.validateForm.value['company']['regionId'] = this.regionId; |
||||
this.validateForm.value['company']['address'] = this.validateForm.value.address; |
||||
this.validateForm.value['company']['phone'] = this.validateForm.value.phone; |
||||
this.validateForm.value['company']['logo'] = this.validateForm.value.logo; |
||||
this.validateForm.value['user']['loginName'] = this.validateForm.value.loginName; |
||||
this.validateForm.value['user']['password'] = this.validateForm.value.password; |
||||
if (this.editFlag) { |
||||
this.validateForm.value['company'].id = this.id; |
||||
this.validateForm.value['company'].status = 1; |
||||
this.validateForm.value['company'].createTime = this.time; |
||||
this.validateForm.value['user'].id = this.userId; |
||||
this.company.updateCompany(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('修改成功'); |
||||
} else { |
||||
this.message.create('error', '修改失败'); |
||||
} |
||||
}); |
||||
} else { |
||||
|
||||
this.company.addCompanyAndUser(this.validateForm.value, data => { |
||||
console.log(data); |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('添加成功'); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
// 图片查看
|
||||
handlePreview = async (file: NzUploadFile) => { |
||||
if (!file.url && !file.preview) { |
||||
// tslint:disable-next-line:no-non-null-assertion
|
||||
file.preview = await getBase64(file.originFileObj!); |
||||
} |
||||
this.previewImage = file.url || file.preview; |
||||
this.previewVisible = true; |
||||
} |
||||
|
||||
public getDetails(id) { |
||||
this.company.companyView(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
data['return_data']['company'].loginName = data['return_data'].user.loginName; |
||||
data['return_data']['company'].password = data['return_data'].user.password; |
||||
this.regionId = data['return_data'].company.regionId; |
||||
this.userId = data['return_data'].user.id; |
||||
this.time = data['return_data'].company.createTime; |
||||
if (data['return_data']['company']['logo'] != null && data['return_data']['company']['logo'] !== '') { |
||||
const logo = String(data['return_data']['company']['logo']); |
||||
const logoArray = []; |
||||
logoArray.push( |
||||
{ |
||||
uid: 1, |
||||
name: logo, |
||||
status: 'done', |
||||
url: environment.imageUrl + logo |
||||
}); |
||||
this.logoFile = logoArray; |
||||
} |
||||
this.validateForm.patchValue(data['return_data']['company']); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
regionChange(regionId) { |
||||
this.regionId = regionId; |
||||
} |
||||
} |
@ -0,0 +1,87 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
|
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">公司名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="name"/> |
||||
</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>共计 {{total}} 条数据</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/company/company-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button> |
||||
</div> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="80px">所属地区</th> |
||||
<th nzWidth="80px">公司名称</th> |
||||
<th nzWidth="80px">公司LOGO</th> |
||||
<th nzWidth="70px">联系方式</th> |
||||
<th nzWidth="100px">地址</th> |
||||
<th nzWidth="100px">创建时间</th> |
||||
<th nzWidth="100px">更新时间</th> |
||||
<th nzWidth="80px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.regionName}}</td> |
||||
<td>{{data.name}}</td> |
||||
<td> |
||||
<img class="head_img" src="{{WEB_SERVE_URL + data.logo}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt=""> |
||||
</td> |
||||
<td>{{data.phone}}</td> |
||||
<td>{{data.address}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.updateTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)="getDetail(data.id)"><i nz-icon [nzIconfont]="'icon-xiangqing'" nz-tooltip="公司详情"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)='getForbiddenUser(data.id , data.status)'><i nz-icon nzType="{{data.status === 1 ? 'stop': 'check-circle'}}" nzTheme="outline" nz-tooltip="{{data.status === 1 ? '禁用': '启用'}}"></i></a> |
||||
|
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
|
@ -0,0 +1,4 @@ |
||||
.head_img { |
||||
height: 60px; |
||||
width: 60px; |
||||
} |
@ -0,0 +1,105 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {Router} from '@angular/router'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {CompanyService} from '../../../services/company.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-company-list', |
||||
templateUrl: './company-list.component.html', |
||||
styleUrls: ['./company-list.component.scss'] |
||||
}) |
||||
export class CompanyListComponent implements OnInit { |
||||
WEB_SERVE_URL = environment.imageUrl; |
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
|
||||
constructor( |
||||
private form: FormBuilder, |
||||
private company: CompanyService, |
||||
private iconService: IconService, |
||||
private message: NzMessageService, |
||||
private router: Router, |
||||
private common: CommonsService |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.init(); |
||||
} |
||||
|
||||
public init(): void { |
||||
this.searchForm = this.form.group({ |
||||
name: [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.company.selectCompanyList(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 getForbiddenUser(id, status: any): void { |
||||
const message = (status === 1 ? '是否禁用当前公司' : '是否启用当前公司'); |
||||
|
||||
const s = status === 1 ? 0 : 1; |
||||
|
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.company.editStatus(id, s , dataUser => { |
||||
this.getRequest(false , this.searchForm.value); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
// 修改
|
||||
public getEdit(id: number): void { |
||||
this.router.navigate(['/admin/company/company-edit'], { |
||||
queryParams: { |
||||
companyId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 查看详情
|
||||
public getDetail(id: number): void { |
||||
this.router.navigate(['/admin/company/company-detail'], { |
||||
queryParams: { |
||||
companyId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -0,0 +1,18 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {CompanyEditComponent} from './company-edit/company-edit.component'; |
||||
import {CompanyDetailComponent} from './company-detail/company-detail.component'; |
||||
import {CompanyListComponent} from './company-list/company-list.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'company-list', component: CompanyListComponent }, |
||||
{ path: 'company-edit', component: CompanyEditComponent}, |
||||
{ path: 'company-detail', component: CompanyDetailComponent} |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class CompanyRoutingModule { } |
@ -0,0 +1,28 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { CompanyRoutingModule } from './company-routing.module'; |
||||
import { CompanyListComponent } from './company-list/company-list.component'; |
||||
import { CompanyEditComponent } from './company-edit/company-edit.component'; |
||||
import { CompanyDetailComponent } from './company-detail/company-detail.component'; |
||||
import {NgZorroAntdModule} from 'ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [CompanyListComponent, CompanyEditComponent, CompanyDetailComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
CompanyRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
RegionSelectorModule |
||||
] |
||||
}) |
||||
export class CompanyModule { } |
@ -0,0 +1 @@ |
||||
<p>coupon-detail works!</p> |
@ -0,0 +1,15 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
|
||||
@Component({ |
||||
selector: 'app-coupon-detail', |
||||
templateUrl: './coupon-detail.component.html', |
||||
styleUrls: ['./coupon-detail.component.scss'] |
||||
}) |
||||
export class CouponDetailComponent implements OnInit { |
||||
|
||||
constructor() { } |
||||
|
||||
ngOnInit(): void { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,225 @@ |
||||
<!-- start 面包屑 --> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
<a (click)="getBack()">卡券管理</a> |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
编辑卡券 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<nz-content class="inner-content"> |
||||
<form nz-form [formGroup]="validateForm" class="ant-advanced-search-form"> |
||||
<div nz-row [nzGutter]="24"> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'couponName'" nzRequired>卡券名称</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入卡券名称!"> |
||||
<input nz-input placeholder="请输入卡券名称..." [formControlName]="'couponName'" id="'couponName'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'couponType'" nzRequired>卡券类型</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择卡券类型!"> |
||||
<nz-select nzPlaceHolder="请选择卡券类型" [formControlName]="'couponType'"> |
||||
<nz-option nzValue="1" nzLabel="内部卷"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="外部卷"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'displayArea'" nzRequired>展示区域</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择展示区域!"> |
||||
<nz-select nzPlaceHolder="请选择展示区域" [formControlName]="'displayArea'"> |
||||
<nz-option nzValue="1" nzLabel="赠券专区"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="金币专区"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'payType'" nzRequired>支付类型</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择支付类型!"> |
||||
<nz-select nzPlaceHolder="请选择支付类型" [formControlName]="'payType'"> |
||||
<nz-option nzValue="1" nzLabel="微信支付"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="金币支付"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'couponPrice'" nzRequired>卡券面值</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入卡券面值!"> |
||||
<input nz-input placeholder="请输入卡券面值..." [formControlName]="'couponPrice'" id="'couponPrice'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'salesPrice'" nzRequired>销售价格</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入销售价格!"> |
||||
<input nz-input placeholder="请输入销售价格..." [formControlName]="'salesPrice'" id="'salesPrice'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'discountPrice'" nzRequired>折扣价格</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入折扣价格!"> |
||||
<input nz-input placeholder="请输入折扣价格..." [formControlName]="'discountPrice'" id="'discountPrice'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'limitNumber'" nzRequired>限购数量</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入限购数量!"> |
||||
<input nz-input placeholder="请输入限购数量 ..." [formControlName]="'limitNumber'" id="'limitNumber'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'merchantId'" nzRequired>选择商户</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择商户!"> |
||||
<nz-select |
||||
(nzScrollToBottom)="loadMore()" |
||||
(nzOnSearch)="search($event)" |
||||
nzShowSearch |
||||
[formControlName]="'merchantId'" |
||||
nzServerSearch |
||||
nzPlaceHolder="请选择商户" |
||||
nzAllowClear |
||||
[nzDropdownRender]="renderTemplate" |
||||
> |
||||
<nz-option *ngFor="let o of optionList" [nzValue]="o.id" [nzLabel]="o.merchantName"></nz-option> |
||||
</nz-select> |
||||
<ng-template #renderTemplate> |
||||
<nz-spin *ngIf="isLoading"></nz-spin> |
||||
</ng-template> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'salesEndTime'" nzRequired>截止日期</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择销售截止日期!"> |
||||
<nz-date-picker |
||||
nzFormat="yyyy-MM-dd" |
||||
[formControlName]="'salesEndTime'" |
||||
></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'recycleDay'" nzRequired>归库天数</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入归库天数!"> |
||||
<nz-input-number [formControlName]="'recycleDay'" [nzMin]="1" [nzMax]="10" [nzStep]="1"></nz-input-number> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'isPresent'" nzRequired>是否赠送卡券</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择是否赠送卡券!"> |
||||
<nz-switch [formControlName]="'isPresent'" ></nz-switch> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
|
||||
<div nz-col [nzSpan]="16" *ngIf="validateForm.value.isPresent"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'handselCouponId'" nzRequired>选择卡券</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择卡券!"> |
||||
<nz-select |
||||
[formControlName]="'handselCouponId'" |
||||
(nzScrollToBottom)="loadMoreCoupon()" |
||||
(nzOnSearch)="searchCoupon($event)" |
||||
nzShowSearch |
||||
nzMode="multiple" |
||||
nzServerSearch |
||||
nzPlaceHolder="请选择卡券" |
||||
nzAllowClear |
||||
[nzDropdownRender]="renderTemplateCoupon" |
||||
> |
||||
<nz-option *ngFor="let o of optionListCoupon" [nzValue]="o.id" [nzLabel]="o.couponName"></nz-option> |
||||
</nz-select> |
||||
<ng-template #renderTemplateCoupon> |
||||
<nz-spin *ngIf="isLoading"></nz-spin> |
||||
</ng-template> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label nzRequired>卡券图片</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-upload |
||||
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="couponImg" |
||||
[nzShowButton]="couponImg.length < 1" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传图片</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
|
||||
<div nz-col [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label nzRequired>卡卷轮播图</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-upload |
||||
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="couponCarouselImg" |
||||
[nzShowButton]="couponCarouselImg.length < 5" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传图片</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="20"> |
||||
<nz-form-item> |
||||
<nz-form-label nzRequired>卡券介紹</nz-form-label> |
||||
<nz-form-control> |
||||
<app-richtext [content]='content' (newTextEvent)="textData($event)"></app-richtext> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
<div nz-row> |
||||
<div nz-col [nzSpan]="24" class="search-area"> |
||||
<button nz-button (click)="resetForm()">重置</button> |
||||
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
</nz-content> |
@ -0,0 +1,6 @@ |
||||
button { |
||||
margin-left: 8px; |
||||
} |
||||
:host ::ng-deep .ant-upload { |
||||
background-color: #ffffff; |
||||
} |
@ -0,0 +1,300 @@ |
||||
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 {ActivatedRoute} from '@angular/router'; |
||||
import {CouponService} from '../../../services/coupon.service'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
||||
return new Promise((resolve, reject) => { |
||||
const reader = new FileReader(); |
||||
reader.readAsDataURL(file); |
||||
reader.onload = () => resolve(reader.result); |
||||
reader.onerror = error => reject(error); |
||||
}); |
||||
} |
||||
|
||||
@Component({ |
||||
selector: 'app-coupon-edit', |
||||
templateUrl: './coupon-edit.component.html', |
||||
styleUrls: ['./coupon-edit.component.scss'] |
||||
}) |
||||
export class CouponEditComponent implements OnInit { |
||||
|
||||
|
||||
|
||||
validateForm!: FormGroup; |
||||
data: any; |
||||
editFlag = false; |
||||
id: number; |
||||
couponImg = []; |
||||
couponCarouselImg = []; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
previewImage: string | undefined = ''; |
||||
previewVisible = false; |
||||
optionList: string[] = []; |
||||
isLoading = false; |
||||
pageNum = 1; |
||||
pageSize = 10; |
||||
pageSizeCoupon = 10; |
||||
merchantName: string; |
||||
optionListCoupon: string[] = []; |
||||
isLoadingCoupon = false; |
||||
pageNumCoupon = 1; |
||||
couponName: string; |
||||
content: string; |
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private merchant: MerchantService, |
||||
private coupon: CouponService, |
||||
private common: CommonsService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.couponId != null) { |
||||
this.editFlag = true; |
||||
this.id = queryParams.couponId; |
||||
this.getDetails(queryParams.couponId); |
||||
this.pageSize = 10000; |
||||
this.pageSizeCoupon = 10000; |
||||
this.loadMore(); |
||||
this.loadMoreCoupon(); |
||||
} |
||||
}); |
||||
this.validateForm = this.fb.group({ |
||||
couponName: [null, [Validators.required]], |
||||
couponPrice: [null, [Validators.required]], |
||||
couponDesc: [null], |
||||
couponType: [null, [Validators.required]], |
||||
salesEndTime: [null, [Validators.required]], |
||||
recycleDay: [1, [Validators.required]], |
||||
limitNumber: [null, [Validators.required]], |
||||
salesPrice: [null, [Validators.required]], |
||||
discountPrice: [null, [Validators.required]], |
||||
merchantId: [null, [Validators.required]], |
||||
isPresent: [false, [Validators.required]], |
||||
payType: [false, [Validators.required]], |
||||
displayArea: [false, [Validators.required]], |
||||
handselCouponId: [null], |
||||
status: [null], |
||||
couponKey: [null], |
||||
createTime: [null], |
||||
secUser: {}, |
||||
}); |
||||
} |
||||
|
||||
|
||||
// 查询商户
|
||||
loadMore(): void { |
||||
this.isLoading = true; |
||||
const paramsObject = { |
||||
pageNum: this.pageNum, |
||||
pageSize: this.pageSize, |
||||
merchantName: this.merchantName, |
||||
}; |
||||
this.getMerchantList(paramsObject); |
||||
} |
||||
|
||||
// 搜索商户
|
||||
search(e): void { |
||||
this.optionList = []; |
||||
this.isLoading = true; |
||||
this.merchantName = e; |
||||
this.pageNum = 1; |
||||
const paramsObject = { |
||||
pageNum: this.pageNum, |
||||
pageSize: this.pageSize, |
||||
merchantName: e, |
||||
}; |
||||
this.getMerchantList(paramsObject); |
||||
} |
||||
|
||||
// 查询商户
|
||||
public getMerchantList(paramsObject): void { |
||||
this.merchant.getMerchantList(paramsObject , data => { |
||||
if (data['return_code'] === '000000' && this.pageNum <= data['return_data'].pages ) { |
||||
this.pageNum ++; |
||||
this.isLoading = false; |
||||
this.optionList = [...this.optionList, ...data['return_data'].list]; |
||||
} else { |
||||
this.isLoading = false; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 查询卡券
|
||||
loadMoreCoupon(): void { |
||||
this.isLoadingCoupon = true; |
||||
const paramsObject = { |
||||
pageNum: this.pageNumCoupon, |
||||
pageSize: this.pageSizeCoupon, |
||||
merchantName: this.merchantName, |
||||
}; |
||||
this.getCouponList(paramsObject); |
||||
} |
||||
|
||||
// 搜索卡券
|
||||
searchCoupon(e): void { |
||||
this.optionListCoupon = []; |
||||
this.isLoadingCoupon = true; |
||||
this.merchantName = e; |
||||
this.pageNumCoupon = 1; |
||||
const paramsObject = { |
||||
pageNum: this.pageNumCoupon, |
||||
pageSize: this.pageSizeCoupon, |
||||
merchantName: e, |
||||
}; |
||||
this.getCouponList(paramsObject); |
||||
} |
||||
|
||||
// 查询卡券
|
||||
public getCouponList(paramsObject): void { |
||||
this.coupon.getCouponList(paramsObject , data => { |
||||
if (data['return_code'] === '000000' && this.pageNumCoupon <= data['return_data'].pages ) { |
||||
this.pageNumCoupon ++; |
||||
this.isLoadingCoupon = false; |
||||
this.optionListCoupon = [...this.optionListCoupon, ...data['return_data'].list]; |
||||
} else { |
||||
this.isLoadingCoupon = false; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 返回
|
||||
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.couponImg.length !== 0) { |
||||
if (this.couponImg[0]['response'] != null) { |
||||
this.validateForm.value.couponImg = this.couponImg[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateForm.value.couponImg = this.couponImg[0].name; |
||||
} |
||||
} else { |
||||
this.message.error('请上传卡券图片'); |
||||
return; |
||||
} |
||||
|
||||
const couponCarouselImg = []; |
||||
|
||||
if (this.couponCarouselImg.length !== 0) { |
||||
for (const i of this.couponCarouselImg) { |
||||
if (i['response'] != null) { |
||||
couponCarouselImg.push(i['response']['return_data'][0]); |
||||
} else { |
||||
couponCarouselImg.push(i.name); |
||||
} |
||||
} |
||||
} else { |
||||
this.message.error('请上传卡券轮播图'); |
||||
return; |
||||
} |
||||
this.validateForm.value.couponCarouselImg = couponCarouselImg.join(','); |
||||
this.validateForm.value.couponDesc = this.content; |
||||
if (this.editFlag) { |
||||
this.common.showConfirm('是否确定修改,确定将下架' , dataR => { |
||||
if (dataR) { |
||||
this.validateForm.value.id = this.id; |
||||
this.coupon.updateCoupon(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('修改成功,卡券已下架!'); |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} else { |
||||
|
||||
this.coupon.insertCoupon(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('添加成功'); |
||||
} else { |
||||
this.message.error(data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
// 图片查看
|
||||
handlePreview = async (file: NzUploadFile) => { |
||||
if (!file.url && !file.preview) { |
||||
// tslint:disable-next-line:no-non-null-assertion
|
||||
file.preview = await getBase64(file.originFileObj!); |
||||
} |
||||
this.previewImage = file.url || file.preview; |
||||
this.previewVisible = true; |
||||
} |
||||
|
||||
public getDetails(id) { |
||||
this.coupon.getCouponById(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
data['return_data']['couponType'] = String(data['return_data']['couponType']); |
||||
data['return_data']['displayArea'] = String(data['return_data']['displayArea']); |
||||
data['return_data']['payType'] = String(data['return_data']['payType']); |
||||
this.content = data['return_data']['couponDesc']; |
||||
if (data['return_data']['couponImg'] != null && data['return_data']['couponImg'] !== '') { |
||||
const couponImg = String(data['return_data']['couponImg']); |
||||
const couponArray = []; |
||||
couponArray.push( |
||||
{ |
||||
uid: 1, |
||||
name: couponImg, |
||||
status: 'done', |
||||
url: environment.imageUrl + couponImg |
||||
}); |
||||
this.couponImg = couponArray; |
||||
} |
||||
if (data['return_data']['couponCarouselImg'] != null && data['return_data']['couponCarouselImg'] !== '') { |
||||
const couponCarouselImg = data['return_data']['couponCarouselImg'].split(','); |
||||
const couponCarouselArray = []; |
||||
for (const i of couponCarouselImg) { |
||||
couponCarouselArray.push( |
||||
{ |
||||
uid: 1, |
||||
name: i, |
||||
status: 'done', |
||||
url: environment.imageUrl + i |
||||
}); |
||||
} |
||||
this.couponCarouselImg = couponCarouselArray; |
||||
} |
||||
this.validateForm.patchValue(data['return_data']); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 富文本内容
|
||||
textData(content) { |
||||
this.content = content; |
||||
} |
||||
} |
@ -0,0 +1,142 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
|
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">卡券名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="couponName"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">商户</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select |
||||
(nzScrollToBottom)="loadMore()" |
||||
(nzOnSearch)="search($event)" |
||||
nzShowSearch |
||||
[formControlName]="'merchantId'" |
||||
nzServerSearch |
||||
nzPlaceHolder="请选择商户" |
||||
nzAllowClear |
||||
[nzDropdownRender]="renderTemplate" |
||||
> |
||||
<nz-option *ngFor="let o of optionList" [nzValue]="o.id" [nzLabel]="o.merchantName"></nz-option> |
||||
</nz-select> |
||||
<ng-template #renderTemplate> |
||||
<nz-spin *ngIf="isLoading"></nz-spin> |
||||
</ng-template> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">卡券类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select [formControlName]="'couponType'"> |
||||
<nz-option nzValue="1" nzLabel="内部卷"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="外部卷"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">卡券状态</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select [formControlName]="'status'"> |
||||
<nz-option nzValue="1" nzLabel="编辑中"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="已上架"></nz-option> |
||||
<nz-option nzValue="3" nzLabel="已下架"></nz-option> |
||||
<nz-option nzValue="101" nzLabel="上架审批中"></nz-option> |
||||
<nz-option nzValue="102" nzLabel="上架审批驳回"></nz-option> |
||||
</nz-select> |
||||
</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>共计 {{total}} 条数据</span> |
||||
<span *ngIf="id != null" style="margin-left: 30px;;"> |
||||
商戶名称: |
||||
<span style="font-weight: bold; font-size: 20px">{{name}}</span> |
||||
</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/coupon/coupon-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button> |
||||
</div> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="80px">卡券编号</th> |
||||
<th nzWidth="80px">卡券名称</th> |
||||
<th nzWidth="100px">卡券面值</th> |
||||
<th nzWidth="100px">销售价格</th> |
||||
<th nzWidth="100px">有效库存</th> |
||||
<th nzWidth="100px">卡券类型</th> |
||||
<th nzWidth="100px">卡券状态</th> |
||||
<th nzWidth="120px">销售截止时间</th> |
||||
<th nzWidth="120px">创建时间</th> |
||||
<th nzWidth="150px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.couponKey}}</td> |
||||
<td>{{data.couponName}}</td> |
||||
<td>¥{{data.couponPrice}}</td> |
||||
<td>¥{{data.salesPrice}}</td> |
||||
<td>{{data.stockCount}}</td> |
||||
<td>{{data.couponType === 1 ? '内部卷' : '外部卷'}}</td> |
||||
<td>{{data.status | couponStatus}}</td> |
||||
<td>{{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a *ngIf="data.status !== 101" (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a> |
||||
<nz-divider nzType="vertical" *ngIf="data.status === 1 || data.status === 3 || data.status === 102"></nz-divider> |
||||
<a *ngIf="data.status === 1 || data.status === 3 || data.status === 102" (click)="enableMerchant(data.id)"> <i nz-icon [nzIconfont]="'icon-shangjia'" nz-tooltip="上架"></i></a> |
||||
<nz-divider *ngIf="data.status === 2" nzType="vertical"></nz-divider> |
||||
<a *ngIf="data.status === 2" (click)="disableMerchant(data.id)"> <i nz-icon [nzIconfont]="'icon-xiajia'" nz-tooltip="下架"></i></a> |
||||
<nz-divider *ngIf="data.status !== 101" nzType="vertical"></nz-divider> |
||||
<a (click)="getList(data.id , data.couponName , data.couponType)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="销售码列表"></i></a> |
||||
<nz-divider *ngIf="data.status !== 101" nzType="vertical"></nz-divider> |
||||
<a *ngIf="data.status !== 101" (click)="getDelete(data.id)"><i nz-icon nzType="delete" nzTheme="outline" nz-tooltip="删除"></i></a> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
|
@ -0,0 +1,207 @@ |
||||
import {Component, OnInit} from '@angular/core'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {MerchantStoreService} from '../../../services/merchant-store.service'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {ActivatedRoute, Router} from '@angular/router'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {CouponService} from '../../../services/coupon.service'; |
||||
import {MerchantService} from '../../../services/merchant.service'; |
||||
|
||||
@Component({ |
||||
selector: 'app-coupon-list', |
||||
templateUrl: './coupon-list.component.html', |
||||
styleUrls: ['./coupon-list.component.scss'] |
||||
}) |
||||
export class CouponListComponent implements OnInit { |
||||
|
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
id = null; |
||||
name: string; |
||||
merchantName: string; |
||||
optionList: string[] = []; |
||||
isLoading = false; |
||||
pageNumMer = 1; |
||||
constructor( |
||||
private form: FormBuilder, |
||||
private coupon: CouponService, |
||||
private merchant: MerchantService, |
||||
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({ |
||||
merchantId: [null], |
||||
couponName: [null], |
||||
couponType: [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.coupon.getCouponList(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 getDelete(id): void { |
||||
const message = '是否删除门店'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
// this.coupon.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 getEdit(id: number): void { |
||||
this.router.navigate(['/admin/coupon/coupon-edit'], { |
||||
queryParams: { |
||||
couponId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 查看详情
|
||||
public getDetail(id: number): void { |
||||
this.router.navigate(['/admin/merchantStore/store-detail'], { |
||||
queryParams: { |
||||
storeId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 查询商户
|
||||
loadMore(): void { |
||||
this.isLoading = true; |
||||
const paramsObject = { |
||||
pageNum: this.pageNumMer, |
||||
pageSize: 10, |
||||
merchantName: this.merchantName, |
||||
}; |
||||
this.getMerchantList(paramsObject); |
||||
} |
||||
|
||||
// 搜索商户
|
||||
search(e): void { |
||||
this.optionList = []; |
||||
this.isLoading = true; |
||||
this.merchantName = e; |
||||
this.pageNumMer = 1; |
||||
const paramsObject = { |
||||
pageNum: this.pageNumMer, |
||||
pageSize: 10, |
||||
merchantName: e, |
||||
}; |
||||
this.getMerchantList(paramsObject); |
||||
} |
||||
|
||||
// 查询商户
|
||||
public getMerchantList(paramsObject): void { |
||||
this.merchant.getMerchantList(paramsObject , data => { |
||||
if (data['return_code'] === '000000' && this.pageNumMer <= data['return_data'].pages ) { |
||||
this.pageNumMer ++; |
||||
this.isLoading = false; |
||||
this.optionList = [...this.optionList, ...data['return_data'].list]; |
||||
} else { |
||||
this.isLoading = false; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 下架卡券
|
||||
public disableMerchant(id): void { |
||||
const message = '是否下架卡券'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.coupon.ofShelfApprove(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 = '是否上架审核卡券'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.coupon.upShelfApprove(id, dataReturn => { |
||||
if (dataReturn['return_code'] === '000000') { |
||||
this.message.success('操作成功'); |
||||
this.getRequest(false , this.searchForm.value); |
||||
} else { |
||||
this.message.warning(dataReturn['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 查看门店列表
|
||||
public getList(id: number , couponName: string , couponType: number): void { |
||||
this.router.navigate(['/admin/coupon/salesCode-list'], { |
||||
queryParams: { |
||||
couponId: id, |
||||
name: couponName, |
||||
type: couponType, |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {CouponListComponent} from './coupon-list/coupon-list.component'; |
||||
import {CouponEditComponent} from './coupon-edit/coupon-edit.component'; |
||||
import {CouponDetailComponent} from './coupon-detail/coupon-detail.component'; |
||||
import {SalesCodeListComponent} from './sales-code-list/sales-code-list.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'coupon-list', component: CouponListComponent }, |
||||
{ path: 'coupon-edit', component: CouponEditComponent }, |
||||
{ path: 'coupon-detail', component: CouponDetailComponent }, |
||||
{ path: 'salesCode-list', component: SalesCodeListComponent }, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class CouponRoutingModule { } |
@ -0,0 +1,30 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { CouponRoutingModule } from './coupon-routing.module'; |
||||
import { CouponListComponent } from './coupon-list/coupon-list.component'; |
||||
import { CouponEditComponent } from './coupon-edit/coupon-edit.component'; |
||||
import { CouponDetailComponent } from './coupon-detail/coupon-detail.component'; |
||||
import {NgZorroAntdModule} from 'ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {RichtextModule} from '../../common/richtext/richtext.module'; |
||||
import {AppCommonModule} from '../../app-common.module'; |
||||
import { SalesCodeListComponent } from './sales-code-list/sales-code-list.component'; |
||||
|
||||
@NgModule({ |
||||
declarations: [CouponListComponent, CouponEditComponent, CouponDetailComponent, SalesCodeListComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
CouponRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
RichtextModule, |
||||
AppCommonModule |
||||
] |
||||
}) |
||||
export class CouponModule { } |
@ -0,0 +1,168 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
|
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">消费码KEY</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="salesCode"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">消费码状态</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select formControlName="status"> |
||||
<nz-option nzValue="1" nzLabel="待销售"></nz-option> |
||||
<nz-option nzValue="2" nzLabel="待使用"></nz-option> |
||||
<nz-option nzValue="3" nzLabel="已使用"></nz-option> |
||||
<nz-option nzValue="4" nzLabel="已过期"></nz-option> |
||||
</nz-select> |
||||
</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>共计 {{total}} 条数据</span> |
||||
<span *ngIf="id != null" style="margin-left: 30px;;"> |
||||
卡券名称: |
||||
<span style="font-weight: bold; font-size: 20px">{{name}}({{type === 1 ? '内部卷' : '外部卷'}})</span> |
||||
</span> |
||||
<div class="operating-button"> |
||||
<button *ngIf="type === 1" nz-button nzType="primary" class="right-btn" (click)="showModal()"><i nz-icon |
||||
nzType="import" |
||||
nzTheme="outline"></i>生成消费码 |
||||
</button> |
||||
<nz-upload |
||||
*ngIf="type === 2" |
||||
[nzAccept]="'.xls,.xlsx'" |
||||
nzAction="{{WEB_SERVE_URL}}coupon/importStock?couponId={{id}}" |
||||
[nzHeaders]="{ authorization: 'authorization-text' }" |
||||
(nzChange)="handleChange($event)" |
||||
[nzShowUploadList]="false" |
||||
> |
||||
<button nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>导入消费码</button> |
||||
</nz-upload> |
||||
</div> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="180px">消费码</th> |
||||
<th nzWidth="70px">订单ID</th> |
||||
<th nzWidth="120px">领取时间</th> |
||||
<th nzWidth="120px">消费时间</th> |
||||
<th nzWidth="120px">销售截止时间</th> |
||||
<th nzWidth="120px">使用截止时间</th> |
||||
<th nzWidth="120px">创建时间</th> |
||||
<th nzWidth="80px" nzRight="0px">状态</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i + 1}}</td> |
||||
<td>{{data.salesCode}}</td> |
||||
<td>{{data.orderId == null ? '暂无' : data.orderId}}</td> |
||||
<td>{{data.receiveTime == null ? '未领取' : data.receiveTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.consumeTime == null ? '未消费' : data.consumeTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.salesEndTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.useEndTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight="0px">{{data.status | couponCode}}</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="isVisible" nzTitle="生成消费码" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"> |
||||
<ng-container> |
||||
<form nz-form [formGroup]="codeForm"> |
||||
<div nz-row> |
||||
<div nz-col nzSpan="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'salesEndTime'" nzRequired>销售截止日期</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择销售截止日期!"> |
||||
<nz-date-picker nzFormat="yyyy-MM-dd" [formControlName]="'salesEndTime'" |
||||
></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="24"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'useEndTime'" nzRequired>使用截止日期</nz-form-label> |
||||
<nz-form-control nzErrorTip="请选择使用截止日期!"> |
||||
<nz-date-picker nzFormat="yyyy-MM-dd" [formControlName]="'useEndTime'" |
||||
></nz-date-picker> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="12"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'generateNum'" nzRequired>消费码数量</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入消费码!"> |
||||
<input nz-input placeholder="请输入消费码 ..." [formControlName]="'generateNum'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
</form> |
||||
</ng-container> |
||||
</nz-modal> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="errorStudentVisible" nzTitle="导入失败数据" (nzOnCancel)="handleCancelError()" nzWidth="900px" [nzFooter]="null"> |
||||
<nz-table #errorStudentTable [nzData]="importErrorStudentArray"> |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="80px">序号</th> |
||||
<th nzWidth="150px">销售码</th> |
||||
<th nzWidth="150px">销售截止时间</th> |
||||
<th nzWidth="150px">使用截止时间</th> |
||||
<th nzWidth="300px">原因</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of errorStudentTable.data;let i = index"> |
||||
<td>{{ i + 1}}</td> |
||||
<td>{{data.salesCode}}</td> |
||||
<td>{{data.salesEndTime}}</td> |
||||
<td>{{data.useEndTime}}</td> |
||||
<td>{{data.errorMessage}}</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</nz-modal> |
@ -0,0 +1,153 @@ |
||||
import {Component, OnInit} from '@angular/core'; |
||||
import {ActivatedRoute} from '@angular/router'; |
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
||||
import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd'; |
||||
import {CouponService} from '../../../services/coupon.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-sales-code-list', |
||||
templateUrl: './sales-code-list.component.html', |
||||
styleUrls: ['./sales-code-list.component.scss'] |
||||
}) |
||||
export class SalesCodeListComponent implements OnInit { |
||||
|
||||
searchForm: FormGroup; // 搜索框
|
||||
codeForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
id = null; |
||||
name: string; |
||||
type: number; |
||||
isVisible = false; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
importErrorStudentArray = []; |
||||
errorStudentVisible = false; |
||||
|
||||
constructor( |
||||
private form: FormBuilder, |
||||
private activatedRoute: ActivatedRoute, |
||||
private message: NzMessageService, |
||||
private modal: NzModalService, |
||||
private coupon: CouponService |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.couponId != null) { |
||||
this.id = queryParams.couponId; |
||||
this.name = queryParams.name; |
||||
this.type = Number(queryParams.type); |
||||
this.searchForm = this.form.group({ |
||||
status: [null], |
||||
salesCode: [null], |
||||
}); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} |
||||
}); |
||||
this.codeForm = this.form.group({ |
||||
salesEndTime: [null, [Validators.required]], |
||||
useEndTime: [null, [Validators.required]], |
||||
generateNum: [null, [Validators.required]], |
||||
}); |
||||
} |
||||
|
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false, whereObject: object) { |
||||
|
||||
this.loading = false; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
whereObject['couponId'] = this.id; |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
this.coupon.getCouponCodeList(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(); |
||||
} |
||||
|
||||
showModal(): void { |
||||
this.isVisible = true; |
||||
} |
||||
|
||||
handleOk(): void { |
||||
// tslint:disable-next-line:forin
|
||||
for (const i in this.codeForm.controls) { |
||||
this.codeForm.controls[i].markAsDirty(); |
||||
this.codeForm.controls[i].updateValueAndValidity(); |
||||
if (this.codeForm.controls[i].errors != null) { |
||||
this.message.error('必填项不能为空'); |
||||
return; |
||||
} |
||||
} |
||||
this.codeForm.value['couponId'] = this.id; |
||||
this.coupon.writeStock(this.codeForm.value , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.message.success('生成成功'); |
||||
} else { |
||||
this.message.create('error', '生成失败'); |
||||
} |
||||
}); |
||||
this.isVisible = false; |
||||
} |
||||
|
||||
handleCancel(): void { |
||||
console.log('Button cancel clicked!'); |
||||
this.isVisible = false; |
||||
} |
||||
|
||||
handleCancelError(): void { |
||||
this.errorStudentVisible = false; |
||||
} |
||||
|
||||
handleChange(info: NzUploadChangeParam): void { |
||||
if (info.file.status !== 'uploading') { |
||||
console.log(info.file, info.fileList); |
||||
} |
||||
if (info.file.status === 'done') { |
||||
if (info.file.response.return_code === '000000') { |
||||
this.loading = false; |
||||
if (info.file.response.return_data == null || info.file.response.return_data.length === 0) { |
||||
this.message.success('导入成功'); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} else { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzOkText: '查看失败数据', |
||||
nzContent: '只有部分数据导入成功', |
||||
nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data) |
||||
}); |
||||
} |
||||
} else { |
||||
this.loading = false; |
||||
this.message.error(info.file.response.return_msg); |
||||
} |
||||
} else if (info.file.status === 'error') { |
||||
this.message.error('上传错误'); |
||||
} |
||||
} |
||||
|
||||
// 打开模态框
|
||||
showErrorStudentModal(data: []) { |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.importErrorStudentArray = data['errorData']; |
||||
this.errorStudentVisible = true; |
||||
} |
||||
} |
@ -1,18 +0,0 @@ |
||||
<div nz-row> |
||||
<div nz-col [nzSpan]="8"> |
||||
<!--<div>职位发布数量排名</div>--> |
||||
<div echarts [options]="positionTopTen"></div> |
||||
<div class="enterprise-top" echarts [options]="enterpriseTopTen"></div> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<div echarts [options]="resumeByAge"></div> |
||||
<div class="enterprise-top" echarts [options]="deliveryByMonth"></div> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<div echarts [options]="resumeByEdu"></div> |
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {StoreListComponent} from './store-list/store-list.component'; |
||||
import {StoreEditComponent} from './store-edit/store-edit.component'; |
||||
import {StoreDetailComponent} from './store-detail/store-detail.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'store-list', component: StoreListComponent }, |
||||
{ path: 'store-edit', component: StoreEditComponent }, |
||||
{ path: 'store-detail', component: StoreDetailComponent }, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class MerchantStoreRoutingModule { } |
@ -0,0 +1,26 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { MerchantStoreRoutingModule } from './merchant-store-routing.module'; |
||||
import { StoreListComponent } from './store-list/store-list.component'; |
||||
import { StoreEditComponent } from './store-edit/store-edit.component'; |
||||
import { StoreDetailComponent } from './store-detail/store-detail.component'; |
||||
import {NgZorroAntdModule} from 'ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [StoreListComponent, StoreEditComponent, StoreDetailComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
MerchantStoreRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule |
||||
] |
||||
}) |
||||
export class MerchantStoreModule { } |
@ -0,0 +1,18 @@ |
||||
<div class="inner-content"> |
||||
<nz-descriptions nzBordered> |
||||
<nz-descriptions-item nzTitle="登录账户">{{data.telephone}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="门店编号">{{data['storeKey']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="门店名称">{{data.storeName}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="门店地址">{{data.address}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="地址经度">{{data.longitude}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="地址纬度">{{data.latitude}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="创建时间"> |
||||
{{data.createTime | date: 'yyyy-MM-dd'}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="更新时间"> |
||||
{{data.updateTime | date: 'yyyy-MM-dd'}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="操作人员">{{data.operatorName }}</nz-descriptions-item> |
||||
|
||||
</nz-descriptions> |
||||
</div> |
@ -0,0 +1,40 @@ |
||||
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', |
||||
templateUrl: './store-detail.component.html', |
||||
styleUrls: ['./store-detail.component.scss'] |
||||
}) |
||||
export class StoreDetailComponent implements OnInit { |
||||
|
||||
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']; |
||||
|
||||
}); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,108 @@ |
||||
<!-- start 面包屑 --> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
<a (click)="getBack()">门店管理</a> |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
编辑门店 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
|
||||
<nz-content class="inner-content"> |
||||
<form nz-form [formGroup]="validateForm" class="ant-advanced-search-form"> |
||||
<div nz-row [nzGutter]="24"> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'telephone'" nzRequired>登录手机号</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入登录手机号!"> |
||||
<input nz-input placeholder="请输入登录手机号..." [formControlName]="'telephone'" id="'telephone'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'password'" nzRequired>登录密码</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入登录密码!"> |
||||
<nz-input-group [nzSuffix]="suffixTemplate"> |
||||
<input [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="请输入登录密码..." [formControlName]="'password'" id="'password'" /> |
||||
</nz-input-group> |
||||
<ng-template #suffixTemplate> |
||||
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i> |
||||
</ng-template> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'storeKey'" nzRequired>门店编号</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入门店编号!"> |
||||
<input nz-input placeholder="请输入门店编号..." [formControlName]="'storeKey'" id="'storeKey'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'storeName'" nzRequired>门店名称</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入门店名称!"> |
||||
<input nz-input placeholder="请输入门店名称..." [formControlName]="'storeName'" id="'storeName'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'latitude'" nzRequired>地址维度</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入门店地址维度!"> |
||||
<input nz-input placeholder="请输入门店地址维度..." readonly [formControlName]="'latitude'" id="'latitude'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'longitude'" nzRequired>地址经度</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入门店地址维度!"> |
||||
<input nz-input placeholder="请输入门店地址维度..." readonly [formControlName]="'longitude'" id="'longitude'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="14"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'address'" nzRequired>门店地址</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入门店地址!"> |
||||
<input nz-input placeholder="请输入门店地址..." [formControlName]="'address'" id="'address'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="24"> |
||||
<nz-form-item> |
||||
<nz-form-label nzRequired>设置定位</nz-form-label> |
||||
<nz-form-control> |
||||
<div id="container"></div> |
||||
<div > |
||||
<table> |
||||
<tr> |
||||
<td> |
||||
<label>请输入关键字:</label> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td> |
||||
<input nz-input id="input" /> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</div> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
<div nz-row> |
||||
<div nz-col [nzSpan]="24" class="search-area"> |
||||
<button nz-button (click)="resetForm()">重置</button> |
||||
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
</nz-content> |
@ -0,0 +1,7 @@ |
||||
button { |
||||
margin-left: 8px; |
||||
} |
||||
:host ::ng-deep .ant-upload { |
||||
background-color: #ffffff; |
||||
} |
||||
#container {width:800px; height: 500px; } |
@ -0,0 +1,185 @@ |
||||
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 {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', |
||||
templateUrl: './store-edit.component.html', |
||||
styleUrls: ['./store-edit.component.scss'] |
||||
}) |
||||
export class StoreEditComponent implements OnInit { |
||||
|
||||
validateForm!: FormGroup; |
||||
data: any; |
||||
editFlag = false; |
||||
id: number; |
||||
passwordVisible = false; |
||||
logoFile = []; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
previewVisible = false; |
||||
|
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private merchantStore: MerchantStoreService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.storeId != null) { |
||||
this.editFlag = true; |
||||
this.id = queryParams.storeId; |
||||
this.getDetails(queryParams.storeId); |
||||
} else { |
||||
this.getMap(); |
||||
} |
||||
}); |
||||
this.validateForm = this.fb.group({ |
||||
telephone: [null, [Validators.required, ValidatorsService.mobile]], |
||||
password: [null, [Validators.required, ValidatorsService.minLength(6)]], |
||||
storeKey: [null, [Validators.required, ValidatorsService.maxLength(10)]], |
||||
storeName: [null, [Validators.required]], |
||||
address: [null, [Validators.required]], |
||||
latitude: [29.553134, [Validators.required]], |
||||
longitude: [106.565428, [Validators.required]], |
||||
status: [null], |
||||
companyId: [null], |
||||
regionId: [null], |
||||
merchantId: [null], |
||||
createTime: [null], |
||||
secUser: {}, |
||||
}); |
||||
|
||||
} |
||||
|
||||
// 返回
|
||||
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; |
||||
} |
||||
} |
||||
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) { |
||||
this.validateForm.value.merchantLogo = this.logoFile[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateForm.value.merchantLogo = this.logoFile[0].name; |
||||
} |
||||
} |
||||
if (this.editFlag) { |
||||
this.validateForm.value.id = this.id; |
||||
this.merchantStore.updateMerchantStore(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('修改成功'); |
||||
} else { |
||||
this.message.create('error', '修改失败'); |
||||
} |
||||
}); |
||||
} else { |
||||
|
||||
this.merchantStore.insertMerchantStore(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('添加成功'); |
||||
} else { |
||||
this.message.create('error', '保存失败'); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
public getDetails(id) { |
||||
this.merchantStore.getMerchantStoreById(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
data['return_data'].telephone = data['return_data'].secUser.loginName; |
||||
data['return_data'].password = data['return_data'].secUser.password; |
||||
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 => { |
||||
console.log(positionResult); |
||||
positionResult['latitude'] = positionResult.position.lat; |
||||
positionResult['longitude'] = positionResult.position.lng; |
||||
positionResult['regionId'] = positionResult.regeocode.addressComponent.adcode; |
||||
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 |
||||
})); |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,124 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
|
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">门店名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="storeName"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">门店电话</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="telephone"/> |
||||
</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>共计 {{total}} 条数据</span> |
||||
<span *ngIf="id != null" style="margin-left: 30px;;"> |
||||
商戶名称: |
||||
<span style="font-weight: bold; font-size: 20px">{{name}}</span> |
||||
</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/merchantStore/store-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button> |
||||
<nz-upload |
||||
[nzAccept]="'.xls,.xlsx'" |
||||
nzAction="{{WEB_SERVE_URL}}highMerchantStore/importMerchantStore" |
||||
[nzHeaders]="{ authorization: 'authorization-text' }" |
||||
(nzChange)="handleChange($event)" |
||||
[nzShowUploadList]="false" |
||||
> |
||||
<button nz-button nzType="primary" ><i nz-icon nzType="import" nzTheme="outline"></i>批量导入</button> |
||||
</nz-upload> |
||||
</div> |
||||
<nz-spin nzTip="批量导入中..." [nzSpinning]="isSpinning"> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="80px">所属地区</th> |
||||
<th nzWidth="80px">门店编号</th> |
||||
<th nzWidth="80px">门店名称</th> |
||||
<th nzWidth="100px">门店电话</th> |
||||
<th nzWidth="100px">创建时间</th> |
||||
<th nzWidth="80px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.regionName}}</td> |
||||
<td>{{data.storeKey}}</td> |
||||
<td>{{data.storeName}}</td> |
||||
<td>{{data.telephone}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)="getDetail(data.id)"><i nz-icon [nzIconfont]="'icon-xiangqing'" nz-tooltip="门店详情"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)="getDelete(data.id)"><i nz-icon nzType="delete" nzTheme="outline" nz-tooltip="删除"></i></a> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</nz-spin> |
||||
</div> |
||||
|
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="errorStudentVisible" nzTitle="导入失败数据" (nzOnCancel)="handleCancelError()" nzWidth="900px" [nzFooter]="null"> |
||||
<nz-table #errorStudentTable [nzData]="importErrorStudentArray"> |
||||
<thead> |
||||
<tr> |
||||
<th nzWidth="80px">序号</th> |
||||
<th nzWidth="150px">门店编号</th> |
||||
<th nzWidth="150px">门店名称</th> |
||||
<th nzWidth="150px">区域ID</th> |
||||
<th nzWidth="300px">原因</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of errorStudentTable.data;let i = index"> |
||||
<td>{{ i + 1}}</td> |
||||
<td>{{data.storeKey}}</td> |
||||
<td>{{data.storeName}}</td> |
||||
<td>{{data.regionId}}</td> |
||||
<td>{{data.errorMessage}}</td> |
||||
</tr> |
||||
</tbody> |
||||
</nz-table> |
||||
</nz-modal> |
@ -0,0 +1,4 @@ |
||||
.head_img { |
||||
height: 60px; |
||||
width: 60px; |
||||
} |
@ -0,0 +1,175 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService, NzModalService, NzUploadChangeParam} from 'ng-zorro-antd'; |
||||
import {ActivatedRoute, Router} from '@angular/router'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {MerchantStoreService} from '../../../services/merchant-store.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-store-list', |
||||
templateUrl: './store-list.component.html', |
||||
styleUrls: ['./store-list.component.scss'] |
||||
}) |
||||
export class StoreListComponent implements OnInit { |
||||
|
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
id = null; |
||||
name: string; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
importErrorStudentArray = []; |
||||
errorStudentVisible = false; |
||||
isSpinning = false; |
||||
|
||||
constructor( |
||||
private form: FormBuilder, |
||||
private merchantStore: MerchantStoreService, |
||||
private iconService: IconService, |
||||
private message: NzMessageService, |
||||
private router: Router, |
||||
private modal: NzModalService, |
||||
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({ |
||||
storeName: [null], |
||||
telephone: [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; |
||||
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']); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
// 重置
|
||||
public resetForm(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
|
||||
// 禁用门店
|
||||
public getDelete(id): void { |
||||
const message = '是否删除门店'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.merchantStore.deleteMerchantStore(id, dataReturn => { |
||||
if (dataReturn['return_code'] === '000000') { |
||||
this.message.success('操作成功'); |
||||
this.getRequest(false , this.searchForm.value); |
||||
} else { |
||||
this.message.warning(dataReturn['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 修改
|
||||
public getEdit(id: number): void { |
||||
this.router.navigate(['/admin/merchantStore/store-edit'], { |
||||
queryParams: { |
||||
storeId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 查看详情
|
||||
public getDetail(id: number): void { |
||||
this.router.navigate(['/admin/merchantStore/store-detail'], { |
||||
queryParams: { |
||||
storeId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
handleCancelError(): void { |
||||
this.errorStudentVisible = false; |
||||
} |
||||
|
||||
handleChange(info: NzUploadChangeParam): void { |
||||
this.isSpinning = true; |
||||
if (info.file.status !== 'uploading') { |
||||
console.log(info.file, info.fileList); |
||||
} |
||||
if (info.file.status === 'done') { |
||||
if (info.file.response.return_code === '000000') { |
||||
this.loading = false; |
||||
this.isSpinning = false; |
||||
if (info.file.response.return_data.errorTotal === 0) { |
||||
this.message.success('导入成功'); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} else { |
||||
this.modal.warning({ |
||||
nzTitle: '提示', |
||||
nzOkText: '查看失败数据', |
||||
nzContent: '只有部分数据导入成功', |
||||
nzOnOk: () => this.showErrorStudentModal(info.file.response.return_data) |
||||
}); |
||||
} |
||||
} else { |
||||
this.isSpinning = false; |
||||
this.loading = false; |
||||
this.message.error(info.file.response.return_msg); |
||||
} |
||||
} else if (info.file.status === 'error') { |
||||
this.message.error('上传错误'); |
||||
} |
||||
} |
||||
|
||||
// 打开模态框
|
||||
showErrorStudentModal(data: []) { |
||||
this.getRequest(true, this.searchForm.value); |
||||
this.importErrorStudentArray = data['errorData']; |
||||
this.errorStudentVisible = true; |
||||
} |
||||
} |
@ -0,0 +1,32 @@ |
||||
<div class="inner-content"> |
||||
<nz-descriptions nzBordered> |
||||
<nz-descriptions-item nzTitle="商户logo" [nzSpan]="3"> |
||||
<img class="head_img" src="{{data.merchantLogo}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt=""> |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="登录账户">{{data['secUser']['loginName']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="商户编号">{{data['merchantKey']}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="商户名称">{{data.merchantName}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="联系电话">{{data.secUser.telephone}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="商户地址">{{data.address}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="状态">{{data.status ===1 ? '正常' : '禁用'}}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="银行名称"> |
||||
{{data.bankName == null ? '未上传' : data.bankName}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="银行账号"> |
||||
{{data.bankAccount == null ? '未上传' : data.bankAccount}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="开户人"> |
||||
{{data.bankHolder == null ? '未上传' : data.bankHolder}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="创建时间"> |
||||
{{data.createTime | date: 'yyyy-MM-dd'}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="更新时间"> |
||||
{{data.updateTime | date: 'yyyy-MM-dd'}} |
||||
</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="操作人员">{{data.operatorName }}</nz-descriptions-item> |
||||
<nz-descriptions-item nzTitle="简介" [nzSpan]="3"> |
||||
{{data.merchantDesc}} |
||||
</nz-descriptions-item> |
||||
</nz-descriptions> |
||||
</div> |
@ -0,0 +1,4 @@ |
||||
.head_img { |
||||
height: 60px; |
||||
width: 60px; |
||||
} |
@ -0,0 +1,37 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {MerchantService} from '../../../services/merchant.service'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {ActivatedRoute} from '@angular/router'; |
||||
|
||||
@Component({ |
||||
selector: 'app-merchant-detail', |
||||
templateUrl: './merchant-detail.component.html', |
||||
styleUrls: ['./merchant-detail.component.scss'] |
||||
}) |
||||
export class MerchantDetailComponent implements OnInit { |
||||
|
||||
data: any = {}; |
||||
id: number; |
||||
constructor( |
||||
private merchant: MerchantService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { } |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.merchantId != null) { |
||||
this.id = queryParams.merchantId; |
||||
this.getDetails(queryParams.merchantId); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
// 查询详情
|
||||
public getDetails(id: number) { |
||||
this.merchant.getMerchantById(id , data => { |
||||
this.data = data['return_data']; |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,132 @@ |
||||
<!-- start 面包屑 --> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
<a (click)="getBack()">商户管理</a> |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
编辑商户 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
|
||||
<nz-content class="inner-content"> |
||||
<form nz-form [formGroup]="validateForm" class="ant-advanced-search-form"> |
||||
<div nz-row [nzGutter]="24"> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'loginTelephone'" nzRequired>登录手机号</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入登录手机号!"> |
||||
<input nz-input placeholder="请输入登录手机号..." [formControlName]="'loginTelephone'" id="'loginTelephone'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'password'" nzRequired>登录密码</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入登录密码!"> |
||||
<nz-input-group [nzSuffix]="suffixTemplate"> |
||||
<input [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="请输入登录密码..." [formControlName]="'password'" id="'password'" /> |
||||
</nz-input-group> |
||||
<ng-template #suffixTemplate> |
||||
<i nz-icon [nzType]="passwordVisible ? 'eye-invisible' : 'eye'" (click)="passwordVisible = !passwordVisible"></i> |
||||
</ng-template> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'merchantKey'" nzRequired>商户编号</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入商户编号!"> |
||||
<input nz-input placeholder="请输入商户编号..." [formControlName]="'merchantKey'" id="'merchantKey'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'merchantName'" nzRequired>商户名称</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入商户名称!"> |
||||
<input nz-input placeholder="请输入商户名称..." [formControlName]="'merchantName'" id="'merchantName'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'telephone'" nzRequired>联系电话</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入联系电话!"> |
||||
<input nz-input placeholder="请输入联系电话..." [formControlName]="'telephone'" id="'telephone'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'address'" nzRequired>商户地址</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入商户地址!"> |
||||
<input nz-input placeholder="请输入商户地址..." [formControlName]="'address'" id="'address'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'bankName'" >银行名称</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入银行名称!"> |
||||
<input nz-input placeholder="请输入银行名称..." [formControlName]="'bankName'" id="'bankName'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'bankAccount'" >银行账号</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入银行账号!"> |
||||
<input nz-input placeholder="请输入银行账号..." [formControlName]="'bankAccount'" id="'bankAccount'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="8"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzFor]="'bankHolder'" >开户人</nz-form-label> |
||||
<nz-form-control nzErrorTip="请输入开户人!"> |
||||
<input nz-input placeholder="请输入开户人..." [formControlName]="'bankHolder'" id="'bankHolder'" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="16"> |
||||
<nz-form-item> |
||||
<nz-form-label>商户LOGO</nz-form-label> |
||||
<nz-form-control> |
||||
<nz-upload |
||||
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="logoFile" |
||||
[nzShowButton]="logoFile.length < 1" |
||||
[nzPreview]="handlePreview" |
||||
> |
||||
<i nz-icon nzType="plus"></i> |
||||
<div class="ant-upload-text">上传LOGO</div> |
||||
</nz-upload> |
||||
<nz-modal [nzVisible]="previewVisible" [nzContent]="modalContent" [nzFooter]="null" (nzOnCancel)="previewVisible = false"> |
||||
<ng-template #modalContent> |
||||
<img [src]="previewImage" [ngStyle]="{ width: '100%' }" /> |
||||
</ng-template> |
||||
</nz-modal> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col [nzSpan]="16"> |
||||
<nz-form-item> |
||||
<nz-form-label>商户简介</nz-form-label> |
||||
<nz-form-control> |
||||
<textarea formControlName="merchantDesc" nz-input rows="2" placeholder="请输入商户简介"></textarea> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
</div> |
||||
<div nz-row> |
||||
<div nz-col [nzSpan]="24" class="search-area"> |
||||
<button nz-button (click)="resetForm()">重置</button> |
||||
<button nz-button [nzType]="'primary'" (click)="getSave()">提交</button> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
|
||||
</nz-content> |
@ -0,0 +1,6 @@ |
||||
button { |
||||
margin-left: 8px; |
||||
} |
||||
:host ::ng-deep .ant-upload { |
||||
background-color: #ffffff; |
||||
} |
@ -0,0 +1,157 @@ |
||||
import {Component, OnInit} from '@angular/core'; |
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; |
||||
import {MerchantService} from '../../../services/merchant.service'; |
||||
import {NzMessageService, NzUploadFile} from 'ng-zorro-antd'; |
||||
import {ActivatedRoute} from '@angular/router'; |
||||
import {ValidatorsService} from '../../../services/validators.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
function getBase64(file: File): Promise<string | ArrayBuffer | null> { |
||||
return new Promise((resolve, reject) => { |
||||
const reader = new FileReader(); |
||||
reader.readAsDataURL(file); |
||||
reader.onload = () => resolve(reader.result); |
||||
reader.onerror = error => reject(error); |
||||
}); |
||||
} |
||||
|
||||
@Component({ |
||||
selector: 'app-merchant-edit', |
||||
templateUrl: './merchant-edit.component.html', |
||||
styleUrls: ['./merchant-edit.component.scss'] |
||||
}) |
||||
export class MerchantEditComponent implements OnInit { |
||||
|
||||
validateForm!: FormGroup; |
||||
data: any; |
||||
editFlag = false; |
||||
id: number; |
||||
passwordVisible = false; |
||||
logoFile = []; |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
previewImage: string | undefined = ''; |
||||
previewVisible = false; |
||||
|
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private merchant: MerchantService, |
||||
private message: NzMessageService, // 信息提示
|
||||
private activatedRoute: ActivatedRoute, |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.activatedRoute.queryParams.subscribe(queryParams => { |
||||
if (queryParams.merchantId != null) { |
||||
this.editFlag = true; |
||||
this.id = queryParams.merchantId; |
||||
this.getDetails(queryParams.merchantId); |
||||
} |
||||
}); |
||||
this.validateForm = this.fb.group({ |
||||
loginTelephone: [null, [Validators.required, ValidatorsService.mobile]], |
||||
password: [null, [Validators.required, ValidatorsService.minLength(6)]], |
||||
merchantKey: [null, [Validators.required, ValidatorsService.maxLength(10)]], |
||||
merchantName: [null, [Validators.required, ValidatorsService.pwdLength(2, 12)]], |
||||
telephone: [null, [Validators.required]], |
||||
address: [null, [Validators.required]], |
||||
bankName: [null], |
||||
bankAccount: [null], |
||||
bankHolder: [null], |
||||
status: [null], |
||||
createTime: [null], |
||||
merchantDesc: [null], |
||||
secUser: {}, |
||||
}); |
||||
} |
||||
|
||||
// 返回
|
||||
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; |
||||
} |
||||
} |
||||
|
||||
this.validateForm.value['secUser']['telephone'] = this.validateForm.value.loginTelephone; |
||||
this.validateForm.value['secUser']['password'] = this.validateForm.value.password; |
||||
if (this.logoFile.length !== 0) { |
||||
if (this.logoFile[0]['response'] != null) { |
||||
this.validateForm.value.merchantLogo = this.logoFile[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateForm.value.merchantLogo = this.logoFile[0].name; |
||||
} |
||||
} |
||||
|
||||
if (this.editFlag) { |
||||
this.validateForm.value.id = this.id; |
||||
this.merchant.updateMerchant(this.validateForm.value, data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('修改成功'); |
||||
} else { |
||||
this.message.create('error', '修改失败'); |
||||
} |
||||
}); |
||||
} else { |
||||
|
||||
this.merchant.insertMerchant(this.validateForm.value, data => { |
||||
console.log(data); |
||||
if (data['return_code'] === '000000') { |
||||
this.getBack(); |
||||
this.message.success('添加成功'); |
||||
} else { |
||||
this.message.create('error', '保存失败'); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
// 图片查看
|
||||
handlePreview = async (file: NzUploadFile) => { |
||||
if (!file.url && !file.preview) { |
||||
// tslint:disable-next-line:no-non-null-assertion
|
||||
file.preview = await getBase64(file.originFileObj!); |
||||
} |
||||
this.previewImage = file.url || file.preview; |
||||
this.previewVisible = true; |
||||
} |
||||
|
||||
public getDetails(id) { |
||||
this.merchant.getMerchantById(id, data => { |
||||
if (data['return_code'] === '000000') { |
||||
data['return_data'].loginTelephone = 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']); |
||||
} else { |
||||
this.message.create('error', data['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,112 @@ |
||||
<!-- start 面包屑 --> |
||||
<app-breadcrumb></app-breadcrumb> |
||||
<!-- end 面包屑 --> |
||||
|
||||
<!--条件搜索--> |
||||
<div class="inner-content"> |
||||
<form nz-form [formGroup]="searchForm" (ngSubmit)="getRequest(true , searchForm.value)"> |
||||
<div nz-row> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">商户编号</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="merchantKey"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">商户名称</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="merchantName"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">商户电话</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input nz-input formControlName="telephone"/> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
</div> |
||||
<div nz-col nzSpan="6"> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">商户状态</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-select nzShowSearch nzAllowClear formControlName="status" nzPlaceHolder="请选择状态"> |
||||
<nz-option nzLabel="禁用" nzValue="0"></nz-option> |
||||
<nz-option nzLabel="正常" nzValue="1"></nz-option> |
||||
</nz-select> |
||||
</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>共计 {{total}} 条数据</span> |
||||
<div class="operating-button"> |
||||
<button nz-button nzType="primary" class="right-btn" [routerLink]="['/admin/merchant/merchant-edit']" ><i nz-icon nzType="plus" nzTheme="outline"></i>添加</button> |
||||
</div> |
||||
<nz-table |
||||
class="table" |
||||
#ajaxTable |
||||
nzShowSizeChanger |
||||
[nzFrontPagination]="false" |
||||
[nzData]="requestData" |
||||
[nzLoading]="loading" |
||||
[nzTotal]="total" |
||||
[(nzPageIndex)]="pageNum" |
||||
[(nzPageSize)]="pageSize" |
||||
[nzScroll]="{ x: '1200px' }" |
||||
(nzPageIndexChange)="getRequest(false , searchForm.value)" |
||||
(nzPageSizeChange)="getRequest(false , searchForm.value)"> |
||||
<thead nzSingleSort> |
||||
<tr> |
||||
<th nzWidth="50px">编号</th> |
||||
<th nzWidth="80px">商户编号</th> |
||||
<th nzWidth="80px">商户名称</th> |
||||
<th nzWidth="70px">商户LOGO</th> |
||||
<th nzWidth="100px">商户电话</th> |
||||
<th nzWidth="100px">创建时间</th> |
||||
<th nzWidth="50px">状态</th> |
||||
<th nzWidth="80px" nzRight="0px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.merchantKey}}</td> |
||||
<td>{{data.merchantName}}</td> |
||||
<td> |
||||
<img class="head_img" src="{{WEB_SERVE_URL + data.merchantLogo}}" onerror="this.src='../../../../assets/admin/navigation/icon.png'" alt=""> |
||||
</td> |
||||
<td>{{data.telephone}}</td> |
||||
<td>{{data.createTime | date: 'yyyy-MM-dd HH:mm'}}</td> |
||||
<td>{{data.status ===1 ? '正常' : '禁用'}}</td> |
||||
<td nzRight="0px" class="table-td-operation"> |
||||
<a (click)="getEdit(data.id)"><i nz-icon nzType="form" nzTheme="outline" nz-tooltip="编辑"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)="getDetail(data.id)"><i nz-icon [nzIconfont]="'icon-xiangqing'" nz-tooltip="商户详情"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a (click)="getList(data.id , data.merchantName)"><i nz-icon nzType="unordered-list" nzTheme="outline" nz-tooltip="门店列表"></i></a> |
||||
<nz-divider nzType="vertical"></nz-divider> |
||||
<a *ngIf="data.status === 1" (click)='disableMerchant(data.id)'><i nz-icon nzType="stop" nzTheme="outline" nz-tooltip="禁用"></i></a> |
||||
<a *ngIf="data.status !== 1" (click)='enableMerchant(data.id)'><i nz-icon nzType="check-circle" nzTheme="outline" nz-tooltip="启用"></i></a> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
|
@ -0,0 +1,4 @@ |
||||
.head_img { |
||||
height: 60px; |
||||
width: 60px; |
||||
} |
@ -0,0 +1,136 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {UserService} from '../../../services/user.service'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {MerchantService} from '../../../services/merchant.service'; |
||||
import {Router} from '@angular/router'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-merchant-list', |
||||
templateUrl: './merchant-list.component.html', |
||||
styleUrls: ['./merchant-list.component.scss'] |
||||
}) |
||||
export class MerchantListComponent implements OnInit { |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
|
||||
constructor( |
||||
private form: FormBuilder, |
||||
private merchant: MerchantService, |
||||
private iconService: IconService, |
||||
private message: NzMessageService, |
||||
private router: Router, |
||||
private common: CommonsService |
||||
) { |
||||
} |
||||
|
||||
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.merchant.getMerchantList(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 disableMerchant(id): void { |
||||
const message = '是否禁用商户'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.merchant.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 = '是否启用商户'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.merchant.enableMerchant(id, dataReturn => { |
||||
if (dataReturn['return_code'] === '000000') { |
||||
this.message.success('操作成功'); |
||||
this.getRequest(false , this.searchForm.value); |
||||
} else { |
||||
this.message.warning(dataReturn['return_msg']); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
// 修改
|
||||
public getEdit(id: number): void { |
||||
this.router.navigate(['/admin/merchant/merchant-edit'], { |
||||
queryParams: { |
||||
merchantId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 查看详情
|
||||
public getDetail(id: number): void { |
||||
this.router.navigate(['/admin/merchant/merchant-detail'], { |
||||
queryParams: { |
||||
merchantId: id |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
|
||||
// 查看门店列表
|
||||
public getList(id: number , merchantName: string): void { |
||||
this.router.navigate(['/admin/merchantStore/store-list'], { |
||||
queryParams: { |
||||
merchantId: id, |
||||
name: merchantName, |
||||
} |
||||
}).then(r => console.log(r)); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,18 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {MerchantListComponent} from './merchant-list/merchant-list.component'; |
||||
import {MerchantEditComponent} from './merchant-edit/merchant-edit.component'; |
||||
import {MerchantDetailComponent} from './merchant-detail/merchant-detail.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'merchant-list', component: MerchantListComponent }, |
||||
{ path: 'merchant-edit', component: MerchantEditComponent }, |
||||
{ path: 'merchant-detail', component: MerchantDetailComponent }, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class MerchantRoutingModule { } |
@ -0,0 +1,26 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { MerchantRoutingModule } from './merchant-routing.module'; |
||||
import { MerchantListComponent } from './merchant-list/merchant-list.component'; |
||||
import {NgZorroAntdModule} from 'ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import { MerchantEditComponent } from './merchant-edit/merchant-edit.component'; |
||||
import { MerchantDetailComponent } from './merchant-detail/merchant-detail.component'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [MerchantListComponent, MerchantEditComponent, MerchantDetailComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
MerchantRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule |
||||
] |
||||
}) |
||||
export class MerchantModule { } |
@ -0,0 +1 @@ |
||||
<p>price-edit works!</p> |
@ -0,0 +1,15 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
|
||||
@Component({ |
||||
selector: 'app-price-edit', |
||||
templateUrl: './price-edit.component.html', |
||||
styleUrls: ['./price-edit.component.scss'] |
||||
}) |
||||
export class PriceEditComponent implements OnInit { |
||||
|
||||
constructor() { } |
||||
|
||||
ngOnInit(): void { |
||||
} |
||||
|
||||
} |
@ -0,0 +1 @@ |
||||
<p>price-list works!</p> |
@ -0,0 +1,15 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
|
||||
@Component({ |
||||
selector: 'app-price-list', |
||||
templateUrl: './price-list.component.html', |
||||
styleUrls: ['./price-list.component.scss'] |
||||
}) |
||||
export class PriceListComponent implements OnInit { |
||||
|
||||
constructor() { } |
||||
|
||||
ngOnInit(): void { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { Routes, RouterModule } from '@angular/router'; |
||||
import {PriceListComponent} from './price-list/price-list.component'; |
||||
import {PriceEditComponent} from './price-edit/price-edit.component'; |
||||
|
||||
|
||||
const routes: Routes = [ |
||||
{ path: 'price-list', component: PriceListComponent }, |
||||
{ path: 'price-edit', component: PriceEditComponent}, |
||||
]; |
||||
|
||||
@NgModule({ |
||||
imports: [RouterModule.forChild(routes)], |
||||
exports: [RouterModule] |
||||
}) |
||||
export class PriceRoutingModule { } |
@ -0,0 +1,27 @@ |
||||
import { NgModule } from '@angular/core'; |
||||
import { CommonModule } from '@angular/common'; |
||||
|
||||
import { PriceRoutingModule } from './price-routing.module'; |
||||
import { PriceListComponent } from './price-list/price-list.component'; |
||||
import { PriceEditComponent } from './price-edit/price-edit.component'; |
||||
import {NgZorroAntdModule} from 'ng-zorro-antd'; |
||||
import {SeparateModule} from '../../common/separate/separate.module'; |
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; |
||||
import {BreadcrumbModule} from '../../common/breadcrumb/breadcrumb.module'; |
||||
import {RegionSelectorModule} from '../../common/region-selector/region-selector.module'; |
||||
|
||||
|
||||
@NgModule({ |
||||
declarations: [PriceListComponent, PriceEditComponent], |
||||
imports: [ |
||||
CommonModule, |
||||
PriceRoutingModule, |
||||
NgZorroAntdModule, |
||||
SeparateModule, |
||||
ReactiveFormsModule, |
||||
FormsModule, |
||||
BreadcrumbModule, |
||||
RegionSelectorModule |
||||
] |
||||
}) |
||||
export class PriceModule { } |
@ -1,70 +1,88 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {Component, OnInit} from '@angular/core'; |
||||
import {FormBuilder, FormGroup} from '@angular/forms'; |
||||
import {UserService} from '../../../services/user.service'; |
||||
import {NzMessageService} from 'ng-zorro-antd'; |
||||
import {IconService} from '../../../services/icon.service'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
|
||||
@Component({ |
||||
selector: 'app-user-list', |
||||
templateUrl: './user-list.component.html', |
||||
styleUrls: ['./user-list.component.scss'] |
||||
selector: 'app-user-list', |
||||
templateUrl: './user-list.component.html', |
||||
styleUrls: ['./user-list.component.scss'] |
||||
}) |
||||
export class UserListComponent implements OnInit { |
||||
WEB_SERVE_URL = environment.baseUrl; |
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
regTime; |
||||
|
||||
searchForm: FormGroup; // 搜索框
|
||||
requestData = []; // 列表数据
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
regTime; |
||||
constructor( |
||||
private form: FormBuilder, |
||||
private user: UserService, |
||||
private message: NzMessageService |
||||
) { } |
||||
constructor( |
||||
private form: FormBuilder, |
||||
private user: UserService, |
||||
private iconService: IconService, |
||||
private message: NzMessageService, |
||||
private common: CommonsService |
||||
) { |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.init(); |
||||
} |
||||
|
||||
ngOnInit(): void { |
||||
this.init(); |
||||
} |
||||
public init(): void { |
||||
this.searchForm = this.form.group({ |
||||
name: [null], |
||||
status: [null], |
||||
phone: [null], |
||||
regTime: [null], |
||||
}); |
||||
this.getRequest(true, this.searchForm.value); |
||||
} |
||||
|
||||
public init(): void { |
||||
this.searchForm = this.form.group({ |
||||
name: [null], |
||||
phone: [null], |
||||
regTime: [null], |
||||
}); |
||||
this.getRequest(true , this.searchForm.value); |
||||
} |
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false, whereObject: object) { |
||||
|
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false , whereObject: object) { |
||||
if (whereObject['regTime'] != null && whereObject['regTime'].length !== 0) { |
||||
whereObject['regTimeStart'] = whereObject['regTime'][0].getTime(); |
||||
whereObject['regTimeEnd'] = whereObject['regTime'][1].getTime(); |
||||
} |
||||
|
||||
if (whereObject['regTime'] != null && whereObject['regTime'].length !== 0) { |
||||
whereObject['regTimeStart'] = whereObject['regTime'][0]; |
||||
whereObject['regTimeEnd'] = whereObject['regTime'][1]; |
||||
whereObject['regTime'] = null; |
||||
this.loading = false; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
this.user.getListUser(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']); |
||||
} |
||||
}); |
||||
} |
||||
this.loading = false; |
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
|
||||
// 重置
|
||||
public resetForm(): void { |
||||
this.searchForm.reset(); |
||||
} |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
console.log(whereObject); |
||||
this.user.getListUser( whereObject, data => { |
||||
console.log(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 getForbiddenUser(id, status: any): void { |
||||
const message = (status === 1 ? '是否禁用当前用户' : '是否启用当前用户'); |
||||
|
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.user.forbiddenUser(id, dataUser => { |
||||
this.getRequest(false , this.searchForm.value); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,19 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'auditStatus' |
||||
}) |
||||
export class AuditStatusPipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '待审批'; |
||||
case 2: |
||||
return '驳回'; |
||||
case 3: |
||||
return '通过'; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,14 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'auditType' |
||||
}) |
||||
export class AuditTypePipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '卡券上架审批'; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'couponCode' |
||||
}) |
||||
export class CouponCodePipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 1: |
||||
return '待销售'; |
||||
case 2: |
||||
return '待使用'; |
||||
case 3: |
||||
return '已使用'; |
||||
case 4: |
||||
return '已过期'; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'couponStatus' |
||||
}) |
||||
export class CouponStatusPipe implements PipeTransform { |
||||
|
||||
transform(value: number): string { |
||||
switch (value) { |
||||
case 0: |
||||
return '删除'; |
||||
case 1: |
||||
return '编辑中'; |
||||
case 2: |
||||
return '已上架'; |
||||
case 3: |
||||
return '已下架'; |
||||
case 101: |
||||
return '上架审批中'; |
||||
case 102: |
||||
return '上架审批驳回'; |
||||
} |
||||
} |
||||
} |
@ -1,3 +1,7 @@ |
||||
export * from './commons/times.pipe'; |
||||
export * from './commons/textarea.pipe'; |
||||
export * from './system.pipe'; |
||||
export * from './coupon-status.pipe'; |
||||
export * from './coupon-code.pipe'; |
||||
export * from './audit-status.pipe'; |
||||
export * from './audit-type.pipe'; |
||||
|
@ -1,64 +0,0 @@ |
||||
import {Injectable} from '@angular/core'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class AdminIndexService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
) { |
||||
} |
||||
|
||||
/** |
||||
* 按职位类型统计前十职位数量 |
||||
* @param callBack |
||||
*/ |
||||
public getPositionTopTen(callBack) { |
||||
this.http.get(environment.baseUrl + '/statistics/getPositionTopTen').subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 按年龄段统计简历 |
||||
* @param callBack |
||||
*/ |
||||
public findResumeByAge(callBack) { |
||||
this.http.get(environment.baseUrl + '/statistics/findResumeByAge').subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 按学历统计简历 |
||||
* @param callBack |
||||
*/ |
||||
public findResumeByEdu(callBack) { |
||||
this.http.get(environment.baseUrl + '/statistics/findResumeByEdu').subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 按行业统计前十企业数量 |
||||
* @param callBack |
||||
*/ |
||||
public getEnterpriseTopTen(callBack) { |
||||
this.http.get(environment.baseUrl + '/statistics/getEnterpriseTopTen').subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 按照月份统计简历投递数量(当前年份) |
||||
* @param callBack |
||||
*/ |
||||
public findDeliveryByMonth(callBack) { |
||||
this.http.get(environment.baseUrl + '/statistics/findDeliveryByMonth').subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,54 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class AuditService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 查询审核列表列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getApproveList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'audit/getApproveList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询审核详情 |
||||
* |
||||
* @param approveId 审核id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getApproveDetail(approveId: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'audit/getApproveDetail?approveId=' + approveId).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 修改卡券 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public approveProcessed(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'audit/approveProcessed', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class CompanyService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 查询公司列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public selectCompanyList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'bsCompany/selectCompanyList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增卡券 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public addCompanyAndUser(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'bsCompany/addCompanyAndUser', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 修改卡券 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public updateCompany(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'bsCompany/updateCompany', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询详情 |
||||
* |
||||
* @param companyId 公司id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public companyView(companyId: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'bsCompany/companyView?companyId=' + companyId).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 修改公司状态 |
||||
* |
||||
* @param id 用户id |
||||
* @param status status |
||||
* @param callBack 返回参数 |
||||
*/ |
||||
public editStatus(id: number, status: number , callBack) { |
||||
this.http.get(environment.baseUrl + 'bsCompany/editStatus?companyId=' + id + '&status=' + status).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,116 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class CouponService { |
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 查询卡券列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getCouponList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'coupon/getCouponList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 查询卡券消费码列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getCouponCodeList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'couponCode/getCouponCodeList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增卡券 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public insertCoupon(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'coupon/insertCoupon', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 修改卡券 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public updateCoupon(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'coupon/updateCoupon', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询详情 |
||||
* |
||||
* @param couponId 卡券id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getCouponById(couponId: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'coupon/getCouponById?id=' + couponId).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 下架卡券 |
||||
* |
||||
* @param id 用户id |
||||
* @param callBack 返回参数 |
||||
*/ |
||||
public ofShelfApprove(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'coupon/ofShelfApprove?id=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 上架卡券 |
||||
* |
||||
* @param id 用户id |
||||
* @param callBack 返回参数 |
||||
*/ |
||||
public upShelfApprove(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'coupon/upShelfApprove?id=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 生成消费码 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public writeStock(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'coupon/writeStock', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,92 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {environment} from '../../environments/environment'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class MerchantStoreService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 查询门店列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getStoreListByMerchant(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchantStore/getStoreListByMerchant?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 超级管理员查询门店列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getStoreListByCompany(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchantStore/getStoreListByCompany?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增商户 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public insertMerchantStore(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'highMerchantStore/insertMerchantStore', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 修改商户 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public updateMerchantStore(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'highMerchantStore/updateMerchantStore', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询详情 |
||||
* |
||||
* @param merchantId 职位id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getMerchantStoreById(merchantId: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchantStore/getMerchantStoreById?id=' + merchantId).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 禁用商户 |
||||
* |
||||
* @param id 用户id |
||||
* @param callBack 返回参数 |
||||
*/ |
||||
public deleteMerchantStore(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchantStore/deleteMerchantStore?id=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,92 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class MerchantService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 查询商户列表 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getMerchantList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchant/getMerchantList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增商户 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public insertMerchant(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'highMerchant/insertMerchant', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 修改商户 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public updateMerchant(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'highMerchant/updateMerchant', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询详情 |
||||
* |
||||
* @param merchantId 职位id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getMerchantById(merchantId: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchant/getMerchantById?id=' + merchantId).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 禁用商户 |
||||
* |
||||
* @param id 用户id |
||||
* @param callBack 返回参数 |
||||
*/ |
||||
public disableMerchant(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'highMerchant/disableMerchant?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); |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,168 @@ |
||||
|
||||
<p align="center"> |
||||
<a href="https://jq.qq.com/?_wv=1027&k=5qVzRh4" title="Notadd 官方技术交流群"><img src="https://img.shields.io/badge/QQ%20Group-321735506-6782d6.svg?style=flat-square"></a> |
||||
<a href="https://travis-ci.org/notadd/neditor" title="Build Status"><img src="https://img.shields.io/travis/notadd/neditor/master.svg?style=flat-square"></a> |
||||
</p> |
||||
|
||||
## 新版发布 |
||||
|
||||
2.1 发布,此次版本移除了后端相关代码,纯 ajax 提交,请配置 `neditor.config.js` `neditor.service.js`,支持各种后端或者云存储。 |
||||
|
||||
## 捐赠 |
||||
|
||||
该项目需要您的支持, [捐赠](https://gitee.com/notadd/neditor?donate=true) 以支持此项目的发展。 |
||||
|
||||
|
||||
## 第一步:下载编辑器 |
||||
|
||||
**方式一:完整安装包 (推荐)** |
||||
|
||||
* [Neditor.tar.xz](https://www.notadd.com/download/neditor/Neditor-next-master.tar.xz) |
||||
|
||||
**方式二: npm安装** |
||||
|
||||
`npm i @notadd/neditor -S` |
||||
|
||||
**方式三:编译安装** |
||||
|
||||
```shell |
||||
git clone https://github.com/notadd/neditor.git |
||||
npm install |
||||
npm run build |
||||
``` |
||||
|
||||
### 第二步:在浏览器打开 index.html ### |
||||
|
||||
进入到目录 `dist` , 使用浏览器打开文件 `index.html` 。 |
||||
|
||||
如果看到了下面这样的编辑器,恭喜你,初次部署成功! |
||||
|
||||
 |
||||
|
||||
## 相关版本 |
||||
|
||||
[Angular 版 Neditor](https://github.com/notadd/ngx-neditor) |
||||
|
||||
[Vue 版 Neditor](https://github.com/caiya/vue-neditor-wrap) 【第三方维护】 |
||||
|
||||
## 技术支持 |
||||
|
||||
该项目基于 MIT 协议开源,任何组织/企业以及个人都可以免费使用(保留版权)。 |
||||
如果您需要额外商业技术支持或者定制编辑器,请联系 QQ:1256985886 |
||||
|
||||
|
||||
|
||||
其他版本待添加 |
||||
|
||||
### 自定义的参数 |
||||
|
||||
编辑器有很多可自定义的参数项,在实例化的时候可以传入给编辑器: |
||||
|
||||
```javascript |
||||
var ue = UE.getEditor('container', { |
||||
autoHeight: false |
||||
}); |
||||
``` |
||||
|
||||
配置项也可以通过 `neditor.config.js` 文件修改,具体的配置方法请看 [前端配置项说明](http://fex.baidu.com/ueditor/#start-config1.4 前端配置项说明.md)、[后端配置项说明](http://fex.baidu.com/ueditor/#server-config) |
||||
|
||||
### 编辑器图片、视频、涂鸦、附件上传service |
||||
|
||||
编辑器上传逻辑单独在 `neditor.service.js` 文件配置,具体的配置方法见注释 |
||||
|
||||
### 设置和读取编辑器的内容 |
||||
|
||||
通 getContent 和 setContent 方法可以设置和读取编辑器的内容 |
||||
|
||||
```javascript |
||||
var ue = UE.getContent(); |
||||
ue.ready(function(){ |
||||
//设置编辑器的内容 |
||||
ue.setContent('hello'); |
||||
//获取html内容,返回: <p>hello</p> |
||||
var html = ue.getContent(); |
||||
//获取纯文本内容,返回: hello |
||||
var txt = ue.getContentTxt(); |
||||
}); |
||||
``` |
||||
|
||||
Ueditor 的更多API请看[API 文档](http://ueditor.baidu.com/doc "ueditor API 文档") |
||||
|
||||
## 下载地址 |
||||
|
||||
Neditor 码云: [http://gitee.com/notadd/neditor](http://gitee.com/notadd/neditor "Neditor github 地址") |
||||
|
||||
Neditor github 地址:[http://github.com/notadd/neditor](http://github.com/notadd/neditor "Neditor github 地址") |
||||
|
||||
## 相关链接 |
||||
|
||||
Ueditor 官网:[http://ueditor.baidu.com](http://ueditor.baidu.com "ueditor 官网") |
||||
|
||||
Ueditor API 文档:[http://ueditor.baidu.com/doc](http://ueditor.baidu.com/doc "ueditor API 文档") |
||||
|
||||
## 详细文档 |
||||
|
||||
Ueditor 文档:[http://fex.baidu.com/ueditor/](http://fex.baidu.com/ueditor/) |
||||
|
||||
注: 对IE8以下版本不再承诺兼容 |
||||
|
||||
|
||||
### 关于 HTTPS |
||||
|
||||
使用了 [又拍云CDN](https://console.upyun.com/register/?invite=r17EYO3BW) 服务,支持跨域 和 https。 |
||||
|
||||
如果有需要,也可将下面域名改成自己的。 |
||||
``` |
||||
imgbaidu.b0.upaiyun.com |
||||
tingapi.b0.upaiyun.com |
||||
``` |
||||
|
||||
## 联系我们 ## |
||||
|
||||
Neditor官方交流群:257753500 |
||||
|
||||
QQ 群: 321735506 |
||||
|
||||
[issue](http://github.com/notadd/neditor/issues) |
||||
|
||||
|
||||
|
||||
## Todo |
||||
|
||||
### 2.1 |
||||
|
||||
- [x] 将上传封装为 service ,支持非 GraphQL 接口。 |
||||
- [x] 细节样式修改(美化) |
||||
|
||||
### 2.2 |
||||
|
||||
- [ ] word 内图片自动上传 |
||||
- [x] 粘贴图片转为本地图片(图片本地化) |
||||
|
||||
### 2.3 |
||||
|
||||
- [ ] 上传文件/图片无需后端 |
||||
|
||||
### 3.0 |
||||
|
||||
- [ ] 使用 Typescript 重构 |
||||
- [ ] 草稿箱功能与离线保存 |
||||
- [ ] service worker 特性 |
||||
- [ ] 实现 2.0 的大部分功能 |
||||
|
||||
## 其他项目:Notadd |
||||
|
||||
https://github.com/notadd/notadd |
||||
|
||||
|
||||
## 感谢提供赞助: |
||||
|
||||
|
||||
<a href="https://www.ucloud.cn/site/active/gift.html?ytag=notadd"><img src="https://www.notadd.com/src/ucloud_logo.svg" width="150" /></a> |
||||
|
||||
**UCloud 云服务器限时优惠 — Notadd 项目用户福利** |
||||
|
||||
[【基础型】1核2G 1M带宽 50GB SSD数据盘 低至250元/年](https://www.ucloud.cn/site/active/gift.html?ytag=notadd ) |
||||
|
||||
[【标准型】2核4G 1M带宽 50GB SSD数据盘 低至550元/年](https://www.ucloud.cn/site/active/gift.html?ytag=notadd ) |
||||
|
@ -0,0 +1,40 @@ |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
||||
"http://www.w3.org/TR/html4/loose.dtd"> |
||||
<html> |
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
||||
<title></title> |
||||
<style type="text/css"> |
||||
*{color: #838383;margin: 0;padding: 0} |
||||
html,body {font-size: 12px;overflow: hidden; } |
||||
.content{padding:15px 0 0 15px;} |
||||
input{width:210px;height:28px;line-height:28px;margin-left: 4px;border-radius: 5px;border: 1px solid #ccc;} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<div class="content"> |
||||
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value="" /> |
||||
</div> |
||||
<script type="text/javascript" src="../internal.js"></script> |
||||
<script type="text/javascript"> |
||||
var anchorInput = $G('anchorName'), |
||||
node = editor.selection.getRange().getClosedNode(); |
||||
if(node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))){ |
||||
anchorInput.value = node; |
||||
} |
||||
anchorInput.onkeydown = function(evt){ |
||||
evt = evt || window.event; |
||||
if(evt.keyCode == 13){ |
||||
editor.execCommand('anchor', anchorInput.value); |
||||
dialog.close(); |
||||
domUtils.preventDefault(evt) |
||||
} |
||||
}; |
||||
dialog.onok = function (){ |
||||
editor.execCommand('anchor', anchorInput.value); |
||||
dialog.close(); |
||||
}; |
||||
$focus(anchorInput); |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,682 @@ |
||||
@charset "utf-8"; |
||||
/* dialog样式 */ |
||||
.wrapper { |
||||
zoom: 1; |
||||
width: 630px; |
||||
*width: 626px; |
||||
height: 380px; |
||||
margin: 0 auto; |
||||
padding: 10px; |
||||
position: relative; |
||||
font-family: sans-serif; |
||||
} |
||||
|
||||
/*tab样式框大小*/ |
||||
.tabhead { |
||||
float:left; |
||||
} |
||||
.tabbody { |
||||
width: 100%; |
||||
height: 346px; |
||||
position: relative; |
||||
clear: both; |
||||
} |
||||
|
||||
.tabbody .panel { |
||||
position: absolute; |
||||
width: 0; |
||||
height: 0; |
||||
background: #fff; |
||||
overflow: hidden; |
||||
display: none; |
||||
} |
||||
|
||||
.tabbody .panel.focus { |
||||
width: 100%; |
||||
height: 346px; |
||||
display: block; |
||||
} |
||||
|
||||
/* 上传附件 */ |
||||
.tabbody #upload.panel { |
||||
width: 0; |
||||
height: 0; |
||||
overflow: hidden; |
||||
position: absolute !important; |
||||
clip: rect(1px, 1px, 1px, 1px); |
||||
background: #fff; |
||||
display: block; |
||||
} |
||||
|
||||
.tabbody #upload.panel.focus { |
||||
width: 100%; |
||||
height: 346px; |
||||
display: block; |
||||
clip: auto; |
||||
} |
||||
|
||||
#upload .queueList { |
||||
margin: 0; |
||||
width: 100%; |
||||
height: 100%; |
||||
position: absolute; |
||||
overflow: hidden; |
||||
} |
||||
|
||||
#upload p { |
||||
margin: 0; |
||||
} |
||||
|
||||
.element-invisible { |
||||
width: 0 !important; |
||||
height: 0 !important; |
||||
border: 0; |
||||
padding: 0; |
||||
margin: 0; |
||||
overflow: hidden; |
||||
position: absolute !important; |
||||
clip: rect(1px, 1px, 1px, 1px); |
||||
} |
||||
|
||||
#upload .placeholder { |
||||
margin: 10px; |
||||
/*border: 2px dashed #e6e6e6;*/ |
||||
height: 172px; |
||||
padding-top: 150px; |
||||
text-align: center; |
||||
/*background: url(./images/image.png) center 70px no-repeat;*/ |
||||
background-color: #f3f3f3; |
||||
color: #cccccc; |
||||
font-size: 18px; |
||||
position: relative; |
||||
top:0; |
||||
*top: 10px; |
||||
} |
||||
|
||||
#upload .placeholder .webuploader-pick { |
||||
font-size: 16px; |
||||
background: #f3f3f3; |
||||
border-radius: 3px; |
||||
line-height: 44px; |
||||
padding: 0 30px; |
||||
color: #646464; |
||||
display: inline-block; |
||||
margin: 0 auto 20px auto; |
||||
cursor: pointer; |
||||
/* box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); */ |
||||
border: 1px solid #ccc; |
||||
} |
||||
|
||||
#upload .placeholder .webuploader-pick-hover { |
||||
border: 1px solid #00a2d4; |
||||
color: #00a2d4; |
||||
} |
||||
|
||||
|
||||
#filePickerContainer { |
||||
text-align: center; |
||||
} |
||||
|
||||
#upload .placeholder .flashTip { |
||||
color: #666666; |
||||
font-size: 12px; |
||||
position: absolute; |
||||
width: 100%; |
||||
text-align: center; |
||||
bottom: 20px; |
||||
} |
||||
|
||||
#upload .placeholder .flashTip a { |
||||
color: #0785d1; |
||||
text-decoration: none; |
||||
} |
||||
|
||||
#upload .placeholder .flashTip a:hover { |
||||
text-decoration: underline; |
||||
} |
||||
|
||||
#upload .placeholder.webuploader-dnd-over { |
||||
border-color: #999999; |
||||
} |
||||
|
||||
#upload .filelist { |
||||
list-style: none; |
||||
margin: 0; |
||||
padding: 0; |
||||
overflow-x: hidden; |
||||
overflow-y: auto; |
||||
position: relative; |
||||
height: 300px; |
||||
} |
||||
|
||||
#upload .filelist:after { |
||||
content: ''; |
||||
display: block; |
||||
width: 0; |
||||
height: 0; |
||||
overflow: hidden; |
||||
clear: both; |
||||
} |
||||
|
||||
#upload .filelist li { |
||||
width: 113px; |
||||
height: 113px; |
||||
background: url(./images/bg.png); |
||||
text-align: center; |
||||
margin: 9px 0 0 9px; |
||||
*margin: 6px 0 0 6px; |
||||
position: relative; |
||||
display: block; |
||||
float: left; |
||||
overflow: hidden; |
||||
font-size: 12px; |
||||
} |
||||
|
||||
#upload .filelist li p.log { |
||||
position: relative; |
||||
top: -45px; |
||||
} |
||||
|
||||
#upload .filelist li p.title { |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
width: 100%; |
||||
overflow: hidden; |
||||
white-space: nowrap; |
||||
text-overflow: ellipsis; |
||||
top: 5px; |
||||
text-indent: 5px; |
||||
text-align: left; |
||||
} |
||||
|
||||
#upload .filelist li p.progress { |
||||
position: absolute; |
||||
width: 100%; |
||||
bottom: 0; |
||||
left: 0; |
||||
height: 8px; |
||||
overflow: hidden; |
||||
z-index: 50; |
||||
margin: 0; |
||||
border-radius: 0; |
||||
background: none; |
||||
-webkit-box-shadow: 0 0 0; |
||||
} |
||||
|
||||
#upload .filelist li p.progress span { |
||||
display: none; |
||||
overflow: hidden; |
||||
width: 0; |
||||
height: 100%; |
||||
background: #1483d8 url(./images/progress.png) repeat-x; |
||||
|
||||
-webit-transition: width 200ms linear; |
||||
-moz-transition: width 200ms linear; |
||||
-o-transition: width 200ms linear; |
||||
-ms-transition: width 200ms linear; |
||||
transition: width 200ms linear; |
||||
|
||||
-webkit-animation: progressmove 2s linear infinite; |
||||
-moz-animation: progressmove 2s linear infinite; |
||||
-o-animation: progressmove 2s linear infinite; |
||||
-ms-animation: progressmove 2s linear infinite; |
||||
animation: progressmove 2s linear infinite; |
||||
|
||||
-webkit-transform: translateZ(0); |
||||
} |
||||
|
||||
@-webkit-keyframes progressmove { |
||||
0% { |
||||
background-position: 0 0; |
||||
} |
||||
100% { |
||||
background-position: 17px 0; |
||||
} |
||||
} |
||||
|
||||
@-moz-keyframes progressmove { |
||||
0% { |
||||
background-position: 0 0; |
||||
} |
||||
100% { |
||||
background-position: 17px 0; |
||||
} |
||||
} |
||||
|
||||
@keyframes progressmove { |
||||
0% { |
||||
background-position: 0 0; |
||||
} |
||||
100% { |
||||
background-position: 17px 0; |
||||
} |
||||
} |
||||
|
||||
#upload .filelist li p.imgWrap { |
||||
position: relative; |
||||
z-index: 2; |
||||
line-height: 113px; |
||||
vertical-align: middle; |
||||
overflow: hidden; |
||||
width: 113px; |
||||
height: 113px; |
||||
|
||||
-webkit-transform-origin: 50% 50%; |
||||
-moz-transform-origin: 50% 50%; |
||||
-o-transform-origin: 50% 50%; |
||||
-ms-transform-origin: 50% 50%; |
||||
transform-origin: 50% 50%; |
||||
|
||||
-webit-transition: 200ms ease-out; |
||||
-moz-transition: 200ms ease-out; |
||||
-o-transition: 200ms ease-out; |
||||
-ms-transition: 200ms ease-out; |
||||
transition: 200ms ease-out; |
||||
} |
||||
#upload .filelist li p.imgWrap.notimage { |
||||
margin-top: 0; |
||||
width: 111px; |
||||
height: 111px; |
||||
border: 1px #eeeeee solid; |
||||
} |
||||
#upload .filelist li p.imgWrap.notimage i.file-preview { |
||||
margin-top: 15px; |
||||
} |
||||
|
||||
#upload .filelist li img { |
||||
width: 100%; |
||||
} |
||||
|
||||
#upload .filelist li p.error { |
||||
background: #f43838; |
||||
color: #fff; |
||||
position: absolute; |
||||
bottom: 0; |
||||
left: 0; |
||||
height: 28px; |
||||
line-height: 28px; |
||||
width: 100%; |
||||
z-index: 100; |
||||
display:none; |
||||
} |
||||
|
||||
#upload .filelist li .success { |
||||
display: block; |
||||
position: absolute; |
||||
left: 0; |
||||
bottom: 0; |
||||
height: 40px; |
||||
width: 100%; |
||||
z-index: 200; |
||||
background: url(./images/success.png) no-repeat right bottom; |
||||
background-image: url(./images/success.gif) \9; |
||||
} |
||||
|
||||
#upload .filelist li.filePickerBlock { |
||||
width: 113px; |
||||
height: 113px; |
||||
background: url(../fonts/images/addfile.svg) no-repeat center; |
||||
border: 1px solid #eeeeee; |
||||
border-radius: 0; |
||||
} |
||||
#upload .filelist li.filePickerBlock div.webuploader-pick { |
||||
width: 100%; |
||||
height: 100%; |
||||
margin: 0; |
||||
padding: 0; |
||||
opacity: 0; |
||||
background: none; |
||||
font-size: 0; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel { |
||||
position: absolute; |
||||
height: 0; |
||||
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr='#80000000', endColorstr='#80000000') \0; |
||||
background: rgba(0, 0, 0, 0.5); |
||||
width: 100%; |
||||
top: 0; |
||||
left: 0; |
||||
overflow: hidden; |
||||
z-index: 300; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span { |
||||
width: 24px; |
||||
height: 24px; |
||||
display: inline; |
||||
float: right; |
||||
text-indent: -9999px; |
||||
overflow: hidden; |
||||
background: url(./images/icons.png) no-repeat; |
||||
background: url(./images/icons.gif) no-repeat \9; |
||||
margin: 5px 1px 1px; |
||||
cursor: pointer; |
||||
-webkit-tap-highlight-color: rgba(0,0,0,0); |
||||
-webkit-user-select: none; |
||||
-moz-user-select: none; |
||||
-ms-user-select: none; |
||||
user-select: none; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span.rotateLeft { |
||||
display:none; |
||||
background-position: 0 -24px; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span.rotateLeft:hover { |
||||
background-position: 0 0; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span.rotateRight { |
||||
display:none; |
||||
background-position: -24px -24px; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span.rotateRight:hover { |
||||
background-position: -24px 0; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span.cancel { |
||||
background-position: -48px -24px; |
||||
} |
||||
|
||||
#upload .filelist div.file-panel span.cancel:hover { |
||||
background-position: -48px 0; |
||||
} |
||||
|
||||
#upload .statusBar { |
||||
height: 45px; |
||||
border-bottom: 1px solid #dadada; |
||||
margin: 0 10px; |
||||
padding: 0; |
||||
line-height: 45px; |
||||
vertical-align: middle; |
||||
position: relative; |
||||
} |
||||
|
||||
#upload .statusBar .progress { |
||||
border: 1px solid #1483d8; |
||||
width: 198px; |
||||
background: #fff; |
||||
height: 18px; |
||||
position: absolute; |
||||
top: 12px; |
||||
display: none; |
||||
text-align: center; |
||||
line-height: 18px; |
||||
color: #6dbfff; |
||||
margin: 0 10px 0 0; |
||||
} |
||||
#upload .statusBar .progress span.percentage { |
||||
width: 0; |
||||
height: 100%; |
||||
left: 0; |
||||
top: 0; |
||||
background: #1483d8; |
||||
position: absolute; |
||||
} |
||||
#upload .statusBar .progress span.text { |
||||
position: relative; |
||||
z-index: 10; |
||||
} |
||||
|
||||
#upload .statusBar .info { |
||||
display: inline-block; |
||||
font-size: 14px; |
||||
color: #666666; |
||||
} |
||||
|
||||
#upload .statusBar .btns { |
||||
position: absolute; |
||||
top: 7px; |
||||
right: 0; |
||||
line-height: 30px; |
||||
} |
||||
|
||||
#filePickerBtn { |
||||
display: inline-block; |
||||
float: left; |
||||
} |
||||
#upload .statusBar .btns .webuploader-pick, |
||||
#upload .statusBar .btns .uploadBtn, |
||||
#upload .statusBar .btns .uploadBtn.state-uploading, |
||||
#upload .statusBar .btns .uploadBtn.state-paused { |
||||
background: #ffffff; |
||||
border: 1px solid #cfcfcf; |
||||
color: #565656; |
||||
padding: 0 18px; |
||||
display: inline-block; |
||||
border-radius: 3px; |
||||
margin-left: 10px; |
||||
cursor: pointer; |
||||
font-size: 14px; |
||||
float: left; |
||||
-webkit-user-select: none; |
||||
-moz-user-select: none; |
||||
-ms-user-select: none; |
||||
user-select: none; |
||||
} |
||||
#upload .statusBar .btns .webuploader-pick-hover, |
||||
#upload .statusBar .btns .uploadBtn:hover, |
||||
#upload .statusBar .btns .uploadBtn.state-uploading:hover, |
||||
#upload .statusBar .btns .uploadBtn.state-paused:hover { |
||||
background: #f0f0f0; |
||||
} |
||||
|
||||
#upload .statusBar .btns .uploadBtn, |
||||
#upload .statusBar .btns .uploadBtn.state-paused{ |
||||
background: #00b7ee; |
||||
color: #fff; |
||||
border-color: transparent; |
||||
} |
||||
#upload .statusBar .btns .uploadBtn:hover, |
||||
#upload .statusBar .btns .uploadBtn.state-paused:hover{ |
||||
background: #00a2d4; |
||||
} |
||||
|
||||
#upload .statusBar .btns .uploadBtn.disabled { |
||||
pointer-events: none; |
||||
filter:alpha(opacity=60); |
||||
-moz-opacity:0.6; |
||||
-khtml-opacity: 0.6; |
||||
opacity: 0.6; |
||||
} |
||||
|
||||
|
||||
|
||||
/* 图片管理样式 */ |
||||
#online { |
||||
width: 100%; |
||||
height: 336px; |
||||
padding: 10px 0 0 0; |
||||
} |
||||
#online #fileList{ |
||||
width: 100%; |
||||
height: 100%; |
||||
overflow-x: hidden; |
||||
overflow-y: auto; |
||||
position: relative; |
||||
} |
||||
#online ul { |
||||
display: block; |
||||
list-style: none; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
#online li { |
||||
float: left; |
||||
display: block; |
||||
list-style: none; |
||||
padding: 0; |
||||
width: 113px; |
||||
height: 113px; |
||||
margin: 0 0 9px 9px; |
||||
*margin: 0 0 6px 6px; |
||||
background-color: #eee; |
||||
overflow: hidden; |
||||
cursor: pointer; |
||||
position: relative; |
||||
} |
||||
#online li.clearFloat { |
||||
float: none; |
||||
clear: both; |
||||
display: block; |
||||
width:0; |
||||
height:0; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
#online li img { |
||||
cursor: pointer; |
||||
} |
||||
#online li div.file-wrapper { |
||||
cursor: pointer; |
||||
position: absolute; |
||||
display: block; |
||||
width: 111px; |
||||
height: 111px; |
||||
border: 1px solid #eee; |
||||
background: url("./images/bg.png") repeat; |
||||
} |
||||
#online li div span.file-title{ |
||||
display: block; |
||||
padding: 0 3px; |
||||
margin: 3px 0 0 0; |
||||
font-size: 12px; |
||||
height: 15px; |
||||
color: #555555; |
||||
text-align: center; |
||||
width: 107px; |
||||
white-space: nowrap; |
||||
word-break: break-all; |
||||
overflow: hidden; |
||||
text-overflow: ellipsis; |
||||
} |
||||
#online li .icon { |
||||
cursor: pointer; |
||||
width: 113px; |
||||
height: 113px; |
||||
position: absolute; |
||||
top: 0; |
||||
left: 0; |
||||
z-index: 2; |
||||
border: 0; |
||||
background-repeat: no-repeat; |
||||
} |
||||
#online li .icon:hover { |
||||
width: 107px; |
||||
height: 107px; |
||||
border: 3px solid #1094fa; |
||||
} |
||||
#online li.selected .icon { |
||||
background-image: url(images/success.png); |
||||
background-image: url(images/success.gif) \9; |
||||
background-position: 75px 75px; |
||||
} |
||||
#online li.selected .icon:hover { |
||||
width: 107px; |
||||
height: 107px; |
||||
border: 3px solid #1094fa; |
||||
background-position: 72px 72px; |
||||
} |
||||
|
||||
|
||||
/* 在线文件的文件预览图标 */ |
||||
i.file-preview { |
||||
display: block; |
||||
margin: 10px auto; |
||||
width: 70px; |
||||
height: 70px; |
||||
background-image: url("./images/file-icons.png"); |
||||
background-image: url("./images/file-icons.gif") \9; |
||||
background-position: -140px center; |
||||
background-repeat: no-repeat; |
||||
} |
||||
i.file-preview.file-type-dir{ |
||||
background-position: 0 center; |
||||
} |
||||
i.file-preview.file-type-file{ |
||||
background-position: -140px center; |
||||
} |
||||
i.file-preview.file-type-filelist{ |
||||
background-position: -210px center; |
||||
} |
||||
i.file-preview.file-type-zip, |
||||
i.file-preview.file-type-rar, |
||||
i.file-preview.file-type-7z, |
||||
i.file-preview.file-type-tar, |
||||
i.file-preview.file-type-gz, |
||||
i.file-preview.file-type-bz2{ |
||||
background-position: -280px center; |
||||
} |
||||
i.file-preview.file-type-xls, |
||||
i.file-preview.file-type-xlsx{ |
||||
background-position: -350px center; |
||||
} |
||||
i.file-preview.file-type-doc, |
||||
i.file-preview.file-type-docx{ |
||||
background-position: -420px center; |
||||
} |
||||
i.file-preview.file-type-ppt, |
||||
i.file-preview.file-type-pptx{ |
||||
background-position: -490px center; |
||||
} |
||||
i.file-preview.file-type-vsd{ |
||||
background-position: -560px center; |
||||
} |
||||
i.file-preview.file-type-pdf{ |
||||
background-position: -630px center; |
||||
} |
||||
i.file-preview.file-type-txt, |
||||
i.file-preview.file-type-md, |
||||
i.file-preview.file-type-json, |
||||
i.file-preview.file-type-htm, |
||||
i.file-preview.file-type-xml, |
||||
i.file-preview.file-type-html, |
||||
i.file-preview.file-type-js, |
||||
i.file-preview.file-type-css, |
||||
i.file-preview.file-type-php, |
||||
i.file-preview.file-type-jsp, |
||||
i.file-preview.file-type-asp{ |
||||
background-position: -700px center; |
||||
} |
||||
i.file-preview.file-type-apk{ |
||||
background-position: -770px center; |
||||
} |
||||
i.file-preview.file-type-exe{ |
||||
background-position: -840px center; |
||||
} |
||||
i.file-preview.file-type-ipa{ |
||||
background-position: -910px center; |
||||
} |
||||
i.file-preview.file-type-mp4, |
||||
i.file-preview.file-type-swf, |
||||
i.file-preview.file-type-mkv, |
||||
i.file-preview.file-type-avi, |
||||
i.file-preview.file-type-flv, |
||||
i.file-preview.file-type-mov, |
||||
i.file-preview.file-type-mpg, |
||||
i.file-preview.file-type-mpeg, |
||||
i.file-preview.file-type-ogv, |
||||
i.file-preview.file-type-webm, |
||||
i.file-preview.file-type-rm, |
||||
i.file-preview.file-type-rmvb{ |
||||
background-position: -980px center; |
||||
} |
||||
i.file-preview.file-type-ogg, |
||||
i.file-preview.file-type-wav, |
||||
i.file-preview.file-type-wmv, |
||||
i.file-preview.file-type-mid, |
||||
i.file-preview.file-type-mp3{ |
||||
background-position: -1050px center; |
||||
} |
||||
i.file-preview.file-type-jpg, |
||||
i.file-preview.file-type-jpeg, |
||||
i.file-preview.file-type-gif, |
||||
i.file-preview.file-type-bmp, |
||||
i.file-preview.file-type-png, |
||||
i.file-preview.file-type-psd{ |
||||
background-position: -140px center; |
||||
} |
@ -0,0 +1,60 @@ |
||||
<!doctype html> |
||||
<html> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>neditor图片对话框</title> |
||||
<script type="text/javascript" src="../internal.js"></script> |
||||
|
||||
<!-- jquery --> |
||||
<script type="text/javascript" src="../../third-party/jquery-1.10.2.min.js"></script> |
||||
|
||||
<!-- webuploader --> |
||||
<script src="../../third-party/webuploader/webuploader.js"></script> |
||||
<link rel="stylesheet" type="text/css" href="../../third-party/webuploader/webuploader.css"> |
||||
|
||||
<!-- attachment dialog --> |
||||
<link rel="stylesheet" href="attachment.css" type="text/css" /> |
||||
</head> |
||||
<body> |
||||
|
||||
<div class="wrapper"> |
||||
<div id="tabhead" class="tabhead"> |
||||
<span class="tab focus" data-content-id="upload"><var id="lang_tab_upload"></var></span> |
||||
<!-- <span class="tab" data-content-id="online"><var id="lang_tab_online"></var></span> --> |
||||
</div> |
||||
<div id="tabbody" class="tabbody"> |
||||
<!-- 上传图片 --> |
||||
<div id="upload" class="panel focus"> |
||||
<div id="queueList" class="queueList"> |
||||
<div class="statusBar element-invisible"> |
||||
<div class="progress"> |
||||
<span class="text">0%</span> |
||||
<span class="percentage"></span> |
||||
</div><div class="info"></div> |
||||
<div class="btns"> |
||||
<div id="filePickerBtn"></div> |
||||
<div class="uploadBtn"><var id="lang_start_upload"></var></div> |
||||
</div> |
||||
</div> |
||||
<div id="dndArea" class="placeholder"> |
||||
<div class="filePickerContainer"> |
||||
<div id="filePickerReady"></div> |
||||
</div> |
||||
</div> |
||||
<ul class="filelist element-invisible"> |
||||
<li id="filePickerBlock" class="filePickerBlock"></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
|
||||
<!-- 在线图片 --> |
||||
<div id="online" class="panel"> |
||||
<div id="fileList"><var id="lang_imgLoading"></var></div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
<script type="text/javascript" src="attachment.js"></script> |
||||
|
||||
</body> |
||||
</html> |
@ -0,0 +1,777 @@ |
||||
/** |
||||
* User: Jinqn |
||||
* Date: 14-04-08 |
||||
* Time: 下午16:34 |
||||
* 上传图片对话框逻辑代码,包括tab: 远程图片/上传图片/在线图片/搜索图片 |
||||
*/ |
||||
|
||||
(function () { |
||||
|
||||
var uploadFile, |
||||
onlineFile; |
||||
|
||||
window.onload = function () { |
||||
initTabs(); |
||||
initButtons(); |
||||
}; |
||||
|
||||
/* 初始化tab标签 */ |
||||
function initTabs() { |
||||
var tabs = $G('tabhead').children; |
||||
for (var i = 0; i < tabs.length; i++) { |
||||
domUtils.on(tabs[i], "click", function (e) { |
||||
var target = e.target || e.srcElement; |
||||
setTabFocus(target.getAttribute('data-content-id')); |
||||
}); |
||||
} |
||||
|
||||
setTabFocus('upload'); |
||||
} |
||||
|
||||
/* 初始化tabbody */ |
||||
function setTabFocus(id) { |
||||
if(!id) return; |
||||
var i, bodyId, tabs = $G('tabhead').children; |
||||
for (i = 0; i < tabs.length; i++) { |
||||
bodyId = tabs[i].getAttribute('data-content-id') |
||||
if (bodyId == id) { |
||||
domUtils.addClass(tabs[i], 'focus'); |
||||
domUtils.addClass($G(bodyId), 'focus'); |
||||
} else { |
||||
domUtils.removeClasses(tabs[i], 'focus'); |
||||
domUtils.removeClasses($G(bodyId), 'focus'); |
||||
} |
||||
} |
||||
switch (id) { |
||||
case 'upload': |
||||
uploadFile = uploadFile || new UploadFile('queueList'); |
||||
break; |
||||
case 'online': |
||||
onlineFile = onlineFile || new OnlineFile('fileList'); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/* 初始化onok事件 */ |
||||
function initButtons() { |
||||
|
||||
dialog.onok = function () { |
||||
var list = [], id, tabs = $G('tabhead').children; |
||||
for (var i = 0; i < tabs.length; i++) { |
||||
if (domUtils.hasClass(tabs[i], 'focus')) { |
||||
id = tabs[i].getAttribute('data-content-id'); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
switch (id) { |
||||
case 'upload': |
||||
list = uploadFile.getInsertList(); |
||||
var count = uploadFile.getQueueCount(); |
||||
if (count) { |
||||
$('.info', '#queueList').html('<span style="color:red;">' + '还有2个未上传文件'.replace(/[\d]/, count) + '</span>'); |
||||
return false; |
||||
} |
||||
break; |
||||
case 'online': |
||||
list = onlineFile.getInsertList(); |
||||
break; |
||||
} |
||||
|
||||
editor.execCommand('insertfile', list); |
||||
}; |
||||
} |
||||
|
||||
|
||||
/* 上传附件 */ |
||||
function UploadFile(target) { |
||||
this.$wrap = target.constructor == String ? $('#' + target) : $(target); |
||||
this.init(); |
||||
} |
||||
UploadFile.prototype = { |
||||
init: function () { |
||||
this.fileList = []; |
||||
this.initContainer(); |
||||
this.initUploader(); |
||||
}, |
||||
initContainer: function () { |
||||
this.$queue = this.$wrap.find('.filelist'); |
||||
}, |
||||
/* 初始化容器 */ |
||||
initUploader: function () { |
||||
var _this = this, |
||||
$ = jQuery, // just in case. Make sure it's not an other libaray.
|
||||
$wrap = _this.$wrap, |
||||
// 图片容器
|
||||
$queue = $wrap.find('.filelist'), |
||||
// 状态栏,包括进度和控制按钮
|
||||
$statusBar = $wrap.find('.statusBar'), |
||||
// 文件总体选择信息。
|
||||
$info = $statusBar.find('.info'), |
||||
// 上传按钮
|
||||
$upload = $wrap.find('.uploadBtn'), |
||||
// 上传按钮
|
||||
$filePickerBtn = $wrap.find('.filePickerBtn'), |
||||
// 上传按钮
|
||||
$filePickerBlock = $wrap.find('.filePickerBlock'), |
||||
// 没选择文件之前的内容。
|
||||
$placeHolder = $wrap.find('.placeholder'), |
||||
// 总体进度条
|
||||
$progress = $statusBar.find('.progress').hide(), |
||||
// 添加的文件数量
|
||||
fileCount = 0, |
||||
// 添加的文件总大小
|
||||
fileSize = 0, |
||||
// 优化retina, 在retina下这个值是2
|
||||
ratio = window.devicePixelRatio || 1, |
||||
// 缩略图大小
|
||||
thumbnailWidth = 113 * ratio, |
||||
thumbnailHeight = 113 * ratio, |
||||
// 可能有pedding, ready, uploading, confirm, done.
|
||||
state = '', |
||||
// 所有文件的进度信息,key为file id
|
||||
percentages = {}, |
||||
supportTransition = (function () { |
||||
var s = document.createElement('p').style, |
||||
r = 'transition' in s || |
||||
'WebkitTransition' in s || |
||||
'MozTransition' in s || |
||||
'msTransition' in s || |
||||
'OTransition' in s; |
||||
s = null; |
||||
return r; |
||||
})(), |
||||
// WebUploader实例
|
||||
uploader, |
||||
actionUrl = editor.getActionUrl(editor.getOpt('fileActionName')), |
||||
fileMaxSize = editor.getOpt('fileMaxSize'), |
||||
acceptExtensions = (editor.getOpt('fileAllowFiles') ||
|
||||
[".accdb",".pub","psd",".exe",".webm",".flv",".rmvb",".mp4",".mvb",".tiff",".swf",".jpg",".jpeg",".gif",".png",".txt",".doc",".docs",".xls", |
||||
".xlsx",".ppt",".pdf",".odt",".ott",".fodt",".uot",".xml",".dot",".htm",".html",".rtf",".docm", |
||||
".zip",".rar",".tar",".7z",".tar.gz",".tar.bz",".tar.xz"]).join('').replace(/\./g, ',').replace(/^[,]/, '');; |
||||
if (!WebUploader.Uploader.support()) { |
||||
$('#filePickerReady').after($('<div>').html(lang.errorNotSupport)).hide(); |
||||
return; |
||||
} else if (!editor.getOpt('fileActionName')) { |
||||
$('#filePickerReady').after($('<div>').html(lang.errorLoadConfig)).hide(); |
||||
return; |
||||
} |
||||
|
||||
uploader = _this.uploader = WebUploader.create({ |
||||
pick: { |
||||
id: '#filePickerReady', |
||||
label: lang.uploadSelectFile |
||||
}, |
||||
swf: '../../third-party/webuploader/Uploader.swf', |
||||
server: actionUrl, |
||||
fileVal: editor.getOpt('fileFieldName'), |
||||
duplicate: true, |
||||
fileSingleSizeLimit: fileMaxSize, |
||||
compress: false |
||||
}); |
||||
uploader.addButton({ |
||||
id: '#filePickerBlock' |
||||
}); |
||||
uploader.addButton({ |
||||
id: '#filePickerBtn', |
||||
label: lang.uploadAddFile |
||||
}); |
||||
|
||||
setState('pedding'); |
||||
|
||||
// 当有文件添加进来时执行,负责view的创建
|
||||
function addFile(file) { |
||||
var $li = $('<li id="' + file.id + '">' + |
||||
'<p class="title">' + file.name + '</p>' + |
||||
'<p class="imgWrap"></p>' + |
||||
'<p class="progress"><span></span></p>' + |
||||
'</li>'), |
||||
|
||||
$btns = $('<div class="file-panel">' + |
||||
'<span class="cancel">' + lang.uploadDelete + '</span>' + |
||||
'<span class="rotateRight">' + lang.uploadTurnRight + '</span>' + |
||||
'<span class="rotateLeft">' + lang.uploadTurnLeft + '</span></div>').appendTo($li), |
||||
$prgress = $li.find('p.progress span'), |
||||
$wrap = $li.find('p.imgWrap'), |
||||
$info = $('<p class="error"></p>').hide().appendTo($li), |
||||
|
||||
showError = function (code) { |
||||
switch (code) { |
||||
case 'exceed_size': |
||||
text = lang.errorExceedSize; |
||||
break; |
||||
case 'interrupt': |
||||
text = lang.errorInterrupt; |
||||
break; |
||||
case 'http': |
||||
text = lang.errorHttp; |
||||
break; |
||||
case 'not_allow_type': |
||||
text = lang.errorFileType; |
||||
break; |
||||
default: |
||||
text = lang.errorUploadRetry; |
||||
break; |
||||
} |
||||
$info.text(text).show(); |
||||
}; |
||||
|
||||
if (file.getStatus() === 'invalid') { |
||||
showError(file.statusText); |
||||
} else { |
||||
$wrap.text(lang.uploadPreview); |
||||
if ('|png|jpg|jpeg|bmp|gif|'.indexOf('|'+file.ext.toLowerCase()+'|') == -1) { |
||||
$wrap.empty().addClass('notimage').append('<i class="file-preview file-type-' + file.ext.toLowerCase() + '"></i>' + |
||||
'<span class="file-title" title="' + file.name + '">' + file.name + '</span>'); |
||||
} else { |
||||
if (browser.ie && browser.version <= 7) { |
||||
$wrap.text(lang.uploadNoPreview); |
||||
} else { |
||||
uploader.makeThumb(file, function (error, src) { |
||||
if (error || !src) { |
||||
$wrap.text(lang.uploadNoPreview); |
||||
} else { |
||||
var $img = $('<img src="' + src + '">'); |
||||
$wrap.empty().append($img); |
||||
$img.on('error', function () { |
||||
$wrap.text(lang.uploadNoPreview); |
||||
}); |
||||
} |
||||
}, thumbnailWidth, thumbnailHeight); |
||||
} |
||||
} |
||||
percentages[ file.id ] = [ file.size, 0 ]; |
||||
file.rotation = 0; |
||||
|
||||
/* 检查文件格式 */ |
||||
if (!file.ext || acceptExtensions.indexOf(file.ext.toLowerCase()) == -1) { |
||||
showError('not_allow_type'); |
||||
uploader.removeFile(file); |
||||
} |
||||
} |
||||
|
||||
file.on('statuschange', function (cur, prev) { |
||||
if (prev === 'progress') { |
||||
$prgress.hide().width(0); |
||||
} else if (prev === 'queued') { |
||||
$li.off('mouseenter mouseleave'); |
||||
$btns.remove(); |
||||
} |
||||
// 成功
|
||||
if (cur === 'error' || cur === 'invalid') { |
||||
showError(file.statusText); |
||||
percentages[ file.id ][ 1 ] = 1; |
||||
} else if (cur === 'interrupt') { |
||||
showError('interrupt'); |
||||
} else if (cur === 'queued') { |
||||
percentages[ file.id ][ 1 ] = 0; |
||||
} else if (cur === 'progress') { |
||||
$info.hide(); |
||||
$prgress.css('display', 'block'); |
||||
} else if (cur === 'complete') { |
||||
} |
||||
|
||||
$li.removeClass('state-' + prev).addClass('state-' + cur); |
||||
}); |
||||
|
||||
$li.on('mouseenter', function () { |
||||
$btns.stop().animate({height: 30}); |
||||
}); |
||||
$li.on('mouseleave', function () { |
||||
$btns.stop().animate({height: 0}); |
||||
}); |
||||
|
||||
$btns.on('click', 'span', function () { |
||||
var index = $(this).index(), |
||||
deg; |
||||
|
||||
switch (index) { |
||||
case 0: |
||||
uploader.removeFile(file); |
||||
return; |
||||
case 1: |
||||
file.rotation += 90; |
||||
break; |
||||
case 2: |
||||
file.rotation -= 90; |
||||
break; |
||||
} |
||||
|
||||
if (supportTransition) { |
||||
deg = 'rotate(' + file.rotation + 'deg)'; |
||||
$wrap.css({ |
||||
'-webkit-transform': deg, |
||||
'-mos-transform': deg, |
||||
'-o-transform': deg, |
||||
'transform': deg |
||||
}); |
||||
} else { |
||||
$wrap.css('filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' + (~~((file.rotation / 90) % 4 + 4) % 4) + ')'); |
||||
} |
||||
|
||||
}); |
||||
|
||||
$li.insertBefore($filePickerBlock); |
||||
} |
||||
|
||||
// 负责view的销毁
|
||||
function removeFile(file) { |
||||
var $li = $('#' + file.id); |
||||
delete percentages[ file.id ]; |
||||
updateTotalProgress(); |
||||
$li.off().find('.file-panel').off().end().remove(); |
||||
} |
||||
|
||||
function updateTotalProgress() { |
||||
var loaded = 0, |
||||
total = 0, |
||||
spans = $progress.children(), |
||||
percent; |
||||
|
||||
$.each(percentages, function (k, v) { |
||||
total += v[ 0 ]; |
||||
loaded += v[ 0 ] * v[ 1 ]; |
||||
}); |
||||
|
||||
percent = total ? loaded / total : 0; |
||||
|
||||
spans.eq(0).text(Math.round(percent * 100) + '%'); |
||||
spans.eq(1).css('width', Math.round(percent * 100) + '%'); |
||||
updateStatus(); |
||||
} |
||||
|
||||
function setState(val, files) { |
||||
|
||||
if (val != state) { |
||||
|
||||
var stats = uploader.getStats(); |
||||
|
||||
$upload.removeClass('state-' + state); |
||||
$upload.addClass('state-' + val); |
||||
|
||||
switch (val) { |
||||
|
||||
/* 未选择文件 */ |
||||
case 'pedding': |
||||
$queue.addClass('element-invisible'); |
||||
$statusBar.addClass('element-invisible'); |
||||
$placeHolder.removeClass('element-invisible'); |
||||
$progress.hide(); $info.hide(); |
||||
uploader.refresh(); |
||||
break; |
||||
|
||||
/* 可以开始上传 */ |
||||
case 'ready': |
||||
$placeHolder.addClass('element-invisible'); |
||||
$queue.removeClass('element-invisible'); |
||||
$statusBar.removeClass('element-invisible'); |
||||
$progress.hide(); $info.show(); |
||||
$upload.text(lang.uploadStart); |
||||
uploader.refresh(); |
||||
break; |
||||
|
||||
/* 上传中 */ |
||||
case 'uploading': |
||||
$progress.show(); $info.hide(); |
||||
$upload.text(lang.uploadPause); |
||||
break; |
||||
|
||||
/* 暂停上传 */ |
||||
case 'paused': |
||||
$progress.show(); $info.hide(); |
||||
$upload.text(lang.uploadContinue); |
||||
break; |
||||
|
||||
case 'confirm': |
||||
$progress.show(); $info.hide(); |
||||
$upload.text(lang.uploadStart); |
||||
|
||||
stats = uploader.getStats(); |
||||
if (stats.successNum && !stats.uploadFailNum) { |
||||
setState('finish'); |
||||
return; |
||||
} |
||||
break; |
||||
|
||||
case 'finish': |
||||
$progress.hide(); $info.show(); |
||||
if (stats.uploadFailNum) { |
||||
$upload.text(lang.uploadRetry); |
||||
} else { |
||||
$upload.text(lang.uploadStart); |
||||
} |
||||
break; |
||||
} |
||||
|
||||
state = val; |
||||
updateStatus(); |
||||
|
||||
} |
||||
|
||||
if (!_this.getQueueCount()) { |
||||
$upload.addClass('disabled') |
||||
} else { |
||||
$upload.removeClass('disabled') |
||||
} |
||||
|
||||
} |
||||
|
||||
function updateStatus() { |
||||
var text = '', stats; |
||||
|
||||
if (state === 'ready') { |
||||
text = lang.updateStatusReady.replace('_', fileCount).replace('_KB', WebUploader.formatSize(fileSize)); |
||||
} else if (state === 'confirm') { |
||||
stats = uploader.getStats(); |
||||
if (stats.uploadFailNum) { |
||||
text = lang.updateStatusConfirm.replace('_', stats.successNum).replace('_', stats.successNum); |
||||
} |
||||
} else { |
||||
stats = uploader.getStats(); |
||||
text = lang.updateStatusFinish.replace('_', fileCount). |
||||
replace('_KB', WebUploader.formatSize(fileSize)). |
||||
replace('_', stats.successNum); |
||||
|
||||
if (stats.uploadFailNum) { |
||||
text += lang.updateStatusError.replace('_', stats.uploadFailNum); |
||||
} |
||||
} |
||||
|
||||
$info.html(text); |
||||
} |
||||
|
||||
uploader.on('fileQueued', function (file) { |
||||
/* 选择文件后设置上传相关的url和自定义参数 */ |
||||
editor.getOpt("fileUploadService")(_this, editor).setUploadData(file); |
||||
|
||||
if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) { |
||||
fileCount++; |
||||
fileSize += file.size; |
||||
} |
||||
|
||||
if (fileCount === 1) { |
||||
$placeHolder.addClass('element-invisible'); |
||||
$statusBar.show(); |
||||
} |
||||
|
||||
addFile(file); |
||||
}); |
||||
|
||||
uploader.on('fileDequeued', function (file) { |
||||
if (file.ext && acceptExtensions.indexOf(file.ext.toLowerCase()) != -1 && file.size <= fileMaxSize) { |
||||
fileCount--; |
||||
fileSize -= file.size; |
||||
} |
||||
|
||||
removeFile(file); |
||||
updateTotalProgress(); |
||||
}); |
||||
|
||||
uploader.on('filesQueued', function (file) { |
||||
if (!uploader.isInProgress() && (state == 'pedding' || state == 'finish' || state == 'confirm' || state == 'ready')) { |
||||
setState('ready'); |
||||
} |
||||
updateTotalProgress(); |
||||
}); |
||||
|
||||
uploader.on('all', function (type, files) { |
||||
switch (type) { |
||||
case 'uploadFinished': |
||||
setState('confirm', files); |
||||
break; |
||||
case 'startUpload': |
||||
/* 设置Uploader配置项 */ |
||||
editor.getOpt("fileUploadService")(_this, editor).setUploaderOptions(uploader); |
||||
setState('uploading', files); |
||||
break; |
||||
case 'stopUpload': |
||||
setState('paused', files); |
||||
break; |
||||
} |
||||
}); |
||||
|
||||
uploader.on('uploadBeforeSend', function (object, data, headers) { |
||||
//这里可以通过data对象添加POST参数
|
||||
editor.getOpt("fileUploadService")(_this, editor).setFormData(object, data, headers); |
||||
}); |
||||
|
||||
uploader.on('uploadProgress', function (file, percentage) { |
||||
var $li = $('#' + file.id), |
||||
$percent = $li.find('.progress span'); |
||||
|
||||
$percent.css('width', percentage * 100 + '%'); |
||||
percentages[ file.id ][ 1 ] = percentage; |
||||
updateTotalProgress(); |
||||
}); |
||||
|
||||
uploader.on('uploadSuccess', function (file, res) { |
||||
var $file = $('#' + file.id); |
||||
try { |
||||
if (editor.getOpt("fileUploadService")(_this, editor).getResponseSuccess(res)) { |
||||
_this.fileList.push(res); |
||||
$file.append('<span class="success"></span>'); |
||||
} else { |
||||
$file.find('.error').text(res.message).show(); |
||||
} |
||||
} catch (e) { |
||||
$file.find('.error').text(lang.errorServerUpload).show(); |
||||
} |
||||
}); |
||||
|
||||
uploader.on('uploadError', function (file, code) { |
||||
}); |
||||
uploader.on('error', function (code, file) { |
||||
if (code == 'Q_TYPE_DENIED' || code == 'F_EXCEED_SIZE') { |
||||
addFile(file); |
||||
} |
||||
}); |
||||
uploader.on('uploadComplete', function (file, ret) { |
||||
}); |
||||
|
||||
$upload.on('click', function () { |
||||
if ($(this).hasClass('disabled')) { |
||||
return false; |
||||
} |
||||
|
||||
if (state === 'ready') { |
||||
uploader.upload(); |
||||
} else if (state === 'paused') { |
||||
uploader.upload(); |
||||
} else if (state === 'uploading') { |
||||
uploader.stop(); |
||||
} |
||||
}); |
||||
|
||||
$upload.addClass('state-' + state); |
||||
updateTotalProgress(); |
||||
}, |
||||
getQueueCount: function () { |
||||
var file, i, status, readyFile = 0, files = this.uploader.getFiles(); |
||||
for (i = 0; file = files[i++]; ) { |
||||
status = file.getStatus(); |
||||
if (status == 'queued' || status == 'uploading' || status == 'progress') readyFile++; |
||||
} |
||||
return readyFile; |
||||
}, |
||||
getInsertList: function () { |
||||
var i, link, data, list = [], |
||||
prefix = editor.getOpt('fileUrlPrefix'), |
||||
fileSrcField = editor.getOpt("fileUploadService")(this, editor).fileSrcField || 'url', |
||||
fileSrc = '', |
||||
fileSrcFieldKeys = fileSrcField.split('.'); |
||||
|
||||
for (i = 0; i < this.fileList.length; i++) { |
||||
data = this.fileList[i]; |
||||
if(fileSrcFieldKeys.length > 1) { |
||||
function setFileSrc(obj, keys, index) { |
||||
obj = obj[keys[index]]; |
||||
if (index < keys.length - 1) { |
||||
setFileSrc(obj, keys, index += 1) |
||||
} else { |
||||
fileSrc = obj; |
||||
} |
||||
} |
||||
|
||||
setFileSrc(data, fileSrcFieldKeys, 0); |
||||
} else { |
||||
fileSrc = data[fileSrcField]; |
||||
} |
||||
link = fileSrc; |
||||
list.push({ |
||||
title: data.original || link.substr(link.lastIndexOf('/') + 1), |
||||
url: prefix + link |
||||
}); |
||||
} |
||||
return list; |
||||
} |
||||
}; |
||||
|
||||
|
||||
/* 在线附件 */ |
||||
function OnlineFile(target) { |
||||
this.container = utils.isString(target) ? document.getElementById(target) : target; |
||||
this.init(); |
||||
} |
||||
OnlineFile.prototype = { |
||||
init: function () { |
||||
this.initContainer(); |
||||
this.initEvents(); |
||||
this.initData(); |
||||
}, |
||||
/* 初始化容器 */ |
||||
initContainer: function () { |
||||
this.container.innerHTML = ''; |
||||
this.list = document.createElement('ul'); |
||||
this.clearFloat = document.createElement('li'); |
||||
|
||||
domUtils.addClass(this.list, 'list'); |
||||
domUtils.addClass(this.clearFloat, 'clearFloat'); |
||||
|
||||
this.list.appendChild(this.clearFloat); |
||||
this.container.appendChild(this.list); |
||||
}, |
||||
/* 初始化滚动事件,滚动到地步自动拉取数据 */ |
||||
initEvents: function () { |
||||
var _this = this; |
||||
|
||||
/* 滚动拉取图片 */ |
||||
domUtils.on($G('fileList'), 'scroll', function(e){ |
||||
var panel = this; |
||||
if (panel.scrollHeight - (panel.offsetHeight + panel.scrollTop) < 10) { |
||||
_this.getFileData(); |
||||
} |
||||
}); |
||||
/* 选中图片 */ |
||||
domUtils.on(this.list, 'click', function (e) { |
||||
var target = e.target || e.srcElement, |
||||
li = target.parentNode; |
||||
|
||||
if (li.tagName.toLowerCase() == 'li') { |
||||
if (domUtils.hasClass(li, 'selected')) { |
||||
domUtils.removeClasses(li, 'selected'); |
||||
} else { |
||||
domUtils.addClass(li, 'selected'); |
||||
} |
||||
} |
||||
}); |
||||
}, |
||||
/* 初始化第一次的数据 */ |
||||
initData: function () { |
||||
|
||||
/* 拉取数据需要使用的值 */ |
||||
this.state = 0; |
||||
this.listSize = editor.getOpt('fileManagerListSize'); |
||||
this.listIndex = 0; |
||||
this.listEnd = false; |
||||
|
||||
/* 第一次拉取数据 */ |
||||
this.getFileData(); |
||||
}, |
||||
/* 向后台拉取图片列表数据 */ |
||||
getFileData: function () { |
||||
var _this = this; |
||||
|
||||
if(!_this.listEnd && !this.isLoadingData) { |
||||
this.isLoadingData = true; |
||||
ajax.request(editor.getActionUrl(editor.getOpt('fileManagerActionName')), { |
||||
timeout: 100000, |
||||
data: utils.extend({ |
||||
start: this.listIndex, |
||||
size: this.listSize |
||||
}, editor.queryCommandValue('serverparam')), |
||||
method: 'get', |
||||
onsuccess: function (r) { |
||||
try { |
||||
var json = eval('(' + r.responseText + ')'); |
||||
if (json.state == 'SUCCESS') { |
||||
_this.pushData(json.list); |
||||
_this.listIndex = parseInt(json.start) + parseInt(json.list.length); |
||||
if(_this.listIndex >= json.total) { |
||||
_this.listEnd = true; |
||||
} |
||||
_this.isLoadingData = false; |
||||
} |
||||
} catch (e) { |
||||
if(r.responseText.indexOf('ue_separate_ue') != -1) { |
||||
var list = r.responseText.split(r.responseText); |
||||
_this.pushData(list); |
||||
_this.listIndex = parseInt(list.length); |
||||
_this.listEnd = true; |
||||
_this.isLoadingData = false; |
||||
} |
||||
} |
||||
}, |
||||
onerror: function () { |
||||
_this.isLoadingData = false; |
||||
} |
||||
}); |
||||
} |
||||
}, |
||||
/* 添加图片到列表界面上 */ |
||||
pushData: function (list) { |
||||
var i, item, img, filetype, preview, icon, _this = this, |
||||
urlPrefix = editor.getOpt('fileManagerUrlPrefix'); |
||||
for (i = 0; i < list.length; i++) { |
||||
if(list[i] && list[i].url) { |
||||
item = document.createElement('li'); |
||||
icon = document.createElement('span'); |
||||
filetype = list[i].url.substr(list[i].url.lastIndexOf('.') + 1); |
||||
|
||||
if ( "png|jpg|jpeg|gif|bmp".indexOf(filetype) != -1 ) { |
||||
preview = document.createElement('img'); |
||||
domUtils.on(preview, 'load', (function(image){ |
||||
return function(){ |
||||
_this.scale(image, image.parentNode.offsetWidth, image.parentNode.offsetHeight); |
||||
}; |
||||
})(preview)); |
||||
preview.width = 113; |
||||
preview.setAttribute('src', urlPrefix + list[i].url + (list[i].url.indexOf('?') == -1 ? '?noCache=':'&noCache=') + (+new Date()).toString(36) ); |
||||
} else { |
||||
var ic = document.createElement('i'), |
||||
textSpan = document.createElement('span'); |
||||
textSpan.innerHTML = list[i].url.substr(list[i].url.lastIndexOf('/') + 1); |
||||
preview = document.createElement('div'); |
||||
preview.appendChild(ic); |
||||
preview.appendChild(textSpan); |
||||
domUtils.addClass(preview, 'file-wrapper'); |
||||
domUtils.addClass(textSpan, 'file-title'); |
||||
domUtils.addClass(ic, 'file-type-' + filetype); |
||||
domUtils.addClass(ic, 'file-preview'); |
||||
} |
||||
domUtils.addClass(icon, 'icon'); |
||||
item.setAttribute('data-url', urlPrefix + list[i].url); |
||||
if (list[i].original) { |
||||
item.setAttribute('data-title', list[i].original); |
||||
} |
||||
|
||||
item.appendChild(preview); |
||||
item.appendChild(icon); |
||||
this.list.insertBefore(item, this.clearFloat); |
||||
} |
||||
} |
||||
}, |
||||
/* 改变图片大小 */ |
||||
scale: function (img, w, h, type) { |
||||
var ow = img.width, |
||||
oh = img.height; |
||||
|
||||
if (type == 'justify') { |
||||
if (ow >= oh) { |
||||
img.width = w; |
||||
img.height = h * oh / ow; |
||||
img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px'; |
||||
} else { |
||||
img.width = w * ow / oh; |
||||
img.height = h; |
||||
img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px'; |
||||
} |
||||
} else { |
||||
if (ow >= oh) { |
||||
img.width = w * ow / oh; |
||||
img.height = h; |
||||
img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px'; |
||||
} else { |
||||
img.width = w; |
||||
img.height = h * oh / ow; |
||||
img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px'; |
||||
} |
||||
} |
||||
}, |
||||
getInsertList: function () { |
||||
var i, lis = this.list.children, list = []; |
||||
for (i = 0; i < lis.length; i++) { |
||||
if (domUtils.hasClass(lis[i], 'selected')) { |
||||
var url = lis[i].getAttribute('data-url'); |
||||
var title = lis[i].getAttribute('data-title') || url.substr(url.lastIndexOf('/') + 1); |
||||
list.push({ |
||||
title: title, |
||||
url: url |
||||
}); |
||||
} |
||||
} |
||||
return list; |
||||
} |
||||
}; |
||||
|
||||
|
||||
})(); |
BIN
src/assets/node_modules/@notadd/neditor/dialogs/attachment/fileTypeImages/icon_chm.gif
generated
vendored
BIN
src/assets/node_modules/@notadd/neditor/dialogs/attachment/fileTypeImages/icon_chm.gif
generated
vendored
After Width: | Height: | Size: 923 B |
BIN
src/assets/node_modules/@notadd/neditor/dialogs/attachment/fileTypeImages/icon_default.png
generated
vendored
BIN
src/assets/node_modules/@notadd/neditor/dialogs/attachment/fileTypeImages/icon_default.png
generated
vendored
After Width: | Height: | Size: 841 B |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue