|
|
@@ -362,22 +362,7 @@ export default {
|
|
|
}
|
|
|
const latestRecord = this.communicationRecords[0];
|
|
|
if (latestRecord && latestRecord.customerFocusJson) {
|
|
|
- try {
|
|
|
- // 如果是字符串,尝试解析为 JSON 数组
|
|
|
- if (typeof latestRecord.customerFocusJson === 'string') {
|
|
|
- const parsed = JSON.parse(latestRecord.customerFocusJson);
|
|
|
- // 如果解析后的数组为空,返回默认提示
|
|
|
- if (Array.isArray(parsed) && parsed.length > 0) {
|
|
|
- return parsed;
|
|
|
- }
|
|
|
- }
|
|
|
- // 如果已经是数组且不为空,直接返回
|
|
|
- if (Array.isArray(latestRecord.customerFocusJson) && latestRecord.customerFocusJson.length > 0) {
|
|
|
- return latestRecord.customerFocusJson;
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('解析客户关注点 JSON 失败:', error);
|
|
|
- }
|
|
|
+ return this.normalizeFocusPoints(latestRecord.customerFocusJson);
|
|
|
}
|
|
|
return ['暂无分析数据'];
|
|
|
}
|
|
|
@@ -395,6 +380,54 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ normalizeFocusPoints(value) {
|
|
|
+ if (value === null || value === undefined) return [];
|
|
|
+ if (Array.isArray(value)) {
|
|
|
+ return value.map(v => String(v)).filter(Boolean);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 字符串:可能是 JSON 数组字符串,也可能是普通字符串
|
|
|
+ if (typeof value === 'string') {
|
|
|
+ const raw = value.trim();
|
|
|
+ if (!raw) return [];
|
|
|
+
|
|
|
+ // JSON 数组 / JSON 字符串尝试解析
|
|
|
+ if (
|
|
|
+ (raw.startsWith('[') && raw.endsWith(']')) ||
|
|
|
+ (raw.startsWith('"') && raw.endsWith('"')) ||
|
|
|
+ (raw.startsWith("'") && raw.endsWith("'"))
|
|
|
+ ) {
|
|
|
+ try {
|
|
|
+ const parsed = JSON.parse(raw);
|
|
|
+ if (Array.isArray(parsed)) {
|
|
|
+ return parsed.map(v => String(v)).map(s => s.trim()).filter(Boolean);
|
|
|
+ }
|
|
|
+ if (typeof parsed === 'string') {
|
|
|
+ return this.normalizeFocusPoints(parsed);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ // ignore,走后面的兜底清洗
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 兜底:去掉中括号/引号后按分隔符拆分
|
|
|
+ let cleaned = raw;
|
|
|
+ if (cleaned.startsWith('[') && cleaned.endsWith(']')) {
|
|
|
+ cleaned = cleaned.slice(1, -1);
|
|
|
+ }
|
|
|
+ cleaned = cleaned.replace(/["']/g, '');
|
|
|
+
|
|
|
+ const parts = cleaned
|
|
|
+ .split(/[,,、;;\n]/g)
|
|
|
+ .map(s => s.trim())
|
|
|
+ .filter(Boolean);
|
|
|
+
|
|
|
+ return parts.length ? parts : [cleaned.trim()].filter(Boolean);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其它类型兜底
|
|
|
+ return [String(value)].filter(Boolean);
|
|
|
+ },
|
|
|
initFromParentOrRoute() {
|
|
|
// 优先用父组件传参(抽屉模式)
|
|
|
const idFromParent = this.customerId;
|