Commit 399a8ecb by wangql

Merge branch 'master' of http://192.168.3.233:8090/glsx-web/tFIMS

2 parents b09c0bd6 c41b8254
...@@ -4,4 +4,4 @@ module.exports = { ...@@ -4,4 +4,4 @@ module.exports = {
], ],
// 允许两种编码引入方式共存,也就是 common 规范与 es6 规范的共存处理 // 允许两种编码引入方式共存,也就是 common 规范与 es6 规范的共存处理
sourceType: 'unambiguous' sourceType: 'unambiguous'
}
\ No newline at end of file \ No newline at end of file
}
...@@ -4939,6 +4939,14 @@ ...@@ -4939,6 +4939,14 @@
"safer-buffer": "2.1.2" "safer-buffer": "2.1.2"
} }
}, },
"echarts": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/echarts/-/echarts-4.2.1.tgz",
"integrity": "sha512-pw4xScRPsLegD/cqEcoXRKeA2SD4+s+Kyo0Na166NamOWhzNl2yI5RZ2rE97tBlAopNmhyMeBVpAeD5qb+ee1A==",
"requires": {
"zrender": "4.0.7"
}
},
"editorconfig": { "editorconfig": {
"version": "0.15.3", "version": "0.15.3",
"resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.3.tgz", "resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.3.tgz",
...@@ -15446,6 +15454,11 @@ ...@@ -15446,6 +15454,11 @@
"dev": true "dev": true
} }
} }
},
"zrender": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/zrender/-/zrender-4.0.7.tgz",
"integrity": "sha512-TNloHe0ums6zxbHfnaCryM61J4IWDajZwNq6dHk9vfWhhysO/OeFvvR0drBs/nbXha2YxSzfQj2FiCd6RVBe+Q=="
} }
} }
} }
...@@ -3,10 +3,10 @@ var app = express() ...@@ -3,10 +3,10 @@ var app = express()
app.use(express.static('./dist')) app.use(express.static('./dist'))
app.get('/', function(req, res) { app.get('/', function (req, res) {
res.send('Hello Vue') res.send('Hello Vue')
}) })
app.listen(2333) app.listen(2333)
console.log('服务已运行:\r\n localhost:2333')
\ No newline at end of file \ No newline at end of file
console.log('服务已运行:\r\n localhost:2333')
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:41 * @Date: 2019-08-26 18:02:41
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-26 18:02:41 * @Last Modified time: 2019-08-28 15:04:32
*/ */
import axios from '@/plugin/axios' import axios from '@/plugin/axios'
import sign from './sign' import sign from './sign'
import { const request = (params, method) => {
sysMonitorMethods,
trafficManageMethods
} from './sys.traffic.subsys.js'
const request = (params,method) => {
params.source = '' params.source = ''
params.app_key = '48e5e13229b82c1b4e6e8c96151f0637' params.app_key = '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime() params.timestamp = new Date().getTime()
...@@ -21,12 +17,8 @@ const request = (params,method) => { ...@@ -21,12 +17,8 @@ const request = (params,method) => {
// return axios.post(url, { 'params': sign(params) }) // return axios.post(url, { 'params': sign(params) })
return axios({ return axios({
url, url,
method: method||'get', method: method || 'get',
data:sign(params) data: sign(params)
}) })
} }
export { export default request
request,
sysMonitorMethods,
trafficManageMethods
}
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:01:59 * @Date: 2019-08-26 18:01:59
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-26 18:02:32 * @Last Modified time: 2019-08-26 18:02:32
*/ */
const RequestMethods = { const RequestMethods = {
POST:'post', POST: 'post',
GET:'get', GET: 'get',
PUT:'put', PUT: 'put',
DELETE:'delete' DELETE: 'delete'
} }
export default RequestMethods export default RequestMethods
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:49 * @Date: 2019-08-26 18:02:49
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-26 18:03:46 * @Last Modified time: 2019-08-26 18:03:46
*/ */
......
/* /*
* @Author: limin * @Author: limin
* @Date: 2019-08-26 18:02:55 * @Date: 2019-08-26 18:02:55
* @Last Modified by: limin * @Last Modified by: limin
* @Last Modified time: 2019-08-26 18:02:55 * @Last Modified time: 2019-08-26 18:02:55
*/ */
import { request } from './request' import request from './request'
import RequestMethods from "./request.methods"; import RequestMethods from './request.methods'
const path = '' const path = ''
// export function AccountLogin (data) { // export function AccountLogin (data) {
// return request({ // return request({
...@@ -16,6 +16,6 @@ const path = '' ...@@ -16,6 +16,6 @@ const path = ''
// }) // })
// } // }
export function AccountLogin (data) { export function AccountLogin (data) {
data.method=`${path}login`
return request(data,RequestMethods.POST)
}
\ No newline at end of file \ No newline at end of file
data.method = `${path}login`
return request(data, RequestMethods.POST)
}
...@@ -16,4 +16,4 @@ const trafficManageMethods = { ...@@ -16,4 +16,4 @@ const trafficManageMethods = {
export { export {
sysMonitorMethods, sysMonitorMethods,
trafficManageMethods trafficManageMethods
}
\ No newline at end of file \ No newline at end of file
}
// 过渡动画 横向渐变 // 过渡动画 横向渐变
.fade-transverse-leave-active, .fade-transverse-leave-active,
.fade-transverse-enter-active { .fade-transverse-enter-active {
transition: all .5s; transition: all .2s;
} }
.fade-transverse-enter { .fade-transverse-enter {
opacity: 0; opacity: 0;
......
...@@ -2,19 +2,19 @@ import Vue from 'vue' ...@@ -2,19 +2,19 @@ import Vue from 'vue'
export default new Vue({ export default new Vue({
methods: { methods: {
warningTips(message) { warningTips (message) {
this.$notify({ this.$notify({
type: 'warning', type: 'warning',
title: message title: message
}) })
}, },
okTips(message) { okTips (message) {
this.$notify({ this.$notify({
type: 'success', type: 'success',
title: message || '操作成功' title: message || '操作成功'
}) })
}, },
errorTips(message) { errorTips (message) {
this.$notify({ this.$notify({
type: 'error', type: 'error',
title: message || '操作失败' title: message || '操作失败'
......
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
<script> <script>
export default { export default {
name: "AuthButton", name: 'AuthButton',
props: { props: {
label: { label: {
type: String, type: String,
default: "Button" default: 'Button'
}, },
size: { size: {
type: String, type: String,
default: "mini" default: 'mini'
}, },
type: { type: {
type: String, type: String,
...@@ -37,21 +37,21 @@ export default { ...@@ -37,21 +37,21 @@ export default {
default: null default: null
} }
}, },
data() { data () {
return {}; return {}
}, },
beforeCreate() { beforeCreate () {
this.$vrm.setRoles(["1", "2", "3"]); this.$vrm.setRoles(['1', '2', '3'])
}, },
methods: { methods: {
handleClick: function() { handleClick: function () {
this.$emit("e-auth-click", {}); this.$emit('e-auth-click', {})
} }
}, },
mounted() { mounted () {
} }
}; }
</script> </script>
<style scoped> <style scoped>
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -7,4 +7,4 @@ import authButton from './d2-auth/d2-auth-btn.vue' ...@@ -7,4 +7,4 @@ import authButton from './d2-auth/d2-auth-btn.vue'
Vue.component('d2-container', d2Container) Vue.component('d2-container', d2Container)
Vue.component('d2-icon', () => import('./d2-icon')) Vue.component('d2-icon', () => import('./d2-icon'))
Vue.component('d2-icon-svg', () => import('./d2-icon-svg/index.vue')) Vue.component('d2-icon-svg', () => import('./d2-icon-svg/index.vue'))
Vue.component('auth-button', authButton)
\ No newline at end of file \ No newline at end of file
Vue.component('auth-button', authButton)
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
} }
}, },
methods: { methods: {
click() { click () {
this.onClick && this.onClick() this.onClick && this.onClick()
} }
} }
...@@ -43,4 +43,4 @@ export default { ...@@ -43,4 +43,4 @@ export default {
.hamburger.is-active { .hamburger.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -31,30 +31,30 @@ import PersonalPanel from '../personal-panel' ...@@ -31,30 +31,30 @@ import PersonalPanel from '../personal-panel'
import PersonDetailDialog from './personMsgDialog' import PersonDetailDialog from './personMsgDialog'
import PasswordDialog from './passwordDialog' import PasswordDialog from './passwordDialog'
export default { export default {
components:{ components: {
PersonalPanel, PersonalPanel,
PersonDetailDialog, PersonDetailDialog,
PasswordDialog PasswordDialog
}, },
computed: { computed: {
...mapState("d2admin/user", ["info"]) ...mapState('d2admin/user', ['info'])
}, },
data() { data () {
return { return {
detailVisible:false, detailVisible: false,
passVisible:false passVisible: false
} }
}, },
methods: { methods: {
...mapActions("d2admin/account", ["logout"]), ...mapActions('d2admin/account', ['logout']),
/** /**
* @description 登出 * @description 登出
*/ */
logOff() { logOff () {
this.logout({ this.logout({
confirm: true confirm: true
}); })
} }
} }
}; }
</script> </script>
...@@ -63,33 +63,33 @@ export default { ...@@ -63,33 +63,33 @@ export default {
components: { components: {
}, },
data() { data () {
var validateOldPass = (rule, value, callback) => { var validateOldPass = (rule, value, callback) => {
if (value === '') { if (value === '') {
callback(new Error('请输入旧密码')); callback(new Error('请输入旧密码'))
}else{ } else {
callback(); callback()
//查询当前用户的密码是否与输入的旧密码一致 // 查询当前用户的密码是否与输入的旧密码一致
} }
}; }
var validateNewPass = (rule, value, callback) => { var validateNewPass = (rule, value, callback) => {
if (value === '') { if (value === '') {
callback(new Error('请输入新密码')); callback(new Error('请输入新密码'))
}else if(value === this.info.oldPassword){ } else if (value === this.info.oldPassword) {
callback(new Error('新密码与旧密码不能一样')); callback(new Error('新密码与旧密码不能一样'))
}else{ } else {
callback(); callback()
} }
}; }
var validateSurePass = (rule, value, callback) => { var validateSurePass = (rule, value, callback) => {
if (value === '') { if (value === '') {
callback(new Error('请输入确认新密码')); callback(new Error('请输入确认新密码'))
}else if(value !== this.info.newPassword){ } else if (value !== this.info.newPassword) {
callback(new Error('两次输入密码不一致')); callback(new Error('两次输入密码不一致'))
}else{ } else {
callback(); callback()
} }
}; }
return { return {
info: { info: {
userName: 'admin', userName: 'admin',
...@@ -114,7 +114,7 @@ export default { ...@@ -114,7 +114,7 @@ export default {
passwordDialogVisible: { passwordDialogVisible: {
type: Boolean, type: Boolean,
default: false default: false
}, }
// info: { // info: {
// type: Object, // type: Object,
// default: function() { // default: function() {
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
watch: { watch: {
}, },
mounted() { mounted () {
}, },
methods: { methods: {
// getPersonalType() { // getPersonalType() {
...@@ -141,22 +141,22 @@ export default { ...@@ -141,22 +141,22 @@ export default {
// }) // })
// }, // },
//修改密码 // 修改密码
savePassword(formName) { savePassword (formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
alert('submit!'); alert('submit!')
} else { } else {
console.log('error submit!!'); console.log('error submit!!')
return false; return false
} }
}); })
}, },
handleClose() { handleClose () {
this.passwordDialogVisible = false this.passwordDialogVisible = false
}, },
mergePassWord(params) { mergePassWord (params) {
// mergeBg // mergeBg
// .req(params) // .req(params)
// .then(res => { // .then(res => {
...@@ -166,7 +166,7 @@ export default { ...@@ -166,7 +166,7 @@ export default {
// }); // });
// }) // })
// .catch(err => console.log(err)) // .catch(err => console.log(err))
}, }
} }
} }
...@@ -208,4 +208,4 @@ export default { ...@@ -208,4 +208,4 @@ export default {
.detail .el-radio:focus:not(.is-focus):not(:active) .el-radio__inner { .detail .el-radio:focus:not(.is-focus):not(:active) .el-radio__inner {
box-shadow: 0 0; box-shadow: 0 0;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -80,15 +80,15 @@ export default { ...@@ -80,15 +80,15 @@ export default {
components: { components: {
}, },
data() { data () {
return { return {
detail: { detail: {
userName : 'abc123', userName: 'abc123',
personName : '张三', personName: '张三',
phone : '18511111111', phone: '18511111111',
company : '长春富通机电设备有限公司', company: '长春富通机电设备有限公司',
department : '售后部', department: '售后部',
duties : '仓库管理', duties: '仓库管理'
} }
} }
}, },
...@@ -96,7 +96,7 @@ export default { ...@@ -96,7 +96,7 @@ export default {
personDialogVisible: { personDialogVisible: {
type: Boolean, type: Boolean,
default: false default: false
}, }
// detail: { // detail: {
// type: Object, // type: Object,
// default: function() { // default: function() {
...@@ -122,7 +122,7 @@ export default { ...@@ -122,7 +122,7 @@ export default {
// } // }
// } // }
}, },
mounted() { mounted () {
}, },
methods: { methods: {
// getPersonalType() { // getPersonalType() {
...@@ -137,7 +137,7 @@ export default { ...@@ -137,7 +137,7 @@ export default {
// console.log(err) // console.log(err)
// }) // })
// }, // },
handleClose() { handleClose () {
this.personDialogVisible = false this.personDialogVisible = false
} }
} }
...@@ -181,4 +181,4 @@ export default { ...@@ -181,4 +181,4 @@ export default {
.detail .el-radio:focus:not(.is-focus):not(:active) .el-radio__inner { .detail .el-radio:focus:not(.is-focus):not(:active) .el-radio__inner {
box-shadow: 0 0; box-shadow: 0 0;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -9,8 +9,8 @@ export default { ...@@ -9,8 +9,8 @@ export default {
menuMixin menuMixin
], ],
render (createElement) { render (createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' }, return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' }
}, [ }, [
createElement('el-menu', { createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active }, props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active },
ref: 'menu', ref: 'menu',
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
// } // }
}) })
}, },
test(){ test () {
alert(111) alert(111)
}, },
scrollDestroy () { scrollDestroy () {
......
...@@ -4,43 +4,43 @@ ...@@ -4,43 +4,43 @@
<div class="avatar-container"> <div class="avatar-container">
<avatar :username="user.name"></avatar> <avatar :username="user.name"></avatar>
<!-- <img class="avatar" :src="require('@/assets/user.png')" /> --> <!-- <img class="avatar" :src="require('@/assets/user.png')" /> -->
</div> </div>
<div class="name-role"> <div class="name-role">
<span class="sender">{{ user.name }} - {{ user.role||'超级管理员' }}</span> <span class="sender">{{ user.name }} - {{ user.role||'超级管理员' }}</span>
</div> </div>
<div class="registe-info"> <div class="registe-info">
<span class="registe-info"> <span class="registe-info">
<li class="fa fa-clock-o"></li> <li class="fa fa-clock-o"></li>
注册时间:{{ user.registeInfo|| '2019-08-08' }} 注册时间:{{ user.registeInfo|| '2019-08-08' }}
</span> </span>
</div> </div>
</div> </div>
<!-- <div class="personal-relation"> <!-- <div class="personal-relation">
<span class="relation-item">followers</span> <span class="relation-item">followers</span>
<span class="relation-item">watches</span> <span class="relation-item">watches</span>
<span class="relation-item">friends</span> <span class="relation-item">friends</span>
</div> --> </div> -->
<div class="main-operation"> <div class="main-operation">
<span class="main-operation-item"> <span class="main-operation-item">
<el-button size="small" icon="fa fa-male" @click="openUserMsgDialog()"> 个人中心</el-button> <el-button size="small" icon="fa fa-male" @click="openUserMsgDialog()"> 个人中心</el-button>
</span> </span>
<span class="main-operation-item"> <span class="main-operation-item">
<el-button size="small" icon="fa fa-key"> 修改密码</el-button> <el-button size="small" icon="fa fa-key"> 修改密码</el-button>
</span> </span>
</div> </div>
<div class="other-operation"> <div class="other-operation">
<div class="other-operation-item"> <div class="other-operation-item">
<li class="fa fa-eraser"></li> <li class="fa fa-eraser"></li>
清除缓存 清除缓存
</div> </div>
<!-- <div class="other-operation-item"> <!-- <div class="other-operation-item">
<li class="fa fa-user"></li> <li class="fa fa-user"></li>
在线人数 在线人数
</div> </div>
<div class="other-operation-item"> <div class="other-operation-item">
<li class="fa fa-bell"></li> <li class="fa fa-bell"></li>
访问次数 访问次数
</div> </div>
<div class="other-operation-item" @click="showBackupDialog"> <div class="other-operation-item" @click="showBackupDialog">
<li class="fa fa-undo"></li> <li class="fa fa-undo"></li>
{{$t("common.backupRestore")}} {{$t("common.backupRestore")}}
...@@ -57,12 +57,12 @@ ...@@ -57,12 +57,12 @@
</template> </template>
<script> <script>
import Cookies from "js-cookie" import Cookies from 'js-cookie'
// import Backup from "@/views/Backup/Backup" // import Backup from "@/views/Backup/Backup"
import Avatar from 'vue-avatar' import Avatar from 'vue-avatar'
export default { export default {
name: 'PersonalPanel', name: 'PersonalPanel',
components:{ components: {
// Backup // Backup
Avatar Avatar
}, },
...@@ -70,58 +70,58 @@ export default { ...@@ -70,58 +70,58 @@ export default {
user: { user: {
type: Object, type: Object,
default: { default: {
name: "admin", name: 'admin',
avatar: "@/assets/user.png", avatar: '@/assets/user.png',
role: "超级管理员", role: '超级管理员',
registeInfo: "注册时间:2018-12-25 " registeInfo: '注册时间:2018-12-25 '
} }
} }
}, },
data() { data () {
return { return {
} }
}, },
methods: { methods: {
// 退出登录 // 退出登录
logout: function() { logout: function () {
this.$confirm("确认退出吗?", "提示", { this.$confirm('确认退出吗?', '提示', {
type: "warning" type: 'warning'
}) })
.then(() => { .then(() => {
sessionStorage.removeItem("user") sessionStorage.removeItem('user')
this.deleteCookie("token") this.deleteCookie('token')
this.$router.push("/login") this.$router.push('/login')
this.$api.login.logout().then((res) => { this.$api.login.logout().then((res) => {
}).catch(function(res) { }).catch(function (res) {
})
}) })
}) .catch(() => {})
.catch(() => {})
}, },
// 删除cookie // 删除cookie
deleteCookie: function(name) { deleteCookie: function (name) {
Cookies.remove(name) Cookies.remove(name)
}, },
// 打开备份还原界面 // 打开备份还原界面
showBackupDialog: function() { showBackupDialog: function () {
this.$refs.backupDialog.setBackupVisible(true) this.$refs.backupDialog.setBackupVisible(true)
}, },
// 成功还原之后,重新登录 // 成功还原之后,重新登录
afterRestore: function() { afterRestore: function () {
this.$refs.backupDialog.setBackupVisible(false) this.$refs.backupDialog.setBackupVisible(false)
sessionStorage.removeItem("user") sessionStorage.removeItem('user')
this.deleteCookie("token") this.deleteCookie('token')
this.$router.push("/login") this.$router.push('/login')
this.$api.login.logout().then((res) => { this.$api.login.logout().then((res) => {
}).catch(function(res) { }).catch(function (res) {
}) })
}, },
//打开个人信息弹出框 // 打开个人信息弹出框
openUserMsgDialog: function(){ openUserMsgDialog: function () {
console.log('aaaa') console.log('aaaa')
} }
}, },
mounted() { mounted () {
} }
} }
</script> </script>
...@@ -210,4 +210,4 @@ export default { ...@@ -210,4 +210,4 @@ export default {
color: rgb(19, 138, 156); color: rgb(19, 138, 156);
background: #b1a6a61e; background: #b1a6a61e;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<el-tab-pane <el-tab-pane
v-for="page in opened" v-for="page in opened"
:key="page.fullPath" :key="page.fullPath"
:label="page.meta.title || '未命名'" :label="(page.meta && page.meta.title) || '未命名'"
:name="page.fullPath"/> :name="page.fullPath"/>
</el-tabs> </el-tabs>
</div> </div>
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
</div> </div>
<!-- 页面 --> <!-- 页面 -->
<div class="d2-theme-container-main-body" flex-box="1"> <div class="d2-theme-container-main-body" flex-box="1">
<transition :name="transitionActive ? 'fade-transverse' : ''"> <transition :name="transitionActive ? 'fade-transverse' : ''" mode="in-out">
<keep-alive :include="keepAlive"> <keep-alive :include="keepAlive">
<router-view/> <router-view/>
</keep-alive> </keep-alive>
......
import cookies from './util.cookies' import cookies from './util.cookies'
import db from './util.db' import db from './util.db'
import log from './util.log' import log from './util.log'
import permision from './util.permision'
const util = { const util = {
cookies, cookies,
db, db,
log log,
permision
} }
/** /**
...@@ -54,24 +55,63 @@ util.deepClone = (obj) => { ...@@ -54,24 +55,63 @@ util.deepClone = (obj) => {
return copy return copy
} }
throw new Error("Unable to clone obj! Its type isn't supported.") throw new Error("Unable to clone obj! Its type isn't supported.")
} }
/** /**
* 深度递归搜索 * 深度递归搜索
* @param {Array} arr 你要搜索的数组 * @param {Array} arr 你要搜索的数组
* @param {Function} condition 回调函数,必须返回谓词,判断是否找到了。会传入(item, index, level)三个参数 * @param {Function} condition 回调函数,必须返回谓词,判断是否找到了。会传入(item, index, level)三个参数
* @param {String} children 子数组的key * @param {String} children 子数组的key
*/ */
util.deepFind = function(menus,id) { util.deepFind = function (menus, id) {
const cloneMenus= util.deepClone(menus) const cloneMenus = util.deepClone(menus)
for (let menu of cloneMenus) { for (let menu of cloneMenus) {
if(menu.id === id ){ if (menu.id === id) {
delete menu.children delete menu.children
return menu return menu
} }
if (menu.children) { if (menu.children) {
return util.deepFind(menu.children,id) return util.deepFind(menu.children, id)
} }
} }
return null return null
} }
export default util
\ No newline at end of file \ No newline at end of file
util.packRoutes = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
idsInPermision.forEach(obj => {
__aRouteInPermision.push(resources[obj.id])
})
return __aRouteInPermision
}
util.packAsideMenus = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
idsInPermision.forEach(obj => {
const { icon, path, meta } = resources[obj.id]
const { title, id, pid } = meta
if (obj.pid === '0') {
__aMenusInPermision.push({ title, icon, path, id, pid })
} else {
__aSub.push({ title, icon, path, id, pid })
}
})
let __parent = null
__aSub.forEach(obj => {
__parent = __aMenusInPermision.find(menu => menu.id === obj.pid)
if (__parent.children) {
__parent.children.push(obj)
} else {
__parent.children = [obj]
}
})
return __aMenusInPermision
}
export default util
/*
* @Author: limin
* @Date: 2019-08-27 19:16:26
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 12:15:51
*/
const permision = {
}
permision.packRoutes = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aRouteInPermision = []
idsInPermision.forEach(obj => {
__aRouteInPermision.push(resources[obj.id])
})
return __aRouteInPermision
}
permision.packAsideMenus = function (resources, idsInPermision) {
if (!resources || !idsInPermision || !idsInPermision.length) {
throw new Error('参数错误')
}
let __aMenusInPermision = []
let __aSub = []
idsInPermision.forEach(obj => {
const __oMenu = permision.format2Menu(resources[obj.id])
if (obj.pid === '0') {
__aMenusInPermision.push(__oMenu)
} else {
__aSub.push(__oMenu)
}
})
let __parent = null
__aSub.forEach(obj => {
__parent = __aMenusInPermision.find(menu => menu.id === obj.pid)
if (__parent.children) {
__parent.children.push(obj)
} else {
__parent.children = [obj]
}
})
return __aMenusInPermision
}
/**
* 格式化菜单 封装成系统所需格式
*/
permision.format2Menu = function (oMenu) {
const { icon, path, meta } = oMenu
const { title, id, pid } = meta
return { title, icon, path, id, pid }
}
export default permision
...@@ -12,8 +12,7 @@ import D2Crud from '@d2-projects/d2-crud' ...@@ -12,8 +12,7 @@ import D2Crud from '@d2-projects/d2-crud'
import router from './router' import router from './router'
// import menuHeader from '@/menu/header' // import menuHeader from '@/menu/header'
// import menuAside from '@/menu/aside' // import menuAside from '@/menu/aside'
import menuAside from '@/resources' // import { frameInRoutes } from '@/router/routes'
import { frameInRoutes } from '@/router/routes'
import echarts from 'echarts' import echarts from 'echarts'
import VRM from 'vue-role-manager' import VRM from 'vue-role-manager'
...@@ -33,11 +32,11 @@ new Vue({ ...@@ -33,11 +32,11 @@ new Vue({
render: h => h(App), render: h => h(App),
created () { created () {
// 处理路由 得到每一级的路由设置 // 处理路由 得到每一级的路由设置
this.$store.commit('d2admin/page/init', frameInRoutes) // this.$store.commit('d2admin/page/init', frameInRoutes)
// 设置顶栏菜单 (暂时不需要) // 设置顶栏菜单 (暂时不需要)
// this.$store.commit('d2admin/menu/headerSet', menuHeader) // this.$store.commit('d2admin/menu/headerSet', menuHeader)
// 设置侧边栏菜单 (TODO 进行过滤) // 设置侧边栏菜单 (TODO 进行过滤)
this.$store.commit('d2admin/menu/asideSet', menuAside) // this.$store.commit('d2admin/menu/asideSet', menuAside)
// 初始化菜单搜索功能 // 初始化菜单搜索功能
// this.$store.commit('d2admin/search/init', menuHeader) // this.$store.commit('d2admin/search/init', menuHeader)
}, },
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
Vue.prototype.$version = process.env.VUE_APP_VERSION Vue.prototype.$version = process.env.VUE_APP_VERSION
// 构建时间 // 构建时间
Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
//事件传递 // 事件传递
Vue.prototype.$event = new Vue() Vue.prototype.$event = new Vue()
// Element // Element
Vue.use(ElementUI) Vue.use(ElementUI)
......
/*
* @Author: limin
* @Date: 2019-08-26 18:03:10
* @Last Modified by: limin
* @Last Modified time: 2019-08-26 21:45:31
*/
// 由于懒加载页面太多的话会造成webpack热更新太慢,所以开发环境不使用懒加载,只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
const resources = [{
id: '101',
path: '/index',
title: '首页',
icon: 'desktop'
},
{
id: '102',
title: '页面',
path: '',
icon: 'folder-o',
children: [{
id: '10201',
path: '/page1',
title: '页面 1',
component: _import('demo/page1')
},
{
id: '10202',
path: '/page2',
title: '页面 2',
component: _import('demo/page2'),
auth: {
'operation': [{ //列表操作
id: '1020101',
name: '查看',
}, { //
id: '1020102',
name: '编辑',
}],
'action': [] //按钮操作
}
},
{
id: '10203',
path: '/page3',
title: '页面 3',
component: _import('demo/page3')
}
]
}
]
export default resources
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,10 @@ import util from '@/libs/util.js' ...@@ -12,6 +12,10 @@ import util from '@/libs/util.js'
// 路由数据 // 路由数据
import routes from './routes' import routes from './routes'
const originalPush = VueRouter.prototype.push // 解决连续点击路由异常问题 limin
VueRouter.prototype.push = function push (location) {
return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter) Vue.use(VueRouter)
// 导出路由 在 main.js 里使用 // 导出路由 在 main.js 里使用
...@@ -24,6 +28,7 @@ const router = new VueRouter({ ...@@ -24,6 +28,7 @@ const router = new VueRouter({
* 权限验证 * 权限验证
*/ */
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
const source = store.state.d2admin.auth.source
// 确认已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201 // 确认已经加载多标签页数据 https://github.com/d2-projects/d2-admin/issues/201
await store.dispatch('d2admin/page/isLoaded') await store.dispatch('d2admin/page/isLoaded')
// 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198 // 确认已经加载组件尺寸设置 https://github.com/d2-projects/d2-admin/issues/198
...@@ -32,8 +37,10 @@ router.beforeEach(async (to, from, next) => { ...@@ -32,8 +37,10 @@ router.beforeEach(async (to, from, next) => {
NProgress.start() NProgress.start()
// 关闭搜索面板 // 关闭搜索面板
store.commit('d2admin/search/set', false) store.commit('d2admin/search/set', false)
// 验证当前路由所有的匹配中是否需要有登录验证的 if (from.name === null && to.path !== '/login' && !source) { // 页面刷新 动态路由会失效 初始化路由与左侧菜单栏
if (to.matched.some(r => r.meta.auth)) { await store.dispatch('d2admin/auth/init')
next(to.path)
} else if (to.matched.some(r => r.meta.auth)) { // 验证当前路由所有的匹配中是否需要有登录验证的
// 这里暂时将cookie里是否存有token作为验证是否登录的条件 // 这里暂时将cookie里是否存有token作为验证是否登录的条件
// 请根据自身业务需要修改 // 请根据自身业务需要修改
const token = util.cookies.get('token') const token = util.cookies.get('token')
...@@ -64,7 +71,7 @@ router.afterEach(to => { ...@@ -64,7 +71,7 @@ router.afterEach(to => {
store.dispatch('d2admin/page/open', to) store.dispatch('d2admin/page/open', to)
// 更改标题 // 更改标题
util.title(to.meta.title) util.title(to.meta.title)
store.dispatch('d2admin/auth/set', to.meta.title) // store.dispatch('d2admin/auth/set', to.meta.title)
}) })
export default router export default router
...@@ -4,118 +4,90 @@ import layoutHeaderAside from '@/layout/header-aside' ...@@ -4,118 +4,90 @@ import layoutHeaderAside from '@/layout/header-aside'
const _import = require('@/libs/util.import.' + process.env.NODE_ENV) const _import = require('@/libs/util.import.' + process.env.NODE_ENV)
/** /**
* 在主框架内显示 * 在主框架内显示(children 由后台返回资源点集合 从 resources 中动态过滤加载)
*/ */
const frameIn = [ const frameIn = [{
{ path: '/',
path: '/', redirect: { name: 'index' },
redirect: { name: 'index' }, component: layoutHeaderAside,
component: layoutHeaderAside, children: []
children: [ }
// 首页
{
path: 'index',
name: 'index',
meta: {
auth: true
},
component: _import('systemMonitor')
},
// 演示页面
{
path: 'page1',
name: 'page1',
meta: {
title: '页面 1',
auth: true
},
component: _import('demo/page1')
},
{
path: 'page2',
name: 'page2',
meta: {
title: '页面 2',
auth: true
},
component: _import('demo/page2')
},
{
path: 'page3',
name: 'page3',
meta: {
title: '页面 3',
auth: true
},
component: _import('demo/page3')
},
// 车辆管理
{
path: 'trafficManagement',
name: 'trafficManagement',
meta: {
title: '车辆管理',
auth: true
},
component: _import('trafficManagement')
},
// 子系统管理
{
path: 'subSysManagement',
name: 'subSysManagement',
meta: {
title: '子系统管理',
auth: true
},
component: _import('subSysManagement')
},
// 系统 前端日志
{
path: 'log',
name: 'log',
meta: {
title: '前端日志',
auth: true
},
component: _import('system/log')
},
// 上报日志
{
path: 'reportingLogs',
name: 'reportingLogs',
meta: {
title: '上报日志',
auth: true
},
component: _import('reportingLogs')
},
// 登录日志
{
path: 'loginLogs',
name: 'loginLogs',
meta: {
title: '登录日志',
auth: true
},
component: _import('userManage/loginLogs')
},
// 刷新页面 必须保留
{
path: 'refresh',
name: 'refresh',
hidden: true,
component: _import('system/function/refresh')
},
// 页面重定向 必须保留
{
path: 'redirect/:route*',
name: 'redirect',
hidden: true,
component: _import('system/function/redirect')
}
]
}
] ]
/**
* 首页
*/
export const home = {
path: 'index',
name: 'index',
icon: 'desktop',
meta: {
auth: true,
title: '首页',
id: '101',
pid: '0'
},
component: _import('system/index')
}
/**
* 所有需动态过滤的资源点
*/
export const resources = {
'102': {
path: 'page',
icon: 'folder-o',
name: '页面',
meta: {
auth: true,
title: '页面',
id: '102',
pid: '0'
}
},
'10201': {
path: '/page1',
name: '页面 1',
meta: {
auth: true,
title: '页面 1',
id: '10201',
pid: '102'
},
component: _import('demo/page1')
},
'10202': {
path: '/page2',
name: '页面 2',
meta: {
auth: true,
title: '页面 2',
id: '10202',
pid: '102'
},
component: _import('demo/page2'),
auth: {
'operation': [{ // 列表操作
id: '1020101',
name: '查看'
}, { //
id: '1020102',
name: '编辑'
}],
'action': [] // 按钮操作
}
},
'10203': {
path: '/page3',
name: '页面 3',
meta: {
auth: true,
title: '页面 3',
id: '10203',
pid: '102'
},
component: _import('demo/page3')
}
}
/** /**
* 在主框架之外显示 * 在主框架之外显示
...@@ -132,20 +104,20 @@ const frameOut = [ ...@@ -132,20 +104,20 @@ const frameOut = [
/** /**
* 错误页面 * 错误页面
*/ */
const errorPage = [ export const errorPage = {
{ path: '*',
path: '*', name: '404',
name: '404', component: _import('system/error/404')
component: _import('system/error/404') }
}
]
// 导出需要显示菜单的 // 导出需要显示菜单的
export const frameInRoutes = frameIn export const frameInRoutes = frameIn
// 重新组织后导出 // 重新组织后导出
export default [ export default [
...frameIn, // ...resources,
// ...frameIn,
// dashboard,
...frameOut, ...frameOut,
...errorPage errorPage
] ]
...@@ -2,8 +2,6 @@ import { Message, MessageBox } from 'element-ui' ...@@ -2,8 +2,6 @@ import { Message, MessageBox } from 'element-ui'
import util from '@/libs/util.js' import util from '@/libs/util.js'
import router from '@/router' import router from '@/router'
import { AccountLogin } from '@api/sys.login' import { AccountLogin } from '@api/sys.login'
import routesAll from '@/resources'
import {frameInRoutes} from "@/router/routes.js";
export default { export default {
namespaced: true, namespaced: true,
actions: { actions: {
...@@ -14,7 +12,7 @@ export default { ...@@ -14,7 +12,7 @@ export default {
* @param {Object} payload password {String} 密码 * @param {Object} payload password {String} 密码
* @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式 * @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
*/ */
login ({ dispatch }, { login ({ dispatch, commit }, {
username = '', username = '',
password = '' password = ''
} = {}) { } = {}) {
...@@ -33,16 +31,14 @@ export default { ...@@ -33,16 +31,14 @@ export default {
// 如有必要 token 需要定时更新,默认保存一天 // 如有必要 token 需要定时更新,默认保存一天
util.cookies.set('uuid', res.uuid) util.cookies.set('uuid', res.uuid)
util.cookies.set('token', res.token) util.cookies.set('token', res.token)
const {user,resources} = res const { user, resources } = res
// // console.log(resources,routesAll); // const __aRoutesInPermisions= util.permision.packRoutes(sources,resources)
// const __routes = [] // frameInRoutes[0].children=[dashboard,...__aRoutesInPermisions];
// resources.forEach(obj => {
// frameInRoutes[0].children.push(util.deepFind(routesAll,obj.id))
// });
// frameInRoutes[0].children.push(...__routes);
// console.log(frameInRoutes[0].children.push(...__routes));
// router.addRoutes(frameInRoutes) // router.addRoutes(frameInRoutes)
// const __aMenusInPermisions = util.permision.packAsideMenus(sources,resources)
// await commit('d2admin/page/init', frameInRoutes, { root: true })
// await commit('d2admin/menu/asideSet', [dashboard,...__aMenusInPermisions], { root: true })
await dispatch('d2admin/auth/set', resources, { root: true })
// 设置 vuex 用户信息 // 设置 vuex 用户信息
await dispatch('d2admin/user/set', { await dispatch('d2admin/user/set', {
name: user.name name: user.name
...@@ -118,7 +114,8 @@ export default { ...@@ -118,7 +114,8 @@ export default {
await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true }) await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// DB -> store 持久化数据加载全局尺寸 // DB -> store 持久化数据加载全局尺寸
await dispatch('d2admin/size/load', null, { root: true }) await dispatch('d2admin/size/load', null, { root: true })
// 后台接口 -> store // 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
// end // end
resolve() resolve()
}) })
......
// 设置文件 /*
import setting from '@/setting.js' * @Author: limin
* @Date: 2019-08-27 17:25:12
* @Last Modified by: limin
* @Last Modified time: 2019-08-28 14:25:41
*/
import util from '@/libs/util.js'
import router from '@/router'
import { resources as sources, home, frameInRoutes, errorPage } from '@/router/routes'
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
activePage:'', source: ''
}, },
getters: { getters: {
/** /**
* @description 返回当前的主题信息 不是一个名字 而是当前激活主题的所有数据 * @description 返回当前登录用户权限资源
* @param {Object} state state * @param {Object} state state
*/ */
activePage (state) { source (state, dispatch) {
return state.activePage return state.source
} }
}, },
actions: { actions: {
save2db ({ state, dispatch }) {
return new Promise(async resolve => {
// 设置数据
dispatch('d2admin/db/set', {
dbName: 'sys',
path: 'source',
value: state.source,
user: true
}, { root: true })
// end
resolve()
})
},
/** /**
* @description 激活一个主题 * @description 保存当前角色权限资源
* @param {String} themeValue 需要激活的主题名称 * @param {obj} source 需要保存的权限资源
*/ */
set ({ state, commit, dispatch }, currentPage) { set ({ state, commit, dispatch }, source) {
return new Promise(async resolve => { return new Promise(async resolve => {
// 检查这个主题在主题列表里是否存在 // 检查这个主题在主题列表里是否存在
state.activePage = currentPage state.source = source
console.log(state.activePage) // 持久化数据 防止刷新 数据 丢失
await dispatch('save2db')
// end // end
resolve() resolve()
}) })
}, },
/** /**
* @description 从持久化数据加载主题设置 * @param {Object} context * @description 从持久化数据加载资源数据
* @param {Object} context
*/ */
load ({ state, commit, dispatch }) { load ({ state, commit, dispatch }) {
return new Promise(async resolve => { return new Promise(async resolve => {
if (!state.source) {
state.source = await dispatch('d2admin/db/get', {
dbName: 'sys',
path: 'source',
user: true
}, { root: true })
// console.log(document.querySelector('html').getAttribute('login')==='1');
// if( document.querySelector('html').getAttribute('login')==='1'){
// await dispatch('init')
// router.replace(router.currentRoute.path || '/')
// }
// 用户登录后从持久化数据加载一系列的设置
// await dispatch('d2admin/account/load', { root: true })
}
// end // end
resolve() resolve(state.source)
}) })
} },
},
mutations: {
/** /**
* @description * 过滤并初始化路由与左侧菜单栏
* @param {Object} state state * @param {*} param0
*/ */
dom (state) { init ({ state, commit, dispatch }) {
return new Promise(async resolve => {
// 获取权限资源点
const __source = await dispatch('load')
// 过滤资源点 并动态添加到路由
const __aRoutesInPermisions = util.permision.packRoutes(sources, __source)
frameInRoutes[0].children = [home, ...__aRoutesInPermisions]
router.addRoutes(frameInRoutes)
// router.addRoutes(errorPage)
await commit('d2admin/page/init', frameInRoutes, { root: true })
// 过滤左侧菜单栏
const __aMenusInPermisions = util.permision.packAsideMenus(sources, __source)
const __oHome = util.permision.format2Menu(home)
await commit('d2admin/menu/asideSet', [__oHome, ...__aMenusInPermisions], { root: true })
// DB -> store 加载用户名
// await dispatch('d2admin/user/load', null, { root: true })
// // DB -> store 加载主题
// await dispatch('d2admin/theme/load', null, { root: true })
// // DB -> store 加载页面过渡效果设置
// await dispatch('d2admin/transition/load', null, { root: true })
// // DB -> store 持久化数据加载上次退出时的多页列表
// await dispatch('d2admin/page/openedLoad', null, { root: true })
// // DB -> store 持久化数据加载侧边栏折叠状态
// await dispatch('d2admin/menu/asideCollapseLoad', null, { root: true })
// // DB -> store 持久化数据加载全局尺寸
// await dispatch('d2admin/size/load', null, { root: true })
// 后台接口 -> store
// await dispatch('d2admin/auth/init', null, { root: true })
// end
resolve(state.source)
})
} }
},
mutations: {
} }
} }
...@@ -53,6 +53,7 @@ export default { ...@@ -53,6 +53,7 @@ export default {
// 如果页面过多的话可能需要优化算法 // 如果页面过多的话可能需要优化算法
// valid 有效列表 1, 1, 0, 1 => 有效, 有效, 失效, 有效 // valid 有效列表 1, 1, 0, 1 => 有效, 有效, 失效, 有效
const valid = [] const valid = []
const __oSource = await dispatch('d2admin/auth/load', null, { root: true })
// 处理数据 // 处理数据
state.opened = value.map(opened => { state.opened = value.map(opened => {
// 忽略首页 // 忽略首页
...@@ -61,7 +62,9 @@ export default { ...@@ -61,7 +62,9 @@ export default {
return opened return opened
} }
// 尝试在所有的支持多标签页的页面里找到 name 匹配的页面 // 尝试在所有的支持多标签页的页面里找到 name 匹配的页面
const find = state.pool.find(item => item.name === opened.name) const find = state.pool.find(item => {
return item.name === opened.name && __oSource.some(obj => obj.id === item.meta.id)
})
// 记录有效或无效信息 // 记录有效或无效信息
valid.push(find ? 1 : 0) valid.push(find ? 1 : 0)
// 返回合并后的数据 新的覆盖旧的 // 返回合并后的数据 新的覆盖旧的
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
export default { export default {
name: 'page1', name: 'page1',
render: function (createElement) { render: function (createElement) {
return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' }, return createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-side' }
}, [ }, [
createElement('el-menu', { createElement('el-menu', {
props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active }, props: { collapse: this.asideCollapse, uniqueOpened: true, defaultActive: this.active },
ref: 'menu', ref: 'menu',
on: { select: this.handleMenuSelect } on: { select: this.handleMenuSelect }
}, ), }),
...this.aside.length === 0 && !this.asideCollapse ? [ ...this.aside.length === 0 && !this.asideCollapse ? [
createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-empty', flex: 'dir:top main:center cross:center' } }, [ createElement('div', { attrs: { class: 'd2-layout-header-aside-menu-empty', flex: 'dir:top main:center cross:center' } }, [
createElement('d2-icon', { props: { name: 'inbox' } }), createElement('d2-icon', { props: { name: 'inbox' } }),
...@@ -27,6 +27,6 @@ export default { ...@@ -27,6 +27,6 @@ export default {
]) ])
] : [] ] : []
]) ])
} }
} }
</script> </script>
...@@ -52,58 +52,58 @@ ...@@ -52,58 +52,58 @@
<script> <script>
export default { export default {
methods: { methods: {
handleClick(row) { handleClick (row) {
console.log(row); console.log(row)
},
test(row){
console.log(row);
}
},
components: {
},
mounted () {
this.$event.$on("e-auth-click", function(){
alert(1)
});
}, },
data() { test (row) {
return { console.log(row)
btn:{ }
lable:'测试', },
action:'test', components: {
}, },
tableData: [{ mounted () {
date: '2016-05-03', this.$event.$on('e-auth-click', function () {
name: '王小虎', alert(1)
province: '上海', })
city: '普陀区', },
address: '上海市普陀区金沙江路 1518 弄', data () {
zip: 200333 return {
}, { btn: {
date: '2016-05-02', lable: '测试',
name: '王小虎', action: 'test'
province: '上海', },
city: '普陀区', tableData: [{
address: '上海市普陀区金沙江路 1518 弄', date: '2016-05-03',
zip: 200333 name: '王小虎',
}, { province: '上海',
date: '2016-05-04', city: '普陀区',
name: '王小虎', address: '上海市普陀区金沙江路 1518 弄',
province: '上海', zip: 200333
city: '普陀区', }, {
address: '上海市普陀区金沙江路 1518 弄', date: '2016-05-02',
zip: 200333 name: '王小虎',
}, { province: '上海',
date: '2016-05-01', city: '普陀区',
name: '王小虎', address: '上海市普陀区金沙江路 1518 弄',
province: '上海', zip: 200333
city: '普陀区', }, {
address: '上海市普陀区金沙江路 1518 弄', date: '2016-05-04',
zip: 200333 name: '王小虎',
}] province: '上海',
} city: '普陀区',
address: '上海市普陀区金沙江路 1518 弄',
zip: 200333
}, {
date: '2016-05-01',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 1518 弄',
zip: 200333
}]
} }
} }
</script>
\ No newline at end of file \ No newline at end of file
}
</script>
...@@ -87,58 +87,58 @@ export default { ...@@ -87,58 +87,58 @@ export default {
return { return {
times: [], times: [],
searchForm: { searchForm: {
beginTime: '', beginTime: '',
endTime: '', endTime: '',
carNum: '', carNum: '',
depot: '', depot: '',
subsystemNum: '', subsystemNum: ''
}, },
tableData: [{ tableData: [{
reportTime:'2019-08-16 14:45:21', reportTime: '2019-08-16 14:45:21',
carNum: 'CRH45661-5648', carNum: 'CRH45661-5648',
depot: '青岛', depot: '青岛',
subsystemNum: '3#1F', subsystemNum: '3#1F',
subsystemType:'座椅', subsystemType: '座椅',
subsystemManufactor:'长春通富机电设备有限公司', subsystemManufactor: '长春通富机电设备有限公司',
reportContent: '00x4561aa' reportContent: '00x4561aa'
}, { }, {
reportTime:'2019-08-16 14:45:21', reportTime: '2019-08-16 14:45:21',
carNum: 'CRH45661-5648', carNum: 'CRH45661-5648',
depot: '青岛', depot: '青岛',
subsystemNum: '3#1F', subsystemNum: '3#1F',
subsystemType:'座椅', subsystemType: '座椅',
subsystemManufactor:'长春通富机电设备有限公司', subsystemManufactor: '长春通富机电设备有限公司',
reportContent: '00x4561aa' reportContent: '00x4561aa'
}, { }, {
reportTime:'2019-08-16 14:45:21', reportTime: '2019-08-16 14:45:21',
carNum: 'CRH45661-5648', carNum: 'CRH45661-5648',
depot: '青岛', depot: '青岛',
subsystemNum: '3#1F', subsystemNum: '3#1F',
subsystemType:'座椅', subsystemType: '座椅',
subsystemManufactor:'长春通富机电设备有限公司', subsystemManufactor: '长春通富机电设备有限公司',
reportContent: '00x4561aa' reportContent: '00x4561aa'
}], }],
tableColumns: [{ tableColumns: [{
label: '上报时间', label: '上报时间',
prop: 'reportTime' prop: 'reportTime'
}, { }, {
label: '车辆编号', label: '车辆编号',
prop: 'carNum' prop: 'carNum'
}, { }, {
label: '归属车辆段', label: '归属车辆段',
prop: 'depot' prop: 'depot'
}, { }, {
label: '子系统编号', label: '子系统编号',
prop: 'subsystemNum' prop: 'subsystemNum'
}, { }, {
label: '子系统类型', label: '子系统类型',
prop: 'subsystemType' prop: 'subsystemType'
}, { }, {
label: '子系统厂家', label: '子系统厂家',
prop: 'subsystemManufactor' prop: 'subsystemManufactor'
}, { }, {
label: '上报内容', label: '上报内容',
prop: 'reportContent' prop: 'reportContent'
}], }],
// 页码 // 页码
currentPage: 1, currentPage: 1,
...@@ -149,18 +149,18 @@ export default { ...@@ -149,18 +149,18 @@ export default {
methods: { methods: {
// 搜索 // 搜索
handleSearch() { handleSearch () {
console.log(this.searchForm) console.log(this.searchForm)
}, },
// 页码 // 页码
handleSizeChange(value) { handleSizeChange (value) {
console.log(value) console.log(value)
this.pageSize = value this.pageSize = value
// 调接口 // 调接口
}, },
handleCurrentChange(value) { handleCurrentChange (value) {
console.log(value) console.log(value)
this.currentPage = value this.currentPage = value
// 调接口 // 调接口
......
...@@ -18,7 +18,7 @@ import { constants } from 'fs'; ...@@ -18,7 +18,7 @@ import { constants } from 'fs';
prop="subSystemNum"> prop="subSystemNum">
<el-input <el-input
:disabled="disabled" :disabled="disabled"
v-model="editForm.subSystemNum" v-model="editForm.subSystemNum"
placeholder="请输入子系统编号" placeholder="请输入子系统编号"
></el-input> ></el-input>
</el-form-item> </el-form-item>
...@@ -27,7 +27,7 @@ import { constants } from 'fs'; ...@@ -27,7 +27,7 @@ import { constants } from 'fs';
prop="carNum"> prop="carNum">
<el-input <el-input
:disabled="disabled" :disabled="disabled"
v-model="editForm.carNum" v-model="editForm.carNum"
placeholder="请输入车辆编号" placeholder="请输入车辆编号"
></el-input> ></el-input>
</el-form-item> </el-form-item>
...@@ -96,7 +96,7 @@ export default { ...@@ -96,7 +96,7 @@ export default {
], ],
wgdk: [ wgdk: [
{ required: true, message: '请输入网关端口', trigger: 'blur' } { required: true, message: '请输入网关端口', trigger: 'blur' }
], ]
} }
} }
}, },
...@@ -109,8 +109,8 @@ export default { ...@@ -109,8 +109,8 @@ export default {
}, },
watch: { watch: {
isVisible(val) { isVisible (val) {
this.disabled = this.editForm.subSystemNum ? true : false this.disabled = !!this.editForm.subSystemNum
// this.editForm.interface = this.editForm.carNum ? this.editForm.interface : '1' // this.editForm.interface = this.editForm.carNum ? this.editForm.interface : '1'
this.$refs.editRuleForm.resetFields() this.$refs.editRuleForm.resetFields()
} }
...@@ -119,12 +119,12 @@ export default { ...@@ -119,12 +119,12 @@ export default {
mounted: {}, mounted: {},
methods: { methods: {
handleClose() { handleClose () {
this.$emit('closeDialog') this.$emit('closeDialog')
}, },
handleConfirm() { handleConfirm () {
this.$refs.editRuleForm.validate((vaild) => { this.$refs.editRuleForm.validate((vaild) => {
if(vaild) { if (vaild) {
this.$emit('confirmDialog') this.$emit('confirmDialog')
} }
}) })
......
...@@ -152,29 +152,29 @@ export default { ...@@ -152,29 +152,29 @@ export default {
wgdk: '8000' wgdk: '8000'
}], }],
tableColumns: [{ tableColumns: [{
label: '子系统编号', label: '子系统编号',
prop: 'subSystemNum' prop: 'subSystemNum'
}, { }, {
label: '类型', label: '类型',
prop: 'type' prop: 'type'
}, { }, {
label: '车辆编号', label: '车辆编号',
prop: 'carNum' prop: 'carNum'
}, { }, {
label: '生产厂家', label: '生产厂家',
prop: 'manufacturer' prop: 'manufacturer'
}, { }, {
label: '发送结点序列', label: '发送结点序列',
prop: 'xl' prop: 'xl'
}, { }, {
label: '发送结点接口', label: '发送结点接口',
prop: 'jk' prop: 'jk'
}, { }, {
label: '网关地址', label: '网关地址',
prop: 'wgdz' prop: 'wgdz'
}, { }, {
label: '网关端口', label: '网关端口',
prop: 'wgdk' prop: 'wgdk'
}], }],
// 页码 // 页码
currentPage: 1, currentPage: 1,
...@@ -202,7 +202,7 @@ export default { ...@@ -202,7 +202,7 @@ export default {
// 调接口 // 调接口
}, },
resetForm(obj) { resetForm (obj) {
for (var item in obj) { for (var item in obj) {
if (obj[item] instanceof Array) { if (obj[item] instanceof Array) {
obj[item] = [] obj[item] = []
...@@ -216,12 +216,12 @@ export default { ...@@ -216,12 +216,12 @@ export default {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
}, },
handleEditClose() { handleEditClose () {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
this.resetForm(this.editForm) this.resetForm(this.editForm)
}, },
handleEditConfirm() { handleEditConfirm () {
console.log(JSON.parse(JSON.stringify(this.editForm))) console.log(JSON.parse(JSON.stringify(this.editForm)))
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
this.resetForm(this.editForm) this.resetForm(this.editForm)
......
...@@ -220,8 +220,10 @@ export default { ...@@ -220,8 +220,10 @@ export default {
password: this.formLogin.password password: this.formLogin.password
}) })
.then(() => { .then(() => {
// 重定向对象不存在则返回顶层路径 this.$store.dispatch('d2admin/auth/init').then(_ => {
this.$router.replace(this.$route.query.redirect || '/') // 重定向对象不存在则返回顶层路径
this.$router.replace(this.$route.query.redirect || '/')
})
}) })
} else { } else {
// 登录表单校验失败 // 登录表单校验失败
......
...@@ -239,19 +239,19 @@ export default { ...@@ -239,19 +239,19 @@ export default {
}, },
methods: { methods: {
loadingGetList() { loadingGetList () {
this.tableLoading = true this.tableLoading = true
this.getList() this.getList()
}, },
/* 接口请求-start */ /* 接口请求-start */
getParams() { getParams () {
return { return {
pageCount: this.pageSize, pageCount: this.pageSize,
pageSize: this.currentPage, pageSize: this.currentPage,
...this.searchForm ...this.searchForm
} }
}, },
getList() { getList () {
const params = this.getParams() const params = this.getParams()
params.method = sysMonitorMethods.Search params.method = sysMonitorMethods.Search
request(params).then(res => { request(params).then(res => {
...@@ -262,7 +262,7 @@ export default { ...@@ -262,7 +262,7 @@ export default {
this.tableLoading = false this.tableLoading = false
}) })
}, },
getPie(systemTypeId = 1) { getPie (systemTypeId = 1) {
const params = { const params = {
method: sysMonitorMethods.Report, method: sysMonitorMethods.Report,
systemTypeId: systemTypeId systemTypeId: systemTypeId
......
<!-- 新增/编辑车辆弹窗 --> <!-- 新增/编辑车辆弹窗 -->
import { constants } from 'fs';
<template> <template>
<div> <div>
<el-dialog <el-dialog
:title="!editForm.carNum ? '添加车辆' : '编辑车辆'" :title="!editForm.trafficCode ? '添加车辆' : '编辑车辆'"
:visible.sync="isVisible" :visible.sync="isVisible"
:before-close="handleClose" :before-close="handleClose"
> >
...@@ -15,25 +14,25 @@ import { constants } from 'fs'; ...@@ -15,25 +14,25 @@ import { constants } from 'fs';
> >
<el-form-item <el-form-item
label="车辆编号" label="车辆编号"
prop="carNum"> prop="trafficCode">
<el-input <el-input
:disabled="disabled" :disabled="disabled"
v-model="editForm.carNum" v-model="editForm.trafficCode"
placeholder="请输入车辆编号" placeholder="请输入车辆编号"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="归属车辆段" prop="belongCar"> <el-form-item label="归属车辆段" prop="stationName">
<el-select v-model="editForm.belongCar" placeholder="请选择归属车辆段" clearable filterable> <el-select v-model="editForm.stationName" placeholder="请选择归属车辆段" clearable filterable>
<el-option label="青岛" value="1"></el-option> <el-option label="青岛" value="1"></el-option>
<el-option label="深圳" value="2"></el-option> <el-option label="深圳" value="2"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="维修承包商" prop="repairContractor"> <el-form-item label="维修承包商" prop="merchantName">
<el-input v-model="editForm.repairContractor" placeholder="请输入维修承包商" clearable></el-input> <el-input v-model="editForm.merchantName" placeholder="请输入维修承包商" clearable></el-input>
</el-form-item> </el-form-item>
<el-form-item label="接口开放" prop="interface"> <el-form-item label="接口开放" prop="openType">
<el-radio v-model="editForm.interface" label="1">是</el-radio> <el-radio v-model="editForm.openType" label="1">是</el-radio>
<el-radio v-model="editForm.interface" label="0">否</el-radio> <el-radio v-model="editForm.openType" label="2">否</el-radio>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer"> <div slot="footer">
...@@ -56,18 +55,18 @@ export default { ...@@ -56,18 +55,18 @@ export default {
return { return {
disabled: false, disabled: false,
rules: { rules: {
carNum: [ trafficCode: [
{ required: true, message: '请输入车辆编号', trigger: 'blur' } { required: true, message: '请输入车辆编号', trigger: 'blur' }
], ],
belongCar: [ stationName: [
{ required: true, message: '请选择归属车辆段', trigger: 'change' } { required: true, message: '请选择归属车辆段', trigger: 'change' }
], ],
repairContractor: [ merchantName: [
{ required: true, message: '请输入维修承包商', trigger: 'blur' } { required: true, message: '请输入维修承包商', trigger: 'blur' }
], ],
interface: [ openType: [
{ required: true, message: '请选择接口开放', trigger: 'change' } { required: true, message: '请选择接口开放', trigger: 'change' }
], ]
} }
} }
}, },
...@@ -81,8 +80,8 @@ export default { ...@@ -81,8 +80,8 @@ export default {
watch: { watch: {
isVisible(val) { isVisible(val) {
this.disabled = this.editForm.carNum ? true : false this.disabled = this.editForm.trafficCode ? true : false
this.editForm.interface = this.editForm.carNum ? this.editForm.interface : '1' this.editForm.openType = this.editForm.trafficCode ? this.editForm.openType : '1'
this.$refs.editRuleForm.resetFields() this.$refs.editRuleForm.resetFields()
} }
}, },
...@@ -90,12 +89,12 @@ export default { ...@@ -90,12 +89,12 @@ export default {
mounted: {}, mounted: {},
methods: { methods: {
handleClose() { handleClose () {
this.$emit('closeDialog') this.$emit('closeDialog')
}, },
handleConfirm() { handleConfirm () {
this.$refs.editRuleForm.validate((vaild) => { this.$refs.editRuleForm.validate((vaild) => {
if(vaild) { if (vaild) {
this.$emit('confirmDialog') this.$emit('confirmDialog')
} }
}) })
......
...@@ -128,42 +128,26 @@ export default { ...@@ -128,42 +128,26 @@ export default {
// 表格 // 表格
tableLoading: false, tableLoading: false,
tableData: [], tableData: [],
// tableData: [{
// trafficCode: 'CRH45661-0001',
// stationName: '青岛',
// merchantName: '长春通富机电设备有限公司',
// openType: '1'
// }, {
// trafficCode: 'CRH45661-0002',
// stationName: '青岛',
// merchantName: '长春通富机电设备有限公司',
// openType: '0'
// }, {
// trafficCode: 'CRH45661-0003',
// stationName: '青岛',
// merchantName: '长春通富机电设备有限公司',
// openType: '1'
// }],
tableColumns: [{ tableColumns: [{
label: '车辆编号', label: '车辆编号',
prop: 'trafficCode' prop: 'trafficCode'
}, { }, {
label: '归属车辆段', label: '归属车辆段',
prop: 'stationName' prop: 'stationName'
}, { }, {
label: '维修承包商', label: '维修承包商',
prop: 'merchantName' prop: 'merchantName'
}, { }, {
label: '接口开放', label: '接口开放',
prop: 'openType', prop: 'openType',
formatter: (cellValue) => { formatter: (cellValue) => {
if(cellValue.openType) { if(cellValue.openType) {
return { return {
0: '否', 1: '是',
1: '是' 2: '否'
}[cellValue.openType] }[cellValue.openType]
}
} }
}
}], }],
// 页码 // 页码
currentPage: 1, currentPage: 1,
...@@ -172,28 +156,27 @@ export default { ...@@ -172,28 +156,27 @@ export default {
} }
}, },
mounted() { mounted () {
this.loadingGetList() this.loadingGetList()
}, },
methods: { methods: {
loadingGetList() { loadingGetList () {
this.tableLoading = true this.tableLoading = true
this.getList() this.getList()
}, },
/* 接口请求-start */ /* 接口请求-start */
getParams() { getParams () {
return { return {
pageCount: this.pageSize, pageCount: this.pageSize,
pageSize: this.currentPage, pageSize: this.currentPage,
...this.searchForm ...this.searchForm
} }
}, },
getList() { getList () {
const params = this.getParams() const params = this.getParams()
params.method = trafficManageMethods.Search params.method = trafficManageMethods.Search
request(params).then(res => { request(params).then(res => {
// console.log(res)
this.tableData = res this.tableData = res
this.tableLoading = false this.tableLoading = false
}).catch(err => { }).catch(err => {
...@@ -201,6 +184,17 @@ export default { ...@@ -201,6 +184,17 @@ export default {
this.tableLoading = false this.tableLoading = false
}) })
}, },
addTraffic(value) {
const params = value
params.method = trafficManageMethods.Add
request(params).then(res => {
this.handleEditClose()
notice.okTips()
this.loadingGetList()
}).catch(err => {
notice.errorTips()
})
},
/* 接口请求-end */ /* 接口请求-end */
// 搜索 // 搜索
handleSearch () { handleSearch () {
...@@ -223,7 +217,7 @@ export default { ...@@ -223,7 +217,7 @@ export default {
this.loadingGetList() this.loadingGetList()
}, },
resetForm(obj) { resetForm (obj) {
for (var item in obj) { for (var item in obj) {
if (obj[item] instanceof Array) { if (obj[item] instanceof Array) {
obj[item] = [] obj[item] = []
...@@ -237,15 +231,16 @@ export default { ...@@ -237,15 +231,16 @@ export default {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
}, },
handleEditClose() { handleEditClose () {
this.editVisible = !this.editVisible this.editVisible = !this.editVisible
this.resetForm(this.editForm) this.resetForm(this.editForm)
}, },
handleEditConfirm() { handleEditConfirm () {
console.log(JSON.parse(JSON.stringify(this.editForm))) console.log(JSON.parse(JSON.stringify(this.editForm)))
this.editVisible = !this.editVisible var editParams = JSON.parse(JSON.stringify(this.editForm))
this.resetForm(this.editForm) // this.editVisible = !this.editVisible
// this.resetForm(this.editForm)
}, },
// 表格-编辑 // 表格-编辑
......
...@@ -81,51 +81,51 @@ export default { ...@@ -81,51 +81,51 @@ export default {
return { return {
times: [], times: [],
searchForm: { searchForm: {
beginTime: '', beginTime: '',
endTime: '', endTime: '',
field: '', field: '',
loginType: '' loginType: ''
}, },
tableData: [{ tableData: [{
loginTime:'2019-08-16 14:45:21', loginTime: '2019-08-16 14:45:21',
loginUser: 'abc123', loginUser: 'abc123',
userName: '张三', userName: '张三',
phone: '13511111111', phone: '13511111111',
loginType:'PC', loginType: 'PC',
loginDevice:'win10/chrome' loginDevice: 'win10/chrome'
}, { }, {
loginTime:'2019-08-16 14:45:21', loginTime: '2019-08-16 14:45:21',
loginUser: 'abc123', loginUser: 'abc123',
userName: '李四', userName: '李四',
phone: '13511111111', phone: '13511111111',
loginType:'小程序', loginType: '小程序',
loginDevice:'iphone8', loginDevice: 'iphone8'
}, { }, {
loginTime:'2019-08-16 14:45:21', loginTime: '2019-08-16 14:45:21',
loginUser: 'abc123', loginUser: 'abc123',
userName: '王五', userName: '王五',
phone: '13511111111', phone: '13511111111',
loginType:'PC', loginType: 'PC',
loginDevice:'win10/chrome', loginDevice: 'win10/chrome'
}], }],
tableColumns: [{ tableColumns: [{
label: '登录时间', label: '登录时间',
prop: 'loginTime' prop: 'loginTime'
}, { }, {
label: '登录用户', label: '登录用户',
prop: 'loginUser' prop: 'loginUser'
}, { }, {
label: '姓名', label: '姓名',
prop: 'userName' prop: 'userName'
}, { }, {
label: '联系电话', label: '联系电话',
prop: 'phone' prop: 'phone'
}, { }, {
label: '登录方式', label: '登录方式',
prop: 'loginType' prop: 'loginType'
}, { }, {
label: '登录设备', label: '登录设备',
prop: 'loginDevice' prop: 'loginDevice'
}], }],
// 页码 // 页码
currentPage: 1, currentPage: 1,
...@@ -136,18 +136,18 @@ export default { ...@@ -136,18 +136,18 @@ export default {
methods: { methods: {
// 搜索 // 搜索
handleSearch() { handleSearch () {
console.log(this.searchForm) console.log(this.searchForm)
}, },
// 页码 // 页码
handleSizeChange(value) { handleSizeChange (value) {
console.log(value) console.log(value)
this.pageSize = value this.pageSize = value
// 调接口 // 调接口
}, },
handleCurrentChange(value) { handleCurrentChange (value) {
console.log(value) console.log(value)
this.currentPage = value this.currentPage = value
// 调接口 // 调接口
......
...@@ -25,7 +25,7 @@ module.exports = { ...@@ -25,7 +25,7 @@ module.exports = {
data: `@import '~@/assets/style/public.scss';` data: `@import '~@/assets/style/public.scss';`
} }
} }
}, },
configureWebpack: config => { configureWebpack: config => {
// 非开发环境 // 非开发环境
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {
...@@ -51,15 +51,15 @@ module.exports = { ...@@ -51,15 +51,15 @@ module.exports = {
config.resolve config.resolve
.symlinks(true) .symlinks(true)
config config
.plugin('theme-color-replacer') .plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{ .use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css', fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [ matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列 ...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
], ],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors. externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector changeSelector: forElementUI.changeSelector
}]) }])
config config
// 开发环境 // 开发环境
.when(process.env.NODE_ENV === 'development', .when(process.env.NODE_ENV === 'development',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!