Commit efb57e1d by Lyan

后台bug修改

parent e7ff6004
......@@ -35,7 +35,8 @@ module.exports = {
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// useEslint: true,
useEslint: false,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
......
......@@ -373,6 +373,9 @@ img {
position: relative;
overflow: hidden;
}
.avatar-uploaderFile>.el-upload {
border:none
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
......
......@@ -90,7 +90,7 @@ const mainRoutes = {
],
beforeEnter (to, from, next) {
// let token = Vue.cookie.get('token')
let token = sessionStorage.getItem('token')
let token = localStorage.getItem('token')
if (!token || !/\S/.test(token)) {
clearLoginInfo()
next({ name: 'login' })
......@@ -115,8 +115,8 @@ router.beforeEach((to, from, next) => {
} else {
// fnAddDynamicMenuRoutes(menuData.navDataList)
// router.options.isAddDynamicMenuRoutes = true
// sessionStorage.setItem('menuList', JSON.stringify(menuData.navDataList || '[]'))
// sessionStorage.setItem('permissions', JSON.stringify(menuData.permissions || '[]'))
// localStorage.setItem('menuList', JSON.stringify(menuData.navDataList || '[]'))
// localStorage.setItem('permissions', JSON.stringify(menuData.permissions || '[]'))
// next({ ...to, replace: true })
http({
......@@ -127,12 +127,12 @@ router.beforeEach((to, from, next) => {
if (data && data.code === 0) {
fnAddDynamicMenuRoutes(data.menuList)
router.options.isAddDynamicMenuRoutes = true
sessionStorage.setItem('menuList', JSON.stringify(data.menuList || '[]'))
sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]'))
localStorage.setItem('menuList', JSON.stringify(data.menuList || '[]'))
localStorage.setItem('permissions', JSON.stringify(data.permissions || '[]'))
next({ ...to, replace: true })
} else {
sessionStorage.setItem('menuList', '[]')
sessionStorage.setItem('permissions', '[]')
localStorage.setItem('menuList', '[]')
localStorage.setItem('permissions', '[]')
next()
}
}).catch((e) => router.push({ name: 'login' }))
......@@ -201,7 +201,7 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
mainRoutes,
{ path: '*', redirect: { name: '404' } }
])
sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]'))
localStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]'))
console.log('\n')
console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue')
console.log(mainRoutes.children)
......
......@@ -18,7 +18,7 @@ const http = axios.create({
*/
http.interceptors.request.use(config => {
// config.headers['token'] = Vue.cookie.get('token') // 请求头带上token
config.headers['token'] = sessionStorage.getItem('token')
config.headers['token'] = localStorage.getItem('token')
return config
}, error => {
return Promise.reject(error)
......
......@@ -52,19 +52,19 @@
}
},
created () {
this.dataForm.userName = sessionStorage.getItem('username')
this.dataForm.password = sessionStorage.getItem('password')
this.dataForm.userName = localStorage.getItem('username')
this.dataForm.password = localStorage.getItem('password')
},
methods: {
// 提交表单
dataFormSubmit () {
if (this.dataForm.checked) {
sessionStorage.setItem('username', this.dataForm.userName)
sessionStorage.setItem('password', this.dataForm.password)
localStorage.setItem('username', this.dataForm.userName)
localStorage.setItem('password', this.dataForm.password)
this.submit()
} else {
sessionStorage.removeItem('username')
sessionStorage.removeItem('password')
localStorage.removeItem('username')
localStorage.removeItem('password')
this.submit()
}
},
......@@ -80,8 +80,8 @@
})
}).then(({data}) => {
if (data && data.code === 0) {
sessionStorage.setItem('token', data.token)
sessionStorage.setItem('username', this.dataForm.userName)
localStorage.setItem('token', data.token)
localStorage.setItem('username', this.dataForm.userName)
this.$router.replace({ name: 'home' })
} else {
......
......@@ -78,7 +78,7 @@
set (val) { this.$store.commit('common/updateMainTabs', val) }
},
userName: {
get () { return sessionStorage.getItem('username') }
get () { return localStorage.getItem('username') }
}
},
methods: {
......
......@@ -75,8 +75,8 @@
$route: 'routeHandle'
},
created () {
this.menuList = JSON.parse(sessionStorage.getItem('menuList') || '[]')
this.dynamicMenuRoutes = JSON.parse(sessionStorage.getItem('dynamicMenuRoutes') || '[]')
this.menuList = JSON.parse(localStorage.getItem('menuList') || '[]')
this.dynamicMenuRoutes = JSON.parse(localStorage.getItem('dynamicMenuRoutes') || '[]')
this.routeHandle(this.$route)
},
methods: {
......
<template>
<el-dialog
:title="!dataForm.id ? '新增' : this.showInfo?'详情':'修改'"
:close-on-click-modal="false"
:visible.sync="visible">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px" v-loading='loading'>
<el-form-item label='分类:' prop='announcetype'>
<el-select v-model="dataForm.announcetype" placeholder="请选择分类" clearable>
<el-option
v-for="item in typeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label='级别:' prop='levels'>
<el-select v-model="dataForm.levels" placeholder="请输入级别" v-show="!showInfo">
<el-option
v-for="item in piclevelList"
:key="item"
:label="item"
:value="item">
</el-option>
</el-select>
<p v-show="showInfo">{{dataForm.levels}}</p>
</el-form-item>
<el-form-item label="标题:" prop="title">
<el-input v-model="dataForm.title" placeholder="请输入显示标题" v-show="!showInfo"></el-input>
<p v-show="showInfo">{{dataForm.title}}</p>
</el-form-item>
<!-- <el-form-item label="跳转至:" prop="directpath">
<el-input v-model="dataForm.directpath" placeholder="请输入跳转地址" v-show="!showInfo"></el-input>
<p v-show="showInfo">{{dataForm.directpath}}</p>
</el-form-item> -->
<el-form-item label="作者:" prop="author">
<el-input v-model="dataForm.author" placeholder="请输入作者" v-show="!showInfo"></el-input>
<p v-show="showInfo">{{dataForm.author}}</p>
</el-form-item>
<el-form-item label="显示时间:" prop="showtime">
<el-date-picker
v-show="!showInfo"
v-model="dataForm.showtime"
value-format='yyyy-MM-dd'
type="date"
placeholder="选择日期">
</el-date-picker>
<p v-show="showInfo">{{dataForm.showtime}}</p>
</el-form-item>
<el-form-item label="附件路径:" prop="fileUrl">
<el-upload
v-show="!showInfo"
class="avatar-uploaderFile"
action=""
:show-file-list="false"
:http-request="Upload"
:before-upload="beforeAvatarUpload">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
<a v-if="fileUrlStr" :href="fileUrlStr" target="_blank">{{fileUrlStr}}</a>
<p v-show="showInfo"><a :href="fileUrlStr">{{fileUrlStr}}</a></p>
</el-form-item>
<el-form-item label="文章内容:" prop="content" >
<Ueditor @ready="editorReady" :value="ueditor.value" :config="ueditor.config" ref="ue" v-show="!showInfo" ></Ueditor>
<div v-show="showInfo" v-html="dataForm.content"></div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer" v-show="!showInfo">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
import Ueditor from '../temps/ueditor'
export default {
components: {
Ueditor
},
data () {
return {
loading: false,
showInfo: false,
visible: false,
defaultProps: {
children: 'children',
label: 'label'
},
dataForm: {
id: 0,
title: '',
author: '',
levels: '',
fileurl: '',
content: '',
showtime: '',
announcetype: ''
},
typeList: [
{
value: 1,
label: '中心公告'
},
{
value: 2,
label: '地方公告'
}
],
cclassidStr: undefined,
dataRule: {
title: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
author: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
levels: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
type: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
// fileurl: [
// { required: true, message: '不能为空', trigger: 'blur' }
// ],
showtime: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
},
fileUrl: new FormData(),
fileUrlStr: '',
dialogVisible: false,
ueditor: {
value: '',
config: {}
},
piclevelList: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
id: [],
classidList: [],
cclassidList: [],
title: '',
className: '',
cclassName: ''
}
},
created () {
},
mounted () {
},
methods: {
getSelectName (list, id) {
let arr = list.filter((item) => {
return item.id === id
})
return arr[0].name
},
init (id, showInfo) {
this.dataForm.id = id || 0
this.visible = true
this.showInfo = showInfo
this.$nextTick(() => {
this.clearInp()
if (this.dataForm.id) {
this.loading = true
this.$http({
url: this.$http.adornUrl(`/office/announce/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
this.loading = false
if (data && data.code === 0) {
this.dataForm = data.announce
this.fileUrlStr = data.announce.fileUrlStr
this.dialogVisible = true
this.ueditor.value = this.dataForm.content
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.loading = true
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/office/announce/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'title': this.dataForm.title,
'announcetype': this.dataForm.announcetype,
'author': this.dataForm.author,
'levels': this.dataForm.levels,
'fileurl': this.dataForm.fileurl,
'content': this.dataForm.content,
'showtime': this.dataForm.showtime
})
}).then(({data}) => {
this.loading = false
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)
}
})
}
})
},
// 上传之前校验
beforeAvatarUpload (file) {
if (file) {
var windowURL = window.URL || window.webkitURL
this.fileUrlStr = windowURL.createObjectURL(file)
this.dialogVisible = true
this.fileUrl.append('file', file)
}
},
Upload () {
this.$http({
url: this.$http.adornUrl('/office/file/uploadFile'),
method: 'post',
data: this.fileUrl,
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(res => {
console.log(res)
this.dataForm.fileurl = res.data.data
this.fileUrlStr = res.data.data
}).catch(err => {
console.log(err)
})
},
clearInp () {
this.$refs['dataForm'].resetFields()
this.fileUrlStr = ''
this.dialogVisible = false
this.ueditor.value = ''
},
// 更新父子组件内容
editorReady (instance) {
instance.setContent(this.dataForm.content)
instance.addListener('contentChange', () => {
this.dataForm.content = instance.getContent()
})
}
}
}
</script>
<style scoped>
.avatar-uploader > .el-upload{
border: none!important;
}
</style>
\ No newline at end of file
......@@ -32,7 +32,7 @@
},
methods: {
init (id) {
this.url = this.$http.adornUrl(`/office/sys/oss/upload?token=${sessionStorage.getItem('token')}`)
this.url = this.$http.adornUrl(`/office/sys/oss/upload?token=${localStorage.getItem('token')}`)
this.visible = true
},
// 上传之前
......
......@@ -64,7 +64,7 @@
prop="category"
header-align="center"
align="center"
label="状态">
label="类型">
<template slot-scope="scope">
<div>
<span v-if="scope.row.category === 1">表格下载</span>
......@@ -73,6 +73,14 @@
</template>
</el-table-column>
<el-table-column
prop="auditor"
header-align="center"
align="center"
label="审核人">
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
......
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