expansion-test.html
7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<!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>