refactor: 分页响应数据结构调整
This commit is contained in:
@@ -99,13 +99,9 @@ const stateArr = ref<OptionItem[]>([
|
||||
|
||||
// 初始化选项数据
|
||||
const initOptions = async () => {
|
||||
try {
|
||||
const [dept, roles] = await Promise.all([DeptAPI.getOptions(), RoleAPI.getOptions()]);
|
||||
deptArr.value = dept;
|
||||
roleArr.value = roles;
|
||||
} catch (error) {
|
||||
console.error("初始化选项失败:", error);
|
||||
}
|
||||
const [dept, roles] = await Promise.all([DeptAPI.getOptions(), RoleAPI.getOptions()]);
|
||||
deptArr.value = dept;
|
||||
roleArr.value = roles;
|
||||
};
|
||||
|
||||
// ========================= 搜索配置 =========================
|
||||
@@ -191,9 +187,9 @@ const contentConfig: IContentConfig<UserQueryParams, UserItem> = reactive({
|
||||
return Promise.resolve();
|
||||
},
|
||||
async exportsAction(params: any) {
|
||||
const res = await UserAPI.getPage(params);
|
||||
console.log("exportsAction", res.data);
|
||||
return res.data;
|
||||
const data = await UserAPI.getPage(params);
|
||||
console.log("exportsAction", data.list);
|
||||
return data.list;
|
||||
},
|
||||
pk: "id",
|
||||
toolbar: [
|
||||
@@ -560,8 +556,8 @@ const handleOperateClick = (data: IObject) => {
|
||||
ElMessageBox.prompt("请输入用户名" + data.row.username + "」的新密码", "重置密码", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
})
|
||||
.then(({ value }: any) => {
|
||||
}).then(
|
||||
({ value }: any) => {
|
||||
if (!value || value.length < 6) {
|
||||
ElMessage.warning("密码至少需6位字符,请重新输入");
|
||||
return false;
|
||||
@@ -569,8 +565,11 @@ const handleOperateClick = (data: IObject) => {
|
||||
UserAPI.resetPassword(data.row.id, value).then(() => {
|
||||
ElMessage.success("密码重置成功,新密码是:" + value);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
() => {
|
||||
// 用户取消
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ const contentConfig: IContentConfig<UserQueryParams, UserItem> = {
|
||||
},
|
||||
async exportsAction(params) {
|
||||
// 模拟获取到的是全量数据
|
||||
const res = await UserAPI.getPage(params);
|
||||
console.log("exportsAction", res.data);
|
||||
return res.data;
|
||||
const data = await UserAPI.getPage(params);
|
||||
console.log("exportsAction", data.list);
|
||||
return data.list;
|
||||
},
|
||||
pk: "id",
|
||||
toolbar: [
|
||||
|
||||
@@ -18,14 +18,10 @@ export const stateArr = ref<OptionItem[]>([
|
||||
|
||||
// 初始化逻辑,在 onMounted 钩子中调用
|
||||
export const initOptions = async () => {
|
||||
try {
|
||||
// 使用Promise.all并行请求
|
||||
const [dept, roles] = await Promise.all([DeptAPI.getOptions(), RoleAPI.getOptions()]);
|
||||
// 获取部门选项并赋值
|
||||
deptArr.value = dept;
|
||||
// 获取角色选项并赋值
|
||||
roleArr.value = roles;
|
||||
} catch (error) {
|
||||
console.error("初始化选项失败:", error);
|
||||
}
|
||||
// 使用Promise.all并行请求
|
||||
const [dept, roles] = await Promise.all([DeptAPI.getOptions(), RoleAPI.getOptions()]);
|
||||
// 获取部门选项并赋值
|
||||
deptArr.value = dept;
|
||||
// 获取角色选项并赋值
|
||||
roleArr.value = roles;
|
||||
};
|
||||
|
||||
@@ -68,12 +68,8 @@ const contentConfig: IContentConfig<DemoQueryParams, DemoItem> = {
|
||||
const end = start + pageSize;
|
||||
|
||||
return Promise.resolve({
|
||||
data: list.slice(start, end),
|
||||
page: {
|
||||
pageNum,
|
||||
pageSize,
|
||||
total: list.length,
|
||||
},
|
||||
list: list.slice(start, end),
|
||||
total: list.length,
|
||||
});
|
||||
},
|
||||
modifyAction(data) {
|
||||
|
||||
@@ -169,8 +169,8 @@ const handleOperateClick = (data: IObject) => {
|
||||
ElMessageBox.prompt("请输入用户名" + data.row.username + "」的新密码", "重置密码", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
})
|
||||
.then(({ value }) => {
|
||||
}).then(
|
||||
({ value }) => {
|
||||
if (!value || value.length < 6) {
|
||||
ElMessage.warning("密码至少需6位字符,请重新输入");
|
||||
return false;
|
||||
@@ -178,8 +178,11 @@ const handleOperateClick = (data: IObject) => {
|
||||
UserAPI.resetPassword(data.row.id, value).then(() => {
|
||||
ElMessage.success("密码重置成功,新密码是:" + value);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
() => {
|
||||
// 用户取消
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
const handleOperateClick2 = (data: IOperateData) => {
|
||||
|
||||
@@ -218,20 +218,14 @@ const saveDict = async () => {
|
||||
if (!dictForm.value) return;
|
||||
|
||||
saving.value = true;
|
||||
try {
|
||||
// dictForm的类型已经是DictItemForm,直接传递
|
||||
await DictAPI.updateDictItem(DICT_CODE, MALE_ITEM_ID, dictForm.value);
|
||||
// dictForm的类型已经是DictItemForm,直接传递
|
||||
await DictAPI.updateDictItem(DICT_CODE, MALE_ITEM_ID, dictForm.value);
|
||||
|
||||
// 更新时间
|
||||
lastUpdateTime.value = useDateFormat(new Date(), "YYYY-MM-DD HH:mm:ss").value;
|
||||
// 更新时间
|
||||
lastUpdateTime.value = useDateFormat(new Date(), "YYYY-MM-DD HH:mm:ss").value;
|
||||
|
||||
ElMessage.success("保存成功,后端将通过WebSocket通知所有客户端");
|
||||
} catch (error) {
|
||||
console.error("保存字典项失败", error);
|
||||
ElMessage.error("保存失败");
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
ElMessage.success("保存成功,后端将通过WebSocket通知所有客户端");
|
||||
saving.value = false;
|
||||
};
|
||||
|
||||
// 组件挂载时加载性别字典
|
||||
|
||||
Reference in New Issue
Block a user