| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>检查 Parse 后端数据</title>
- <script src="https://npmcdn.com/parse/dist/parse.min.js"></script>
- <style>
- body {
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
- max-width: 1200px;
- margin: 50px auto;
- padding: 20px;
- background: #f5f5f5;
- }
- .container {
- background: white;
- padding: 30px;
- border-radius: 8px;
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
- }
- h1 {
- color: #333;
- margin-bottom: 30px;
- }
- .input-group {
- margin-bottom: 20px;
- }
- label {
- display: block;
- margin-bottom: 8px;
- font-weight: 600;
- color: #555;
- }
- input {
- width: 100%;
- padding: 12px;
- border: 1px solid #ddd;
- border-radius: 4px;
- font-size: 14px;
- box-sizing: border-box;
- }
- button {
- background: #007bff;
- color: white;
- border: none;
- padding: 12px 24px;
- border-radius: 4px;
- cursor: pointer;
- font-size: 16px;
- margin-right: 10px;
- }
- button:hover {
- background: #0056b3;
- }
- button:disabled {
- background: #ccc;
- cursor: not-allowed;
- }
- .success {
- background: #28a745;
- }
- .success:hover {
- background: #218838;
- }
- .result {
- margin-top: 30px;
- padding: 20px;
- background: #f8f9fa;
- border-radius: 4px;
- border-left: 4px solid #007bff;
- white-space: pre-wrap;
- font-family: 'Courier New', monospace;
- font-size: 13px;
- line-height: 1.6;
- max-height: 600px;
- overflow-y: auto;
- }
- .error {
- border-left-color: #dc3545;
- color: #dc3545;
- }
- .success-msg {
- border-left-color: #28a745;
- color: #28a745;
- }
- .status {
- display: inline-block;
- padding: 4px 12px;
- border-radius: 12px;
- font-size: 12px;
- font-weight: 600;
- margin-left: 10px;
- }
- .status.pending {
- background: #fff3cd;
- color: #856404;
- }
- .status.approved {
- background: #d4edda;
- color: #155724;
- }
- .status.undefined {
- background: #f8d7da;
- color: #721c24;
- }
- .highlight {
- background: #fffacd;
- padding: 2px 6px;
- border-radius: 3px;
- font-weight: 600;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>🔍 检查 Parse 后端项目数据</h1>
-
- <div class="input-group">
- <label>项目 ID:</label>
- <input type="text" id="projectId" placeholder="例如:EyO8xplVhz" value="EyO8xplVhz">
- </div>
-
- <button onclick="checkData()">🔍 查询数据</button>
- <button class="success" onclick="fixData()" id="fixBtn" disabled>🔧 修复数据(设置为 pending)</button>
-
- <div id="result"></div>
- </div>
- <script>
- // 初始化 Parse
- Parse.initialize("YSS_PROJECT");
- Parse.serverURL = 'https://server.fmode.cn/parse';
- let currentProject = null;
- async function checkData() {
- const projectId = document.getElementById('projectId').value.trim();
- const resultDiv = document.getElementById('result');
- const fixBtn = document.getElementById('fixBtn');
-
- if (!projectId) {
- resultDiv.className = 'result error';
- resultDiv.textContent = '❌ 请输入项目 ID';
- return;
- }
- resultDiv.className = 'result';
- resultDiv.textContent = '⏳ 正在查询...';
- fixBtn.disabled = true;
- try {
- const query = new Parse.Query('Project');
- const project = await query.get(projectId);
- currentProject = project;
- const data = project.get('data') || {};
- const currentStage = project.get('currentStage');
- const title = project.get('title');
- const approvalStatus = data.approvalStatus;
- const pendingApprovalBy = data.pendingApprovalBy;
- const approvalHistory = data.approvalHistory || [];
-
- let statusClass = 'undefined';
- if (approvalStatus === 'pending') statusClass = 'pending';
- if (approvalStatus === 'approved') statusClass = 'approved';
- let output = `
- ✅ 查询成功!
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- 📋 项目基本信息:
- 项目 ID: ${projectId}
- 项目名称: ${title || '未设置'}
- 当前阶段: ${currentStage || '未设置'}
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- 🎯 审批状态检查:
- approvalStatus: ${approvalStatus || 'undefined'} ${approvalStatus === 'pending' ? '✅' : '❌'}
- pendingApprovalBy: ${pendingApprovalBy || 'undefined'}
-
- 审批历史记录数: ${approvalHistory.length} 条
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- 📊 完整的 data 字段:
- ${JSON.stringify(data, null, 2)}
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- ${approvalStatus === 'pending'
- ? '✅ 数据正常!approvalStatus 已正确设置为 pending'
- : '❌ 数据异常!approvalStatus 不是 pending,需要修复'}
- `;
- resultDiv.className = approvalStatus === 'pending' ? 'result success-msg' : 'result error';
- resultDiv.textContent = output;
-
- // 如果数据异常,启用修复按钮
- fixBtn.disabled = (approvalStatus === 'pending');
-
- } catch (error) {
- console.error('查询失败:', error);
- resultDiv.className = 'result error';
- resultDiv.textContent = `❌ 查询失败:\n\n${error.message}\n\n${error.stack}`;
- currentProject = null;
- fixBtn.disabled = true;
- }
- }
- async function fixData() {
- if (!currentProject) {
- alert('请先查询项目数据');
- return;
- }
- const resultDiv = document.getElementById('result');
- const fixBtn = document.getElementById('fixBtn');
- if (!confirm('确定要将此项目的 approvalStatus 设置为 pending 吗?')) {
- return;
- }
- resultDiv.className = 'result';
- resultDiv.textContent = '⏳ 正在修复数据...';
- fixBtn.disabled = true;
- try {
- const data = currentProject.get('data') || {};
-
- // 设置审批状态
- data.approvalStatus = 'pending';
- data.pendingApprovalBy = 'team-leader';
-
- // 确保 currentStage 是"订单分配"
- currentProject.set('currentStage', '订单分配');
- currentProject.set('data', data);
- console.log('🔧 准备保存修复后的数据:', {
- projectId: currentProject.id,
- currentStage: currentProject.get('currentStage'),
- approvalStatus: data.approvalStatus,
- pendingApprovalBy: data.pendingApprovalBy
- });
- await currentProject.save();
- // 验证保存
- const verifyQuery = new Parse.Query('Project');
- const savedProject = await verifyQuery.get(currentProject.id);
- const savedData = savedProject.get('data') || {};
- let output = `
- ✅ 修复成功!
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- 已更新的字段:
- currentStage: ${savedProject.get('currentStage')}
- approvalStatus: ${savedData.approvalStatus}
- pendingApprovalBy: ${savedData.pendingApprovalBy}
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- 验证结果:
- ${savedData.approvalStatus === 'pending' ? '✅ approvalStatus 已正确设置为 pending' : '❌ 修复失败,approvalStatus 仍不是 pending'}
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- 请刷新组长端页面查看效果!
- `;
- resultDiv.className = 'result success-msg';
- resultDiv.textContent = output;
-
- fixBtn.disabled = true;
- } catch (error) {
- console.error('修复失败:', error);
- resultDiv.className = 'result error';
- resultDiv.textContent = `❌ 修复失败:\n\n${error.message}\n\n${error.stack}`;
- }
- }
- // 页面加载时自动查询
- window.onload = () => {
- const projectId = document.getElementById('projectId').value;
- if (projectId) {
- checkData();
- }
- };
- </script>
- </body>
- </html>
|