CustomersView.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div class="data-page">
  3. <div class="data-header">
  4. <div class="data-title">📋 客户池 - 共{{ customerStats.totalCustomerCount }}家</div>
  5. <div style="display: flex; gap: 8px;">
  6. <button class="btn btn-secondary"><i class="fas fa-download"></i> 导出</button>
  7. <!-- <button class="btn btn-primary" @click="showAddModal = true"><i class="fas fa-plus"></i> 添加客户</button> -->
  8. </div>
  9. </div>
  10. <!-- Stats -->
  11. <div class="stat-row">
  12. <div class="stat-card-lg"> <!-- @click="filterTab = 'all'" -->
  13. <div class="stat-icon-lg blue"><i class="fas fa-users"></i></div>
  14. <div class="stat-content-lg"><h3>{{ customerStats.totalCustomerCount }}</h3><p>总客户数</p></div>
  15. </div>
  16. <div class="stat-card-lg"><!-- @click="filterTab = 'prospect'" -->
  17. <div class="stat-icon-lg purple"><i class="fas fa-user-clock"></i></div>
  18. <div class="stat-content-lg"><h3>{{ customerStats.keyCustomerCount }}</h3><p>重点客户</p></div>
  19. </div>
  20. <div class="stat-card-lg"><!-- @click="filterTab = 'intent'" -->
  21. <div class="stat-icon-lg orange"><i class="fas fa-star"></i></div>
  22. <div class="stat-content-lg"><h3>{{ customerStats.dealCustomerCount }}</h3><p>成交客户</p></div>
  23. </div>
  24. <div class="stat-card-lg"><!-- @click="filterTab = 'deal'" -->
  25. <div class="stat-icon-lg green"><img src="../assets/images/icon-gh.svg" /></div>
  26. <div class="stat-content-lg"><h3>{{ customerStats.publicCustomerCount }}</h3><p>公海客户</p></div>
  27. </div>
  28. <div class="stat-card-lg"><!-- @click="filterTab = 'silent'" -->
  29. <div class="stat-icon-lg" style="background: rgba(148, 163, 184, 0.2); color: var(--text-secondary);"><i class="fas fa-moon"></i></div>
  30. <div class="stat-content-lg"><h3>{{ customerStats.invalidCustomerCount }}</h3><p>无效客户</p></div>
  31. </div>
  32. </div>
  33. <!-- Search & Filter -->
  34. <div style="display: flex; gap: 16px; margin-bottom: 20px;width:100%;" class="filter-customer">
  35. <div class="search-box" style="flex: 1;">
  36. <i class="fas fa-search search-icon"></i>
  37. <input type="text" v-model="searchQuery" class="search-input" placeholder="搜索公司名称、联系人、邮箱..." @change="getCustomerData">
  38. </div>
  39. <div style="flex: 1;display: flex; gap: 16px;width:100%;" >
  40. <div class="form-select">
  41. <el-cascader placeholder="区域名称" :options="region"
  42. v-model="regionValue" clearable filterable @change="getRegion" style="width: 100%;"/>
  43. </div>
  44. <div class="form-select">
  45. <el-select v-model="customerClassify" clearable placeholder="客户分类" @change="getCustomerData()">
  46. <el-option label="公海客户" value="1" />
  47. <el-option label="无效客户" value="2" />
  48. <el-option label="重点客户" value="3" />
  49. <el-option label="成交客户" value="4" />
  50. </el-select>
  51. </div>
  52. </div>
  53. </div>
  54. <div style="display: flex; gap: 16px; margin-bottom: 20px;width:100%;" class="filter-customer">
  55. <div class="form-select">
  56. <el-select v-model="customerParams.customerSourceDictValue" clearable placeholder="客户来源" @change="getCustomerData()">
  57. <el-option label="搜索引擎(例:Google)" value="1" />
  58. <el-option label="公司网站live chat咨询" value="2" />
  59. <el-option label="公司网站留言" value="3" />
  60. <el-option label="sales信箱" value="4" />
  61. <el-option label="德国Embedded展会" value="5" />
  62. <el-option label="CES展会" value="6" />
  63. <el-option label="B2ClT" value="7" />
  64. <el-option label="CEBIT展会" value="8" />
  65. <el-option label="中国制造网" value="9" />
  66. <el-option label="Computex展会" value="10" />
  67. <el-option label="客户介绍" value="11" />
  68. <el-option label="社交媒体(例:Linkedln)" value="12" />
  69. <el-option label="SalesForce" value="13" />
  70. <el-option label="香港电子展" value="14" />
  71. <el-option label="官网注册用户" value="15" />
  72. </el-select>
  73. </div>
  74. <div class="form-select">
  75. <el-select v-model="customerParams.customerStatusDictValue" clearable placeholder="客户状态" @change="getCustomerData()">
  76. <el-option label="暂无需求" value="1" />
  77. <el-option label="潜在客户" value="2" />
  78. <el-option label="意向客户" value="3" />
  79. <el-option label="忠诚客户" value="4" />
  80. <el-option label="了解产品" value="11" />
  81. <el-option label="正在跟进" value="22" />
  82. <el-option label="寄样试用" value="33" />
  83. <el-option label="意向购买" value="44" />
  84. <el-option label="准备付款" value="55" />
  85. <el-option label="暂时搁置" value="66" />
  86. </el-select>
  87. </div>
  88. <div class="form-select">
  89. <el-select v-model="customerParams.customerTypeDictValue" clearable placeholder="客户类型" @change="getCustomerData()">
  90. <el-option label="供应厂商" value="4" />
  91. <el-option label="代理合作" value="5" />
  92. <el-option label="普通客户" value="1" />
  93. <el-option label="友商客户" value="3" />
  94. <el-option label="定制客户" value="2" />
  95. <el-option label="内部客户" value="6" />
  96. <el-option label="客户保护" value="10" />
  97. <el-option label="协助项目" value="11" />
  98. </el-select>
  99. </div>
  100. <div class="form-select">
  101. <el-select v-model="customerParams.customerLevelDictValue" clearable placeholder="客户等级" @change="getCustomerData()">
  102. <el-option label="A级" value="1" />
  103. <el-option label="B级" value="2" />
  104. <el-option label="C级" value="3" />
  105. <el-option label="D级" value="4" />
  106. </el-select>
  107. </div>
  108. <!-- <button class="btn btn-secondary"><i class="fas fa-sliders-h"></i> 高级筛选</button> -->
  109. </div>
  110. <!-- Tabs -->
  111. <div style="display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 12px;">
  112. <div v-for="tab in tabs" :key="tab.key"
  113. :style="{
  114. padding: '8px 16px',
  115. borderRadius: '8px 8px 0 0',
  116. cursor: 'pointer',
  117. fontSize: '13px',
  118. background: filterTab === tab.key ? 'var(--bg-hover)' : 'transparent',
  119. color: filterTab === tab.key ? 'var(--text-primary)' : 'var(--text-secondary)',
  120. fontWeight: filterTab === tab.key ? '600' : '400'
  121. }"
  122. @click="filterTab = tab.key">
  123. {{ tab.label }} <span style="font-size: 11px; opacity: 0.7;">({{ tab.count }})</span>
  124. </div>
  125. </div>
  126. <!-- Customer List -->
  127. <!-- <div style="flex: 1; overflow-y: auto;"> -->
  128. <div v-loading="dataLoading" element-loading-background="rgba(0, 0, 0, 0.8)">
  129. <div v-for="customer in customers" :key="customer.id"
  130. class="customer-card">
  131. <div class="customer-flag">{{ customer.flag }}</div>
  132. <div class="customer-info">
  133. <div class="customer-header">
  134. <span class="customer-name">{{ customer.customerName }}</span>
  135. <!-- 客户类型标识 -->
  136. <!-- <span class="customer-status" :style="{ background: getStatusBg(customer.status), color: getStatusColor(customer.status) }">
  137. {{ getStatusLabel(customer.status) }}
  138. </span> -->
  139. </div>
  140. <div class="customer-contact">
  141. <i class="fas fa-user"></i> {{ customer.liaison?.name }}<span v-if="customer.liaison?.departmentPosition"> · </span>{{ customer.liaison?.departmentPosition }}
  142. </div>
  143. <div class="customer-meta">
  144. <span><i class="fas fa-map-marker-alt"></i> {{ customer.continent }} · {{ customer.country }}</span>
  145. <span><i class="fas fa-industry"></i> {{ customer.customerCompany?.industry }}</span>
  146. <!-- <span><i class="fas fa-dollar-sign"></i> {{ customer.annualPurchase }}</span> -->
  147. </div>
  148. </div>
  149. <!-- <div class="customer-score">
  150. <div class="score-circle" :class="getScoreClass(customer.score)">{{ customer.score }}</div>
  151. <div class="score-label">意向分</div>
  152. </div> -->
  153. <div class="customer-actions" @click.stop>
  154. <button class="btn btn-secondary btn-sm" @click="showCustomerDetail(customer.id)"><i class="fas fa-eye"></i>更多详情</button>
  155. </div>
  156. </div>
  157. </div>
  158. <div class="pagination-area">
  159. <el-pagination
  160. background
  161. :total="customerTotal"
  162. style="text-align: right;"
  163. :current-page="params.pageIndex"
  164. :page-size="params.pageSize"
  165. layout="total, prev, pager, next"
  166. @current-change="pageCurrentChange">
  167. </el-pagination>
  168. </div>
  169. <!-- </div> -->
  170. <!-- 引入添加客户弹窗组件 -->
  171. <!-- <AddCustomerModal
  172. :show-modal="showAddModal"
  173. @close="showAddModal = false"
  174. @add="handleAddCustomer"
  175. /> -->
  176. <!-- Customer Detail Modal -->
  177. <CustomerDetail ref="customerDetailRef" />
  178. <!-- Toast -->
  179. <transition name="toast">
  180. <div v-if="showToast" class="toast" :class="toastType">
  181. <i :class="toastType === 'success' ? 'fas fa-check-circle' : 'fas fa-info-circle'"></i>
  182. {{ toastMessage }}
  183. </div>
  184. </transition>
  185. </div>
  186. </template>
  187. <script setup>
  188. import { ref, computed } from 'vue'
  189. import { getCustomerList,getCustomerStats } from '../api/customer'
  190. import {region} from '@/utils/region';
  191. // 引入添加客户组件
  192. import AddCustomerModal from '../components/addCustomer.vue'
  193. import CustomerDetail from '../components/customerDetail.vue';
  194. const showAddModal = ref(false)
  195. const showDetailModal = ref(false)
  196. const selectedCustomer = ref(null)
  197. const filterTab = ref('all')
  198. const searchQuery = ref('')
  199. const regionFilter = ref('')
  200. const industryFilter = ref('')
  201. const showToast = ref(false)
  202. const toastMessage = ref('')
  203. const toastType = ref('success')
  204. const dataLoading = ref(false)
  205. const aiContentLoading = ref(false)
  206. const formattedText = ref('')
  207. const detailLoading = ref(false)
  208. const customerClassify = ref('')
  209. const customerStats = ref({})
  210. const getStats = ()=>{
  211. getCustomerStats({}).then(res => {
  212. if(res.success){
  213. customerStats.value = res.result
  214. }
  215. })
  216. }
  217. getStats()
  218. const tabs = ref([
  219. { key: 'all', label: '全部客户', count: 0 },
  220. // { key: 'prospect', label: '潜在客户', count: 812 },
  221. // { key: 'intent', label: '意向客户', count: 224 },
  222. // { key: 'deal', label: '成交客户', count: 156 },
  223. // { key: 'silent', label: '沉默客户', count: 55 }
  224. ])
  225. const customers = ref([])
  226. const customerTotal = ref()
  227. const params = ref({
  228. pageIndex: 1,
  229. pageSize: 10,
  230. blurry:null,
  231. country:null,
  232. })
  233. const customerParams = ref({
  234. customerStatusDictValue: '',
  235. customerTypeDictValue: '',
  236. customerLevelDictValue: '',
  237. customerSourceDictValue: ''
  238. })
  239. const getCustomer = (type) => {
  240. let paramsData = {
  241. ...params.value,
  242. ...customerParams.value
  243. }
  244. dataLoading.value= true
  245. paramsData.blurry = searchQuery.value
  246. if(customerClassify.value == 1) {
  247. paramsData.hasPublicCustomer = 1
  248. }else if(customerClassify.value == 2) {
  249. paramsData.hasGarbageCustomer = 1
  250. }else if(customerClassify.value == 3) {
  251. paramsData.hasFollowCustomer = 1
  252. }else if(customerClassify.value == 4) {
  253. paramsData.hasOrderForm = 1
  254. paramsData.hasPublicCustomer = 0
  255. }
  256. getCustomerList(paramsData).then(res => {
  257. dataLoading.value= false
  258. // if(type=='init'){ //页面初始记录客户总数量
  259. // customerStats.value.total = res.result.total
  260. // }
  261. customerTotal.value = tabs.value[0].count = res.result.total
  262. customers.value = res.result.records
  263. })
  264. }
  265. getCustomer('init')
  266. const pageCurrentChange = (page) => {
  267. params.value.pageIndex = page
  268. getCustomer()
  269. }
  270. const getCustomerData = ()=>{
  271. getCustomer()
  272. }
  273. const regionValue = ref([])
  274. const getRegion = (value) => {
  275. params.value.country = value?value[1]:''
  276. getCustomer()
  277. }
  278. const customerDetailId = ref()
  279. const customerDetailRef = ref()
  280. const showCustomerDetail = (id) => {
  281. customerDetailRef.value.open(id)
  282. // aiContentLoading.value = false
  283. // detailLoading.value = true
  284. // showDetailModal.value = true
  285. // customerDetailId.value = id
  286. // getCustomerDetail({id:id}).then(res => {
  287. // detailLoading.value = false
  288. // if(res.success){
  289. // selectedCustomer.value = res.result
  290. // if(selectedCustomer.value.customerAnalysisResult){
  291. // formattedText.value = selectedCustomer.value.customerAnalysisResult.reasonSummary
  292. // }else{
  293. // formattedText.value = ''
  294. // }
  295. // }else{
  296. // ElMessage.warning(res.message)
  297. // }
  298. // })
  299. }
  300. // const customers = ref([
  301. // {
  302. // id: 1, flag: '🇸🇦', name: 'Riyadh Tech Distribution', status: 'prospect', contact: 'Ahmed Al-Rashid',
  303. // role: '采购总监', location: '沙特·利雅得', industry: '固态硬盘进口商', annualPurchase: '年采购$2M+', score: 92,
  304. // email: 'ahmed@riyahtech.sa', phone: '+966 50 123 4567', website: 'www.riyahtech.sa',
  305. // totalDeals: 3, totalAmount: 4560000, lastContact: '3天前',
  306. // aiInsights: [
  307. // { type: 'purchase', level: 'high', icon: 'fas fa-shopping-cart', title: '采购意愿强烈', description: '近30天内访问官网5次,下载产品手册,建议重点跟进' },
  308. // { type: 'timing', level: 'medium', icon: 'fas fa-clock', title: '最佳联系时间', description: '根据历史数据分析,周二上午10点联系成功率最高' },
  309. // { type: 'decision', level: 'high', icon: 'fas fa-user-tie', title: '决策人已识别', description: 'Ahmed Al-Rashid 为采购决策人,已验证邮箱有效性' }
  310. // ],
  311. // interactions: [
  312. // { id: 1, type: 'email', action: '发送报价单', detail: 'SSD采购报价已发送,等待回复', time: '3天前' },
  313. // { id: 2, type: 'visit', action: '官网访问', detail: '浏览了企业级SSD产品页面,停留8分钟', time: '5天前' },
  314. // { id: 3, type: 'call', action: '电话沟通', detail: '确认了采购需求,数量约5000片', time: '1周前' },
  315. // { id: 4, type: 'email', action: '首次联系', detail: '通过LinkedIn找到联系人,发送介绍邮件', time: '2周前' }
  316. // ],
  317. // opportunities: [
  318. // { id: 1, name: 'SSD批量采购', amount: 850000, stage: '谈判中', statusClass: 'negotiation', statusLabel: '跟进中' }
  319. // ]
  320. // },
  321. // {
  322. // id: 2, flag: '🇦🇪', name: 'Dubai Storage Solutions', status: 'prospect', contact: 'Mohammed Khan',
  323. // role: 'CEO', location: '阿联酋·迪拜', industry: '电子分销商', annualPurchase: '年采购$1.5M', score: 88,
  324. // email: 'mohammed@dubaistorage.ae', phone: '+971 50 987 6543', website: 'www.dubaistorage.ae',
  325. // totalDeals: 2, totalAmount: 2800000, lastContact: '1天前',
  326. // aiInsights: [
  327. // { type: 'purchase', level: 'medium', icon: 'fas fa-chart-line', title: '采购潜力', description: '公司规模扩张中,预计明年需求增长30%' }
  328. // ],
  329. // interactions: [
  330. // { id: 1, type: 'meeting', action: '视频会议', detail: '讨论Q2采购计划,对NVMe SSD感兴趣', time: '1天前' }
  331. // ],
  332. // opportunities: []
  333. // },
  334. // {
  335. // id: 3, flag: '🇰🇼', name: 'Kuwait Data Systems', status: 'intent', contact: 'Faisal Al-Mutairi',
  336. // role: 'IT总监', location: '科威特', industry: '数据中心集成商', annualPurchase: '年采购$2.5M', score: 85,
  337. // email: 'faisal@kwdata.kw', phone: '+965 99 888 777', website: 'www.kwdata.kw',
  338. // totalDeals: 5, totalAmount: 6800000, lastContact: '今天',
  339. // aiInsights: [
  340. // { type: 'timing', level: 'high', icon: 'fas fa-fire', title: '紧急需求', description: '数据中心扩容项目急需采购,建议立即跟进' }
  341. // ],
  342. // interactions: [
  343. // { id: 1, type: 'email', action: '回复询价', detail: '确认了技术规格,要求提供样品', time: '今天' }
  344. // ],
  345. // opportunities: [
  346. // { id: 1, name: '数据中心扩容项目', amount: 1200000, stage: '方案报价', statusClass: 'proposal', statusLabel: '待报价' }
  347. // ]
  348. // },
  349. // {
  350. // id: 4, flag: '🇩🇪', name: 'Berlin Tech GmbH', status: 'deal', contact: 'Hans Mueller',
  351. // role: '采购经理', location: '德国·柏林', industry: '企业级存储', annualPurchase: '年采购$3M+', score: 95,
  352. // email: 'hans@berlintech.de', phone: '+49 30 12345678', website: 'www.berlintech.de',
  353. // totalDeals: 8, totalAmount: 12500000, lastContact: '2天前',
  354. // aiInsights: [],
  355. // interactions: [
  356. // { id: 1, type: 'order', action: '订单确认', detail: 'PO-2026-0315 已确认,金额¥680,000', time: '2天前' }
  357. // ],
  358. // opportunities: [
  359. // { id: 1, name: 'NVMe SSD批量采购', amount: 680000, stage: '已成交', statusClass: 'won', statusLabel: '已成交' }
  360. // ]
  361. // }
  362. // ])
  363. // const filteredCustomers = computed(() => {
  364. // let result = customers.value
  365. // if (filterTab.value !== 'all') {
  366. // result = result.filter(c => c.status === filterTab.value)
  367. // }
  368. // if (searchQuery.value) {
  369. // const query = searchQuery.value.toLowerCase()
  370. // result = result.filter(c =>
  371. // c.name.toLowerCase().includes(query) ||
  372. // c.contact.toLowerCase().includes(query) ||
  373. // c.email?.toLowerCase().includes(query)
  374. // )
  375. // }
  376. // return result
  377. // })
  378. const getStatusBg = (status) => ({
  379. prospect: 'rgba(139, 92, 246, 0.2)',
  380. intent: 'rgba(245, 158, 11, 0.2)',
  381. deal: 'rgba(16, 185, 129, 0.2)',
  382. silent: 'rgba(148, 163, 184, 0.2)'
  383. }[status] || 'rgba(148, 163, 184, 0.2)')
  384. const getStatusColor = (status) => ({
  385. prospect: 'var(--secondary)',
  386. intent: 'var(--warning)',
  387. deal: 'var(--success)',
  388. silent: 'var(--text-secondary)'
  389. }[status] || 'var(--text-secondary)')
  390. const getStatusLabel = (status) => ({
  391. prospect: '潜客',
  392. intent: '意向',
  393. deal: '成交',
  394. silent: '沉默'
  395. }[status] || status)
  396. const sendEmail = (customer) => {
  397. showToastMessage(`正在发送邮件给 ${customer.contact}...`, 'success')
  398. }
  399. const createOpportunity = (customer) => {
  400. showDetailModal.value = false
  401. showToastMessage(`正在为 ${customer.name} 创建商机...`, 'success')
  402. }
  403. // 辅助函数:根据国家代码获取国旗
  404. const getFlagByCountry = (countryCode) => {
  405. const flagMap = {
  406. 'SA': '🇸🇦',
  407. 'AE': '🇦🇪',
  408. 'DE': '🇩🇪',
  409. 'FR': '🇫🇷',
  410. '': '🌐'
  411. }
  412. return flagMap[countryCode] || '🌐'
  413. }
  414. // 辅助函数:根据国家代码获取地区
  415. const getLocationByCountry = (countryCode) => {
  416. const locationMap = {
  417. 'SA': '沙特阿拉伯',
  418. 'AE': '阿联酋',
  419. 'DE': '德国',
  420. 'FR': '法国',
  421. '': '未填写'
  422. }
  423. return locationMap[countryCode] || '未填写'
  424. }
  425. const showToastMessage = (message, type = 'success') => {
  426. toastMessage.value = message
  427. toastType.value = type
  428. showToast.value = true
  429. setTimeout(() => showToast.value = false, 3000)
  430. }
  431. // ---------------- 暂时无用 ---------------------
  432. // 处理添加客户逻辑
  433. const handleAddCustomer = (customerData) => {
  434. // 模拟生成客户ID(实际项目中由后端生成)
  435. const newId = customers.value.length + 1
  436. // 构建完整的客户数据(补充默认值)
  437. const newCustomer = {
  438. id: newId,
  439. flag: getFlagByCountry(customerData.country),
  440. name: customerData.name,
  441. status: customerData.type,
  442. contact: customerData.contact,
  443. role: '未填写',
  444. location: getLocationByCountry(customerData.country),
  445. industry: '未填写',
  446. annualPurchase: '未填写',
  447. score: 80,
  448. email: customerData.email || '未填写',
  449. phone: customerData.phone || '未填写',
  450. website: '未填写',
  451. totalDeals: 0,
  452. totalAmount: 0,
  453. lastContact: '刚刚',
  454. aiInsights: [],
  455. interactions: [],
  456. opportunities: []
  457. }
  458. // 添加到客户列表
  459. customers.value.push(newCustomer)
  460. // 更新统计数据
  461. customerStats.total += 1
  462. if (customerData.type === 'prospect') customerStats.prospect += 1
  463. else if (customerData.type === 'intent') customerStats.intent += 1
  464. else if (customerData.type === 'deal') customerStats.deal += 1
  465. // 更新tabs计数
  466. tabs.forEach(tab => {
  467. if (tab.key === 'all') tab.count += 1
  468. else if (tab.key === customerData.type) tab.count += 1
  469. })
  470. // 显示提示
  471. showToastMessage('客户添加成功', 'success')
  472. }
  473. </script>
  474. <style scoped>
  475. @import '../assets/styles/customer.css';
  476. </style>