|
@@ -35,7 +35,7 @@
|
|
<RoleIndexModal @register="registerIndexModal" />
|
|
<RoleIndexModal @register="registerIndexModal" />
|
|
</template>
|
|
</template>
|
|
<script lang="ts" name="system-role" setup>
|
|
<script lang="ts" name="system-role" setup>
|
|
-import { ref } from 'vue';
|
|
|
|
|
|
+import { ref, onMounted, watch } from 'vue';
|
|
import { BasicTable, TableAction } from '/@/components/Table';
|
|
import { BasicTable, TableAction } from '/@/components/Table';
|
|
import { useDrawer } from '/@/components/Drawer';
|
|
import { useDrawer } from '/@/components/Drawer';
|
|
import { useModal } from '/@/components/Modal';
|
|
import { useModal } from '/@/components/Modal';
|
|
@@ -54,6 +54,17 @@ const [registerDrawer, { openDrawer }] = useDrawer();
|
|
const [registerIndexModal, { openModal: openIndexModal }] = useModal();
|
|
const [registerIndexModal, { openModal: openIndexModal }] = useModal();
|
|
const [rolePermissionDrawer, { openDrawer: openRolePermissionDrawer }] = useDrawer();
|
|
const [rolePermissionDrawer, { openDrawer: openRolePermissionDrawer }] = useDrawer();
|
|
const [registerDesc, { openDrawer: openRoleDesc }] = useDrawer();
|
|
const [registerDesc, { openDrawer: openRoleDesc }] = useDrawer();
|
|
|
|
+const isFirst = ref(true);
|
|
|
|
+const apps = ref([]);
|
|
|
|
+onMounted(async () => {
|
|
|
|
+ apps.value = await appList();
|
|
|
|
+});
|
|
|
|
+watch(() => apps.value,(newVal) => {
|
|
|
|
+ if (newVal.length > 0) {
|
|
|
|
+ reload();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+);
|
|
|
|
|
|
// 列表页面公共参数、方法
|
|
// 列表页面公共参数、方法
|
|
const { prefixCls, tableContext, onImportXls, onExportXls } = useListPage({
|
|
const { prefixCls, tableContext, onImportXls, onExportXls } = useListPage({
|
|
@@ -63,6 +74,8 @@ const { prefixCls, tableContext, onImportXls, onExportXls } = useListPage({
|
|
api: list,
|
|
api: list,
|
|
columns: columns,
|
|
columns: columns,
|
|
striped: true,
|
|
striped: true,
|
|
|
|
+ immediate: false,
|
|
|
|
+
|
|
formConfig: {
|
|
formConfig: {
|
|
labelWidth: 65,
|
|
labelWidth: 65,
|
|
rowProps: { gutter: 24 },
|
|
rowProps: { gutter: 24 },
|
|
@@ -77,8 +90,14 @@ const { prefixCls, tableContext, onImportXls, onExportXls } = useListPage({
|
|
column: 'createTime',
|
|
column: 'createTime',
|
|
order: 'desc',
|
|
order: 'desc',
|
|
},
|
|
},
|
|
|
|
+ beforeFetch: async (params) => {
|
|
|
|
+ if (isFirst.value) {
|
|
|
|
+ params.appId = apps.value[0].id;
|
|
|
|
+ isFirst.value = false;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
afterFetch: async (record) => {
|
|
afterFetch: async (record) => {
|
|
- const app = await appList();
|
|
|
|
|
|
+ const app = apps.value;
|
|
record.forEach((item) => {
|
|
record.forEach((item) => {
|
|
// 获取当前角色的appName
|
|
// 获取当前角色的appName
|
|
const rightApp = app.find((m) => m.id === item.appId);
|
|
const rightApp = app.find((m) => m.id === item.appId);
|
|
@@ -142,7 +161,7 @@ async function batchHandleDelete() {
|
|
* 角色授权弹窗
|
|
* 角色授权弹窗
|
|
*/
|
|
*/
|
|
function handlePerssion(record) {
|
|
function handlePerssion(record) {
|
|
- openRolePermissionDrawer(true, { roleId: record.id,appId: record.appId,appName: record.appName });
|
|
|
|
|
|
+ openRolePermissionDrawer(true, { roleId: record.id, appId: record.appId, appName: record.appName });
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* 首页配置弹窗
|
|
* 首页配置弹窗
|
|
@@ -162,7 +181,7 @@ function handleUser(record) {
|
|
*/
|
|
*/
|
|
function getTableAction(record) {
|
|
function getTableAction(record) {
|
|
return [
|
|
return [
|
|
- {
|
|
|
|
|
|
+ {
|
|
label: '授权',
|
|
label: '授权',
|
|
onClick: handlePerssion.bind(null, record),
|
|
onClick: handlePerssion.bind(null, record),
|
|
},
|
|
},
|
|
@@ -170,7 +189,6 @@ function getTableAction(record) {
|
|
label: '分配用户',
|
|
label: '分配用户',
|
|
onClick: handleUser.bind(null, record),
|
|
onClick: handleUser.bind(null, record),
|
|
},
|
|
},
|
|
-
|
|
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|