expansion-test.html 7.14 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>拓客字段测试</title>
  <script src="config.js"></script>
  <script src="auth-utils.js"></script>
  <style>
    body {
      font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
      margin: 20px;
      background: #f5f5f5;
    }
    .container {
      max-width: 600px;
      margin: 0 auto;
      background: white;
      padding: 20px;
      border-radius: 10px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    .form-group {
      margin: 15px 0;
      padding: 15px;
      border: 1px solid #ddd;
      border-radius: 8px;
    }
    .form-group.hidden {
      background: #f9f9f9;
      border-color: #ccc;
    }
    .form-group.hidden label {
      color: #999;
    }
    .form-group.hidden .desc {
      color: #ccc;
    }
    .field-value {
      background: #e8f5e9;
      padding: 8px;
      border-radius: 4px;
      margin-top: 8px;
      font-family: monospace;
      font-size: 12px;
    }
    .btn {
      background: #2196f3;
      color: white;
      border: none;
      padding: 10px 20px;
      border-radius: 5px;
      cursor: pointer;
      margin: 5px;
    }
    .btn:hover {
      background: #1976d2;
    }
    .status {
      margin: 15px 0;
      padding: 15px;
      border-radius: 8px;
      font-family: monospace;
    }
    .status.success {
      background: #e8f5e9;
      border: 1px solid #4caf50;
      color: #2e7d32;
    }
    .status.info {
      background: #e3f2fd;
      border: 1px solid #2196f3;
      color: #1565c0;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>🔍 拓客字段测试页面</h1>
    
    <div class="status info">
      <strong>说明:</strong> 这个页面用于测试拓客时间和拓客人员字段的隐藏状态和默认值设置
    </div>
    
    <div class="form-group hidden">
      <label for="expansionTime">拓客时间</label>
      <div class="desc">负责人创建时间(已隐藏)</div>
      <input type="datetime-local" id="expansionTime" name="expansionTime" required>
      <div class="field-value">当前值: <span id="timeValue">-</span></div>
    </div>
    
    <div class="form-group hidden">
      <label for="expansionStaff">拓客人员</label>
      <div class="desc">负责人添加参与人员(已隐藏)</div>
              <select id="expansionStaff" name="expansionStaff">
          <option value="管理员">管理员</option>
          <option value="张三">张三</option>
          <option value="李四">李四</option>
          <option value="王五">王五</option>
        </select>
      <div class="field-value">当前值: <span id="staffValue">-</span></div>
    </div>
    
    <div class="form-group">
      <label for="customerName">顾客姓名</label>
      <input type="text" id="customerName" name="customerName" placeholder="请输入顾客姓名" required>
    </div>
    
    <div class="form-group">
      <label for="buyCount">购买张数</label>
      <input type="number" id="buyCount" name="buyCount" min="1" value="1" placeholder="请输入购买张数" required>
    </div>
    
    <div class="form-group">
      <button class="btn" onclick="checkFieldValues()">检查字段值</button>
      <button class="btn" onclick="showFormData()">显示表单数据</button>
      <button class="btn" onclick="resetForm()">重置表单</button>
    </div>
    
    <div class="status info" id="result">点击按钮查看结果</div>
  </div>

  <script>
    // 页面加载完成后初始化
    document.addEventListener('DOMContentLoaded', function() {
      // 设置默认时间为当前时间
      const now = new Date();
      const localDateTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
      document.getElementById('expansionTime').value = localDateTime;
      
      // 设置默认拓客人员
      setDefaultExpansionStaff();
      
      console.log('✅ 页面初始化完成');
    });
    
    // 设置默认拓客人员
    function setDefaultExpansionStaff() {
      // 优先从认证工具获取用户信息
      if (window.AUTH_UTILS && window.AUTH_UTILS.getUserInfo()) {
        const userInfo = window.AUTH_UTILS.getUserInfo();
        if (userInfo && userInfo.realname) {
          document.getElementById('expansionStaff').value = userInfo.realname;
          console.log('✅ 已设置默认拓客人员:', userInfo.realname);
          return;
        }
      }
      
      // 如果认证工具不可用,尝试从全局变量获取
      if (window.USER_INFO && window.USER_INFO.realname) {
        document.getElementById('expansionStaff').value = window.USER_INFO.realname;
        console.log('✅ 已设置默认拓客人员:', window.USER_INFO.realname);
        return;
      }
      
      // 如果都没有,使用默认值
      document.getElementById('expansionStaff').value = '管理员';
      console.log('✅ 已设置默认拓客人员: 管理员');
    }
    
    // 检查字段值
    function checkFieldValues() {
      const timeValue = document.getElementById('expansionTime').value;
      const staffValue = document.getElementById('expansionStaff').value;
      const customerName = document.getElementById('customerName').value;
      const buyCount = document.getElementById('buyCount').value;
      
      document.getElementById('timeValue').textContent = timeValue || '未设置';
      document.getElementById('staffValue').textContent = staffValue || '未设置';
      
      const result = document.getElementById('result');
      result.className = 'status success';
      result.innerHTML = `
        <strong>字段值检查结果:</strong><br>
        拓客时间: ${timeValue || '未设置'}<br>
        拓客人员: ${staffValue || '未设置'}<br>
        顾客姓名: ${customerName || '未填写'}<br>
        购买张数: ${buyCount || '未填写'}
      `;
    }
    
    // 显示表单数据
    function showFormData() {
      const formData = {
        expansionTime: document.getElementById('expansionTime').value,
        expansionStaff: document.getElementById('expansionStaff').value,
        customerName: document.getElementById('customerName').value,
        buyCount: document.getElementById('buyCount').value
      };
      
      const result = document.getElementById('result');
      result.className = 'status info';
      result.innerHTML = `
        <strong>表单数据:</strong><br>
        <pre>${JSON.stringify(formData, null, 2)}</pre>
      `;
    }
    
    // 重置表单
    function resetForm() {
      document.getElementById('customerName').value = '';
      document.getElementById('buyCount').value = '1';
      
      // 重新设置默认值
      const now = new Date();
      const localDateTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
      document.getElementById('expansionTime').value = localDateTime;
      
      setDefaultExpansionStaff();
      
      const result = document.getElementById('result');
      result.className = 'status success';
      result.textContent = '✅ 表单已重置,默认值已重新设置';
    }
  </script>
</body>
</html>