76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
|
||
|
|
with open('TenantListView.vue', 'r', encoding='utf-8') as f:
|
||
|
|
content = f.read()
|
||
|
|
|
||
|
|
# 找到 handleModalOk 函数中的 catch 块并修改
|
||
|
|
old_catch = ''' } catch (error: any) {
|
||
|
|
message.error(error.response?.data?.message || '操作失败');
|
||
|
|
} finally {
|
||
|
|
modalLoading.value = false;
|
||
|
|
}
|
||
|
|
};'''
|
||
|
|
|
||
|
|
new_catch = ''' } catch (error: any) {
|
||
|
|
// 处理错误码 3102 - 套餐下有排课计划
|
||
|
|
if (error.response?.data?.code === 3102) {
|
||
|
|
const warnings = error.response.data.data as Array<{
|
||
|
|
collectionId: number;
|
||
|
|
collectionName: string;
|
||
|
|
scheduleCount: number;
|
||
|
|
}>;
|
||
|
|
// 保存当前表单数据
|
||
|
|
pendingFormData.value = {
|
||
|
|
...formData,
|
||
|
|
startDate,
|
||
|
|
expireDate,
|
||
|
|
};
|
||
|
|
// 显示强制移除确认弹窗
|
||
|
|
forceRemoveWarnings.value = warnings;
|
||
|
|
forceRemoveModalVisible.value = true;
|
||
|
|
modalLoading.value = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
message.error(error.response?.data?.message || '操作失败');
|
||
|
|
} finally {
|
||
|
|
modalLoading.value = false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
// 强制移除确认弹窗 - 确认
|
||
|
|
const handleForceRemoveConfirm = async () => {
|
||
|
|
if (!pendingFormData.value || !editingId.value) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
modalLoading.value = true;
|
||
|
|
try {
|
||
|
|
// 传递 forceRemove: true 重新调用更新接口
|
||
|
|
await updateTenant(editingId.value, { ...pendingFormData.value, forceRemove: true } as UpdateTenantDto);
|
||
|
|
message.success('更新成功');
|
||
|
|
modalVisible.value = false;
|
||
|
|
forceRemoveModalVisible.value = false;
|
||
|
|
pendingFormData.value = null;
|
||
|
|
loadData();
|
||
|
|
} catch (error: any) {
|
||
|
|
message.error(error.response?.data?.message || '操作失败');
|
||
|
|
} finally {
|
||
|
|
modalLoading.value = false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
// 强制移除确认弹窗 - 取消
|
||
|
|
const handleForceRemoveCancel = () => {
|
||
|
|
forceRemoveModalVisible.value = false;
|
||
|
|
pendingFormData.value = null;
|
||
|
|
forceRemoveWarnings.value = [];
|
||
|
|
};'''
|
||
|
|
|
||
|
|
content = content.replace(old_catch, new_catch)
|
||
|
|
|
||
|
|
with open('TenantListView.vue', 'w', encoding='utf-8') as f:
|
||
|
|
f.write(content)
|
||
|
|
|
||
|
|
print('修改成功')
|