mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -2,12 +2,10 @@ package com.gitee.sop.adminbackend.controller.isv;
|
|||||||
|
|
||||||
import com.gitee.fastmybatis.core.PageInfo;
|
import com.gitee.fastmybatis.core.PageInfo;
|
||||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
|
||||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||||
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupApiInfoParam;
|
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupApiInfoParam;
|
||||||
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupPermissionParam;
|
import com.gitee.sop.adminbackend.controller.isv.req.PermGroupPermissionParam;
|
||||||
import com.gitee.sop.adminbackend.dao.entity.ApiInfo;
|
import com.gitee.sop.adminbackend.dao.entity.ApiInfo;
|
||||||
import com.gitee.sop.adminbackend.dao.entity.PermGroupPermission;
|
|
||||||
import com.gitee.sop.adminbackend.service.isv.PermGroupPermissionService;
|
import com.gitee.sop.adminbackend.service.isv.PermGroupPermissionService;
|
||||||
import com.gitee.sop.adminbackend.service.isv.dto.PermGroupPermissionDTO;
|
import com.gitee.sop.adminbackend.service.isv.dto.PermGroupPermissionDTO;
|
||||||
import com.gitee.sop.adminbackend.util.CopyUtil;
|
import com.gitee.sop.adminbackend.util.CopyUtil;
|
||||||
@@ -19,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 六如
|
* @author 六如
|
||||||
@@ -37,10 +34,10 @@ public class PermGroupPermissionController {
|
|||||||
* @param param param
|
* @param param param
|
||||||
* @return 返回分页结果
|
* @return 返回分页结果
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/page")
|
||||||
public Result<List<ApiInfo>> page(@Validated PermGroupApiInfoParam param) {
|
public Result<PageInfo<ApiInfo>> page(Long groupId, @Validated PermGroupApiInfoParam param) {
|
||||||
LambdaQuery<ApiInfo> query = param.toLambdaQuery(ApiInfo.class);
|
LambdaQuery<ApiInfo> query = param.toLambdaQuery(ApiInfo.class);
|
||||||
List<ApiInfo> apiInfoList = permGroupPermissionService.listGroupApiId(param.getGroupId(), query);
|
PageInfo<ApiInfo> apiInfoList = permGroupPermissionService.pageGroupApiId(groupId, query);
|
||||||
return Result.ok(apiInfoList);
|
return Result.ok(apiInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +48,11 @@ public class PermGroupPermissionController {
|
|||||||
return Result.ok(cnt);
|
return Result.ok(cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("delete")
|
||||||
|
public Result<Integer> delete(@RequestBody @Validated PermGroupPermissionParam param) {
|
||||||
|
int cnt = permGroupPermissionService.delete(param.getGroupId(), param.getApiIdList());
|
||||||
|
return Result.ok(cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,19 +2,14 @@ package com.gitee.sop.adminbackend.controller.isv.req;
|
|||||||
|
|
||||||
import com.gitee.fastmybatis.core.query.Operator;
|
import com.gitee.fastmybatis.core.query.Operator;
|
||||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||||
import com.gitee.fastmybatis.core.query.param.IParam;
|
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 六如
|
* @author 六如
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class PermGroupApiInfoParam implements IParam {
|
public class PermGroupApiInfoParam extends PageParam {
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private Long groupId;
|
|
||||||
|
|
||||||
@Condition(operator = Operator.like)
|
@Condition(operator = Operator.like)
|
||||||
private String apiName;
|
private String apiName;
|
||||||
@@ -22,4 +17,6 @@ public class PermGroupApiInfoParam implements IParam {
|
|||||||
@Condition
|
@Condition
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Condition
|
||||||
|
private Integer isPermission;
|
||||||
}
|
}
|
||||||
|
@@ -19,4 +19,7 @@ public class ApiInfoPageParam extends PageParam {
|
|||||||
@Condition
|
@Condition
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
@Condition
|
||||||
|
private Integer isPermission;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -8,16 +8,13 @@ import com.gitee.sop.adminbackend.dao.entity.PermGroupPermission;
|
|||||||
import com.gitee.sop.adminbackend.dao.mapper.ApiInfoMapper;
|
import com.gitee.sop.adminbackend.dao.mapper.ApiInfoMapper;
|
||||||
import com.gitee.sop.adminbackend.dao.mapper.PermGroupPermissionMapper;
|
import com.gitee.sop.adminbackend.dao.mapper.PermGroupPermissionMapper;
|
||||||
import com.gitee.sop.adminbackend.service.isv.dto.PermGroupPermissionDTO;
|
import com.gitee.sop.adminbackend.service.isv.dto.PermGroupPermissionDTO;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,29 +37,34 @@ public class PermGroupPermissionService implements LambdaService<PermGroupPermis
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiInfo> listGroupApiId(Long groupId, LambdaQuery<ApiInfo> query) {
|
public PageInfo<ApiInfo> pageGroupApiId(Long groupId, LambdaQuery<ApiInfo> query) {
|
||||||
List<Long> apiIds = this.query()
|
List<Long> apiIds = this.query()
|
||||||
.eq(PermGroupPermission::getGroupId, groupId)
|
.eq(PermGroupPermission::getGroupId, groupId)
|
||||||
.listUniqueValue(PermGroupPermission::getApiId);
|
.listUniqueValue(PermGroupPermission::getApiId);
|
||||||
|
|
||||||
if (apiIds.isEmpty()) {
|
if (apiIds.isEmpty()) {
|
||||||
return new ArrayList<>(0);
|
return new PageInfo<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
query.in(ApiInfo::getId, apiIds);
|
query.in(ApiInfo::getId, apiIds);
|
||||||
|
|
||||||
return apiInfoMapper.list(query);
|
return apiInfoMapper.page(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int setting(PermGroupPermissionDTO param) {
|
public int setting(PermGroupPermissionDTO param) {
|
||||||
Long groupId = param.getGroupId();
|
Long groupId = param.getGroupId();
|
||||||
this.deleteByColumn(PermGroupPermission::getGroupId, groupId);
|
|
||||||
|
|
||||||
List<Long> apiIdList = param.getApiIdList();
|
List<Long> apiIdList = param.getApiIdList();
|
||||||
if (CollectionUtils.isEmpty(apiIdList)) {
|
if (CollectionUtils.isEmpty(apiIdList)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Long> existApiIdList = this.query()
|
||||||
|
.eq(PermGroupPermission::getGroupId, groupId)
|
||||||
|
.listUniqueValue(PermGroupPermission::getApiId);
|
||||||
|
|
||||||
List<PermGroupPermission> saveList = apiIdList.stream()
|
List<PermGroupPermission> saveList = apiIdList.stream()
|
||||||
|
// 已存在的不添加
|
||||||
|
.filter(apiId -> !existApiIdList.contains(apiId))
|
||||||
.map(apiId -> {
|
.map(apiId -> {
|
||||||
PermGroupPermission permGroupPermission = new PermGroupPermission();
|
PermGroupPermission permGroupPermission = new PermGroupPermission();
|
||||||
permGroupPermission.setGroupId(groupId);
|
permGroupPermission.setGroupId(groupId);
|
||||||
@@ -72,4 +74,11 @@ public class PermGroupPermissionService implements LambdaService<PermGroupPermis
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return this.saveBatch(saveList);
|
return this.saveBatch(saveList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int delete(Long groupId, Collection<Long> apiIds) {
|
||||||
|
return this.query()
|
||||||
|
.eq(PermGroupPermission::getGroupId, groupId)
|
||||||
|
.in(PermGroupPermission::getApiId, apiIds)
|
||||||
|
.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { createUrl, http } from "@/utils/http";
|
import { createUrl, http } from "@/utils/http";
|
||||||
import type { Result } from "@/model";
|
import type { PageResult, Result } from "@/model";
|
||||||
|
|
||||||
// 后端请求接口
|
// 后端请求接口
|
||||||
const apiUrl: any = createUrl({
|
const apiUrl: any = createUrl({
|
||||||
listGroupApiId: "perm/group/permission/list",
|
page: "perm/group/permission/page",
|
||||||
setting: "perm/group/permission/setting"
|
setting: "perm/group/permission/setting",
|
||||||
|
del: "perm/group/permission/delete"
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,13 +15,10 @@ export const api: any = {
|
|||||||
/**
|
/**
|
||||||
* 查询分组权限
|
* 查询分组权限
|
||||||
*
|
*
|
||||||
* @param groupId groupId
|
* @param params params
|
||||||
*/
|
*/
|
||||||
listGroupApiId(groupId: number): Promise<Result<any>> {
|
page(params): Promise<PageResult> {
|
||||||
const params = {
|
return http.get<PageResult, any>(apiUrl.page, { params });
|
||||||
groupId: groupId
|
|
||||||
};
|
|
||||||
return http.get<Result<any>, any>(apiUrl.listGroupApiId, { params });
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 设置接口权限
|
* 设置接口权限
|
||||||
@@ -34,5 +32,12 @@ export const api: any = {
|
|||||||
apiIdList: apiIdList
|
apiIdList: apiIdList
|
||||||
};
|
};
|
||||||
return http.post<Result<any>, any>(apiUrl.setting, { data });
|
return http.post<Result<any>, any>(apiUrl.setting, { data });
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
* @param data 表单内容
|
||||||
|
*/
|
||||||
|
del(data: object) {
|
||||||
|
return http.post<Result<any>, any>(apiUrl.del, { data });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { type PlusColumn, useTable } from "plus-pro-components";
|
import { type PageInfo, type PlusColumn, useTable } from "plus-pro-components";
|
||||||
import { withInstall } from "@pureadmin/utils";
|
import { withInstall } from "@pureadmin/utils";
|
||||||
import apiSelect from "./index.vue";
|
import apiSelect from "./index.vue";
|
||||||
import { StatusEnum } from "@/model/enums";
|
import { StatusEnum } from "@/model/enums";
|
||||||
@@ -15,8 +15,9 @@ export const handleSaveApi = ref((_: Array<number>) => {});
|
|||||||
export const searchFormData = ref({
|
export const searchFormData = ref({
|
||||||
apiName: "",
|
apiName: "",
|
||||||
status: "",
|
status: "",
|
||||||
|
isPermission: null,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 999999
|
pageSize: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查询表单字段定义
|
// 查询表单字段定义
|
||||||
@@ -48,13 +49,11 @@ export const searchFormColumns: PlusColumn[] = [
|
|||||||
// ========= table =========
|
// ========= table =========
|
||||||
|
|
||||||
// 表格对象
|
// 表格对象
|
||||||
export const { tableData } = useTable<any[]>();
|
export const { tableData, total, pageInfo } = useTable<any[]>();
|
||||||
|
// 默认每页条数,默认10
|
||||||
|
pageInfo.value.pageSize = 10;
|
||||||
|
|
||||||
interface TableRow {
|
const multipleSelection = ref([]);
|
||||||
id: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const multipleSelection = ref<TableRow[]>([]);
|
|
||||||
export const selectable = (row: any) => row.status === StatusEnum.ENABLE;
|
export const selectable = (row: any) => row.status === StatusEnum.ENABLE;
|
||||||
// 表格字段定义
|
// 表格字段定义
|
||||||
export const tableColumns: PlusColumn[] = [
|
export const tableColumns: PlusColumn[] = [
|
||||||
@@ -122,18 +121,9 @@ export const tableColumns: PlusColumn[] = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export const handleAuthApi = apiList => {
|
export const openDlg = () => {
|
||||||
dlgApiSelectShow.value = true;
|
dlgApiSelectShow.value = true;
|
||||||
const arr = [];
|
search();
|
||||||
for (let apiId of apiList) {
|
|
||||||
for (let row of tableData.value) {
|
|
||||||
if (apiId === row.id) {
|
|
||||||
arr.push(row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
multipleSelection.value = arr;
|
|
||||||
console.log(arr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleConfirm = () => {
|
export const handleConfirm = () => {
|
||||||
@@ -145,8 +135,7 @@ export const handleClose = () => {
|
|||||||
dlgApiSelectShow.value = false;
|
dlgApiSelectShow.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleSelectionChange = (rows: TableRow[]) => {
|
export const handleSelectionChange = (rows: any) => {
|
||||||
console.log(rows);
|
|
||||||
multipleSelection.value = rows;
|
multipleSelection.value = rows;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -155,18 +144,29 @@ export const handleSearch = () => {
|
|||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 分页事件
|
||||||
|
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
|
||||||
|
pageInfo.value = _pageInfo;
|
||||||
|
search();
|
||||||
|
};
|
||||||
|
|
||||||
// 查询
|
// 查询
|
||||||
export const search = async () => {
|
export const search = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await doSearch();
|
const { data } = await doSearch();
|
||||||
tableData.value = data;
|
tableData.value = data.list;
|
||||||
|
total.value = data.total;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
// 请求接口
|
// 请求接口
|
||||||
const doSearch = async () => {
|
const doSearch = async () => {
|
||||||
// 查询参数
|
// 查询参数
|
||||||
const data = searchFormData.value;
|
const data = searchFormData.value;
|
||||||
return serveApi.listAll(data);
|
// 添加分页参数
|
||||||
|
data.pageIndex = pageInfo.value.page;
|
||||||
|
data.pageSize = pageInfo.value.pageSize;
|
||||||
|
|
||||||
|
return serveApi.page(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
|
@@ -9,7 +9,10 @@ import {
|
|||||||
handleSearch,
|
handleSearch,
|
||||||
searchFormColumns,
|
searchFormColumns,
|
||||||
searchFormData,
|
searchFormData,
|
||||||
tableData
|
tableData,
|
||||||
|
pageInfo,
|
||||||
|
total,
|
||||||
|
handlePaginationChange
|
||||||
} from "@/components/ApiSelect/index";
|
} from "@/components/ApiSelect/index";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -40,7 +43,14 @@ import {
|
|||||||
:selectionTableColumnProps="{
|
:selectionTableColumnProps="{
|
||||||
selectable: selectable
|
selectable: selectable
|
||||||
}"
|
}"
|
||||||
|
:pagination="{
|
||||||
|
total,
|
||||||
|
modelValue: pageInfo,
|
||||||
|
pageSizeList: [10, 20, 50, 100],
|
||||||
|
align: 'right'
|
||||||
|
}"
|
||||||
adaptive
|
adaptive
|
||||||
|
@paginationChange="handlePaginationChange"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@@ -6,8 +6,6 @@ import {
|
|||||||
} from "plus-pro-components";
|
} from "plus-pro-components";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { api } from "@/api/permGroup";
|
import { api } from "@/api/permGroup";
|
||||||
import { api as permApi } from "@/api/permGroupPermission";
|
|
||||||
import { handleSaveApi, handleClose } from "@/components/ApiSelect";
|
|
||||||
import { searchTable } from "@/views/isv/perm/permGroupApi";
|
import { searchTable } from "@/views/isv/perm/permGroupApi";
|
||||||
|
|
||||||
const isAdd = ref(false);
|
const isAdd = ref(false);
|
||||||
@@ -29,17 +27,6 @@ export const searchFormColumns: PlusColumn[] = [
|
|||||||
|
|
||||||
// ========= table =========
|
// ========= table =========
|
||||||
|
|
||||||
handleSaveApi.value = apiIdList => {
|
|
||||||
const groupId = selectedGroupId.value;
|
|
||||||
if (groupId > 0) {
|
|
||||||
permApi.setting(groupId, apiIdList).then(() => {
|
|
||||||
ElMessage.success("保存成功");
|
|
||||||
handleClose();
|
|
||||||
search();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 表格对象
|
// 表格对象
|
||||||
export const { tableData, buttons: actionButtons } = useTable<any[]>();
|
export const { tableData, buttons: actionButtons } = useTable<any[]>();
|
||||||
|
|
||||||
@@ -61,12 +48,6 @@ actionButtons.value = [
|
|||||||
props: {
|
props: {
|
||||||
type: "primary"
|
type: "primary"
|
||||||
},
|
},
|
||||||
// onClick: withModifiers((params: ButtonsCallBackParams) => {
|
|
||||||
// isAdd.value = false;
|
|
||||||
// editFormData.value = Object.assign({}, params.row);
|
|
||||||
// dlgTitle.value = "修改";
|
|
||||||
// dlgShow.value = true;
|
|
||||||
// }, ['stop', 'self']),
|
|
||||||
onClick(params: ButtonsCallBackParams) {
|
onClick(params: ButtonsCallBackParams) {
|
||||||
params.e.stopPropagation();
|
params.e.stopPropagation();
|
||||||
isAdd.value = false;
|
isAdd.value = false;
|
||||||
|
@@ -1,9 +1,21 @@
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { type PlusColumn, useTable } from "plus-pro-components";
|
import {
|
||||||
|
type ButtonsCallBackParams,
|
||||||
|
type PageInfo,
|
||||||
|
type PlusColumn,
|
||||||
|
useTable
|
||||||
|
} from "plus-pro-components";
|
||||||
import { withInstall } from "@pureadmin/utils";
|
import { withInstall } from "@pureadmin/utils";
|
||||||
import permGroupApi from "./permGroupApi.vue";
|
import permGroupApi from "./permGroupApi.vue";
|
||||||
import { StatusEnum } from "@/model/enums";
|
import { StatusEnum } from "@/model/enums";
|
||||||
import { api as serveApi } from "@/api/serveApi";
|
import { api as permApi, api } from "@/api/permGroupPermission";
|
||||||
|
import {
|
||||||
|
handleClose,
|
||||||
|
handleSaveApi,
|
||||||
|
openDlg,
|
||||||
|
searchFormData as apiSearFormData
|
||||||
|
} from "@/components/ApiSelect";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
// ========= search form =========
|
// ========= search form =========
|
||||||
|
|
||||||
@@ -11,7 +23,9 @@ import { api as serveApi } from "@/api/serveApi";
|
|||||||
export const searchFormData = ref({
|
export const searchFormData = ref({
|
||||||
groupId: 0,
|
groupId: 0,
|
||||||
apiName: "",
|
apiName: "",
|
||||||
status: ""
|
status: "",
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查询表单字段定义
|
// 查询表单字段定义
|
||||||
@@ -42,9 +56,26 @@ export const searchFormColumns: PlusColumn[] = [
|
|||||||
|
|
||||||
// ========= table =========
|
// ========= table =========
|
||||||
|
|
||||||
// 表格对象
|
handleSaveApi.value = apiIdList => {
|
||||||
export const { tableData } = useTable<any[]>();
|
const groupId = searchFormData.value.groupId;
|
||||||
|
if (groupId > 0) {
|
||||||
|
permApi.setting(groupId, apiIdList).then(() => {
|
||||||
|
ElMessage.success("保存成功");
|
||||||
|
handleClose();
|
||||||
|
search();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 表格对象
|
||||||
|
export const {
|
||||||
|
tableData,
|
||||||
|
total,
|
||||||
|
pageInfo,
|
||||||
|
buttons: actionButtons
|
||||||
|
} = useTable<any[]>();
|
||||||
|
// 默认每页条数,默认10
|
||||||
|
pageInfo.value.pageSize = 10;
|
||||||
// 表格字段定义
|
// 表格字段定义
|
||||||
export const tableColumns: PlusColumn[] = [
|
export const tableColumns: PlusColumn[] = [
|
||||||
{
|
{
|
||||||
@@ -110,6 +141,35 @@ export const tableColumns: PlusColumn[] = [
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
// 表格按钮定义
|
||||||
|
actionButtons.value = [
|
||||||
|
{
|
||||||
|
// 删除
|
||||||
|
text: "删除",
|
||||||
|
code: "delete",
|
||||||
|
props: {
|
||||||
|
type: "danger"
|
||||||
|
},
|
||||||
|
confirm: {
|
||||||
|
options: { draggable: false }
|
||||||
|
},
|
||||||
|
onConfirm(params: ButtonsCallBackParams) {
|
||||||
|
const data = {
|
||||||
|
groupId: searchFormData.value.groupId,
|
||||||
|
apiIdList: [params.row.id]
|
||||||
|
};
|
||||||
|
api.del(data).then(() => {
|
||||||
|
ElMessage.success("删除成功");
|
||||||
|
search();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export const handleOpenDlg = () => {
|
||||||
|
apiSearFormData.value.isPermission = 1;
|
||||||
|
openDlg();
|
||||||
|
};
|
||||||
|
|
||||||
export const searchTable = groupId => {
|
export const searchTable = groupId => {
|
||||||
searchFormData.value.groupId = groupId;
|
searchFormData.value.groupId = groupId;
|
||||||
@@ -121,18 +181,29 @@ export const handleSearch = () => {
|
|||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 分页事件
|
||||||
|
export const handlePaginationChange = (_pageInfo: PageInfo): void => {
|
||||||
|
pageInfo.value = _pageInfo;
|
||||||
|
search();
|
||||||
|
};
|
||||||
|
|
||||||
// 查询
|
// 查询
|
||||||
export const search = async () => {
|
export const search = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await doSearch();
|
const { data } = await doSearch();
|
||||||
tableData.value = data;
|
tableData.value = data.list;
|
||||||
|
total.value = data.total;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
// 请求接口
|
// 请求接口
|
||||||
const doSearch = async () => {
|
const doSearch = async () => {
|
||||||
// 查询参数
|
// 查询参数
|
||||||
const data = searchFormData.value;
|
const data = searchFormData.value;
|
||||||
return serveApi.listAll(data);
|
// 添加分页参数
|
||||||
|
data.pageIndex = pageInfo.value.page;
|
||||||
|
data.pageSize = pageInfo.value.pageSize;
|
||||||
|
|
||||||
|
return api.page(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const PermGroupApi = withInstall(permGroupApi);
|
const PermGroupApi = withInstall(permGroupApi);
|
||||||
|
@@ -4,9 +4,14 @@ import {
|
|||||||
handleSearch,
|
handleSearch,
|
||||||
searchFormColumns,
|
searchFormColumns,
|
||||||
searchFormData,
|
searchFormData,
|
||||||
tableData
|
tableData,
|
||||||
|
total,
|
||||||
|
pageInfo,
|
||||||
|
handleOpenDlg,
|
||||||
|
handlePaginationChange
|
||||||
} from "./permGroupApi";
|
} from "./permGroupApi";
|
||||||
import { ApiSelect } from "@/components/ApiSelect/index";
|
import { ApiSelect } from "@/components/ApiSelect/index";
|
||||||
|
import { actionButtons } from "./permGroupApi";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -21,7 +26,22 @@ import { ApiSelect } from "@/components/ApiSelect/index";
|
|||||||
@search="handleSearch"
|
@search="handleSearch"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<PlusTable :columns="tableColumns" :table-data="tableData" adaptive />
|
<PlusTable
|
||||||
|
:columns="tableColumns"
|
||||||
|
:table-data="tableData"
|
||||||
|
:action-bar="{ buttons: actionButtons, width: 80 }"
|
||||||
|
:pagination="{
|
||||||
|
total,
|
||||||
|
modelValue: pageInfo,
|
||||||
|
pageSizeList: [10, 20, 50, 100],
|
||||||
|
align: 'right'
|
||||||
|
}"
|
||||||
|
@paginationChange="handlePaginationChange"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<el-button type="primary" @click="handleOpenDlg">授权接口</el-button>
|
||||||
|
</template>
|
||||||
|
</PlusTable>
|
||||||
<ApiSelect />
|
<ApiSelect />
|
||||||
</el-card>
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
|
@@ -213,7 +213,6 @@ actionButtons.value = [
|
|||||||
};
|
};
|
||||||
api.updateStatus(data).then(() => {
|
api.updateStatus(data).then(() => {
|
||||||
ElMessage.success("修改成功");
|
ElMessage.success("修改成功");
|
||||||
dlgShow.value = false;
|
|
||||||
search();
|
search();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -234,7 +233,7 @@ const editFormDataGen = () => {
|
|||||||
status: 1,
|
status: 1,
|
||||||
isPermission: 0,
|
isPermission: 0,
|
||||||
description: "",
|
description: "",
|
||||||
regSource: 1,
|
regSource: RegSource.CUSTOM,
|
||||||
isNeedToken: 0
|
isNeedToken: 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user