mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 23:47:17 +08:00
Merge pull request #3 from gyzhang/fix_by_kevin_20231002
fix: 修改“岗位管理”-查询、排序、重置、全部导出到excel等的错误
This commit is contained in:
commit
c1db073b23
@ -110,7 +110,7 @@ function openDialog(type: "add" | "update", row?: PostPageResponse) {
|
|||||||
type="primary"
|
type="primary"
|
||||||
:icon="useRenderIcon(Search)"
|
:icon="useRenderIcon(Search)"
|
||||||
:loading="pageLoading"
|
:loading="pageLoading"
|
||||||
@click="onSearch"
|
@click="onSearch(tableRef)"
|
||||||
>
|
>
|
||||||
搜索
|
搜索
|
||||||
</el-button>
|
</el-button>
|
||||||
|
@ -16,8 +16,8 @@ const statusMap = useUserStoreHook().dictionaryMap["common.status"];
|
|||||||
|
|
||||||
export function usePostHook() {
|
export function usePostHook() {
|
||||||
const defaultSort: Sort = {
|
const defaultSort: Sort = {
|
||||||
prop: "createTime",
|
prop: "postSort",
|
||||||
order: "descending"
|
order: "ascending"
|
||||||
};
|
};
|
||||||
|
|
||||||
const pagination: PaginationProps = {
|
const pagination: PaginationProps = {
|
||||||
@ -80,6 +80,7 @@ export function usePostHook() {
|
|||||||
{
|
{
|
||||||
label: "岗位排序",
|
label: "岗位排序",
|
||||||
prop: "postSort",
|
prop: "postSort",
|
||||||
|
sortable: "custom",
|
||||||
minWidth: 120
|
minWidth: 120
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -114,36 +115,31 @@ export function usePostHook() {
|
|||||||
|
|
||||||
function onSortChanged(sort: Sort) {
|
function onSortChanged(sort: Sort) {
|
||||||
sortState.value = sort;
|
sortState.value = sort;
|
||||||
onSearch();
|
// 表格列的排序变化的时候,需要重置分页
|
||||||
}
|
|
||||||
|
|
||||||
async function onSearch() {
|
|
||||||
// 点击搜索的时候 需要重置分页
|
|
||||||
pagination.currentPage = 1;
|
pagination.currentPage = 1;
|
||||||
getPostList();
|
getPostList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onSearch(tableRef) {
|
||||||
|
// 点击搜索的时候,需要重置排序,重新排序的时候会重置分页并发起查询请求
|
||||||
|
tableRef.getTableRef().sort("postSort", "ascending");
|
||||||
|
}
|
||||||
|
|
||||||
function resetForm(formEl, tableRef) {
|
function resetForm(formEl, tableRef) {
|
||||||
if (!formEl) return;
|
if (!formEl) return;
|
||||||
// 清空查询参数
|
// 清空查询参数
|
||||||
formEl.resetFields();
|
formEl.resetFields();
|
||||||
// 清空排序
|
|
||||||
searchFormParams.orderColumn = undefined;
|
|
||||||
searchFormParams.orderDirection = undefined;
|
|
||||||
// 清空时间查询 TODO 这块有点繁琐 有可以优化的地方吗?
|
// 清空时间查询 TODO 这块有点繁琐 有可以优化的地方吗?
|
||||||
// Form组件的resetFields方法无法清除datepicker里面的数据。
|
// Form组件的resetFields方法无法清除datepicker里面的数据。
|
||||||
searchFormParams.beginTime = undefined;
|
searchFormParams.beginTime = undefined;
|
||||||
searchFormParams.endTime = undefined;
|
searchFormParams.endTime = undefined;
|
||||||
tableRef.getTableRef().clearSort();
|
|
||||||
// 重置分页并查询
|
// 重置分页并查询
|
||||||
onSearch();
|
onSearch(tableRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPostList(sort: Sort = defaultSort) {
|
async function getPostList() {
|
||||||
pageLoading.value = true;
|
pageLoading.value = true;
|
||||||
if (sort != null) {
|
CommonUtils.fillSortParams(searchFormParams, sortState.value);
|
||||||
CommonUtils.fillSortParams(searchFormParams, sort);
|
|
||||||
}
|
|
||||||
CommonUtils.fillPaginationParams(searchFormParams, pagination);
|
CommonUtils.fillPaginationParams(searchFormParams, pagination);
|
||||||
|
|
||||||
const { data } = await getPostListApi(toRaw(searchFormParams)).finally(
|
const { data } = await getPostListApi(toRaw(searchFormParams)).finally(
|
||||||
@ -162,12 +158,12 @@ export function usePostHook() {
|
|||||||
CommonUtils.fillPaginationParams(searchFormParams, pagination);
|
CommonUtils.fillPaginationParams(searchFormParams, pagination);
|
||||||
CommonUtils.fillTimeRangeParams(searchFormParams, timeRange.value);
|
CommonUtils.fillTimeRangeParams(searchFormParams, timeRange.value);
|
||||||
|
|
||||||
exportPostExcelApi(toRaw(searchFormParams), "岗位数据.xls");
|
exportPostExcelApi(toRaw(searchFormParams), "岗位数据.xlsx");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(row) {
|
async function handleDelete(row) {
|
||||||
await deletePostApi([row.logId]).then(() => {
|
await deletePostApi([row.postId]).then(() => {
|
||||||
message(`您删除了操作编号为${row.logId}的这条数据`, {
|
message(`您删除了编号为${row.postId}的这条岗位数据`, {
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
@ -182,7 +178,7 @@ export function usePostHook() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm(
|
||||||
`确认要<strong>删除</strong>编号为<strong style='color:var(--el-color-primary)'>[ ${multipleSelection.value} ]</strong>的日志吗?`,
|
`确认要<strong>删除</strong>编号为<strong style='color:var(--el-color-primary)'>[ ${multipleSelection.value} ]</strong>的岗位数据吗?`,
|
||||||
"系统提示",
|
"系统提示",
|
||||||
{
|
{
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
@ -194,7 +190,7 @@ export function usePostHook() {
|
|||||||
)
|
)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await deletePostApi(multipleSelection.value).then(() => {
|
await deletePostApi(multipleSelection.value).then(() => {
|
||||||
message(`您删除了日志编号为[ ${multipleSelection.value} ]的数据`, {
|
message(`您删除了编号为[ ${multipleSelection.value} ]的岗位数据`, {
|
||||||
type: "success"
|
type: "success"
|
||||||
});
|
});
|
||||||
// 刷新列表
|
// 刷新列表
|
||||||
|
Loading…
x
Reference in New Issue
Block a user