Commit 16096425 authored by obt's avatar obt

星空动态完成代码更新

parent cf0c03e4
/*
* @Author: Jenkins
* @Date: 2020-12-02 09:18:01
* @LastEditTime: 2020-12-07 16:03:52
* @LastEditTime: 2020-12-08 10:57:37
* @LastEditors: Please set LastEditors
* @Description: 星云动态页请求接口
* @FilePath: \rs-cloud-platform-ui\src\api\wsmanagement\newsCategory\index.js
......@@ -26,6 +26,7 @@ export function getAllnewsType(){
*/
export function getListnewsType(obj){
return fetch({
// url: '/api/website/newsType/getList',
url: '/api/website/newsType/getList',
method: 'get',
params: obj
......
<!--
* @Author: your name
* @Date: 2020-12-01 09:54:12
* @LastEditTime: 2020-12-07 18:31:07
* @LastEditTime: 2020-12-08 09:59:45
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \rs-cloud-platform-ui\src\views\webSiteManagement\newsCategory\index.vue
......@@ -26,7 +26,8 @@ export default {
data(){
return {
componentName: 'nebulaDynamics',
regions:[]
regions:[],
info: null,
}
},
mounted() {
......
<!--
* @Author: Jenkins
* @Date: 2020-12-01 09:54:12
* @LastEditTime: 2020-12-07 20:59:50
* @LastEditTime: 2020-12-08 14:24:04
* @LastEditors: Please set LastEditors
* @Description: 星云动态
* @FilePath: \rs-cloud-platform-ui\src\views\webSiteManagement\newsCategory\index.vue
......@@ -22,6 +22,7 @@
</div>
</div>
</div>
<!-- 类型管理弹框 -->
<el-dialog title="类型管理" :visible.sync="typeManagerVisible" append-to-body>
<div id="typeManager">
......@@ -59,15 +60,16 @@
<span>
<div class="operators">
<div class="edit" @click.stop="clickTypeEditor(scope.row)">编辑</div>
<div class="offshelf" v-if="scope.row.status==1">下架</div>
<div class="upshelf" v-else>上架</div>
<div class="delete">删除</div>
<div class="offshelf" v-if="scope.row.status==1" @click.stop="changeTypeStatus(scope.row)">下架</div>
<div class="upshelf" v-else @click.stop="changeTypeStatus(scope.row)">上架</div>
<div class="delete" @click.stop="delType(scope.row)">删除</div>
</div>
</span>
</template>
</el-table-column>
</el-table>
</div>
<div class="typePagination">
<el-pagination
@size-change="changeHandleSize"
......@@ -257,9 +259,9 @@
<span>
<div class="operators">
<div class="edit" @click.stop="editorInfo(scope.row)">编辑</div>
<div class="offshelf" v-if="scope.row.status == 1">下架</div>
<div class="upshelf" v-else>上架</div>
<div class="delete">删除</div>
<div class="offshelf" v-if="scope.row.status == 1" @click.stop="changeInfoStatus(scope.row)">下架</div>
<div class="upshelf" v-else @click.stop="changeInfoStatus(scope.row)">上架</div>
<div class="delete" @click.stop="delInfo(scope.row)">删除</div>
</div>
</span>
</template>
......@@ -277,11 +279,11 @@
:total="infoPagination.total">
</el-pagination>
</div>
<el-dialog title="资讯编辑" :visible.sync="infoEditorVisible" append-to-body>
<!-- <el-dialog title="资讯编辑" :visible.sync="infoEditorVisible" append-to-body>
<div id="infoEditor">
</div>
</el-dialog>
</el-dialog> -->
<!-- 使用图片查看器预览当前缩略图 -->
<el-image-viewer v-if="currentIcon.showPreview" :on-close="closePreview" :url-list="[currentIcon.url]"/>
</div>
......@@ -296,6 +298,7 @@ import {
getListnewsType,
addUpdateNewsType,
getListNewsInfo,
addUpdateNewsInfo,
} from "@/api/website/newsCategory/index";
export default {
name: "nebulaDynamics",
......@@ -372,7 +375,7 @@ export default {
},
],
canPull: false,
infoEditorVisible: false,
// infoEditorVisible: false,
// 表格数据
tableData: [
// {
......@@ -448,47 +451,106 @@ export default {
this.pullListNewsInfo()
}
},
// 关闭当前类型弹框时重新加载资讯
typeManagerVisible(newVal){
!newVal && (this.pullListNewsInfo())
},
// 类型表格筛选页码改变
"typePagination.currentPage": {
deep: true,
handler(){
this.changeTableType()
// this.changeTableType()
this.pullListNewsType()
}
},
// 类型表格筛选数量改变
"typePagination.pageSize": {
deep: true,
handler(){
this.changeTableType()
// this.changeTableType()
this.pullListNewsType()
}
}
},
mounted() {
// 获取所有新闻类型
this.pullAllNewsType()
// // 获取分页新闻类型
// getListnewsType({
// page: "0",
// limit: "10",
// name: "",
// }).then((res) => {
// console.log("获取分页新闻类型=>", res);
// });
// // 新增或更新新闻类型
// addUpdateNewsType({
// nameCn: "行业创新",
// nameEn: "News creation",
// rank: 0,
// status: 1,
// id: "11",
// }).then((res) => {
// console.log("新增或更新新闻类型=>", res);
// });
},
methods: {
// 删除新闻信息
delInfo(info){
this.$confirm('确定继续执行该操作吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
info.isDel = 1
// 删除资讯
addUpdateNewsInfo({
id: info.id,
title: info.title,
detail: info.introduce,
coverImg: info.icon.url,
content: info.title,
newsDate: info.newsDate,
typeId: info.typeId,
status: info.status,
indexShow: info.indexShow,
typeName: info.type,
isDel: info.isDel,
}).then(res => {
if(res.status==200){
this.$message({
message: "删除成功!!!",
type: 'success'
})
this.pullListNewsInfo()
}else{
this.$message.error('操作失败,请稍后重试!!!');
}
})
})
},
// 更改资讯状态
changeInfoStatus(info){
let message = ""
if(info.status==1){// 当前为启用
info.status = 2
message = "下架成功!!!"
}else{
info.status = 1
message = "上架成功"
}
// 更新资讯
addUpdateNewsInfo({
id: info.id,
title: info.title,
detail: info.introduce,
coverImg: info.icon.url,
content: info.title,
newsDate: info.newsDate,
typeId: info.typeId,
status: info.status,
indexShow: info.indexShow,
typeName: info.type,
isDel: info.isDel,
}).then(res => {
if(res.status==200){
this.$message({
message: message,
type: 'success'
})
}else{
this.$message.error('操作失败,请稍后重试!!!');
}
})
},
// 编辑资讯
editorInfo(info){
console.log("Info=>",info)
this.infoEditorVisible = true
this.$parent.componentName = "newsCreator";
this.$parent.regions = this.typesState
this.$parent.info = info
},
handleSizeChange(val) {
// console.log(`每页 ${val} 条`);
......@@ -501,7 +563,10 @@ export default {
// 获取所有的新闻类型
pullAllNewsType(isInit = true){
this.typesState = []
this.types = []
this.types = [{
value: "",
label: "全部",
}]
// 获取所有新闻类型
getAllnewsType().then((res) => {
// console.log("所有的新闻类型=>",res)
......@@ -530,6 +595,10 @@ export default {
}
});
console.log("获取到的所有类型=>",this.typesState)
// 改变类型表格数据
// this.changeTableType()
// 拉取分页表格数据
this.pullListNewsType()
this.canPull = isInit
}
});
......@@ -548,9 +617,10 @@ export default {
res.data.data.forEach(element => {
// 缓存当前的表格数据
this.tableDataState.push(element)
})
console.log("tableDataState",this.tableDataState)
// 将缓存的数据作进一步的筛选
this.screenTableData()
})
}
console.log("获取分页新闻资讯=>", res);
});
......@@ -563,6 +633,7 @@ export default {
this.tableDataState.forEach((element,index) => {
// 未被删除则显示
if(element.isDel == 0){
let type = (this.typesState.find(ele => ele.id == element.typeId))
this.tableData.push({
id: element.id,
title: element.title,
......@@ -571,10 +642,14 @@ export default {
showPreview: false,
},
introduce: element.detail,
type: (this.typesState.find(ele => ele.id == element.typeId)).nameCn,
content: element.content,// 富文本内容
newsDate: element.newsDate,
type: type?type.nameCn:"",
typeId: element.typeId,
sort: index+1,
status: element.status,
indexShow: element.indexShow,
isDel: element.isDel,
});
}
})
......@@ -623,19 +698,29 @@ export default {
this.typeManagerVisible = true;
// 将获取到的所有新闻类型按字段放入到弹框表格中
// console.log("所有新闻类型缓存数据=>",this.typesState)
this.changeTableType()
// this.changeTableType()
// 拉取分页数据
this.pullListNewsType()
} else {
this.$parent.componentName = "newsCreator";
this.$parent.regions = this.typesState
this.$parent.info = null
}
},
// 更改类型表格
changeTableType(){
// 获取类型分页的表格数据
pullListNewsType(){
// 先将当前类型表格数据清空
this.tableType = []
let startIndex = (this.typePagination.currentPage * this.typePagination.pageSize) - this.typePagination.pageSize; // 开始截取的索引位置
let endIndex = startIndex + this.typePagination.pageSize // 结束截取的索引位置
this.typePagination.total = this.typesState.length
this.typesState.slice(startIndex,endIndex).forEach((element,index) => {
// 获取分页新闻类型
getListnewsType({
page: this.typePagination.currentPage,
limit: this.typePagination.pageSize,
name: "",
}).then((res) => {
console.log("获取分页新闻类型=>", res);
if(res.status==200){
this.typePagination.total = res.data.totalCount
res.data.data.forEach(element => {
// 未被删除的类型
if(element.isDel==0){
this.tableType.push({
......@@ -643,23 +728,104 @@ export default {
name: element.nameCn,
nameEn: element.nameEn,
sort: element.rank,
status: element.status
status: element.status,
isDel: element.isDel
})
}
})
}
});
this.typesState.sort((obj1,obj2)=>{
let val1 = parseInt((obj1.id+""))
let val2 = parseInt((obj2.id+""))
if(val1<val2){
return -1
}else if(val1>val2){
return 1
},
// 更改类型表格
// changeTableType(){
// this.tableType = []
// let startIndex = (this.typePagination.currentPage * this.typePagination.pageSize) - this.typePagination.pageSize; // 开始截取的索引位置
// let endIndex = startIndex + this.typePagination.pageSize // 结束截取的索引位置
// this.typePagination.total = this.typesState.length
// this.typesState.slice(startIndex,endIndex).forEach((element,index) => {
// // 未被删除的类型
// if(element.isDel==0){
// this.tableType.push({
// id: element.id,
// name: element.nameCn,
// nameEn: element.nameEn,
// sort: element.rank,
// status: element.status,
// isDel: element.isDel
// })
// }
// });
// this.typesState.sort((obj1,obj2)=>{
// let val1 = parseInt((obj1.id+""))
// let val2 = parseInt((obj2.id+""))
// if(val1<val2){
// return -1
// }else if(val1>val2){
// return 1
// }else{
// return 0
// }
// });
// console.log("类型表格数据改变=>",this.tableType)
// },
// 上下架类型
changeTypeStatus(type){
let message = ""
if(type.status==1){// 当前为启用
type.status=2
message = "下架成功"
}else{// 当前为弃用
type.status=1
message = "上架成功"
}
addUpdateNewsType({
id: type.id+'',
nameCn: type.name,
nameEn: type.nameEn,
rank: type.sort,
status: type.status,
isDel: type.isDel+'', // 0为不删除,1为删除
}).then(res => {
if(res.status == 200){
this.$message({
message: message,
type: 'success'
})
this.pullAllNewsType(false)
}else{
return 0
this.$message.error('操作失败,请稍后重试!!!');
}
})
},
// 删除类型
delType(type){
this.$confirm('确定继续执行该操作吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
type.isDel = 1
addUpdateNewsType({
id: type.id+'',
nameCn: type.name,
nameEn: type.nameEn,
rank: type.sort,
status: type.status,
isDel: type.isDel+'', // 0为不删除,1为删除
}).then(res => {
if(res.status == 200){
this.$message({
message: "删除成功",
type: 'success'
})
this.pullAllNewsType(false)
}else{
this.$message.error('操作失败,请稍后重试!!!');
}
})
});
console.log("类型表格数据改变=>",this.tableType)
},
// 添加类型
createType(){
if(this.newType&&this.newSort){
// 必须是中文名称
......@@ -669,15 +835,16 @@ export default {
nameCn: this.newType,
nameEn: "",
rank: this.newSort,
status: 1 // 创建即启用
status: 1, // 创建即启用
isDel: "0", // 0为不删除,1为删除
}).then(res => {
if(res.status == 200){
this.$message({
message: '创建成功!!!',
type: 'success'
})
this.typeCreatorVisible = false
this.pullAllNewsType(false)
this.typeCreatorVisible = false
}
})
}else{
......@@ -686,7 +853,6 @@ export default {
}else{
this.$message.error('请输入中文名称!!!');
}
}else{
this.$message.error('必填框有缺乏值,请完善输入!!!');
}
......@@ -695,6 +861,7 @@ export default {
this.typeEditorVisible = true
this.editorType = type
},
// 修改类型
confirmEditor(){
// 中文对应
if(/^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])+$/.test(this.editorType.name)){
......@@ -702,7 +869,18 @@ export default {
if(!/^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0])+$/.test(this.editorType.nameEn)){
if(this.editorType.sort>=0&&this.editorType.sort<10000){
// 上传修改
addUpdateNewsType({
id: this.editorType.id,
nameCn: this.editorType.name,
nameEn: this.editorType.nameEn,
rank: this.editorType.sort,
status: this.editorType.status,// 1启用,2不启用
isDel: this.editorType.isDel,// 0不删除,1删除
});
this.$message({
message: '修改成功!!!',
type: 'success'
})
this.typeEditorVisible = false
}else{
this.$message.error('排序值不在指定范围,请输入正确的排序值!!!');
......
<!--
* @Author: Jenkins
* @Date: 2020-12-02 14:49:10
* @LastEditTime: 2020-12-07 21:04:06
* @LastEditTime: 2020-12-08 14:18:46
* @LastEditors: Please set LastEditors
* @Description: 创建新闻
* @FilePath: \rs-cloud-platform-ui\src\views\webSiteManagement\newsCategory\newsCreator\index.vue
......@@ -101,6 +101,15 @@ export default {
})
}
});
if(this.$parent.info!=null){
this.form.id = this.$parent.info.id
this.form.title = this.$parent.info.title
this.form.coverImg = this.$parent.info.icon.url
this.form.introduce = this.$parent.info.introduce
this.form.region = this.$parent.info.typeId
this.form.sort = this.$parent.info.sort
this.form.content = this.$parent.info.content
}
},
methods: {
onContentChange (val) {
......@@ -126,28 +135,49 @@ export default {
}else if(this.form.content==""){
this.$message.error('请输入资讯详情!!!');
}else{
// 新增新闻资讯
addUpdateNewsInfo({
id: Math.floor((Math.random())*100000000),
let data,message
if(this.$parent.info!=null){
data = {
id: this.form.id,
title: this.form.title,
detail: this.form.introduce,
coverImg: this.form.coverImg,
content: this.form.content,
newsDate: timestamp2Date((new Date()).getTime()),
typeId: this.form.region,
isDel: 0,// 0为未被删除,1为已删除
status: 0, // 默认上传即为下架状态
indexShow: 1,
typeName: (this.types.find(ele => ele.value == this.form.region)).label,
}).then((res) => {
}
message = "修改成功!!!"
}else{
data = {
title: this.form.title,
detail: this.form.introduce,
coverImg: this.form.coverImg,
content: this.form.content,
newsDate: timestamp2Date((new Date()).getTime()),
typeId: this.form.region,
isDel: 0,// 0为未被删除,1为已删除
status: 2, // 默认上传即为下架状态(后端规定1为启用2为禁用)
indexShow: 1,
typeName: (this.types.find(ele => ele.value == this.form.region)).label,
}
message = "创建成功!!!"
}
// 新增新闻资讯
addUpdateNewsInfo(data).then((res) => {
if(res.status==200){
let _this = this
this.$message({
message: '创建成功!!!',
message: message,
type: 'success',
duration: 2000,
});
setTimeout(()=>{
_this.componentName = "nebulaDynamics"
_this.$parent.componentName = "nebulaDynamics"
_this.$parent.info = null
},2100);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment