feat: 禁用功能增加tip 提示

This commit is contained in:
lbw 2023-02-15 15:38:15 +08:00
parent 0fd375fe26
commit 0fafbd4226
7 changed files with 53 additions and 24 deletions

View File

@ -21,7 +21,8 @@ export default {
inputSystemFlagTip: 'input systemFlag',
inputDelFlagTip: 'input delFlag',
inputTenantIdTip: 'input tenantId',
dictItem: 'dict item'
dictItem: 'dict item',
deleteDisabledTip: 'system data cannot be deleted ',
},
dictItem: {
index: 'index',

View File

@ -24,7 +24,8 @@ export default {
inputSystemFlagTip: '请输入字典类型',
inputDelFlagTip: '请输入 delFlag',
inputTenantIdTip: '请输入所属租户',
dictItem: '字典项'
dictItem: '字典项',
deleteDisabledTip: '系统内置数据不能删除',
},
dictItem: {
index: '序号',

View File

@ -54,10 +54,17 @@
<el-table-column label="操作" width="200">
<template #default="scope">
<el-button text type="primary" @click="onOpenEditDic('edit', scope.row)">修改</el-button>
<el-button text type="primary" :disabled="scope.row.systemFlag !== '1'"
@click="handleDelete([scope.row.id])">删除</el-button>
<el-button text type="primary" @click="showDictITem(scope.row)">字典项</el-button>
<el-button text type="primary" @click="onOpenEditDic('edit', scope.row)">修改</el-button>
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1"
placement="top">
<span style="margin-left: 12px">
<el-button text type="primary" :disabled="scope.row.systemFlag !== 1"
@click="handleDelete([scope.row.id])">
{{ $t('common.delBtn') }}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>

View File

@ -28,5 +28,6 @@ export default {
inputDelFlagTip: 'input delFlag',
inputTenantIdTip: 'input tenantId',
inputEmbeddedTip: 'input embedded',
deleteDisabledTip: 'menu inclusion subordinates cannot be deleted',
}
}

View File

@ -22,6 +22,7 @@ export default {
inputKeepAliveTip: '请选择是否缓冲',
inputMenuTypeTip: '请选择菜单类型',
inputEmbeddedTip: '请选择是否内嵌',
deleteDisabledTip: '菜单包含下级不能删除',
},
}

View File

@ -14,12 +14,13 @@
<el-table :data="state.dataList" v-loading="state.loading" style="width: 100%" row-key="path"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column prop="name" :label="$t('sysmenu.name')" show-overflow-tooltip></el-table-column>
<el-table-column prop="sortOrder" :label="$t('sysmenu.sortOrder')" show-overflow-tooltip></el-table-column>
<el-table-column prop="sortOrder" :label="$t('sysmenu.sortOrder')"
show-overflow-tooltip></el-table-column>
<el-table-column prop="icon" :label="$t('sysmenu.icon')" show-overflow-tooltip>
<template #default="scope">
<SvgIcon :name="scope.row.icon" />
</template>
</el-table-column>
<template #default="scope">
<SvgIcon :name="scope.row.icon" />
</template>
</el-table-column>
<el-table-column prop="path" :label="$t('sysmenu.path')" show-overflow-tooltip></el-table-column>
<el-table-column :label="$t('sysmenu.menuType')" show-overflow-tooltip>
<template #default="scope">
@ -43,9 +44,16 @@
}}</el-button>
<el-button text type="primary" @click="onOpenEditMenu('edit', scope.row)"
v-auth="'sys_menu_edit'">{{ $t('common.editBtn') }}</el-button>
<el-button text type="primary" @click="onTabelRowDel(scope.row)" v-auth="'sys_menu_del'">{{
$t('common.delBtn')
}}</el-button>
<el-tooltip :content="$t('sysmenu.deleteDisabledTip')"
:disabled="!deleteMenuDisabled(scope.row)" placement="top">
<span style="margin-left: 12px">
<el-button text type="primary" :disabled="deleteMenuDisabled(scope.row)"
@click="onTabelRowDel(scope.row)" v-auth="'sys_menu_del'">
{{ $t('common.delBtn') }}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>
@ -63,7 +71,7 @@ import { useMessage, useMessageBox } from "/@/hooks/message";
const MenuDialog = defineAsyncComponent(() => import('./form.vue'));
//
const menuDialogRef = ref<InstanceType<typeof MenuDialog>>();
const menuDialogRef = ref();
const state: BasicTableProps = reactive<BasicTableProps>({
pageList: pageList, // H
queryForm: {
@ -72,7 +80,6 @@ const state: BasicTableProps = reactive<BasicTableProps>({
isPage: false
});
const {
getDataList,
} = useTable(state)
@ -85,16 +92,22 @@ const onOpenAddMenu = (type: string) => {
const onOpenEditMenu = (type: string, row: RouteRecordRaw) => {
menuDialogRef.value.openDialog(type, row);
};
//
//
const deleteMenuDisabled = (row: any) => {
return (row.children || []).length > 0
}
//
const onTabelRowDel = (row: any) => {
useMessageBox().confirm(`此操作将永久删除路由:${row.name}`)
.then(() => {
delObj(row.id).then(() => {
useMessage().success('删除成功');
getDataList()
})
}).catch((err: any) => {
useMessage().error(err.msg)
});
})
.catch(() => { });
};
</script>

View File

@ -58,11 +58,16 @@
$t('common.editBtn')
}}
</el-button>
<el-button text :disabled="scope.row.systemFlag === '1'" type="primary"
@click="handleDelete([scope.row.publicId])">{{
$t('common.delBtn')
}}
</el-button>
<el-tooltip :content="$t('sysdict.deleteDisabledTip')" :disabled="scope.row.systemFlag === 1"
placement="top">
<span style="margin-left: 12px">
<el-button text type="primary" :disabled="scope.row.systemFlag !== 1"
@click="handleDelete([scope.row.publicId])">
{{ $t('common.delBtn') }}
</el-button>
</span>
</el-tooltip>
</template>
</el-table-column>
</el-table>