Commit 53901a16 by Lyan

图片资讯页面

parent 3c096382
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
*/ */
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import http from '@/utils/httpRequest' // import http from '@/utils/httpRequest'
import { isURL } from '@/utils/validate' import { isURL } from '@/utils/validate'
import { clearLoginInfo } from '@/utils' import { clearLoginInfo } from '@/utils'
import { menuData } from '@/utils/routerdata'
Vue.use(Router) Vue.use(Router)
...@@ -34,9 +35,9 @@ const mainRoutes = { ...@@ -34,9 +35,9 @@ const mainRoutes = {
// 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否 // 2. iframeUrl: 是否通过iframe嵌套展示内容, '以http[s]://开头': 是, '': 否
// 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理! // 提示: 如需要通过iframe嵌套展示内容, 但不通过tab打开, 请自行创建组件使用iframe处理!
{ path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页' } }, { path: '/home', component: _import('common/home'), name: 'home', meta: { title: '首页' } },
{ path: '/theme', component: _import('common/theme'), name: 'theme', meta: { title: '主题' } }, { path: '/theme', component: _import('common/theme'), name: 'theme', meta: { title: '主题' } }
{ path: '/demo-echarts', component: _import('demo/echarts'), name: 'demo-echarts', meta: { title: 'demo-echarts', isTab: true } }, // { path: '/demo-echarts', component: _import('demo/echarts'), name: 'demo-echarts', meta: { title: 'demo-echarts', isTab: true } }
{ path: '/demo-ueditor', component: _import('demo/ueditor'), name: 'demo-ueditor', meta: { title: 'demo-ueditor', isTab: true } } // { path: '/demo-ueditor', component: _import('demo/ueditor'), name: 'demo-ueditor', meta: { title: 'demo-ueditor', isTab: true } }
], ],
beforeEnter (to, from, next) { beforeEnter (to, from, next) {
let token = Vue.cookie.get('token') let token = Vue.cookie.get('token')
...@@ -62,166 +63,10 @@ router.beforeEach((to, from, next) => { ...@@ -62,166 +63,10 @@ router.beforeEach((to, from, next) => {
if (router.options.isAddDynamicMenuRoutes || fnCurrentRouteType(to, globalRoutes) === 'global') { if (router.options.isAddDynamicMenuRoutes || fnCurrentRouteType(to, globalRoutes) === 'global') {
next() next()
} else { } else {
console.log(http) fnAddDynamicMenuRoutes(menuData.navDataList)
var navDataList = [
{
'menuId': 1,
'parentId': 0,
'parentName': null,
'name': '系统管理',
'url': null,
'perms': null,
'type': 0,
'icon': 'system',
'orderNum': 0,
'open': null,
'list': [
{
'menuId': 2,
'parentId': 1,
'parentName': null,
'name': '管理员列表',
'url': 'sys/user',
'perms': null,
'type': 1,
'icon': 'admin',
'orderNum': 1,
'open': null,
'list': null
},
{
'menuId': 3,
'parentId': 1,
'parentName': null,
'name': '角色管理',
'url': 'sys/role',
'perms': null,
'type': 1,
'icon': 'role',
'orderNum': 2,
'open': null,
'list': null
},
{
'menuId': 4,
'parentId': 1,
'parentName': null,
'name': '菜单管理',
'url': 'sys/menu',
'perms': null,
'type': 1,
'icon': 'menu',
'orderNum': 3,
'open': null,
'list': null
},
{
'menuId': 5,
'parentId': 1,
'parentName': null,
'name': 'SQL监控',
'url': 'http://localhost:8080/renren-fast/druid/sql.html',
'perms': null,
'type': 1,
'icon': 'sql',
'orderNum': 4,
'open': null,
'list': null
},
{
'menuId': 6,
'parentId': 1,
'parentName': null,
'name': '定时任务',
'url': 'job/schedule',
'perms': null,
'type': 1,
'icon': 'job',
'orderNum': 5,
'open': null,
'list': null
},
{
'menuId': 27,
'parentId': 1,
'parentName': null,
'name': '参数管理',
'url': 'sys/config',
'perms': 'sys:config:list,sys:config:info,sys:config:save,sys:config:update,sys:config:delete',
'type': 1,
'icon': 'config',
'orderNum': 6,
'open': null,
'list': null
},
{
'menuId': 30,
'parentId': 1,
'parentName': null,
'name': '文件上传',
'url': ' ',
'perms': 'sys:oss:all',
'type': 1,
'icon': 'oss',
'orderNum': 6,
'open': null,
'list': null
},
{
'menuId': 29,
'parentId': 1,
'parentName': null,
'name': '系统日志',
'url': 'sys/log',
'perms': 'sys:log:list',
'type': 1,
'icon': 'log',
'orderNum': 7,
'open': null,
'list': null
}
]
}
]
var permissions = [
'sys:schedule:info',
'sys:menu:update',
'sys:menu:delete',
'sys:config:info',
'sys:menu:list',
'sys:config:save',
'sys:config:update',
'sys:schedule:resume',
'sys:user:delete',
'sys:config:list',
'sys:user:update',
'sys:role:list',
'sys:menu:info',
'sys:menu:select',
'sys:schedule:update',
'sys:schedule:save',
'sys:role:select',
'sys:user:list',
'sys:menu:save',
'sys:role:save',
'sys:schedule:log',
'sys:role:info',
'sys:schedule:delete',
'sys:role:update',
'sys:schedule:list',
'sys:user:info',
'sys:schedule:run',
'sys:config:delete',
'sys:role:delete',
'sys:user:save',
'sys:schedule:pause',
'sys:log:list',
'sys:oss:all'
]
fnAddDynamicMenuRoutes(navDataList)
router.options.isAddDynamicMenuRoutes = true router.options.isAddDynamicMenuRoutes = true
sessionStorage.setItem('menuList', JSON.stringify(navDataList || '[]')) sessionStorage.setItem('menuList', JSON.stringify(menuData.navDataList || '[]'))
sessionStorage.setItem('permissions', JSON.stringify(permissions || '[]')) sessionStorage.setItem('permissions', JSON.stringify(menuData.permissions || '[]'))
next({ ...to, replace: true }) next({ ...to, replace: true })
// http({ // http({
......
/**
* 动态路由
*/
export const menuData = {
navDataList: [
{
'menuId': 1,
'parentId': 0,
'parentName': null,
'name': '资讯管理',
'url': null,
'perms': null,
'type': 0,
'icon': null,
'orderNum': 0,
'open': null,
'list': [
{
'menuId': 2,
'parentId': 1,
'parentName': null,
'name': '图片资讯',
'url': 'info/picture',
'perms': 'manage:picture:save',
'type': 1,
'icon': null,
'orderNum': 1,
'open': null,
'list': null
}
// {
// 'menuId': 3,
// 'parentId': 1,
// 'parentName': null,
// 'name': '角色管理',
// 'url': 'sys/role',
// 'perms': 'sys:user:save',
// 'type': 1,
// 'icon': 'role',
// 'orderNum': 2,
// 'open': null,
// 'list': null
// },
// {
// 'menuId': 4,
// 'parentId': 1,
// 'parentName': null,
// 'name': '菜单管理',
// 'url': 'sys/menu',
// 'perms': null,
// 'type': 1,
// 'icon': 'menu',
// 'orderNum': 3,
// 'open': null,
// 'list': null
// },
// {
// 'menuId': 5,
// 'parentId': 1,
// 'parentName': null,
// 'name': 'SQL监控',
// 'url': 'http://localhost:8080/renren-fast/druid/sql.html',
// 'perms': null,
// 'type': 1,
// 'icon': 'sql',
// 'orderNum': 4,
// 'open': null,
// 'list': null
// },
// {
// 'menuId': 6,
// 'parentId': 1,
// 'parentName': null,
// 'name': '定时任务',
// 'url': 'job/schedule',
// 'perms': null,
// 'type': 1,
// 'icon': 'job',
// 'orderNum': 5,
// 'open': null,
// 'list': null
// },
// {
// 'menuId': 27,
// 'parentId': 1,
// 'parentName': null,
// 'name': '参数管理',
// 'url': 'sys/config',
// 'perms': 'sys:config:delete',
// 'type': 1,
// 'icon': 'config',
// 'orderNum': 6,
// 'open': null,
// 'list': null
// },
// {
// 'menuId': 30,
// 'parentId': 1,
// 'parentName': null,
// 'name': '文件上传',
// 'url': ' ',
// 'perms': 'sys:oss:all',
// 'type': 1,
// 'icon': 'oss',
// 'orderNum': 6,
// 'open': null,
// 'list': null
// },
// {
// 'menuId': 29,
// 'parentId': 1,
// 'parentName': null,
// 'name': '系统日志',
// 'url': 'sys/log',
// 'perms': 'sys:log:list',
// 'type': 1,
// 'icon': 'log',
// 'orderNum': 7,
// 'open': null,
// 'list': null
// }
]
}
],
permissions: [
'manage:picture:save',
'manage:picture:delete'
]
}
...@@ -91,22 +91,23 @@ ...@@ -91,22 +91,23 @@
}, },
// 退出 // 退出
logoutHandle () { logoutHandle () {
this.$confirm(`确定进行[退出]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/sys/logout'),
method: 'post',
data: this.$http.adornData()
}).then(({data}) => {
if (data && data.code === 0) {
clearLoginInfo() clearLoginInfo()
this.$router.push({ name: 'login' }) // this.$confirm(`确定进行[退出]操作?`, '提示', {
} // confirmButtonText: '确定',
}) // cancelButtonText: '取消',
}).catch(() => {}) // type: 'warning'
// }).then(() => {
// this.$http({
// url: this.$http.adornUrl('/sys/logout'),
// method: 'post',
// data: this.$http.adornData()
// }).then(({data}) => {
// if (data && data.code === 0) {
// clearLoginInfo()
// this.$router.push({ name: 'login' })
// }
// })
// }).catch(() => {})
} }
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
:collapse="sidebarFold" :collapse="sidebarFold"
:collapseTransition="false" :collapseTransition="false"
class="site-sidebar__menu"> class="site-sidebar__menu">
<el-menu-item index="home" @click="$router.push({ name: 'home' })"> <!-- <el-menu-item index="home" @click="$router.push({ name: 'home' })">
<icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg> <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg>
<span slot="title">首页</span> <span slot="title">首页</span>
</el-menu-item> </el-menu-item>
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<icon-svg name="editor" class="site-sidebar__menu-icon"></icon-svg> <icon-svg name="editor" class="site-sidebar__menu-icon"></icon-svg>
<span slot="title">ueditor</span> <span slot="title">ueditor</span>
</el-menu-item> </el-menu-item>
</el-submenu> </el-submenu> -->
<sub-menu <sub-menu
v-for="menu in menuList" v-for="menu in menuList"
:key="menu.menuId" :key="menu.menuId"
......
<template>
<el-dialog
:title="!dataForm.pictureid ? '新增' : '修改'"
:close-on-click-modal='false'
:visible.sync='visible'
>
<el-form
:model='dataForm'
:rules='dataRule'
ref='dataForm'
@keyup.enter.native='dataFormSubmit()'
label-width='80px'
>
<el-form-item label='标题' prop='title'>
<el-input v-model='dataForm.title' placeholder='请输入标题'></el-input>
</el-form-item>
<el-form-item label='类别' prop='pictureType'>
<el-select v-model="dataForm.pictureType" placeholder="请选择类别">
<el-option
v-for="item in pictureTypeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label='图片地址' prop='picFile'>
<el-upload
class="avatar-uploader"
action=""
:show-file-list="false"
:on-success="handleAvatarSuccess"
:http-request="Upload"
:before-upload="beforeAvatarUpload">
<img v-if="dataForm.picFile" :src="dataForm.picFile" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
<!-- <el-input v-model='dataForm.picFile' placeholder='图片地址'></el-input> -->
</el-form-item>
<el-form-item label='级别' prop='piclevel'>
<el-input v-model='dataForm.piclevel' placeholder='请输入级别'></el-input>
</el-form-item>
<el-form-item label='关键字' prop='keyword'>
<el-input v-model='dataForm.keyword' placeholder='请输入关键字'></el-input>
</el-form-item>
<el-form-item label='跳转路径' prop='jumppath'>
<el-input v-model='dataForm.jumppath' placeholder='请输入跳转路径'></el-input>
</el-form-item>
<el-form-item label='展示时间' prop='showtime'>
<el-input v-model='dataForm.content' placeholder='${column.comments}'></el-input>
</el-form-item>
</el-form>
<span slot='footer' class='dialog-footer'>
<el-button @click='visible = false'>取消</el-button>
<el-button type='primary' @click='dataFormSubmit()'>确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
title: '',
pictureType: '',
picFile: '',
editor: '',
piclevel: '',
status: '',
keyword: '',
jumppath: '',
showtime: ''
},
pictureTypeList: [
{
value: '1',
label: '类型1'
}
],
dataRule: {
title: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
pictureType: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
picFile: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
editor: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
piclevel: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
status: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
keyword: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
jumppath: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
],
showtime: [
{
required: true,
message: '不能为空',
trigger: 'blur'
}
]
},
imgUrl: new FormData()
}
},
methods: {
init (id) {
this.dataForm.pictureid = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.pictureid) {
this.$http({
url: this.$http.adornUrl(
`/office/picture/info/${this.dataForm.pictureid}`
),
method: 'get',
params: this.$http.adornParams()
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataForm.title = data.picture.title
this.dataForm.pictureType = data.picture.pictureType
this.dataForm.picFile = data.picture.picFile
this.dataForm.minPicFile = data.picture.minPicFile
this.dataForm.editor = data.picture.editor
this.dataForm.inputdate = data.picture.inputdate
this.dataForm.piclevel = data.picture.piclevel
this.dataForm.status = data.picture.status
this.dataForm.keyword = data.picture.keyword
this.dataForm.jumppath = data.picture.jumppath
this.dataForm.content = data.picture.content
this.dataForm.articleId = data.picture.articleId
this.dataForm.showtime = data.picture.showtime
this.dataForm.auditor = data.picture.auditor
this.dataForm.lasteditor = data.picture.lasteditor
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate(valid => {
if (valid) {
this.$http({
url: this.$http.adornUrl(
`/manage/picture/${!this.dataForm.pictureid ? 'save' : 'update'}`
),
method: 'post',
data: this.$http.adornData({
pictureid: this.dataForm.pictureid || undefined,
title: this.dataForm.title,
pictureType: this.dataForm.pictureType,
picFile: this.dataForm.picFile,
editor: this.dataForm.editor,
piclevel: this.dataForm.piclevel,
status: this.dataForm.status,
keyword: this.dataForm.keyword,
jumppath: this.dataForm.jumppath,
showtime: this.dataForm.showtime
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
},
// 图片成功
handleAvatarSuccess (res, file) {
this.dataForm.picFile = URL.createObjectURL(file.raw)
},
// 上传之前校验
beforeAvatarUpload (file) {
const isJPG = file.type === 'image/jpeg'
const isPNG = file.type === 'image/png'
const isLt2M = file.size / 1024 / 1024 < 2
if (!isJPG) {
if (!isPNG) {
this.$message.error('上传图片只能是 JPG, PNG 格式!')
}
}
if (!isLt2M) {
this.$message.error('上传头像图片大小不能超过 2MB!')
}
if (file) {
this.imgUrl.append('file', file)
// console.log(this.imgUrl.get('file'))
}
},
Upload () {
this.$http({
url: this.$http.adornUrl('/office/file/uploadFile'),
method: 'post',
data: this.imgUrl,
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(res => {
console.log(res)
this.dataForm.picFile = res.data.data
}).catch(err => {
console.log(err)
})
}
}
}
</script>
<style scoped>
.avatar-uploader /deep/.el-upload {
border: 1px dashed #dcdfe6;
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;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
</style>
<template>
<div class="mod-config">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('manage:picture:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('manage:picture:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
border
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
style="width: 100%;">
<el-table-column
type="selection"
header-align="center"
align="center"
width="50">
</el-table-column>
<el-table-column
prop="title"
header-align="center"
align="center"
label="标题">
</el-table-column>
<el-table-column
prop="keyword"
header-align="center"
align="center"
label="关键字">
</el-table-column>
<el-table-column
prop="piclevel"
header-align="center"
align="center"
label="等级">
</el-table-column>
<el-table-column
prop="pictureType"
header-align="center"
align="center"
label="发布类型">
</el-table-column>
<el-table-column
prop="editor"
header-align="center"
align="center"
label="编辑者">
</el-table-column>
<el-table-column
prop="inputDateStart"
header-align="center"
align="center"
label="发布时间">
</el-table-column>
<el-table-column
prop="status"
header-align="center"
align="center"
label="状态">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="150"
label="操作">
<template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.pictureid)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.pictureid)">删除</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div>
</template>
<script>
import AddOrUpdate from './picture-add-or-update'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/office/picture/list'),
method: 'post',
data: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key
})
}).then(({data}) => {
if (data && data.code === 0) {
this.dataList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
// 多选
selectionChangeHandle (val) {
this.dataListSelections = val
},
// 新增 / 修改
addOrUpdateHandle (id) {
this.addOrUpdateVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.id
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/office/picture/delete'),
method: 'post',
data: this.$http.adornData(ids, false)
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.getDataList()
}
})
} else {
this.$message.error(data.msg)
}
})
})
}
}
}
</script>
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