// 图片上传控件 – 上传成功后 V8 事件
// 调试版:查看数据结构
const fieldName = ‘YongpinTP’;
console.log(‘========================================’);
console.log(‘ 上传成功后 – 调试信息’);
console.log(‘========================================’);
// 1. 查看字段值
console.log(‘1. V8.Form.’ + fieldName + ‘:’);
const fieldValue = V8.Form[fieldName];
console.log(‘ 原始值:’, fieldValue);
console.log(‘ 类型:’, typeof fieldValue);
// 2. 如果是字符串,尝试解析
if (typeof fieldValue === ‘string’) {
try {
const parsed = JSON.parse(fieldValue);
console.log(‘ 解析后:’, parsed);
console.log(‘ 解析后类型:’, Array.isArray(parsed) ? ‘数组’ : ‘object’);
} catch (e) {
console.log(‘ 解析失败:’, e.message);
}
}
// 3. 如果是数组,遍历每一项
if (Array.isArray(fieldValue)) {
console.log(‘ 数组长度:’, fieldValue.length);
fieldValue.forEach((item, index) => {
console.log(` [${index}]:`, item);
console.log(` Id: ${item.Id}`);
console.log(` State: ${item.State}`);
console.log(` Name: ${item.Name}`);
console.log(` Path: ${item.Path}`);
});
}
// 4. 查看 V8.Form 中所有相关键
console.log(‘2. V8.Form 中包含 “‘ + fieldName + ‘” 的键:’);
const relatedKeys = Object.keys(V8.Form).filter(key => key.includes(fieldName));
console.log(‘ 相关键:’, relatedKeys);
relatedKeys.forEach(key => {
console.log(` ${key}:`, V8.Form[key]);
});
// 5. 查看是否有 State === 0 的图片
if (Array.isArray(fieldValue)) {
const state0Items = fieldValue.filter(item => item.State === 0);
const state1Items = fieldValue.filter(item => item.State === 1);
console.log(‘3. State 统计:’);
console.log(‘ State = 0 (待上传/原图):’, state0Items.length);
console.log(‘ State = 1 (已上传):’, state1Items.length);
}
// 6. 查看 V8.ThisValue(当前上传的文件信息)
console.log(‘4. V8.ThisValue:’);
if (V8.ThisValue) {
console.log(‘ name:’, V8.ThisValue.name);
console.log(‘ uid:’, V8.ThisValue.uid);
console.log(‘ size:’, V8.ThisValue.size);
}
console.log(‘========================================’);
console.log(‘ 调试信息打印完成’);
console.log(‘========================================’);
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END




