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. 342
      src/app/admin/cms/cms-content/cms-content.component.html
  5. 27
      src/app/admin/cms/cms-content/cms-content.component.less
  6. 636
      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>
<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>
<div nz-row>
<div nz-col nzSpan="8">
<nz-form-item>
<nz-form-label [nzSpan]="6">内容分类</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-tree-select
nzPlaceHolder="请选择分类"
style="width: 250px"
[nzNodes]="nodes"
nzShowSearch
formControlName="categoryId"
nzPlaceHolder="请选择内容分类"
[(ngModel)]="searchCategoryId"
nzShowSearch
>
</nz-tree-select>
<input class="width_input_chlid" [(ngModel)]="searchTitle" name="searchTitle" nz-input placeholder="请输入内容标题" nzSize="default">
<nz-select class="width_input_chlid" nzShowSearch nzAllowClear nzPlaceHolder="请选择状态" [(ngModel)]="searchStatus">
</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">
<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-option nzLabel="已下线" nzValue="3"></nz-option>-->
</nz-select>
<button style="margin-left: 10px;" nz-button nzType="primary" (click)="getSearch()" [nzLoading]="isLoadingSearch">搜索</button>
<button nz-button (click)="resetSearch()">重置</button>
</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 class="inner-content">
<span>共计 {{total}} 条数据</span>
<div class="operating-button">
<button (click)="getAdd()" class="right-btn" nz-button nzType="primary"><i nz-icon nzTheme="outline"
nzType="plus"></i>添加
</button>
</div>
</div>
<div class="inner-content" nz-row>
<nz-layout>
<nz-sider style="background: #ffffff;"><div class="gaopin-data-toalt" style="width: 300px;">共搜索到 {{total}} 条数据</div></nz-sider>
<nz-content style="text-align: right;background: #ffffff;">
<button *ngIf="BTN_cmscontent_add == 1" class="funcBnt" nz-button nzType="primary" (click)="getAdd()">添加</button>
</nz-content>
</nz-layout>
<!--数组表格 -->
<nz-table
style="margin-top: 30px;width: 100%;"
#ajaxTable
nzShowSizeChanger
[nzFrontPagination]="false"
(nzPageIndexChange)="getRequest(false , searchForm.value)"
(nzPageSizeChange)="getRequest(false , searchForm.value)"
[(nzPageIndex)]="pageNum"
[(nzPageSize)]="pageSize"
[nzData]="requestData"
[nzFrontPagination]="false"
nzBordered
[nzLoading]="loading"
[nzScroll]="{ x: '1200px' }"
[nzTotal]="total"
[(nzPageIndex)]="pageIndex"
[(nzPageSize)]="pageSize"
(nzPageIndexChange)="getRequest()"
(nzPageSizeChange)="getRequest(true)"
[nzScroll]="{ x: '1150px'}">
class="table"
nzShowSizeChanger>
<thead nzSingleSort>
<tr>
<th nzWidth="80px">序号</th>
<th nzWidth="240px">分类名称</th>
<th nzWidth="240px">内容标题</th>
<th nzWidth="300px">简要描述</th>
<th nzWidth="120px">访问总量</th>
<th nzWidth="120px">是否推荐</th>
<th nzWidth="120px">状态</th>
<th nzWidth="100px">分类名称</th>
<th nzWidth="100px">内容标题</th>
<th nzWidth="80px">展示平台</th>
<th nzWidth="80px">状态</th>
<th nzWidth="120px">创建时间</th>
<th nzRight="0px" nzAlign="left" nzWidth="300px">操作</th>
<th nzAlign="left" nzRight="0px" nzWidth="100px">操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of ajaxTable.data; let i = index;">
<td>{{i+ 1}}</td>
<td>{{data.categoryName}}</td>
<tr *ngFor="let data of ajaxTable.data; let i = index">
<td>{{data.tag}}</td>
<td>{{data.title}}</td>
<td>{{data.description}}</td>
<td>{{data.visitCount}}</td>
<td>
<span style="color: #1890ff;" *ngIf="data.recommend"></span>
<span style="color: darkgray;" *ngIf="!data.recommend"></span>
</td>
<td>{{data.platform | showType}}</td>
<td>
<span *ngIf="data.status == 1">编辑中</span>
<span *ngIf="data.status == 2">已发布</span>
{{data.status == 1 ? '编辑中' : '已发布'}}
</td>
<td>{{data.createTime | date:'yyyy-MM-dd' }}</td>
<td nzRight="0px" style="font-size: 16px;">
<a><span nz-tooltip nzTitle="详情" (click)='getContentView(data.id)'><i nz-icon nzType="unordered-list" nzTheme="outline"></i></span></a>
<span *ngIf="BTN_cmscontent_edit">
<nz-divider nzType="vertical"></nz-divider>
<a *ngIf="data.status == 1"><span nz-tooltip nzTitle="编辑" (click)='getEdit(data.id)'><i nz-icon nzType="edit" nzTheme="outline"></i></span></a>
</span>
<span *ngIf="BTN_cmscontent_up_down == 1">
<nz-divider *ngIf="data.status == 1" nzType="vertical"></nz-divider>
<a *ngIf="data.status == 2"><span nz-tooltip nzTitle="下线" (click)='showDown(data.id)'><i nz-icon nzType="down-square" nzTheme="outline"></i></span></a>
<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>
</span>
<span *ngIf="BTN_cmscontent_delete == 1">
<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>
</span>
<span *ngIf="BTN_cmscontent_patch == 1">
<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>
</span>
<td class="table-td-operation" nzRight>
<a [nzDropdownMenu]="menu" nz-dropdown>更多操作<i nz-icon nzType="down"></i></a>
<nz-dropdown-menu #menu="nzDropdownMenu">
<ul nz-menu nzSelectable>
<li *ngIf="data.status == 1 && 'BTN_cmscontent_edit' | button" nz-menu-item><a
(click)="getEdit(data)">编辑</a></li>
<li *ngIf="'BTN_cmscontent_up_down' | button" nz-menu-item><a
(click)='getForbiddenUser(data.id , data.status)'>{{data.status === 2 ? '下架' : '上架'}}</a>
</li>
<li *ngIf="data.status == 1 && 'BTN_cmscontent_delete' | button" nz-menu-item><a
(click)='showDeleteConfirmDelete(data.id)'>删除</a></li>
</ul>
</nz-dropdown-menu>
</td>
</tr>
</tbody>
</nz-table>
<nz-layout *ngIf="showPatch == 1" style="margin-bottom: 10px;">
<nz-content style="text-align: right;background: #ffffff;">
<button class="funcBnt" nz-button nzType="primary" (click)="addPatch()">添加附件</button>
</nz-content>
</nz-layout>
<nz-table style="width: 100%" [nzShowPagination]="false" #basicTable [nzData]="patchList" *ngIf="showPatch == 1">
<thead>
<tr>
<th>附件名称</th>
<th>附件类型</th>
<th>附件描述</th>
<th>排序</th>
<th>添加时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of patchList">
<td>{{ data.patchName }}</td>
<td *ngIf="data.patchType == 1">图片</td>
<td *ngIf="data.patchType == 2">音频</td>
<td *ngIf="data.patchType == 3">视频</td>
<td *ngIf="data.patchType == 4">文档</td>
<td *ngIf="data.patchType == 5">其他</td>
<td>{{data.patchDesc}}</td>
<td>{{data.sort}}</td>
<td>{{data.addTime | date:'yyyy-MM-dd'}}</td>
<td>
<a><span nz-tooltip nzTitle="删除附件" (click)='showDeletePatch(data.id)'><i nz-icon nzType="delete" nzTheme="outline"></i></span></a>
</td>
</tr>
</tbody>
</nz-table>
</div>
<!--添加附件弹出层-->
<nz-modal [(nzVisible)]="isVisible" nzTitle="添加附件" (nzOnCancel)="handleCancel()" (nzOnOk)="handlePatchOk(annexForm.value)" [nzOkLoading]="isOkLoading">
<form nz-form [formGroup]="annexForm" style="margin-left: 5%;">
<!--附件名称-->
</div>
<!--添加附件弹出层-->
<nz-modal (nzOnCancel)="isVisible = false" (nzOnOk)="handleOk()" [(nzVisible)]="isVisible" nzTitle="编辑内容"
nzWidth="700">
<form [formGroup]="validateForm" class="login-form" nz-form>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchName" 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="patchName" placeholder="请输入附件名称..." />
<!--<nz-form-explain *ngIf="annexForm.get('patchName')?.dirty && annexForm.get('patchName')?.errors">请输入附件名称!</nz-form-explain>-->
<nz-form-label [nzSpan]="6" nzRequired>分类</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="内容分类">
<nz-tree-select
[nzNodes]="nodes"
formControlName="categoryId"
nzPlaceHolder="请选择内容分类"
nzShowSearch
style="width: 250px"
>
</nz-tree-select>
</nz-form-control>
</nz-form-item>
<!--附件描述-->
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchDesc">
<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="patchDesc" placeholder="请输入附件描述..." />
<!--<nz-form-explain *ngIf="annexForm.get('patchDesc')?.dirty && annexForm.get('patchDesc')?.errors">请输入附件描述!</nz-form-explain>-->
<nz-form-label [nzSpan]="6" nzRequired>内容标题</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请输入内容标题">
<input formControlName="title" nz-input placeholder="请输入内容标题!"/>
</nz-form-control>
</nz-form-item>
<!--附件排序-->
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="sort" 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="sort" placeholder="请输入附件排序,越小越靠前..." oninput="if(value.length>5) value=value.slice(0,5)"/>
<!--<nz-form-explain *ngIf="annexForm.get('sort')?.dirty && annexForm.get('sort')?.errors">请输入附件排序!</nz-form-explain>-->
<nz-form-label [nzSpan]="6" nzRequired>展示平台</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请选择展示平台">
<nz-select *ngIf="!editFlag" formControlName="platformArray" nzAllowClear nzMode="multiple" nzPlaceHolder="请选择展示平台"
nzShowSearch>
<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-select *ngIf="editFlag" formControlName="platform" nzAllowClear nzPlaceHolder="请选择展示平台"
nzShowSearch>
<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>
<!--附件类型-->
<nz-form-item >
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchType" nzRequired>
<span>附件类型</span>
</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select style="width: 80%;" formControlName="patchType" (ngModelChange)="getChange($event)" nzShowSearch nzAllowClear nzPlaceHolder="请选择附件类型">
<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-option nzLabel="其他" nzValue="5" ></nz-option>
</nz-select>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired>优先级</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请输入优先级">
<nz-input-number [nzMax]="100" [nzMin]="1" [nzStep]="1"
formControlName="sortId" nzPlaceHolder="请输入优先级,越小越靠前..." style="width: 240px;"></nz-input-number>
</nz-form-control>
</nz-form-item>
<!--附件上传-->
<nz-form-item *ngIf="patchTypeCheck != '0' && patchTypeCheck != null && patchTypeCheck != ''">
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="patchPath" 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">
<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-item>
<nz-form-label [nzSpan]="6" nzRequired>内容描述</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请输入内容描述">
<input formControlName="description" nz-input placeholder="请输入内容描述!"/>
</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-form-label [nzSpan]="6">跳转类型</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请输入跳转类型">
<nz-select formControlName="jumpType" nzAllowClear nzPlaceHolder="请选择跳转类型" nzShowSearch>
<nz-option [nzValue]="1" nzLabel="外链"></nz-option>
<nz-option [nzValue]="2" nzLabel="内链"></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>
<nz-form-item>
<nz-form-label [nzSpan]="6">跳转路径</nz-form-label>
<nz-form-control [nzSpan]="16" nzErrorTip="请输入跳转路径">
<input formControlName="jumpUrl" nz-input placeholder="请输入跳转链接(轮播图必填)"/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6">封面图片</nz-form-label>
<nz-form-control [nzSpan]="16">
<nz-upload
[(nzFileList)]="imgFile"
[nzPreview]="handlePreview"
[nzShowButton]="imgFile.length < 1"
nzAction="{{POST_URL}}/fileUpload/uploadfile"
nzListType="picture-card"
>
<i nz-icon nzType="plus"></i>
<div class="ant-upload-text">上传图片</div>
</nz-upload>
<nz-modal (nzOnCancel)="previewVisible = false" [nzContent]="modalContent" [nzFooter]="null"
[nzVisible]="previewVisible">
<ng-template #modalContent>
<img [ngStyle]="{ width: '100%' }" [src]="previewImage"/>
</ng-template>
</nz-modal>
</nz-form-control>
</nz-form-item>
</form>
</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 {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 {HttpClient} from '@angular/common/http';
import {NzMessageService, NzUploadFile} from 'ng-zorro-antd';
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 {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({
@ -14,247 +23,90 @@ import {environment} from '../../../../environments/environment';
styleUrls: ['./cms-content.component.less']
})
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 = [];
// 添加附件相关
// 提交等待
isOkLoading = false;
// 附件类型
patchTypeCheck = '0';
// 附件返回地址
patchPath = '';
// 允许上传的文件类型
annexForm: FormGroup;
/** 定义附件表单 **/
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;
/** 是否弹出添加 **/
fileList = [];
// 上传的后缀名
suffix = '';
// 允许上传的文件类型
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'
];
imgFile = [];
previewImage: string | undefined = '';
previewVisible = false;
id: number;
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(
private fb: FormBuilder,
private http: HttpClient, // http请求
private message: NzMessageService, // 信息提示
private router: Router,
private modalService: NzModalService, // 对话框
private store: LocalStorageService, // 请求缓存
private common: CommonsService,
private cms: CmsService,
) {
this.WEB_SERVE_URL = environment.baseUrl;
this.searchCompanyId = this.store.get(ADMIN_INFO_OBJECT)['secUser']['companyId'];
}
ngOnInit() {
/** 循环查询 按钮权限 **/
for (let i = 0; i < this.store.get(ADMIN_INFO_OBJECT)['buttonList'].length; i++) {
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_add') {
this.BTN_cmscontent_add = 1;
}
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_edit') {
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.searchForm = this.fb.group({
title: [null],
categoryId: [null],
platform: [null],
status: [null],
});
this.pushForm = this.fb.group({
moduleId: [null]
this.validateForm = this.fb.group({
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.getRequest();
}
// 重置搜索
resetSearch() {
// 搜索内容标题
this.searchTitle = '';
// 状态搜索
this.searchStatus = '';
// 分类搜索
this.searchCategoryId = '';
}
// 请求列表
getRequest(reset: boolean = false) {
this.showPatch = 0;
this.loading = false;
// 查询列表
public getRequest(reset: boolean = false, whereObject: object) {
if (reset) {
this.pageIndex = 1;
}
if (this.searchStatus == null) {
this.searchStatus = '';
this.pageNum = 1;
}
if (this.searchCategoryId == null) {
this.searchCategoryId = '';
}
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 => {
whereObject['pageNum'] = this.pageNum;
whereObject['pageSize'] = this.pageSize;
this.cms.getListContent(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;
this.isLoadingSearch = false;
} else {
this.message.create('error', data['return_msg']);
this.message.error(data['return_msg']);
}
});
}
// 搜索
getSearch() {
this.getRequest();
// 重置
public resetForm(): void {
this.searchForm.reset();
}
// 查询分类树
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') {
this.nodes = data['return_data'];
if (this.nodes.length !== 0) {
@ -272,23 +124,19 @@ export class CmsContentComponent implements OnInit {
generateComment(data) {
for (const i in data) {
if (data[i].nodes == null) {
const item = {
/** 重新赋值 **/
data[i] = {
isLeaf: true,
title: data[i].text,
key: data[i].id,
children: data[i].nodes,
};
data[i] = item;
} else {
const item = {
/** 重新赋值 **/
data[i] = {
isLeaf: false,
title: data[i].text,
key: data[i].id,
children: data[i].nodes,
};
data[i] = item;
this.generateComment(data[i].children);
}
}
@ -296,337 +144,115 @@ export class CmsContentComponent implements OnInit {
console.log(this.nodes);
}
// 跳转添加
// 新增
getAdd() {
this.router.navigate(['/admin/cms/cmscontentadd'], {
queryParams: {
editFlag: 0
}
});
}
// 跳转修改
getEdit(id) {
this.router.navigate(['/admin/cms/cmscontentedit'], {
queryParams: {
id: id
}
});
this.isVisible = true;
this.editFlag = false;
}
// 跳转详情
getContentView(id) {
this.router.navigate(['/admin/cms/cmscontentview'], {
queryParams: {
id: id
}
// 编辑
getEdit(data: object) {
console.log(data);
if (data['imgData'] != null && data['imgData'] !== '') {
const logo = String(data['imgData']);
const logoArray = [];
logoArray.push(
{
uid: 1,
name: logo,
status: 'done',
url: environment.imageUrl + logo
});
this.imgFile = logoArray;
}
// 对话框删除
showDeleteConfirmDelete(id): void {
this.modalService.confirm({
nzTitle: '是否确定删除',
nzOkText: '是',
nzOnOk: () => this.deleteContent(id),
nzCancelText: '否',
});
this.id = data['id'];
this.validateForm.patchValue(data);
this.editFlag = true;
this.isVisible = true;
}
// 删除内容
deleteContent(id) {
if (id === undefined) {
// 提交内容
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 (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);
if (this.imgFile.length !== 0) {
if (this.imgFile[0]['response'] != null) {
this.validateForm.value.imgData = this.imgFile[0]['response']['return_data'][0];
} else {
this.message.create('warning', data['return_msg']);
this.validateForm.value.imgData = this.imgFile[0].name;
}
});
}
// 弹出添加附件
addPatch() {
this.isVisible = true;
}
// 删除附件确认
showDeletePatch(id) {
this.modalService.confirm({
nzTitle: '是否确定删除',
nzOkText: '是',
nzOnOk: () => this.deletePatch(id),
nzCancelText: '否',
});
}
// 删除附件
deletePatch(id) {
if (id === undefined || id === null || id === '') {
return;
}
this.http.get(this.WEB_SERVE_URL + '/cmsPatch/delPatch?id=' + id).subscribe(data => {
if (this.editFlag) {
this.validateForm.value.id = this.id;
this.cms.updateCmsContent(this.validateForm.value, 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);
}
this.getRequest(false, this.searchForm.value);
this.message.success('修改成功');
} else {
this.message.create('error', '修改失败');
}
// 附件上传设置
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();
}
}
// 附件弹窗确定添加按钮
handlePatchOk(value: any): void {
// 校验类型选择与必填
if (value.patchName == null || value.patchName == '') {
this.message.create('error', `请填写附件名称!`);
return;
}
if (value.sort == null || value.sort == '') {
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;
}
} 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 == '') {
this.message.create('error', `请上传附件!`);
return;
}
// 定义附件数据
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 => {
this.cms.insertCmsContent(this.validateForm.value, 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', `新增成功!`);
this.getRequest(false, this.searchForm.value);
this.message.success('新增成功');
} else {
this.message.create('warning', data['return_msg']);
this.message.create('error', '修改失败');
}
}, 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;
// 图片查看
handlePreview = async (file: NzUploadFile) => {
if (!file.url && !file.preview) {
// tslint:disable-next-line:no-non-null-assertion
file.preview = await getBase64(file.originFileObj!);
}
if (this.moduleId == null || this.moduleId == undefined) {
this.moduleId = '';
this.previewImage = file.url || file.preview;
this.previewVisible = true;
}
// 定义附件数据
const params = {
'id': this.pushId,
'status': 2,
'moduleId': this.moduleId
};
/** 确定等待 **/
this.http.post(this.WEB_SERVE_URL + '/cmsContent/updateStatusOfContent', params).subscribe(data => {
showDeleteConfirmDelete(id: number): void {
this.common.showConfirm('是否确定删除!', dataR => {
if (dataR) {
this.cms.deleteById(id, data => {
if (data['return_code'] === '000000') {
this.isPublish = false;
this.isPushOkLoading = false;
this.moduleId = '';
this.pushId = '';
this.getRequest();
this.message.create('success', `发布成功!`);
this.getRequest(true, this.searchForm.value);
this.message.success(data['return_data']);
} else {
this.message.create('warning', data['return_msg']);
this.message.error(data['return_msg']);
}
}, error => {
this.message.create('error', `未知错误!`);
});
}
/** 清空模板 **/
emptyPushForm(e: MouseEvent): void {
e.preventDefault();
this.pushForm.reset();
for (const key in this.pushForm.controls) {
this.pushForm.controls[key].markAsPristine();
this.pushForm.controls[key].updateValueAndValidity();
}
});
}
// 根据内容分类查询可使用的模板列表
findModuleByCategory(categoryId) {
this.http.get(this.WEB_SERVE_URL + '/cmsCategoryModule/getModuleByCategoryId?categoryId=' + categoryId).subscribe(data => {
if (data['return_code'] === '000000') {
this.selectModule = data['return_data'];
console.log(this.selectModule);
public getForbiddenUser(id, status: any): void {
const message = (status === 2 ? '是否下架当前内容' : '是否上架当前内容');
const s = status === 2 ? 1 : 2;
this.common.showConfirm(message, data => {
if (data) {
this.cms.updateContentStatus(id, s, dataUser => {
if (dataUser['return_code'] === '000000') {
this.message.success(dataUser['return_data']);
} else {
this.message.create('error', data['return_msg']);
this.message.error(dataUser['return_msg']);
}
this.getRequest(false, this.searchForm.value);
});
}
showDown(id): void {
this.modalService.confirm({
nzTitle: '是否确定下线',
nzOkText: '是',
nzOnOk: () => this.DownContent(id),
nzCancelText: '否',
});
}
// 下线
DownContent(id) {
// 定义附件数据
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 {CmsContentComponent} from './cms-content/cms-content.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';
@ -13,7 +12,6 @@ const routes: Routes = [
{path: 'cmscategorymodule', component: CmsCategoryModuleComponent},
{path: 'cmscontent', component: CmsContentComponent},
{path: 'cmscontentadd', component: CmsContentAddComponent},
{path: 'cmscontentedit', component: CmsContentEditComponent},
{path: 'cmscontentview', component: CmsContentViewComponent}
];

@ -6,17 +6,15 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {NgZorroAntdModule} from 'ng-zorro-antd';
import {NgxNeditorModule} from '@notadd/ngx-neditor';
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 {CmsCategoryModuleComponent} from './cms-category-module/cms-category-module.component';
import {CmsContentAddComponent} from './cms-content-add/cms-content-add.component';
import {CmsContentComponent} from './cms-content/cms-content.component';
import { ContentEditComponent } from './content-edit/content-edit.component';
import {AppCommonModule} from "../../app-common.module";
@NgModule({
declarations: [CmsCategoryComponent, CmsCategoryModuleComponent, CmsContentComponent, CmsContentAddComponent, CmsContentEditComponent, CmsContentViewComponent, ContentEditComponent],
declarations: [CmsCategoryComponent, CmsCategoryModuleComponent, CmsContentComponent, CmsContentAddComponent, CmsContentViewComponent],
imports: [
CommonModule,
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,
baseUrl: 'http://localhost:9302/brest/', // 测试环境服务器地址(请求数据地址)
// orderUrl: 'http://localhost:9304/order/',
// imageUrl: 'https://hsgcs.dctpay.com/filesystem/',
imageUrl: 'https://hsgcs.dctpay.com/filesystem/',
// baseUrl: 'https://hsgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址)
orderUrl: 'https://hsgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址)
// imageUrl: 'https://hsgcs.dctpay.com/filesystem/',

Loading…
Cancel
Save