Browse Source

大更新

ZaiZai 1 năm trước cách đây
mục cha
commit
d18f8a3ce3

+ 40 - 0
src/api/modules/system/menu-top.js

@@ -0,0 +1,40 @@
+import { HcApi } from '../../request/index'
+
+export default {
+    //加载菜单列表
+    async page(form) {
+        return HcApi({
+            url: '/api/blade-system/topmenu/list',
+            method: 'get',
+            params: form,
+        }, false)
+    },
+    //菜单详情
+    async detail(id) {
+        return HcApi({
+            url: '/api/blade-system/topmenu/detail',
+            method: 'get',
+            params: {
+                id,
+            },
+        }, false)
+    },
+    //新增和编辑菜单
+    async submit(form) {
+        return HcApi({
+            url: '/api/blade-system/topmenu/submit',
+            method: 'post',
+            data: form,
+        }, false)
+    },
+    //删除菜单
+    async del(ids) {
+        return HcApi({
+            url: '/api/blade-system/topmenu/remove',
+            method: 'post',
+            params: {
+                ids,
+            },
+        }, false)
+    },
+}

+ 46 - 0
src/components/icon-input/icon-input.vue

@@ -0,0 +1,46 @@
+<template>
+    <div class="select-menu-icon-input">
+        <el-input v-model="source" clearable>
+            <template #prepend>
+                <hc-icon :name="source" />
+            </template>
+            <template #append>
+                <el-button @click="isIconShow = true">选择图标</el-button>
+            </template>
+        </el-input>
+        <!-- 图标选择 -->
+        <hc-menu-icon v-model="isIconShow" @finish="menuIconFinish" />
+    </div>
+</template>
+
+<script setup>
+import { ref } from 'vue'
+
+defineOptions({
+    name: 'HcIconInput',
+})
+
+//双向绑定
+const source = defineModel('modelValue', {
+    default: '',
+})
+
+//图标选择
+const isIconShow = ref(false)
+const menuIconFinish = (icon) => {
+    source.value = icon
+    isIconShow.value = false
+}
+</script>
+
+<style lang="scss">
+//选择图标的输入框
+.select-menu-icon-input {
+    position: relative;
+    width: 100%;
+    .el-input .el-input-group__prepend {
+        padding: 0 6px;
+        font-size: 22px;
+    }
+}
+</style>

+ 2 - 0
src/components/index.js

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

+ 12 - 0
src/router/modules/base.js

@@ -64,6 +64,12 @@ export default [
                 meta: { title: '菜单管理' },
                 component: () => import('~src/views/system/menu.vue'),
             },
+            {
+                path: '/system/menu-top',
+                name: 'topmenu',
+                meta: { title: '顶部菜单' },
+                component: () => import('~src/views/system/menu-top.vue'),
+            },
             {
                 path: '/system/app',
                 name: 'app',
@@ -82,6 +88,12 @@ export default [
                 meta: { title: '岗位管理' },
                 component: () => import('~src/views/system/post.vue'),
             },
+            {
+                path: '/system/dept',
+                name: 'dept',
+                meta: { title: '机构管理' },
+                component: () => import('~src/views/system/dept.vue'),
+            },
             {
                 path: '/system/dict',
                 name: 'dict',

+ 11 - 0
src/views/system/dept.vue

@@ -0,0 +1,11 @@
+<template>
+    <div>机构管理</div>
+</template>
+
+<script setup>
+
+</script>
+
+<style scoped lang="scss">
+
+</style>

+ 224 - 0
src/views/system/menu-top.vue

@@ -0,0 +1,224 @@
+<template>
+    <hc-new-card>
+        <template #header>
+            <div class="w-60">
+                <hc-search-input v-model="searchForm.name" placeholder="请输入菜单名称" @search="searchClick" />
+            </div>
+        </template>
+        <template #extra>
+            <el-button hc-btn type="primary" @click="addClick">新增</el-button>
+            <el-button hc-btn type="danger" @click="delClick">删除</el-button>
+        </template>
+        <hc-table
+            ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
+            :is-index="false" is-new is-check :check-style="{ width: 29 }"
+            @selection-change="tableCheckChange"
+        >
+            <template #action="{ row }">
+                <el-link type="warning" @click="editRowClick(row)">修改</el-link>
+                <el-link type="danger" @click="delRowClick(row)">删除</el-link>
+            </template>
+        </hc-table>
+        <template #action>
+            <hc-pages :pages="searchForm" @change="pageChange" />
+        </template>
+
+        <!-- 新增/修改 菜单 -->
+        <hc-new-dialog v-model="isDialogShow" widths="800px" is-footer-center :title="iconDialogTitle" @close="dialogClose">
+            <el-form ref="formRef" :model="formModel" :rules="formRules" label-position="top" label-width="auto">
+                <el-row :gutter="20">
+                    <el-col :span="12">
+                        <el-form-item label="菜单名称:" prop="name">
+                            <el-input v-model="formModel.name" clearable />
+                        </el-form-item>
+                    </el-col>
+                    <el-col :span="12">
+                        <el-form-item label="跳转地址:" prop="code">
+                            <el-input v-model="formModel.code" clearable />
+                        </el-form-item>
+                    </el-col>
+                    <el-col :span="12">
+                        <el-form-item label="菜单图标:">
+                            <hc-icon-input v-model="formModel.source" />
+                        </el-form-item>
+                    </el-col>
+                    <el-col :span="12">
+                        <el-form-item label="菜单排序:" prop="sort">
+                            <el-input-number v-model="formModel.sort" :min="1" block controls-position="right" />
+                        </el-form-item>
+                    </el-col>
+                </el-row>
+            </el-form>
+            <template #footer>
+                <el-button hc-btn @click="dialogClose">取消</el-button>
+                <el-button hc-btn type="primary" :loading="submitLoading" @click="dialogSubmit">提交</el-button>
+            </template>
+        </hc-new-dialog>
+    </hc-new-card>
+</template>
+
+<script setup>
+import { nextTick, onActivated, ref } from 'vue'
+import { arrToId, formValidate, getArrValue } from 'js-fast-way'
+import { delMessage, reloadPage } from '~uti/tools'
+import mainApi from '~api/system/menu-top'
+
+//激活
+onActivated(() => {
+    searchClick()
+})
+
+//搜索表单
+const searchForm = ref({ name: null, current: 1, size: 30, total: 0 })
+
+//搜索
+const searchClick = () => {
+    searchForm.value.current = 1
+    getTableData()
+}
+
+//分页
+const pageChange = ({ current, size }) => {
+    searchForm.value.current = current
+    searchForm.value.size = size
+    getTableData()
+}
+
+//表格数据
+const tableRef = ref(null)
+const tableColumn = ref([
+    { key: 'name', name: '菜单名称' },
+    { key: 'code', name: '跳转地址' },
+    { 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 { error, code, data } = await mainApi.page({
+        ...searchForm.value,
+        total: null,
+    })
+    tableLoading.value = false
+    if (!error && code === 200) {
+        tableData.value = getArrValue(data['records'])
+        searchForm.value.total = data['total']
+    } else {
+        tableData.value = []
+        searchForm.value.total = 0
+    }
+}
+
+//表格被选择
+const tableCheckKeys = ref([])
+const tableCheckChange = (rows) => {
+    tableCheckKeys.value = rows
+}
+
+//新增/修改 弹窗
+const isDialogShow = ref(false)
+const iconDialogTitle = ref('')
+
+//菜单表单
+const formRef = ref(null)
+const formModel = ref({})
+const formRules = {
+    name: {
+        required: true,
+        trigger: 'blur',
+        message: '请输入菜单名称',
+    },
+    code: {
+        required: true,
+        trigger: 'blur',
+        message: '请输入跳转地址',
+    },
+    sort: {
+        required: true,
+        trigger: 'blur',
+        message: '请输入菜单排序',
+    },
+}
+
+//新增菜单
+const addClick = () => {
+    iconDialogTitle.value = '新增菜单'
+    formModel.value = {}
+    //显示表单弹窗
+    nextTick(() => {
+        isDialogShow.value = true
+    })
+}
+
+//修改菜单
+const editRowClick = (row) => {
+    formModel.value = {}
+    iconDialogTitle.value = '修改菜单'
+    formModel.value = { ...row }
+    //显示表单弹窗
+    nextTick(() => {
+        isDialogShow.value = true
+    })
+}
+
+//删除菜单
+const delRowClick = (row) => {
+    delMessage(async () => {
+        const { code, msg } = await mainApi.del(row.id)
+        if (code === 200) {
+            window.$message.success('删除成功')
+            reloadPage()
+        } else {
+            window.$message.error(msg ?? '删除失败')
+        }
+    })
+}
+
+//批量删除菜单
+const delClick = () => {
+    const rows = tableCheckKeys.value
+    if (rows.length <= 0) {
+        window.$message.warning('请选择要删除的菜单')
+        return false
+    }
+    //确认删除菜单
+    delMessage(async () => {
+        const ids = arrToId(rows)
+        const { code, msg } = await mainApi.del(ids)
+        if (code === 200) {
+            window.$message.success('删除成功')
+            reloadPage()
+        } else {
+            window.$message.error(msg ?? '删除失败')
+        }
+    })
+}
+
+//提交表单
+const submitLoading = ref(false)
+const dialogSubmit = async () => {
+    const formRes = await formValidate(formRef.value)
+    if (!formRes) return false
+    submitLoading.value = true
+    //发起请求
+    const { error, code, msg } = await mainApi.submit(formModel.value)
+    if (!error && code === 200) {
+        submitLoading.value = false
+        window?.$message?.success('操作成功')
+        reloadPage()
+    } else {
+        window?.$message?.error(msg ?? '操作失败')
+    }
+}
+
+//关闭弹窗
+const dialogClose = () => {
+    isDialogShow.value = false
+    submitLoading.value = false
+    formModel.value = {}
+}
+</script>

+ 0 - 1
src/views/system/tenant.vue

@@ -128,7 +128,6 @@ onActivated(() => {
     searchClick()
 })
 
-
 //搜索表单
 const searchType = ref('tenantId')
 const searchName = ref('')