Browse Source

角色权限

ZaiZai 1 year ago
parent
commit
dcb13b6c9f

+ 4 - 13
src/api/modules/authority/api.js

@@ -4,7 +4,7 @@ export default {
     //分页
     async page(form) {
         return HcApi({
-            url: '/api/blade-resource/oss/list',
+            url: '/api/blade-system/api-scope/list',
             method: 'get',
             params: form,
         }, false)
@@ -12,7 +12,7 @@ export default {
     //详情
     async detail(id) {
         return HcApi({
-            url: '/api/blade-resource/oss/detail',
+            url: '/api/blade-system/api-scope/detail',
             method: 'get',
             params: {
                 id,
@@ -22,7 +22,7 @@ export default {
     //新增和编辑
     async submit(form) {
         return HcApi({
-            url: '/api/blade-resource/oss/submit',
+            url: '/api/blade-system/api-scope/submit',
             method: 'post',
             data: form,
         }, false)
@@ -30,20 +30,11 @@ export default {
     //删除
     async del(ids) {
         return HcApi({
-            url: '/api/blade-resource/oss/remove',
+            url: '/api/blade-system/api-scope/remove',
             method: 'post',
             params: {
                 ids,
             },
         }, false)
     },
-    async enable(id) {
-        return HcApi({
-            url: '/api/blade-resource/oss/enable',
-            method: 'post',
-            params: {
-                id,
-            },
-        }, false)
-    },
 }

+ 4 - 13
src/api/modules/authority/data.js

@@ -4,7 +4,7 @@ export default {
     //分页
     async page(form) {
         return HcApi({
-            url: '/api/blade-resource/oss/list',
+            url: '/api/blade-system/data-scope/list',
             method: 'get',
             params: form,
         }, false)
@@ -12,7 +12,7 @@ export default {
     //详情
     async detail(id) {
         return HcApi({
-            url: '/api/blade-resource/oss/detail',
+            url: '/api/blade-system/data-scope/detail',
             method: 'get',
             params: {
                 id,
@@ -22,7 +22,7 @@ export default {
     //新增和编辑
     async submit(form) {
         return HcApi({
-            url: '/api/blade-resource/oss/submit',
+            url: '/api/blade-system/data-scope/submit',
             method: 'post',
             data: form,
         }, false)
@@ -30,20 +30,11 @@ export default {
     //删除
     async del(ids) {
         return HcApi({
-            url: '/api/blade-resource/oss/remove',
+            url: '/api/blade-system/data-scope/remove',
             method: 'post',
             params: {
                 ids,
             },
         }, false)
     },
-    async enable(id) {
-        return HcApi({
-            url: '/api/blade-resource/oss/enable',
-            method: 'post',
-            params: {
-                id,
-            },
-        }, false)
-    },
 }

+ 7 - 0
src/api/modules/system/menu.js

@@ -47,4 +47,11 @@ export default {
             },
         }, false)
     },
+    async getLazyMenuList(form) {
+        return HcApi({
+            url: '/api/blade-system/menu/lazy-menu-list',
+            method: 'get',
+            params: form,
+        }, false)
+    },
 }

+ 102 - 4
src/views/authority/data.vue

@@ -1,17 +1,115 @@
 <template>
-    <div>111</div>
+    <hc-new-card>
+        <template #header>
+            <div class="w-40">
+                <el-select v-model="searchForm.sysId" filterable clearable block placeholder="选择所属系统">
+                    <el-option v-for="item in clinets" :key="item.id" :label="item.name" :value="item.id" />
+                </el-select>
+            </div>
+            <div class="ml-3 w-60">
+                <hc-search-input v-model="searchForm.name" placeholder="请输入菜单名称" @search="searchClick" />
+            </div>
+        </template>
+        <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :is-index="false" is-new lazy :load="tableLoad">
+            <template #sysId="{ row }">
+                {{ getSystemNmae(row.sysId) }}
+            </template>
+            <template #action="{ row }">
+                <el-link type="primary">权限配置</el-link>
+            </template>
+        </hc-table>
+    </hc-new-card>
 </template>
 
 <script setup>
 import { onActivated, ref } from 'vue'
-import { delMessage } from 'hc-vue3-ui'
-import { arrToId, getArrValue } from 'js-fast-way'
+import { useRoute, useRouter } from 'vue-router'
+import { formValidate, getArrValue, getObjValue } from 'js-fast-way'
+import { getClinetAll } from '~api/other'
 import mainApi from '~api/authority/data'
+import menuApi from '~api/system/menu'
+
+//初始组合式
+const router = useRouter()
+const useRoutes = useRoute()
 
 //激活
 onActivated(() => {
-
+//获取参数
+    const { sysId, name } = getObjValue(useRoutes.query)
+    searchForm.value = { sysId: sysId, name: name }
+    //获取数据
+    getClinetAllApi()
+    getTableData()
 })
+
+//获取所有系统
+const clinets = ref([])
+const getClinetAllApi = async () => {
+    const { data } = await getClinetAll()
+    clinets.value = getArrValue(data)
+}
+
+//获取系统名称
+const getSystemNmae = (id) => {
+    const item = clinets.value.find((item) => item.id === id)
+    return item ? item.name : ''
+}
+
+//搜索表单
+const searchForm = ref({ sysId: null, name: null })
+
+//搜索
+const searchClick = () => {
+    router.push({
+        name: 'data_scope',
+        query: searchForm.value,
+    })
+    getTableData()
+}
+
+//表格数据
+const tableColumn = ref([
+    { key: 'name', name: '菜单名称' },
+    { key: 'sysId', name: '所属系统' },
+    { key: 'path', name: '路由地址' },
+    { key: 'code', name: '菜单编号' },
+    { key: 'category', name: '菜单类型', width: 90, align: 'center' },
+    { key: 'sort', name: '排序', width: 80, align: 'center' },
+    { key: 'action', name: '操作', width: 200, align: 'center' },
+])
+const tableData = ref([{}])
+
+//获取表格数据
+const tableLoading = ref(false)
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    tableData.value = await getLazyList(0)
+    tableLoading.value = false
+}
+
+//懒加载表格
+const tableLoad = async (row, node, resolve) => {
+    resolve(await getLazyList(row.id))
+}
+
+//获取表格数据
+const getLazyList = async (id) => {
+    let newArr = []
+    const { data } = await menuApi.getLazyList({
+        ...searchForm.value,
+        parentId: id,
+    })
+    //处理数据
+    const res = getArrValue(data)
+    for (let i = 0; i < res.length; i++) {
+        if (res[i].category === 1) {
+            newArr.push(res[i])
+        }
+    }
+    return newArr
+}
 </script>
 
 <style scoped lang="scss">