dev_1.0.1
tangjie 2026-07-09 09:52:04 +08:00
parent f3d9291fdb
commit a495eb3f83
1 changed files with 7 additions and 3 deletions

View File

@ -119,7 +119,7 @@ function DepartmentPositionPage(props) {
const tree = res?.data || []; const tree = res?.data || [];
setTreeData(tree); setTreeData(tree);
if (tree.length) { if (tree.length) {
setSelectedDept(toSelectedDept(tree[0])); setSelectedDept(tree[0]);
} }
} catch (err) { } catch (err) {
console.warn("[DepartmentPosition] loadTree failed:", err); console.warn("[DepartmentPosition] loadTree failed:", err);
@ -281,7 +281,7 @@ function DepartmentPositionPage(props) {
treeData={filteredTree} treeData={filteredTree}
fieldNames={{ title: "deptName", key: "id", children: "children" }} fieldNames={{ title: "deptName", key: "id", children: "children" }}
onSelect={(_, { node }) => { onSelect={(_, { node }) => {
setSelectedDept(toSelectedDept(node)); setSelectedDept(node);
}} }}
/> />
</div> </div>
@ -383,6 +383,7 @@ function DepartmentPositionPage(props) {
{deptModalOpen && ( {deptModalOpen && (
<DeptFormModal <DeptFormModal
open={deptModalOpen} open={deptModalOpen}
selectedDept={selectedDept}
currentId={currentId} currentId={currentId}
selectedDeptId={selectedDept?.id} selectedDeptId={selectedDept?.id}
staffOptions={staffOptions} staffOptions={staffOptions}
@ -462,6 +463,7 @@ function DeptFormModal({
currentId, currentId,
staffOptions, staffOptions,
treeData, treeData,
selectedDept,
requestAdd, requestAdd,
requestEdit, requestEdit,
requestDetails, requestDetails,
@ -528,10 +530,12 @@ function DeptFormModal({
}; };
const handleSubmit = async (values) => { const handleSubmit = async (values) => {
try { try {
setSubmitting(true); setSubmitting(true);
const request = currentId ? requestEdit : requestAdd; const request = currentId ? requestEdit : requestAdd;
const payload = { ...values }; const payload = {...selectedDept, ...values };
delete payload.children;
if (currentId) { if (currentId) {
payload.id = currentId; payload.id = currentId;
} }