|
@@ -12,12 +12,12 @@
|
|
|
</ElInput>
|
|
</ElInput>
|
|
|
</ElCol>
|
|
</ElCol>
|
|
|
<ElCol :md="6">
|
|
<ElCol :md="6">
|
|
|
- <ElButton type="primary">查找</ElButton>
|
|
|
|
|
|
|
+ <ElButton type="primary" @click="rolequery">查找</ElButton>
|
|
|
</ElCol>
|
|
</ElCol>
|
|
|
</ElFormItem>
|
|
</ElFormItem>
|
|
|
<div style="height: 500px;overflow-y: auto;">
|
|
<div style="height: 500px;overflow-y: auto;">
|
|
|
<div class="pad-2 roleitem flex f-c " v-for="(item, index) in roleList" :key="index"
|
|
<div class="pad-2 roleitem flex f-c " v-for="(item, index) in roleList" :key="index"
|
|
|
- @click="roleitemClick(item.id)">
|
|
|
|
|
|
|
+ @click="roleitemClick(item)">
|
|
|
<span>{{ item.name }}</span>
|
|
<span>{{ item.name }}</span>
|
|
|
<span style="margin-top: 10px;font-size: 12px;color: #999;">{{ item.remark }}</span>
|
|
<span style="margin-top: 10px;font-size: 12px;color: #999;">{{ item.remark }}</span>
|
|
|
</div>
|
|
</div>
|
|
@@ -33,6 +33,7 @@
|
|
|
<span class="strong">角色管理</span>
|
|
<span class="strong">角色管理</span>
|
|
|
<div>
|
|
<div>
|
|
|
<ElButton type="primary" @click="roleSubmit">提交</ElButton>
|
|
<ElButton type="primary" @click="roleSubmit">提交</ElButton>
|
|
|
|
|
+ <ElButton v-if="roleInfo.id" type="danger" @click="roleDelClick">删除</ElButton>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
@@ -65,7 +66,7 @@
|
|
|
<script lang='ts' setup>
|
|
<script lang='ts' setup>
|
|
|
import { asyncRoutes } from '@/router/routes' // 请根据实际路径调整
|
|
import { asyncRoutes } from '@/router/routes' // 请根据实际路径调整
|
|
|
import { ref, reactive, onBeforeMount } from 'vue';
|
|
import { ref, reactive, onBeforeMount } from 'vue';
|
|
|
-import type { FormRules, ElTree } from 'element-plus';
|
|
|
|
|
|
|
+import { FormRules, ElTree, ElMessage, ElMessageBox } from 'element-plus';
|
|
|
import { preprocessRoutes, convertToTreeData, TreeNode } from '@/utils/composables/routeUtils'; // 导入工具方法
|
|
import { preprocessRoutes, convertToTreeData, TreeNode } from '@/utils/composables/routeUtils'; // 导入工具方法
|
|
|
import api from '@/api'
|
|
import api from '@/api'
|
|
|
import Message from 'vue-m-message'
|
|
import Message from 'vue-m-message'
|
|
@@ -87,6 +88,8 @@ interface Perm {
|
|
|
}
|
|
}
|
|
|
const treeRef = ref<InstanceType<typeof ElTree>>();
|
|
const treeRef = ref<InstanceType<typeof ElTree>>();
|
|
|
const roleName = ref<string>("");
|
|
const roleName = ref<string>("");
|
|
|
|
|
+const roleId = ref<string>("");
|
|
|
|
|
+
|
|
|
const PageNum = ref<number>(1);
|
|
const PageNum = ref<number>(1);
|
|
|
const PageSize = ref<number>(20);
|
|
const PageSize = ref<number>(20);
|
|
|
const checkedKeys = ref<string[]>([])
|
|
const checkedKeys = ref<string[]>([])
|
|
@@ -139,15 +142,18 @@ async function roleSubmit() {
|
|
|
await api.roleApi.roleUpdate(roleInfo).then((res: any) => {
|
|
await api.roleApi.roleUpdate(roleInfo).then((res: any) => {
|
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
|
rolequery();
|
|
rolequery();
|
|
|
- Message.success(res.msg, {
|
|
|
|
|
- zIndex: 2000,
|
|
|
|
|
|
|
+ ElMessage({
|
|
|
|
|
+ type: 'success',
|
|
|
|
|
+ message: res.msg,
|
|
|
|
|
+ plain: true,
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
resetForm();
|
|
resetForm();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- await api.roleApi.roleAdd(roleInfo).then((res:any) => {
|
|
|
|
|
|
|
+ await api.roleApi.roleAdd(roleInfo).then((res: any) => {
|
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
|
rolequery();
|
|
rolequery();
|
|
|
Message.success(res.msg, {
|
|
Message.success(res.msg, {
|
|
@@ -158,6 +164,43 @@ async function roleSubmit() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
+function roleDelClick() {
|
|
|
|
|
+ api.roleApi.roleDeleteValid({ systemCode: roleInfo.system, id: roleId.value }).then((res: any) => {
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
|
+ '确定要删除该角色吗?',
|
|
|
|
|
+ '删除角色',
|
|
|
|
|
+ {
|
|
|
|
|
+ confirmButtonText: '确认删除',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'error',
|
|
|
|
|
+ draggable: true,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ .then(async () => {
|
|
|
|
|
+ await api.roleApi.roleDelete({ id: roleId.value }).then((res: any) => {
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ rolequery();
|
|
|
|
|
+ Message.success(res.msg, {
|
|
|
|
|
+ zIndex: 2000,
|
|
|
|
|
+ })
|
|
|
|
|
+ resetForm();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ElMessageBox.alert('删除角色前,请先移除角色内的所有成员', '无法删除', {
|
|
|
|
|
+ confirmButtonText: '知道了',
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
function pageChange(e: number) {
|
|
function pageChange(e: number) {
|
|
|
PageNum.value = e;
|
|
PageNum.value = e;
|
|
@@ -166,8 +209,8 @@ function pageChange(e: number) {
|
|
|
function sizeChange(val: number) {
|
|
function sizeChange(val: number) {
|
|
|
PageSize.value = val;
|
|
PageSize.value = val;
|
|
|
}
|
|
}
|
|
|
-function roleitemClick(id: string) {
|
|
|
|
|
- api.roleApi.roleGet({ roleId: id }).then((res: any) => {
|
|
|
|
|
|
|
+async function roleitemClick(item: { id: string }) {
|
|
|
|
|
+ await api.roleApi.roleGet({ roleId: item.id }).then((res: any) => {
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
checkedKeys.value = res.data.perms.map((val: Perm) => val.id);
|
|
checkedKeys.value = res.data.perms.map((val: Perm) => val.id);
|
|
|
roleInfo.permsId = res.data.perms.map((val: Perm) => val.id);
|
|
roleInfo.permsId = res.data.perms.map((val: Perm) => val.id);
|
|
@@ -175,11 +218,12 @@ function roleitemClick(id: string) {
|
|
|
roleInfo.name = res.data.name;
|
|
roleInfo.name = res.data.name;
|
|
|
roleInfo.remark = res.data.remark;
|
|
roleInfo.remark = res.data.remark;
|
|
|
roleInfo.id = res.data.id;
|
|
roleInfo.id = res.data.id;
|
|
|
|
|
+ roleId.value = res.data.id;
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
async function rolequery() {
|
|
async function rolequery() {
|
|
|
- await api.roleApi.roleList({ pageNum: PageNum.value, pageSize: PageSize.value }).then((res: any) => {
|
|
|
|
|
|
|
+ await api.roleApi.roleList({ pageNum: PageNum.value, pageSize: PageSize.value, name: roleName.value }).then((res: any) => {
|
|
|
totalSize.value = res.data.total;
|
|
totalSize.value = res.data.total;
|
|
|
roleList.value = res.data.records;
|
|
roleList.value = res.data.records;
|
|
|
})
|
|
})
|