"use client" import { useState } from "react" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Switch } from "@/components/ui/switch" import { Badge } from "@/components/ui/badge" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { ArrowRight, Plus, Save, Trash2, HelpCircle } from "lucide-react" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" interface FieldMapping { id: string sourceField: string targetField: string dataType: string required: boolean transformation: string primaryKey: boolean } export function DataFieldMapping() { // 模拟数据 const [mappings, setMappings] = useState([ { id: "1", sourceField: "user_id", targetField: "userId", dataType: "string", required: true, transformation: "none", primaryKey: true, }, { id: "2", sourceField: "phone", targetField: "phoneNumber", dataType: "string", required: true, transformation: "formatPhoneNumber", primaryKey: false, }, { id: "3", sourceField: "id_card", targetField: "identityNumber", dataType: "string", required: true, transformation: "mask", primaryKey: false, }, { id: "4", sourceField: "imei", targetField: "deviceImei", dataType: "string", required: false, transformation: "none", primaryKey: false, }, { id: "5", sourceField: "name", targetField: "fullName", dataType: "string", required: true, transformation: "none", primaryKey: false, }, { id: "6", sourceField: "register_time", targetField: "registrationDate", dataType: "datetime", required: true, transformation: "parseDateTime", primaryKey: false, }, { id: "7", sourceField: "last_login", targetField: "lastActiveTime", dataType: "datetime", required: false, transformation: "parseDateTime", primaryKey: false, }, ]) const addNewMapping = () => { const newMapping: FieldMapping = { id: `new-${Date.now()}`, sourceField: "", targetField: "", dataType: "string", required: false, transformation: "none", primaryKey: false, } setMappings([...mappings, newMapping]) } const updateMapping = (id: string, field: keyof FieldMapping, value: any) => { setMappings(mappings.map((mapping) => (mapping.id === id ? { ...mapping, [field]: value } : mapping))) } const deleteMapping = (id: string) => { setMappings(mappings.filter((mapping) => mapping.id !== id)) } return (
数据字段映射 配置源数据字段与目标数据字段的映射关系,以ID、手机号、身份证号和IMEI设备号为标准整合客户数据
标准字段映射

标准字段映射用于将不同数据源的字段映射到统一的标准字段,以便于数据整合和分析。 主键字段用于唯一标识用户,通常为用户ID、手机号、身份证号或IMEI设备号。

源字段 目标字段 数据类型 必填 主键 转换方式 操作 {mappings.map((mapping) => ( updateMapping(mapping.id, "sourceField", e.target.value)} placeholder="源字段名" /> updateMapping(mapping.id, "targetField", e.target.value)} placeholder="目标字段名" />
updateMapping(mapping.id, "required", checked)} />
updateMapping(mapping.id, "primaryKey", checked)} />
))}
标准字段说明 用户数据标准字段的说明和用途 字段名 数据类型 说明 用途 userId 字符串 用户唯一标识符 用于唯一标识用户,主键字段 phoneNumber 字符串 用户手机号码 用于用户联系和身份验证,可作为主键 identityNumber 字符串 用户身份证号码 用于用户实名认证,可作为主键 deviceImei 字符串 设备IMEI号码 用于设备识别,可作为主键 fullName 字符串 用户姓名 用于用户基本信息 registrationDate 日期时间 用户注册时间 用于用户生命周期分析 lastActiveTime 日期时间 用户最后活跃时间 用于用户活跃度分析
) }