From a49460571c56e5c16bf91ef15c5215e4e6a117e8 Mon Sep 17 00:00:00 2001 From: Ycc Date: Thu, 10 Apr 2025 15:54:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E8=BF=90=E8=90=A5=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/DesktopApp.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/DesktopApp.jsx b/src/views/DesktopApp.jsx index a94568b..1d91cb1 100644 --- a/src/views/DesktopApp.jsx +++ b/src/views/DesktopApp.jsx @@ -177,6 +177,10 @@ function DesktopApp() { key: '/chat/history', label: 聊天记录, }, + { + key: '/customer_relation', + label: 客户运营, + }, ]} /> From f999855166b3f21af333d07209d14830fd862ba7 Mon Sep 17 00:00:00 2001 From: Ycc Date: Sat, 12 Apr 2025 13:30:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=AE=A2=E8=BF=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.js | 1 + src/main.jsx | 3 + src/stores/AuthStore.js | 3 +- src/stores/CustomerRelationStore.js | 41 +++++++ .../Conversations/History/SearchForm.jsx | 1 + src/views/DesktopApp.jsx | 4 +- src/views/customer_relation/index.jsx | 108 ++++++++++++++++++ 7 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 src/stores/CustomerRelationStore.js create mode 100644 src/views/customer_relation/index.jsx diff --git a/src/config.js b/src/config.js index 9d36563..de8b202 100644 --- a/src/config.js +++ b/src/config.js @@ -21,6 +21,7 @@ export const EMAIL_HOST = 'https://p9axztuwd7x8a7.mycht.cn/mail-server/service-m export const API_HOST = 'https://p9axztuwd7x8a7.mycht.cn/whatsapp_server/v2'; export const WS_URL = 'wss://p9axztuwd7x8a7.mycht.cn/whatsapp_server'; // prod: export const VONAGE_URL = 'https://p9axztuwd7x8a7.mycht.cn/vonage-server'; // 语音和视频接口: +export const HT3 = process.env.NODE_ENV === 'production' ? 'https://p9axztuwd7x8a7.mycht.cn/ht3' : 'http://127.0.0.1:8000'; export const DATE_FORMAT = 'YYYY-MM-DD'; export const DATETIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'; diff --git a/src/main.jsx b/src/main.jsx index 3435123..ca5dd95 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -30,6 +30,8 @@ import DingdingAuthCode from '@/views/dingding/AuthCode' import useAuthStore from '@/stores/AuthStore' import '@/assets/index.css' +import CustomerRelation from '@/views/customer_relation/index' + useAuthStore.getState().loadUserSession() const isMobileApp = @@ -81,6 +83,7 @@ const router = createBrowserRouter([ { path: 'chat/unassign', element: }, { path: 'callcenter/call', element: }, { path: 'callcenter/call/:phonenumber', element: }, + { path: 'customer_relation/index', element: }, ], }, ], diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index 18c44d0..2bd5d37 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -157,7 +157,8 @@ const useAuthStore = create(devtools((set, get) => ({ }, loadUserSession: () => { - let sessionData = window.sessionStorage.getItem('GLOBAL_SALES_LOGIN_USER') + //let sessionData = window.sessionStorage.getItem('GLOBAL_SALES_LOGIN_USER') + let sessionData ='{"userId":"155","userIdStr":"155","emailList":[],"whatsAppBusiness":"+8617607730395","whatsAppNo":null,"username":"尹诚诚","avatarUrl":"https://static-legacy.dingtalk.com/media/lADPBE1XYG_HAcDNAgDNAgA_512_512.jpg","mobile":"+86-18507832160","email":"ycc@hainatravel.com","openId":"K8BNXMf8ESSr1DzLVUrX7wiEiE","accountList":[{"OPI_SN":155,"OPI_Code":"YCC","OPI_NameCN":"尹诚诚","OPI_DEI_SN":1,"OPI_NameEN":"Yin Chengcheng"}]}' // if (window.location.hostname === '202.103.68.93' && window.location.port === '4173' && isEmpty(sessionData)) { // sessionData = `{"userId":"383","userIdStr":"383,609","emailList":[{"opi_sn":383,"mat_sn":760,"email":"lyj@asiahighlights.com","default":false,"backup":false},{"opi_sn":383,"mat_sn":759,"email":"lyj@chinahighlights.com","default":true,"backup":false},{"opi_sn":383,"mat_sn":758,"email":"lyj@hainatravel.com","default":false,"backup":false}],"username":"廖一军","avatarUrl":"https://static-legacy.dingtalk.com/media/lALPBDDrhXr716HNAoDNAoA_640_640.png","mobile":"+86-18777396951","email":"lyj@hainatravel.com","whatsAppBusiness":"8617458471254","openId":"iioljiPmZ4RPoOYpkFiSn7IKAiEiE","accountList":[{"OPI_SN":383,"OPI_Code":"LYJ","OPI_NameCN":"廖一军","OPI_DEI_SN":7,"OPI_NameEN":"Jimmy Liow"},{"OPI_SN":609,"OPI_Code":"LYJAH","OPI_NameCN":"廖一军(ah)","OPI_DEI_SN":28,"OPI_NameEN":"Jimmy Liow"}]}` diff --git a/src/stores/CustomerRelationStore.js b/src/stores/CustomerRelationStore.js new file mode 100644 index 0000000..4645ff3 --- /dev/null +++ b/src/stores/CustomerRelationStore.js @@ -0,0 +1,41 @@ +import { create } from 'zustand' +import { devtools } from 'zustand/middleware' +import { fetchJSON, postForm } from '@/utils/request' +import { HT3, EMAIL_HOST } from '@/config' +import { isNotEmpty, prepareUrl } from '@/utils/commons' + +export const useCustomerRelationStore = create((set, get) => ({ + loading: false, + setLoading: (loading) => set({ loading }), + + tasksList: [], + + fetchSearchTasks: async (data) => { + set({ loading: true }) + const formData = new FormData() + for (const key in data) { + formData.append(key, data[key]) + } + fetch(`${HT3}/customerrelation/search_tasks`, { + method: 'POST', + body: formData, + }) + .then((res) => { + if (!res.ok) { + throw new Error(`HTTP error! status: ${res.status}`) + } + return res.json() + }) + .then((data) => { + set({ tasksList: data }) + }) + .catch((error) => { + console.error('Fetch error:', error) + }) + .finally(() => { + set({ loading: false }) + }) + }, +})) + +export default useCustomerRelationStore diff --git a/src/views/Conversations/History/SearchForm.jsx b/src/views/Conversations/History/SearchForm.jsx index 0315086..a90d12b 100644 --- a/src/views/Conversations/History/SearchForm.jsx +++ b/src/views/Conversations/History/SearchForm.jsx @@ -57,6 +57,7 @@ const SearchForm = memo(function ({ initialValues, onSubmit, onReset }) { +
diff --git a/src/views/DesktopApp.jsx b/src/views/DesktopApp.jsx index 1d91cb1..e4990ac 100644 --- a/src/views/DesktopApp.jsx +++ b/src/views/DesktopApp.jsx @@ -178,8 +178,8 @@ function DesktopApp() { label: 聊天记录, }, { - key: '/customer_relation', - label: 客户运营, + key: '/customer_relation/index', + label: 客户运营, }, ]} /> diff --git a/src/views/customer_relation/index.jsx b/src/views/customer_relation/index.jsx new file mode 100644 index 0000000..eb20bf1 --- /dev/null +++ b/src/views/customer_relation/index.jsx @@ -0,0 +1,108 @@ +import React, { useState } from 'react' +import { Form, Input, Button, DatePicker, Select, Table } from 'antd' +import dayjs from 'dayjs' +import useCustomerRelationStore from '@/stores/CustomerRelationStore' + +const { RangePicker } = DatePicker +const { Option } = Select + +const Index = () => { + const { loading, tasksList, fetchSearchTasks } = useCustomerRelationStore() + + // 定义默认值 + const initialFormValues = { + crt_mei_firstname: '', // 客人名字默认空 + dateRange: [dayjs().startOf('M'), dayjs().endOf('M')], // 默认本月 + crt_status: '' // 状态默认所有 + }; + + // 搜索表单提交 + const onFinish = (values) => { + const formattedValues = { + ...values, + start_date: values.dateRange ? values.dateRange[0].format('YYYY-MM-DD') : '', + end_date: values.dateRange ? values.dateRange[1].endOf('day').format('YYYY-MM-DD HH:mm:ss') : '', + } + fetchSearchTasks(formattedValues) + } + + const DATE_RANGE_PRESETS = [ + { + label: '本周', + value: [dayjs().startOf('w'), dayjs().endOf('w')], + }, + { + label: '上周', + value: [dayjs().startOf('w').subtract(7, 'days'), dayjs().endOf('w').subtract(7, 'days')], + }, + { + label: '本月', + value: [dayjs().startOf('M'), dayjs().endOf('M')], + }, + { + label: '上月', + value: [dayjs().subtract(1, 'M').startOf('M'), dayjs().subtract(1, 'M').endOf('M')], + }, + { + label: '前三月', + value: [dayjs().subtract(2, 'M').startOf('M'), dayjs().endOf('M')], + }, + { + label: '本年', + value: [dayjs().startOf('y'), dayjs().endOf('y')], + }, + ] + // 表格列定义 + const columns = [ + { title: '序列号', dataIndex: 'crt_sn', key: 'crt_sn' }, + { title: '模板', dataIndex: 'crt_template', key: 'crt_template' }, + { title: '状态', dataIndex: 'crt_status', key: 'crt_status' }, + { title: '团号', dataIndex: 'crt_coli_id', key: 'crt_coli_id' }, + { title: '发送时间', dataIndex: 'crt_send_datetime', key: 'crt_send_datetime' }, + { title: '客人名', dataIndex: 'crt_mei_firstname', key: 'crt_mei_firstname' }, + { title: '客人姓', dataIndex: 'crt_mei_lastname', key: 'crt_mei_lastname' }, + { title: 'WhatsApp', dataIndex: 'crt_whatsapp', key: 'crt_whatsapp' }, + { title: '邮箱', dataIndex: 'crt_mei_maillist', key: 'crt_mei_maillist' }, + { title: '关联序列号', dataIndex: 'crt_coli_sn', key: 'crt_coli_sn' }, + { title: '国家', dataIndex: 'crt_coi2_country', key: 'crt_coi2_country' }, + { title: '创建时间', dataIndex: 'ct_datetime', key: 'ct_datetime' }, + { title: '国家代码', dataIndex: 'ct_coi_code', key: 'ct_coi_code' }, + { title: '客人国家', dataIndex: 'crt_mei_country', key: 'crt_mei_country' }, + { title: '会话ID', dataIndex: 'crt_conversation_id', key: 'crt_conversation_id' }, + { title: '消息ID', dataIndex: 'crt_message_id', key: 'crt_message_id' }, + ]; + + return ( + <> + {/* 搜索栏 */} +
+ + + + + + + + + + + + +
+ + {/* 搜索结果 */} + + 搜索结果总数: {tasksList&&tasksList.length} + + + + ) +} + +export default Index From 5b0799ff039c67bf5d8c88c818c098e9a07d927d Mon Sep 17 00:00:00 2001 From: Ycc Date: Mon, 14 Apr 2025 21:10:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/customer_relation/index.jsx | 45 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/views/customer_relation/index.jsx b/src/views/customer_relation/index.jsx index eb20bf1..20407fb 100644 --- a/src/views/customer_relation/index.jsx +++ b/src/views/customer_relation/index.jsx @@ -11,10 +11,10 @@ const Index = () => { // 定义默认值 const initialFormValues = { - crt_mei_firstname: '', // 客人名字默认空 + crt_coli_id: '', // 客人名字默认空 dateRange: [dayjs().startOf('M'), dayjs().endOf('M')], // 默认本月 - crt_status: '' // 状态默认所有 - }; + crt_status: '', // 状态默认所有 + } // 搜索表单提交 const onFinish = (values) => { @@ -54,23 +54,34 @@ const Index = () => { ] // 表格列定义 const columns = [ - { title: '序列号', dataIndex: 'crt_sn', key: 'crt_sn' }, - { title: '模板', dataIndex: 'crt_template', key: 'crt_template' }, - { title: '状态', dataIndex: 'crt_status', key: 'crt_status' }, { title: '团号', dataIndex: 'crt_coli_id', key: 'crt_coli_id' }, + { title: '客人', dataIndex: 'crt_mei_firstname', key: 'crt_mei_firstname', render: (text, record) => record.crt_mei_firstname + ' ' + record.crt_mei_lastname }, + { title: '国家', dataIndex: 'crt_coi2_country', key: 'crt_coi2_country' }, + // { title: '时区', dataIndex: 'ct_coi_code', key: 'ct_coi_code' }, + + { + title: '状态', + dataIndex: 'crt_status', + key: 'crt_status', + render: (status) => { + if (status == '0') { + return '待发送' + } else if (status == '99') { + return '已发送' + } + return '失败' + }, + }, { title: '发送时间', dataIndex: 'crt_send_datetime', key: 'crt_send_datetime' }, - { title: '客人名', dataIndex: 'crt_mei_firstname', key: 'crt_mei_firstname' }, - { title: '客人姓', dataIndex: 'crt_mei_lastname', key: 'crt_mei_lastname' }, + { title: '模板', dataIndex: 'crt_template', key: 'crt_template' }, { title: 'WhatsApp', dataIndex: 'crt_whatsapp', key: 'crt_whatsapp' }, - { title: '邮箱', dataIndex: 'crt_mei_maillist', key: 'crt_mei_maillist' }, - { title: '关联序列号', dataIndex: 'crt_coli_sn', key: 'crt_coli_sn' }, - { title: '国家', dataIndex: 'crt_coi2_country', key: 'crt_coi2_country' }, - { title: '创建时间', dataIndex: 'ct_datetime', key: 'ct_datetime' }, - { title: '国家代码', dataIndex: 'ct_coi_code', key: 'ct_coi_code' }, - { title: '客人国家', dataIndex: 'crt_mei_country', key: 'crt_mei_country' }, { title: '会话ID', dataIndex: 'crt_conversation_id', key: 'crt_conversation_id' }, { title: '消息ID', dataIndex: 'crt_message_id', key: 'crt_message_id' }, - ]; + // { title: '邮箱', dataIndex: 'crt_mei_maillist', key: 'crt_mei_maillist' }, + // { title: '创建时间', dataIndex: 'ct_datetime', key: 'ct_datetime' }, + // { title: '客人国家', dataIndex: 'crt_mei_country', key: 'crt_mei_country' }, + + ] return ( <> @@ -86,7 +97,7 @@ const Index = () => { @@ -98,7 +109,7 @@ const Index = () => { {/* 搜索结果 */} - 搜索结果总数: {tasksList&&tasksList.length} + 搜索结果总数: {tasksList && tasksList.length}