kongdeqiang
2023-06-08 f015ecea67a1e322374c422f6661366f93341556
修改前端页面
6个文件已修改
9个文件已添加
550 ■■■■ 已修改文件
App.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.html 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.js 159 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package-lock.json 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/common/Header.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/common/Sidebar.vue 122 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/page/Login.vue 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/actions.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/getters.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/index.js 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/mutations.js 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/state.js 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/mappingData.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
App.vue
New file
@@ -0,0 +1,14 @@
<template>
    <div id="app">
        <router-view></router-view>
    </div>
</template>
<style>
    @import "./assets/css/main.css";
    @import "./assets/css/color-dark.css";     /*深色主题*/
    /*@import "./assets/css/theme-green/color-green.css";   浅绿色主题*/
    /* 解决element-ui的table表格控件表头与内容列不对齐问题 */
    .el-table th.gutter{
        display: table-cell!important;
    }
</style>
index.html
New file
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <title>峰峰矿区综合行政执法局</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=tuVbv4tLIzoX7IWdeKeTwojDqPILFoe5"></script>
    <!--<script src="//mapv.baidu.com/build/mapv.min.js"></script>
    <script src="https://code.bdstatic.com/npm/mapvgl@1.0.0-beta.127/dist/mapvgl.min.js"></script>-->
    <script type="text/javascript" src="http://api.map.baidu.com/library/Heatmap/2.0/src/Heatmap_min.js"></script>
    <script src="./static/iconfont.js"></script>
    <title>峰峰智慧泊车系统</title>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>
main.js
New file
@@ -0,0 +1,159 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios';
import qs from 'qs'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; // 默认主题
import './assets/css/fonts/iconfont.css'
// import '../static/css/theme-green/index.css';       // 浅绿色主题
import './assets/css/icon.css';
import './components/common/directives';
import "babel-polyfill";
import ByUtils, {byUtils} from './assets/js/ByUtils'
import StringUtil from './assets/js/StringUtil'
import TscPrintUtil from './assets/js/TscPrintUtil'
import Print from './assets/js/print'
import moment from 'moment'
import store from './store/index' // 引入vuex
Vue.prototype.$moment = moment;
Vue.use(Print) // 注册
import ViewUI from 'view-design';
import 'lib-flexible'
// import style
import 'view-design/dist/styles/iview.css';
import preview from 'vue-photo-preview'
//preview的参数
var option = {
    minZoom:0.3,
    maxSpreadZoom: 20, // 控制预览图最大的倍数,默认是2倍,我这里改成了原图
    fullscreenEl: false, //控制是否显示右上角全屏按钮
    closeEl: true, //控制是否显示右上角关闭按钮
    tapToClose: true, //点击滑动区域应关闭图库
    shareEl: false, //控制是否显示分享按钮
    zoomEl: true, //控制是否显示放大缩小按钮
    counterEl: true, //控制是否显示左上角图片数量按钮
    arrowEl: true,  //控制如图的左右箭头(pc浏览器模拟手机时)
    tapToToggleControls: true, //点击应切换控件的可见性
    allowPanToNext:true, //当前项目缩放时,允许滑动到下一个/上一个项目
    clickToCloseNonZoomable: false,//点击图片应关闭图库,仅当图像小于视口的大小时
    closeOnVerticalDrag:false,//垂直拖动和未缩放图像时,请关闭图库
    pinchToClose:false,//捏以关闭画廊手势
    getDoubleTapZoom:()=>1 //函数应返回缩放级别,在双击手势后,用户单击缩放图标或鼠标单击图像本身时,图像将缩放到该级别
}
Vue.use(preview,option)
Vue.use(ViewUI);
Vue.config.productionTip = false
Vue.use(ElementUI, {
    size: 'small'
});
import echarts from 'echarts'
Vue.prototype.$echarts = echarts;
import '@/utils/lib-fiexible'
import {getStore,setStore,removeStore} from "./libs/store";
Vue.prototype.getStore = getStore
Vue.prototype.setStore = setStore
Vue.prototype.removeStore = removeStore
Vue.prototype.$axios = axios;
axios.defaults.withCredentials = true
// 对提交的数据进行json序列化,可能存在问题,暂时未发现什么问题
axios.interceptors.request.use((config) => {
    if (config.method === 'post') {
        config.data = qs.stringify(config.data)
    }
    if (config.method === 'get') {
        config.data = qs.stringify(config.data)
    }
    console.log(config.data)
    return config
})
// 配置文件
Vue.prototype.$systemconfig = {
// 服务端路径
    basePath: 'http://183.196.93.178:8089',
    //basePath:'http://127.0.0.1:8089'
}
Vue.prototype.$byutil = byUtils
Vue.prototype.$stringUtil = StringUtil
Vue.prototype.$tscPrintUtil = TscPrintUtil
// const rolesList = JSON.parse(localStorage.getItem('userRouters'))
//使用钩子函数对路由进行权限跳转
// router.beforeEach((to, from, next) => {
//     let user = byUtils.getUser()
//     if (!user && to.path!== '/') {
//         next('/');
//     }
//    console.log(to,"触发了",router.options.routes);
//    // type 2 : all admin
//    // type 0 :  泊车 id:2
//    // type 1 :  执法 id:3
//    next();
//         //
//     // if (to.path==='/login') {
//     //     byUtils.setUser(null)
//     // }
//     // let user = byUtils.getUser()
//     // console.log(user)
//     // if (!user && to.path !== '/login') {
//     //     next('/login');
//     // } else if (to.meta.permission) {
//     //     // 如果是管理员权限则可进入,这里只是简单的模拟管理员权限而已
//     //     role === 'admin' ? next() : next('/403');
//     // } else {
//         // 简单的判断IE10及以下不进入富文本编辑器,该组件不兼容
//         if (navigator.userAgent.indexOf('MSIE') > -1 && to.path === '/editor') {
//             Vue.prototype.$alert('vue-quill-editor组件不兼容IE10及以下浏览器,请使用更高版本的浏览器查看', '浏览器不兼容通知', {
//                 confirmButtonText: '确定'
//             });
//         } else {
//             next();
//         }
//     // }
// })
// router.beforeEach((to, from, next) => {
//     if(!sessionStorage.accessToken){
//         router.push({'path': '/'});
//     }
// })
// router.beforeEach((to, from, next) => {
//     if (to.path === '/login') {
//         next();
//     } else {
//         //sessionStorage.accessToken
//         let token = localStorage.getItem('userId');
//         if(token){
//             if (token==null) {
//                 next('/login');
//             } else {
//                 if(token == ''){
//                     next('/login');
//                 }else{
//                     next();
//                 }
//             }
//         }else{
//             next('/login');
//         }
//     }
// });
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
package-lock.json
@@ -15803,6 +15803,11 @@
        "sortablejs": "^1.10.1"
      }
    },
    "vuex": {
      "version": "3.6.2",
      "resolved": "https://registry.npmmirror.com/vuex/-/vuex-3.6.2.tgz",
      "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw=="
    },
    "watchpack": {
      "version": "1.6.1",
      "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.1.tgz",
package.json
@@ -35,6 +35,7 @@
    "vue-router": "^3.0.1",
    "vue-schart": "^1.0.0",
    "vuedraggable": "^2.17.0",
    "vuex": "^3.6.2",
    "webpack-dev-server": "^2.9.1"
  },
  "devDependencies": {
src/components/common/Header.vue
@@ -71,6 +71,7 @@
    </div>
</template>
<script>
import {mapMutations} from 'vuex'
    import bus from '../common/bus';
    export default {
        data() {
@@ -101,6 +102,9 @@
      },
      methods:{
        ...mapMutations([
        'CLEAR_ROLELIST'
        ]),
            // 用户名下拉菜单选择事件
            handleCommand(command) {
                if(command == 'loginout'){
@@ -108,6 +112,7 @@
                    sessionStorage.userRoleNames = ''
                    sessionStorage.userGuid = ''
                    sessionStorage.userName = ''
                    this.CLEAR_ROLELIST(); //清空本地权限缓存
                    this.$router.push('/login');
                    // this.$confirm("是否退出登录?", "提示", {
                    //     confirmButtonText: "确定",
src/components/common/Sidebar.vue
@@ -1,14 +1,16 @@
<template>
    <div class="sidebar">
        <el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#324157"
            text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened router>
            text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened router
            >
            <template v-for="item in items">
                <template v-if="item.children">
                    <el-submenu :index="item.indexUrl" :key="item.indexUrl">
                    <el-submenu :index="item.indexUrl" :key="item.indexUrl"
                    >
                        <template slot="title">
                            <i :class="item.icon"></i><span slot="title">{{ item.name }}</span>
                        </template>
                        <template v-for="subItem in item.children">
                        <div v-for="subItem in item.children" :key="subItem.indexUrl">
                            <!--<el-submenu v-if="subItem.children" :index="subItem.indexUrl" :key="subItem.indexUrl">-->
                                <!--<template slot="title">-->
                                    <!--<i :class="subItem.icon"></i><span slot="title">{{ subItem.name }}</span>-->
@@ -19,12 +21,12 @@
                                    <!--</template>-->
                                <!--</el-menu-item>-->
                            <!--</el-submenu>-->
                            <el-menu-item :index="subItem.indexUrl" :key="subItem.indexUrl">
                            <el-menu-item :index="subItem.indexUrl">
                                <template slot="title">
                                    <i :class="subItem.icon"></i><span slot="title">{{ subItem.name }}</span>
                                </template>
                            </el-menu-item>
                        </template>
                        </div>
                    </el-submenu>
                </template>
                <template v-else>
@@ -41,112 +43,18 @@
<script>
    import bus from '../common/bus';
    import {mapState} from 'vuex';
    export default {
        data() {
            return {
                collapse: false,
                items: [
                  {
                    id:1,
                    icon: 'el-icon-folder-opened',
                    indexUrl: '1',
                    name: '系统管理',
                    children:[
                      {
                        id:1,
                        icon: 'el-icon-user-solid',
                        name: '人员管理',
                        parentId: 1,
                        indexUrl: 'user'
                      }
                    ]
                  },
                  {
                      id:2,
                      icon: 'el-icon-folder-opened',
                      indexUrl: '2',
                      name: '智慧泊车管理',
                      children:[
                          {
                              icon: 'el-icon-document',
                              name: '停车场管理',
                              parentId: 2,
                              indexUrl: "park"
                          },
                          {
                              icon: 'el-icon-document',
                              name: '收费规则管理',
                              parentId: 2,
                              indexUrl: "costRule"
                          },
                          {
                            icon: 'el-icon-document',
                            name: '车辆入场管理',
                            parentId: 2,
                            indexUrl: "enterPark"
                          },
                          {
                            icon: 'el-icon-document',
                            name: '车辆出场管理',
                            parentId: 2,
                            indexUrl: "outPark"
                          },
                          {
                            icon: 'el-icon-document',
                            name: '白名单管理',
                            parentId: 2,
                            indexUrl: "whiteList"
                          },
                          {
                            icon: 'el-icon-document',
                            name: '泊车发票管理',
                            parentId: 2,
                            indexUrl: "parkticket"
                          },
                          {
                            icon: 'el-icon-document',
                            name: '订单统计',
                            parentId: 2,
                            indexUrl: "orderRecord"
                          },
                      ]
                  },
                  {
                    id:3,
                    icon: 'el-icon-folder-opened',
                    indexUrl: '3',
                    name: '智慧罚没管理',
                    children:[
                      {
                        icon: 'el-icon-document',
                        name: '违章类型管理',
                        parentId: 3,
                        indexUrl: "violationType"
                      },
                      {
                        icon: 'el-icon-document',
                        name: '街道管理',
                        parentId: 3,
                        indexUrl: "street"
                      },
                      {
                        icon: 'el-icon-document',
                        name: '罚单管理',
                        parentId: 3,
                        indexUrl: "ticket"
                      },
                      {
                        icon: 'el-icon-document',
                        name: '罚没发票管理',
                        parentId: 3,
                        indexUrl: "zfticket"
                      },
                    ]
                  },
                ]
            }
        },
        computed:{
          ...mapState({
             items:'resultAsyncRoutes'
            }),
            onRoutes(){
                return this.$route.path.replace('/','');
            }
@@ -158,11 +66,15 @@
            })
        },
        mounted(){
            // type 2 : all
            // type 0 :  泊车 id:2
            // type 1 :  执法 id:3
            // var url = this.$systemconfig.basePath + '/menuList';
            // this.$byutil.postData(this,url,{},res=>{
            //     this.items = res.obj.menuList;
            // })
        }
        },
    }
</script>
src/components/page/Login.vue
@@ -23,9 +23,11 @@
</template>
<script>
   import {mapMutations,mapState} from 'vuex';
    export default {
        data: function(){
            return {
               // 权限菜单
                ruleForm: {
                    loginName: '',
                    password: '',
@@ -43,8 +45,15 @@
        created(){
            //this.$router.push({'path': '/home'});
        },
        computed:{
            ...mapState(['resultAsyncRoutes'])
        },
        methods: {
            ...mapMutations([
            'SET_ROLELISt',
            'SET_ROLES'
       ]),
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
@@ -52,10 +61,14 @@
                        this.$byutil.postData(this,url,this.ruleForm,res=>{
                            let data = res.data;
                          if (data) {
                            localStorage.userId = data.id
                            localStorage.name = data.name
                            localStorage.type = data.type
                            this.$router.push({'path': '/home'});
                            localStorage.userId = data.id;
                            localStorage.name = data.name;
                            localStorage.type = data.type;
                            // localStorage.userRouters = JSON.stringify(this.items) ;
                            this.SET_ROLES(data.type)
                            this.SET_ROLELISt();  // 筛选左侧菜单栏
                            this.$router.push({'path': this.resultAsyncRoutes[0].children[0].indexUrl || '/home'});
                             // 自动跳转当前权限路由的第一个页面 ,如果找不到就去跳home
                            // if (this._isMobile()) {
                            //     this.$router.push({'path': '/index4'});
                            // } else {
src/main.js
@@ -15,6 +15,7 @@
import TscPrintUtil from './assets/js/TscPrintUtil'
import Print from './assets/js/print'
import moment from 'moment'
import store from './store/index' // 引入vuex
Vue.prototype.$moment = moment;
Vue.use(Print) // 注册
import ViewUI from 'view-design';
@@ -83,13 +84,22 @@
Vue.prototype.$byutil = byUtils
Vue.prototype.$stringUtil = StringUtil
Vue.prototype.$tscPrintUtil = TscPrintUtil
// const rolesList = JSON.parse(localStorage.getItem('userRouters'))
//使用钩子函数对路由进行权限跳转
// router.beforeEach((to, from, next) => {
//     let user = byUtils.getUser()
//     if (!user && to.path!== '/') {
//         next('/');
//     }
//    console.log(to,"触发了",router.options.routes);
//    // type 2 : all admin
//    // type 0 :  泊车 id:2
//    // type 1 :  执法 id:3
//    next();
//         //
//     // if (to.path==='/login') {
//     //     byUtils.setUser(null)
@@ -110,6 +120,7 @@
//         } else {
//             next();
//         }
//     // }
// })
// router.beforeEach((to, from, next) => {
@@ -143,5 +154,6 @@
new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
src/store/actions.js
New file
@@ -0,0 +1,17 @@
export default {
    setResNameAsync:(context,payload)=>{
      //异步修改值(异步中调用同步)
      //context指的是Vuex上下文,相当于this.$store
     //六秒后执行代码
      setTimeout(function(){
      comtext.commit("setResName",payload);
      },6000);
      let _this = payload._this;
      let url = _this.axios.url.SYSTEM_MENU_TREE;
      _this.axios.post(url,{}).then(r=>{
        console.log(r);
      }).catch(e=>{
      });
    }
  }
src/store/getters.js
New file
@@ -0,0 +1,5 @@
export default{
    getResName:(state)=>{
      return state.resName;
    }
  }
src/store/index.js
New file
@@ -0,0 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import getters from './getters'
import actions from './actions'
import mutations from './mutations'
Vue.use(Vuex)
const store = new Vuex.Store({
  state,
  getters,
  actions,
  mutations
})
 export default store
src/store/mutations.js
New file
@@ -0,0 +1,46 @@
export default {
    setResName:(state,payload)=>{
      //state对象就对应了state.js中的对象
      //payload载荷 对应的 传递的 json对象参数{name:xx,age:12}
      state.resName = payload.resName
    },
    SET_ROLES:(state,payload) =>{
    state.roles = payload;
    },
    SET_ROLELISt:(state,payload)=>{
        console.log('触发')
        //处理左侧菜单栏逻辑
            // type 2 : all admin
            // type 0 :  泊车 id:2
            // type 1 :  执法 id:3
            // state.roles  // 用户权限字段
            // state.resultAsyncRoutes // 用户权限路由
            switch (state.roles) {
                case 0:
                    state.resultAsyncRoutes = state.items.filter((item)=>item.id == 2);
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                    console.log(state.resultAsyncRoutes,state.roles,'0泊车')
                    break;
                case 1:
                    state.resultAsyncRoutes =state.items.filter((item)=>item.id == 3);
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                  console.log(state.resultAsyncRoutes,state.roles,'1执法')
                  break;
                  case 2:
                    state.resultAsyncRoutes = state.items;
                    localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
                      console.log(state.resultAsyncRoutes,state.roles,' 全部')//  不用修改
                  break;
                default:
                    break;
            }
    },
    CLEAR_ROLELIST:(state,payload)=>{
        state.resultAsyncRoutes =  [];
        localStorage.setItem('userRouters',JSON.stringify(state.resultAsyncRoutes));
    }
  }
src/store/state.js
New file
@@ -0,0 +1,105 @@
export default {
    resName:'dxy',
    roles:JSON.parse(localStorage.getItem('type')) || "",
    resultAsyncRoutes:JSON.parse(localStorage.getItem('userRouters')) || [] ,// 根据权限筛选路由
    items: [
        {
          id:1,
          icon: 'el-icon-folder-opened',
          indexUrl: '1',
          name: '系统管理',
          children:[
            {
              id:1,
              icon: 'el-icon-user-solid',
              name: '人员管理',
              parentId: 1,
              indexUrl: 'user'
            }
          ]
        },
        {
            id:2,
            icon: 'el-icon-folder-opened',
            indexUrl: '2',
            name: '智慧泊车管理',
            children:[
                {
                    icon: 'el-icon-document',
                    name: '停车场管理',
                    parentId: 2,
                    indexUrl: "park"
                },
                {
                    icon: 'el-icon-document',
                    name: '收费规则管理',
                    parentId: 2,
                    indexUrl: "costRule"
                },
                {
                  icon: 'el-icon-document',
                  name: '车辆入场管理',
                  parentId: 2,
                  indexUrl: "enterPark"
                },
                {
                  icon: 'el-icon-document',
                  name: '车辆出场管理',
                  parentId: 2,
                  indexUrl: "outPark"
                },
                {
                  icon: 'el-icon-document',
                  name: '白名单管理',
                  parentId: 2,
                  indexUrl: "whiteList"
                },
                {
                  icon: 'el-icon-document',
                  name: '泊车发票管理',
                  parentId: 2,
                  indexUrl: "parkticket"
                },
                {
                  icon: 'el-icon-document',
                  name: '订单统计',
                  parentId: 2,
                  indexUrl: "orderRecord"
                },
            ]
        },
        {
          id:3,
          icon: 'el-icon-folder-opened',
          indexUrl: '3',
          name: '智慧罚没管理',
          children:[
            {
              icon: 'el-icon-document',
              name: '违章类型管理',
              parentId: 3,
              indexUrl: "violationType"
            },
            {
              icon: 'el-icon-document',
              name: '街道管理',
              parentId: 3,
              indexUrl: "street"
            },
            {
              icon: 'el-icon-document',
              name: '罚单管理',
              parentId: 3,
              indexUrl: "ticket"
            },
            {
              icon: 'el-icon-document',
              name: '罚没发票管理',
              parentId: 3,
              indexUrl: "zfticket"
            },
          ]
        },
      ],
 }
src/utils/mappingData.js
New file
@@ -0,0 +1,2 @@
export const USER_TYPEUSER_ASYNCROUTES = 'userRouters'; // 用户权限数组
export const USER_TYPE = 'userRouters'; // 用户权限字段