Browse Source

后台

master
aBin 5 years ago
parent
commit
fb4971360a
  1. 48
      src/api/policy.js
  2. BIN
      src/assets/404_images/touxiang.jpg
  3. 13
      src/layout/components/Navbar.vue
  4. 4
      src/main.js
  5. 6
      src/router/index.js
  6. 35
      src/utils/error-log.js
  7. 25
      src/utils/open-window.js
  8. 21
      src/utils/permission.js
  9. 58
      src/utils/scroll-to.js
  10. 2
      src/views/dashboard/index.vue
  11. 326
      src/views/firstPages/policy.vue
  12. 30
      src/views/firstPages/typemanage.vue

48
src/api/policy.js

@ -16,3 +16,51 @@ export function PolicyDetail(data) {
})
}
export function PolicyUpdate(data) {
return request({
url: `/gateway${policy}/PolicyUpdate`,
method: 'post',
data: {
param: {
auditStatus: data.auditStatus,
content: data.content,
id: data.id,
imgUrl: data.imgUrl,
intro: data.intro,
title: data.title,
titleUrl: data.titleUrl,
type: data.type
}
}
})
}
export function PolicyDelete(id) {
return request({
url: `/gateway${policy}/PolicyDelete`,
method: 'post',
data: {
param: {
id: id
}
}
})
}
export function PolicyAdd(data) {
console.log(data)
return request({
url: `/gateway${policy}/PolicyAdd`,
method: 'post',
data: {
param: {
content: data.content,
imgUrl: data.imgUrl,
intro: data.intro,
publishTime: data.publishTime,
title: data.title,
titleUrl: data.titleUrl
}
}
})
}

BIN
src/assets/404_images/touxiang.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

13
src/layout/components/Navbar.vue

@ -7,23 +7,18 @@
<div class="right-menu">
<el-dropdown class="avatar-container" trigger="click">
<div class="avatar-wrapper">
<img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
<!-- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar"> -->
<img src="@/assets/404_images/touxiang.jpg" class="user-avatar">
<i class="el-icon-caret-bottom" />
</div>
<el-dropdown-menu slot="dropdown" class="user-dropdown">
<router-link to="/">
<el-dropdown-item>
Home
主页
</el-dropdown-item>
</router-link>
<a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/">
<el-dropdown-item>Github</el-dropdown-item>
</a>
<a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
<el-dropdown-item>Docs</el-dropdown-item>
</a>
<el-dropdown-item divided @click.native="logout">
<span style="display:block;">Log Out</span>
<span style="display:block;">退出登录</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>

4
src/main.js

@ -4,7 +4,7 @@ import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import '@/styles/index.scss' // global css
@ -28,7 +28,7 @@ if (process.env.NODE_ENV === 'production') {
mockXHR()
}
// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
Vue.use(ElementUI)
// 如果想要中文版 element-ui,按如下方式声明
// Vue.use(ElementUI)

6
src/router/index.js

@ -78,6 +78,12 @@ export const constantRoutes = [
name: 'Train',
component: () => import('@/views/firstPages/train'),
meta: { title: '培训管理', icon: '' }
},
{
path: 'typemanage',
name: 'Typemanage',
component: () => import('@/views/firstPages/typemanage'),
meta: { title: '类型管理', icon: '' }
}]
},

35
src/utils/error-log.js

@ -0,0 +1,35 @@
import Vue from 'vue'
import store from '@/store'
import { isString, isArray } from '@/utils/validate'
import settings from '@/settings'
// you can set in settings.js
// errorLog:'production' | ['production', 'development']
const { errorLog: needErrorLog } = settings
function checkNeed() {
const env = process.env.NODE_ENV
if (isString(needErrorLog)) {
return env === needErrorLog
}
if (isArray(needErrorLog)) {
return needErrorLog.includes(env)
}
return false
}
if (checkNeed()) {
Vue.config.errorHandler = function(err, vm, info, a) {
// Don't ask me why I use Vue.nextTick, it just a hack.
// detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500
Vue.nextTick(() => {
store.dispatch('errorLog/addErrorLog', {
err,
vm,
info,
url: window.location.href
})
console.error(err, info)
})
}
}

25
src/utils/open-window.js

@ -0,0 +1,25 @@
/**
*Created by PanJiaChen on 16/11/29.
* @param {Sting} url
* @param {Sting} title
* @param {Number} w
* @param {Number} h
*/
export default function openWindow(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height
const left = ((width / 2) - (w / 2)) + dualScreenLeft
const top = ((height / 2) - (h / 2)) + dualScreenTop
const newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left)
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus()
}
}

21
src/utils/permission.js

@ -0,0 +1,21 @@
import store from '@/store'
/**
* @param {Array} value
* @returns {Boolean}
* @example see @/views/permission/directive.vue
*/
export default function checkPermission(value) {
if (value && value instanceof Array && value.length > 0) {
const roles = store.getters && store.getters.roles
const permissionRoles = value
const hasPermission = roles.some(role => {
return permissionRoles.includes(role)
})
return hasPermission
} else {
console.error(`need roles! Like v-permission="['admin','editor']"`)
return false
}
}

58
src/utils/scroll-to.js

@ -0,0 +1,58 @@
Math.easeInOutQuad = function(t, b, c, d) {
t /= d / 2
if (t < 1) {
return c / 2 * t * t + b
}
t--
return -c / 2 * (t * (t - 2) - 1) + b
}
// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
var requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) }
})()
/**
* Because it's so fucking difficult to detect the scrolling element, just move them all
* @param {number} amount
*/
function move(amount) {
document.documentElement.scrollTop = amount
document.body.parentNode.scrollTop = amount
document.body.scrollTop = amount
}
function position() {
return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop
}
/**
* @param {number} to
* @param {number} duration
* @param {Function} callback
*/
export function scrollTo(to, duration, callback) {
const start = position()
const change = to - start
const increment = 20
let currentTime = 0
duration = (typeof (duration) === 'undefined') ? 500 : duration
var animateScroll = function() {
// increment the time
currentTime += increment
// find the value with the quadratic in-out easing function
var val = Math.easeInOutQuad(currentTime, start, change, duration)
// move the document.body
move(val)
// do the animation unless its over
if (currentTime < duration) {
requestAnimFrame(animateScroll)
} else {
if (callback && typeof (callback) === 'function') {
// the animation is done so lets callback
callback()
}
}
}
animateScroll()
}

2
src/views/dashboard/index.vue

@ -1,6 +1,6 @@
<template>
<div class="dashboard-container">
<div class="dashboard-text">name: {{ name }}2</div>
<div class="dashboard-text">欢迎登陆{{ name }}</div>
</div>
</template>

326
src/views/firstPages/policy.vue

@ -1,8 +1,9 @@
<template>
<div class="app-container">
<!-- 头部搜索添加 -->
<div class="filter-container">
<el-select v-model="policyType" placeholder="政策类型" clearable style="width: 190px" class="filter-item">
<el-option v-for="(item,index) in types" :key="index" :value="index" />
<el-option v-for="(item,index) in typeList" :key="index" :value="index" />
</el-select>
<el-select v-model="policyStatus" placeholder="审核状态" clearable class="filter-item" style="width: 190px;margin-left:10px" value="1">
<el-option v-for="(item,index) in status" :key="index" :value="index" />
@ -10,38 +11,170 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-search" @click="Search">
搜索
</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit">
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="policyAdd">
添加
</el-button>
<el-checkbox class="filter-item" style="margin-left:15px;">
审核人
</el-checkbox>
</div>
<!-- <el-table :data="polictList" border fit highlight-current-row style="width: 100%;">
<el-table-column label="ID" prop="id" sortable="custom" align="center" width="80">
<!-- 政策信息列表 -->
<el-table v-loading="listLoading" :data="polictList" border fit highlight-current-row style="width: 100%;">
<el-table-column label="ID" prop="id" align="center" width="80">
<template slot-scope="{row}">
<span>{{ row.id }}</span>
</template>
</el-table-column>
<el-table-column>
<template>
<span>ID</span>
<el-table-column label="标题" prop="title" align="center" width="480">
<template slot-scope="{row}">
<span>{{ row.title }}</span>
</template>
</el-table-column>
<el-table-column label="时间" prop="time" align="center" width="180">
<template slot-scope="{row}">
<span>{{ row.publishTime }}</span>
</template>
</el-table-column>
<el-table-column label="部门" prop="depart" align="center" width="180">
<template slot-scope="{row}">
<span>{{ row.publishDepart }}</span>
</template>
</el-table-column>
<el-table-column>
<template>
<span>ID</span>
<el-table-column label="原文链接" prop="url" align="center" width="180">
<template slot-scope="{row}">
<!-- <span>{{ row.titleUrl }} -->
<a :href="row.titleUrl" target="_blank">点击此处跳转</a>
<!-- </span> -->
</template>
</el-table-column>
<el-table-column>
<template>
<span>ID</span>
<el-table-column label="审核状态" prop="status" align="center" width="180">
<template slot-scope="{row}">
<!-- <span>{{ row.auditStatus }}</span> -->
<el-tag v-if="row.auditStatus === 0" style="background:#FFBB77;" type="published">
刚入库
</el-tag>
<el-tag v-if="row.auditStatus === 1" type="published">
审核通过
</el-tag>
<el-tag v-if="row.auditStatus === 2" style="background:#FF5151;color:white" type="draft">
审核不通过
</el-tag>
</template>
</el-table-column>
</el-table> -->
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
<template slot-scope="{row}">
<el-button type="primary" size="mini" @click="handleUpdate(row)">
修改
</el-button>
<el-button v-if="row.auditStatus === 2" size="mini" type="success" @click="handleModifyStatus(row,1)">
通过
</el-button>
<el-button v-if="row.auditStatus === 1" size="mini" @click="handleModifyStatus(row,2)">
未通过
</el-button>
<el-button v-if="row.auditStatus === 0" size="mini" type="success" @click="handleModifyStatus(row,1)">
通过
</el-button>
<el-button size="mini" type="danger" @click="handleDelete(row.id)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 显示当前页数且显示所有页数可以跳转 -->
<pagination v-show="total>0" :total="total" :page.sync="data.pageNum" :limit.sync="data.pageSize" @pagination="getList" />
<!-- 修改政策界面 -->
<el-dialog title="修改" :visible.sync="dialogFormVisible">
<el-form ref="dataForm" :model="temp" label-position="left" label-width="70px" style="width: 400px; margin-left:50px;">
<el-form-item label="政策标题" prop="title" style="width: 180%">
<el-input v-model="temp.title" />
</el-form-item>
<el-form-item label="原文链接" prop="titleUrl" style="width: 180%">
<el-input v-model="temp.titleUrl" />
</el-form-item>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
<el-form-item label="图片路径" prop="imgUrl" style="width: 180%">
<el-input v-model="temp.imgUrl" />
</el-form-item>
<el-form-item label="原文内容" prop="content" style="width: 180%">
<!-- <el-button @click="show111 = !show111">原文/编辑</el-button> -->
<!-- <textarea v-if="show111 === false" style="width: 100%;height: 300px" v-text="temp.content" /> -->
<div v-if="show111 === false" contentEditable="true" style="border:1px solid #000;border-radius:10px 0 0 10px;padding: 20px;background: #F5F5F5;height: 260px;overflow-y: auto;" v-html="temp.content">'</div>
<!-- <textarea id="content" name="content" /> -->
</el-form-item>
<el-form-item label="政策简介" prop="intro" style="width: 180%">
<el-input v-model="temp.intro" />
</el-form-item>
<el-form-item label="政策标签" prop="intro" style="width: 180%">
<el-input />
</el-form-item>
<el-form-item label="政策类型" prop="type">
<el-select v-model="policyType1" placeholder="政策类型" clearable style="width: 190px" class="filter-item">
<el-option v-for="(item,index) in typeList" :key="index" :value="index" />
</el-select>
</el-form-item>
<el-form-item label="审核状态" prop="status">
<el-select v-model="policyStatus1" placeholder="审核状态" clearable class="filter-item" style="width: 190px;" value="1">
<el-option v-for="(item,index) in status" :key="index" :value="index" />
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">
取消
</el-button>
<el-button type="primary" @click="Commit">
提交
</el-button>
</div>
</el-dialog>
<!-- 添加政策界面 -->
<el-dialog title="修改" :visible.sync="dialogFormVisible1">
<el-form ref="dataForm" :model="temp" label-position="left" label-width="70px" style="width: 400px; margin-left:50px;">
<el-form-item label="政策标题" prop="title" style="width: 180%">
<el-input v-model="addPolicy.title" />
</el-form-item>
<el-form-item label="发布时间" prop="time" style="width: 180%">
<!-- <el-input v-model="addPolicy.publishTime" placeholder="例如:2020/01/01" /> -->
<el-date-picker id="Time" v-model="addPolicy.publishTime" type="date" placeholder="请选择时间" />
</el-form-item>
<el-form-item label="原文链接" prop="titleUrl" style="width: 180%">
<el-input v-model="addPolicy.titleUrl" />
</el-form-item>
<el-form-item label="图片路径" prop="imgUrl" style="width: 180%">
<el-input v-model="addPolicy.imgUrl" />
</el-form-item>
<el-form-item label="原文内容" prop="content" style="width: 180%">
<!-- <el-button @click="show111 = !show111">原文/编辑</el-button> -->
<!-- <textarea v-if="show111 === false" style="width: 100%;height: 300px" v-text="temp.content" /> -->
<div v-if="show111 === false" id="Content" contentEditable="true" style="border:1px solid #000;border-radius:10px 0 0 10px;padding: 20px;background: #F5F5F5;height: 260px;overflow-y: auto;" v-html="addPolicy.content">'</div>
<!-- <textarea id="content" name="content" /> -->
</el-form-item>
<el-form-item label="政策简介" prop="intro" style="width: 180%">
<el-input v-model="addPolicy.intro" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible1 = false">
取消
</el-button>
<el-button type="primary" @click="CommitAdd">
提交
</el-button>
</div>
</el-dialog>
</div>
</template>
@ -55,8 +188,8 @@ export default {
components: { Pagination },
data() {
return {
tableKey: 0,
list: null,
show111: false,
total: 0,
listLoading: true,
data: {
@ -65,19 +198,29 @@ export default {
pageSize: 20,
type: ''
},
listQuery: {
page: 1,
limit: 20,
importance: undefined,
title: undefined,
type: undefined,
sort: '+id'
},
polictList: [],
types: { '申报通知': 0, '公告公示': 1, '政策动态': 2, '申报指南': 3 },
typeList: { '申报通知': 0, '公告公示': 1, '政策动态': 2, '申报指南': 3 },
policyType: undefined,
policyType1: undefined,
policyStatus: undefined,
status: { '刚入库': 0, '审核通过': 1, '审核不通过': 2 }
policyStatus1: undefined,
status: { '刚入库': 0, '审核通过': 1, '审核不通过': 2 },
textMap: {
update: 'Edit',
create: 'Create'
},
dialogStatus: '',
dialogFormVisible: false,
dialogFormVisible1: false,
temp: {},
addPolicy: {
title: '',
publishTime: '',
titleUrl: '',
imgUrl: '',
content: '',
intro: ''
}
}
},
computed: {
@ -85,36 +228,127 @@ export default {
'name'
])
},
async mounted() {
const that = this
await api.PolicyDetail(this.data).then((res) => {
// console.log(res)
that.polictList = res.list
console.log(that.polictList)
}).catch(() => {
// console.log(err)
})
created() {
this.getList()
},
methods: {
async Search() {
const that = this
if (that.types[`${that.policyType}`] === undefined) {
console.log('无数据')
that.listLoading = true
if (that.typeList[`${that.policyType}`] === undefined && that.status[`${that.policyStatus}`] === undefined) {
that.data.type = ''
that.data.auditStatus = ''
await api.PolicyDetail(this.data).then((res) => {
that.polictList = res.list
that.total = res.total - 0
that.listLoading = false
})
} else if (that.typeList[`${that.policyType}`] === undefined) {
that.data.type = ''
that.data.auditStatus = that.status[`${that.policyStatus}`]
await api.PolicyDetail(this.data).then((res) => {
that.polictList = res.list
that.total = res.total - 0
that.listLoading = false
})
} else if (that.status[`${that.policyStatus}`] === undefined) {
that.data.type = that.typeList[`${that.policyType}`]
that.data.auditStatus = ''
await api.PolicyDetail(this.data).then((res) => {
that.polictList = res.list
that.total = res.total - 0
that.listLoading = false
})
} else {
that.data.pageNum = 1
that.data.type = that.types[`${that.policyType}`]
that.data.type = that.typeList[`${that.policyType}`]
that.data.auditStatus = that.status[`${that.policyStatus}`]
await api.PolicyDetail(this.data).then((res) => {
console.log(res)
}).catch((err) => {
console.log(err)
that.polictList = res.list
that.total = res.total - 0
that.listLoading = false
})
}
},
getList() {
console.log('xxx')
async getList() {
const that = this
that.listLoading = true
await api.PolicyDetail(that.data).then((res) => {
that.polictList = res.list
that.total = res.total - 0
setTimeout(() => {
that.listLoading = false
}, 1000)
})
},
handleUpdate(row) {
const that = this
that.temp = Object.assign({}, row) // copy obj
that.temp.timestamp = new Date(that.temp.timestamp)
that.dialogStatus = 'update'
for (const key in that.typeList) {
if (that.typeList[key] === that.temp.type) {
that.policyType1 = key
}
}
for (const key in that.status) {
if (that.status[key] === that.temp.auditStatus) {
that.policyStatus1 = key
}
}
that.dialogFormVisible = true
that.$nextTick(() => {
that.$refs['dataForm'].clearValidate()
})
},
async Commit() {
const that = this
that.temp.type = that.typeList[`${that.policyType1}`]
that.temp.auditStatus = that.status[`${that.policyStatus1}`]
await api.PolicyUpdate(that.temp).then((res) => {
this.getList()
that.dialogFormVisible = false
})
},
async handleModifyStatus(detail, num) {
this.listLoading = true
detail.auditStatus = num
await api.PolicyUpdate(detail).then((res) => {
this.listLoading = false
})
},
async handleDelete(id) {
await api.PolicyDelete(id).then((res) => {
this.getList()
})
},
policyAdd() {
const that = this
for (const key in that.addPolicy) {
that.addPolicy[key] = ''
}
that.addPolicy.publishTime = new Date()
that.dialogFormVisible1 = true
},
async CommitAdd() {
const that = this
var Content = document.getElementById('Content')
var Time = document.getElementById('Time').value
that.addPolicy.content = Content.innerHTML
var str = Time.replace(/-/g, '/')
that.addPolicy.publishTime = str
for (const key in that.addPolicy) {
if (that.addPolicy[key] === '') {
alert(key + '不能为空')
} else {
api.PolicyAdd(that.addPolicy).then((res) => {
that.dialogFormVisible1 = false
})
}
}
}
}
}

30
src/views/firstPages/typemanage.vue

@ -0,0 +1,30 @@
<template>
<div class="dashboard-container">
类型管理页
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'Typemanage',
computed: {
...mapGetters([
'name'
])
}
}
</script>
<style lang="scss" scoped>
.dashboard {
&-container {
margin: 30px;
}
&-text {
font-size: 30px;
line-height: 46px;
}
}
</style>
Loading…
Cancel
Save