scorpio 3 лет назад
Родитель
Сommit
c282d3d9a7

+ 8 - 1
src/api/login/index.js

@@ -26,6 +26,13 @@ export default {
     return fetch('/blade-auth/oauth/logout')
   },
   getUserInfo () {
-    return fetch('//blade-project-manage/other/v1/getUserInfo')
+    return fetch('/blade-project-manage/other/v1/getUserInfo')
+  },
+  /**
+   * 获取按钮权限
+   * @returns {Promise | Promise<unknown>}
+   */
+  getPermission () {
+    return fetch('/blade-system/menu/buttons')
   }
 }

BIN
src/assets/img/code.png


+ 13 - 3
src/layout/top.vue

@@ -13,7 +13,7 @@
         <el-col :span='12'>
           <div class='flex-child-average flex-justify-end flex padding-right '>
             <div class='padding flex flex-align-center'>
-              <el-avatar class='mr-10' :size="30" :src="user.info.avatarUrl.length > 0 ?  user.info.avatarUrl : 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'" />
+              <el-avatar class='mr-10' :size="30" :src="user.info.avatarUrl && user.info.avatarUrl.length > 0 ?  user.info.avatarUrl : 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'" />
               <el-dropdown @command='dropDown'>
                 <span class="flex flex-center">
                   {{user.info.nikeName}} / {{user.info.deptName}}
@@ -37,18 +37,27 @@
 <script>
 import navStore from '../store/nav.js'
 import { useStore } from '../store/user.js'
+import permissionStore from '@/store/permission.js'
 
 export default {
   name: 'top',
   setup () {
     const nav = navStore()
     const user = useStore()
-    return { nav, user }
+    const permission = permissionStore()
+    return { nav, user, permission }
   },
   created () {
-
+    this.getPermission()
   },
   methods: {
+    getPermission () {
+      this.$api.login.getPermission().then(res => {
+        if (res.code === 200) {
+          this.permission.addPermission(res.data)
+        }
+      })
+    },
     dropDown (res) {
       if (res === 'info') {
         this.$message.success('个人中心')
@@ -56,6 +65,7 @@ export default {
         this.$api.login.logout().then(res => {
           if (res.success === 'true') {
             this.nav.cleanMenu()
+            this.permission.cleanPermission()
             this.$message.success('退出登录')
             this.$router.replace('/login')
           } else {

+ 29 - 5
src/page/login.vue

@@ -10,8 +10,21 @@
         </div>
 
         <div class='flex-child-average right'>
-          <div class='padding-20'>
-            <span class='font-24 black bold '>欢迎来到梧桐树云项目管理云平台👏</span>
+
+          <div class='flex flex-justify-end '>
+            <div>
+              <img src='../assets/img/code.png' style='width: 50px' @click='qrCodeLogin = !qrCodeLogin'/>
+            </div>
+          </div>
+
+          <div v-if='qrCodeLogin' class='flex flex-center flex-col'>
+            <span class='font-24 black bold '>欢迎来到梧桐树云平台👏</span>
+            <img class='mt-20' src='../assets/img/code.png' style='width: 300px'/>
+            <span class='mt-20 grey-6 bold '>请使用微信扫一扫,进行登录</span>
+          </div>
+
+          <div v-else class='padding-20' style='margin-top: -50px'>
+            <span class='font-24 black bold '>欢迎来到梧桐树云平台👏</span>
             <el-form class='form' :model="form" :rules="rules" ref='loginForm'>
               <el-form-item prop='name'>
                 <el-input
@@ -64,7 +77,7 @@
             <el-divider/>
             <div class='flex flex-col'>
               <span class='grey-6'>
-              由梧桐经济院提供技术支持
+              由梧桐经济院提供技术支持
               </span>
               <div>
                 <el-button size='small' type='primary' plain class='mt-10' @click='loginAdmin'>admin</el-button>
@@ -89,11 +102,13 @@
 import md5 from 'js-md5'
 import { useStore } from '@/store/user.js'
 import { setToken } from '../utils/auth.js'
+import permissionStore from '@/store/permission.js'
 export default {
   name: 'login',
   setup () {
     const user = useStore()
-    return { user }
+    const permission = permissionStore()
+    return { user, permission }
   },
   data () {
     return {
@@ -117,7 +132,8 @@ export default {
         ]
       },
       code: '',
-      header: ''
+      header: '',
+      qrCodeLogin: true
     }
   },
   created () {
@@ -155,6 +171,7 @@ export default {
       this.form.pass = 'admin'
     },
     getInfo () {
+      this.getPermission()
       this.$api.login.getUserInfo().then(res => {
         if (res.code === 200) {
           // 保存信息
@@ -166,6 +183,13 @@ export default {
           this.user.setUserInfo(res.data)
         }
       })
+    },
+    getPermission () {
+      this.$api.login.getPermission().then(res => {
+        if (res.code === 200) {
+          this.permission.addPermission(res.data)
+        }
+      })
     }
   }
 }

+ 35 - 0
src/store/permission.js

@@ -0,0 +1,35 @@
+import { defineStore } from 'pinia'
+
+export const permissionStore = defineStore('permissionStore', {
+  persist: false, // 持久化
+  state: () => ({
+    permissions: {}
+  }),
+  actions: {
+    /**
+     * 设置用户信息
+     */
+    addPermission (list = []) {
+      list.forEach(sub => {
+        if (typeof (sub) === 'object') {
+          const children = sub.children
+          const code = sub.code
+          if (children) {
+            this.addPermission(children)
+          } else {
+            const item = { [code]: true }
+            this.permissions = Object.assign(this.permissions, item)
+          }
+        }
+      })
+    },
+    /**
+     * 清空权限配置(用户退出时候,必须调调用此菜单)
+     */
+    cleanPermission () {
+      this.permissions = {}
+    }
+  }
+})
+
+export default permissionStore

+ 14 - 6
src/utils/tools.js

@@ -1,7 +1,15 @@
-export function bytesToSize(bytes) {
-    const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
-    if (bytes === 0) return 'n/a';
-    const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
-    if (i === 0) return bytes + ' ' + sizes[i];
-    return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
+export function bytesToSize (bytes) {
+  const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
+  if (bytes === 0) return 'n/a'
+  const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)))
+  if (i === 0) return bytes + ' ' + sizes[i]
+  return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]
+}
+
+export function vaildData (key, defaultValue = Boolean) {
+  if (key) {
+    return true
+  } else {
+    return defaultValue
+  }
 }

+ 55 - 40
src/views/home/component/dash.vue

@@ -8,7 +8,7 @@
         <span class="ml-5">项目总投资额87847万元</span>
       </div>
       <div class="flex ml-20">
-        <div v-for="(item,index) in stage" :class="active === index ? 'total-s' : 'total'"
+        <div v-for="(item,index) in stage" :key='item.id' :class="active === index ? 'total-s' : 'total'"
              class="flex flex-col flex-align-start flex-center mt-20 bold font-16" @click="switchTab(item,index)">
           <span class="ml-15 sp">{{ item.name }}</span>
           <span class="ml-15 sp1 mt-5">{{ item.projectNumber }}<span class="grey font-14 ml-5">个</span></span>
@@ -16,13 +16,15 @@
       </div>
       <base-button class="ml-20 mt-20" icon="Plus" title="新增" @click="showAdd = true"/>
     </div>
+    {{permissionList}}
     <avue-crud ref="crud"
                v-model="form"
                :before-open="beforeOpen"
                :data="data"
                :option="option"
-               :page.sync="page"
+               v-model:page="page"
                :table-loading="loading"
+               :permission="permissionList"
                class="curd"
                @row-del="rowDel"
                @current-change="currentChange"
@@ -99,12 +101,18 @@
 </template>
 
 <script>
-import BaseButton from "../../../components/base-button.vue";
+import BaseButton from '../../../components/base-button.vue'
+import permissionStore from '@/store/permission.js'
+import { vaildData } from '@/utils/tools.js'
 
 export default {
   name: 'dash',
-  components: {BaseButton},
-  data() {
+  components: { BaseButton },
+  setup () {
+    const permissions = permissionStore()
+    return { permissions }
+  },
+  data () {
     return {
       showAdd: false,
       active: 0,
@@ -148,7 +156,7 @@ export default {
           },
           {
             label: '项目领域',
-            prop: 'dictName',
+            prop: 'dictName'
           },
           {
             label: '发债时间',
@@ -177,21 +185,28 @@ export default {
         totalAmount: '',
         projectType: '',
         tags: '',
-        introduction: '',
+        introduction: ''
       }
     }
   },
-  created() {
+  created () {
     this.getStageList()
     this.getTypeList()
     this.$bus.on('serach', (res) => {
       this.onLoad(res)
     })
   },
+  computed: {
+    permissionList () {
+      return {
+        delBtn: vaildData(this.permissions.permissions.home_del, false)
+      }
+    }
+  },
   methods: {
-    switchTab(item, index) {
+    switchTab (item, index) {
       this.active = index
-      this.onLoad({stageId: item.id})
+      this.onLoad({ stageId: item.id })
     },
     // track(id) {
     //   this.$router.push({
@@ -199,68 +214,68 @@ export default {
     //     query: {id: id, type: '1'}
     //   })
     // },
-    onLoad(query = {}) {
-      let data = {...query, ...this.page}
+    onLoad (query = {}) {
+      const data = { ...query, ...this.page }
       this.$api.project.projectList(data).then(res => {
         if (res.code === 200) {
           this.data = res.data.content
           this.page.total = res.data.numberOfElements
-          this.loading = false;
+          this.loading = false
         }
       })
     },
-    beforeOpen(done, type) {
+    beforeOpen (done, type) {
       if (['view'].includes(type)) {
         this.$router.push({
           path: '/home/details',
-          query: {id: this.form.id, type: '0'}
+          query: { id: this.form.id, type: '0' }
         })
       } else if (type === 'edit') {
         this.$router.push({
           path: '/home/details',
-          query: {id: this.form.id, type: '1'}
+          query: { id: this.form.id, type: '1' }
         })
       }
     },
-    currentChange(currentPage) {
-      this.page.currentPage = currentPage;
+    currentChange (currentPage) {
+      this.page.currentPage = currentPage
     },
-    sizeChange(pageSize) {
-      this.page.pageSize = pageSize;
+    sizeChange (pageSize) {
+      this.page.pageSize = pageSize
     },
-    refreshChange() {
-      this.onLoad(this.page, this.query);
+    refreshChange () {
+      this.onLoad(this.page, this.query)
     },
-    rowDel(row) {
-      this.$confirm("确定删除选择的项目?", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning"
+    rowDel (row) {
+      this.$confirm('确定删除选择的项目?', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
       })
-          .then(() => {
-            this.$api.project.projectRemove({ids: row.id}).then(res => {
-              if (res.code === 200) {
-                this.$message.success(res.msg)
-                this.onLoad()
-              } else {
-                this.$message.error(res.msg)
-              }
-            })
+        .then(() => {
+          this.$api.project.projectRemove({ ids: row.id }).then(res => {
+            if (res.code === 200) {
+              this.$message.success(res.msg)
+              this.onLoad()
+            } else {
+              this.$message.error(res.msg)
+            }
           })
+        })
     },
-    getStageList() {
+    getStageList () {
       this.$api.project.userStageList().then(res => {
         if (res.code === 200) {
           this.stage = res.data
         }
       })
     },
-    getTypeList() {
+    getTypeList () {
       this.$api.project.typeList().then(res => {
         this.typeList = res.data.records
       })
     },
-    projectSave() {
+    projectSave () {
       this.$api.project.projectAdd(this.projectForm).then(res => {
         if (res.code === 200) {
           this.showAdd = false
@@ -271,7 +286,7 @@ export default {
           this.$message.error(res.msg)
         }
       })
-    },
+    }
   }
 }
 </script>

+ 20 - 6
src/views/home/component/folder_list.vue

@@ -2,8 +2,7 @@
   <div class="full-width full-height mb-10">
     <div class="flex flex-col">
       <div class="flex flex-align-center padding border-bottom bold title-sp">
-        <span v-if="type === 0" class="flex-1">谋划阶段</span>
-        <span v-else class="flex-1"></span>
+        <span class="flex-1"></span>
         <span style="flex: 2">文件/文件夹名称</span>
         <span style="flex: 1">更新(上传)时间</span>
         <span style="flex: 1.5">文件数量</span>
@@ -20,9 +19,9 @@
         <span style="flex: 1.5">{{ item.fileNumber }}</span>
         <div class="flex flex-center" style="flex: 3">
           <main-button icon="View" title="详情" width="85" @click="fileView(item)"/>
-          <main-button icon="Upload" title="上传文件" width="85" @click="uploadFiles(item)"/>
-          <main-button v-if="type === 0" icon="Pointer" title="授权操作" width="85" @click='getFileList(item)'/>
-          <main-button icon="Delete" title="删除" width="85" @click="folderRemove(item)"/>
+          <main-button v-if='permissions.permissions.home_folder_add' icon="Upload" title="上传文件" width="85" @click="uploadFiles(item)"/>
+          <main-button v-if="permissions.permissions.home_folder_authorize" icon="Pointer" title="授权操作" width="85" @click='getFileList(item)'/>
+          <main-button v-if="permissions.permissions.home_folder_del" icon="Delete" title="删除" width="85" @click="folderRemove(item)"/>
         </div>
       </div>
     </div>
@@ -54,6 +53,15 @@
       </template>
       <authorize :list='fileData.records' :folder-id='currentRow.id' :project-id='projectId' @close='authorizeShow = false'/>
     </el-dialog>
+    <el-dialog v-model='sendMsg' top='20%' width='400px'>
+      <div class="flex flex-col flex-center">
+        <span class="font-15">是否给业主发送提醒消息?</span>
+        <div class="flex flex-center mt-20">
+          <el-button class="mr-15" title="取消" @click="sendMsg = false"/>
+          <el-button type='primary' title="发送" @click="SendMsg"/>
+        </div>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -61,10 +69,15 @@
 import mainButton from '../../../components/main-button.vue'
 import uploadFile from '../../../components/upload-file.vue'
 import authorize from '@/views/home/component/authorize.vue'
+import permissionStore from '@/store/permission.js'
 
 export default {
   name: 'file_list',
   components: { mainButton, uploadFile, authorize },
+  setup () {
+    const permissions = permissionStore()
+    return { permissions }
+  },
   props: {
     folder: Array,
     total: String,
@@ -172,13 +185,14 @@ export default {
           this.show = false
           this.$bus.emit('reFolder')
           this.$message.success(res.msg)
+          this.sendMsg = true
         } else {
           this.show = false
           this.$message.error(res.msg)
         }
       })
     },
-    SendMsg() {
+    SendMsg () {
       this.sendParams.ownerId = this.folder[0].createUser
       this.sendParams.ids = this.fileList.map(e => e.fileId).join(',')
       this.$api.project.send(this.sendParams).then(res => {

+ 0 - 1
src/views/home/component/item1.vue

@@ -9,7 +9,6 @@
         <el-radio label="2" size="large">可编辑</el-radio>
       </el-radio-group>
     </div>
-    <div>{{item.type}}</div>
   </div>
 </template>
 

+ 9 - 8
src/views/home/index.vue

@@ -19,27 +19,28 @@ name: '项目库',
 import topSerach from './component/top_serach.vue'
 import owner_serach from './component/owner_serach.vue'
 import dash from './component/dash.vue'
-import {useStore} from '../../store/user.js'
+import { useStore } from '@/store/user.js'
+
 import tokenStore from '../../store/token.js'
 
 export default {
-  components: {topSerach, dash, owner_serach},
-  setup() {
+  components: { topSerach, dash, owner_serach },
+  setup () {
     const store = useStore()
     const token = tokenStore()
-    return {store, token}
+    return { store, token }
   },
-  data() {
+  data () {
     return {
       type: 1
     }
   },
-  created() {
+  created () {
 
   },
   methods: {
-    push() {
-      this.$router.push({path: '/setting', query: {id: 12, type: 'test'}})
+    push () {
+      this.$router.push({ path: '/setting', query: { id: 12, type: 'test' } })
     }
   }
 }