Browse Source

Revert "完善菜单管理模块"

This reverts commit 99b37f1504cbd42a8ab82b37afe2cb478b25b65c.
ljh 2 years ago
parent
commit
07d8fe76d1

+ 117 - 0
chuanyi-admin/package.json

@@ -0,0 +1,117 @@
+{
+  "name": "chuanyi-admin",
+  "version": "4.4.0",
+  "description": "A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features",
+  "author": "Pan <panfree23@gmail.com>",
+  "scripts": {
+    "dev": "vue-cli-service serve",
+    "lint": "eslint --fix --ext .js,.vue src",
+    "electron:build": "vue-cli-service electron:build",
+    "electron:serve": "vue-cli-service electron:serve",
+    "build:prod": "vue-cli-service build",
+    "build:stage": "vue-cli-service build --mode staging",
+    "preview": "node build/index.js --preview",
+    "new": "plop",
+    "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml",
+    "test:unit": "jest --clearCache && vue-cli-service test:unit",
+    "test:ci": "npm run lint && npm run test:unit"
+  },
+  "main": "background.js",
+  "dependencies": {
+    "axios": "0.18.1",
+    "clipboard": "2.0.4",
+    "codemirror": "5.45.0",
+    "core-js": "3.6.5",
+    "driver.js": "0.9.5",
+    "dropzone": "5.5.1",
+    "echarts": "4.2.1",
+    "element-ui": "2.13.2",
+    "file-saver": "2.0.1",
+    "fuse.js": "3.4.4",
+    "js-cookie": "2.2.0",
+    "jsencrypt": "^3.3.0",
+    "jsonlint": "1.6.3",
+    "jszip": "3.2.1",
+    "normalize.css": "7.0.0",
+    "nprogress": "0.2.0",
+    "path-to-regexp": "2.4.0",
+    "screenfull": "4.2.0",
+    "script-loader": "0.7.2",
+    "sortablejs": "1.8.4",
+    "vue": "2.6.10",
+    "vue-count-to": "1.0.13",
+    "vue-router": "3.0.2",
+    "vue-splitpane": "1.0.4",
+    "vuedraggable": "2.20.0",
+    "vuex": "3.1.0",
+    "xlsx": "0.14.1"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "4.4.4",
+    "@vue/cli-plugin-eslint": "4.4.4",
+    "@vue/cli-plugin-unit-jest": "4.4.4",
+    "@vue/cli-service": "4.4.4",
+    "@vue/test-utils": "1.0.0-beta.29",
+    "autoprefixer": "9.5.1",
+    "babel-eslint": "10.1.0",
+    "babel-jest": "23.6.0",
+    "babel-plugin-dynamic-import-node": "2.3.3",
+    "chalk": "2.4.2",
+    "chokidar": "2.1.5",
+    "connect": "3.6.6",
+    "electron": "^13.0.0",
+    "electron-devtools-installer": "^3.1.0",
+    "eslint": "6.7.2",
+    "eslint-plugin-vue": "6.2.2",
+    "html-webpack-plugin": "3.2.0",
+    "husky": "1.3.1",
+    "lint-staged": "8.1.5",
+    "mockjs": "1.0.1-beta3",
+    "plop": "2.3.0",
+    "runjs": "4.3.2",
+    "sass": "1.26.2",
+    "sass-loader": "8.0.2",
+    "script-ext-html-webpack-plugin": "2.1.3",
+    "serve-static": "1.13.2",
+    "svg-sprite-loader": "4.1.3",
+    "svgo": "1.2.0",
+    "vue-cli-plugin-electron-builder": "~2.1.1",
+    "vue-template-compiler": "2.6.10"
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions"
+  ],
+  "bugs": {
+    "url": "https://github.com/PanJiaChen/vue-element-admin/issues"
+  },
+  "engines": {
+    "node": ">=8.9",
+    "npm": ">= 3.0.0"
+  },
+  "keywords": [
+    "vue",
+    "admin",
+    "dashboard",
+    "element-ui",
+    "boilerplate",
+    "admin-template",
+    "management-system"
+  ],
+  "license": "MIT",
+  "lint-staged": {
+    "src/**/*.{js,vue}": [
+      "eslint --fix",
+      "git add"
+    ]
+  },
+  "husky": {
+    "hooks": {
+      "pre-commit": "lint-staged"
+    }
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/PanJiaChen/vue-element-admin.git"
+  }
+}

+ 5 - 0
chuanyi-admin/src/layout/components/index.js

@@ -0,0 +1,5 @@
+export { default as AppMain } from './AppMain'
+export { default as Navbar } from './Navbar'
+export { default as Settings } from './Settings'
+export { default as Sidebar } from './Sidebar/index.vue'
+export { default as TagsView } from './TagsView/index.vue'

+ 45 - 0
chuanyi-admin/src/layout/mixin/ResizeHandler.js

@@ -0,0 +1,45 @@
+import store from '@/store'
+
+const { body } = document
+const WIDTH = 992 // refer to Bootstrap's responsive design
+
+export default {
+  watch: {
+    $route(route) {
+      if (this.device === 'mobile' && this.sidebar.opened) {
+        store.dispatch('app/closeSideBar', { withoutAnimation: false })
+      }
+    }
+  },
+  beforeMount() {
+    window.addEventListener('resize', this.$_resizeHandler)
+  },
+  beforeDestroy() {
+    window.removeEventListener('resize', this.$_resizeHandler)
+  },
+  mounted() {
+    const isMobile = this.$_isMobile()
+    if (isMobile) {
+      store.dispatch('app/toggleDevice', 'mobile')
+      store.dispatch('app/closeSideBar', { withoutAnimation: true })
+    }
+  },
+  methods: {
+    // use $_ for mixins properties
+    // https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
+    $_isMobile() {
+      const rect = body.getBoundingClientRect()
+      return rect.width - 1 < WIDTH
+    },
+    $_resizeHandler() {
+      if (!document.hidden) {
+        const isMobile = this.$_isMobile()
+        store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')
+
+        if (isMobile) {
+          store.dispatch('app/closeSideBar', { withoutAnimation: true })
+        }
+      }
+    }
+  }
+}

+ 15 - 0
chuanyi-admin/src/utils/errorCode.js

@@ -0,0 +1,15 @@
+export default {
+  '401': '认证失败,无法访问系统资源',
+  '403': '当前操作没有权限',
+  '404': '访问资源不存在',
+
+  '900': '初始化未完成,请稍候再试',
+  '901': '数据正在处理,请勿重复提交',
+  '902': '下载文件出现错误,请联系管理员',
+  '903': '正在下载文件,请稍候',
+  '904': '系统接口连接异常',
+  '905': '系统接口请求超时',
+  '906': '用户数据异常,请重新登录',
+
+  'default': '系统未知错误,请反馈给管理员'
+}

+ 34 - 0
chuanyi-admin/src/utils/jsencrypt.js

@@ -0,0 +1,34 @@
+import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
+
+// 密钥对生成 http://web.chacuo.net/netrsakeypair
+// 生成密钥位数:1024位(bit)
+// 密钥格式:PKCS#8
+// 输出格式:PEM/Base64
+
+/**
+ * RSA根据公钥加密
+ * @param txt
+ * @param publicKey
+ * @returns {string | false | Promise<ArrayBuffer>}
+ */
+export function encrypt(txt, publicKey) {
+  const encryptor = new JSEncrypt()
+  // 设置公钥
+  encryptor.setPublicKey(publicKey)
+  // 对数据进行加密
+  return encryptor.encrypt(txt)
+}
+
+/**
+ * RSA内容解密
+ * @param txt
+ * @param privateKey
+ * @returns {string | false | Promise<ArrayBuffer>}
+ */
+export function decrypt(txt, privateKey) {
+  const encryptor = new JSEncrypt()
+  // 设置私钥
+  encryptor.setPrivateKey(privateKey)
+  // 对数据进行解密
+  return encryptor.decrypt(txt)
+}

+ 55 - 18
chuanyi-admin/src/views/system/menu/index.vue

@@ -16,8 +16,8 @@
         <el-button size="mini" icon="el-icon-plus" type="primary" plain @click="handelAdd">新增</el-button>
 
         <!-- 表格数据信息 -->
-        <el-table v-loading="loading" :data="menuList" row-key="id">
-          <el-table-column type="index" width="50" align="center" />
+        <el-table v-loading="loading" :data="menuList" @selection-change="handleSelectionChange">
+          <el-table-column type="selection" width="50" align="center" />
           <el-table-column key="menuName" label="菜单名称" align="center" prop="menuName" />
           <el-table-column key="menuIcon" label="菜单图标" align="center" prop="menuIcon" />
           <el-table-column key="menuUrl" label="路由地址" align="center" prop="menuUrl" />
@@ -50,7 +50,6 @@
       </el-col>
     </el-row>
 
-    <!-- 弹出框 -->
     <el-dialog :title="title" :visible.sync="dialogVisible" width="35%">
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-row>
@@ -59,9 +58,9 @@
               <el-select v-model="form.parentId" clearable placeholder="请选择" style="width:100%">
                 <el-option
                   v-for="item in options"
-                  :key="item.id"
-                  :label="item.menuName"
-                  :value="item.id"
+                  :key="item.parentId"
+                  :label="item.label"
+                  :value="item.parentId"
                 />
               </el-select>
             </el-form-item>
@@ -110,10 +109,48 @@
 
 <script>
 import { getMenuList, addtMenuList, detailtMenuList, delMenuList, editMenuList } from '@/api/system/menu.js'
-import XEUtils from 'xe-utils'
 export default {
   data() {
     return {
+      data: [{
+        label: '一级 1',
+        children: [{
+          label: '二级 1-1',
+          children: [{
+            label: '三级 1-1-1'
+          }]
+        }]
+      }, {
+        label: '一级 2',
+        children: [{
+          label: '二级 2-1',
+          children: [{
+            label: '三级 2-1-1'
+          }]
+        }, {
+          label: '二级 2-2',
+          children: [{
+            label: '三级 2-2-1'
+          }]
+        }]
+      }, {
+        label: '一级 3',
+        children: [{
+          label: '二级 3-1',
+          children: [{
+            label: '三级 3-1-1'
+          }]
+        }, {
+          label: '二级 3-2',
+          children: [{
+            label: '三级 3-2-1'
+          }]
+        }]
+      }],
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      },
       // 遮罩层
       loading: true,
       // 查询参数
@@ -132,7 +169,10 @@ export default {
       // 弹出框表单
       form: {},
       // 菜单类别
-      options: [],
+      options: [
+        { label: '主类目', parentId: 0 },
+        { label: '菜单', parentId: 1 }
+      ],
       // 表单验证
       rules: {
         menuName: [
@@ -155,19 +195,17 @@ export default {
   methods: {
     /** 获取表格数据 */
     getMenuList() {
-      getMenuList(this.queryParams).then(res => {
-        const data = res.data
-        this.menuList = XEUtils.toArrayTree(data.menuList)
-        this.options = data.menuList.map((item) => {
-          return {
-            menuName: item.menuName,
-            id: item.id
-          }
-        })
+      getMenuList(this.queryParams).then(response => {
+        const data = response.data
+        this.menuList = data.menuList
         this.total = data.count
         this.loading = false
       })
     },
+    /** 表格多选事件 */
+    handleSelectionChange() {
+
+    },
     /** 搜索 */
     handelSearch() {
       this.queryParams.page = 1
@@ -221,7 +259,6 @@ export default {
       this.$refs[formName].validate((valid) => {
         if (valid) {
           if (this.title === '添加菜单') {
-            this.form.parentId = this.form.parentId || 0
             addtMenuList(this.form).then(res => {
               if (res.code === 200) {
                 this.$message({