| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- /**
- * 组长端路由跳转调试脚本
- *
- * 使用方法:
- * 1. 在组长端 Dashboard 页面打开浏览器控制台(F12)
- * 2. 复制并粘贴此脚本到控制台执行
- * 3. 查看诊断结果
- */
- console.log('🔍 开始诊断组长端路由跳转问题...\n');
- // 1. 检查 localStorage 标记
- console.log('📦 检查 localStorage 标记:');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- const enterAsTeamLeader = localStorage.getItem('enterAsTeamLeader');
- const teamLeaderMode = localStorage.getItem('teamLeaderMode');
- const enterFromCustomerService = localStorage.getItem('enterFromCustomerService');
- const customerServiceMode = localStorage.getItem('customerServiceMode');
- const company = localStorage.getItem('company');
- console.log(` enterAsTeamLeader: ${enterAsTeamLeader || '❌ 未设置'}`);
- console.log(` teamLeaderMode: ${teamLeaderMode || '❌ 未设置'}`);
- console.log(` enterFromCustomerService: ${enterFromCustomerService || '✅ 未设置(正常)'}`);
- console.log(` customerServiceMode: ${customerServiceMode || '✅ 未设置(正常)'}`);
- console.log(` company (cid): ${company || '❌ 未设置'}\n`);
- // 2. 检查诊断结果
- let hasIssues = false;
- const issues = [];
- const recommendations = [];
- if (!teamLeaderMode && !enterAsTeamLeader) {
- hasIssues = true;
- issues.push('❌ 缺少组长模式标记(teamLeaderMode 和 enterAsTeamLeader)');
- recommendations.push('运行修复命令:fixTeamLeaderMode()');
- }
- if (!company) {
- hasIssues = true;
- issues.push('❌ 缺少公司ID(company)');
- recommendations.push('手动设置:localStorage.setItem("company", "cDL6R1hgSi")');
- }
- if (enterFromCustomerService === '1' || customerServiceMode === 'true') {
- hasIssues = true;
- issues.push('⚠️ 检测到客服模式标记,可能与组长模式冲突');
- recommendations.push('运行清理命令:cleanCustomerServiceMode()');
- }
- // 3. 输出诊断结果
- console.log('🏥 诊断结果:');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- if (!hasIssues) {
- console.log(' ✅ 所有标记正常,路由跳转应该可以正常工作\n');
- } else {
- console.log(' 发现以下问题:');
- issues.forEach((issue, i) => {
- console.log(` ${i + 1}. ${issue}`);
- });
- console.log('\n 🔧 建议修复:');
- recommendations.forEach((rec, i) => {
- console.log(` ${i + 1}. ${rec}`);
- });
- console.log('');
- }
- // 4. 检查当前路径
- console.log('🌐 当前环境信息:');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- console.log(` 当前URL: ${window.location.href}`);
- console.log(` 路径: ${window.location.pathname}`);
- console.log(` Referrer: ${document.referrer || '无'}\n`);
- // 5. 检查项目数据
- console.log('📊 检查项目数据(如果可用):');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- if (typeof window.Parse !== 'undefined') {
- console.log(' ✅ Parse SDK 已加载');
-
- // 检查停滞期/改图期项目
- const checkProjectStatus = async () => {
- try {
- const query = new window.Parse.Query('Project');
- query.limit(100);
- const projects = await query.find();
-
- let stalledCount = 0;
- let modificationCount = 0;
-
- projects.forEach(p => {
- const data = p.get('data') || {};
- if (data.isStalled === true) stalledCount++;
- if (data.isModification === true) modificationCount++;
- });
-
- console.log(` 总项目数: ${projects.length}`);
- console.log(` 停滞期项目: ${stalledCount} 个`);
- console.log(` 改图期项目: ${modificationCount} 个\n`);
- } catch (e) {
- console.error(' ❌ 检查项目数据失败:', e);
- }
- };
-
- checkProjectStatus();
- } else {
- console.log(' ⚠️ Parse SDK 未加载,跳过项目数据检查\n');
- }
- // 6. 提供修复函数
- console.log('🛠️ 可用的修复函数:');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- console.log(' 1. fixTeamLeaderMode() - 修复组长模式标记');
- console.log(' 2. cleanCustomerServiceMode() - 清除客服模式标记');
- console.log(' 3. resetAllMode() - 重置所有模式标记');
- console.log(' 4. testNavigation(projectId) - 测试跳转到指定项目\n');
- // 修复函数定义
- window.fixTeamLeaderMode = function() {
- console.log('🔧 正在修复组长模式标记...');
- try {
- localStorage.setItem('teamLeaderMode', 'true');
- localStorage.setItem('enterAsTeamLeader', '1');
- console.log('✅ 组长模式标记已设置');
- console.log(' teamLeaderMode: true');
- console.log(' enterAsTeamLeader: 1');
- console.log('\n💡 请重新点击"查看详情"按钮测试');
- } catch (e) {
- console.error('❌ 设置失败:', e);
- }
- };
- window.cleanCustomerServiceMode = function() {
- console.log('🧹 正在清除客服模式标记...');
- try {
- localStorage.removeItem('enterFromCustomerService');
- localStorage.removeItem('customerServiceMode');
- console.log('✅ 客服模式标记已清除');
- console.log('\n💡 请运行 fixTeamLeaderMode() 重新设置组长模式');
- } catch (e) {
- console.error('❌ 清除失败:', e);
- }
- };
- window.resetAllMode = function() {
- console.log('🔄 正在重置所有模式标记...');
- try {
- // 清除所有模式
- localStorage.removeItem('enterAsTeamLeader');
- localStorage.removeItem('teamLeaderMode');
- localStorage.removeItem('enterFromCustomerService');
- localStorage.removeItem('customerServiceMode');
-
- // 重新设置组长模式
- localStorage.setItem('teamLeaderMode', 'true');
- localStorage.setItem('enterAsTeamLeader', '1');
-
- console.log('✅ 已重置并设置为组长模式');
- console.log('\n💡 请刷新页面或重新点击"查看详情"按钮');
- } catch (e) {
- console.error('❌ 重置失败:', e);
- }
- };
- window.testNavigation = function(projectId) {
- if (!projectId) {
- console.error('❌ 请提供项目ID');
- console.log('用法: testNavigation("项目ID")');
- return;
- }
-
- console.log(`🧪 测试跳转到项目: ${projectId}`);
-
- // 确保标记已设置
- localStorage.setItem('teamLeaderMode', 'true');
- localStorage.setItem('enterAsTeamLeader', '1');
-
- const cid = localStorage.getItem('company') || 'cDL6R1hgSi';
- const url = `/wxwork/${cid}/project/${projectId}/delivery`;
-
- console.log(`📍 目标URL: ${url}`);
- console.log('⏳ 正在跳转...');
-
- window.location.href = url;
- };
- // 7. 监听 localStorage 变化
- if (typeof window.addEventListener !== 'undefined') {
- let storageListener = function(e) {
- if (e.key === 'teamLeaderMode' || e.key === 'enterAsTeamLeader') {
- console.log(`📢 localStorage 变化: ${e.key} = ${e.newValue}`);
- }
- };
-
- // 只添加一次监听器
- if (!window._debugStorageListenerAdded) {
- window.addEventListener('storage', storageListener);
- window._debugStorageListenerAdded = true;
- console.log('👂 已启动 localStorage 变化监听\n');
- }
- }
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
- console.log('📝 诊断完成!');
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
- if (hasIssues) {
- console.log('💡 快速修复:复制以下命令到控制台执行\n');
- console.log('fixTeamLeaderMode();\n');
- }
|