Commit 33d2f7f3 authored by liwei's avatar liwei

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/views/monitor/errorLog/index.vue
#	src/views/monitor/operLog/index.vue
parents 19cf1ebd 3155e425
......@@ -81,21 +81,21 @@ export const constantRoutes = [
meta: { title: '修改密码', icon: 'dashboard' }
}]
},
{
path: '/formManage',
component: Layout,
name: 'formManage',
redirect: '/formManage/imgForm',
meta: { title: '表单管理', icon: 'dashboard' },
showFather: 'true',
children: [{
path: '/formManage/imgForm',
name: 'imgForm',
component: () => import('@/views/formManage/imgForm'),
meta: { title: '图片菜单', icon: 'dashboard' }
}
]
},
// {
// path: '/formManage',
// component: Layout,
// name: 'formManage',
// redirect: '/formManage/imgForm',
// meta: { title: '表单管理', icon: 'dashboard' },
// showFather: 'true',
// children: [{
// path: '/formManage/imgForm',
// name: 'imgForm',
// component: () => import('@/views/formManage/imgForm'),
// meta: { title: '图片菜单', icon: 'dashboard' }
// }
// ]
// },
{
path: '/onlyOffice',
component: (resolve) => require(['@/views/onlyOffice.vue'], resolve),
......
<template>
<div class="app-container">
<el-form ref="queryForm" style="padding: 0 0 0 10px" :model="queryParams" :inline="true">
<el-form-item label="名称:" prop="bannerName">
<el-input
v-model.trim="queryParams.bannerName"
placeholder="请输入名称"
clearable
:maxlength="500"
size="small"
style="width: 150px"
/>
</el-form-item>
<el-form-item label="链接地址:" prop="linkUrl">
<el-input
v-model.trim="queryParams.linkUrl"
placeholder="请输入链接地址"
clearable
:maxlength="255"
size="small"
style="width: 150px"
/>
</el-form-item>
<el-form-item>
<el-button
:class="commonField.queryClass"
:type="commonField.typePrimary"
:icon="commonField.queryIcon"
:size="commonField.smallSize"
@click="handleQuery"
>查询</el-button>
<el-button
:class="commonField.resetClass"
:icon="commonField.resetIcon"
:size="commonField.smallSize"
@click="resetQuery"
>重置</el-button>
</el-form-item>
<div style="float: right">
<el-form-item>
<el-button
:class="commonField.addClass"
:type="commonField.typePrimary"
:icon="commonField.addIcon"
:size="commonField.smallSize"
@click="handleAdd"
>新增</el-button>
</el-form-item>
</div>
</el-form>
<div class="placeholder" />
<div style="padding:5px 10px">
<el-table v-loading="loading" border :data="cmsBannerList">
<el-table-column type="index" label="序号" width="100px" align="center" />
<el-table-column label="图片" prop="bannerPicture" :show-overflow-tooltip="true" width="150px">
<template slot-scope="scope">
<div :id="step(scope.$index)">
<el-image
style="width:100%;height:100%;"
:src="scope.row.url"
:preview-src-list="[scope.row.url]"
@click="handleClickStop(scope.$index)"
@mouseover="justEnter($event)"
@mouseout="justOut($event)"
>
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline" />
</div>
</el-image>
</div>
</template>
</el-table-column>
<el-table-column label="分类" prop="type" :show-overflow-tooltip="true" width="130px">
<template slot-scope="scope">
<span v-if="scope.row.type=='0'">课程资源</span>
<span v-else-if="scope.row.type=='1'">其他资源</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="名称" prop="bannerName" :show-overflow-tooltip="true" width="130px">
<template slot-scope="scope">
{{ scope.row.bannerName || '-' }}
</template>
</el-table-column>
<!-- <el-table-column label="图片" prop="bannerPicture" :show-overflow-tooltip="true">-->
<!-- <template slot-scope="scope">-->
<!-- {{ scope.row.bannerPicture || '-' }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="链接地址" prop="linkUrl" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.linkUrl || '-' }}
</template>
</el-table-column>
<el-table-column label="排序" prop="weight" :show-overflow-tooltip="true" width="100px">
<template slot-scope="scope">
{{ scope.row.weight || '-' }}
</template>
</el-table-column>
<el-table-column width="120" label="状态" prop="flag">
<template slot-scope="scope">
<el-switch
v-model="scope.row.flag"
class="switchDisabledStyle"
inactive-value="0"
active-value="1"
@click.native="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<!-- <el-table-column label="备注" prop="remarks" :show-overflow-tooltip="true">-->
<!-- <template slot-scope="scope">-->
<!-- {{ scope.row.remarks || '-' }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="创建时间" prop="createDate" :show-overflow-tooltip="true">-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ scope.row.createDate | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" class-name="small-padding fixed-width" width="200px">
<template slot-scope="scope">
<el-button
:class="commonField.updateClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
:class="commonField.delClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.rows"
@pagination="getList"
/>
<!-- 添加或修改banner管理配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="90px">
<el-form-item label="分类:" prop="type">
<!-- <el-input v-model.trim="form.type" show-word-limit :maxlength="32" placeholder="请输入类型" />-->
<el-select v-model.trim="form.type" show-word-limit placeholder="请输入类型" style="width: 100%">
<el-option label="课程资源" value="0" />
<el-option label="其他资源" value="1" />
</el-select>
</el-form-item>
<el-form-item label="名称:" prop="bannerName">
<el-input v-model.trim="form.bannerName" show-word-limit :maxlength="500" placeholder="请输入banner名字" />
</el-form-item>
<el-form-item label="图片:" prop="bannerPicture">
<el-input v-model="form.bannerPicture" style="display: none" />
<el-upload
class="avatar-uploader"
action="#"
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<!-- <img v-if="imageUrl" :src="imageUrl" style="height: 200px;width: 200px">-->
<img v-if="imageUrl" :src="imageUrl" style="height: 200px;width: 200px">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
<el-form-item label="链接地址:" prop="linkUrl">
<el-input v-model.trim="form.linkUrl" show-word-limit :maxlength="255" placeholder="请输入链接地址" />
</el-form-item>
<el-form-item label="排序:" prop="weight">
<el-input-number v-model.trim="form.weight" style="width: 100%" controls-position="right" :min="0" />
</el-form-item>
<el-form-item label="状态:">
<el-radio-group v-model="form.flag">
<el-radio label="1">启用</el-radio>
<el-radio label="0">停用</el-radio>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label="备注" prop="remarks">-->
<!-- <el-input v-model.trim="form.remarks" maxlength="200" show-word-limit type="textarea" placeholder="请输入内容" />-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button class="cancelBtn" @click="cancel">取 消</el-button>
<el-button class="submitBtn" type="primary" @click="submitForm">确 定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import commonField from '@/utils/commonField'
import {
addCmsBanner,
delCmsBanner, exportCmsBanner,
getCmsBanner,
listCmsBanner,
updateCmsBanner
} from '@/api/contentManagement/cmsBanner'
import { updateResponseUrl } from '@/utils/updateUrl'
import { uploadPublic } from '@/api/contentManagement/sysContest'
import user from "@/store/modules/user";
import store from "@/store";
export default {
name: 'CmsBanner',
data() {
return {
imageUrl: '',
fileUpload: '/dev-api/common/fileUpload?file=' + this.file + '&temp=' + 'development',
// 遮罩层
loading: true,
// 总条数
total: 0,
// banner管理表格数据
cmsBannerList: [],
// 弹出层标题
title: '',
// 是否显示弹出层
open: false,
// 状态菜单
statusOptions: [
{
dictLabel: '启用',
dictValue: '1'
},
{
dictLabel: '停用',
dictValue: '0'
}
],
// 查询参数
queryParams: {
page: 1,
rows: 10,
bannerPicture: undefined,
bannerName: undefined,
type: undefined,
weight: undefined,
linkUrl: undefined,
flag: ''
},
showImg: false,
imagUrl: '',
// 表单参数
form: {},
// 表单校验
rules: {
bannerName: [
{ required: true, message: '请输入名称', trigger: 'blur' }
],
type: [
{ required: true, message: '请选择类型' }
],
weight: [
{ required: true, message: '请输入排序' }
],
bannerPicture: [
{ required: true, message: '请上传图片' }
]
}
}
},
computed: {
commonField() {
return commonField
}
},
created() {
this.getList() // 列表查询
},
methods: {
// 封面图片预览
justEnter(event) {},
justOut(event) {},
/**
* @description: 点击蒙版关闭预览图片
* @author: gaoyu
* @param: imageId
* @return:
**/
handleClickStop(imageId) {
this.$nextTick(() => {
var domImageView = document.querySelector(`#${this.step(imageId)} .el-image-viewer__mask`)
if (!domImageView) {
return
}
var closeButton = document.querySelector(`#${this.step(imageId)} .el-image-viewer__close`)
domImageView.addEventListener('click', () => {
closeButton.click()
})
})
},
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload(file) {
const formData = new FormData()
formData.append('file', file.file)
formData.append('temp', 'CmsBanner')
uploadPublic(formData).then(res => {
// console.log('url', res.data.url)
this.imageUrl = res.data.url
this.showImg = true
this.form.bannerPicture = res.data.businessId
})
},
handleAvatarSuccess(res, file) {
console.log('res', res)
// this.imageUrl = URL.createObjectURL(file.raw)
// this.form.bannerPicture = res.data.businessId
// this.form.url = res.data.url
},
beforeAvatarUpload(file) {
// this.file = file
// 判断文件是否为图片类型
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
const isLt2M = file.size / 1024 / 1024 < 2
if (!isJPG) {
this.$message.error('只能上传图片格式的文件!')
return false
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 2MB!')
return false
}
this.file = file
},
step(index) {
return 'step' + index
},
handleRemove(file, fileList) {
console.log(file, fileList)
},
/** 查询banner管理列表 */
getList() {
this.loading = true
listCmsBanner(this.queryParams).then(
response => {
if (this.$store.getters.type === '1') { // 开启
// 遍历rows
for (var i = 0; i < response.rows.length; i++) {
if (response.rows[i].path !== undefined) { // rows里的数据是path
const newUrl = updateResponseUrl(response.rows[i].path)
response.rows[i].path = newUrl
}
if (response.rows[i].url !== undefined) { // rows里的数据是url
const newUrl = updateResponseUrl(response.rows[i].url)
response.rows[i].url = newUrl
}
if (response.rows[i].avatarUrl !== undefined) { // rows里的数据是avatarUrl
const newUrl = updateResponseUrl(response.rows[i].avatarUrl)
response.rows[i].avatarUrl = newUrl
}
}
}
console.log('response.rows:', response.rows)
// 处理分页数据里的url
this.cmsBannerList = response.rows
// console.log('this.cmsBannerList:', this.cmsBannerList)
this.total = response.total
this.loading = false
}
)
},
// 取消按钮
cancel() {
this.open = false
this.reset()
},
// 表单重置
reset() {
this.form = {
businessId: undefined,
bannerPicture: undefined,
bannerName: undefined,
type: undefined,
weight: undefined,
remarks: undefined,
linkUrl: undefined,
flag: '1'
}
this.resetForm('form')
},
/** 查询按钮操作 */
handleQuery() {
this.queryParams.page = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
page: 1,
rows: 10,
bannerPicture: undefined,
bannerName: undefined,
type: undefined,
weight: undefined,
linkUrl: undefined,
flag: ''
}
this.handleQuery()
},
/** 新增按钮操作 */
handleAdd() {
this.imageUrl = null
this.reset()
this.open = true
this.title = '添加banner'
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const id = row.businessId
getCmsBanner(id).then(response => {
// 处理data数据里的url
if (this.$store.getters.type === '1') { // 开启
if (response.data.path !== undefined) {
const newUrl = updateResponseUrl(response.data.path)
response.data.path = newUrl
}
if (response.data.url !== undefined) {
const newUrl = updateResponseUrl(response.data.url)
response.data.url = newUrl
}
if (response.data.avatarUrl !== undefined) {
const newUrl = updateResponseUrl(response.data.avatarUrl)
response.data.avatarUrl = newUrl
}
}
this.form = response.data
// console.log('this.form:', this.form)
this.imageUrl = response.data.url
this.open = true
this.title = '修改banner'
})
},
// 改变状态
handleStatusChange(row) {
const text = row.flag === '1' ? '启用' : '停用'
this.$confirm('确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return updateCmsBanner(row)
}).then(() => {
this.$message({
message: text + '成功',
type: 'success'
})
}).catch(function() {
row.flag = row.flag === '0' ? '1' : '0'
})
},
/** 提交按钮 */
submitForm: function() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.businessId !== undefined) {
updateCmsBanner(this.form).then(response => {
this.msgSuccess('修改成功')
this.open = false
this.getList()
})
} else {
addCmsBanner(this.form).then(response => {
this.msgSuccess('新增成功')
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.businessId
this.$confirm('是否确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return delCmsBanner(id)
}).then(() => {
this.getList()
this.$message({
message: '删除成功',
type: 'success'
})
}).catch(function() {
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams
this.$confirm('是否确认操作?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return exportCmsBanner(queryParams).then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = 'banner管理信息' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
})
})
}
}
}
</script>
<style lang="scss" scoped>
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
border: 1px solid #dcdfe6;
}
.app-container {
font-size: 18px;
padding: 0;
::v-deep .el-table td:nth-child(2) .cell {
margin: 10px;
text-align: center!important;
}
font-size: 18px;
padding: 0;
.placeholder {
height: 1.3vh;
background-color: #F4F4F4;
margin-bottom: 10px
}
.placeholder {
height: 1.3vh;
background-color: #F4F4F4;
margin-bottom: 10px
}
}
</style>
<template>
<!-- 新闻资讯管理 -->
<div id="courseManage">
<div v-show="showSwitch.courseContent" class="courseContent">
<div class="search" style="border-bottom: 14px solid #f4f4f4">
<el-form ref="queryForm" style="padding: 0 0 0 10px" :model="queryParams" :inline="true">
<el-form-item label="发布状态:" prop="flag">
<!-- 发布状态下拉框-->
<el-select v-model="queryParams.flag" placeholder="请选择发布状态">
<el-option
v-for="item in releaseStatusOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="发布日期:" prop="releaseDate">
<el-date-picker
v-model="dateRange"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="handleChangeTime"
/>
</el-form-item>
<el-form-item>
<!-- //查询按钮-->
<el-button
:class="commonField.queryClass"
:type="commonField.typePrimary"
:icon="commonField.queryIcon"
:size="commonField.smallSize"
@click="loadData"
>{{ commonField.queryName }}</el-button>
<!-- //重置按钮-->
<el-button
:class="commonField.resetClass"
:icon="commonField.resetIcon"
:size="commonField.smallSize"
@click="resetQuery"
>{{ commonField.resetName }}</el-button>
</el-form-item>
<div style="float: right">
<el-form-item>
<!-- //新增按钮-->
<el-button
v-has-permi="hasAddPerm"
:class="commonField.addClass"
:type="commonField.typePrimary"
:icon="commonField.addIcon"
:size="commonField.smallSize"
@click="handleAdd"
>{{ commonField.addName }}</el-button>
<!-- //新增按钮-->
<!-- <el-button-->
<!-- :class="commonField.addClass"-->
<!-- :type="commonField.typePrimary"-->
<!-- :icon="commonField.addIcon"-->
<!-- :size="commonField.smallSize"-->
<!-- @click="handleExamination"-->
<!-- >{{ "跳转考核临时" }}</el-button>-->
</el-form-item>
</div>
</el-form>
</div><div style="padding:5px 10px">
<div class="tableTitle">新闻资讯列表</div>
<el-table v-loading="fullscreenLoading" :data="tableData" border sortable="true" style="text-align: left;">
<span slot="empty">{{ tableDataTips }}</span>
<el-table-column align="left" prop="id" label="序号" width="55px">
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column align="left" prop="title" label="新闻标题" width="300" show-overflow-tooltip />
<el-table-column align="left" prop="remarks" label="新闻摘要" width="300" show-overflow-tooltip />
<el-table-column align="left" label="新闻标题图" prop="pictureId">
<template slot-scope="scope">
<div :id="step(scope.$index)">
<el-image :src="scope.row.path" :preview-src-list="[scope.row.path]" style="width:100%;height:100%;" @mouseover="justEnter($event)" @mouseout="justOut($event)" />
</div>
</template>
</el-table-column>
<!-- <el-table-column align="left" prop="isForntPage" label="是否为头条新闻" show-overflow-tooltip>-->
<!-- <template slot-scope="scope">-->
<!-- <span>{{ scope.row.isForntPage === 1 ? '是' : '否' }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column align="left" prop="isTop" width="150" label="是否为置顶新闻" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.isTop === 1 ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column align="left" prop="isRecommended" width="150" label="是否为推荐新闻" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.isRecommended === 1 ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column align="left" prop="releaseStatus" label="发布状态" show-overflow-tooltip>
<template slot-scope="scope">
<el-switch
v-model="scope.row.flag"
class="switchDisabledStyle"
inactive-value="0"
active-value="1"
@click.native="handleStatusChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column align="left" prop="releaseDate" label="发布日期" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.releaseDate }}</span>
</template>
</el-table-column>
<el-table-column align="left" prop="createDate" label="提交时间" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.createDate }}</span>
</template>
</el-table-column>
<el-table-column align="left" prop="createUser" label="提交人" show-overflow-tooltip>
<template slot-scope="scope">
<span>{{ scope.row.nickName }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="350">
<template slot-scope="scope">
<el-button
v-has-permi="hasDetailPerm"
:class="commonField.updateClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="handleView(scope.row)"
>查看</el-button>
<el-button
v-has-permi="hasUpdatePerm"
:class="commonField.updateClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="handleUpdate(scope.row)"
>编辑</el-button>
<el-button
:class="commonField.resetPasClass"
:type="commonField.typeParent"
:size="commonField.size"
@click="removeCourse(scope.row)"
>删除</el-button>
<!-- <el-button type="text" @click="handleView(scope.row)">查看</el-button>-->
</template>
</el-table-column>
</el-table>
</div>
<pagination
:key="pageKey"
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.rows"
@pagination="loadData"
/>
<footer />
</div>
</div>
</template>
<script>
import commonField from '@/utils/commonField'
import {
delSysContentNewsInformation,
listSysContentNewsInformation, updateStatus
} from '@/api/contentManagement/sysContentNewsInformation'
import { updateResponseUrl } from '@/utils/updateUrl'
import { error } from 'autoprefixer/lib/utils'
import { parseTime } from '@/utils'
import { getDataCache, setDataCache } from '@/assets/js/filterData'
export default {
name: 'Index',
// components: {
// CurCat
// },
data() {
return {
pageKey: 0,
hasAddPerm: ['sys:contentNewsInformation:add'],
hasUpdatePerm: ['sys:contentNewsInformation:update'],
hasDetailPerm: ['sys:contentNewsInformation:query'],
imageSrc: require('@/assets/image/test.png'),
// 显示开关
showSwitch: {
courseContent: true,
curCat: false
},
// 对话框
dialogFormVisible: false,
dialogVisible: false,
// 新增课程
form: {
id: '',
name: '',
couDire: '',
credit: 0,
totalStuHours: 0
},
// 课程方向
courseDirection: [],
formLabelWidth: '90px',
// 表格
tableData: [],
lineindex: 0,
teacode: '',
// edit form
labelPosition: 'right',
formLabelAlign: {
id: '',
region: '',
couDire: '',
credit: 0,
totalStuHours: 0
},
// 日期范围
dateRange: [],
// 板块选择框
plateOptions: [
{
label: '板块一',
value: '1'
},
{
label: '板块二',
value: '2'
},
{
label: '板块三',
value: '3'
}
],
// 发布状态
releaseStatusOptions: [
{
label: '已发布',
value: '1'
},
{
label: '未发布',
value: '0'
}
],
// 上传提交
uploadList: {
fm: ''
},
// search area
courseid: '',
coursename: '',
queryParams: {
page: 1,
rows: 10,
flag: ''
},
// pagination
total: 0,
actionUrl: '',
filelist: [],
bussid: [],
fullscreenLoading: false,
curCatForm: {
},
tableDataTips: '加载中'
}
},
computed: {
commonField() {
return commonField
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
setDataCache(this.$route.path, this.queryParams)
next()
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.path === '/contentManagement/newsInformation/info/detail' ||
from.path === '/contentManagement/newsInformation/info/index' ||
from.path === '/contentManagement/newsInformation/info/update') {
vm.queryParams.page = JSON.parse(getDataCache(vm.$route.path)).page
setTimeout(() => {
vm.loadData()
},500)
}
})
},
created() {
// this.queryParams.page = JSON.parse(getDataCache(this.$route.path)).page
// console.log('11111', this.$store.getters.type)
// console.log('url:', window.location.href)
},
mounted: function() {
this.loadData()
},
methods: {
step(index) {
return 'step' + index
},
changPlate(data) {
if (data === '1') {
return '板块一'
}
if (data === '2') {
return '板块二'
}
if (data === '3') {
return '板块三'
}
},
/**
* @description: 点击蒙版关闭预览图片
* @author: gaoyu
* @param: imageId
* @return:
**/
handleClickStop(imageId) {
this.$nextTick(() => {
var domImageView = document.querySelector(`#${this.step(imageId)} .el-image-viewer__mask`)
if (!domImageView) {
return
}
var closeButton = document.querySelector(`#${this.step(imageId)} .el-image-viewer__close`)
domImageView.addEventListener('click', () => {
closeButton.click()
})
})
},
// 日期格式转换
replace(time) {
return parseTime(time, '{y}/{m}/{d}/{h}:{i}')
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
page: 1,
rows: 10,
flag: ''
}
this.dateRange = []
this.loadData()
},
handleChangeTime() {
if (this.dateRange && this.dateRange !== '' && this.dateRange !== undefined && this.dateRange.length > 0) {
this.queryParams.beginTime = this.dateRange[0] + ' 00:00:00'
this.queryParams.endTime = this.dateRange[1] + ' 23:59:59'
} else {
this.queryParams.beginTime = ''
this.queryParams.endTime = ''
}
},
loadData() {
// 列表渲染数据
var data = []
const _this = this
this.tableData = []
_this.fullscreenLoading = true
const params = {
page: _this.queryParams.page,
rows: _this.queryParams.rows,
flag: _this.queryParams.flag,
// plate: _this.queryParams.plate,
beginTime: _this.queryParams.beginTime,
endTime: _this.queryParams.endTime
}
listSysContentNewsInformation(params).then(response => {
if (this.$store.getters.type === '1') { // 开启
// 遍历rows
for (var i = 0; i < response.rows.length; i++) {
if (response.rows[i].path !== undefined) { // rows里的数据是path
const newUrl = updateResponseUrl(response.rows[i].path)
response.rows[i].path = newUrl
}
if (response.rows[i].url !== undefined) { // rows里的数据是url
const newUrl = updateResponseUrl(response.rows[i].url)
response.rows[i].url = newUrl
}
if (response.rows[i].avatarUrl !== undefined) { // rows里的数据是avatarUrl
const newUrl = updateResponseUrl(response.rows[i].avatarUrl)
response.rows[i].avatarUrl = newUrl
}
}
}
// console.log('res.rows:', res.rows)
_this.total = response.total// 总记录数
_this.bussid = []
response.rows.forEach(item => {
item.srclist = []
item.srclist.push(item.pictureId)
})
_this.tableData = response.rows
_this.fullscreenLoading = false
if (response.rows.length === 0) {
_this.tableDataTips = '暂无数据'
}
this.pageKey++
}).catch(function() {
_this.fullscreenLoading = false
console.log(error)
})
_this.dataIsReady = true
_this.uploadList.fm = this.interfaceUrl + 'BLesson/picImport'
},
// 修改状态
handleStatusChange(row) {
const text = row.flag === '1' ? '启用' : '停用'
const params = {
businessId: row.businessId,
flag: row.flag
}
this.$confirm('是否确认操作?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return updateStatus(params)
}).then(() => {
this.$message({
message: text + '成功',
type: 'success'
})
}).catch(function() {
row.flag = row.flag === '0' ? '1' : '0'
})
},
handleExamination(data) {
console.log('data', data)
this.$router.push({
path: '/courseInformation/examinationManagement/index',
query: {
bussinessId: '0bfc7e40e2784ea9a7de7c6e6f07d93e',
name: '测试'
}
})
},
/** 新增按钮操作 */
handleAdd() {
this.$router.push({
path: '/contentManagement/newsInformation/info/index',
query: {
isOperation: '1',
title: '新增新闻'
}
})
},
/** 修改按钮操作 */
handleUpdate(row) {
console.log('我是修改')
this.$router.push({
path: '/contentManagement/newsInformation/info/update',
query: {
isOperation: '2',
bussinessId: row.businessId,
title: ' 编辑新闻 '
}
})
},
/** 删除按钮操作 */
removeCourse(row) {
const id = row.businessId
this.$confirm('是否确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return delSysContentNewsInformation(id)
}).then(() => {
this.loadData()
this.$message({
message: '删除成功',
type: 'success'
})
})
},
/**
* @description: 查看
* @author: gaoyu
* @param:
* @return:
**/
handleView(row) {
this.$router.push({
path: '/contentManagement/newsInformation/info/detail',
query: {
isOperation: '3',
bussinessId: row.businessId,
title: ' 查看新闻 '
}
})
},
// 封面图片预览
justEnter(event) {
},
justOut(event) {
}
}
}
</script>
<style lang="scss" scoped>
#courseManage{
/*width:calc(100% - 30px);*/
/*height:calc(100% - 60px);*/
}
.courseContent{
/*padding-left: 15px;*/
width:100%;
height:100%;
::v-deep .el-table th .cell{
justify-content: left!important;
}
::v-deep .el-table td .cell{
margin: 10px 0 10px 0;
text-align: left!important;
}
}
#courseManage .table_box{
margin:0;
height:calc(100% - 175px);
}
#courseManage .el-table{height:100%;}
#courseManage .el-table__body-wrapper{
height:calc(100% - 40px);
overflow-x:hidden;
overflow-y:auto;
}
#courseManage .pages{margin-top:15px;}
#courseManage .breadNav{margin-left:0;}
#courseManage .search_area{margin:1em 0;}
#courseManage .info_change{margin-left:0;}
#courseManage .search_area div{width:190px;}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {-webkit-appearance: none;}
input[type="number"]{-moz-appearance: textfield;}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none !important;
margin: 0;
}
</style>
<template>
<div class="shiftInformation_update">
<div class="updateContainer">
<div class="topTitle">
<span class="topTitleText">{{ title }}</span>
</div>
<div class="twoTitle">
<el-tag v-if="form.flag==='1'" type="success">已发布</el-tag>
</div>
<div class="updateBoby">
<el-form ref="deviceFormRef" :model="form" :rules="rules" label-position="right" label-width="auto">
<el-row>
<el-col :span="24">
<el-form-item
label="标题:"
prop="title"
:rules="{ required: !(controls.isOperation === '3'), message: '请输入标题', trigger: 'blur' }"
>
<el-input
v-model.trim="form.title"
:disabled="secondFromDisabled"
placeholder="请输入标题"
size="small"
class="normalInput"
:maxlength="100"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<!-- <el-col :span="12">-->
<!-- &lt;!&ndash; 是否为头条新闻&ndash;&gt;-->
<!-- <el-form-item-->
<!-- label="是否为头条新闻:"-->
<!-- prop="isForntPage"-->
<!-- :rules="{ required: !(controls.isOperation === '3'), message: '请选择是否为头条新闻', trigger: 'blur' }"-->
<!-- >-->
<!-- <el-select v-model="form.isForntPage" placeholder="请选择是否为头条新闻" size="small" class="normalInput" :disabled="secondFromDisabled">-->
<!-- <el-option v-for="item in isList" :key="item.value" :label="item.label" :value="item.value" />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="12">
<!-- 是否推荐-->
<el-form-item
label="是否为推荐新闻:"
prop="isRecommended"
:rules="{ required: !(controls.isOperation === '3'), message: '请选择是否推荐新闻', trigger: 'change' }"
>
<el-select v-model="form.isRecommended" placeholder="请选择是否推荐新闻" size="small" class="normalInput" :disabled="secondFromDisabled">
<el-option v-for="item in isList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<!-- 是否置顶-->
<el-form-item
label="是否为置顶新闻:"
prop="isTop"
:rules="{ required: !(controls.isOperation === '3'), message: '请选择是否置顶新闻', trigger: 'change' }"
>
<el-select v-model="form.isTop" placeholder="请选择是否置顶新闻" size="small" class="normalInput" :disabled="secondFromDisabled">
<el-option v-for="item in isList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item
label="发布日期:"
prop="releaseDate"
:rules="{ required: !(controls.isOperation === '3'), message: '请选择发布日期', trigger: 'blur' }"
>
<el-date-picker
v-model="form.releaseDate"
type="date"
placeholder="选择发布日期"
:disabled="secondFromDisabled"
size="small"
class="normalInput"
value-format="yyyy-MM-dd"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="封面:">
<el-upload
accept=".png,.jpg,.jpeg,.PNG,.JPG,.JPEG"
:disabled="secondFromDisabled"
class="avatar-uploader"
action="#"
:http-request="handleUpload"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img v-if="imageUrl" :src="imageUrl" style="height: 200px;width: 200px">
<i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item
label="新闻摘要:"
prop="remarks"
:rules="{ required: !(controls.isOperation === '3'), message: '请输入新闻简介', trigger: 'blur' }"
>
<el-input
v-model.trim="form.remarks"
type="textarea"
:disabled="secondFromDisabled"
placeholder="请输入新闻摘要"
size="small"
rows="3"
class="normalInput"
:maxlength="300"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item
label="新闻内容:"
prop="details"
:rules="{ required: !(controls.isOperation === '3'), message: '请输入新闻内容', trigger: 'blur' }"
>
<vue-editor id="editorsay" v-model="form.details" :useCustomImageHandler="true" :editor-toolbar="customToolbar" :disabled="secondFromDisabled" @blur="queryRules" @image-added="handleImageAdded" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</div>
<!-- 按钮区 -->
<div class="btn-box">
<el-button v-if="controls.isOperation !== '3'" style="width: 80px; height: 40px;font-size: 16px; width: 138px;height: 38px " @click="submit">保存
</el-button>
<el-button v-if="controls.isOperation !== '3'" style="width: 80px; height: 40px;font-size: 16px; width: 138px;height: 38px " type="primary" :loading="pubLoading" @click="publish">发布
</el-button>
<el-button v-if="controls.isOperation === '3'" style="width: 80px; height: 40px;font-size: 16px; width: 138px;height: 38px " @click="goBack">返回
</el-button>
</div>
</div>
</template>
<script >
import {
addSysContentNewsInformation,
getSysContentNewsInformation, updateSysContentNewsInformation
} from '@/api/contentManagement/sysContentNewsInformation'
import {updatePagesRes, updateRes, updateResonseUrl, updateResponseUrl} from '@/utils/updateUrl'
import { VueEditor } from 'vue2-editor'
import { uploadPublic } from '@/api/contentManagement/sysContest'
export default {
components: {
VueEditor
},
data() {
return {
title: '新增新闻',
pubLoading: false,
businessId: null,
// 变更字段存储数组
formChanges: [],
// 板块选择框
plateOptions: [
{
label: '板块一',
value: '1'
},
{
label: '板块二',
value: '2'
},
{
label: '板块三',
value: '3'
}
],
customToolbar: [
['bold', 'italic', 'underline', 'strike'], // 加粗 斜体 下划线 删除线 -----['bold', 'italic', 'underline', 'strike']
['blockquote', 'code-block'], // 引用 代码块-----['blockquote', 'code-block']
[{ list: 'ordered' }, { list: 'bullet' }], // 有序、无序列表-----[{ list: 'ordered' }, { list: 'bullet' }]
[{ header: 1 }, { header: 2 }],
[{ script: 'sub' }, { script: 'super' }], // 上标/下标-----[{ script: 'sub' }, { script: 'super' }]
[{ indent: '-1' }, { indent: '+1' }],
[{ size: [] }], // 配置字号
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题-----[{ header: [1, 2, 3, 4, 5, 6, false] }]
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色-----[{ color: [] }, { background: [] }]
[{ font: [] }], // 显示字体选择
[{ align: [] }], // 对齐方式-----[{ align: [] }]
['clean'], // 清除文本格式-----['clean']
['image'] // 链接、图片、视频-----['link', 'image', 'video']
],
imageUrl: '',
// 控制表单
controls: {
// 1:代表新增 2:代表编辑 3:代表查看
isOperation: '1'
},
// 是否List
isList: [
{
label: '是',
value: 1
},
{
label: '否',
value: 0
}
],
fileUpload: '/dev-api/common/fileUpload?file=' + this.file + '&temp=' + 'newsInformation',
// 提交表单
form: {
// 主表id
businessId: undefined,
createBy: undefined,
createDate: undefined,
deptId: undefined,
deptTwoId: undefined,
equipmentName: undefined,
flag: undefined,
photoossId: undefined,
remarks: undefined,
weight: undefined,
// isForntPage: undefined,
isRecommended: undefined,
isTop: undefined
},
// 状态
statusOptions: [
{
label: '启用',
value: '1'
},
{
label: '停用',
value: '0'
}
],
// 校验规则
rules: {
startDateS: [],
endDateS: []
}
}
},
computed: {
// 第一种禁用情况 1.查看的情况
secondFromDisabled() {
return (this.controls.isOperation === '3')
}
},
mounted() {
this.businessId = this.$route.query.bussinessId
this.title = this.$route.query.title
this.getIsOperation()
this.getDetail()
},
created() {
},
methods: {
queryRules() {
console.log('111111111111')
this.$refs.deviceFormRef.validateField('details')
},
/**
* @description: 处理上传接口
* @author: gaoyu
* @param:
* @return:
**/
handleUpload(file) {
const formData = new FormData()
formData.append('file', file.file)
formData.append('temp', 'newInformation')
uploadPublic(formData).then(res => {
this.form.pictureId = res.data.businessId
this.imageUrl = res.data.url
})
},
handleImageAdded(file, Editor, cursorLocation, reseter) {
const formData = new FormData()
formData.append('file', file)
formData.append('temp', 'newInformation')
uploadPublic(formData).then(res => {
console.log('handleImageAdded', res)
const url = res.data.url
Editor.insertEmbed(cursorLocation, 'image', url)
})
// var formData = new FormData()
// formData.append('image', file)
// $http.post(this.$common.baseUrl + 'upload/image', formData).then(res => {
// const data = res.body
// if (data.code == 200) {
// const url = data.data.url
// Editor.insertEmbed(cursorLocation, 'image', url)
// resetUploader()
// } else { }
// })
},
// 查询详情
getDetail() {
console.log('查询详情')
if (this.$route.query.bussinessId) {
getSysContentNewsInformation(this.$route.query.bussinessId).then(response => {
if (response.code === 200) {
// 处理data数据里的url
if (this.$store.getters.type === '1') { // 开启
if (response.data.path !== undefined) {
const newUrl = updateResponseUrl(response.data.path)
response.data.path = newUrl
}
if (response.data.url !== undefined) {
const newUrl = updateResponseUrl(response.data.url)
response.data.url = newUrl
}
if (response.data.avatarUrl !== undefined) {
const newUrl = updateResponseUrl(response.data.avatarUrl)
response.data.avatarUrl = newUrl
}
}
// console.log('res.data:', res.data)
this.form = response.data
this.imageUrl = response.data.path
}
})
}
},
handleAvatarSuccess(res, file) {
console.log('res', res)
this.imageUrl = URL.createObjectURL(file.raw)
this.form.pictureId = res.data.businessId
},
beforeAvatarUpload(file) {
// 判断文件是否为图片类型
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
const isLt2M = file.size / 1024 / 1024 < 2
if (!isJPG) {
this.$message.error('只能上传图片格式的文件!')
return false
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 2MB!')
return false
}
this.file = file
},
goBack() {
this.$router.push({
path: '/contentManagement/newsInformation/index'
})
},
// 判断要进行什么操作 isOperation值 1:新增 2:编辑 3:查看
getIsOperation() {
if (this.$route.query.isOperation) {
this.controls.isOperation = this.$route.query.isOperation
}
},
// 保存方法
submit() {
// 拷贝form
const form = JSON.parse(JSON.stringify(this.form))
// 转换时间格式
this.$refs.deviceFormRef.validate(valid => {
if (valid) {
if (this.form.businessId !== undefined) {
// 编辑
updateSysContentNewsInformation(form).then(res => {
if (res.code === 200) {
this.$message({
message: '保存成功',
type: 'success'
})
this.$router.push({
path: '/contentManagement/newsInformation/index'
})
}
})
} else {
addSysContentNewsInformation(form).then(res => {
if (res.code === 200) {
this.$message({
message: '保存成功',
type: 'success'
})
this.$router.push({
path: '/contentManagement/newsInformation/index'
})
}
})
}
}
})
},
// 发布方法
publish() {
// 拷贝form
const form = JSON.parse(JSON.stringify(this.form))
// 转换时间格式
this.pubLoading = true
this.$refs.deviceFormRef.validate(valid => {
if (valid) {
if (this.form.businessId !== undefined) {
// 编辑
form.flag = '1'
updateSysContentNewsInformation(form).then(res => {
if (res.code === 200) {
this.$message({
message: '保存成功',
type: 'success'
})
this.pubLoading = false
this.$router.push({
path: '/contentManagement/newsInformation/index'
})
}
}).catch(() => {
this.pubLoading = false
})
} else {
form.flag = '1'
addSysContentNewsInformation(form).then(res => {
if (res.code === 200) {
this.$message({
message: '保存成功',
type: 'success'
})
this.pubLoading = false
this.$router.push({
path: '/contentManagement/newsInformation/index'
})
}
}).catch(() => {
this.pubLoading = false
})
}
} else {
this.pubLoading = false
}
})
}
}
}
</script>
<style scoped lang="scss">
::v-deep.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
::v-deep.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
::v-deep.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
::v-deep.avatar {
width: 178px;
height: 178px;
display: block;
}
.btn-box{
margin-top: 50px;
margin-bottom: 30px;
//position: absolute;
//bottom: 50px;
}
.shiftInformation_update {
background-color: rgba(243, 243, 255, 1);
width: 98%;
margin-left: 1%;
display: flex;
flex-wrap: wrap;
align-items: baseline;
justify-content: space-evenly;
.normalInput {
width: 100%;
background: #F9F9F9;
border-radius: 5px;
}
.updateContainer {
width: 100%;
border-radius: 6px;
.updateBoby {
padding: 0 40px 0 40px;
width: 100%;
margin-top: 40px;
}
.topTitle {
text-align: center;
padding-top: 30px;
}
.topTitleText{
font-size: 24px;
font-weight: bold;
color: #333333;
line-height: 24px;
}
.twoTitle {
text-align: center;
padding-top: 20px;
}
.twoTitleText{
font-size: 16px;
font-weight: bold;
color: green;
line-height: 24px;
}
}
.buttonArea {
justify-content: end;
align-items: end;
display: flex;
height: 500px;
width: 82%;
.alter {
border-radius: 6px;
background-color: rgba(52, 51, 153, 1);
color: rgba(255, 255, 255, 1);
font-size: 14px;
}
.Back {
border-radius: 6px;
background-color: rgba(255, 255, 255, 1);
border: 1px solid rgba(52, 51, 153, 1);
color: rgba(52, 51, 153, 1)
}
}
.applicationDialog {
.right-section {
margin-left: 20px;
}
.left-scrollable-area{
overflow: auto;
height: 170px;
}
.scrollable-area{
overflow: auto;
height: 213px;
}
.left-section {
width: 98%;
}
}
}
</style>
......@@ -295,7 +295,7 @@ export default {
getList() {
this.loading = true
list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
if (response.rows !== undefined){
if (response.rows !== undefined) {
this.list = response.rows.map(item => {
const title = item.title
if (title) {
......
......@@ -340,21 +340,21 @@ export default {
getList() {
this.loading = true
list(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
if (response.rows !== undefined) {
this.list = response.rows.map(item => {
const title = item.title
if (title) {
const temp = title.split('-')
const systemMode = temp.filter((item, index) => { return index < temp.length - 1 }).join('-')
item.systemMode = systemMode
item.optionName = temp[temp.length - 1]
} else {
item.systemMode = undefined
item.optionName = undefined
}
return item
})
}
if (response.rows !== undefined) {
this.list = response.rows.map(item => {
const title = item.title
if (title) {
const temp = title.split('-')
const systemMode = temp.filter((item, index) => { return index < temp.length - 1 }).join('-')
item.systemMode = systemMode
item.optionName = temp[temp.length - 1]
} else {
item.systemMode = undefined
item.optionName = undefined
}
return item
})
}
this.total = response.total
this.loading = false
}
......
......@@ -257,7 +257,7 @@
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<div slot="footer" class="dialog-footer">
<el-button class="cancelBtn" @click="cancel">取 消</el-button>
<el-button class="submitBtn" type="primary" @click="submitForm">确 定</el-button>
</div>
......@@ -447,7 +447,7 @@ export default {
isProcess: '1',
flag: '0'
}
this.resetForm('form')
// this.resetForm('form')
},
/** 查询按钮操作 */
handleQuery() {
......
......@@ -61,7 +61,8 @@ module.exports = {
[process.env.VUE_APP_BASE_API]: {
// target: `http://49.232.167.247:20014/`,
// target: `http://192.168.10.185:8084/`,
target: `http://106.3.97.198:20062/`,
// target: `http://106.3.97.198:20062/`,
target: `http://localhost:8082/`,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
......
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