8
0
ZaiZai 1 gadu atpakaļ
vecāks
revīzija
25660dfb22

+ 1 - 1
package.json

@@ -21,7 +21,7 @@
         "dayjs": "^1.11.10",
         "echarts": "^5.4.3",
         "element-plus": "2.4.4",
-        "hc-vue3-ui": "^2.7.7",
+        "hc-vue3-ui": "^2.8.1",
         "js-base64": "^3.7.5",
         "js-fast-way": "^0.3.8",
         "js-md5": "^0.8.3",

+ 7 - 0
src/api/modules/other.js

@@ -1,5 +1,12 @@
 import { HcApi } from '../request/index'
 
+//用户配置保存
+export const getClinetAll = () => HcApi({
+    url: '/api/blade-system/client/getClinetAll',
+    method: 'get',
+    params: {},
+}, false)
+
 //用户配置保存
 export const userConfigSave = (form, msg = true) => HcApi({
     url: '/api/blade-business/defaultConfig/saveOrUpdate',

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

@@ -0,0 +1,11 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    async getLazyList(form) {
+        return HcApi({
+            url: '/api/blade-system/menu/lazy-list',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+}

+ 2 - 0
src/components/index.js

@@ -1,5 +1,6 @@
 import { vAuthBtn } from './auth-btn/index'
 import HcCharts from './echarts/echarts.vue'
+import HcSearchInput from './search-input/search-input.vue'
 
 //注册全局组件
 export const setupComponents = (App) => {
@@ -7,4 +8,5 @@ export const setupComponents = (App) => {
     App.directive('auth-btn', vAuthBtn)
     //自定义组件
     App.component('HcCharts', HcCharts)
+    App.component('HcSearchInput', HcSearchInput)
 }

+ 59 - 0
src/components/search-input/search-input.vue

@@ -0,0 +1,59 @@
+<template>
+    <div class="hc-search-input-box">
+        <el-input v-model="queryValue" class="w-60" clearable :placeholder="placeholder" @keyup="keyUpEvent" />
+        <el-button type="primary" @click="searchClick">{{ text }}</el-button>
+    </div>
+</template>
+
+<script setup>
+defineProps({
+    placeholder: {
+        type: String,
+        default: '请输入关键词检索',
+    },
+    text: {
+        type: String,
+        default: '查询',
+    },
+})
+
+const emit = defineEmits(['search'])
+
+defineOptions({
+    name: 'HcSearchInput',
+})
+
+//双向绑定
+// eslint-disable-next-line no-undef
+const queryValue = defineModel('modelValue', {
+    default: '',
+})
+
+//回车搜索
+const keyUpEvent = (e) => {
+    if (e.key === 'Enter') {
+        searchClick()
+    }
+}
+
+//搜索
+const searchClick = () => {
+    emit('search', queryValue.value)
+}
+</script>
+
+<style lang="scss">
+.hc-search-input-box {
+    position: relative;
+    display: flex;
+    align-items: center;
+    .el-input__wrapper {
+        border-top-right-radius: 0;
+        border-bottom-right-radius: 0;
+    }
+    .el-button {
+        border-top-left-radius: 0;
+        border-bottom-left-radius: 0;
+    }
+}
+</style>

+ 106 - 1
src/views/system/menu.vue

@@ -1,9 +1,114 @@
 <template>
-    <div>11</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.clientId" :value="item.id" />
+                </el-select>
+            </div>
+            <div class="ml-3 w-60">
+                <hc-search-input v-model="searchForm.name" placeholder="请输入菜单名称" @search="searchClick" />
+            </div>
+        </template>
+        <template #extra>
+            <el-button hc-btn type="primary">新增</el-button>
+            <el-button hc-btn type="danger">删除</el-button>
+        </template>
+        <hc-table
+            ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
+            :is-index="false" is-new is-check :check-style="{ width: 29 }" lazy :load="tableLoad"
+            @selection-change="tableCheckChange"
+        >
+            <template #sysId="{ row }">
+                {{ getSystemNmae(row.sysId) }}
+            </template>
+            <template #category="{ row }">
+                {{ row.category === 1 ? '菜单' : '按钮' }}
+            </template>
+            <template #action="{ row }">
+                <el-link type="warning">修改</el-link>
+                <el-link type="success">新增子项</el-link>
+                <el-link type="primary">复制</el-link>
+                <el-link type="danger">删除</el-link>
+            </template>
+        </hc-table>
+    </hc-new-card>
 </template>
 
 <script setup>
+import { onActivated, ref } from 'vue'
+import mainApi from '~api/system/menu'
+import { getArrValue } from 'js-fast-way'
+import { getClinetAll } from '~api/other'
 
+//激活
+onActivated(() => {
+    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.clientId : ''
+}
+
+//搜索表单
+const searchForm = ref({
+    sysId: null, name: null,
+})
+
+//搜索
+const searchClick = () => {
+    getTableData()
+}
+
+//表格数据
+const tableRef = ref(null)
+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 tableLoading = ref(false)
+const tableData = ref([{}])
+const getTableData = async () => {
+    tableData.value = []
+    tableLoading.value = true
+    const { data } = await mainApi.getLazyList({
+        ...searchForm.value,
+        parentId: 0,
+    })
+    tableData.value = getArrValue(data)
+    tableLoading.value = false
+}
+
+//懒加载表格
+const tableLoad = async (row, node, resolve) => {
+    const { data } = await mainApi.getLazyList({
+        ...searchForm.value,
+        parentId: row.id,
+    })
+    resolve(getArrValue(data))
+}
+
+//表格被选择
+const tableCheckChange = () => {
+
+}
 </script>
 
 <style scoped lang="scss">

+ 4 - 4
yarn.lock

@@ -1915,10 +1915,10 @@ has-flag@^4.0.0:
   resolved "http://47.110.251.215:9000/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
   integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
 
-hc-vue3-ui@^2.7.7:
-  version "2.7.7"
-  resolved "http://47.110.251.215:9000/hc-vue3-ui/-/hc-vue3-ui-2.7.7.tgz#62a9a4245cc42789d33197fcd8a1d64efd33636c"
-  integrity sha512-m3grVcqd+CIGTW9OTshfypfpgPiUvZ1rCLMXbgcuuqDCdSSbhr6wLnwJ4Z1OV/et0tKy4dAD+wd/jyi6FWA8GA==
+hc-vue3-ui@^2.8.1:
+  version "2.8.1"
+  resolved "http://47.110.251.215:9000/hc-vue3-ui/-/hc-vue3-ui-2.8.1.tgz#35e5dca0af16cda770d3b28cda1eac10302dd081"
+  integrity sha512-4ipfBnzuS2KZ6h9yzQNrsyhUWsvxeDm2Tzi6/rDp0ByiCuE0cBLeWxfbssz6SDK4XeQruQAfaYZ/KZCfomEAIQ==
 
 human-signals@^2.1.0:
   version "2.1.0"