| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- /**
- * 验证停滞期/改图期数据是否正确保存到数据库
- *
- * 使用方法:
- * 1. 在浏览器控制台(F12)
- * 2. 复制并粘贴此脚本执行
- */
- async function verifyStagnationData() {
- console.log('🔍 开始验证停滞期/改图期数据保存情况...\n');
-
- // 检查 Parse SDK
- const Parse = window.Parse;
- if (!Parse) {
- console.error('❌ Parse SDK 未加载!');
- console.log('💡 可能原因:');
- console.log(' 1. 页面还未完全加载');
- console.log(' 2. Parse SDK 导入有问题');
- console.log('\n请等待页面完全加载后再试,或刷新页面');
- return;
- }
-
- console.log('✅ Parse SDK 已加载\n');
-
- try {
- // 查询所有项目
- const query = new Parse.Query('Project');
- query.limit(1000);
- const projects = await query.find();
-
- console.log(`📊 数据库中共有 ${projects.length} 个项目\n`);
-
- // 统计停滞期和改图期项目
- const stalledProjects = [];
- const modificationProjects = [];
-
- projects.forEach(p => {
- const data = p.get('data') || {};
-
- if (data.isStalled === true) {
- stalledProjects.push({
- id: p.id,
- title: p.get('title') || '未命名',
- currentStage: p.get('currentStage'),
- reasonType: data.stagnationReasonType,
- customReason: data.stagnationCustomReason,
- markedBy: data.markedBy,
- markedAt: data.markedAt
- });
- }
-
- if (data.isModification === true) {
- modificationProjects.push({
- id: p.id,
- title: p.get('title') || '未命名',
- currentStage: p.get('currentStage'),
- reasonType: data.modificationReasonType,
- customReason: data.modificationCustomReason,
- markedBy: data.markedBy,
- markedAt: data.markedAt
- });
- }
- });
-
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- console.log('📈 统计结果:');
- console.log(` ⏸️ 停滞期项目: ${stalledProjects.length} 个`);
- console.log(` ✏️ 改图期项目: ${modificationProjects.length} 个`);
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
-
- // 显示停滞期项目详情
- if (stalledProjects.length > 0) {
- console.log('⏸️ 停滞期项目详情:');
- stalledProjects.forEach((p, i) => {
- console.log(`\n${i + 1}. 📋 ${p.title}`);
- console.log(` ID: ${p.id}`);
- console.log(` 当前阶段: ${p.currentStage}`);
- console.log(` 原因类型: ${p.reasonType || 'N/A'}`);
- if (p.customReason) {
- console.log(` 自定义原因: ${p.customReason}`);
- }
- if (p.markedBy) {
- console.log(` 标记人: ${p.markedBy}`);
- }
- if (p.markedAt) {
- const date = new Date(p.markedAt);
- console.log(` 标记时间: ${date.toLocaleString('zh-CN')}`);
- }
- });
- console.log('');
- } else {
- console.log('ℹ️ 数据库中没有停滞期项目\n');
- }
-
- // 显示改图期项目详情
- if (modificationProjects.length > 0) {
- console.log('✏️ 改图期项目详情:');
- modificationProjects.forEach((p, i) => {
- console.log(`\n${i + 1}. 📋 ${p.title}`);
- console.log(` ID: ${p.id}`);
- console.log(` 当前阶段: ${p.currentStage}`);
- console.log(` 原因类型: ${p.reasonType || 'N/A'}`);
- if (p.customReason) {
- console.log(` 自定义原因: ${p.customReason}`);
- }
- if (p.markedBy) {
- console.log(` 标记人: ${p.markedBy}`);
- }
- if (p.markedAt) {
- const date = new Date(p.markedAt);
- console.log(` 标记时间: ${date.toLocaleString('zh-CN')}`);
- }
- });
- console.log('');
- } else {
- console.log('ℹ️ 数据库中没有改图期项目\n');
- }
-
- // 对比内存中的数据
- const dashboard = document.querySelector('app-dashboard');
- if (dashboard) {
- const component = window.ng?.getComponent?.(dashboard);
- if (component && component.projects) {
- const memoryStalled = component.projects.filter(p => p.isStalled === true);
- const memoryModification = component.projects.filter(p => p.isModification === true);
-
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- console.log('🔄 内存 vs 数据库对比:');
- console.log(` 内存中停滞期: ${memoryStalled.length} 个`);
- console.log(` 数据库中停滞期: ${stalledProjects.length} 个`);
- console.log(` 内存中改图期: ${memoryModification.length} 个`);
- console.log(` 数据库中改图期: ${modificationProjects.length} 个`);
-
- if (memoryStalled.length !== stalledProjects.length) {
- console.warn('\n⚠️ 警告:内存和数据库中的停滞期项目数量不一致!');
- console.log(' 建议:刷新页面重新加载数据');
- }
- if (memoryModification.length !== modificationProjects.length) {
- console.warn('\n⚠️ 警告:内存和数据库中的改图期项目数量不一致!');
- console.log(' 建议:刷新页面重新加载数据');
- }
-
- if (memoryStalled.length === stalledProjects.length &&
- memoryModification.length === modificationProjects.length) {
- console.log('\n✅ 内存和数据库数据一致');
- }
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
- }
- }
-
- // 返回结果
- return {
- success: true,
- database: {
- stalled: stalledProjects.length,
- modification: modificationProjects.length
- },
- projects: {
- stalledProjects,
- modificationProjects
- }
- };
-
- } catch (error) {
- console.error('❌ 验证失败:', error);
- console.log('\n💡 可能的原因:');
- console.log(' 1. 网络连接问题');
- console.log(' 2. Parse 服务器无响应');
- console.log(' 3. 权限不足');
- return { success: false, error };
- }
- }
- // 检查特定项目
- async function checkProjectById(projectId) {
- if (!projectId) {
- console.error('❌ 请提供项目ID');
- console.log('用法: checkProjectById("项目ID")');
- return;
- }
-
- console.log(`🔍 查询项目: ${projectId}\n`);
-
- const Parse = window.Parse;
- if (!Parse) {
- console.error('❌ Parse SDK 未加载!');
- return;
- }
-
- try {
- const query = new Parse.Query('Project');
- const project = await query.get(projectId);
-
- if (!project) {
- console.error('❌ 未找到项目');
- return;
- }
-
- const title = project.get('title') || '未命名';
- const currentStage = project.get('currentStage');
- const data = project.get('data') || {};
-
- console.log('📋 项目信息:');
- console.log(` 名称: ${title}`);
- console.log(` 当前阶段: ${currentStage}`);
- console.log(` 停滞期: ${data.isStalled === true ? '✅ 是' : '❌ 否'}`);
- console.log(` 改图期: ${data.isModification === true ? '✅ 是' : '❌ 否'}\n`);
-
- if (data.isStalled === true) {
- console.log('⏸️ 停滞期详情:');
- console.log(` 原因类型: ${data.stagnationReasonType || 'N/A'}`);
- if (data.stagnationCustomReason) {
- console.log(` 自定义原因: ${data.stagnationCustomReason}`);
- }
- if (data.estimatedResumeDate) {
- console.log(` 预计恢复: ${new Date(data.estimatedResumeDate).toLocaleDateString('zh-CN')}`);
- }
- if (data.reasonNotes) {
- console.log(` 备注: ${data.reasonNotes}`);
- }
- if (data.markedBy) {
- console.log(` 标记人: ${data.markedBy}`);
- }
- if (data.markedAt) {
- console.log(` 标记时间: ${new Date(data.markedAt).toLocaleString('zh-CN')}`);
- }
- console.log('');
- }
-
- if (data.isModification === true) {
- console.log('✏️ 改图期详情:');
- console.log(` 原因类型: ${data.modificationReasonType || 'N/A'}`);
- if (data.modificationCustomReason) {
- console.log(` 自定义原因: ${data.modificationCustomReason}`);
- }
- if (data.reasonNotes) {
- console.log(` 备注: ${data.reasonNotes}`);
- }
- if (data.markedBy) {
- console.log(` 标记人: ${data.markedBy}`);
- }
- if (data.markedAt) {
- console.log(` 标记时间: ${new Date(data.markedAt).toLocaleString('zh-CN')}`);
- }
- console.log('');
- }
-
- console.log('📦 完整 data 字段:');
- console.log(data);
-
- return { title, currentStage, data };
-
- } catch (error) {
- console.error('❌ 查询失败:', error);
- return null;
- }
- }
- // 使用说明
- console.log('📖 验证脚本已加载!');
- console.log('');
- console.log('可用命令:');
- console.log(' verifyStagnationData() - 验证所有停滞期/改图期数据');
- console.log(' checkProjectById("项目ID") - 检查特定项目');
- console.log('');
- console.log('示例:');
- console.log(' await verifyStagnationData();');
- console.log(' await checkProjectById("abc123def456");');
- console.log('');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- console.log('');
- // 自动执行验证
- console.log('⏳ 自动执行验证...\n');
- verifyStagnationData();
|