| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template>
|
| | | <div class="app-container">
|
| | | <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
|
| | | <el-form-item label="èååç§°" prop="menuName">
|
| | | <el-input
|
| | | v-model="queryParams.menuName"
|
| | | placeholder="请è¾å
¥èååç§°"
|
| | | clearable
|
| | | style="width: 200px"
|
| | | @keyup.enter="handleQuery"
|
| | | />
|
| | | </el-form-item>
|
| | | <el-form-item label="ç¶æ" prop="status">
|
| | | <el-select v-model="queryParams.status" placeholder="èåç¶æ" clearable style="width: 200px">
|
| | | <el-option
|
| | | v-for="dict in sys_normal_disable"
|
| | | :key="dict.value"
|
| | | :label="dict.label"
|
| | | :value="dict.value"
|
| | | />
|
| | | </el-select>
|
| | | </el-form-item>
|
| | | <el-form-item>
|
| | | <el-button type="primary" icon="Search" @click="handleQuery">æç´¢</el-button>
|
| | | <el-button icon="Refresh" @click="resetQuery">éç½®</el-button>
|
| | | </el-form-item>
|
| | | </el-form>
|
| | |
|
| | | <el-row :gutter="10" class="mb8">
|
| | | <el-col :span="1.5">
|
| | | <el-button
|
| | | type="primary"
|
| | | plain
|
| | | icon="Plus"
|
| | | @click="handleAdd"
|
| | | v-hasPermi="['system:menu:add']"
|
| | | >æ°å¢</el-button>
|
| | | </el-col>
|
| | | <el-col :span="1.5">
|
| | | <el-button |
| | | type="info"
|
| | | plain
|
| | | icon="Sort"
|
| | | @click="toggleExpandAll"
|
| | | >å±å¼/æå </el-button>
|
| | | </el-col>
|
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
| | | </el-row>
|
| | |
|
| | | <el-table
|
| | | v-if="refreshTable"
|
| | | v-loading="loading"
|
| | | :data="menuList"
|
| | | row-key="menuId"
|
| | | :default-expand-all="isExpandAll"
|
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
| | | >
|
| | | <el-table-column prop="menuName" label="èååç§°" :show-overflow-tooltip="true" width="160"></el-table-column>
|
| | | <el-table-column prop="icon" label="徿 " align="center" width="100">
|
| | | <template #default="scope">
|
| | | <svg-icon :icon-class="scope.row.icon" />
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column prop="orderNum" label="æåº" width="60"></el-table-column>
|
| | | <el-table-column prop="perms" label="æéæ è¯" :show-overflow-tooltip="true"></el-table-column>
|
| | | <el-table-column prop="component" label="ç»ä»¶è·¯å¾" :show-overflow-tooltip="true"></el-table-column>
|
| | | <el-table-column prop="status" label="ç¶æ" width="80">
|
| | | <template #default="scope">
|
| | | <dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column label="å建æ¶é´" align="center" width="160" prop="createTime">
|
| | | <template #default="scope">
|
| | | <span>{{ parseTime(scope.row.createTime) }}</span>
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column label="æä½" align="center" width="210" class-name="small-padding fixed-width">
|
| | | <template #default="scope">
|
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:menu:edit']">ä¿®æ¹</el-button>
|
| | | <el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:menu:add']">æ°å¢</el-button>
|
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:menu:remove']">å é¤</el-button>
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | |
|
| | | <!-- æ·»å æä¿®æ¹èåå¯¹è¯æ¡ -->
|
| | | <el-dialog :title="title" v-model="open" width="880px" append-to-body>
|
| | | <el-form ref="menuRef" :model="form" :rules="rules" label-width="130px">
|
| | | <el-row>
|
| | | <el-col :span="24">
|
| | | <el-form-item label="ä¸çº§èå">
|
| | | <el-tree-select
|
| | | v-model="form.parentId"
|
| | | :data="menuOptions"
|
| | | :props="{ value: 'menuId', label: 'menuName', children: 'children' }"
|
| | | value-key="menuId"
|
| | | placeholder="éæ©ä¸çº§èå"
|
| | | check-strictly
|
| | | />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="24">
|
| | | <el-form-item label="èåç±»å" prop="menuType">
|
| | | <el-radio-group v-model="form.menuType">
|
| | | <el-radio value="M">ç®å½</el-radio>
|
| | | <el-radio value="C">èå</el-radio>
|
| | | <el-radio value="F">æé®</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType != 'F'">
|
| | | <el-form-item label="èå徿 " prop="icon">
|
| | | <el-popover
|
| | | placement="bottom-start"
|
| | | :width="540"
|
| | | trigger="click"
|
| | | >
|
| | | <template #reference>
|
| | | <el-input v-model="form.icon" placeholder="ç¹å»éæ©å¾æ " @blur="showSelectIcon" readonly>
|
| | | <template #prefix>
|
| | | <svg-icon
|
| | | v-if="form.icon"
|
| | | :icon-class="form.icon"
|
| | | class="el-input__icon"
|
| | | style="height: 32px;width: 16px;"
|
| | | />
|
| | | <el-icon v-else style="height: 32px;width: 16px;"><search /></el-icon>
|
| | | </template>
|
| | | </el-input>
|
| | | </template>
|
| | | <icon-select ref="iconSelectRef" @selected="selected" :active-icon="form.icon" />
|
| | | </el-popover>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="æ¾ç¤ºæåº" prop="orderNum">
|
| | | <el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item label="èååç§°" prop="menuName">
|
| | | <el-input v-model="form.menuName" placeholder="请è¾å
¥èååç§°" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType == 'C'">
|
| | | <el-form-item prop="routeName">
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="é»è®¤ä¸å¡«ååè·¯ç±å°åç¸åï¼å¦å°å为ï¼`user`ï¼åå称为`User`ï¼æ³¨æï¼å 为routerä¼å é¤åç§°ç¸åè·¯ç±ï¼ä¸ºé¿å
ååçå²çªï¼ç¹æ®æ
åµä¸è¯·èªå®ä¹ï¼ä¿è¯å¯ä¸æ§ï¼" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | è·¯ç±åç§°
|
| | | </span>
|
| | | </template>
|
| | | <el-input v-model="form.routeName" placeholder="请è¾å
¥è·¯ç±åç§°" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType != 'F'">
|
| | | <el-form-item>
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="éæ©æ¯å¤é¾åè·¯ç±å°åéè¦ä»¥`http(s)://`å¼å¤´" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>æ¯å¦å¤é¾
|
| | | </span>
|
| | | </template>
|
| | | <el-radio-group v-model="form.isFrame">
|
| | | <el-radio value="0">æ¯</el-radio>
|
| | | <el-radio value="1">å¦</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType != 'F'">
|
| | | <el-form-item prop="path">
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="访é®çè·¯ç±å°åï¼å¦ï¼`user`ï¼å¦å¤ç½å°åéå
é¾è®¿é®å以`http(s)://`å¼å¤´" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | è·¯ç±å°å
|
| | | </span>
|
| | | </template>
|
| | | <el-input v-model="form.path" placeholder="请è¾å
¥è·¯ç±å°å" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType == 'C'">
|
| | | <el-form-item prop="component">
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="访é®çç»ä»¶è·¯å¾ï¼å¦ï¼`system/user/index`ï¼é»è®¤å¨`views`ç®å½ä¸" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | ç»ä»¶è·¯å¾
|
| | | </span>
|
| | | </template>
|
| | | <el-input v-model="form.component" placeholder="请è¾å
¥ç»ä»¶è·¯å¾" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType == 'C'">
|
| | | <el-form-item prop="appComponent">
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="APP 端访é®çç»ä»¶è·¯å¾ï¼å¦ï¼`app/system/user/index`" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | APPç»ä»¶è·¯å¾
|
| | | </span>
|
| | | </template>
|
| | | <el-input v-model="form.appComponent" placeholder="请è¾å
¥ APP ç»ä»¶è·¯å¾ï¼å¯éï¼" />
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType != 'M'">
|
| | | <el-form-item>
|
| | | <el-input v-model="form.perms" placeholder="请è¾å
¥æéæ è¯" maxlength="100" />
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="æ§å¶å¨ä¸å®ä¹çæéå符ï¼å¦ï¼@PreAuthorize(`@ss.hasPermi('system:user:list')`)" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | æéå符
|
| | | </span>
|
| | | </template>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType == 'C'">
|
| | | <el-form-item>
|
| | | <el-input v-model="form.query" placeholder="请è¾å
¥è·¯ç±åæ°" maxlength="255" />
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content='访é®è·¯ç±çé»è®¤ä¼ éåæ°ï¼å¦ï¼`{"id": 1, "name": "ry"}`' placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | è·¯ç±åæ°
|
| | | </span>
|
| | | </template>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType == 'C'">
|
| | | <el-form-item>
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="éæ©æ¯åä¼è¢«`keep-alive`ç¼åï¼éè¦å¹é
ç»ä»¶ç`name`åå°åä¿æä¸è´" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | æ¯å¦ç¼å
|
| | | </span>
|
| | | </template>
|
| | | <el-radio-group v-model="form.isCache">
|
| | | <el-radio value="0">ç¼å</el-radio>
|
| | | <el-radio value="1">ä¸ç¼å</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12" v-if="form.menuType != 'F'">
|
| | | <el-form-item>
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="éæ©éèåè·¯ç±å°ä¸ä¼åºç°å¨ä¾§è¾¹æ ï¼ä½ä»ç¶å¯ä»¥è®¿é®" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | æ¾ç¤ºç¶æ
|
| | | </span>
|
| | | </template>
|
| | | <el-radio-group v-model="form.visible">
|
| | | <el-radio
|
| | | v-for="dict in sys_show_hide"
|
| | | :key="dict.value"
|
| | | :value="dict.value"
|
| | | >{{ dict.label }}</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | <el-col :span="12">
|
| | | <el-form-item>
|
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="éæ©åç¨åè·¯ç±å°ä¸ä¼åºç°å¨ä¾§è¾¹æ ï¼ä¹ä¸è½è¢«è®¿é®" placement="top">
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | èåç¶æ
|
| | | </span>
|
| | | </template>
|
| | | <el-radio-group v-model="form.status">
|
| | | <el-radio
|
| | | v-for="dict in sys_normal_disable"
|
| | | :key="dict.value"
|
| | | :value="dict.value"
|
| | | >{{ dict.label }}</el-radio>
|
| | | </el-radio-group>
|
| | | </el-form-item>
|
| | | </el-col>
|
| | | </el-row>
|
| | | </el-form>
|
| | | <template #footer>
|
| | | <div class="dialog-footer">
|
| | | <el-button type="primary" @click="submitForm">ç¡® å®</el-button>
|
| | | <el-button @click="cancel">å æ¶</el-button>
|
| | | </div>
|
| | | </template>
|
| | | </el-dialog>
|
| | | </div>
|
| | | </template>
|
| | |
|
| | | <script setup name="Menu">
|
| | | import { addMenu, delMenu, getMenu, listMenu, updateMenu } from "@/api/system/menu"
|
| | | import SvgIcon from "@/components/SvgIcon"
|
| | | import IconSelect from "@/components/IconSelect"
|
| | | import {onMounted} from "vue";
|
| | |
|
| | | const { proxy } = getCurrentInstance()
|
| | | const { sys_show_hide, sys_normal_disable } = proxy.useDict("sys_show_hide", "sys_normal_disable")
|
| | |
|
| | | const menuList = ref([])
|
| | | const open = ref(false)
|
| | | const loading = ref(true)
|
| | | const showSearch = ref(true)
|
| | | const title = ref("")
|
| | | const menuOptions = ref([])
|
| | | const isExpandAll = ref(false)
|
| | | const refreshTable = ref(true)
|
| | | const iconSelectRef = ref(null)
|
| | |
|
| | | const data = reactive({
|
| | | form: {},
|
| | | queryParams: {
|
| | | menuName: undefined,
|
| | | visible: undefined
|
| | | },
|
| | | rules: {
|
| | | menuName: [{ required: true, message: "èååç§°ä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | orderNum: [{ required: true, message: "èå顺åºä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | path: [{ required: true, message: "è·¯ç±å°åä¸è½ä¸ºç©º", trigger: "blur" }],
|
| | | appComponent: [{ required: false, message: "APPç»ä»¶è·¯å¾ä¸è½ä¸ºç©º", trigger: "blur" }]
|
| | | },
|
| | | })
|
| | |
|
| | | const { queryParams, form, rules } = toRefs(data)
|
| | |
|
| | | /** æ¥è¯¢èåå表 */
|
| | | function getList() {
|
| | | loading.value = true
|
| | | listMenu(queryParams.value).then(response => {
|
| | | menuList.value = proxy.handleTree(response.data, "menuId")
|
| | | loading.value = false
|
| | | })
|
| | | }
|
| | |
|
| | | /** æ¥è¯¢èå䏿æ ç»æ */
|
| | | function getTreeselect() {
|
| | | menuOptions.value = []
|
| | | listMenu().then(response => {
|
| | | const menu = { menuId: 0, menuName: "主类ç®", children: [] }
|
| | | menu.children = proxy.handleTree(response.data, "menuId")
|
| | | menuOptions.value.push(menu)
|
| | | })
|
| | | }
|
| | |
|
| | | /** åæ¶æé® */
|
| | | function cancel() {
|
| | | open.value = false
|
| | | reset()
|
| | | }
|
| | |
|
| | | /** 表åéç½® */
|
| | | function reset() {
|
| | | form.value = {
|
| | | menuId: undefined,
|
| | | parentId: 0,
|
| | | menuName: undefined,
|
| | | icon: undefined,
|
| | | menuType: "M",
|
| | | orderNum: undefined,
|
| | | isFrame: "1",
|
| | | isCache: "0",
|
| | | visible: "0",
|
| | | status: "0",
|
| | | appComponent: undefined
|
| | | }
|
| | | proxy.resetForm("menuRef")
|
| | | }
|
| | |
|
| | | /** å±ç¤ºä¸æå¾æ */
|
| | | function showSelectIcon() {
|
| | | iconSelectRef.value.reset()
|
| | | }
|
| | |
|
| | | /** 鿩徿 */
|
| | | function selected(name) {
|
| | | form.value.icon = name
|
| | | }
|
| | |
|
| | | /** æç´¢æé®æä½ */
|
| | | function handleQuery() {
|
| | | getList()
|
| | | }
|
| | |
|
| | | /** éç½®æé®æä½ */
|
| | | function resetQuery() {
|
| | | proxy.resetForm("queryRef")
|
| | | handleQuery()
|
| | | }
|
| | |
|
| | | /** æ°å¢æé®æä½ */
|
| | | function handleAdd(row) {
|
| | | reset()
|
| | | getTreeselect()
|
| | | if (row != null && row.menuId) {
|
| | | form.value.parentId = row.menuId
|
| | | } else {
|
| | | form.value.parentId = 0
|
| | | }
|
| | | open.value = true
|
| | | title.value = "æ·»å èå"
|
| | | }
|
| | |
|
| | | /** å±å¼/æå æä½ */
|
| | | function toggleExpandAll() {
|
| | | refreshTable.value = false
|
| | | isExpandAll.value = !isExpandAll.value
|
| | | nextTick(() => {
|
| | | refreshTable.value = true
|
| | | })
|
| | | }
|
| | |
|
| | | /** ä¿®æ¹æé®æä½ */
|
| | | async function handleUpdate(row) {
|
| | | reset()
|
| | | await getTreeselect()
|
| | | getMenu(row.menuId).then(response => {
|
| | | form.value = response.data
|
| | | open.value = true
|
| | | title.value = "ä¿®æ¹èå"
|
| | | })
|
| | | }
|
| | |
|
| | | /** æäº¤æé® */
|
| | | function submitForm() {
|
| | | proxy.$refs["menuRef"].validate(valid => {
|
| | | if (valid) {
|
| | | if (form.value.menuId != undefined) {
|
| | | updateMenu(form.value).then(response => {
|
| | | proxy.$modal.msgSuccess("ä¿®æ¹æå")
|
| | | open.value = false
|
| | | getList()
|
| | | })
|
| | | } else {
|
| | | addMenu(form.value).then(response => {
|
| | | proxy.$modal.msgSuccess("æ°å¢æå")
|
| | | open.value = false
|
| | | getList()
|
| | | })
|
| | | }
|
| | | }
|
| | | })
|
| | | }
|
| | |
|
| | | /** å é¤æé®æä½ */
|
| | | function handleDelete(row) {
|
| | | proxy.$modal.confirm('æ¯å¦ç¡®è®¤å é¤å称为"' + row.menuName + '"çæ°æ®é¡¹?').then(function() {
|
| | | return delMenu(row.menuId)
|
| | | }).then(() => {
|
| | | getList()
|
| | | proxy.$modal.msgSuccess("å 餿å")
|
| | | }).catch(() => {})
|
| | | }
|
| | |
|
| | | onMounted(() => {
|
| | | getList();
|
| | | });
|
| | | </script>
|