pull/1/head
袁野 2 years ago
parent 5cf885e928
commit 84a57f36fb
  1. 149
      src/app/admin/cms/cms-content-edit/cms-content-edit.component.html
  2. 22
      src/app/admin/cms/cms-content-edit/cms-content-edit.component.less
  3. 176
      src/app/admin/cms/cms-content-edit/cms-content-edit.component.ts
  4. 436
      src/app/admin/cms/cms-content/cms-content.component.html
  5. 27
      src/app/admin/cms/cms-content/cms-content.component.less
  6. 670
      src/app/admin/cms/cms-content/cms-content.component.ts
  7. 2
      src/app/admin/cms/cms-routing.module.ts
  8. 4
      src/app/admin/cms/cms.module.ts
  9. 1
      src/app/admin/cms/content-edit/content-edit.component.html
  10. 0
      src/app/admin/cms/content-edit/content-edit.component.scss
  11. 15
      src/app/admin/cms/content-edit/content-edit.component.ts
  12. 2
      src/environments/environment.ts

@ -1,149 +0,0 @@
<nz-breadcrumb style="margin:12px 0;">
<nz-breadcrumb-item>内容管理</nz-breadcrumb-item>
<nz-breadcrumb-item>修改内容</nz-breadcrumb-item>
</nz-breadcrumb>
<div class="inner-content">
<nz-form-item nzFlex>
<nz-form-label nzFor="category" nzRequired>内容分类</nz-form-label>
<nz-form-control>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-tree-select
style="width: 250px"
[nzNodes]="nodes"
nzShowSearch
nzPlaceHolder="请选择内容分类"
[(ngModel)]="cmsContentView.categoryId"
>
</nz-tree-select>
</nz-form-control>
</nz-form-control>
</nz-form-item>
<form nz-form [formGroup]="validateForm" class="ant-advanced-search-form">
<!--标题-->
<nz-form-item nzFlex>
<nz-form-label nzFor="title" nzRequired>
<span>内容标题<i nz-icon nz-tooltip nzTitle="内容标题" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="title" [(ngModel)]="cmsContentView.title" placeholder="请输入内容标题..." />
<!--<nz-form-explain *ngIf="validateForm.get('title')?.dirty && validateForm.get('title')?.errors">请输入内容标题!</nz-form-explain>-->
</nz-form-control>
</nz-form-item>
<!--简要描述-->
<nz-form-item nzFlex>
<nz-form-label nzFor="description" nzRequired>
<span>简要描述<i nz-icon nz-tooltip nzTitle="简要描述" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="description" [(ngModel)]="cmsContentView.description" placeholder="请输入简要描述..." />
<!--<nz-form-explain *ngIf="validateForm.get('description')?.dirty && validateForm.get('description')?.errors">请输入简要描述!</nz-form-explain>-->
</nz-form-control>
</nz-form-item>
<!--跳转链接-->
<nz-form-item nzFlex>
<nz-form-label>
<span>展示平台</span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择展示平台" [(ngModel)]="cmsContentView.jumpType" formControlName="jumpType">
<nz-option nzLabel="微信小程序" [nzValue]="1"></nz-option>
<nz-option nzLabel="H5" [nzValue]="2"></nz-option>
<nz-option nzLabel="银联小程序" [nzValue]="3"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<!--跳转链接-->
<nz-form-item nzFlex>
<nz-form-label>
<span>跳转类型</span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select nzShowSearch nzAllowClear nzPlaceHolder="请选择跳转类型" [(ngModel)]="cmsContentView.jumpType" formControlName="jumpType">
<nz-option nzLabel="外链" nzValue="1"></nz-option>
<nz-option nzLabel="内链" nzValue="2"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<!--跳转链接-->
<nz-form-item nzFlex>
<nz-form-label>
<span>跳转链接</span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="ext1" [(ngModel)]="cmsContentView.jumpUrl" placeholder="请输入跳转链接(轮播图必填)" />
</nz-form-control>
</nz-form-item>
<!--封面图片-->
<nz-form-item nzFlex>
<nz-form-label nzFor="listImg">封面图片</nz-form-label>
<nz-form-control>
<nz-upload
class="avatar-uploader"
nzAction="{{WEB_SERVE_URL}}/fileUpload/uploadfile"
nzName="avatar"
nzListType="picture-card"
[nzShowUploadList]="false"
(nzChange)="handleChange($event)"
nzAccept="image/*"
>
<ng-container *ngIf="!listImg">
<i class="upload-icon" nz-icon [nzType]="loadingImg ? 'loading' : 'plus'"></i>
<div class="ant-upload-text">上传图片</div>
</ng-container>
<img *ngIf="listImg" [src]=" FILE_URL + listImg" class="avatar" />
</nz-upload>
</nz-form-control>
</nz-form-item>
<!--优先级-->
<nz-form-item nzFlex>
<nz-form-label nzFor="sortId" nzRequired>
<span>优先级<i nz-icon nz-tooltip nzTitle="优先级" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input type="number" formControlName="sortId" [(ngModel)]="cmsContentView.sortId" placeholder="请输入优先级,越小越靠前..." oninput="if(value.length>5) value=value.slice(0,5)"/>
<!--<nz-form-explain *ngIf="validateForm.get('sortId')?.dirty && validateForm.get('sortId')?.errors">请输入优先级!</nz-form-explain>-->
</nz-form-control>
</nz-form-item>
<!--标签-->
<nz-form-item nzFlex>
<nz-form-label nzFor="tag">
<span>标签<i nz-icon nz-tooltip nzTitle="标签" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input formControlName="tag" [(ngModel)]="cmsContentView.tag" placeholder="请输入标签..." />
</nz-form-control>
</nz-form-item>
<!--是否推荐-->
<nz-form-item nzFlex>
<nz-form-label nzFor="recommend" >
<span>是否推荐</span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-switch formControlName="recommend" [(ngModel)]="cmsContentView.recommend" nzCheckedChildren="是" nzUnCheckedChildren="否"></nz-switch>
</nz-form-control>
</nz-form-item>
<!--富文本-->
<nz-form-label nzFor="content">
<span>内容<i nz-icon nz-tooltip nzTitle="相册、图集、视频集等可不填写内容" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label>
<nz-form-item>
<ngx-neditor formControlName="content" [(ngModel)]="cmsContentView.content" #neditor [config]="config"></ngx-neditor>
</nz-form-item>
<div nz-row>
<div nz-col [nzSpan]="24" class="search-area">
<button nz-button [nzType]="'primary'" (click)="handleOk(validateForm.value)">提交</button>
<button nz-button (click)="getBack()">取消</button>
</div>
</div>
</form>
</div>

@ -1,22 +0,0 @@
.ment {
margin-top: 10px;
background: #e8e8e8;
height: 40px;
width: 100%;
}
.ment_left {
width: 4px;
height: 40px;
float: left;
background: #00a0e9;
}
.ment_title {
width: 100px;
height: 40px;
line-height:40px;
font-size: 18px;
}
button {
margin-left: 8px;
}

@ -1,176 +0,0 @@
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {HttpClient, HttpEvent, HttpEventType, HttpRequest, HttpResponse} from '@angular/common/http';
import {NzMessageService, NzModalService, UploadXHRArgs} from 'ng-zorro-antd';
import {ActivatedRoute, Router} from '@angular/router';
import {environment} from '../../../../environments/environment';
@Component({
selector: 'app-cms-content-edit',
templateUrl: './cms-content-edit.component.html',
styleUrls: ['./cms-content-edit.component.less']
})
export class CmsContentEditComponent implements OnInit {
config: any = {
initialFrameHeight: 400,
};
// 详情id
id;
cmsContentView: any = {};
// 定义表单
validateForm: FormGroup;
// 定义路径
WEB_SERVE_URL;
// 定义回调路径
FILE_URL;
nodes = [];
// 列表图片上传等待
loadingImg = false;
// 列表图片
listImg = null;
constructor(
private activatedRoute: ActivatedRoute,
private fb: FormBuilder, // 表单
private http: HttpClient, // http请求
private message: NzMessageService, // 信息提示
) {
this.WEB_SERVE_URL = environment.baseUrl;
this.FILE_URL = environment.imageUrl;
activatedRoute.queryParams.subscribe(queryParams => {
this.id = queryParams.id;
this.findContentView(queryParams.id);
});
}
ngOnInit() {
// 判断表单
this.validateForm = this.fb.group({
title: [null, [Validators.required]],
recommend: [null],
description: [null, [Validators.required]],
ext1: [null],
jumpType: [null],
sortId: [null, [Validators.required]],
content: [null],
tag: [null],
});
// 获取登录人 角色类型,查询分类树
let roleType = 1;
/* if (0 === this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
roleType = 1; // 运营平台
} else if (1 === this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
if (this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['isService'] === true) {
roleType = 3; // 服务机构
} else {
roleType = 2; // 普通企业
}
} else if (2 === this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
roleType = 3; // 司法局
} else if (3 == this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
roleType = 4; // 行政部门
}*/
this.findCategoryTree(roleType);
}
// 查询内容详情
findContentView(id) {
this.http.get(this.WEB_SERVE_URL + '/cmsContent/getContentById?id=' + id).subscribe(data => {
if (data['return_code'] === '000000') {
data['return_data'].jumpType = String(data['return_data'].jumpType);
this.cmsContentView = data['return_data'];
this.listImg = data['return_data'].imgData;
} else {
this.message.create('error', data['return_msg']);
}
});
}
// 查询分类树
findCategoryTree(roleType) {
this.http.get(this.WEB_SERVE_URL + '/cmsCategory/getOwnCategoryTree?roleType=' + roleType).subscribe(data => {
if (data['return_code'] === '000000') {
this.nodes = data['return_data'];
if (this.nodes.length !== 0) {
this.generateComment(this.nodes);
} else {
this.nodes = [];
}
} else {
this.message.create('error', data['return_msg']);
}
});
}
// 递归分类树
generateComment(data) {
for (const i in data) {
if (data[i].nodes == null) {
const item = {
isLeaf: true,
title: data[i].text,
key: data[i].id,
children: data[i].nodes,
};
data[i] = item;
} else {
const item = {
isLeaf: false,
title: data[i].text,
key: data[i].id,
children: data[i].nodes,
};
data[i] = item;
this.generateComment(data[i].children);
}
}
this.nodes = data;
}
// 返回
getBack() {
history.back();
}
// 上传封面图片
handleChange(info: any): void {
this.loadingImg = true;
if (info.file.response == null) {
return;
}
this.loadingImg = false;
if (info.file.response['return_code'] === '000000') {
this.listImg = info.file.response['return_data'].join('');
this.cmsContentView.imgData = this.listImg;
} else {
this.message.create('error', `上传失败!`);
}
}
// 修改保存内容
handleOk(value: any): void {
// 校验必填
if (this.cmsContentView.categoryId == null || this.cmsContentView.categoryId === '') {
this.message.create('error', `请选择分类!`);
return;
}
if (this.cmsContentView.title == null || this.cmsContentView.title === '') {
this.message.create('error', `请填写内容标题!`);
return;
}
if (this.cmsContentView.description == null || this.cmsContentView.description === '') {
this.message.create('error', `请填写简要描述!`);
return;
}
/* if (this.cmsContentView.imgData == null || this.cmsContentView.imgData == '') {
this.message.create('error', `请上传封面!`);
return;
}*/
if (this.cmsContentView.sortId == null || this.cmsContentView.sortId === '') {
this.message.create('error', `请填写内容排序,越小越靠前!`);
return;
}
this.http.post(this.WEB_SERVE_URL + '/cmsContent/updateContent', this.cmsContentView).subscribe(data => {
if (data['return_code'] === '000000') {
this.getBack();
this.message.create('success', `修改成功!`);
} else {
this.message.create('warning', data['return_msg']);
}
}, error => {
this.message.create('error', `未知错误!`);
});
}
}

@ -8,221 +8,231 @@
</nz-breadcrumb-item> </nz-breadcrumb-item>
</nz-breadcrumb> </nz-breadcrumb>
<div class="inner-content" nz-row>
<!--条件搜索--> <!--条件搜索-->
<div style="margin-bottom: 24px; margin-top: 24px;"> <div class="inner-content">
<!--分类--> <form (ngSubmit)="getRequest(true , searchForm.value)" [formGroup]="searchForm" nz-form>
<nz-tree-select <div nz-row>
nzPlaceHolder="请选择分类" <div nz-col nzSpan="8">
style="width: 250px" <nz-form-item>
[nzNodes]="nodes" <nz-form-label [nzSpan]="6">内容分类</nz-form-label>
nzShowSearch <nz-form-control [nzSpan]="16">
nzPlaceHolder="请选择内容分类" <nz-tree-select
[(ngModel)]="searchCategoryId" [nzNodes]="nodes"
> formControlName="categoryId"
</nz-tree-select> nzPlaceHolder="请选择内容分类"
<input class="width_input_chlid" [(ngModel)]="searchTitle" name="searchTitle" nz-input placeholder="请输入内容标题" nzSize="default"> nzShowSearch
<nz-select class="width_input_chlid" nzShowSearch nzAllowClear nzPlaceHolder="请选择状态" [(ngModel)]="searchStatus"> >
<nz-option nzLabel="请选择状态" nzValue=""></nz-option> </nz-tree-select>
<nz-option nzLabel="编辑中" nzValue="1"></nz-option> </nz-form-control>
<nz-option nzLabel="已发布" nzValue="2"></nz-option> </nz-form-item>
<!--<nz-option nzLabel="已下线" nzValue="3"></nz-option>--> </div>
</nz-select> <div nz-col nzSpan="8">
<button style="margin-left: 10px;" nz-button nzType="primary" (click)="getSearch()" [nzLoading]="isLoadingSearch">搜索</button> <nz-form-item>
<button nz-button (click)="resetSearch()">重置</button> <nz-form-label [nzSpan]="6">内容标题</nz-form-label>
<nz-form-control [nzSpan]="16">
<input formControlName="title" name="title" nz-input nzSize="default" placeholder="请输入内容标题">
</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" formControlName="status" nzAllowClear nzPlaceHolder="请选择状态"
nzShowSearch>
<nz-option nzLabel="请选择状态" nzValue=""></nz-option>
<nz-option nzLabel="编辑中" nzValue="1"></nz-option>
<nz-option nzLabel="已发布" nzValue="2"></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" formControlName="platform" nzAllowClear nzPlaceHolder="请选择展示平台"
nzShowSearch>
<nz-option nzLabel="请选择展示平台" nzValue=""></nz-option>
<nz-option [nzValue]="1" nzLabel="微信小程序"></nz-option>
<nz-option [nzValue]="2" nzLabel="H5"></nz-option>
<nz-option [nzValue]="3" nzLabel="银联小程序"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row>
<div class="search-button" nz-col nzSpan="24">
<button nz-button nzType="primary"><i nz-icon nzTheme="outline" nzType="search"></i>搜索</button>
<button (click)="resetForm()" nz-button nzType="default"><i nz-icon nzTheme="outline"
nzType="reload"></i>重置
</button>
</div>
</div>
</form>
</div> </div>
</div>
<div class="inner-content" nz-row> <div class="inner-content">
<nz-layout> <span>共计 {{total}} 条数据</span>
<nz-sider style="background: #ffffff;"><div class="gaopin-data-toalt" style="width: 300px;">共搜索到 {{total}} 条数据</div></nz-sider> <div class="operating-button">
<nz-content style="text-align: right;background: #ffffff;"> <button (click)="getAdd()" class="right-btn" nz-button nzType="primary"><i nz-icon nzTheme="outline"
<button *ngIf="BTN_cmscontent_add == 1" class="funcBnt" nz-button nzType="primary" (click)="getAdd()">添加</button> nzType="plus"></i>添加
</nz-content> </button>
</nz-layout> </div>
<!--数组表格 -->
<nz-table <!--数组表格 -->
style="margin-top: 30px;width: 100%;" <nz-table
#ajaxTable #ajaxTable
nzShowSizeChanger (nzPageIndexChange)="getRequest(false , searchForm.value)"
[nzFrontPagination]="false" (nzPageSizeChange)="getRequest(false , searchForm.value)"
[nzData]="requestData" [(nzPageIndex)]="pageNum"
[nzLoading]="loading" [(nzPageSize)]="pageSize"
[nzTotal]="total" [nzData]="requestData"
[(nzPageIndex)]="pageIndex" [nzFrontPagination]="false"
[(nzPageSize)]="pageSize" nzBordered
(nzPageIndexChange)="getRequest()" [nzLoading]="loading"
(nzPageSizeChange)="getRequest(true)" [nzScroll]="{ x: '1200px' }"
[nzScroll]="{ x: '1150px'}"> [nzTotal]="total"
<thead nzSingleSort> class="table"
<tr> nzShowSizeChanger>
<th nzWidth="80px">序号</th> <thead nzSingleSort>
<th nzWidth="240px">分类名称</th>
<th nzWidth="240px">内容标题</th> <tr>
<th nzWidth="300px">简要描述</th> <th nzWidth="100px">分类名称</th>
<th nzWidth="120px">访问总量</th> <th nzWidth="100px">内容标题</th>
<th nzWidth="120px">是否推荐</th> <th nzWidth="80px">展示平台</th>
<th nzWidth="120px">状态</th> <th nzWidth="80px">状态</th>
<th nzWidth="120px">创建时间</th> <th nzWidth="120px">创建时间</th>
<th nzRight="0px" nzAlign="left" nzWidth="300px">操作</th> <th nzAlign="left" nzRight="0px" nzWidth="100px">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of ajaxTable.data; let i = index;"> <tr *ngFor="let data of ajaxTable.data; let i = index">
<td>{{i+ 1}}</td> <td>{{data.tag}}</td>
<td>{{data.categoryName}}</td> <td>{{data.title}}</td>
<td>{{data.title}}</td> <td>{{data.platform | showType}}</td>
<td>{{data.description}}</td> <td>
<td>{{data.visitCount}}</td> {{data.status == 1 ? '编辑中' : '已发布'}}
<td> </td>
<span style="color: #1890ff;" *ngIf="data.recommend"></span> <td>{{data.createTime | date:'yyyy-MM-dd' }}</td>
<span style="color: darkgray;" *ngIf="!data.recommend"></span> <td class="table-td-operation" nzRight>
</td> <a [nzDropdownMenu]="menu" nz-dropdown>更多操作<i nz-icon nzType="down"></i></a>
<td> <nz-dropdown-menu #menu="nzDropdownMenu">
<span *ngIf="data.status == 1">编辑中</span> <ul nz-menu nzSelectable>
<span *ngIf="data.status == 2">已发布</span> <li *ngIf="data.status == 1 && 'BTN_cmscontent_edit' | button" nz-menu-item><a
</td> (click)="getEdit(data)">编辑</a></li>
<td>{{data.createTime | date:'yyyy-MM-dd' }}</td> <li *ngIf="'BTN_cmscontent_up_down' | button" nz-menu-item><a
<td nzRight="0px" style="font-size: 16px;"> (click)='getForbiddenUser(data.id , data.status)'>{{data.status === 2 ? '下架' : '上架'}}</a>
<a><span nz-tooltip nzTitle="详情" (click)='getContentView(data.id)'><i nz-icon nzType="unordered-list" nzTheme="outline"></i></span></a> </li>
<span *ngIf="BTN_cmscontent_edit"> <li *ngIf="data.status == 1 && 'BTN_cmscontent_delete' | button" nz-menu-item><a
<nz-divider nzType="vertical"></nz-divider> (click)='showDeleteConfirmDelete(data.id)'>删除</a></li>
<a *ngIf="data.status == 1"><span nz-tooltip nzTitle="编辑" (click)='getEdit(data.id)'><i nz-icon nzType="edit" nzTheme="outline"></i></span></a> </ul>
</span> </nz-dropdown-menu>
<span *ngIf="BTN_cmscontent_up_down == 1"> </td>
<nz-divider *ngIf="data.status == 1" nzType="vertical"></nz-divider> </tr>
<a *ngIf="data.status == 2"><span nz-tooltip nzTitle="下线" (click)='showDown(data.id)'><i nz-icon nzType="down-square" nzTheme="outline"></i></span></a> </tbody>
<a *ngIf="data.status == 1"><span nz-tooltip nzTitle="发布" (click)='addPush(data.id, data.categoryId)'><i nz-icon nzType="up-square" nzTheme="outline"></i></span></a> </nz-table>
</span>
<span *ngIf="BTN_cmscontent_delete == 1"> </div>
<nz-divider *ngIf="data.status == 1" nzType="vertical"></nz-divider> <!--添加附件弹出层-->
<a *ngIf="data.status == 1"><span nz-tooltip nzTitle="删除" (click)='showDeleteConfirmDelete(data.id)'><i nz-icon nzType="delete" nzTheme="outline"></i></span></a> <nz-modal (nzOnCancel)="isVisible = false" (nzOnOk)="handleOk()" [(nzVisible)]="isVisible" nzTitle="编辑内容"
</span> nzWidth="700">
<span *ngIf="BTN_cmscontent_patch == 1"> <form [formGroup]="validateForm" class="login-form" nz-form>
<nz-divider *ngIf="data.status == 1" nzType="vertical"></nz-divider>
<a *ngIf="data.status == 1"><span nz-tooltip nzTitle="附件" (click)='findPatchByContent(data.id)'><i nz-icon nzType="file" nzTheme="outline"></i></span></a> <nz-form-item>
</span> <nz-form-label [nzSpan]="6" nzRequired>分类</nz-form-label>
</td> <nz-form-control [nzSpan]="16" nzErrorTip="内容分类">
</tr> <nz-tree-select
</tbody> [nzNodes]="nodes"
</nz-table> formControlName="categoryId"
<nz-layout *ngIf="showPatch == 1" style="margin-bottom: 10px;"> nzPlaceHolder="请选择内容分类"
<nz-content style="text-align: right;background: #ffffff;"> nzShowSearch
<button class="funcBnt" nz-button nzType="primary" (click)="addPatch()">添加附件</button> style="width: 250px"
</nz-content> >
</nz-layout> </nz-tree-select>
<nz-table style="width: 100%" [nzShowPagination]="false" #basicTable [nzData]="patchList" *ngIf="showPatch == 1"> </nz-form-control>
<thead> </nz-form-item>
<tr>
<th>附件名称</th> <nz-form-item>
<th>附件类型</th> <nz-form-label [nzSpan]="6" nzRequired>内容标题</nz-form-label>
<th>附件描述</th> <nz-form-control [nzSpan]="16" nzErrorTip="请输入内容标题">
<th>排序</th> <input formControlName="title" nz-input placeholder="请输入内容标题!"/>
<th>添加时间</th> </nz-form-control>
<th>操作</th> </nz-form-item>
</tr>
</thead> <nz-form-item>
<tbody> <nz-form-label [nzSpan]="6" nzRequired>展示平台</nz-form-label>
<tr *ngFor="let data of patchList"> <nz-form-control [nzSpan]="16" nzErrorTip="请选择展示平台">
<td>{{ data.patchName }}</td> <nz-select *ngIf="!editFlag" formControlName="platformArray" nzAllowClear nzMode="multiple" nzPlaceHolder="请选择展示平台"
<td *ngIf="data.patchType == 1">图片</td> nzShowSearch>
<td *ngIf="data.patchType == 2">音频</td> <nz-option [nzValue]="1" nzLabel="微信小程序"></nz-option>
<td *ngIf="data.patchType == 3">视频</td> <nz-option [nzValue]="2" nzLabel="H5"></nz-option>
<td *ngIf="data.patchType == 4">文档</td> <nz-option [nzValue]="3" nzLabel="银联小程序"></nz-option>
<td *ngIf="data.patchType == 5">其他</td> </nz-select>
<td>{{data.patchDesc}}</td> <nz-select *ngIf="editFlag" formControlName="platform" nzAllowClear nzPlaceHolder="请选择展示平台"
<td>{{data.sort}}</td> nzShowSearch>
<td>{{data.addTime | date:'yyyy-MM-dd'}}</td> <nz-option [nzValue]="1" nzLabel="微信小程序"></nz-option>
<td> <nz-option [nzValue]="2" nzLabel="H5"></nz-option>
<a><span nz-tooltip nzTitle="删除附件" (click)='showDeletePatch(data.id)'><i nz-icon nzType="delete" nzTheme="outline"></i></span></a> <nz-option [nzValue]="3" nzLabel="银联小程序"></nz-option>
</td> </nz-select>
</tr> </nz-form-control>
</tbody> </nz-form-item>
</nz-table>
</div> <nz-form-item>
<!--添加附件弹出层--> <nz-form-label [nzSpan]="6" nzRequired>优先级</nz-form-label>
<nz-modal [(nzVisible)]="isVisible" nzTitle="添加附件" (nzOnCancel)="handleCancel()" (nzOnOk)="handlePatchOk(annexForm.value)" [nzOkLoading]="isOkLoading"> <nz-form-control [nzSpan]="16" nzErrorTip="请输入优先级">
<form nz-form [formGroup]="annexForm" style="margin-left: 5%;"> <nz-input-number [nzMax]="100" [nzMin]="1" [nzStep]="1"
<!--附件名称--> formControlName="sortId" nzPlaceHolder="请输入优先级,越小越靠前..." style="width: 240px;"></nz-input-number>
<nz-form-item> </nz-form-control>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchName" nzRequired> </nz-form-item>
<span>附件名称<i nz-icon nz-tooltip nzTitle="附件名称" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label> <nz-form-item>
<nz-form-control [nzSm]="14" [nzXs]="24"> <nz-form-label [nzSpan]="6" nzRequired>内容描述</nz-form-label>
<input nz-input formControlName="patchName" placeholder="请输入附件名称..." /> <nz-form-control [nzSpan]="16" nzErrorTip="请输入内容描述">
<!--<nz-form-explain *ngIf="annexForm.get('patchName')?.dirty && annexForm.get('patchName')?.errors">请输入附件名称!</nz-form-explain>--> <input formControlName="description" nz-input placeholder="请输入内容描述!"/>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<!--附件描述--> <nz-form-item>
<nz-form-item> <nz-form-label [nzSpan]="6">跳转类型</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchDesc"> <nz-form-control [nzSpan]="16" nzErrorTip="请输入跳转类型">
<span>附件描述<i nz-icon nz-tooltip nzTitle="附件描述" type="question-circle" nzTheme="outline"></i></span> <nz-select formControlName="jumpType" nzAllowClear nzPlaceHolder="请选择跳转类型" nzShowSearch>
</nz-form-label> <nz-option [nzValue]="1" nzLabel="外链"></nz-option>
<nz-form-control [nzSm]="14" [nzXs]="24"> <nz-option [nzValue]="2" nzLabel="内链"></nz-option>
<input nz-input formControlName="patchDesc" placeholder="请输入附件描述..." />
<!--<nz-form-explain *ngIf="annexForm.get('patchDesc')?.dirty && annexForm.get('patchDesc')?.errors">请输入附件描述!</nz-form-explain>--> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<!--附件排序--> <nz-form-item>
<nz-form-item> <nz-form-label [nzSpan]="6">跳转路径</nz-form-label>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="sort" nzRequired> <nz-form-control [nzSpan]="16" nzErrorTip="请输入跳转路径">
<span>附件排序<i nz-icon nz-tooltip nzTitle="附件排序" type="question-circle" nzTheme="outline"></i></span> <input formControlName="jumpUrl" nz-input placeholder="请输入跳转链接(轮播图必填)"/>
</nz-form-label> </nz-form-control>
<nz-form-control [nzSm]="14" [nzXs]="24"> </nz-form-item>
<input nz-input type="number" formControlName="sort" placeholder="请输入附件排序,越小越靠前..." oninput="if(value.length>5) value=value.slice(0,5)"/> <nz-form-item>
<!--<nz-form-explain *ngIf="annexForm.get('sort')?.dirty && annexForm.get('sort')?.errors">请输入附件排序!</nz-form-explain>--> <nz-form-label [nzSpan]="6">封面图片</nz-form-label>
</nz-form-control> <nz-form-control [nzSpan]="16">
</nz-form-item> <nz-upload
<!--附件类型--> [(nzFileList)]="imgFile"
<nz-form-item > [nzPreview]="handlePreview"
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchType" nzRequired> [nzShowButton]="imgFile.length < 1"
<span>附件类型</span> nzAction="{{POST_URL}}/fileUpload/uploadfile"
</nz-form-label> nzListType="picture-card"
<nz-form-control [nzSm]="14" [nzXs]="24"> >
<nz-select style="width: 80%;" formControlName="patchType" (ngModelChange)="getChange($event)" nzShowSearch nzAllowClear nzPlaceHolder="请选择附件类型"> <i nz-icon nzType="plus"></i>
<nz-option nzLabel="图片" nzValue="1" ></nz-option> <div class="ant-upload-text">上传图片</div>
<nz-option nzLabel="音乐" nzValue="2" ></nz-option> </nz-upload>
<nz-option nzLabel="视频" nzValue="3" ></nz-option> <nz-modal (nzOnCancel)="previewVisible = false" [nzContent]="modalContent" [nzFooter]="null"
<nz-option nzLabel="文档" nzValue="4" ></nz-option> [nzVisible]="previewVisible">
<nz-option nzLabel="其他" nzValue="5" ></nz-option> <ng-template #modalContent>
</nz-select> <img [ngStyle]="{ width: '100%' }" [src]="previewImage"/>
</nz-form-control> </ng-template>
</nz-form-item> </nz-modal>
<!--附件上传--> </nz-form-control>
<nz-form-item *ngIf="patchTypeCheck != '0' && patchTypeCheck != null && patchTypeCheck != ''"> </nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchPath" nzRequired>
<span>附件上传<i nz-icon nz-tooltip nzTitle="附件上传" type="question-circle" nzTheme="outline"></i></span> </form>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-upload
nzAction="{{WEB_SERVE_URL}}/fileUpload/fileUpload"
[(nzFileList)]="fileList"
[nzCustomRequest]="customReq"
[nzShowButton]="fileList.length < 1"
>
<button nz-button ><i nz-icon nzType="upload"></i><span>点击上传</span></button>
</nz-upload>
</nz-form-control>
</nz-form-item>
<button nz-button id="reset" style="display: none;" (click)="emptyForm($event)">清空</button>
</form>
</nz-modal>
<!--发布弹出层-->
<nz-modal [(nzVisible)]="isPublish" nzTitle="发布内容" (nzOnCancel)="handleCancelPush()" (nzOnOk)="handlePushOk(pushForm.value)" [nzOkLoading]="isPushOkLoading">
<form nz-form [formGroup]="pushForm" style="margin-left: 5%;">
<!--附件名称-->
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="moduleId">
<span>发布模板<i nz-icon nz-tooltip nzTitle="发布模板" type="question-circle" nzTheme="outline"></i></span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select formControlName="moduleId" nzShowSearch nzAllowClear nzPlaceHolder="选择发布模板,也可不选择" [(ngModel)]="moduleId">
<nz-option *ngFor="let data of selectModule" nzLabel="{{data.moduleName}}" nzValue="{{data.id}}"></nz-option>
</nz-select>
<!--<input nz-input formControlName="moduleId" placeholder="请输入附件名称..." />-->
</nz-form-control>
</nz-form-item>
<button nz-button id="resetPush" style="display: none;" (click)="emptyPushForm($event)">清空</button>
</form>
</nz-modal> </nz-modal>

@ -1,27 +0,0 @@
.width_input {
width: 200px;
}
.width_input_chlid {
width: 200px;
margin-left: 10px;
}
[nz-form] {
max-width: 600px;
}
button {
margin-left: 8px;
}
:host ::ng-deep .upload-list-inline .ant-upload-list-item {
float: left;
width: 200px;
margin-right: 8px;
}
.search-result-list {
margin-top: 16px;
border: 1px dashed #e9e9e9;
border-radius: 6px;
background-color: #fafafa;
min-height: 200px;
text-align: center;
padding-top: 80px;
}

@ -1,11 +1,20 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {HttpClient, HttpEvent, HttpEventType, HttpRequest, HttpResponse} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {NzMessageService, NzModalService, UploadXHRArgs} from 'ng-zorro-antd'; import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {LocalStorageService} from '../../../services/local-storage.service';
import {ADMIN_INFO_OBJECT} from '../../../services/local-storage.namespace';
import {environment} from '../../../../environments/environment'; import {environment} from '../../../../environments/environment';
import {CmsService} from '../../../services/cms.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({ @Component({
@ -14,247 +23,90 @@ import {environment} from '../../../../environments/environment';
styleUrls: ['./cms-content.component.less'] styleUrls: ['./cms-content.component.less']
}) })
export class CmsContentComponent implements OnInit { export class CmsContentComponent implements OnInit {
// 搜索按钮等待特效
isLoadingSearch = false;
// 搜索内容标题
searchTitle = '';
// 状态搜索
searchStatus = '';
// 分类搜索
searchCategoryId = '';
// 公司id
searchCompanyId = '';
// 查询数组
requestData = [];
// 查询数组等待特效
loading = true;
// 请求页码
pageIndex = 1;
// 请求条数
pageSize = 10;
// 查询总条数
total = 0;
/** 分类树数据 **/
nodes = [];
WEB_SERVE_URL;
// 选中的内容id
contentSelect = '';
// 是否显示附件列表
showPatch = 0;
// 根据内容查询附件列表
patchList = [];
// 添加附件相关
// 提交等待 WEB_SERVE_URL = environment.imageUrl;
isOkLoading = false; POST_URL = environment.baseUrl;
// 附件类型 searchForm: FormGroup; // 搜索框
patchTypeCheck = '0'; validateForm: FormGroup; // 添加框
// 附件返回地址 requestData = []; // 列表数据
patchPath = ''; nodes = []; // 类型树
// 允许上传的文件类型 total: number; // 页码
annexForm: FormGroup; pageNum = 1; // 页码
/** 定义附件表单 **/ pageSize = 10; // 条码
loading = true;
editFlag = false;
isVisible = false; isVisible = false;
/** 是否弹出添加 **/ imgFile = [];
fileList = []; previewImage: string | undefined = '';
// 上传的后缀名 previewVisible = false;
suffix = ''; id: number;
// 允许上传的文件类型
imageSuffix = [
'jpg',
'jpeg',
'png',
'jif',
'dwg',
'dxf',
'jp2',
'jpe',
'svf',
'tif',
'tiff',
];
audioSuffix = [
'3gpp',
'ac3',
'mp2',
'mp3',
'asf',
'cda',
'wav',
'wma',
'mid',
'ra',
'rma',
'mod',
];
videoSuffix = [
'3gpp',
'mp2',
'mp4',
'mpeg',
'mpg',
'avi',
'rmvb',
'flv',
'3pg',
'rm',
'mov',
'wmv',
'mkv',
'f4v',
'm4v',
];
applicationSuffix = [
'asf',
'doc',
'dot',
'dtd',
'htm',
'html',
'css',
'csv',
'js',
'json',
'mpp',
'ogg',
'pdf',
'pot',
'pps',
'ppt',
'rtf',
'txt',
'wdb',
'wps',
'xhtml',
'xlc',
'xlm',
'xls',
'xlt',
'xlw',
'xml',
'zip',
'docx',
'xlsx',
'pptx',
'sql'
];
isPublish = false;
isPushOkLoading = false;
moduleId = '';
pushId = '';
pushForm: FormGroup;
// 可选择的模板列表
selectModule = [];
/** 按钮数据权限 **/
BTN_cmscontent_add = 0;
BTN_cmscontent_edit = 0;
BTN_cmscontent_delete = 0;
BTN_cmscontent_patch = 0;
BTN_cmscontent_up_down = 0;
constructor( constructor(
private fb: FormBuilder, private fb: FormBuilder,
private http: HttpClient, // http请求 private http: HttpClient, // http请求
private message: NzMessageService, // 信息提示 private message: NzMessageService, // 信息提示
private router: Router, private router: Router,
private modalService: NzModalService, // 对话框 private common: CommonsService,
private store: LocalStorageService, // 请求缓存 private cms: CmsService,
) { ) {
this.WEB_SERVE_URL = environment.baseUrl; this.WEB_SERVE_URL = environment.baseUrl;
this.searchCompanyId = this.store.get(ADMIN_INFO_OBJECT)['secUser']['companyId'];
} }
ngOnInit() { ngOnInit() {
/** 循环查询 按钮权限 **/
for (let i = 0; i < this.store.get(ADMIN_INFO_OBJECT)['buttonList'].length; i++) { this.searchForm = this.fb.group({
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_add') { title: [null],
this.BTN_cmscontent_add = 1; categoryId: [null],
} platform: [null],
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_edit') { status: [null],
this.BTN_cmscontent_edit = 1;
}
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_delete') {
this.BTN_cmscontent_delete = 1;
}
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_patch') {
this.BTN_cmscontent_patch = 1;
}
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_up_down') {
this.BTN_cmscontent_up_down = 1;
}
}
this.annexForm = this.fb.group({
patchName: [null, [Validators.required]],
patchDesc: [null],
patchType: [null, [Validators.required]],
sort: [null, [Validators.required]],
}); });
this.pushForm = this.fb.group({ this.validateForm = this.fb.group({
moduleId: [null] categoryId: [null, [Validators.required]],
title: [null, [Validators.required]],
platform: [null],
platformArray: [null],
sortId: [null, [Validators.required]],
description: [null, [Validators.required]],
jumpType: [null],
jumpUrl: [null],
}); });
const roleType = 1;
this.findCategoryTree(roleType);
this.getRequest(true, this.searchForm.value);
// 获取登录人 角色类型,查询分类树
console.log(this.store.get(ADMIN_INFO_OBJECT));
let roleType = 1;
/* if (0 == this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
roleType = 1;
} else if (1 == this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
if (this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['isService'] == true) {
roleType = 3;
} else {
roleType = 2;
}
} else if (2 == this.store.get(ADMIN_INFO_OBJECT)['bsCompany']['companyType']) {
roleType = 3;
}*/
this.findCategoryTree(roleType); this.findCategoryTree(roleType);
this.getRequest();
} }
// 重置搜索
resetSearch() {
// 搜索内容标题
this.searchTitle = '';
// 状态搜索
this.searchStatus = '';
// 分类搜索
this.searchCategoryId = '';
}
// 请求列表 // 查询列表
getRequest(reset: boolean = false) { public getRequest(reset: boolean = false, whereObject: object) {
this.showPatch = 0;
this.loading = false;
if (reset) { if (reset) {
this.pageIndex = 1; this.pageNum = 1;
}
if (this.searchStatus == null) {
this.searchStatus = '';
} }
if (this.searchCategoryId == null) { whereObject['pageNum'] = this.pageNum;
this.searchCategoryId = ''; whereObject['pageSize'] = this.pageSize;
} this.cms.getListContent(whereObject, data => {
this.http.get(this.WEB_SERVE_URL + '/cmsContent/getListContent?pageNum=' + this.pageIndex + '&pageSize=' + this.pageSize + '&title=' + this.searchTitle + '&category=' + this.searchCategoryId + '&status=' + this.searchStatus + '&companyId=' + this.searchCompanyId).subscribe(data => {
console.log(data); console.log(data);
this.loading = false;
if (data['return_code'] === '000000') { if (data['return_code'] === '000000') {
this.requestData = data['return_data'].list; this.requestData = data['return_data'].list;
this.total = data['return_data'].total; this.total = data['return_data'].total;
this.isLoadingSearch = false;
} else { } else {
this.message.create('error', data['return_msg']); this.message.error(data['return_msg']);
} }
}); });
} }
// 搜索 // 重置
getSearch() { public resetForm(): void {
this.getRequest(); this.searchForm.reset();
} }
// 查询分类树 // 查询分类树
findCategoryTree(roleType) { findCategoryTree(roleType) {
this.http.get(this.WEB_SERVE_URL + '/cmsCategory/getOwnCategoryTree?roleType=' + roleType).subscribe(data => { this.cms.getOwnCategoryTree(roleType, data => {
if (data['return_code'] === '000000') { if (data['return_code'] === '000000') {
this.nodes = data['return_data']; this.nodes = data['return_data'];
if (this.nodes.length !== 0) { if (this.nodes.length !== 0) {
@ -272,23 +124,19 @@ export class CmsContentComponent implements OnInit {
generateComment(data) { generateComment(data) {
for (const i in data) { for (const i in data) {
if (data[i].nodes == null) { if (data[i].nodes == null) {
const item = { data[i] = {
/** 重新赋值 **/
isLeaf: true, isLeaf: true,
title: data[i].text, title: data[i].text,
key: data[i].id, key: data[i].id,
children: data[i].nodes, children: data[i].nodes,
}; };
data[i] = item;
} else { } else {
const item = { data[i] = {
/** 重新赋值 **/
isLeaf: false, isLeaf: false,
title: data[i].text, title: data[i].text,
key: data[i].id, key: data[i].id,
children: data[i].nodes, children: data[i].nodes,
}; };
data[i] = item;
this.generateComment(data[i].children); this.generateComment(data[i].children);
} }
} }
@ -296,337 +144,115 @@ export class CmsContentComponent implements OnInit {
console.log(this.nodes); console.log(this.nodes);
} }
// 跳转添加 // 新增
getAdd() { getAdd() {
this.router.navigate(['/admin/cms/cmscontentadd'], {
queryParams: {
editFlag: 0
}
});
}
// 跳转修改
getEdit(id) {
this.router.navigate(['/admin/cms/cmscontentedit'], {
queryParams: {
id: id
}
});
}
// 跳转详情
getContentView(id) {
this.router.navigate(['/admin/cms/cmscontentview'], {
queryParams: {
id: id
}
});
}
// 对话框删除
showDeleteConfirmDelete(id): void {
this.modalService.confirm({
nzTitle: '是否确定删除',
nzOkText: '是',
nzOnOk: () => this.deleteContent(id),
nzCancelText: '否',
});
}
// 删除内容
deleteContent(id) {
if (id === undefined) {
return;
}
if (id === null) {
return;
}
if (id === '') {
return;
}
this.http.get(this.WEB_SERVE_URL + '/cmsContent/delContent?id=' + id).subscribe(data => {
if (data['return_code'] === '000000') {
this.message.create('success', `删除成功!`);
this.getRequest();
} else {
this.message.create('warning', data['return_msg']);
}
});
}
// 查询附件列表
findPatchByContent(id) {
this.contentSelect = id;
this.http.get(this.WEB_SERVE_URL + '/cmsContent/getListPatches?pageNum=1&pageSize=100&contentId=' + id).subscribe(data => {
if (data['return_code'] === '000000') {
this.showPatch = 1;
this.patchList = data['return_data'].list;
console.log(this.patchList);
} else {
this.message.create('warning', data['return_msg']);
}
});
}
// 弹出添加附件
addPatch() {
this.isVisible = true; this.isVisible = true;
this.editFlag = false;
} }
// 删除附件确认 // 编辑
showDeletePatch(id) { getEdit(data: object) {
this.modalService.confirm({ console.log(data);
nzTitle: '是否确定删除', if (data['imgData'] != null && data['imgData'] !== '') {
nzOkText: '是', const logo = String(data['imgData']);
nzOnOk: () => this.deletePatch(id), const logoArray = [];
nzCancelText: '否', logoArray.push(
}); {
} uid: 1,
name: logo,
// 删除附件 status: 'done',
deletePatch(id) { url: environment.imageUrl + logo
if (id === undefined || id === null || id === '') { });
return; this.imgFile = logoArray;
}
this.http.get(this.WEB_SERVE_URL + '/cmsPatch/delPatch?id=' + id).subscribe(data => {
if (data['return_code'] === '000000') {
this.message.create('success', `删除成功!`);
this.findPatchByContent(this.contentSelect);
} else {
this.message.create('warning', data['return_msg']);
}
});
}
// 取消按钮
handleCancel(): void {
this.isVisible = false;
this.patchPath = '';
this.fileList = [];
/** 隐藏弹框 **/
}
// 附件类型选择
getChange(event) {
if (event != null) {
this.patchTypeCheck = event;
console.log(event);
}
}
// 附件上传设置
customReq = (item: UploadXHRArgs) => {
this.patchPath = ''; // 置空路径
const formData = new FormData();
formData.append('requestFile', item.file as any);
formData.append('uploadType', 'cmsPatch');
console.log(item);
const req = new HttpRequest('POST', item.action!, formData, {
reportProgress: true,
});
console.log(req);
return this.http.request(req).subscribe(
(event: HttpEvent<any>) => {
console.log(event);
if (event.type === HttpEventType.UploadProgress) {
if (event.total! > 0) {
(event as any).percent = (event.loaded / event.total!) * 100;
}
item.onProgress!(event, item.file!);
} else if (event instanceof HttpResponse) {
item.onSuccess!(event.body, item.file!, event);
if (event.body.return_code === '000000') {
this.patchPath = event.body.return_data[item.file.name];
this.suffix = this.patchPath.split('.')[this.patchPath.split('.').length - 1];
}
}
},
err => {
item.onError!(err, item.file!);
}
);
}
/** 清空 **/
emptyForm(e: MouseEvent): void {
e.preventDefault();
this.annexForm.reset();
for (const key in this.annexForm.controls) {
this.annexForm.controls[key].markAsPristine();
this.annexForm.controls[key].updateValueAndValidity();
} }
this.id = data['id'];
this.validateForm.patchValue(data);
this.editFlag = true;
this.isVisible = true;
} }
// 附件弹窗确定添加按钮 // 提交内容
handlePatchOk(value: any): void { handleOk() {
// 校验类型选择与必填 // tslint:disable-next-line:forin
if (value.patchName == null || value.patchName == '') { for (const i in this.validateForm.controls) {
this.message.create('error', `请填写附件名称!`); this.validateForm.controls[i].markAsDirty();
return; this.validateForm.controls[i].updateValueAndValidity();
} if (this.validateForm.controls[i].errors != null) {
if (value.sort == null || value.sort == '') { this.message.error('必填项不能为空');
this.message.create('error', `请填写附件排序,越小越靠前!`);
return;
}
if (value.patchType == '1') {
if (this.imageSuffix.indexOf(this.suffix) == -1) {
this.message.create('error', `请上传图片类型的附件!`);
return;
}
} else if (value.patchType == '2') {
if (this.audioSuffix.indexOf(this.suffix) == -1) {
this.message.create('error', `请上传音频类型的附件!`);
return;
}
} else if (value.patchType == '3') {
if (this.videoSuffix.indexOf(this.suffix) == -1) {
this.message.create('error', `请上传视频类型的附件!`);
return; return;
} }
} else if (value.patchType == '4') {
if (this.applicationSuffix.indexOf(this.suffix) == -1) {
this.message.create('error', `请上传文档类型的附件!`);
return;
}
} else if (value.patchType == '5') {
} else {
this.message.create('error', `请选择附件类型!`);
return;
} }
if (this.patchPath == null || this.patchPath == '') { if (this.imgFile.length !== 0) {
this.message.create('error', `请上传附件!`); if (this.imgFile[0]['response'] != null) {
return; this.validateForm.value.imgData = this.imgFile[0]['response']['return_data'][0];
}
// 定义附件数据
const params = {
'contentId': this.contentSelect,
'patchName': value.patchName,
'patchDesc': value.patchDesc,
'patchType': value.patchType,
'patchPath': this.patchPath,
'source': 1,
'sort': value.sort,
'suffixName': this.suffix,
'addTime': new Date()
};
/** 确定等待 **/
this.http.post(this.WEB_SERVE_URL + '/cmsPatch/addPatch', params).subscribe(data => {
if (data['return_code'] === '000000') {
this.isVisible = false;
this.isOkLoading = false;
this.fileList = [];
this.patchTypeCheck = '0';
this.findPatchByContent(this.contentSelect);
this.message.create('success', `新增成功!`);
} else { } else {
this.message.create('warning', data['return_msg']); this.validateForm.value.imgData = this.imgFile[0].name;
} }
}, error => {
this.message.create('error', `未知错误!`);
});
}
// 弹出发布附件
addPush(id, categoryId) {
this.findModuleByCategory(categoryId);
this.pushId = id;
// document.getElementById('resetPush').click();
this.isPublish = true;
}
// 取消发布
handleCancelPush(): void {
this.isPublish = false;
this.moduleId = '';
this.pushId = '';
/** 隐藏弹框 **/
}
// 附件弹窗确定添加按钮
handlePushOk(value: any): void {
console.log('发布');
console.log(this.pushId);
console.log(this.moduleId);
console.log(value.moduleId);
if (this.pushId == null || this.pushId == '') {
this.message.create('error', '请重新选择发布的内容!');
return;
} }
if (this.moduleId == null || this.moduleId == undefined) { if (this.editFlag) {
this.moduleId = ''; this.validateForm.value.id = this.id;
this.cms.updateCmsContent(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', '修改失败');
}
});
} else {
this.cms.insertCmsContent(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', '修改失败');
}
});
} }
// 定义附件数据
const params = {
'id': this.pushId,
'status': 2,
'moduleId': this.moduleId
};
/** 确定等待 **/
this.http.post(this.WEB_SERVE_URL + '/cmsContent/updateStatusOfContent', params).subscribe(data => {
if (data['return_code'] === '000000') {
this.isPublish = false;
this.isPushOkLoading = false;
this.moduleId = '';
this.pushId = '';
this.getRequest();
this.message.create('success', `发布成功!`);
} else {
this.message.create('warning', data['return_msg']);
}
}, error => {
this.message.create('error', `未知错误!`);
});
} }
/** 清空模板 **/ // 图片查看
emptyPushForm(e: MouseEvent): void { handlePreview = async (file: NzUploadFile) => {
e.preventDefault(); if (!file.url && !file.preview) {
this.pushForm.reset(); // tslint:disable-next-line:no-non-null-assertion
for (const key in this.pushForm.controls) { file.preview = await getBase64(file.originFileObj!);
this.pushForm.controls[key].markAsPristine();
this.pushForm.controls[key].updateValueAndValidity();
} }
this.previewImage = file.url || file.preview;
this.previewVisible = true;
} }
// 根据内容分类查询可使用的模板列表 showDeleteConfirmDelete(id: number): void {
findModuleByCategory(categoryId) { this.common.showConfirm('是否确定删除!', dataR => {
this.http.get(this.WEB_SERVE_URL + '/cmsCategoryModule/getModuleByCategoryId?categoryId=' + categoryId).subscribe(data => { if (dataR) {
if (data['return_code'] === '000000') { this.cms.deleteById(id, data => {
this.selectModule = data['return_data']; if (data['return_code'] === '000000') {
console.log(this.selectModule); this.getRequest(true, this.searchForm.value);
} else { this.message.success(data['return_data']);
this.message.create('error', data['return_msg']); } else {
this.message.error(data['return_msg']);
}
});
} }
}); });
} }
showDown(id): void { public getForbiddenUser(id, status: any): void {
this.modalService.confirm({ const message = (status === 2 ? '是否下架当前内容' : '是否上架当前内容');
nzTitle: '是否确定下线', const s = status === 2 ? 1 : 2;
nzOkText: '是', this.common.showConfirm(message, data => {
nzOnOk: () => this.DownContent(id), if (data) {
nzCancelText: '否', this.cms.updateContentStatus(id, s, dataUser => {
}); if (dataUser['return_code'] === '000000') {
} this.message.success(dataUser['return_data']);
} else {
// 下线 this.message.error(dataUser['return_msg']);
DownContent(id) { }
// 定义附件数据 this.getRequest(false, this.searchForm.value);
const params = { });
'id': id,
'status': 1
};
/** 确定等待 **/
this.http.post(this.WEB_SERVE_URL + '/cmsContent/updateStatusOfContent', params).subscribe(data => {
if (data['return_code'] === '000000') {
this.getRequest();
this.message.create('success', `下线成功!`);
} else {
this.message.create('warning', data['return_msg']);
} }
}, error => {
this.message.create('error', `未知错误!`);
}); });
} }
} }

@ -4,7 +4,6 @@ import {CmsCategoryComponent} from './cms-category/cms-category.component';
import {CmsCategoryModuleComponent} from './cms-category-module/cms-category-module.component'; import {CmsCategoryModuleComponent} from './cms-category-module/cms-category-module.component';
import {CmsContentComponent} from './cms-content/cms-content.component'; import {CmsContentComponent} from './cms-content/cms-content.component';
import {CmsContentAddComponent} from './cms-content-add/cms-content-add.component'; import {CmsContentAddComponent} from './cms-content-add/cms-content-add.component';
import {CmsContentEditComponent} from './cms-content-edit/cms-content-edit.component';
import {CmsContentViewComponent} from './cms-content-view/cms-content-view.component'; import {CmsContentViewComponent} from './cms-content-view/cms-content-view.component';
@ -13,7 +12,6 @@ const routes: Routes = [
{path: 'cmscategorymodule', component: CmsCategoryModuleComponent}, {path: 'cmscategorymodule', component: CmsCategoryModuleComponent},
{path: 'cmscontent', component: CmsContentComponent}, {path: 'cmscontent', component: CmsContentComponent},
{path: 'cmscontentadd', component: CmsContentAddComponent}, {path: 'cmscontentadd', component: CmsContentAddComponent},
{path: 'cmscontentedit', component: CmsContentEditComponent},
{path: 'cmscontentview', component: CmsContentViewComponent} {path: 'cmscontentview', component: CmsContentViewComponent}
]; ];

@ -6,17 +6,15 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {NgZorroAntdModule} from 'ng-zorro-antd'; import {NgZorroAntdModule} from 'ng-zorro-antd';
import {NgxNeditorModule} from '@notadd/ngx-neditor'; import {NgxNeditorModule} from '@notadd/ngx-neditor';
import {CmsCategoryComponent} from './cms-category/cms-category.component'; import {CmsCategoryComponent} from './cms-category/cms-category.component';
import {CmsContentEditComponent} from './cms-content-edit/cms-content-edit.component';
import {CmsContentViewComponent} from './cms-content-view/cms-content-view.component'; import {CmsContentViewComponent} from './cms-content-view/cms-content-view.component';
import {CmsCategoryModuleComponent} from './cms-category-module/cms-category-module.component'; import {CmsCategoryModuleComponent} from './cms-category-module/cms-category-module.component';
import {CmsContentAddComponent} from './cms-content-add/cms-content-add.component'; import {CmsContentAddComponent} from './cms-content-add/cms-content-add.component';
import {CmsContentComponent} from './cms-content/cms-content.component'; import {CmsContentComponent} from './cms-content/cms-content.component';
import { ContentEditComponent } from './content-edit/content-edit.component';
import {AppCommonModule} from "../../app-common.module"; import {AppCommonModule} from "../../app-common.module";
@NgModule({ @NgModule({
declarations: [CmsCategoryComponent, CmsCategoryModuleComponent, CmsContentComponent, CmsContentAddComponent, CmsContentEditComponent, CmsContentViewComponent, ContentEditComponent], declarations: [CmsCategoryComponent, CmsCategoryModuleComponent, CmsContentComponent, CmsContentAddComponent, CmsContentViewComponent],
imports: [ imports: [
CommonModule, CommonModule,
CmsRoutingModule, CmsRoutingModule,

@ -1,15 +0,0 @@
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 {
}
}

@ -6,7 +6,7 @@ export const environment = {
production: false, production: false,
baseUrl: 'http://localhost:9302/brest/', // 测试环境服务器地址(请求数据地址) baseUrl: 'http://localhost:9302/brest/', // 测试环境服务器地址(请求数据地址)
// orderUrl: 'http://localhost:9304/order/', // orderUrl: 'http://localhost:9304/order/',
// imageUrl: 'https://hsgcs.dctpay.com/filesystem/', imageUrl: 'https://hsgcs.dctpay.com/filesystem/',
// baseUrl: 'https://hsgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) // baseUrl: 'https://hsgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址)
orderUrl: 'https://hsgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址) orderUrl: 'https://hsgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址)
// imageUrl: 'https://hsgcs.dctpay.com/filesystem/', // imageUrl: 'https://hsgcs.dctpay.com/filesystem/',

Loading…
Cancel
Save