|
|
@@ -209,10 +209,19 @@ export default function PadLockManagement({ subMenu }: PadLockManagementProps) {
|
|
|
const savePadLock = async (formData: PadLockVO) => {
|
|
|
try {
|
|
|
if (editingPadLock?.lockId || editingPadLock?.id) {
|
|
|
- await padLockApi.updatePadLock({
|
|
|
+ // 编辑模式下,合并原始数据和表单数据,确保所有必要字段都被传递
|
|
|
+ const updateData: PadLockVO = {
|
|
|
+ // 保留原始数据中的字段(这些字段用户不能编辑但需要传递)
|
|
|
+ ...editingPadLock,
|
|
|
+ // 用表单数据覆盖可编辑字段
|
|
|
...formData,
|
|
|
+ // 确保 id 和 lockId 都存在
|
|
|
+ id: editingPadLock.id || editingPadLock.lockId,
|
|
|
lockId: editingPadLock.lockId || editingPadLock.id,
|
|
|
- });
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log('提交的挂锁数据:', updateData); // 调试用
|
|
|
+ await padLockApi.updatePadLock(updateData);
|
|
|
toast.success('修改成功');
|
|
|
} else {
|
|
|
await padLockApi.addPadLock(formData);
|
|
|
@@ -296,10 +305,19 @@ export default function PadLockManagement({ subMenu }: PadLockManagementProps) {
|
|
|
const saveType = async (formData: PadLockTypeVO) => {
|
|
|
try {
|
|
|
if (editingType?.lockTypeId || editingType?.id) {
|
|
|
- await padLockTypeApi.updatePadLockType({
|
|
|
+ // 编辑模式下,合并原始数据和表单数据,确保所有必要字段都被传递
|
|
|
+ const updateData: PadLockTypeVO = {
|
|
|
+ // 保留原始数据中的字段(这些字段用户不能编辑但需要传递)
|
|
|
+ ...editingType,
|
|
|
+ // 用表单数据覆盖可编辑字段
|
|
|
...formData,
|
|
|
+ // 确保 id 和 lockTypeId 都存在
|
|
|
+ id: editingType.id || editingType.lockTypeId,
|
|
|
lockTypeId: editingType.lockTypeId || editingType.id,
|
|
|
- });
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log('提交的挂锁类型数据:', updateData); // 调试用
|
|
|
+ await padLockTypeApi.updatePadLockType(updateData);
|
|
|
toast.success('修改成功');
|
|
|
} else {
|
|
|
await padLockTypeApi.addPadLockType(formData);
|
|
|
@@ -614,6 +632,17 @@ export default function PadLockManagement({ subMenu }: PadLockManagementProps) {
|
|
|
</div>
|
|
|
</div>
|
|
|
)}
|
|
|
+
|
|
|
+ {/* 挂锁表单弹窗 */}
|
|
|
+ <PadLockFormModal
|
|
|
+ visible={showPadLockForm}
|
|
|
+ editingPadLock={editingPadLock}
|
|
|
+ onCancel={() => {
|
|
|
+ setShowPadLockForm(false);
|
|
|
+ setEditingPadLock(null);
|
|
|
+ }}
|
|
|
+ onSave={savePadLock}
|
|
|
+ />
|
|
|
</>
|
|
|
) : (
|
|
|
<>
|
|
|
@@ -782,10 +811,21 @@ function TypeFormModal({ visible, editingType, parentTypeId, typeList, onCancel,
|
|
|
const values = await form.validateFields();
|
|
|
setFormLoading(true);
|
|
|
|
|
|
- const submitData: PadLockTypeVO = {
|
|
|
+ // 编辑模式下,合并原始数据和表单数据,确保所有必要字段都被传递
|
|
|
+ const submitData: PadLockTypeVO = editingType ? {
|
|
|
+ // 保留原始数据中的字段(这些字段用户不能编辑但需要传递)
|
|
|
+ ...editingType,
|
|
|
+ // 用表单数据覆盖可编辑字段
|
|
|
+ ...values,
|
|
|
+ // 确保 parentTypeId 存在(如果表单中没有,使用原始数据或默认值 0)
|
|
|
+ parentTypeId: values.parentTypeId !== undefined ? (values.parentTypeId || 0) : (editingType.parentTypeId || 0),
|
|
|
+ // 确保 id 和 lockTypeId 都存在
|
|
|
+ id: editingType.id || editingType.lockTypeId,
|
|
|
+ lockTypeId: editingType.lockTypeId || editingType.id,
|
|
|
+ } : {
|
|
|
+ // 新增模式下,只传递表单数据
|
|
|
...values,
|
|
|
parentTypeId: values.parentTypeId || 0,
|
|
|
- lockTypeId: editingType?.lockTypeId || editingType?.id,
|
|
|
};
|
|
|
|
|
|
onSave(submitData);
|
|
|
@@ -809,7 +849,9 @@ function TypeFormModal({ visible, editingType, parentTypeId, typeList, onCancel,
|
|
|
>
|
|
|
<Form
|
|
|
form={form}
|
|
|
- layout="vertical"
|
|
|
+ layout="horizontal"
|
|
|
+ labelCol={{ span: 6 }}
|
|
|
+ wrapperCol={{ span: 18 }}
|
|
|
className="mt-4"
|
|
|
>
|
|
|
{editingType?.parentTypeId !== 0 && (
|
|
|
@@ -968,9 +1010,18 @@ function PadLockFormModal({ visible, editingPadLock, onCancel, onSave }: PadLock
|
|
|
const values = await form.validateFields();
|
|
|
setFormLoading(true);
|
|
|
|
|
|
- const submitData: PadLockVO = {
|
|
|
+ // 编辑模式下,合并原始数据和表单数据,确保所有必要字段都被传递
|
|
|
+ const submitData: PadLockVO = editingPadLock ? {
|
|
|
+ // 保留原始数据中的字段(这些字段用户不能编辑但需要传递)
|
|
|
+ ...editingPadLock,
|
|
|
+ // 用表单数据覆盖可编辑字段
|
|
|
+ ...values,
|
|
|
+ // 确保 id 和 lockId 都存在
|
|
|
+ id: editingPadLock.id || editingPadLock.lockId,
|
|
|
+ lockId: editingPadLock.lockId || editingPadLock.id,
|
|
|
+ } : {
|
|
|
+ // 新增模式下,只传递表单数据
|
|
|
...values,
|
|
|
- lockId: editingPadLock?.lockId || editingPadLock?.id,
|
|
|
};
|
|
|
|
|
|
onSave(submitData);
|
|
|
@@ -994,7 +1045,9 @@ function PadLockFormModal({ visible, editingPadLock, onCancel, onSave }: PadLock
|
|
|
>
|
|
|
<Form
|
|
|
form={form}
|
|
|
- layout="vertical"
|
|
|
+ layout="horizontal"
|
|
|
+ labelCol={{ span: 6 }}
|
|
|
+ wrapperCol={{ span: 18 }}
|
|
|
className="mt-4"
|
|
|
>
|
|
|
<Form.Item
|