|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
|
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'; |
|
|
|
@ -52,8 +52,10 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
// 附件返回地址
|
|
|
|
|
patchPath = ''; |
|
|
|
|
// 允许上传的文件类型
|
|
|
|
|
annexForm: FormGroup; /** 定义附件表单 **/ |
|
|
|
|
isVisible = false; /** 是否弹出添加 **/ |
|
|
|
|
annexForm: FormGroup; |
|
|
|
|
/** 定义附件表单 **/ |
|
|
|
|
isVisible = false; |
|
|
|
|
/** 是否弹出添加 **/ |
|
|
|
|
fileList = []; |
|
|
|
|
// 上传的后缀名
|
|
|
|
|
suffix = ''; |
|
|
|
@ -150,30 +152,35 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
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 store: LocalStorageService, // 请求缓存
|
|
|
|
|
) { |
|
|
|
|
this.WEB_SERVE_URL = environment.imageUrl; |
|
|
|
|
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' ) { |
|
|
|
|
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' ) { |
|
|
|
|
} |
|
|
|
|
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' ) { |
|
|
|
|
} |
|
|
|
|
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' ) { |
|
|
|
|
} |
|
|
|
|
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' ) { |
|
|
|
|
} |
|
|
|
|
if (this.store.get(ADMIN_INFO_OBJECT)['buttonList'][i].permissionCode === 'BTN_cmscontent_up_down') { |
|
|
|
|
this.BTN_cmscontent_up_down = 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -204,6 +211,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.findCategoryTree(roleType); |
|
|
|
|
this.getRequest(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 重置搜索
|
|
|
|
|
resetSearch() { |
|
|
|
|
// 搜索内容标题
|
|
|
|
@ -213,6 +221,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
// 分类搜索
|
|
|
|
|
this.searchCategoryId = ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 请求列表
|
|
|
|
|
getRequest(reset: boolean = false) { |
|
|
|
|
this.showPatch = 0; |
|
|
|
@ -237,12 +246,14 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 搜索
|
|
|
|
|
getSearch() { |
|
|
|
|
this.getRequest(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询分类树
|
|
|
|
|
findCategoryTree (roleType) { |
|
|
|
|
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']; |
|
|
|
@ -256,11 +267,13 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 递归分类树
|
|
|
|
|
generateComment (data) { |
|
|
|
|
generateComment(data) { |
|
|
|
|
for (const i in data) { |
|
|
|
|
if (data[i].nodes == null) { |
|
|
|
|
const item = { /** 重新赋值 **/ |
|
|
|
|
const item = { |
|
|
|
|
/** 重新赋值 **/ |
|
|
|
|
isLeaf: true, |
|
|
|
|
title: data[i].text, |
|
|
|
|
key: data[i].id, |
|
|
|
@ -268,7 +281,8 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
}; |
|
|
|
|
data[i] = item; |
|
|
|
|
} else { |
|
|
|
|
const item = { /** 重新赋值 **/ |
|
|
|
|
const item = { |
|
|
|
|
/** 重新赋值 **/ |
|
|
|
|
isLeaf: false, |
|
|
|
|
title: data[i].text, |
|
|
|
|
key: data[i].id, |
|
|
|
@ -281,6 +295,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.nodes = data; |
|
|
|
|
console.log(this.nodes); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 跳转添加
|
|
|
|
|
getAdd() { |
|
|
|
|
this.router.navigate(['/admin/cms/cmscontentadd'], { |
|
|
|
@ -289,6 +304,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 跳转修改
|
|
|
|
|
getEdit(id) { |
|
|
|
|
this.router.navigate(['/admin/cms/cmscontentedit'], { |
|
|
|
@ -297,6 +313,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 跳转详情
|
|
|
|
|
getContentView(id) { |
|
|
|
|
this.router.navigate(['/admin/cms/cmscontentview'], { |
|
|
|
@ -305,6 +322,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 对话框删除
|
|
|
|
|
showDeleteConfirmDelete(id): void { |
|
|
|
|
this.modalService.confirm({ |
|
|
|
@ -314,16 +332,19 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
nzCancelText: '否', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 删除内容
|
|
|
|
|
deleteContent(id) { |
|
|
|
|
if (id === undefined) { |
|
|
|
|
return; |
|
|
|
|
}if (id === null) { |
|
|
|
|
} |
|
|
|
|
if (id === null) { |
|
|
|
|
return; |
|
|
|
|
}if (id === '') { |
|
|
|
|
} |
|
|
|
|
if (id === '') { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.http.get(this.WEB_SERVE_URL + '/cmsContent/delContent?id=' + id).subscribe( data => { |
|
|
|
|
this.http.get(this.WEB_SERVE_URL + '/cmsContent/delContent?id=' + id).subscribe(data => { |
|
|
|
|
if (data['return_code'] === '000000') { |
|
|
|
|
this.message.create('success', `删除成功!`); |
|
|
|
|
this.getRequest(); |
|
|
|
@ -332,10 +353,11 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询附件列表
|
|
|
|
|
findPatchByContent(id) { |
|
|
|
|
this.contentSelect = id; |
|
|
|
|
this.http.get(this.WEB_SERVE_URL + '/cmsContent/getListPatches?pageNum=1&pageSize=100&contentId=' + id).subscribe( data => { |
|
|
|
|
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; |
|
|
|
@ -345,10 +367,12 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 弹出添加附件
|
|
|
|
|
addPatch() { |
|
|
|
|
this.isVisible = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 删除附件确认
|
|
|
|
|
showDeletePatch(id) { |
|
|
|
|
this.modalService.confirm({ |
|
|
|
@ -358,12 +382,13 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
nzCancelText: '否', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 删除附件
|
|
|
|
|
deletePatch(id) { |
|
|
|
|
if (id === undefined || id === null || id === '') { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.http.get(this.WEB_SERVE_URL + '/cmsPatch/delPatch?id=' + id).subscribe( data => { |
|
|
|
|
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); |
|
|
|
@ -372,6 +397,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 取消按钮
|
|
|
|
|
handleCancel(): void { |
|
|
|
|
this.isVisible = false; |
|
|
|
@ -379,6 +405,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.fileList = []; |
|
|
|
|
/** 隐藏弹框 **/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 附件类型选择
|
|
|
|
|
getChange(event) { |
|
|
|
|
if (event != null) { |
|
|
|
@ -386,6 +413,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
console.log(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 附件上传设置
|
|
|
|
|
customReq = (item: UploadXHRArgs) => { |
|
|
|
|
this.patchPath = ''; // 置空路径
|
|
|
|
@ -418,6 +446,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 清空 **/ |
|
|
|
|
emptyForm(e: MouseEvent): void { |
|
|
|
|
e.preventDefault(); |
|
|
|
@ -427,6 +456,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.annexForm.controls[key].updateValueAndValidity(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 附件弹窗确定添加按钮
|
|
|
|
|
handlePatchOk(value: any): void { |
|
|
|
|
// 校验类型选择与必填
|
|
|
|
@ -495,6 +525,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.message.create('error', `未知错误!`); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 弹出发布附件
|
|
|
|
|
addPush(id, categoryId) { |
|
|
|
|
this.findModuleByCategory(categoryId); |
|
|
|
@ -502,6 +533,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
// document.getElementById('resetPush').click();
|
|
|
|
|
this.isPublish = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 取消发布
|
|
|
|
|
handleCancelPush(): void { |
|
|
|
|
this.isPublish = false; |
|
|
|
@ -509,6 +541,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.pushId = ''; |
|
|
|
|
/** 隐藏弹框 **/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 附件弹窗确定添加按钮
|
|
|
|
|
handlePushOk(value: any): void { |
|
|
|
|
console.log('发布'); |
|
|
|
@ -545,6 +578,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.message.create('error', `未知错误!`); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 清空模板 **/ |
|
|
|
|
emptyPushForm(e: MouseEvent): void { |
|
|
|
|
e.preventDefault(); |
|
|
|
@ -554,6 +588,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
this.pushForm.controls[key].updateValueAndValidity(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 根据内容分类查询可使用的模板列表
|
|
|
|
|
findModuleByCategory(categoryId) { |
|
|
|
|
this.http.get(this.WEB_SERVE_URL + '/cmsCategoryModule/getModuleByCategoryId?categoryId=' + categoryId).subscribe(data => { |
|
|
|
@ -574,6 +609,7 @@ export class CmsContentComponent implements OnInit { |
|
|
|
|
nzCancelText: '否', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 下线
|
|
|
|
|
DownContent(id) { |
|
|
|
|
// 定义附件数据
|
|
|
|
|