| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- /**
- * 检查项目停滞期和改图期数据的验证脚本
- *
- * 使用方法:
- * 1. 在浏览器控制台运行(需要先登录系统)
- * 2. 复制下面的代码到控制台执行
- */
- async function checkProjectStatusFields() {
- console.log('🔍 开始检查项目停滞期和改图期字段...\n');
-
- const Parse = window.Parse;
- if (!Parse) {
- console.error('❌ Parse SDK 未加载!请确保已登录系统。');
- return;
- }
- try {
- // 查询所有项目
- const query = new Parse.Query('Project');
- query.limit(1000); // 最多查询1000个项目
- const projects = await query.find();
-
- console.log(`📊 总项目数: ${projects.length}\n`);
- let stalledCount = 0;
- let modificationCount = 0;
- const stalledProjects = [];
- const modificationProjects = [];
-
- // 遍历所有项目
- projects.forEach(project => {
- const id = project.id;
- const title = project.get('title') || '未命名项目';
- const currentStage = project.get('currentStage') || 'N/A';
- const data = project.get('data') || {};
-
- // 检查停滞期
- if (data.isStalled === true) {
- stalledCount++;
- stalledProjects.push({
- id,
- title,
- currentStage,
- reasonType: data.stagnationReasonType,
- customReason: data.stagnationCustomReason,
- estimatedResumeDate: data.estimatedResumeDate,
- markedAt: data.markedAt,
- markedBy: data.markedBy,
- notes: data.reasonNotes
- });
- }
-
- // 检查改图期
- if (data.isModification === true) {
- modificationCount++;
- modificationProjects.push({
- id,
- title,
- currentStage,
- reasonType: data.modificationReasonType,
- customReason: data.modificationCustomReason,
- markedAt: data.markedAt,
- markedBy: data.markedBy,
- notes: data.reasonNotes
- });
- }
- });
- // 输出统计结果
- console.log('📈 统计结果:');
- console.log(` ⏸️ 停滞期项目: ${stalledCount} 个`);
- console.log(` 🎨 改图期项目: ${modificationCount} 个\n`);
- // 输出停滞期项目详情
- if (stalledCount > 0) {
- console.log('⏸️ 停滞期项目详情:');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- stalledProjects.forEach((p, index) => {
- console.log(`\n${index + 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.estimatedResumeDate) {
- console.log(` 预计恢复: ${new Date(p.estimatedResumeDate).toLocaleDateString()}`);
- }
- if (p.markedBy) {
- console.log(` 标记人: ${p.markedBy}`);
- }
- if (p.markedAt) {
- console.log(` 标记时间: ${new Date(p.markedAt).toLocaleString()}`);
- }
- if (p.notes) {
- console.log(` 备注: ${p.notes}`);
- }
- });
- console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
- }
- // 输出改图期项目详情
- if (modificationCount > 0) {
- console.log('🎨 改图期项目详情:');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- modificationProjects.forEach((p, index) => {
- console.log(`\n${index + 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) {
- console.log(` 标记时间: ${new Date(p.markedAt).toLocaleString()}`);
- }
- if (p.notes) {
- console.log(` 备注: ${p.notes}`);
- }
- });
- console.log('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
- }
- // 检查数据完整性
- console.log('🔬 数据完整性检查:');
- let incompleteCount = 0;
- const allStatusProjects = [...stalledProjects, ...modificationProjects];
-
- allStatusProjects.forEach(p => {
- const issues = [];
- if (!p.reasonType) issues.push('缺少原因类型');
- if (!p.markedBy) issues.push('缺少标记人');
- if (!p.markedAt) issues.push('缺少标记时间');
-
- if (issues.length > 0) {
- incompleteCount++;
- console.log(` ⚠️ ${p.title}: ${issues.join(', ')}`);
- }
- });
-
- if (incompleteCount === 0) {
- console.log(' ✅ 所有标记项目的数据完整\n');
- } else {
- console.log(` ⚠️ 有 ${incompleteCount} 个项目的数据不完整\n`);
- }
- // 返回数据供进一步分析
- return {
- total: projects.length,
- stalledCount,
- modificationCount,
- stalledProjects,
- modificationProjects
- };
- } catch (error) {
- console.error('❌ 检查失败:', error);
- return null;
- }
- }
- // 检查特定项目
- async function checkSingleProject(projectId) {
- console.log(`🔍 检查项目 ID: ${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);
-
- const title = project.get('title') || '未命名项目';
- const currentStage = project.get('currentStage') || 'N/A';
- const stage = project.get('stage') || 'N/A';
- const data = project.get('data') || {};
-
- console.log('📋 项目基本信息:');
- console.log(` 项目名称: ${title}`);
- console.log(` 当前阶段 (currentStage): ${currentStage}`);
- console.log(` 阶段 (stage): ${stage}`);
- console.log(` 停滞期状态: ${data.isStalled === true ? '✅ 是' : '❌ 否'}`);
- console.log(` 改图期状态: ${data.isModification === true ? '✅ 是' : '❌ 否'}\n`);
-
- if (data.isStalled === true) {
- console.log('⏸️ 停滞期详情:');
- console.log(` 原因类型: ${data.stagnationReasonType || 'N/A'}`);
- console.log(` 自定义原因: ${data.stagnationCustomReason || 'N/A'}`);
- console.log(` 预计恢复: ${data.estimatedResumeDate ? new Date(data.estimatedResumeDate).toLocaleDateString() : 'N/A'}`);
- console.log(` 标记人: ${data.markedBy || 'N/A'}`);
- console.log(` 标记时间: ${data.markedAt ? new Date(data.markedAt).toLocaleString() : 'N/A'}`);
- console.log(` 备注: ${data.reasonNotes || 'N/A'}\n`);
- }
-
- if (data.isModification === true) {
- console.log('🎨 改图期详情:');
- console.log(` 原因类型: ${data.modificationReasonType || 'N/A'}`);
- console.log(` 自定义原因: ${data.modificationCustomReason || 'N/A'}`);
- console.log(` 标记人: ${data.markedBy || 'N/A'}`);
- console.log(` 标记时间: ${data.markedAt ? new Date(data.markedAt).toLocaleString() : 'N/A'}`);
- console.log(` 备注: ${data.reasonNotes || 'N/A'}\n`);
- }
-
- console.log('📦 完整 data 字段:');
- console.log(data);
-
- return {
- title,
- currentStage,
- stage,
- isStalled: data.isStalled,
- isModification: data.isModification,
- data
- };
-
- } catch (error) {
- console.error('❌ 查询失败:', error);
- return null;
- }
- }
- // 使用说明
- console.log('📖 使用方法:');
- console.log('1. 检查所有项目: await checkProjectStatusFields()');
- console.log('2. 检查特定项目: await checkSingleProject("项目ID")');
- console.log('\n示例:');
- console.log(' const result = await checkProjectStatusFields();');
- console.log(' await checkSingleProject("abc123def456");');
- console.log('\n开始执行检查...\n');
- // 自动执行检查
- checkProjectStatusFields();
|