pull/1/head
parent
37a532ab31
commit
420c05bee4
@ -0,0 +1 @@ |
||||
<p>content-edit works!</p> |
@ -0,0 +1,15 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
|
||||
@Component({ |
||||
selector: 'app-content-edit', |
||||
templateUrl: './content-edit.component.html', |
||||
styleUrls: ['./content-edit.component.scss'] |
||||
}) |
||||
export class ContentEditComponent implements OnInit { |
||||
|
||||
constructor() { } |
||||
|
||||
ngOnInit(): void { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,178 @@ |
||||
<!--面包屑--> |
||||
<nz-breadcrumb> |
||||
<nz-breadcrumb-item> |
||||
内容管理 |
||||
</nz-breadcrumb-item> |
||||
<nz-breadcrumb-item> |
||||
内容发布 |
||||
</nz-breadcrumb-item> |
||||
</nz-breadcrumb> |
||||
|
||||
<!--条件搜索--> |
||||
<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">站内信标题</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<input formControlName="title" name="title" nz-input placeholder="请输入站内信标题!" nzSize="default"> |
||||
</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 class="width_input_chlid" nzShowSearch nzAllowClear nzPlaceHolder="请选择站内信类型" formControlName="type"> |
||||
<nz-option nzLabel="请选择站内信类型" nzValue=""></nz-option> |
||||
<nz-option nzLabel="服务通知" nzValue="1"></nz-option> |
||||
<nz-option nzLabel="支付信息" nzValue="2"></nz-option> |
||||
<nz-option nzLabel="客服信息" nzValue="3"></nz-option> |
||||
</nz-select> |
||||
</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 class="width_input_chlid" nzShowSearch nzAllowClear nzPlaceHolder="请选择跳转类型" formControlName="jumpType"> |
||||
<nz-option nzLabel="请选择跳转类型" nzValue=""></nz-option> |
||||
<nz-option nzLabel="订单详情" [nzValue]="1"></nz-option> |
||||
<nz-option nzLabel="外部链接" [nzValue]="2"></nz-option> |
||||
<nz-option nzLabel="内部链接" [nzValue]="3"></nz-option> |
||||
<nz-option nzLabel="客服信息" [nzValue]="4"></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" (click)="getAdd()" ><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="80px">序号</th> |
||||
<th nzWidth="100px">标题</th> |
||||
<th nzWidth="80px">类型</th> |
||||
<th nzWidth="80px">跳转类型</th> |
||||
<th nzWidth="80px">消息类型</th> |
||||
<th nzWidth="80px">内容</th> |
||||
<th nzWidth="80px">状态</th> |
||||
<th nzWidth="120px">创建时间</th> |
||||
<th nzRight="0px" nzAlign="left" nzWidth="100px">操作</th> |
||||
</tr> |
||||
</thead> |
||||
<tbody> |
||||
<tr *ngFor="let data of ajaxTable.data; let i = index"> |
||||
<td>{{i+1}}</td> |
||||
<td>{{data.title}}</td> |
||||
<td>{{data.type | msgType : 1 }}</td> |
||||
<td>{{data.jumpType | msgType : 2 }}</td> |
||||
<td>{{data.msgType | msgType : 3 }}</td> |
||||
<td>{{data.content}}</td> |
||||
<td>{{data.status == 1? '编辑中': '已发布'}}</td> |
||||
<td>{{data.createTime | date:'yyyy-MM-dd hh:mm:ss' }}</td> |
||||
<td nzRight class="table-td-operation"> |
||||
<a *ngIf="data.status == 1" nz-dropdown [nzDropdownMenu]="menu">更多操作<i nz-icon nzType="down"></i></a> |
||||
<nz-dropdown-menu #menu="nzDropdownMenu"> |
||||
<ul nz-menu nzSelectable> |
||||
<li nz-menu-item><a (click)="getEdit(data)">查看</a></li> |
||||
<li nz-menu-item><a (click)="getForbiddenUser(data.id)">发布</a></li> |
||||
</ul> |
||||
</nz-dropdown-menu> |
||||
</td> |
||||
</tbody> |
||||
</nz-table> |
||||
</div> |
||||
|
||||
|
||||
<nz-modal [(nzVisible)]="isVisible" nzTitle="编辑内容" nzWidth="700" [nzFooter]="modalFooter" (nzOnCancel)="isVisible = false"> |
||||
<form nz-form [formGroup]="validateForm" class="login-form"> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>内容标题</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入内容标题"> |
||||
<input nz-input formControlName="title" placeholder="请输入内容标题!" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" >类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入类型"> |
||||
<nz-select [nzDisabled]="editFlag" nzShowSearch nzAllowClear nzPlaceHolder="请选择类型" formControlName="type"> |
||||
<nz-option nzLabel="服务通知" [nzValue]="1"></nz-option> |
||||
<nz-option nzLabel="支付信息" [nzValue]="2"></nz-option> |
||||
<nz-option nzLabel="客服信息" [nzValue]="3"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
|
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" >跳转类型</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入跳转类型"> |
||||
<nz-select [nzDisabled]="editFlag" nzShowSearch nzAllowClear nzPlaceHolder="请选择跳转类型" formControlName="jumpType"> |
||||
<nz-option nzLabel="外部链接" [nzValue]="2"></nz-option> |
||||
<nz-option nzLabel="内部链接" [nzValue]="3"></nz-option> |
||||
<nz-option nzLabel="客服信息" [nzValue]="4"></nz-option> |
||||
</nz-select> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6" nzRequired>{{validateForm.value['jumpType'] == 4 ? '消息内容':'跳转路径'}}</nz-form-label> |
||||
<nz-form-control [nzSpan]="16" nzErrorTip="请输入{{validateForm.value['jumpType'] == 4 ? '消息内容':'跳转路径'}}"> |
||||
<input nz-input formControlName="content" placeholder="请输入{{validateForm.value['jumpType'] == 4 ? '消息内容':'跳转路径'}}!" /> |
||||
</nz-form-control> |
||||
</nz-form-item> |
||||
<nz-form-item> |
||||
<nz-form-label [nzSpan]="6">信息图片</nz-form-label> |
||||
<nz-form-control [nzSpan]="16"> |
||||
<nz-upload |
||||
nzAction="{{POST_URL}}/fileUpload/uploadfile" |
||||
nzListType="picture-card" |
||||
[(nzFileList)]="imgFile" |
||||
[nzShowButton]="imgFile.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> |
||||
</form> |
||||
<ng-template #modalFooter> |
||||
<button nz-button nzType="default" (click)="isVisible = false">取消</button> |
||||
<button *ngIf="!editFlag" nz-button nzType="primary" (click)="handleOk()">提交</button> |
||||
</ng-template> |
||||
</nz-modal> |
@ -0,0 +1,180 @@ |
||||
import { Component, OnInit } from '@angular/core'; |
||||
import {environment} from '../../../../environments/environment'; |
||||
import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; |
||||
import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; |
||||
import {NzMessageService, NzUploadFile} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; |
||||
import {Router} from '_@angular_router@9.0.7@@angular/router'; |
||||
import {CommonsService} from '../../../services/commons.service'; |
||||
import {MsgService} from '../../../services/msg.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-system-msg', |
||||
templateUrl: './system-msg.component.html', |
||||
styleUrls: ['./system-msg.component.scss'] |
||||
}) |
||||
export class SystemMsgComponent implements OnInit { |
||||
|
||||
|
||||
WEB_SERVE_URL = environment.imageUrl; |
||||
POST_URL = environment.baseUrl; |
||||
searchForm: FormGroup; // 搜索框
|
||||
validateForm: FormGroup; // 添加框
|
||||
requestData = []; // 列表数据
|
||||
nodes = []; // 类型树
|
||||
total: number; // 页码
|
||||
pageNum = 1; // 页码
|
||||
pageSize = 10; // 条码
|
||||
loading = true; |
||||
editFlag = false; |
||||
isVisible = false; |
||||
imgFile = []; |
||||
previewImage: string | undefined = ''; |
||||
previewVisible = false; |
||||
id: number; |
||||
constructor( |
||||
private fb: FormBuilder, |
||||
private http: HttpClient, // http请求
|
||||
private message: NzMessageService, // 信息提示
|
||||
private router: Router, |
||||
private common: CommonsService, |
||||
private msg: MsgService |
||||
) { |
||||
this.WEB_SERVE_URL = environment.baseUrl; |
||||
} |
||||
|
||||
ngOnInit() { |
||||
|
||||
this.searchForm = this.fb.group({ |
||||
type: [null], |
||||
jumpType: [null], |
||||
title: [null], |
||||
}); |
||||
|
||||
this.validateForm = this.fb.group({ |
||||
type: [null, [Validators.required]], |
||||
title: [null, [Validators.required]], |
||||
jumpType: [null, [Validators.required]], |
||||
content: [null, [Validators.required]], |
||||
}); |
||||
|
||||
this.getRequest(true, this.searchForm.value); |
||||
|
||||
} |
||||
|
||||
|
||||
// 查询列表
|
||||
public getRequest(reset: boolean = false, whereObject: object) { |
||||
|
||||
if (reset) { |
||||
this.pageNum = 1; |
||||
} |
||||
whereObject['pageNum'] = this.pageNum; |
||||
whereObject['pageSize'] = this.pageSize; |
||||
this.msg.getMsgByList(whereObject, data => { |
||||
console.log(data); |
||||
this.loading = false; |
||||
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(); |
||||
} |
||||
|
||||
// 新增
|
||||
getAdd() { |
||||
this.isVisible = true; |
||||
this.editFlag = false; |
||||
} |
||||
|
||||
// 编辑
|
||||
getEdit(data: object) { |
||||
console.log(data); |
||||
if (data['image'] != null && data['image'] !== '') { |
||||
const logo = String(data['image']); |
||||
const logoArray = []; |
||||
logoArray.push( |
||||
{ |
||||
uid: 1, |
||||
name: logo, |
||||
status: 'done', |
||||
url: environment.imageUrl + logo |
||||
}); |
||||
this.imgFile = logoArray; |
||||
} |
||||
this.id = data['id']; |
||||
this.validateForm.patchValue(data); |
||||
this.editFlag = true; |
||||
this.isVisible = true; |
||||
} |
||||
|
||||
// 提交内容
|
||||
handleOk() { |
||||
// 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.imgFile.length !== 0) { |
||||
if (this.imgFile[0]['response'] != null) { |
||||
this.validateForm.value.image = this.imgFile[0]['response']['return_data'][0]; |
||||
} else { |
||||
this.validateForm.value.image = this.imgFile[0].name; |
||||
} |
||||
} |
||||
this.msg.insertMsg(this.validateForm.value , data => { |
||||
if (data['return_code'] === '000000') { |
||||
this.isVisible = false; |
||||
this.getRequest(false, this.searchForm.value); |
||||
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 getForbiddenUser(id): void { |
||||
const message = '是否发布'; |
||||
this.common.showConfirm(message, data => { |
||||
if (data) { |
||||
this.msg.pushMsg(id, dataUser => { |
||||
if (dataUser['return_code'] === '000000') { |
||||
this.message.success(dataUser['return_data']); |
||||
} else { |
||||
this.message.error(dataUser['return_msg']); |
||||
} |
||||
this.getRequest(false , this.searchForm.value); |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,18 @@ |
||||
import { Pipe, PipeTransform } from '@angular/core'; |
||||
|
||||
@Pipe({ |
||||
name: 'msgType' |
||||
}) |
||||
export class MsgTypePipe implements PipeTransform { |
||||
|
||||
array = { |
||||
1: ['服务通知', '支付信息', '客服信息'], |
||||
2: ['订单详情' , '外部链接' , '内部链接' , '客服信息'], |
||||
3: ['个人信息' , '全局信息'] |
||||
}; |
||||
|
||||
transform(type: number , product: number): string { |
||||
return this.array[product][type - 1]; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,52 @@ |
||||
import { Injectable } from '@angular/core'; |
||||
import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; |
||||
import {CommonsService} from './commons.service'; |
||||
import {environment} from '../../environments/environment'; |
||||
|
||||
@Injectable({ |
||||
providedIn: 'root' |
||||
}) |
||||
export class MsgService { |
||||
|
||||
constructor( |
||||
private http: HttpClient, |
||||
private common: CommonsService |
||||
) { } |
||||
|
||||
/** |
||||
* 查询站内信消息 |
||||
* |
||||
* @param paramsObject 对象 |
||||
* @param callBack 回调 |
||||
*/ |
||||
public getMsgByList(paramsObject: object, callBack) { |
||||
this.http.get(environment.baseUrl + 'bsMsg/getMsgByList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 新增站内信内容内容 |
||||
* |
||||
* @param params 上传对象 |
||||
* @param callBack 回调 |
||||
* @return data 返回结果 |
||||
*/ |
||||
public insertMsg(params: object, callBack) { |
||||
this.http.post(environment.baseUrl + 'bsMsg/insertMsg', params).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 发布站内信 |
||||
* |
||||
* @param iId id |
||||
* @param callBack 回调 |
||||
*/ |
||||
public pushMsg(id: number, callBack) { |
||||
this.http.get(environment.baseUrl + 'bsMsg/pushMsg?id=' + id).subscribe(data => { |
||||
callBack(data); |
||||
}); |
||||
} |
||||
} |
Loading…
Reference in new issue