Merge branch 'yongpxu-dev' into yongpxu-dev4
52
Cunkebao/dist/.vite/manifest.json
vendored
@@ -1,50 +1,50 @@
|
|||||||
{
|
{
|
||||||
"_charts-BjEBSMrK.js": {
|
"_charts-aNYyX7D2.js": {
|
||||||
"file": "assets/charts-BjEBSMrK.js",
|
"file": "assets/charts-aNYyX7D2.js",
|
||||||
"name": "charts",
|
"name": "charts",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_ui-CiJ_pikt.js",
|
"_ui-DZwp85UP.js",
|
||||||
"_vendor-BPPoWDlG.js"
|
"_vendor-Bq99rrm8.js"
|
||||||
]
|
|
||||||
},
|
|
||||||
"_ui-CiJ_pikt.js": {
|
|
||||||
"file": "assets/ui-CiJ_pikt.js",
|
|
||||||
"name": "ui",
|
|
||||||
"imports": [
|
|
||||||
"_vendor-BPPoWDlG.js"
|
|
||||||
],
|
|
||||||
"css": [
|
|
||||||
"assets/ui-D0C0OGrH.css"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_ui-D0C0OGrH.css": {
|
"_ui-D0C0OGrH.css": {
|
||||||
"file": "assets/ui-D0C0OGrH.css",
|
"file": "assets/ui-D0C0OGrH.css",
|
||||||
"src": "_ui-D0C0OGrH.css"
|
"src": "_ui-D0C0OGrH.css"
|
||||||
},
|
},
|
||||||
"_utils-DiZV3oaL.js": {
|
"_ui-DZwp85UP.js": {
|
||||||
"file": "assets/utils-DiZV3oaL.js",
|
"file": "assets/ui-DZwp85UP.js",
|
||||||
"name": "utils",
|
"name": "ui",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_vendor-BPPoWDlG.js"
|
"_vendor-Bq99rrm8.js"
|
||||||
|
],
|
||||||
|
"css": [
|
||||||
|
"assets/ui-D0C0OGrH.css"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_vendor-BPPoWDlG.js": {
|
"_utils-Ft3ushmX.js": {
|
||||||
"file": "assets/vendor-BPPoWDlG.js",
|
"file": "assets/utils-Ft3ushmX.js",
|
||||||
|
"name": "utils",
|
||||||
|
"imports": [
|
||||||
|
"_vendor-Bq99rrm8.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_vendor-Bq99rrm8.js": {
|
||||||
|
"file": "assets/vendor-Bq99rrm8.js",
|
||||||
"name": "vendor"
|
"name": "vendor"
|
||||||
},
|
},
|
||||||
"index.html": {
|
"index.html": {
|
||||||
"file": "assets/index-BesOjMPu.js",
|
"file": "assets/index-CCIZs36L.js",
|
||||||
"name": "index",
|
"name": "index",
|
||||||
"src": "index.html",
|
"src": "index.html",
|
||||||
"isEntry": true,
|
"isEntry": true,
|
||||||
"imports": [
|
"imports": [
|
||||||
"_vendor-BPPoWDlG.js",
|
"_vendor-Bq99rrm8.js",
|
||||||
"_utils-DiZV3oaL.js",
|
"_ui-DZwp85UP.js",
|
||||||
"_ui-CiJ_pikt.js",
|
"_utils-Ft3ushmX.js",
|
||||||
"_charts-BjEBSMrK.js"
|
"_charts-aNYyX7D2.js"
|
||||||
],
|
],
|
||||||
"css": [
|
"css": [
|
||||||
"assets/index-677RgwmW.css"
|
"assets/index-DRrzDMi4.css"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
12
Cunkebao/dist/index.html
vendored
@@ -11,13 +11,13 @@
|
|||||||
</style>
|
</style>
|
||||||
<!-- 引入 uni-app web-view SDK(必须) -->
|
<!-- 引入 uni-app web-view SDK(必须) -->
|
||||||
<script type="text/javascript" src="/websdk.js"></script>
|
<script type="text/javascript" src="/websdk.js"></script>
|
||||||
<script type="module" crossorigin src="/assets/index-BesOjMPu.js"></script>
|
<script type="module" crossorigin src="/assets/index-CCIZs36L.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/vendor-BPPoWDlG.js">
|
<link rel="modulepreload" crossorigin href="/assets/vendor-Bq99rrm8.js">
|
||||||
<link rel="modulepreload" crossorigin href="/assets/utils-DiZV3oaL.js">
|
<link rel="modulepreload" crossorigin href="/assets/ui-DZwp85UP.js">
|
||||||
<link rel="modulepreload" crossorigin href="/assets/ui-CiJ_pikt.js">
|
<link rel="modulepreload" crossorigin href="/assets/utils-Ft3ushmX.js">
|
||||||
<link rel="modulepreload" crossorigin href="/assets/charts-BjEBSMrK.js">
|
<link rel="modulepreload" crossorigin href="/assets/charts-aNYyX7D2.js">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/ui-D0C0OGrH.css">
|
<link rel="stylesheet" crossorigin href="/assets/ui-D0C0OGrH.css">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-677RgwmW.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-DRrzDMi4.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
// main.tsx
|
// main.tsx
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
|
import { ConfigProvider } from "antd";
|
||||||
|
import zhCN from "antd/locale/zh_CN";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import "dayjs/locale/zh-cn";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import "./styles/global.scss";
|
import "./styles/global.scss";
|
||||||
import { db } from "@/utils/db"; // 引入数据库实例
|
import { db } from "@/utils/db"; // 引入数据库实例
|
||||||
|
|
||||||
|
// 设置dayjs为中文
|
||||||
|
dayjs.locale("zh-cn");
|
||||||
|
|
||||||
// 数据库初始化
|
// 数据库初始化
|
||||||
async function initializeApp() {
|
async function initializeApp() {
|
||||||
try {
|
try {
|
||||||
@@ -26,7 +33,11 @@ async function initializeApp() {
|
|||||||
|
|
||||||
// 渲染应用
|
// 渲染应用
|
||||||
const root = createRoot(document.getElementById("root")!);
|
const root = createRoot(document.getElementById("root")!);
|
||||||
root.render(<App />);
|
root.render(
|
||||||
|
<ConfigProvider locale={zhCN}>
|
||||||
|
<App />
|
||||||
|
</ConfigProvider>,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 启动应用
|
// 启动应用
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ export default function ContentForm() {
|
|||||||
const [showEndPicker, setShowEndPicker] = useState(false);
|
const [showEndPicker, setShowEndPicker] = useState(false);
|
||||||
const [keywordsInclude, setKeywordsInclude] = useState("");
|
const [keywordsInclude, setKeywordsInclude] = useState("");
|
||||||
const [keywordsExclude, setKeywordsExclude] = useState("");
|
const [keywordsExclude, setKeywordsExclude] = useState("");
|
||||||
|
const [catchType, setCatchType] = useState<string[]>([
|
||||||
|
"text",
|
||||||
|
"image",
|
||||||
|
"video",
|
||||||
|
]);
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
@@ -65,6 +70,7 @@ export default function ContentForm() {
|
|||||||
setSelectedFriendsOptions(data.friendsGroupsOptions || []);
|
setSelectedFriendsOptions(data.friendsGroupsOptions || []);
|
||||||
setKeywordsInclude((data.keywordInclude || []).join(","));
|
setKeywordsInclude((data.keywordInclude || []).join(","));
|
||||||
setKeywordsExclude((data.keywordExclude || []).join(","));
|
setKeywordsExclude((data.keywordExclude || []).join(","));
|
||||||
|
setCatchType(data.catchType || ["text", "image", "video"]);
|
||||||
setAIPrompt(data.aiPrompt || "");
|
setAIPrompt(data.aiPrompt || "");
|
||||||
setUseAI(!!data.aiPrompt);
|
setUseAI(!!data.aiPrompt);
|
||||||
setEnabled(data.status === 1);
|
setEnabled(data.status === 1);
|
||||||
@@ -108,6 +114,7 @@ export default function ContentForm() {
|
|||||||
.split(/,|,|\n|\s+/)
|
.split(/,|,|\n|\s+/)
|
||||||
.map(s => s.trim())
|
.map(s => s.trim())
|
||||||
.filter(Boolean),
|
.filter(Boolean),
|
||||||
|
catchType,
|
||||||
aiPrompt,
|
aiPrompt,
|
||||||
timeEnabled: dateRange[0] || dateRange[1] ? 1 : 0,
|
timeEnabled: dateRange[0] || dateRange[1] ? 1 : 0,
|
||||||
startTime: dateRange[0] ? formatDate(dateRange[0]) : "",
|
startTime: dateRange[0] ? formatDate(dateRange[0]) : "",
|
||||||
@@ -236,6 +243,46 @@ export default function ContentForm() {
|
|||||||
</Collapse.Panel>
|
</Collapse.Panel>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
|
|
||||||
|
{/* 采集内容类型 */}
|
||||||
|
<div className={style["section-title"]}>采集内容类型</div>
|
||||||
|
<div className={style["form-section"]}>
|
||||||
|
<div style={{ display: "flex", flexWrap: "wrap", gap: 12 }}>
|
||||||
|
{["text", "image", "video"].map(type => (
|
||||||
|
<div
|
||||||
|
key={type}
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 8,
|
||||||
|
padding: "8px 12px",
|
||||||
|
border: "1px solid #d9d9d9",
|
||||||
|
borderRadius: "6px",
|
||||||
|
backgroundColor: catchType.includes(type)
|
||||||
|
? "#1890ff"
|
||||||
|
: "#fff",
|
||||||
|
color: catchType.includes(type) ? "#fff" : "#333",
|
||||||
|
cursor: "pointer",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setCatchType(prev =>
|
||||||
|
prev.includes(type)
|
||||||
|
? prev.filter(t => t !== type)
|
||||||
|
: [...prev, type],
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
{type === "text"
|
||||||
|
? "文本"
|
||||||
|
: type === "image"
|
||||||
|
? "图片"
|
||||||
|
: "视频"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className={style["section-title"]}>是否启用AI</div>
|
<div className={style["section-title"]}>是否启用AI</div>
|
||||||
<div
|
<div
|
||||||
className={style["form-section"]}
|
className={style["form-section"]}
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ export function useTrafficPoolListLogic() {
|
|||||||
const [showStats, setShowStats] = useState(false);
|
const [showStats, setShowStats] = useState(false);
|
||||||
const stats = useMemo(() => {
|
const stats = useMemo(() => {
|
||||||
const total = list.length;
|
const total = list.length;
|
||||||
const highValue = list.filter(u => u.tags.includes("高价值客户池")).length;
|
const highValue = list.filter(
|
||||||
|
u => u.tags && u.tags.includes("高价值客户池"),
|
||||||
|
).length;
|
||||||
const added = list.filter(u => u.status === 1).length;
|
const added = list.filter(u => u.status === 1).length;
|
||||||
const pending = list.filter(u => u.status === 0).length;
|
const pending = list.filter(u => u.status === 0).length;
|
||||||
const failed = list.filter(u => u.status === -1).length;
|
const failed = list.filter(u => u.status === -1).length;
|
||||||
@@ -64,6 +66,11 @@ export function useTrafficPoolListLogic() {
|
|||||||
const res = await fetchTrafficPoolList(params);
|
const res = await fetchTrafficPoolList(params);
|
||||||
setList(res.list || []);
|
setList(res.list || []);
|
||||||
setTotal(res.total || 0);
|
setTotal(res.total || 0);
|
||||||
|
} catch (error) {
|
||||||
|
// 忽略请求过于频繁的错误,避免页面崩溃
|
||||||
|
if (error !== "请求过于频繁,请稍后再试") {
|
||||||
|
console.error("获取列表失败:", error);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import Layout from "@/components/Layout/Layout";
|
import Layout from "@/components/Layout/Layout";
|
||||||
import {
|
import {
|
||||||
SearchOutlined,
|
SearchOutlined,
|
||||||
@@ -25,7 +25,6 @@ const TrafficPoolList: React.FC = () => {
|
|||||||
list,
|
list,
|
||||||
page,
|
page,
|
||||||
setPage,
|
setPage,
|
||||||
pageSize,
|
|
||||||
total,
|
total,
|
||||||
search,
|
search,
|
||||||
setSearch,
|
setSearch,
|
||||||
@@ -52,6 +51,22 @@ const TrafficPoolList: React.FC = () => {
|
|||||||
getList,
|
getList,
|
||||||
} = useTrafficPoolListLogic();
|
} = useTrafficPoolListLogic();
|
||||||
|
|
||||||
|
// 搜索防抖处理
|
||||||
|
const [searchInput, setSearchInput] = useState(search);
|
||||||
|
|
||||||
|
const debouncedSearch = useCallback(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setSearch(searchInput);
|
||||||
|
}, 500); // 500ms 防抖延迟
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [searchInput, setSearch]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const cleanup = debouncedSearch();
|
||||||
|
return cleanup;
|
||||||
|
}, [debouncedSearch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@@ -73,8 +88,8 @@ const TrafficPoolList: React.FC = () => {
|
|||||||
<div className="search-input-wrapper">
|
<div className="search-input-wrapper">
|
||||||
<Input
|
<Input
|
||||||
placeholder="搜索计划名称"
|
placeholder="搜索计划名称"
|
||||||
value={search}
|
value={searchInput}
|
||||||
onChange={e => setSearch(e.target.value)}
|
onChange={e => setSearchInput(e.target.value)}
|
||||||
prefix={<SearchOutlined />}
|
prefix={<SearchOutlined />}
|
||||||
allowClear
|
allowClear
|
||||||
size="large"
|
size="large"
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const DeviceListModal: React.FC<DeviceListModalProps> = ({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const detailRes = await getPlanDetail(ruleId.toString());
|
const detailRes = await getPlanDetail(ruleId.toString());
|
||||||
const deviceData = detailRes?.deveiceGroupsOptions || [];
|
const deviceData = detailRes?.deviceGroupsOptions || [];
|
||||||
setDevices(deviceData);
|
setDevices(deviceData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取设备详情失败:", error);
|
console.error("获取设备详情失败:", error);
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ export interface FormData {
|
|||||||
device: string[];
|
device: string[];
|
||||||
customTags: string[];
|
customTags: string[];
|
||||||
customTagsOptions: string[];
|
customTagsOptions: string[];
|
||||||
deveiceGroups: string[];
|
deviceGroups: string[];
|
||||||
deveiceGroupsOptions: DeviceSelectionItem[];
|
deviceGroupsOptions: DeviceSelectionItem[];
|
||||||
wechatGroups: string[];
|
wechatGroups: string[];
|
||||||
wechatGroupsOptions: GroupSelectionItem[];
|
wechatGroupsOptions: GroupSelectionItem[];
|
||||||
messagePlans: any[];
|
messagePlans: any[];
|
||||||
@@ -50,8 +50,8 @@ export const defFormData: FormData = {
|
|||||||
customTags: [],
|
customTags: [],
|
||||||
customTagsOptions: [],
|
customTagsOptions: [],
|
||||||
messagePlans: [],
|
messagePlans: [],
|
||||||
deveiceGroups: [],
|
deviceGroups: [],
|
||||||
deveiceGroupsOptions: [],
|
deviceGroupsOptions: [],
|
||||||
wechatGroups: [],
|
wechatGroups: [],
|
||||||
wechatGroupsOptions: [],
|
wechatGroupsOptions: [],
|
||||||
contentGroups: [],
|
contentGroups: [],
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ export default function NewPlan() {
|
|||||||
remarkFormat: detail.remarkFormat ?? "",
|
remarkFormat: detail.remarkFormat ?? "",
|
||||||
addFriendInterval: detail.addFriendInterval ?? 1,
|
addFriendInterval: detail.addFriendInterval ?? 1,
|
||||||
tips: detail.tips ?? "",
|
tips: detail.tips ?? "",
|
||||||
deveiceGroups: detail.deveiceGroups ?? [],
|
deviceGroups: detail.deviceGroups ?? [],
|
||||||
deveiceGroupsOptions: detail.deveiceGroupsOptions ?? [],
|
deviceGroupsOptions: detail.deviceGroupsOptions ?? [],
|
||||||
wechatGroups: detail.wechatGroups ?? [],
|
wechatGroups: detail.wechatGroups ?? [],
|
||||||
wechatGroupsOptions: detail.wechatGroupsOptions ?? [],
|
wechatGroupsOptions: detail.wechatGroupsOptions ?? [],
|
||||||
contentGroups: detail.contentGroups ?? [],
|
contentGroups: detail.contentGroups ?? [],
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ const FriendRequestSettings: React.FC<FriendRequestSettingsProps> = ({
|
|||||||
onChange({ ...formData, greeting: template });
|
onChange({ ...formData, greeting: template });
|
||||||
setIsTemplateDialogOpen(false);
|
setIsTemplateDialogOpen(false);
|
||||||
};
|
};
|
||||||
const handleDevicesChange = (deveiceGroupsOptions: DeviceSelectionItem[]) => {
|
const handleDevicesChange = (deviceGroupsOptions: DeviceSelectionItem[]) => {
|
||||||
onChange({
|
onChange({
|
||||||
...formData,
|
...formData,
|
||||||
deveiceGroups: deveiceGroupsOptions.map(d => d.id),
|
deviceGroups: deviceGroupsOptions.map(d => d.id),
|
||||||
deveiceGroupsOptions: deveiceGroupsOptions,
|
deviceGroupsOptions: deviceGroupsOptions,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ const FriendRequestSettings: React.FC<FriendRequestSettingsProps> = ({
|
|||||||
<div className={styles["friend-label"]}>选择设备</div>
|
<div className={styles["friend-label"]}>选择设备</div>
|
||||||
<div className={styles["friend-block"]}>
|
<div className={styles["friend-block"]}>
|
||||||
<DeviceSelection
|
<DeviceSelection
|
||||||
selectedOptions={formData.deveiceGroupsOptions}
|
selectedOptions={formData.deviceGroupsOptions}
|
||||||
onSelect={handleDevicesChange}
|
onSelect={handleDevicesChange}
|
||||||
placeholder="选择设备"
|
placeholder="选择设备"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import { DeviceSelectionItem } from "@/components/DeviceSelection/data";
|
|||||||
interface DeviceSelectorProps {
|
interface DeviceSelectorProps {
|
||||||
selectedDevices: DeviceSelectionItem[];
|
selectedDevices: DeviceSelectionItem[];
|
||||||
onNext: (data: {
|
onNext: (data: {
|
||||||
deveiceGroups: string[];
|
deviceGroups: string[];
|
||||||
deveiceGroupsOptions: DeviceSelectionItem[];
|
deviceGroupsOptions: DeviceSelectionItem[];
|
||||||
}) => void;
|
}) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,15 +37,13 @@ const DeviceSelector = forwardRef<DeviceSelectorRef, DeviceSelectorProps>(
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// 设备选择
|
// 设备选择
|
||||||
const handleDeviceSelect = (
|
const handleDeviceSelect = (deviceGroupsOptions: DeviceSelectionItem[]) => {
|
||||||
deveiceGroupsOptions: DeviceSelectionItem[],
|
const deviceGroups = deviceGroupsOptions.map(item => item.id);
|
||||||
) => {
|
form.setFieldValue("deviceGroups", deviceGroups);
|
||||||
const deveiceGroups = deveiceGroupsOptions.map(item => item.id);
|
|
||||||
form.setFieldValue("deveiceGroups", deveiceGroups);
|
|
||||||
// 通知父组件数据变化
|
// 通知父组件数据变化
|
||||||
onNext({
|
onNext({
|
||||||
deveiceGroups: deveiceGroups.map(id => String(id)),
|
deviceGroups: deviceGroups.map(id => String(id)),
|
||||||
deveiceGroupsOptions,
|
deviceGroupsOptions,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,7 +53,7 @@ const DeviceSelector = forwardRef<DeviceSelectorRef, DeviceSelectorProps>(
|
|||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={{
|
initialValues={{
|
||||||
deveiceGroups: selectedDevices.map(item => item.id),
|
deviceGroups: selectedDevices.map(item => item.id),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ marginBottom: 20 }}>
|
<div style={{ marginBottom: 20 }}>
|
||||||
@@ -68,7 +66,7 @@ const DeviceSelector = forwardRef<DeviceSelectorRef, DeviceSelectorProps>(
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="deveiceGroups"
|
name="deviceGroups"
|
||||||
rules={[
|
rules={[
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ const steps: StepItem[] = [
|
|||||||
const defaultForm: AutoGroupFormData = {
|
const defaultForm: AutoGroupFormData = {
|
||||||
name: "",
|
name: "",
|
||||||
type: 4,
|
type: 4,
|
||||||
deveiceGroups: [], // 设备组
|
deviceGroups: [], // 设备组
|
||||||
deveiceGroupsOptions: [], // 设备组选项
|
deviceGroupsOptions: [], // 设备组选项
|
||||||
poolGroups: [], // 内容库
|
poolGroups: [], // 内容库
|
||||||
poolGroupsOptions: [], // 内容库选项
|
poolGroupsOptions: [], // 内容库选项
|
||||||
startTime: dayjs().format("HH:mm"), // 开始时间 (HH:mm)
|
startTime: dayjs().format("HH:mm"), // 开始时间 (HH:mm)
|
||||||
@@ -64,8 +64,8 @@ const AutoGroupForm: React.FC = () => {
|
|||||||
const updatedForm = {
|
const updatedForm = {
|
||||||
...defaultForm,
|
...defaultForm,
|
||||||
name: res.name,
|
name: res.name,
|
||||||
deveiceGroups: res.config.deveiceGroups || [],
|
deviceGroups: res.config.deviceGroups || [],
|
||||||
deveiceGroupsOptions: res.config.deveiceGroupsOptions || [],
|
deviceGroupsOptions: res.config.deviceGroupsOptions || [],
|
||||||
poolGroups: res.config.poolGroups || [],
|
poolGroups: res.config.poolGroups || [],
|
||||||
poolGroupsOptions: res.config.poolGroupsOptions || [],
|
poolGroupsOptions: res.config.poolGroupsOptions || [],
|
||||||
startTime: res.config.startTime,
|
startTime: res.config.startTime,
|
||||||
@@ -80,7 +80,7 @@ const AutoGroupForm: React.FC = () => {
|
|||||||
id: res.id,
|
id: res.id,
|
||||||
};
|
};
|
||||||
setFormData(updatedForm);
|
setFormData(updatedForm);
|
||||||
setDeviceGroupsOptions(res.config.deveiceGroupsOptions || []);
|
setDeviceGroupsOptions(res.config.deviceGroupsOptions || []);
|
||||||
setpoolGroupsOptions(res.config.poolGroupsOptions || []);
|
setpoolGroupsOptions(res.config.poolGroupsOptions || []);
|
||||||
setDataLoaded(true); // 标记数据已加载
|
setDataLoaded(true); // 标记数据已加载
|
||||||
});
|
});
|
||||||
@@ -92,14 +92,14 @@ const AutoGroupForm: React.FC = () => {
|
|||||||
|
|
||||||
// 设备组选择
|
// 设备组选择
|
||||||
const handleDevicesChange = (data: {
|
const handleDevicesChange = (data: {
|
||||||
deveiceGroups: string[];
|
deviceGroups: string[];
|
||||||
deveiceGroupsOptions: DeviceSelectionItem[];
|
deviceGroupsOptions: DeviceSelectionItem[];
|
||||||
}) => {
|
}) => {
|
||||||
setFormData(prev => ({
|
setFormData(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
deveiceGroups: data.deveiceGroups,
|
deviceGroups: data.deviceGroups,
|
||||||
}));
|
}));
|
||||||
setDeviceGroupsOptions(data.deveiceGroupsOptions);
|
setDeviceGroupsOptions(data.deviceGroupsOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 流量池包选择
|
// 流量池包选择
|
||||||
@@ -116,7 +116,7 @@ const AutoGroupForm: React.FC = () => {
|
|||||||
Toast.show({ content: "请输入任务名称" });
|
Toast.show({ content: "请输入任务名称" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (formData.deveiceGroups.length === 0) {
|
if (formData.deviceGroups.length === 0) {
|
||||||
Toast.show({ content: "请选择至少一个设备组" });
|
Toast.show({ content: "请选择至少一个设备组" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ const AutoGroupForm: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const submitData = {
|
const submitData = {
|
||||||
...formData,
|
...formData,
|
||||||
deveiceGroupsOptions: deviceGroupsOptions,
|
deviceGroupsOptions: deviceGroupsOptions,
|
||||||
poolGroupsOptions: poolGroupsOptions,
|
poolGroupsOptions: poolGroupsOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ export interface AutoGroupFormData {
|
|||||||
id?: string; // 任务ID
|
id?: string; // 任务ID
|
||||||
type: number; // 任务类型
|
type: number; // 任务类型
|
||||||
name: string; // 任务名称
|
name: string; // 任务名称
|
||||||
deveiceGroups: string[]; // 设备组
|
deviceGroups: string[]; // 设备组
|
||||||
deveiceGroupsOptions: DeviceSelectionItem[]; // 设备组选项
|
deviceGroupsOptions: DeviceSelectionItem[]; // 设备组选项
|
||||||
poolGroups: string[]; // 流量池
|
poolGroups: string[]; // 流量池
|
||||||
poolGroupsOptions: PoolSelectionItem[]; // 流量池选项
|
poolGroupsOptions: PoolSelectionItem[]; // 流量池选项
|
||||||
startTime: string; // 开始时间 (YYYY-MM-DD HH:mm:ss)
|
startTime: string; // 开始时间 (YYYY-MM-DD HH:mm:ss)
|
||||||
@@ -34,7 +34,7 @@ export const formValidationRules = {
|
|||||||
{ required: true, message: "请输入任务名称" },
|
{ required: true, message: "请输入任务名称" },
|
||||||
{ min: 2, max: 50, message: "任务名称长度应在2-50个字符之间" },
|
{ min: 2, max: 50, message: "任务名称长度应在2-50个字符之间" },
|
||||||
],
|
],
|
||||||
deveiceGroups: [
|
deviceGroups: [
|
||||||
{ required: true, message: "请选择设备组" },
|
{ required: true, message: "请选择设备组" },
|
||||||
{ type: "array", min: 1, message: "至少选择一个设备组" },
|
{ type: "array", min: 1, message: "至少选择一个设备组" },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ export interface CreateLikeTaskData {
|
|||||||
startTime: string;
|
startTime: string;
|
||||||
endTime: string;
|
endTime: string;
|
||||||
contentTypes: ContentType[];
|
contentTypes: ContentType[];
|
||||||
deveiceGroups: number[];
|
deviceGroups: number[];
|
||||||
deveiceGroupsOptions: DeviceSelectionItem[];
|
deviceGroupsOptions: DeviceSelectionItem[];
|
||||||
friendsGroups: number[];
|
friendsGroups: number[];
|
||||||
friendsGroupsOptions: FriendSelectionItem[];
|
friendsGroupsOptions: FriendSelectionItem[];
|
||||||
friendMaxLikes: number;
|
friendMaxLikes: number;
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ const NewAutoLike: React.FC = () => {
|
|||||||
startTime: "08:00",
|
startTime: "08:00",
|
||||||
endTime: "22:00",
|
endTime: "22:00",
|
||||||
contentTypes: ["text", "image", "video"],
|
contentTypes: ["text", "image", "video"],
|
||||||
deveiceGroups: [],
|
deviceGroups: [],
|
||||||
deveiceGroupsOptions: [],
|
deviceGroupsOptions: [],
|
||||||
friendsGroups: [],
|
friendsGroups: [],
|
||||||
friendsGroupsOptions: [],
|
friendsGroupsOptions: [],
|
||||||
targetTags: [],
|
targetTags: [],
|
||||||
@@ -72,8 +72,8 @@ const NewAutoLike: React.FC = () => {
|
|||||||
startTime: config.timeRange?.start || config.startTime || "08:00",
|
startTime: config.timeRange?.start || config.startTime || "08:00",
|
||||||
endTime: config.timeRange?.end || config.endTime || "22:00",
|
endTime: config.timeRange?.end || config.endTime || "22:00",
|
||||||
contentTypes: config.contentTypes || ["text", "image", "video"],
|
contentTypes: config.contentTypes || ["text", "image", "video"],
|
||||||
deveiceGroups: config.deveiceGroups || [],
|
deviceGroups: config.deviceGroups || [],
|
||||||
deveiceGroupsOptions: config.deveiceGroupsOptions || [],
|
deviceGroupsOptions: config.deviceGroupsOptions || [],
|
||||||
friendsGroups: config.friendsgroups || [],
|
friendsGroups: config.friendsgroups || [],
|
||||||
friendsGroupsOptions: config.friendsGroupsOptions || [],
|
friendsGroupsOptions: config.friendsGroupsOptions || [],
|
||||||
targetTags: config.targetTags || [],
|
targetTags: config.targetTags || [],
|
||||||
@@ -121,7 +121,7 @@ const NewAutoLike: React.FC = () => {
|
|||||||
message.warning("请输入任务名称");
|
message.warning("请输入任务名称");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!formData.deveiceGroups || formData.deveiceGroups.length === 0) {
|
if (!formData.deviceGroups || formData.deviceGroups.length === 0) {
|
||||||
message.warning("请选择执行设备");
|
message.warning("请选择执行设备");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -329,11 +329,11 @@ const NewAutoLike: React.FC = () => {
|
|||||||
<div className={style.basicSection}>
|
<div className={style.basicSection}>
|
||||||
<div className={style.formItem}>
|
<div className={style.formItem}>
|
||||||
<DeviceSelection
|
<DeviceSelection
|
||||||
selectedOptions={formData.deveiceGroupsOptions}
|
selectedOptions={formData.deviceGroupsOptions}
|
||||||
onSelect={devices =>
|
onSelect={devices =>
|
||||||
handleUpdateFormData({
|
handleUpdateFormData({
|
||||||
deveiceGroups: devices.map(v => v.id),
|
deviceGroups: devices.map(v => v.id),
|
||||||
deveiceGroupsOptions: devices,
|
deviceGroupsOptions: devices,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
showInput={true}
|
showInput={true}
|
||||||
@@ -353,7 +353,7 @@ const NewAutoLike: React.FC = () => {
|
|||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
className={style.nextBtn}
|
className={style.nextBtn}
|
||||||
size="large"
|
size="large"
|
||||||
disabled={formData.deveiceGroups.length === 0}
|
disabled={formData.deviceGroups.length === 0}
|
||||||
>
|
>
|
||||||
下一步
|
下一步
|
||||||
</Button>
|
</Button>
|
||||||
@@ -372,7 +372,7 @@ const NewAutoLike: React.FC = () => {
|
|||||||
friendsGroupsOptions: friends,
|
friendsGroupsOptions: friends,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
deviceIds={formData.deveiceGroups}
|
deviceIds={formData.deviceGroups}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -0,0 +1,325 @@
|
|||||||
|
.container {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actionCard {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
|
:global(.adm-card-body) {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskHeader {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskInfo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskName {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
flex: 1;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskStatus {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background-color: rgba(82, 196, 26, 0.1);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
|
||||||
|
:global(.adm-button) {
|
||||||
|
flex: 1;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
:global(.adm-tabs-header) {
|
||||||
|
background: #fafafa;
|
||||||
|
border-bottom: 1px solid #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.adm-tabs-tab) {
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 500;
|
||||||
|
|
||||||
|
&.adm-tabs-tab-active {
|
||||||
|
color: #1890ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.adm-tabs-tab-line) {
|
||||||
|
background: #1890ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabContent {
|
||||||
|
padding: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoCard {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #f0f0f0;
|
||||||
|
|
||||||
|
:global(.adm-card-body) {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardTitle {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 1px solid #f0f0f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoList {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoItem {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
color: #666;
|
||||||
|
margin-right: 12px;
|
||||||
|
min-width: 80px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: #333;
|
||||||
|
flex: 1;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordList {
|
||||||
|
:global(.adm-list-body) {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordItem {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #f0f0f0;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
|
||||||
|
:global(.adm-list-item-content) {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordHeader {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordInfo {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordDevice {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordTime {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordContent {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordDetail {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 13px;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
min-width: 70px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordError {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #ff4d4f;
|
||||||
|
background: #fff2f0;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #ffccc7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loadingMore {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 20px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 状态标签样式覆盖
|
||||||
|
:global {
|
||||||
|
.adm-tag {
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
|
||||||
|
&.adm-tag-success {
|
||||||
|
background: #f6ffed;
|
||||||
|
border-color: #b7eb8f;
|
||||||
|
color: #52c41a;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.adm-tag-danger {
|
||||||
|
background: #fff2f0;
|
||||||
|
border-color: #ffccc7;
|
||||||
|
color: #ff4d4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.adm-tag-warning {
|
||||||
|
background: #fff7e6;
|
||||||
|
border-color: #ffd591;
|
||||||
|
color: #fa8c16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下拉刷新样式
|
||||||
|
:global(.adm-pull-to-refresh) {
|
||||||
|
.adm-pull-to-refresh-indicator {
|
||||||
|
color: #1890ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 响应式设计
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.taskName {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskStatus {
|
||||||
|
font-size: 13px;
|
||||||
|
padding: 3px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardTitle {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoItem {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
min-width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordDevice {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordTime {
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordDetail {
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
min-width: 60px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordError {
|
||||||
|
font-size: 12px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 空状态样式
|
||||||
|
:global(.adm-empty) {
|
||||||
|
padding: 40px 20px;
|
||||||
|
|
||||||
|
.adm-empty-image {
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adm-empty-description {
|
||||||
|
color: #999;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,467 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Toast,
|
||||||
|
Card,
|
||||||
|
Tabs,
|
||||||
|
List,
|
||||||
|
Tag,
|
||||||
|
Space,
|
||||||
|
InfiniteScroll,
|
||||||
|
PullToRefresh,
|
||||||
|
Empty,
|
||||||
|
SpinLoading,
|
||||||
|
} from "antd-mobile";
|
||||||
|
import NavCommon from "@/components/NavCommon";
|
||||||
|
import Layout from "@/components/Layout/Layout";
|
||||||
|
import {
|
||||||
|
fetchContactImportTaskDetail,
|
||||||
|
fetchImportRecords,
|
||||||
|
triggerImport,
|
||||||
|
toggleContactImportTask,
|
||||||
|
} from "../list/api";
|
||||||
|
import { ContactImportRecord } from "../list/data";
|
||||||
|
import {
|
||||||
|
PlayCircleOutlined,
|
||||||
|
PauseCircleOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
ReloadOutlined,
|
||||||
|
CheckCircleOutlined,
|
||||||
|
CloseCircleOutlined,
|
||||||
|
ClockCircleOutlined,
|
||||||
|
} from "@ant-design/icons";
|
||||||
|
import style from "./index.module.scss";
|
||||||
|
|
||||||
|
const ContactImportDetail: React.FC = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
const [task, setTask] = useState<any>(null);
|
||||||
|
const [records, setRecords] = useState<ContactImportRecord[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [recordsLoading, setRecordsLoading] = useState(false);
|
||||||
|
const [hasMore, setHasMore] = useState(true);
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [activeTab, setActiveTab] = useState("info");
|
||||||
|
|
||||||
|
// 获取任务详情
|
||||||
|
const loadTaskDetail = async () => {
|
||||||
|
if (!id) return;
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchContactImportTaskDetail(id);
|
||||||
|
const data = response?.data || response;
|
||||||
|
setTask(data);
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "获取任务详情失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
navigate("/workspace/contact-import/list");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取导入记录
|
||||||
|
const loadRecords = async (pageNum: number = 1, reset: boolean = false) => {
|
||||||
|
if (!id) return;
|
||||||
|
|
||||||
|
setRecordsLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchImportRecords(id, pageNum, 20);
|
||||||
|
const data = response?.data || response;
|
||||||
|
if (reset) {
|
||||||
|
setRecords(data.list || []);
|
||||||
|
} else {
|
||||||
|
setRecords(prev => [...prev, ...(data.list || [])]);
|
||||||
|
}
|
||||||
|
setHasMore(data.list.length === 20);
|
||||||
|
setPage(pageNum);
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "获取记录失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setRecordsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 切换任务状态
|
||||||
|
const handleToggleStatus = async () => {
|
||||||
|
if (!task) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await toggleContactImportTask({
|
||||||
|
id: task.id,
|
||||||
|
status: task.status === 1 ? 2 : 1,
|
||||||
|
});
|
||||||
|
Toast.show({
|
||||||
|
content: task.status === 1 ? "任务已暂停" : "任务已启动",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
loadTaskDetail();
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "操作失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 手动触发导入
|
||||||
|
const handleTriggerImport = async () => {
|
||||||
|
if (!task) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await triggerImport(task.id);
|
||||||
|
Toast.show({
|
||||||
|
content: "导入任务已触发",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
loadTaskDetail();
|
||||||
|
loadRecords(1, true);
|
||||||
|
}, 1000);
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "触发失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 刷新数据
|
||||||
|
const handleRefresh = async () => {
|
||||||
|
await loadTaskDetail();
|
||||||
|
if (activeTab === "records") {
|
||||||
|
await loadRecords(1, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 加载更多记录
|
||||||
|
const loadMoreRecords = async () => {
|
||||||
|
await loadRecords(page + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取状态文本和颜色
|
||||||
|
const getStatusInfo = (status: number) => {
|
||||||
|
return status === 1
|
||||||
|
? { text: "运行中", color: "#52c41a" }
|
||||||
|
: { text: "已暂停", color: "#faad14" };
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取记录状态图标
|
||||||
|
const getRecordStatusIcon = (status: string) => {
|
||||||
|
switch (status) {
|
||||||
|
case "success":
|
||||||
|
return <CheckCircleOutlined style={{ color: "#52c41a" }} />;
|
||||||
|
case "failed":
|
||||||
|
return <CloseCircleOutlined style={{ color: "#ff4d4f" }} />;
|
||||||
|
case "pending":
|
||||||
|
return <ClockCircleOutlined style={{ color: "#faad14" }} />;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取记录状态标签
|
||||||
|
const getRecordStatusTag = (status: string) => {
|
||||||
|
switch (status) {
|
||||||
|
case "success":
|
||||||
|
return <Tag color="success">成功</Tag>;
|
||||||
|
case "failed":
|
||||||
|
return <Tag color="danger">失败</Tag>;
|
||||||
|
case "pending":
|
||||||
|
return <Tag color="warning">进行中</Tag>;
|
||||||
|
default:
|
||||||
|
return <Tag color="default">未知</Tag>;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadTaskDetail();
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// if (activeTab === "records" && records.length === 0) {
|
||||||
|
// loadRecords(1, true);
|
||||||
|
// }
|
||||||
|
}, [activeTab]);
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
header={
|
||||||
|
<NavCommon
|
||||||
|
left={
|
||||||
|
<Button
|
||||||
|
fill="none"
|
||||||
|
size="small"
|
||||||
|
onClick={() => navigate("/workspace/contact-import/list")}
|
||||||
|
>
|
||||||
|
返回
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
title="任务详情"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className={style.loading}>
|
||||||
|
<SpinLoading /> 加载中...
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!task) {
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
header={
|
||||||
|
<NavCommon
|
||||||
|
left={
|
||||||
|
<Button
|
||||||
|
fill="none"
|
||||||
|
size="small"
|
||||||
|
onClick={() => navigate("/workspace/contact-import/list")}
|
||||||
|
>
|
||||||
|
返回
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
title="任务详情"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className={style.empty}>
|
||||||
|
<Empty description="任务不存在" />
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusInfo = getStatusInfo(task.status);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
header={
|
||||||
|
<>
|
||||||
|
<NavCommon
|
||||||
|
title="任务详情"
|
||||||
|
right={
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/workspace/contact-import/form/${task.id}`)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<EditOutlined /> 编辑
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{/* 任务操作栏 */}
|
||||||
|
<Card className={style.actionCard}>
|
||||||
|
<div className={style.taskHeader}>
|
||||||
|
<div className={style.taskInfo}>
|
||||||
|
<div className={style.taskName}>{task.name}</div>
|
||||||
|
<div
|
||||||
|
className={style.taskStatus}
|
||||||
|
style={{ color: statusInfo.color }}
|
||||||
|
>
|
||||||
|
{statusInfo.text}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={style.actions}>
|
||||||
|
<Button
|
||||||
|
onClick={handleToggleStatus}
|
||||||
|
color={task.status === 1 ? "warning" : "primary"}
|
||||||
|
>
|
||||||
|
{task.status === 1 ? (
|
||||||
|
<>
|
||||||
|
<PauseCircleOutlined /> 暂停
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<PlayCircleOutlined /> 启动
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={handleTriggerImport}
|
||||||
|
disabled={task.status !== 1}
|
||||||
|
>
|
||||||
|
<ReloadOutlined /> 立即导入
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<PullToRefresh onRefresh={handleRefresh}>
|
||||||
|
<div className={style.container}>
|
||||||
|
{/* 标签页 */}
|
||||||
|
<Tabs
|
||||||
|
activeKey={activeTab}
|
||||||
|
onChange={setActiveTab}
|
||||||
|
className={style.tabs}
|
||||||
|
>
|
||||||
|
<Tabs.Tab title="任务信息" key="info">
|
||||||
|
<div className={style.tabContent}>
|
||||||
|
{/* 基本信息 */}
|
||||||
|
<Card className={style.infoCard}>
|
||||||
|
<div className={style.cardTitle}>基本信息</div>
|
||||||
|
<div className={style.infoList}>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>任务名称:</span>
|
||||||
|
<span className={style.value}>{task.name}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>设备组数:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.deviceGroups?.length || 0}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>导入数量:</span>
|
||||||
|
<span className={style.value}>{task.num}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>客户端ID:</span>
|
||||||
|
<span className={style.value}>{task.clientId}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>备注类型:</span>
|
||||||
|
<span className={style.value}>{task.remarkType}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>备注内容:</span>
|
||||||
|
<span className={style.value}>{task.remarkValue}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{/* 时间配置 */}
|
||||||
|
<Card className={style.infoCard}>
|
||||||
|
<div className={style.cardTitle}>时间配置</div>
|
||||||
|
<div className={style.infoList}>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>开始时间:</span>
|
||||||
|
<span className={style.value}>{task.startTime}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>结束时间:</span>
|
||||||
|
<span className={style.value}>{task.endTime}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>每日最大导入:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.maxImportsPerDay}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>导入间隔:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.importInterval}分钟
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{/* 统计信息 */}
|
||||||
|
<Card className={style.infoCard}>
|
||||||
|
<div className={style.cardTitle}>统计信息</div>
|
||||||
|
<div className={style.infoList}>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>今日导入:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.todayImportCount}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>总导入数:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.totalImportCount}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>创建时间:</span>
|
||||||
|
<span className={style.value}>{task.createTime}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.infoItem}>
|
||||||
|
<span className={style.label}>更新时间:</span>
|
||||||
|
<span className={style.value}>{task.updateTime}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</Tabs.Tab>
|
||||||
|
|
||||||
|
<Tabs.Tab title="导入记录" key="records">
|
||||||
|
<div className={style.tabContent}>
|
||||||
|
{records.length === 0 && !recordsLoading ? (
|
||||||
|
<Empty description="暂无导入记录" />
|
||||||
|
) : (
|
||||||
|
<List className={style.recordList}>
|
||||||
|
{records.map(record => (
|
||||||
|
<List.Item key={record.id} className={style.recordItem}>
|
||||||
|
<div className={style.recordHeader}>
|
||||||
|
<div className={style.recordInfo}>
|
||||||
|
<Space>
|
||||||
|
{getRecordStatusIcon(record.importStatus)}
|
||||||
|
<span className={style.recordDevice}>
|
||||||
|
{record.deviceName}
|
||||||
|
</span>
|
||||||
|
{getRecordStatusTag(record.importStatus)}
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
<div className={style.recordTime}>
|
||||||
|
{record.createTime}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={style.recordContent}>
|
||||||
|
<div className={style.recordDetail}>
|
||||||
|
<span className={style.label}>导入数量:</span>
|
||||||
|
<span className={style.value}>{record.num}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.recordDetail}>
|
||||||
|
<span className={style.label}>备注:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{record.remarkType}: {record.remarkValue}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{record.errorMessage && (
|
||||||
|
<div className={style.recordError}>
|
||||||
|
错误信息: {record.errorMessage}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</List.Item>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<InfiniteScroll
|
||||||
|
loadMore={loadMoreRecords}
|
||||||
|
hasMore={hasMore}
|
||||||
|
threshold={10}
|
||||||
|
>
|
||||||
|
{recordsLoading && (
|
||||||
|
<div className={style.loadingMore}>
|
||||||
|
<SpinLoading /> 加载中...
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</InfiniteScroll>
|
||||||
|
</div>
|
||||||
|
</Tabs.Tab>
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
</PullToRefresh>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ContactImportDetail;
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
import request from "@/api/request";
|
||||||
|
import {
|
||||||
|
Allocation,
|
||||||
|
CreateContactImportTaskData,
|
||||||
|
UpdateContactImportTaskData,
|
||||||
|
ContactImportRecord,
|
||||||
|
PaginatedResponse,
|
||||||
|
ImportStats,
|
||||||
|
} from "./data";
|
||||||
|
|
||||||
|
// 获取通讯录导入任务列表
|
||||||
|
export function fetchContactImportTasks(
|
||||||
|
params = { type: 6, page: 1, limit: 10 },
|
||||||
|
) {
|
||||||
|
return request("/v1/workbench/list", params, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取单个任务详情
|
||||||
|
export function fetchContactImportTaskDetail(id: number) {
|
||||||
|
return request("/v1/workbench/detail", { id }, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建通讯录导入任务
|
||||||
|
export function createContactImportTask(data: Allocation): Promise<any> {
|
||||||
|
return request("/v1/workbench/create", { ...data, type: 6 }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新通讯录导入任务
|
||||||
|
export function updateContactImportTask(data: Allocation): Promise<any> {
|
||||||
|
return request("/v1/workbench/update", { ...data, type: 6 }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除通讯录导入任务
|
||||||
|
export function deleteContactImportTask(id: number): Promise<any> {
|
||||||
|
return request("/v1/workbench/delete", { id }, "DELETE");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 切换任务状态
|
||||||
|
export function toggleContactImportTask(data: {
|
||||||
|
id: number;
|
||||||
|
status: number;
|
||||||
|
}): Promise<any> {
|
||||||
|
return request("/v1/workbench/update-status", { ...data }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制通讯录导入任务
|
||||||
|
export function copyContactImportTask(id: number): Promise<any> {
|
||||||
|
return request("/v1/workbench/copy", { id }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取导入记录
|
||||||
|
export function fetchImportRecords(
|
||||||
|
workbenchId: number,
|
||||||
|
page: number = 1,
|
||||||
|
limit: number = 20,
|
||||||
|
keyword?: string,
|
||||||
|
): Promise<PaginatedResponse<ContactImportRecord>> {
|
||||||
|
return request(
|
||||||
|
"/v1/workbench/import-records",
|
||||||
|
{
|
||||||
|
workbenchId,
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
keyword,
|
||||||
|
},
|
||||||
|
"GET",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取统计数据
|
||||||
|
export function fetchImportStats(): Promise<ImportStats> {
|
||||||
|
return request("/v1/workbench/import-stats", {}, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取设备组列表
|
||||||
|
export function fetchDeviceGroups(): Promise<any[]> {
|
||||||
|
return request("/v1/device/groups", {}, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 手动触发导入
|
||||||
|
export function triggerImport(taskId: number): Promise<any> {
|
||||||
|
return request("/v1/workbench/trigger-import", { taskId }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量操作任务
|
||||||
|
export function batchOperateTasks(data: {
|
||||||
|
taskIds: number[];
|
||||||
|
operation: "start" | "stop" | "delete";
|
||||||
|
}): Promise<any> {
|
||||||
|
return request("/v1/workbench/batch-operate", data, "POST");
|
||||||
|
}
|
||||||
168
Cunkebao/src/pages/mobile/workspace/contact-import/form/data.ts
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
// 分配接口类型
|
||||||
|
export interface Allocation {
|
||||||
|
/** 主键ID */
|
||||||
|
id?: number;
|
||||||
|
/** 任务名称 */
|
||||||
|
name: string;
|
||||||
|
//是否启用0关闭,1启用
|
||||||
|
status: number;
|
||||||
|
//任务类型,固定为6
|
||||||
|
type: number;
|
||||||
|
/** 工作台ID */
|
||||||
|
workbenchId: number;
|
||||||
|
|
||||||
|
/** 设备id */
|
||||||
|
deviceGroups: number[];
|
||||||
|
/** 流量池 */
|
||||||
|
pools?: JSON | null;
|
||||||
|
|
||||||
|
/** 分配数量 */
|
||||||
|
num?: number | null;
|
||||||
|
|
||||||
|
/** 是否清除现有联系人,默认0 */
|
||||||
|
clearContact?: number;
|
||||||
|
|
||||||
|
/** 备注类型 0不备注 1年月日 2月日 3自定义,默认0 */
|
||||||
|
remarkType: number;
|
||||||
|
|
||||||
|
/** 备注 */
|
||||||
|
remark?: string | null;
|
||||||
|
|
||||||
|
/** 开始时间 */
|
||||||
|
startTime?: string | null;
|
||||||
|
|
||||||
|
/** 结束时间 */
|
||||||
|
endTime?: string | null;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
// 通讯录导入任务状态
|
||||||
|
export type ContactImportTaskStatus = 1 | 2; // 1: 开启, 2: 关闭
|
||||||
|
|
||||||
|
// 设备组信息
|
||||||
|
export interface DeviceGroup {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
deviceCount: number;
|
||||||
|
status: "online" | "offline";
|
||||||
|
lastActive: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通讯录导入记录
|
||||||
|
export interface ContactImportRecord {
|
||||||
|
id: string;
|
||||||
|
workbenchId: string;
|
||||||
|
wechatAccountId: string;
|
||||||
|
deviceId: string;
|
||||||
|
num: number;
|
||||||
|
clientId: string;
|
||||||
|
remarkType: string;
|
||||||
|
remarkValue: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
createTime: string;
|
||||||
|
operatorName: string;
|
||||||
|
operatorAvatar: string;
|
||||||
|
deviceName: string;
|
||||||
|
importStatus: "success" | "failed" | "pending";
|
||||||
|
errorMessage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通讯录导入任务配置
|
||||||
|
export interface ContactImportTaskConfig {
|
||||||
|
id: number;
|
||||||
|
workbenchId: number;
|
||||||
|
devices: number[];
|
||||||
|
pools: number[];
|
||||||
|
num: number;
|
||||||
|
clearContact: number;
|
||||||
|
remarkType: number;
|
||||||
|
remark: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
createTime: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通讯录导入任务
|
||||||
|
export interface ContactImportTask {
|
||||||
|
id: number;
|
||||||
|
companyId: number;
|
||||||
|
name: string;
|
||||||
|
type: number;
|
||||||
|
status: ContactImportTaskStatus;
|
||||||
|
autoStart: number;
|
||||||
|
userId: number;
|
||||||
|
createTime: string;
|
||||||
|
updateTime: string;
|
||||||
|
config: ContactImportTaskConfig;
|
||||||
|
creatorName: string;
|
||||||
|
auto_like: any;
|
||||||
|
moments_sync: any;
|
||||||
|
traffic_config: any;
|
||||||
|
group_push: any;
|
||||||
|
group_create: any;
|
||||||
|
// 计算属性,用于向后兼容
|
||||||
|
deviceGroups?: string[];
|
||||||
|
todayImportCount?: number;
|
||||||
|
totalImportCount?: number;
|
||||||
|
maxImportsPerDay?: number;
|
||||||
|
importInterval?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建通讯录导入任务数据
|
||||||
|
export interface CreateContactImportTaskData {
|
||||||
|
name: string;
|
||||||
|
type: number;
|
||||||
|
config: {
|
||||||
|
devices: number[];
|
||||||
|
pools: number[];
|
||||||
|
num: number;
|
||||||
|
clearContact: number;
|
||||||
|
remarkType: number;
|
||||||
|
remark: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新通讯录导入任务数据
|
||||||
|
export interface UpdateContactImportTaskData
|
||||||
|
extends CreateContactImportTaskData {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 任务配置
|
||||||
|
export interface TaskConfig {
|
||||||
|
deviceGroups: string[];
|
||||||
|
num: number;
|
||||||
|
clientId: string;
|
||||||
|
remarkType: string;
|
||||||
|
remarkValue: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
maxImportsPerDay: number;
|
||||||
|
importInterval: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// API响应
|
||||||
|
export interface ApiResponse<T = any> {
|
||||||
|
code: number;
|
||||||
|
msg: string;
|
||||||
|
data: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页响应
|
||||||
|
export interface PaginatedResponse<T> {
|
||||||
|
list: T[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
limit: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统计数据
|
||||||
|
export interface ImportStats {
|
||||||
|
totalTasks: number;
|
||||||
|
activeTasks: number;
|
||||||
|
todayImports: number;
|
||||||
|
totalImports: number;
|
||||||
|
successRate: number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
.basicSection {
|
||||||
|
background: none;
|
||||||
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
padding: 24px 16px 0 16px;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formItem {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.formLabel {
|
||||||
|
font-size: 15px;
|
||||||
|
color: #222;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input {
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 15px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select {
|
||||||
|
width: 100%;
|
||||||
|
height: 44px;
|
||||||
|
|
||||||
|
:global(.ant-select-selector) {
|
||||||
|
height: 44px !important;
|
||||||
|
border-radius: 8px !important;
|
||||||
|
font-size: 15px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.ant-select-selection-item) {
|
||||||
|
line-height: 42px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.timePicker {
|
||||||
|
width: 100%;
|
||||||
|
height: 44px;
|
||||||
|
|
||||||
|
:global(.ant-picker) {
|
||||||
|
width: 100%;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.counterRow {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stepperContainer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stepperButton {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #188eee;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: border 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border: 1px solid #188eee;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.stepperInput {
|
||||||
|
width: 80px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 0;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-left: none;
|
||||||
|
border-right: none;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #222;
|
||||||
|
padding: 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.counterTip {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #aaa;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttonGroup {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 14px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.submitButton {
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 15px;
|
||||||
|
min-width: 120px;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resetButton {
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 15px;
|
||||||
|
min-width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deviceSelection {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.ant-input {
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #e8e8e8;
|
||||||
|
padding: 12px 16px;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
border-color: #1890ff;
|
||||||
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,355 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
|
||||||
|
import { Button, Input, message, TimePicker, Select, Switch } from "antd";
|
||||||
|
import NavCommon from "@/components/NavCommon";
|
||||||
|
import Layout from "@/components/Layout/Layout";
|
||||||
|
import DeviceSelection from "@/components/DeviceSelection";
|
||||||
|
import {
|
||||||
|
createContactImportTask,
|
||||||
|
updateContactImportTask,
|
||||||
|
fetchContactImportTaskDetail,
|
||||||
|
} from "./api";
|
||||||
|
import { Allocation } from "./data";
|
||||||
|
|
||||||
|
import style from "./index.module.scss";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
const ContactImportForm: React.FC = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { id } = useParams<{ id?: string }>();
|
||||||
|
const isEdit = !!id;
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
name: "", // 任务名称
|
||||||
|
status: 1, // 是否启用,默认启用
|
||||||
|
type: 6, // 任务类型,固定为6
|
||||||
|
workbenchId: 1, // 默认工作台ID
|
||||||
|
deviceGroups: [] as number[],
|
||||||
|
pools: [] as any[],
|
||||||
|
num: 50,
|
||||||
|
clearContact: 0,
|
||||||
|
remarkType: 0,
|
||||||
|
remark: "",
|
||||||
|
startTime: dayjs("09:00", "HH:mm"),
|
||||||
|
endTime: dayjs("21:00", "HH:mm"),
|
||||||
|
// 保留原有字段用于UI显示
|
||||||
|
deviceGroupsOptions: [] as any[],
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理设备选择
|
||||||
|
const handleDeviceSelect = (selectedDevices: any[]) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
deviceGroupsOptions: selectedDevices,
|
||||||
|
deviceGroups: selectedDevices.map(device => device.id), // 提取设备ID存储到deviceGroups数组
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取任务详情(编辑模式)
|
||||||
|
const loadTaskDetail = async () => {
|
||||||
|
if (!id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const data = await fetchContactImportTaskDetail(Number(id));
|
||||||
|
if (data) {
|
||||||
|
const config = data.config || {};
|
||||||
|
|
||||||
|
// 构造设备选择组件需要的数据格式
|
||||||
|
const deviceGroupsOptions = config.deviceGroupsOptions || [];
|
||||||
|
|
||||||
|
setFormData({
|
||||||
|
name: data.name || "",
|
||||||
|
status: data.status || 1,
|
||||||
|
type: data.type || 6,
|
||||||
|
workbenchId: config.workbenchId || 1,
|
||||||
|
deviceGroups:
|
||||||
|
deviceGroupsOptions.map((device: any) => device.id) || [],
|
||||||
|
pools: config.pools ? JSON.parse(JSON.stringify(config.pools)) : [],
|
||||||
|
num: config.num || 50,
|
||||||
|
clearContact: config.clearContact || 0,
|
||||||
|
remarkType: config.remarkType || 0,
|
||||||
|
remark: config.remark || "",
|
||||||
|
startTime: config.startTime ? dayjs(config.startTime, "HH:mm") : null,
|
||||||
|
endTime: config.endTime ? dayjs(config.endTime, "HH:mm") : null,
|
||||||
|
deviceGroupsOptions,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load task detail:", error);
|
||||||
|
message.error("获取任务详情失败");
|
||||||
|
navigate("/workspace/contact-import/list");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 更新表单数据
|
||||||
|
const handleUpdateFormData = (data: Partial<typeof formData>) => {
|
||||||
|
setFormData(prev => ({ ...prev, ...data }));
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
// 表单验证
|
||||||
|
if (!formData.name.trim()) {
|
||||||
|
message.error("请输入任务名称");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formData.deviceGroups.length === 0) {
|
||||||
|
message.error("请选择设备");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.num || formData.num <= 0) {
|
||||||
|
message.error("请输入有效的分配数量");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证开始时间不得大于结束时间
|
||||||
|
if (formData.startTime && formData.endTime) {
|
||||||
|
if (formData.startTime.isAfter(formData.endTime)) {
|
||||||
|
message.error("开始时间不得大于结束时间");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const submitData: Partial<Allocation> = {
|
||||||
|
name: formData.name,
|
||||||
|
status: formData.status,
|
||||||
|
type: formData.type,
|
||||||
|
workbenchId: formData.workbenchId,
|
||||||
|
deviceGroups: formData.deviceGroups,
|
||||||
|
pools: JSON.parse(JSON.stringify(formData.pools)),
|
||||||
|
num: formData.num,
|
||||||
|
clearContact: formData.clearContact,
|
||||||
|
remarkType: formData.remarkType,
|
||||||
|
remark: formData.remark || null,
|
||||||
|
startTime: formData.startTime?.format("HH:mm") || null,
|
||||||
|
endTime: formData.endTime?.format("HH:mm") || null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isEdit && id) {
|
||||||
|
await updateContactImportTask({
|
||||||
|
...submitData,
|
||||||
|
id: Number(id),
|
||||||
|
} as Allocation);
|
||||||
|
message.success("更新成功");
|
||||||
|
} else {
|
||||||
|
await createContactImportTask(submitData as Allocation);
|
||||||
|
message.success("创建成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
navigate("/workspace/contact-import/list");
|
||||||
|
} catch (error) {
|
||||||
|
message.error(isEdit ? "更新失败" : "创建失败");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置表单
|
||||||
|
const handleReset = () => {
|
||||||
|
setFormData({
|
||||||
|
name: "",
|
||||||
|
status: 1,
|
||||||
|
type: 6,
|
||||||
|
workbenchId: 1,
|
||||||
|
deviceGroups: [],
|
||||||
|
pools: [],
|
||||||
|
num: 50,
|
||||||
|
clearContact: 0,
|
||||||
|
remarkType: 0,
|
||||||
|
remark: "",
|
||||||
|
startTime: dayjs("09:00", "HH:mm"),
|
||||||
|
endTime: dayjs("21:00", "HH:mm"),
|
||||||
|
deviceGroupsOptions: [],
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEdit) {
|
||||||
|
loadTaskDetail();
|
||||||
|
}
|
||||||
|
}, [id, isEdit]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
header={<NavCommon title={isEdit ? "编辑导入任务" : "新建导入任务"} />}
|
||||||
|
footer={
|
||||||
|
<div className={style.buttonGroup}>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
size="large"
|
||||||
|
loading={loading}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
className={style.submitButton}
|
||||||
|
>
|
||||||
|
{isEdit ? "更新" : "创建"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
onClick={handleReset}
|
||||||
|
className={style.resetButton}
|
||||||
|
>
|
||||||
|
重置
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
loading={loading}
|
||||||
|
>
|
||||||
|
<div className={style.formBg}>
|
||||||
|
<div className={style.basicSection}>
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>任务名称</div>
|
||||||
|
<Input
|
||||||
|
placeholder="请输入任务名称"
|
||||||
|
value={formData.name}
|
||||||
|
onChange={e => handleUpdateFormData({ name: e.target.value })}
|
||||||
|
className={style.input}
|
||||||
|
/>
|
||||||
|
<div className={style.counterTip}>为此导入任务设置一个名称</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>设备选择</div>
|
||||||
|
<DeviceSelection
|
||||||
|
selectedOptions={formData.deviceGroupsOptions}
|
||||||
|
onSelect={handleDeviceSelect}
|
||||||
|
placeholder="请选择设备"
|
||||||
|
className={style.deviceSelection}
|
||||||
|
/>
|
||||||
|
<div className={style.counterTip}>选择要分配联系人的设备</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>分配数量</div>
|
||||||
|
<div className={style.stepperContainer}>
|
||||||
|
<Button
|
||||||
|
icon={<MinusOutlined />}
|
||||||
|
onClick={() =>
|
||||||
|
handleUpdateFormData({ num: Math.max(1, formData.num - 1) })
|
||||||
|
}
|
||||||
|
disabled={formData.num <= 1}
|
||||||
|
className={style.stepperButton}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
value={formData.num}
|
||||||
|
onChange={e => {
|
||||||
|
const value = parseInt(e.target.value) || 1;
|
||||||
|
handleUpdateFormData({
|
||||||
|
num: Math.min(1000, Math.max(1, value)),
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
className={style.stepperInput}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon={<PlusOutlined />}
|
||||||
|
onClick={() =>
|
||||||
|
handleUpdateFormData({
|
||||||
|
num: Math.min(1000, formData.num + 1),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
disabled={formData.num >= 1000}
|
||||||
|
className={style.stepperButton}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={style.counterTip}>要分配给设备的联系人数量</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>清除现有联系人</div>
|
||||||
|
<Switch
|
||||||
|
checked={formData.clearContact === 1}
|
||||||
|
onChange={checked =>
|
||||||
|
handleUpdateFormData({ clearContact: checked ? 1 : 0 })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div className={style.counterTip}>是否清除设备上现有的联系人</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>备注类型</div>
|
||||||
|
<Select
|
||||||
|
placeholder="请选择备注类型"
|
||||||
|
value={formData.remarkType}
|
||||||
|
onChange={value => handleUpdateFormData({ remarkType: value })}
|
||||||
|
className={style.select}
|
||||||
|
>
|
||||||
|
<Select.Option value={0}>不备注</Select.Option>
|
||||||
|
<Select.Option value={1}>年月日</Select.Option>
|
||||||
|
<Select.Option value={2}>月日</Select.Option>
|
||||||
|
<Select.Option value={3}>自定义</Select.Option>
|
||||||
|
</Select>
|
||||||
|
<div className={style.counterTip}>选择联系人备注的格式</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{formData.remarkType === 3 && (
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>自定义备注</div>
|
||||||
|
<Input
|
||||||
|
placeholder="请输入备注内容"
|
||||||
|
value={formData.remark}
|
||||||
|
onChange={e => handleUpdateFormData({ remark: e.target.value })}
|
||||||
|
className={style.input}
|
||||||
|
/>
|
||||||
|
<div className={style.counterTip}>输入自定义的备注内容</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>开始时间</div>
|
||||||
|
<TimePicker
|
||||||
|
value={formData.startTime}
|
||||||
|
onChange={time =>
|
||||||
|
handleUpdateFormData({
|
||||||
|
startTime: time,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
format="HH:mm"
|
||||||
|
placeholder="请选择开始时间"
|
||||||
|
className={style.timePicker}
|
||||||
|
/>
|
||||||
|
<div className={style.counterTip}>设置每天开始导入的时间</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={style.formItem}>
|
||||||
|
<div className={style.formLabel}>结束时间</div>
|
||||||
|
<TimePicker
|
||||||
|
value={formData.endTime}
|
||||||
|
onChange={time =>
|
||||||
|
handleUpdateFormData({
|
||||||
|
endTime: time,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
format="HH:mm"
|
||||||
|
placeholder="请选择结束时间"
|
||||||
|
className={style.timePicker}
|
||||||
|
/>
|
||||||
|
<div className={style.counterTip}>设置每天结束导入的时间</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={style.formItem}
|
||||||
|
style={{ display: "flex", justifyContent: "space-between" }}
|
||||||
|
>
|
||||||
|
<span>是否启用</span>
|
||||||
|
<Switch
|
||||||
|
checked={formData.status === 1}
|
||||||
|
onChange={check =>
|
||||||
|
handleUpdateFormData({ status: check ? 1 : 0 })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ContactImportForm;
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import request from "@/api/request";
|
||||||
|
import {
|
||||||
|
ContactImportTask,
|
||||||
|
CreateContactImportTaskData,
|
||||||
|
UpdateContactImportTaskData,
|
||||||
|
ContactImportRecord,
|
||||||
|
PaginatedResponse,
|
||||||
|
ImportStats,
|
||||||
|
} from "./data";
|
||||||
|
|
||||||
|
// 获取通讯录导入任务列表
|
||||||
|
export function fetchContactImportTasks(
|
||||||
|
params = { type: 6, page: 1, limit: 10 },
|
||||||
|
) {
|
||||||
|
return request("/v1/workbench/list", params, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取单个任务详情
|
||||||
|
export function fetchContactImportTaskDetail(
|
||||||
|
id: number,
|
||||||
|
): Promise<ContactImportTask | null> {
|
||||||
|
return request("/v1/workbench/detail", { id }, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建通讯录导入任务
|
||||||
|
export function createContactImportTask(
|
||||||
|
data: CreateContactImportTaskData,
|
||||||
|
): Promise<any> {
|
||||||
|
return request("/v1/workbench/create", { ...data, type: 6 }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新通讯录导入任务
|
||||||
|
export function updateContactImportTask(
|
||||||
|
data: UpdateContactImportTaskData,
|
||||||
|
): Promise<any> {
|
||||||
|
return request("/v1/workbench/update", { ...data, type: 6 }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除通讯录导入任务
|
||||||
|
export function deleteContactImportTask(id: number): Promise<any> {
|
||||||
|
return request("/v1/workbench/delete", { id }, "DELETE");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 切换任务状态
|
||||||
|
export function toggleContactImportTask(data: {
|
||||||
|
id: number;
|
||||||
|
status: number;
|
||||||
|
}): Promise<any> {
|
||||||
|
return request("/v1/workbench/update-status", { ...data }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制通讯录导入任务
|
||||||
|
export function copyContactImportTask(id: number): Promise<any> {
|
||||||
|
return request("/v1/workbench/copy", { id }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取导入记录
|
||||||
|
export function fetchImportRecords(
|
||||||
|
workbenchId: number,
|
||||||
|
page: number = 1,
|
||||||
|
limit: number = 20,
|
||||||
|
keyword?: string,
|
||||||
|
): Promise<PaginatedResponse<ContactImportRecord>> {
|
||||||
|
return request(
|
||||||
|
"/v1/workbench/import-records",
|
||||||
|
{
|
||||||
|
workbenchId,
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
keyword,
|
||||||
|
},
|
||||||
|
"GET",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取统计数据
|
||||||
|
export function fetchImportStats(): Promise<ImportStats> {
|
||||||
|
return request("/v1/workbench/import-stats", {}, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取设备组列表
|
||||||
|
export function fetchDeviceGroups(): Promise<any[]> {
|
||||||
|
return request("/v1/device/groups", {}, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 手动触发导入
|
||||||
|
export function triggerImport(taskId: number): Promise<any> {
|
||||||
|
return request("/v1/workbench/trigger-import", { taskId }, "POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量操作任务
|
||||||
|
export function batchOperateTasks(data: {
|
||||||
|
taskIds: number[];
|
||||||
|
operation: "start" | "stop" | "delete";
|
||||||
|
}): Promise<any> {
|
||||||
|
return request("/v1/workbench/batch-operate", data, "POST");
|
||||||
|
}
|
||||||
131
Cunkebao/src/pages/mobile/workspace/contact-import/list/data.ts
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
// 通讯录导入任务状态
|
||||||
|
export type ContactImportTaskStatus = 1 | 2; // 1: 开启, 2: 关闭
|
||||||
|
|
||||||
|
// 设备组信息
|
||||||
|
export interface DeviceGroup {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
deviceCount: number;
|
||||||
|
status: "online" | "offline";
|
||||||
|
lastActive: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通讯录导入记录
|
||||||
|
export interface ContactImportRecord {
|
||||||
|
id: string;
|
||||||
|
workbenchId: string;
|
||||||
|
wechatAccountId: string;
|
||||||
|
deviceId: string;
|
||||||
|
num: number;
|
||||||
|
clientId: string;
|
||||||
|
remarkType: string;
|
||||||
|
remarkValue: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
createTime: string;
|
||||||
|
operatorName: string;
|
||||||
|
operatorAvatar: string;
|
||||||
|
deviceName: string;
|
||||||
|
importStatus: "success" | "failed" | "pending";
|
||||||
|
errorMessage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通讯录导入任务配置
|
||||||
|
export interface ContactImportTaskConfig {
|
||||||
|
id: number;
|
||||||
|
workbenchId: number;
|
||||||
|
devices: number[];
|
||||||
|
pools: number[];
|
||||||
|
num: number;
|
||||||
|
clearContact: number;
|
||||||
|
remarkType: number;
|
||||||
|
remark: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
createTime: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通讯录导入任务
|
||||||
|
export interface ContactImportTask {
|
||||||
|
id: number;
|
||||||
|
companyId: number;
|
||||||
|
name: string;
|
||||||
|
type: number;
|
||||||
|
status: ContactImportTaskStatus;
|
||||||
|
autoStart: number;
|
||||||
|
userId: number;
|
||||||
|
createTime: string;
|
||||||
|
updateTime: string;
|
||||||
|
config: ContactImportTaskConfig;
|
||||||
|
creatorName: string;
|
||||||
|
auto_like: any;
|
||||||
|
moments_sync: any;
|
||||||
|
traffic_config: any;
|
||||||
|
group_push: any;
|
||||||
|
group_create: any;
|
||||||
|
// 计算属性,用于向后兼容
|
||||||
|
deviceGroups?: string[];
|
||||||
|
todayImportCount?: number;
|
||||||
|
totalImportCount?: number;
|
||||||
|
maxImportsPerDay?: number;
|
||||||
|
importInterval?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建通讯录导入任务数据
|
||||||
|
export interface CreateContactImportTaskData {
|
||||||
|
name: string;
|
||||||
|
type: number;
|
||||||
|
config: {
|
||||||
|
devices: number[];
|
||||||
|
pools: number[];
|
||||||
|
num: number;
|
||||||
|
clearContact: number;
|
||||||
|
remarkType: number;
|
||||||
|
remark: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新通讯录导入任务数据
|
||||||
|
export interface UpdateContactImportTaskData
|
||||||
|
extends CreateContactImportTaskData {
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 任务配置
|
||||||
|
export interface TaskConfig {
|
||||||
|
deviceGroups: string[];
|
||||||
|
num: number;
|
||||||
|
clientId: string;
|
||||||
|
remarkType: string;
|
||||||
|
remarkValue: string;
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
|
maxImportsPerDay: number;
|
||||||
|
importInterval: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// API响应
|
||||||
|
export interface ApiResponse<T = any> {
|
||||||
|
code: number;
|
||||||
|
msg: string;
|
||||||
|
data: T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页响应
|
||||||
|
export interface PaginatedResponse<T> {
|
||||||
|
list: T[];
|
||||||
|
total: number;
|
||||||
|
page: number;
|
||||||
|
limit: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统计数据
|
||||||
|
export interface ImportStats {
|
||||||
|
totalTasks: number;
|
||||||
|
activeTasks: number;
|
||||||
|
todayImports: number;
|
||||||
|
totalImports: number;
|
||||||
|
successRate: number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,241 @@
|
|||||||
|
.container {
|
||||||
|
padding: 0 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding: 12px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchBox {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
:global(.ant-input-affix-wrapper) {
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
border-color: #40a9ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:focus-within {
|
||||||
|
border-color: #1890ff;
|
||||||
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
:global(.adm-button) {
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskList {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 40px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 60px 20px;
|
||||||
|
text-align: center;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.emptyIcon {
|
||||||
|
font-size: 48px;
|
||||||
|
color: #d9d9d9;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emptyText {
|
||||||
|
color: #666;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskCard {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.adm-card-body) {
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardHeader {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskInfo {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskName {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskStatus {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background-color: rgba(82, 196, 26, 0.1);
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardMenu {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuButton {
|
||||||
|
padding: 4px 8px;
|
||||||
|
color: #666;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #1890ff;
|
||||||
|
background-color: #f0f8ff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuDropdown {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
right: 0;
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #d9d9d9;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
|
z-index: 1000;
|
||||||
|
min-width: 100px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
color: #ff4d4f;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #fff2f0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardContent {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskDetail {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
color: #666;
|
||||||
|
margin-right: 8px;
|
||||||
|
min-width: 70px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
color: #333;
|
||||||
|
flex: 1;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardActions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
padding-top: 12px;
|
||||||
|
border-top: 1px solid #f0f0f0;
|
||||||
|
|
||||||
|
:global(.adm-button) {
|
||||||
|
flex: 1;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 响应式设计
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.toolbar {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskName {
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.taskDetail {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
min-width: 60px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,345 @@
|
|||||||
|
import React, { useState, useEffect, useRef } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { Button, Toast, SpinLoading, Dialog, Card } from "antd-mobile";
|
||||||
|
import NavCommon from "@/components/NavCommon";
|
||||||
|
import { Input } from "antd";
|
||||||
|
import {
|
||||||
|
PlusOutlined,
|
||||||
|
CopyOutlined,
|
||||||
|
DeleteOutlined,
|
||||||
|
SearchOutlined,
|
||||||
|
ReloadOutlined,
|
||||||
|
EyeOutlined,
|
||||||
|
EditOutlined,
|
||||||
|
MoreOutlined,
|
||||||
|
ContactsOutlined,
|
||||||
|
} from "@ant-design/icons";
|
||||||
|
|
||||||
|
import Layout from "@/components/Layout/Layout";
|
||||||
|
import {
|
||||||
|
fetchContactImportTasks,
|
||||||
|
deleteContactImportTask,
|
||||||
|
toggleContactImportTask,
|
||||||
|
copyContactImportTask,
|
||||||
|
} from "./api";
|
||||||
|
import { ContactImportTask } from "./data";
|
||||||
|
import style from "./index.module.scss";
|
||||||
|
|
||||||
|
// 卡片菜单组件
|
||||||
|
interface CardMenuProps {
|
||||||
|
onView: () => void;
|
||||||
|
onEdit: () => void;
|
||||||
|
onCopy: () => void;
|
||||||
|
onDelete: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CardMenu: React.FC<CardMenuProps> = ({
|
||||||
|
onView,
|
||||||
|
onEdit,
|
||||||
|
onCopy,
|
||||||
|
onDelete,
|
||||||
|
}) => {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const menuRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function handleClickOutside(event: MouseEvent) {
|
||||||
|
if (menuRef.current && !menuRef.current.contains(event.target as Node)) {
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("mousedown", handleClickOutside);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("mousedown", handleClickOutside);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={style.cardMenu} ref={menuRef}>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
fill="none"
|
||||||
|
onClick={() => setOpen(!open)}
|
||||||
|
className={style.menuButton}
|
||||||
|
>
|
||||||
|
<MoreOutlined />
|
||||||
|
</Button>
|
||||||
|
{open && (
|
||||||
|
<div className={style.menuDropdown}>
|
||||||
|
<div className={style.menuItem} onClick={onView}>
|
||||||
|
<EyeOutlined /> 查看
|
||||||
|
</div>
|
||||||
|
<div className={style.menuItem} onClick={onEdit}>
|
||||||
|
<EditOutlined /> 编辑
|
||||||
|
</div>
|
||||||
|
<div className={style.menuItem} onClick={onCopy}>
|
||||||
|
<CopyOutlined /> 复制
|
||||||
|
</div>
|
||||||
|
<div className={style.menuItem} onClick={onDelete}>
|
||||||
|
<DeleteOutlined /> 删除
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const ContactImport: React.FC = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [tasks, setTasks] = useState<ContactImportTask[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [searchKeyword, setSearchKeyword] = useState("");
|
||||||
|
const [filteredTasks, setFilteredTasks] = useState<ContactImportTask[]>([]);
|
||||||
|
|
||||||
|
// 获取任务列表
|
||||||
|
const loadTasks = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await fetchContactImportTasks();
|
||||||
|
const data = response?.list || [];
|
||||||
|
setTasks(data);
|
||||||
|
setFilteredTasks(data);
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "获取任务列表失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 搜索过滤
|
||||||
|
const handleSearch = (keyword: string) => {
|
||||||
|
setSearchKeyword(keyword);
|
||||||
|
if (!keyword.trim()) {
|
||||||
|
setFilteredTasks(tasks);
|
||||||
|
} else {
|
||||||
|
const filtered = tasks.filter(
|
||||||
|
task =>
|
||||||
|
task.name.toLowerCase().includes(keyword.toLowerCase()) ||
|
||||||
|
(task.config?.remark || "")
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(keyword.toLowerCase()) ||
|
||||||
|
task.creatorName.toLowerCase().includes(keyword.toLowerCase()),
|
||||||
|
);
|
||||||
|
setFilteredTasks(filtered);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除任务
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
const result = await Dialog.confirm({
|
||||||
|
content: "确定要删除这个通讯录导入任务吗?",
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
try {
|
||||||
|
await deleteContactImportTask(id);
|
||||||
|
Toast.show({
|
||||||
|
content: "删除成功",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
loadTasks();
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "删除失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 切换任务状态
|
||||||
|
const handleToggleStatus = async (task: ContactImportTask) => {
|
||||||
|
try {
|
||||||
|
await toggleContactImportTask({
|
||||||
|
id: task.id,
|
||||||
|
status: task.status === 1 ? 2 : 1,
|
||||||
|
});
|
||||||
|
Toast.show({
|
||||||
|
content: task.status === 1 ? "任务已暂停" : "任务已启动",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
loadTasks();
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "操作失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 复制任务
|
||||||
|
const handleCopy = async (id: number) => {
|
||||||
|
try {
|
||||||
|
await copyContactImportTask(id);
|
||||||
|
Toast.show({
|
||||||
|
content: "复制成功",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
loadTasks();
|
||||||
|
} catch (error) {
|
||||||
|
Toast.show({
|
||||||
|
content: "复制失败",
|
||||||
|
icon: "fail",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 查看详情
|
||||||
|
const handleView = (id: number) => {
|
||||||
|
navigate(`/workspace/contact-import/detail/${id}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 编辑任务
|
||||||
|
const handleEdit = (id: number) => {
|
||||||
|
navigate(`/workspace/contact-import/form/${id}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化状态文本
|
||||||
|
const getStatusText = (status: number) => {
|
||||||
|
return status === 1 ? "运行中" : "已暂停";
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化状态颜色
|
||||||
|
const getStatusColor = (status: number) => {
|
||||||
|
return status === 1 ? "#52c41a" : "#faad14";
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadTasks();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
header={
|
||||||
|
<>
|
||||||
|
<NavCommon
|
||||||
|
backFn={() => navigate("/workspace")}
|
||||||
|
title="通讯录导入"
|
||||||
|
right={
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => navigate("/workspace/contact-import/form")}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 新建
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{/* 搜索栏 */}
|
||||||
|
<div className="search-bar">
|
||||||
|
<div className="search-input-wrapper">
|
||||||
|
<Input
|
||||||
|
placeholder="搜索计划名称"
|
||||||
|
value={searchKeyword}
|
||||||
|
onChange={e => setSearchKeyword(e.target.value)}
|
||||||
|
prefix={<SearchOutlined />}
|
||||||
|
allowClear
|
||||||
|
size="large"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => handleSearch(searchKeyword)}
|
||||||
|
loading={loading}
|
||||||
|
className="refresh-btn"
|
||||||
|
>
|
||||||
|
<ReloadOutlined />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className={style.container}>
|
||||||
|
{/* 任务列表 */}
|
||||||
|
<div className={style.taskList}>
|
||||||
|
{loading ? (
|
||||||
|
<div className={style.loading}>
|
||||||
|
<SpinLoading /> 加载中...
|
||||||
|
</div>
|
||||||
|
) : filteredTasks.length === 0 ? (
|
||||||
|
<div className={style.empty}>
|
||||||
|
<ContactsOutlined className={style.emptyIcon} />
|
||||||
|
<div className={style.emptyText}>
|
||||||
|
{searchKeyword ? "未找到相关任务" : "暂无通讯录导入任务"}
|
||||||
|
</div>
|
||||||
|
{!searchKeyword && (
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
size="small"
|
||||||
|
onClick={() => navigate("/workspace/contact-import/form")}
|
||||||
|
>
|
||||||
|
<PlusOutlined /> 创建第一个任务
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
filteredTasks.map(task => (
|
||||||
|
<Card key={task.id} className={style.taskCard}>
|
||||||
|
<div className={style.cardHeader}>
|
||||||
|
<div className={style.taskInfo}>
|
||||||
|
<div className={style.taskName}>{task.name}</div>
|
||||||
|
<div
|
||||||
|
className={style.taskStatus}
|
||||||
|
style={{ color: getStatusColor(task.status) }}
|
||||||
|
>
|
||||||
|
{getStatusText(task.status)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<CardMenu
|
||||||
|
onView={() => handleView(task.id)}
|
||||||
|
onEdit={() => handleEdit(task.id)}
|
||||||
|
onCopy={() => handleCopy(task.id)}
|
||||||
|
onDelete={() => handleDelete(task.id)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={style.cardContent}>
|
||||||
|
<div className={style.taskDetail}>
|
||||||
|
<span className={style.label}>备注类型:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.config?.remarkType === 1 ? "自定义备注" : "其他"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.taskDetail}>
|
||||||
|
<span className={style.label}>设备数量:</span>
|
||||||
|
<span className={style.value}>
|
||||||
|
{task.config?.devices?.length || 0}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.taskDetail}>
|
||||||
|
<span className={style.label}>导入数量:</span>
|
||||||
|
<span className={style.value}>{task.config?.num || 0}</span>
|
||||||
|
</div>
|
||||||
|
<div className={style.taskDetail}>
|
||||||
|
<span className={style.label}>创建时间:</span>
|
||||||
|
<span className={style.value}>{task.createTime}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={style.cardActions}>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
fill="none"
|
||||||
|
onClick={() => handleToggleStatus(task)}
|
||||||
|
>
|
||||||
|
{task.status === 1 ? "暂停" : "启动"}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
fill="none"
|
||||||
|
onClick={() => handleView(task.id)}
|
||||||
|
>
|
||||||
|
查看记录
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ContactImport;
|
||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
TeamOutlined,
|
TeamOutlined,
|
||||||
LinkOutlined,
|
LinkOutlined,
|
||||||
ClockCircleOutlined,
|
ClockCircleOutlined,
|
||||||
|
ContactsOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import Layout from "@/components/Layout/Layout";
|
import Layout from "@/components/Layout/Layout";
|
||||||
import MeauMobile from "@/components/MeauMobile/MeauMoible";
|
import MeauMobile from "@/components/MeauMobile/MeauMoible";
|
||||||
@@ -69,6 +70,17 @@ const Workspace: React.FC = () => {
|
|||||||
path: "/workspace/traffic-distribution",
|
path: "/workspace/traffic-distribution",
|
||||||
bgColor: "#e6f7ff",
|
bgColor: "#e6f7ff",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "contact-import",
|
||||||
|
name: "通讯录导入",
|
||||||
|
description: "批量导入通讯录联系人",
|
||||||
|
icon: (
|
||||||
|
<ContactsOutlined className={styles.icon} style={{ color: "#722ed1" }} />
|
||||||
|
),
|
||||||
|
path: "/workspace/contact-import/list",
|
||||||
|
bgColor: "#f9f0ff",
|
||||||
|
isNew: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const defaultForm = {
|
|||||||
syncType: 1, // 1=业务号 2=人设号
|
syncType: 1, // 1=业务号 2=人设号
|
||||||
accountType: "business" as "business" | "personal", // 仅UI用
|
accountType: "business" as "business" | "personal", // 仅UI用
|
||||||
enabled: true,
|
enabled: true,
|
||||||
deveiceGroups: [] as any[],
|
deviceGroups: [] as any[],
|
||||||
contentGroups: [] as any[], // 存完整内容库对象数组
|
contentGroups: [] as any[], // 存完整内容库对象数组
|
||||||
contentTypes: ["text", "image", "video"],
|
contentTypes: ["text", "image", "video"],
|
||||||
targetTags: [] as string[],
|
targetTags: [] as string[],
|
||||||
@@ -47,7 +47,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
const [currentStep, setCurrentStep] = useState(0);
|
const [currentStep, setCurrentStep] = useState(0);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [formData, setFormData] = useState({ ...defaultForm });
|
const [formData, setFormData] = useState({ ...defaultForm });
|
||||||
const [deveiceGroupsOptions, setSelectedDevicesOptions] = useState<
|
const [deviceGroupsOptions, setSelectedDevicesOptions] = useState<
|
||||||
DeviceSelectionItem[]
|
DeviceSelectionItem[]
|
||||||
>([]);
|
>([]);
|
||||||
const [contentGroupsOptions, setContentGroupsOptions] = useState<
|
const [contentGroupsOptions, setContentGroupsOptions] = useState<
|
||||||
@@ -70,14 +70,14 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
syncType: res.accountType === 1 ? 1 : 2,
|
syncType: res.accountType === 1 ? 1 : 2,
|
||||||
accountType: res.accountType === 1 ? "business" : "personal",
|
accountType: res.accountType === 1 ? "business" : "personal",
|
||||||
enabled: res.status === 1,
|
enabled: res.status === 1,
|
||||||
deveiceGroups: res.config?.deveiceGroups || [],
|
deviceGroups: res.config?.deviceGroups || [],
|
||||||
// 关键:用id字符串数组回填
|
// 关键:用id字符串数组回填
|
||||||
contentGroups: res.config?.contentGroups || [], // 直接用对象数组
|
contentGroups: res.config?.contentGroups || [], // 直接用对象数组
|
||||||
contentTypes: res.config?.contentTypes || ["text", "image", "video"],
|
contentTypes: res.config?.contentTypes || ["text", "image", "video"],
|
||||||
targetTags: res.config?.targetTags || [],
|
targetTags: res.config?.targetTags || [],
|
||||||
filterKeywords: res.config?.filterKeywords || [],
|
filterKeywords: res.config?.filterKeywords || [],
|
||||||
});
|
});
|
||||||
setSelectedDevicesOptions(res.config?.deveiceGroupsOptions || []);
|
setSelectedDevicesOptions(res.config?.deviceGroupsOptions || []);
|
||||||
setContentGroupsOptions(res.config?.contentGroupsOptions || []);
|
setContentGroupsOptions(res.config?.contentGroupsOptions || []);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
@@ -110,7 +110,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
};
|
};
|
||||||
const handleDevicesChange = (devices: DeviceSelectionItem[]) => {
|
const handleDevicesChange = (devices: DeviceSelectionItem[]) => {
|
||||||
setSelectedDevicesOptions(devices);
|
setSelectedDevicesOptions(devices);
|
||||||
updateForm({ deveiceGroups: devices.map(d => d.id) });
|
updateForm({ deviceGroups: devices.map(d => d.id) });
|
||||||
};
|
};
|
||||||
const handleContentChange = (libs: ContentItem[]) => {
|
const handleContentChange = (libs: ContentItem[]) => {
|
||||||
setContentGroupsOptions(libs);
|
setContentGroupsOptions(libs);
|
||||||
@@ -122,7 +122,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
message.error("请输入任务名称");
|
message.error("请输入任务名称");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (formData.deveiceGroups.length === 0) {
|
if (formData.deviceGroups.length === 0) {
|
||||||
message.error("请选择设备");
|
message.error("请选择设备");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
name: formData.taskName,
|
name: formData.taskName,
|
||||||
deveiceGroups: formData.deveiceGroups,
|
deviceGroups: formData.deviceGroups,
|
||||||
contentGroups: formData.contentGroups.map((lib: any) => lib.id),
|
contentGroups: formData.contentGroups.map((lib: any) => lib.id),
|
||||||
syncInterval: formData.syncInterval,
|
syncInterval: formData.syncInterval,
|
||||||
syncCount: formData.syncCount,
|
syncCount: formData.syncCount,
|
||||||
@@ -260,7 +260,7 @@ const NewMomentsSync: React.FC = () => {
|
|||||||
<div className={style.formItem}>
|
<div className={style.formItem}>
|
||||||
<div className={style.formLabel}>选择设备</div>
|
<div className={style.formLabel}>选择设备</div>
|
||||||
<DeviceSelection
|
<DeviceSelection
|
||||||
selectedOptions={deveiceGroupsOptions}
|
selectedOptions={deviceGroupsOptions}
|
||||||
onSelect={handleDevicesChange}
|
onSelect={handleDevicesChange}
|
||||||
placeholder="请选择设备"
|
placeholder="请选择设备"
|
||||||
showSelectedList={true}
|
showSelectedList={true}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const DeviceListModal: React.FC<DeviceListModalProps> = ({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const detailRes = await fetchDistributionRuleDetail(ruleId);
|
const detailRes = await fetchDistributionRuleDetail(ruleId);
|
||||||
const deviceData = detailRes?.config?.deveiceGroupsOptions || [];
|
const deviceData = detailRes?.config?.deviceGroupsOptions || [];
|
||||||
setDevices(deviceData);
|
setDevices(deviceData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取设备详情失败:", error);
|
console.error("获取设备详情失败:", error);
|
||||||
|
|||||||
@@ -43,33 +43,91 @@
|
|||||||
.headerRight {
|
.headerRight {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.userInfo {
|
.userInfo {
|
||||||
cursor: pointer;
|
display: flex;
|
||||||
padding: 8px 12px;
|
align-items: center;
|
||||||
border-radius: 6px;
|
gap: 16px;
|
||||||
transition: all 0.3s;
|
padding: 8px 0;
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
}
|
|
||||||
.suanli {
|
.suanli {
|
||||||
font-size: 16px;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 14px;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 6px 12px;
|
||||||
|
background: #f8f9fa;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid #e9ecef;
|
||||||
|
|
||||||
.suanliIcon {
|
.suanliIcon {
|
||||||
font-size: 24px;
|
font-size: 16px;
|
||||||
|
color: #ffc107;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.messageButton {
|
||||||
border: 2px solid #f0f0f0;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: 50%;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
|
border: 1px solid #e9ecef;
|
||||||
|
background: #fff;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
background-color: #f8f9fa;
|
||||||
border-color: #1890ff;
|
border-color: #1890ff;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.anticon {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.userSection {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 24px;
|
||||||
|
transition: all 0.3s;
|
||||||
|
border: 1px solid #e9ecef;
|
||||||
|
background: #fff;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
border-color: #1890ff;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.userNickname {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
font-weight: 600;
|
||||||
|
max-width: 100px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
border: 2px solid #e9ecef;
|
||||||
|
transition: all 0.3s;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.username {
|
.username {
|
||||||
|
|||||||
@@ -13,7 +13,48 @@ import {
|
|||||||
|
|
||||||
//读取聊天信息
|
//读取聊天信息
|
||||||
//kf.quwanzhi.com:9991/api/WechatFriend/clearUnreadCount
|
//kf.quwanzhi.com:9991/api/WechatFriend/clearUnreadCount
|
||||||
|
function jsonToQueryString(json) {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
for (const key in json) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(json, key)) {
|
||||||
|
params.append(key, json[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return params.toString();
|
||||||
|
}
|
||||||
|
//转移客户
|
||||||
|
export function WechatFriendAllot(params: {
|
||||||
|
wechatFriendId?: number;
|
||||||
|
wechatChatroomId?: number;
|
||||||
|
toAccountId: number;
|
||||||
|
notifyReceiver: boolean;
|
||||||
|
comment: string;
|
||||||
|
}) {
|
||||||
|
return request(
|
||||||
|
"/api/wechatFriend/allot?" + jsonToQueryString(params),
|
||||||
|
undefined,
|
||||||
|
"PUT",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取可转移客服列表
|
||||||
|
export function getTransferableAgentList() {
|
||||||
|
return request("/api/account/myDepartmentAccountsForTransfer", {}, "GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信好友列表
|
||||||
|
export function WechatFriendRebackAllot(params: {
|
||||||
|
wechatFriendId?: number;
|
||||||
|
wechatChatroomId?: number;
|
||||||
|
}) {
|
||||||
|
return request(
|
||||||
|
"/api/wechatFriend/rebackAllot?" + jsonToQueryString(params),
|
||||||
|
undefined,
|
||||||
|
"PUT",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信群列表
|
||||||
export function WechatGroup(params) {
|
export function WechatGroup(params) {
|
||||||
return request("/api/WechatGroup/list", params, "GET");
|
return request("/api/WechatGroup/list", params, "GET");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { Button, Modal, Input, DatePicker, message } from "antd";
|
||||||
|
import { MessageOutlined } from "@ant-design/icons";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { useWeChatStore } from "@/store/module/weChat/weChat";
|
||||||
|
|
||||||
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
|
interface ChatRecordProps {
|
||||||
|
className?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ChatRecord: React.FC<ChatRecordProps> = ({
|
||||||
|
className,
|
||||||
|
disabled = false,
|
||||||
|
}) => {
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [searchContent, setSearchContent] = useState<string>("");
|
||||||
|
const [dateRange, setDateRange] = useState<[dayjs.Dayjs, dayjs.Dayjs] | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const SearchMessage = useWeChatStore(state => state.SearchMessage);
|
||||||
|
|
||||||
|
// 打开弹窗
|
||||||
|
const openModal = () => {
|
||||||
|
setVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 关闭弹窗并重置状态
|
||||||
|
const closeModal = () => {
|
||||||
|
setVisible(false);
|
||||||
|
setSearchContent("");
|
||||||
|
setDateRange(null);
|
||||||
|
setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 执行查找
|
||||||
|
const handleSearch = async () => {
|
||||||
|
if (!dateRange) {
|
||||||
|
message.warning("请选择时间范围");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const [From, To] = dateRange;
|
||||||
|
const searchData = {
|
||||||
|
From: From.unix() * 1000,
|
||||||
|
To: To.unix() * 1000,
|
||||||
|
keyword: searchContent.trim(),
|
||||||
|
};
|
||||||
|
await SearchMessage(searchData);
|
||||||
|
|
||||||
|
message.success("查找完成");
|
||||||
|
closeModal();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("查找失败:", error);
|
||||||
|
message.error("查找失败,请重试");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={className}
|
||||||
|
onClick={openModal}
|
||||||
|
style={{
|
||||||
|
cursor: disabled ? "not-allowed" : "pointer",
|
||||||
|
opacity: disabled ? 0.5 : 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MessageOutlined />
|
||||||
|
聊天记录
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="查找聊天记录"
|
||||||
|
open={visible}
|
||||||
|
onCancel={closeModal}
|
||||||
|
width={450}
|
||||||
|
centered
|
||||||
|
maskClosable={!loading}
|
||||||
|
footer={[
|
||||||
|
<div
|
||||||
|
key="footer"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={closeModal}
|
||||||
|
disabled={loading}
|
||||||
|
style={{ marginRight: "8px" }}
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
<Button type="primary" loading={loading} onClick={handleSearch}>
|
||||||
|
查找
|
||||||
|
</Button>
|
||||||
|
</div>,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<div style={{ padding: "20px 0" }}>
|
||||||
|
{/* 时间范围选择 */}
|
||||||
|
<div style={{ marginBottom: "20px" }}>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "8px", fontSize: "14px", color: "#333" }}
|
||||||
|
>
|
||||||
|
时间范围
|
||||||
|
</div>
|
||||||
|
<RangePicker
|
||||||
|
value={dateRange}
|
||||||
|
onChange={setDateRange}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
size="large"
|
||||||
|
disabled={loading}
|
||||||
|
placeholder={["开始日期", "结束日期"]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 查找内容输入 */}
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "8px", fontSize: "14px", color: "#333" }}
|
||||||
|
>
|
||||||
|
查找内容
|
||||||
|
</div>
|
||||||
|
<Input
|
||||||
|
placeholder="请输入要查找的关键词或内容"
|
||||||
|
value={searchContent}
|
||||||
|
onChange={e => setSearchContent(e.target.value)}
|
||||||
|
size="large"
|
||||||
|
maxLength={100}
|
||||||
|
showCount
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ChatRecord;
|
||||||
@@ -0,0 +1,253 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { Button, Modal, Select, Input, message } from "antd";
|
||||||
|
import { ShareAltOutlined } from "@ant-design/icons";
|
||||||
|
import {
|
||||||
|
getTransferableAgentList,
|
||||||
|
WechatFriendAllot,
|
||||||
|
WechatFriendRebackAllot,
|
||||||
|
} from "@/pages/pc/ckbox/weChat/api";
|
||||||
|
import { useCurrentContact } from "@/store/module/weChat/weChat";
|
||||||
|
import { useCkChatStore } from "@/store/module/ckchat/ckchat";
|
||||||
|
import { contractService, weChatGroupService } from "@/utils/db";
|
||||||
|
const { TextArea } = Input;
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
|
interface ToContractProps {
|
||||||
|
className?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
interface DepartItem {
|
||||||
|
id: number;
|
||||||
|
userName: string;
|
||||||
|
realName: string;
|
||||||
|
nickname: string;
|
||||||
|
avatar: string;
|
||||||
|
memo: string;
|
||||||
|
departmentId: number;
|
||||||
|
alive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ToContract: React.FC<ToContractProps> = ({
|
||||||
|
className,
|
||||||
|
disabled = false,
|
||||||
|
}) => {
|
||||||
|
const currentContact = useCurrentContact();
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [selectedTarget, setSelectedTarget] = useState<number | null>(null);
|
||||||
|
const [comment, setComment] = useState<string>("");
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [customerServiceList, setCustomerServiceList] = useState<DepartItem[]>(
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
const deleteChatSession = useCkChatStore(state => state.deleteChatSession);
|
||||||
|
// 打开弹窗
|
||||||
|
const openModal = () => {
|
||||||
|
setVisible(true);
|
||||||
|
getTransferableAgentList().then(data => {
|
||||||
|
setCustomerServiceList(data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 关闭弹窗并重置状态
|
||||||
|
const closeModal = () => {
|
||||||
|
setVisible(false);
|
||||||
|
setSelectedTarget(null);
|
||||||
|
setComment("");
|
||||||
|
setLoading(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 确定转给他人
|
||||||
|
const handleConfirm = async () => {
|
||||||
|
if (!selectedTarget) {
|
||||||
|
message.warning("请选择目标客服");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
console.log(currentContact);
|
||||||
|
|
||||||
|
// 调用转接接口
|
||||||
|
if (currentContact) {
|
||||||
|
if ("chatroomId" in currentContact && currentContact.chatroomId) {
|
||||||
|
await WechatFriendAllot({
|
||||||
|
wechatChatroomId: currentContact.id,
|
||||||
|
toAccountId: selectedTarget as number,
|
||||||
|
notifyReceiver: true,
|
||||||
|
comment: comment.trim(),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await WechatFriendAllot({
|
||||||
|
wechatFriendId: currentContact.id,
|
||||||
|
toAccountId: selectedTarget as number,
|
||||||
|
notifyReceiver: true,
|
||||||
|
comment: comment.trim(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.success("转接成功");
|
||||||
|
try {
|
||||||
|
// 删除聊天会话
|
||||||
|
deleteChatSession(currentContact.id);
|
||||||
|
// 删除本地数据库记录
|
||||||
|
if ("chatroomId" in currentContact) {
|
||||||
|
await weChatGroupService.delete(currentContact.id);
|
||||||
|
} else {
|
||||||
|
await contractService.delete(currentContact.id);
|
||||||
|
}
|
||||||
|
} catch (deleteError) {
|
||||||
|
console.error("删除本地数据失败:", deleteError);
|
||||||
|
}
|
||||||
|
closeModal();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("转接失败:", error);
|
||||||
|
message.error("转接失败,请重试");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 一键转回
|
||||||
|
const handleReturn = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
// 调用转回接口
|
||||||
|
if (currentContact) {
|
||||||
|
if ("chatroomId" in currentContact && currentContact.chatroomId) {
|
||||||
|
await WechatFriendRebackAllot({
|
||||||
|
wechatChatroomId: currentContact.id,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await WechatFriendRebackAllot({
|
||||||
|
wechatFriendId: currentContact.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.success("转回成功");
|
||||||
|
try {
|
||||||
|
// 删除聊天会话
|
||||||
|
deleteChatSession(currentContact.id);
|
||||||
|
// 删除本地数据库记录
|
||||||
|
if ("chatroomId" in currentContact) {
|
||||||
|
await weChatGroupService.delete(currentContact.id);
|
||||||
|
} else {
|
||||||
|
await contractService.delete(currentContact.id);
|
||||||
|
}
|
||||||
|
} catch (deleteError) {
|
||||||
|
console.error("删除本地数据失败:", deleteError);
|
||||||
|
}
|
||||||
|
closeModal();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("转回失败:", error);
|
||||||
|
message.error("转回失败,请重试");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
className={className}
|
||||||
|
onClick={openModal}
|
||||||
|
style={{
|
||||||
|
cursor: disabled ? "not-allowed" : "pointer",
|
||||||
|
opacity: disabled ? 0.5 : 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ShareAltOutlined />
|
||||||
|
转给他人
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
title="转给他人"
|
||||||
|
open={visible}
|
||||||
|
onCancel={closeModal}
|
||||||
|
width={400}
|
||||||
|
centered
|
||||||
|
maskClosable={!loading}
|
||||||
|
footer={[
|
||||||
|
<div
|
||||||
|
key="footer"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button onClick={handleReturn} disabled={loading}>
|
||||||
|
一键转回
|
||||||
|
</Button>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
onClick={closeModal}
|
||||||
|
disabled={loading}
|
||||||
|
style={{ marginRight: "8px" }}
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
loading={loading}
|
||||||
|
onClick={handleConfirm}
|
||||||
|
disabled={!selectedTarget}
|
||||||
|
>
|
||||||
|
确定
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<div style={{ padding: "20px 0" }}>
|
||||||
|
{/* 目标客服选择 */}
|
||||||
|
<div style={{ marginBottom: "20px" }}>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "8px", fontSize: "14px", color: "#333" }}
|
||||||
|
>
|
||||||
|
目标客服
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
placeholder="请选择目标客服"
|
||||||
|
value={selectedTarget}
|
||||||
|
onChange={setSelectedTarget}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
size="large"
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{customerServiceList.map(item => (
|
||||||
|
<Option key={item.id} value={item.id}>
|
||||||
|
{item.nickname || item.realName} - {item.userName}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 附言输入 */}
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
style={{ marginBottom: "8px", fontSize: "14px", color: "#333" }}
|
||||||
|
>
|
||||||
|
附言
|
||||||
|
</div>
|
||||||
|
<TextArea
|
||||||
|
placeholder="请输入附言内容"
|
||||||
|
value={comment}
|
||||||
|
onChange={e => setComment(e.target.value)}
|
||||||
|
rows={4}
|
||||||
|
maxLength={300}
|
||||||
|
showCount
|
||||||
|
style={{ resize: "none" }}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ToContract;
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Layout, Input, Button, Tooltip, Modal } from "antd";
|
import { Layout, Input, Button, Modal } from "antd";
|
||||||
import {
|
import {
|
||||||
ShareAltOutlined,
|
|
||||||
SendOutlined,
|
SendOutlined,
|
||||||
AudioOutlined,
|
|
||||||
FolderOutlined,
|
FolderOutlined,
|
||||||
PictureOutlined,
|
PictureOutlined,
|
||||||
MessageOutlined,
|
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
|
import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
|
||||||
import { useWebSocketStore } from "@/store/module/websocket/websocket";
|
import { useWebSocketStore } from "@/store/module/websocket/websocket";
|
||||||
@@ -14,6 +11,8 @@ import { EmojiPicker } from "@/components/EmojiSeclection";
|
|||||||
import { EmojiInfo } from "@/components/EmojiSeclection/wechatEmoji";
|
import { EmojiInfo } from "@/components/EmojiSeclection/wechatEmoji";
|
||||||
import SimpleFileUpload from "@/components/Upload/SimpleFileUpload";
|
import SimpleFileUpload from "@/components/Upload/SimpleFileUpload";
|
||||||
import AudioRecorder from "@/components/Upload/AudioRecorder";
|
import AudioRecorder from "@/components/Upload/AudioRecorder";
|
||||||
|
import ToContract from "./components/toContract";
|
||||||
|
import ChatRecord from "./components/chatRecord";
|
||||||
import styles from "./MessageEnter.module.scss";
|
import styles from "./MessageEnter.module.scss";
|
||||||
|
|
||||||
const { Footer } = Layout;
|
const { Footer } = Layout;
|
||||||
@@ -174,14 +173,8 @@ const MessageEnter: React.FC<MessageEnterProps> = ({ contract }) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.rightTool}>
|
<div className={styles.rightTool}>
|
||||||
<div className={styles.rightToolItem}>
|
<ToContract className={styles.rightToolItem} />
|
||||||
<ShareAltOutlined />
|
<ChatRecord className={styles.rightToolItem} />
|
||||||
转给他人
|
|
||||||
</div>
|
|
||||||
<div className={styles.rightToolItem}>
|
|
||||||
<MessageOutlined />
|
|
||||||
聊天记录
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.inputArea}>
|
<div className={styles.inputArea}>
|
||||||
|
|||||||
@@ -33,6 +33,11 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
font-weight: normal;
|
||||||
|
a {
|
||||||
|
color: #1890ff;
|
||||||
|
margin: 0px 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.loadMore {
|
.loadMore {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -565,10 +565,19 @@ const MessageRecord: React.FC<MessageRecordProps> = ({ contract }) => {
|
|||||||
</div>
|
</div>
|
||||||
{groupMessagesByTime(currentMessages).map((group, groupIndex) => (
|
{groupMessagesByTime(currentMessages).map((group, groupIndex) => (
|
||||||
<React.Fragment key={`group-${groupIndex}`}>
|
<React.Fragment key={`group-${groupIndex}`}>
|
||||||
<Divider>
|
{group.messages
|
||||||
<div className={styles.messageTime}>{group.time}</div>
|
.filter(v => [10000].includes(v.msgType))
|
||||||
</Divider>
|
.map(msg => (
|
||||||
{group.messages.map(renderMessage)}
|
<div
|
||||||
|
key={`divider-${msg.id}`}
|
||||||
|
className={styles.messageTime}
|
||||||
|
dangerouslySetInnerHTML={{ __html: msg.content }}
|
||||||
|
></div>
|
||||||
|
))}
|
||||||
|
<div className={styles.messageTime}>{group.time}</div>
|
||||||
|
{group.messages
|
||||||
|
.filter(v => ![10000].includes(v.msgType))
|
||||||
|
.map(renderMessage)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
<div ref={messagesEndRef} />
|
<div ref={messagesEndRef} />
|
||||||
|
|||||||
@@ -19,17 +19,29 @@ const MessageList: React.FC<MessageListProps> = () => {
|
|||||||
const [chatSessions, setChatSessions] = useState<
|
const [chatSessions, setChatSessions] = useState<
|
||||||
(ContractData | weChatGroup)[]
|
(ContractData | weChatGroup)[]
|
||||||
>([]);
|
>([]);
|
||||||
|
const searchKeyword = useCkChatStore(state => state.searchKeyword);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (kfSelected == 0) {
|
let filteredSessions = getChatSessions;
|
||||||
setChatSessions(getChatSessions);
|
|
||||||
} else {
|
// 根据客服筛选
|
||||||
const newChatSessions = getChatSessions.filter(
|
if (kfSelected !== 0) {
|
||||||
v => v.wechatAccountId === kfSelected && kfSelected != 0,
|
filteredSessions = filteredSessions.filter(
|
||||||
|
v => v.wechatAccountId === kfSelected,
|
||||||
);
|
);
|
||||||
setChatSessions(newChatSessions);
|
|
||||||
}
|
}
|
||||||
}, [getChatSessions, kfSelected]);
|
|
||||||
|
// 根据搜索关键词进行模糊匹配
|
||||||
|
if (searchKeyword.trim()) {
|
||||||
|
const keyword = searchKeyword.toLowerCase();
|
||||||
|
filteredSessions = filteredSessions.filter(v => {
|
||||||
|
const nickname = (v.nickname || "").toLowerCase();
|
||||||
|
const conRemark = (v.conRemark || "").toLowerCase();
|
||||||
|
return nickname.includes(keyword) || conRemark.includes(keyword);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setChatSessions(filteredSessions);
|
||||||
|
}, [getChatSessions, kfSelected, searchKeyword]);
|
||||||
return (
|
return (
|
||||||
<div className={styles.messageList}>
|
<div className={styles.messageList}>
|
||||||
<List
|
<List
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import AIAssistant from "@/pages/mobile/workspace/ai-assistant/AIAssistant";
|
|||||||
import TrafficDistribution from "@/pages/mobile/workspace/traffic-distribution/list/index";
|
import TrafficDistribution from "@/pages/mobile/workspace/traffic-distribution/list/index";
|
||||||
import TrafficDistributionDetail from "@/pages/mobile/workspace/traffic-distribution/detail/index";
|
import TrafficDistributionDetail from "@/pages/mobile/workspace/traffic-distribution/detail/index";
|
||||||
import NewDistribution from "@/pages/mobile/workspace/traffic-distribution/form/index";
|
import NewDistribution from "@/pages/mobile/workspace/traffic-distribution/form/index";
|
||||||
|
import ContactImportList from "@/pages/mobile/workspace/contact-import/list";
|
||||||
|
import ContactImportForm from "@/pages/mobile/workspace/contact-import/form";
|
||||||
|
import ContactImportDetail from "@/pages/mobile/workspace/contact-import/detail";
|
||||||
import PlaceholderPage from "@/components/PlaceholderPage";
|
import PlaceholderPage from "@/components/PlaceholderPage";
|
||||||
import AiAnalyzer from "@/pages/mobile/workspace/ai-analyzer";
|
import AiAnalyzer from "@/pages/mobile/workspace/ai-analyzer";
|
||||||
|
|
||||||
@@ -154,6 +157,27 @@ const workspaceRoutes = [
|
|||||||
element: <TrafficDistributionDetail />,
|
element: <TrafficDistributionDetail />,
|
||||||
auth: true,
|
auth: true,
|
||||||
},
|
},
|
||||||
|
// 通讯录导入
|
||||||
|
{
|
||||||
|
path: "/workspace/contact-import/list",
|
||||||
|
element: <ContactImportList />,
|
||||||
|
auth: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/workspace/contact-import/form",
|
||||||
|
element: <ContactImportForm />,
|
||||||
|
auth: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/workspace/contact-import/form/:id",
|
||||||
|
element: <ContactImportForm />,
|
||||||
|
auth: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/workspace/contact-import/detail/:id",
|
||||||
|
element: <ContactImportDetail />,
|
||||||
|
auth: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default workspaceRoutes;
|
export default workspaceRoutes;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export interface CkChatState {
|
|||||||
updateCtrlUser: (user: KfUserListData) => void;
|
updateCtrlUser: (user: KfUserListData) => void;
|
||||||
clearkfUserList: () => void;
|
clearkfUserList: () => void;
|
||||||
addChatSession: (session: any) => void;
|
addChatSession: (session: any) => void;
|
||||||
deleteChatSession: (sessionId: string) => void;
|
deleteChatSession: (sessionId: number) => void;
|
||||||
setUserInfo: (userInfo: CkUserInfo) => void;
|
setUserInfo: (userInfo: CkUserInfo) => void;
|
||||||
clearUserInfo: () => void;
|
clearUserInfo: () => void;
|
||||||
updateAccount: (account: Partial<CkAccount>) => void;
|
updateAccount: (account: Partial<CkAccount>) => void;
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import {
|
|||||||
} from "@/pages/pc/ckbox/data";
|
} from "@/pages/pc/ckbox/data";
|
||||||
import { weChatGroupService, contractService } from "@/utils/db";
|
import { weChatGroupService, contractService } from "@/utils/db";
|
||||||
import { createContractList } from "@/store/module/ckchat/api";
|
import { createContractList } from "@/store/module/ckchat/api";
|
||||||
|
import { useWeChatStore } from "@/store/module/weChat/weChat";
|
||||||
|
// 从weChat store获取clearCurrentContact方法
|
||||||
|
const getClearCurrentContact = () =>
|
||||||
|
useWeChatStore.getState().clearCurrentContact;
|
||||||
export const useCkChatStore = createPersistStore<CkChatState>(
|
export const useCkChatStore = createPersistStore<CkChatState>(
|
||||||
set => ({
|
set => ({
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
@@ -389,10 +392,12 @@ export const useCkChatStore = createPersistStore<CkChatState>(
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
// 删除聊天会话
|
// 删除聊天会话
|
||||||
deleteChatSession: (sessionId: string) => {
|
deleteChatSession: (sessionId: number) => {
|
||||||
set(state => ({
|
set(state => ({
|
||||||
chatSessions: state.chatSessions.filter(item => item.id !== sessionId),
|
chatSessions: state.chatSessions.filter(item => item.id !== sessionId),
|
||||||
}));
|
}));
|
||||||
|
//当前选中的客户清空
|
||||||
|
getClearCurrentContact();
|
||||||
},
|
},
|
||||||
// 设置用户信息
|
// 设置用户信息
|
||||||
setUserInfo: (userInfo: CkUserInfo) => {
|
setUserInfo: (userInfo: CkUserInfo) => {
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ export interface WeChatState {
|
|||||||
|
|
||||||
// 当前聊天用户的消息列表(只存储当前聊天用户的消息)
|
// 当前聊天用户的消息列表(只存储当前聊天用户的消息)
|
||||||
currentMessages: ChatRecord[];
|
currentMessages: ChatRecord[];
|
||||||
|
// 清空当前联系人
|
||||||
|
clearCurrentContact: () => void;
|
||||||
// 消息加载状态
|
// 消息加载状态
|
||||||
messagesLoading: boolean;
|
messagesLoading: boolean;
|
||||||
isLoadingData: boolean;
|
isLoadingData: boolean;
|
||||||
@@ -18,7 +19,12 @@ export interface WeChatState {
|
|||||||
isExist?: boolean,
|
isExist?: boolean,
|
||||||
) => void;
|
) => void;
|
||||||
loadChatMessages: (Init: boolean, To?: number) => Promise<void>;
|
loadChatMessages: (Init: boolean, To?: number) => Promise<void>;
|
||||||
|
SearchMessage: (params: {
|
||||||
|
From: number;
|
||||||
|
To: number;
|
||||||
|
keyword: string;
|
||||||
|
Count?: number;
|
||||||
|
}) => Promise<void>;
|
||||||
// 视频消息处理方法
|
// 视频消息处理方法
|
||||||
setVideoLoading: (messageId: number, isLoading: boolean) => void;
|
setVideoLoading: (messageId: number, isLoading: boolean) => void;
|
||||||
setVideoUrl: (messageId: number, videoUrl: string) => void;
|
setVideoUrl: (messageId: number, videoUrl: string) => void;
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ export const useWeChatStore = create<WeChatState>()(
|
|||||||
messagesLoading: false,
|
messagesLoading: false,
|
||||||
isLoadingData: false,
|
isLoadingData: false,
|
||||||
currentGroupMembers: [],
|
currentGroupMembers: [],
|
||||||
|
//清空当前联系人
|
||||||
|
clearCurrentContact: () => {
|
||||||
|
set({ currentContract: null, currentMessages: [] });
|
||||||
|
},
|
||||||
// Actions
|
// Actions
|
||||||
setCurrentContact: (
|
setCurrentContact: (
|
||||||
contract: ContractData | weChatGroup,
|
contract: ContractData | weChatGroup,
|
||||||
@@ -98,6 +101,50 @@ export const useWeChatStore = create<WeChatState>()(
|
|||||||
set({ messagesLoading: false });
|
set({ messagesLoading: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
SearchMessage: async ({
|
||||||
|
From = 1,
|
||||||
|
To = 4704624000000,
|
||||||
|
keyword = "",
|
||||||
|
Count = 20,
|
||||||
|
}: {
|
||||||
|
From: number;
|
||||||
|
To: number;
|
||||||
|
keyword: string;
|
||||||
|
Count?: number;
|
||||||
|
}) => {
|
||||||
|
const state = useWeChatStore.getState();
|
||||||
|
const contact = state.currentContract;
|
||||||
|
set({ messagesLoading: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
const params: any = {
|
||||||
|
wechatAccountId: contact.wechatAccountId,
|
||||||
|
From,
|
||||||
|
To,
|
||||||
|
keyword,
|
||||||
|
Count,
|
||||||
|
olderData: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ("chatroomId" in contact && contact.chatroomId) {
|
||||||
|
params.wechatChatroomId = contact.id;
|
||||||
|
const messages = await getChatroomMessages(params);
|
||||||
|
const currentGroupMembers = await getGroupMembers({
|
||||||
|
id: contact.id,
|
||||||
|
});
|
||||||
|
set({ currentMessages: messages || [], currentGroupMembers });
|
||||||
|
} else {
|
||||||
|
params.wechatFriendId = contact.id;
|
||||||
|
const messages = await getChatMessages(params);
|
||||||
|
set({ currentMessages: messages || [] });
|
||||||
|
}
|
||||||
|
set({ messagesLoading: false });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("获取聊天消息失败:", error);
|
||||||
|
} finally {
|
||||||
|
set({ messagesLoading: false });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setMessageLoading: loading => {
|
setMessageLoading: loading => {
|
||||||
set({ messagesLoading: Boolean(loading) });
|
set({ messagesLoading: Boolean(loading) });
|
||||||
|
|||||||
@@ -419,9 +419,17 @@ class DeviceController extends BaseController
|
|||||||
$response = handleApiResponse($result);
|
$response = handleApiResponse($result);
|
||||||
|
|
||||||
if(empty($response)){
|
if(empty($response)){
|
||||||
return successJson([], '操作成功');
|
if($isInner){
|
||||||
|
return json_encode(['code'=>200,'msg'=>'更新设备联系人成功' ]);
|
||||||
|
}else{
|
||||||
|
return successJson([],'更新设备联系人失败:通讯录不能为空' );
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
return errorJson([],$response);
|
if($isInner){
|
||||||
|
return json_encode(['code'=>200,'msg'=> $response ]);
|
||||||
|
}else{
|
||||||
|
return successJson([],$response );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if($isInner){
|
if($isInner){
|
||||||
|
|||||||
@@ -37,4 +37,5 @@ return [
|
|||||||
'workbench:trafficDistribute' => 'app\command\WorkbenchTrafficDistributeCommand', // 工作台流量分发任务
|
'workbench:trafficDistribute' => 'app\command\WorkbenchTrafficDistributeCommand', // 工作台流量分发任务
|
||||||
'workbench:groupPush' => 'app\command\WorkbenchGroupPushCommand', // 工作台群推送任务
|
'workbench:groupPush' => 'app\command\WorkbenchGroupPushCommand', // 工作台群推送任务
|
||||||
'workbench:groupCreate' => 'app\command\WorkbenchGroupCreateCommand', // 工作台群创建任务
|
'workbench:groupCreate' => 'app\command\WorkbenchGroupCreateCommand', // 工作台群创建任务
|
||||||
|
'workbench:import-contact' => 'app\command\WorkbenchImportContactCommand', // 工作台通讯录导入任务
|
||||||
];
|
];
|
||||||
|
|||||||
125
Server/application/command/WorkbenchImportContactCommand.php
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\command;
|
||||||
|
|
||||||
|
use app\job\WorkbenchImportContactJob;
|
||||||
|
use think\console\Command;
|
||||||
|
use think\console\Input;
|
||||||
|
use think\console\Output;
|
||||||
|
use think\facade\Log;
|
||||||
|
use think\facade\Cache;
|
||||||
|
use think\Queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作台通讯录导入命令
|
||||||
|
* Class WorkbenchImportContactCommand
|
||||||
|
* @package app\command
|
||||||
|
*/
|
||||||
|
class WorkbenchImportContactCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 配置命令
|
||||||
|
*/
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this->setName('workbench:import-contact')
|
||||||
|
->setDescription('执行工作台通讯录导入任务');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行命令
|
||||||
|
* @param Input $input
|
||||||
|
* @param Output $output
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected function execute(Input $input, Output $output)
|
||||||
|
{
|
||||||
|
$output->writeln('开始执行工作台通讯录导入任务...');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 检查是否有任务正在执行
|
||||||
|
$lockKey = 'workbench_import_contact_lock';
|
||||||
|
if (Cache::has($lockKey)) {
|
||||||
|
$output->writeln('通讯录导入任务正在执行中,跳过本次执行');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置执行锁,防止重复执行
|
||||||
|
Cache::set($lockKey, time(), 3600); // 1小时锁定时间
|
||||||
|
|
||||||
|
// 生成任务ID
|
||||||
|
$jobId = 'workbench_import_contact_' . date('YmdHis') . '_' . mt_rand(1000, 9999);
|
||||||
|
|
||||||
|
// 准备任务数据
|
||||||
|
$jobData = [
|
||||||
|
'jobId' => $jobId,
|
||||||
|
'queueLockKey' => $lockKey,
|
||||||
|
'executeTime' => time()
|
||||||
|
];
|
||||||
|
// 判断是否使用队列
|
||||||
|
if ($this->shouldUseQueue()) {
|
||||||
|
// 推送到队列
|
||||||
|
Queue::push(WorkbenchImportContactJob::class, $jobData, 'workbench_import_contact');
|
||||||
|
$output->writeln("通讯录导入任务已推送到队列,任务ID: {$jobId}");
|
||||||
|
} else {
|
||||||
|
// 直接执行
|
||||||
|
$job = new WorkbenchImportContactJob();
|
||||||
|
$result = $job->execute();
|
||||||
|
|
||||||
|
// 释放锁
|
||||||
|
Cache::rm($lockKey);
|
||||||
|
|
||||||
|
if ($result !== false) {
|
||||||
|
$output->writeln('通讯录导入任务执行成功');
|
||||||
|
} else {
|
||||||
|
$output->writeln('通讯录导入任务执行失败');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// 释放锁
|
||||||
|
Cache::rm($lockKey ?? '');
|
||||||
|
|
||||||
|
$errorMsg = '通讯录导入任务执行异常: ' . $e->getMessage();
|
||||||
|
$output->writeln($errorMsg);
|
||||||
|
Log::error($errorMsg);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否应该使用队列
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function shouldUseQueue()
|
||||||
|
{
|
||||||
|
// 检查队列配置是否启用
|
||||||
|
$queueConfig = config('queue');
|
||||||
|
if (empty($queueConfig) || !isset($queueConfig['default'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查队列连接是否可用
|
||||||
|
try {
|
||||||
|
$connection = $queueConfig['connections'][$queueConfig['default']] ?? [];
|
||||||
|
if (empty($connection)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是数据库队列,检查表是否存在
|
||||||
|
if ($connection['type'] === 'database') {
|
||||||
|
$tableName = $connection['table'] ?? 'jobs';
|
||||||
|
$exists = \think\Db::query("SHOW TABLES LIKE '{$tableName}'");
|
||||||
|
return !empty($exists);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::warning('队列检查失败,将使用同步执行: ' . $e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -556,12 +556,12 @@ class WorkbenchController extends Controller
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::TYPE_IMPORT_CONTACT:
|
case self::TYPE_IMPORT_CONTACT:
|
||||||
if (!empty($item->importContact)) {
|
if (!empty($workbench->importContact)) {
|
||||||
$item->config = $item->importContact;
|
$workbench->config = $workbench->importContact;
|
||||||
$item->config->devices = json_decode($item->config->devices, true);
|
$workbench->config->devices = json_decode($workbench->config->devices, true);
|
||||||
$item->config->pools = json_decode($item->config->pools, true);
|
$workbench->config->pools = json_decode($workbench->config->pools, true);
|
||||||
}
|
}
|
||||||
unset($item->importContact, $item->import_contact);
|
unset($workbench->importContact, $workbench->import_contact);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
unset(
|
unset(
|
||||||
@@ -991,11 +991,12 @@ class WorkbenchController extends Controller
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::TYPE_IMPORT_CONTACT: //联系人导入
|
case self::TYPE_IMPORT_CONTACT: //联系人导入
|
||||||
$config = WorkbenchImportContact::where('workbenchId',$id)->find();;
|
$config = WorkbenchImportContact::where('workbenchId',$id)->find();
|
||||||
if ($config) {
|
if ($config) {
|
||||||
$newConfig = new WorkbenchImportContact;
|
$newConfig = new WorkbenchImportContact;
|
||||||
$newConfig->devices = json_encode($config->deveiceGroups);
|
$newConfig->workbenchId = $newWorkbench->id;
|
||||||
$newConfig->pools = json_encode($config->pools);
|
$newConfig->devices = $config->devices;
|
||||||
|
$newConfig->pools = $config->pools;
|
||||||
$newConfig->num = $config->num;
|
$newConfig->num = $config->num;
|
||||||
$newConfig->clearContact = $config->clearContact;
|
$newConfig->clearContact = $config->clearContact;
|
||||||
$newConfig->remark = $config->remark;
|
$newConfig->remark = $config->remark;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Workbench extends Model
|
|||||||
|
|
||||||
public function importContact()
|
public function importContact()
|
||||||
{
|
{
|
||||||
return $this->hasOne('WorkbenchTrafficConfig', 'workbenchId', 'id');
|
return $this->hasOne('WorkbenchImportContact', 'workbenchId', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
399
Server/application/job/WorkbenchImportContactJob.php
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\job;
|
||||||
|
|
||||||
|
use app\api\controller\DeviceController;
|
||||||
|
use app\cunkebao\model\Workbench;
|
||||||
|
use app\cunkebao\model\WorkbenchImportContact;
|
||||||
|
use think\facade\Log;
|
||||||
|
use think\facade\Env;
|
||||||
|
use think\Db;
|
||||||
|
use think\queue\Job;
|
||||||
|
use think\facade\Cache;
|
||||||
|
use think\facade\Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作台通讯录导入任务
|
||||||
|
* Class WorkbenchImportContactJob
|
||||||
|
* @package app\job
|
||||||
|
*/
|
||||||
|
class WorkbenchImportContactJob
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最大重试次数
|
||||||
|
*/
|
||||||
|
const MAX_RETRY_ATTEMPTS = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 队列任务处理
|
||||||
|
* @param Job $job 队列任务
|
||||||
|
* @param array $data 任务数据
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function fire(Job $job, $data)
|
||||||
|
{
|
||||||
|
$jobId = $data['jobId'] ?? '';
|
||||||
|
$queueLockKey = $data['queueLockKey'] ?? '';
|
||||||
|
try {
|
||||||
|
$this->logJobStart($jobId, $queueLockKey);
|
||||||
|
$this->execute();
|
||||||
|
$this->handleJobSuccess($job, $queueLockKey);
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->handleJobError($e, $job, $queueLockKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行任务
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function execute()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// 获取所有启用的通讯录导入工作台
|
||||||
|
$workbenches = Workbench::where(['status' => 1, 'type' => 6, 'isDel' => 0])->order('id desc')->select();
|
||||||
|
foreach ($workbenches as $workbench) {
|
||||||
|
// 获取工作台配置
|
||||||
|
$config = WorkbenchImportContact::where('workbenchId', $workbench->id)->find();
|
||||||
|
if (!$config) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否需要导入
|
||||||
|
$shouldImport = $this->shouldImport($workbench, $config);
|
||||||
|
if (!$shouldImport) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取需要导入的设备列表
|
||||||
|
$devices = $this->getDeviceList($workbench, $config);
|
||||||
|
if (empty($devices)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取通讯录数据
|
||||||
|
$contactData = $this->getContactFromDatabase($workbench, $config);
|
||||||
|
if (empty($contactData)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行通讯录导入
|
||||||
|
$this->importContactToDevices($workbench, $config, $devices, $contactData);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error("通讯录导入任务异常: " . $e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入通讯录到设备
|
||||||
|
* @param Workbench $workbench
|
||||||
|
* @param WorkbenchImportContact $config
|
||||||
|
* @param array $devices
|
||||||
|
* @param array $contactData
|
||||||
|
*/
|
||||||
|
public function importContactToDevices($workbench, $config, $devices, $contactData)
|
||||||
|
{
|
||||||
|
$deviceController = new DeviceController();
|
||||||
|
|
||||||
|
// 根据设备数量平分通讯录数据
|
||||||
|
$deviceCount = count($devices);
|
||||||
|
if ($deviceCount == 0) {
|
||||||
|
Log::warning("没有可用设备进行通讯录导入");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contactCount = count($contactData);
|
||||||
|
if ($contactCount == 0) {
|
||||||
|
Log::warning("没有通讯录数据需要导入");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算每个设备分配的联系人数量
|
||||||
|
$contactsPerDevice = ceil($contactCount / $deviceCount);
|
||||||
|
foreach ($devices as $index => $device) {
|
||||||
|
try {
|
||||||
|
// 计算当前设备的联系人数据范围
|
||||||
|
$startIndex = $index * $contactsPerDevice;
|
||||||
|
$endIndex = min($startIndex + $contactsPerDevice, $contactCount);
|
||||||
|
|
||||||
|
// 如果起始索引超出范围,跳过
|
||||||
|
if ($startIndex >= $contactCount) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前设备的联系人数据片段
|
||||||
|
$deviceContactData = array_slice($contactData, $startIndex, $endIndex - $startIndex);
|
||||||
|
|
||||||
|
if (empty($deviceContactData)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 准备联系人数据
|
||||||
|
$contactJson = $this->formatContactData($deviceContactData, $config);
|
||||||
|
|
||||||
|
// 调用设备控制器的导入联系人方法
|
||||||
|
$result = $deviceController->importContact([
|
||||||
|
'deviceId' => $device['deviceId'],
|
||||||
|
'contactJson' => $contactJson,
|
||||||
|
'clearContact' => $config['clearContact'] ?? false
|
||||||
|
], true);
|
||||||
|
|
||||||
|
$resultData = json_decode($result, true);
|
||||||
|
|
||||||
|
// 记录导入历史
|
||||||
|
$this->recordImportHistory($workbench, $device, $deviceContactData);
|
||||||
|
|
||||||
|
if ($resultData['code'] == 200) {
|
||||||
|
Log::info("设备 {$device['deviceId']} 通讯录导入成功,导入联系人数量: " . count($deviceContactData));
|
||||||
|
} else {
|
||||||
|
Log::error("设备 {$device['deviceId']} 通讯录导入失败: " . ($resultData['msg'] ?? '未知错误'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加延迟,避免频繁请求
|
||||||
|
if ($config['importInterval'] ?? 0 > 0) {
|
||||||
|
sleep($config['importInterval']);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error("设备 {$device['deviceId']} 通讯录导入异常: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化联系人数据
|
||||||
|
* @param array $contactData
|
||||||
|
* @param WorkbenchImportContact $config
|
||||||
|
* @return array|string
|
||||||
|
*/
|
||||||
|
protected function formatContactData($contactData, $config)
|
||||||
|
{
|
||||||
|
$remarkType = $config['remarkType'] ?? 0;
|
||||||
|
$remark = $config['remark'] ?? '';
|
||||||
|
|
||||||
|
// 根据remarkType添加备注
|
||||||
|
$suffix = '';
|
||||||
|
switch ($remarkType) {
|
||||||
|
case 0:
|
||||||
|
// 不添加备注
|
||||||
|
$suffix = '';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// 添加年月日
|
||||||
|
$suffix = date('Ymd') . '_';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// 添加月日
|
||||||
|
$suffix = date('md') . '_';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// 自定义备注
|
||||||
|
$suffix = $remark . '_';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$suffix = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 返回数组格式
|
||||||
|
$contacts = [];
|
||||||
|
foreach ($contactData as $contact) {
|
||||||
|
$name = !empty($contact['name']) ? trim($contact['name']) : trim($contact['phone']);
|
||||||
|
if (!empty($suffix)) {
|
||||||
|
$name = $suffix . $name;
|
||||||
|
}
|
||||||
|
$contacts[] = [
|
||||||
|
'name' => $name,
|
||||||
|
'phone' => trim($contact['phone'])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $contacts;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录导入历史
|
||||||
|
* @param Workbench $workbench
|
||||||
|
* @param array $device
|
||||||
|
* @param array $contactData
|
||||||
|
* @param array $result
|
||||||
|
*/
|
||||||
|
protected function recordImportHistory($workbench, $device, $contactData)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
foreach ($contactData as $v){
|
||||||
|
$data[] = [
|
||||||
|
'workbenchId' => $workbench->id,
|
||||||
|
'deviceId' => $device['deviceId'],
|
||||||
|
'packageId' => !empty($v['packageId']) ? $v['packageId'] : 0,
|
||||||
|
'poolId' => !empty($v['id']) ? $v['id'] : 0,
|
||||||
|
'createTime' => time(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
Db::name('workbench_import_contact_item')->insertAll($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取设备列表
|
||||||
|
* @param Workbench $workbench 工作台
|
||||||
|
* @param WorkbenchImportContact $config 配置
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getDeviceList($workbench, $config)
|
||||||
|
{
|
||||||
|
$deviceIds = json_decode($config['devices'], true);
|
||||||
|
if (empty($deviceIds)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从数据库获取设备信息
|
||||||
|
$devices = Db::table('s2_device')
|
||||||
|
->whereIn('id', $deviceIds)
|
||||||
|
->where('isDeleted', 0)
|
||||||
|
->where('alive', 1) // 只选择在线设备
|
||||||
|
->field('id as deviceId, imei, nickname')
|
||||||
|
->select();
|
||||||
|
|
||||||
|
return $devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否需要导入
|
||||||
|
* @param Workbench $workbench 工作台
|
||||||
|
* @param WorkbenchImportContact $config 配置
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function shouldImport($workbench, $config)
|
||||||
|
{
|
||||||
|
// 检查导入间隔
|
||||||
|
$today = date('Y-m-d');
|
||||||
|
$startTimestamp = strtotime($today . ' ' . $config['startTime'] . ':00');
|
||||||
|
$endTimestamp = strtotime($today . ' ' . $config['endTime'] . ':00');
|
||||||
|
// 如果不在指定时间范围内,则跳过
|
||||||
|
if ($startTimestamp > time() || $endTimestamp < time()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$maxPerDay = $config['num'];
|
||||||
|
if ($maxPerDay <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询今日已导入次数
|
||||||
|
$count = Db::name('workbench_import_contact_item')
|
||||||
|
->where('workbenchId', $workbench->id)
|
||||||
|
->whereTime('createTime', 'between', [$startTimestamp, $endTimestamp])
|
||||||
|
->count();
|
||||||
|
|
||||||
|
if ($count >= $maxPerDay) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算导入间隔
|
||||||
|
$totalSeconds = $endTimestamp - $startTimestamp;
|
||||||
|
$interval = floor($totalSeconds / $maxPerDay);
|
||||||
|
$nextImportTime = $startTimestamp + $count * $interval;
|
||||||
|
|
||||||
|
if (time() < $nextImportTime) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从数据库读取通讯录
|
||||||
|
* @param WorkbenchImportContact $config
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getContactFromDatabase($workbench,$config)
|
||||||
|
{
|
||||||
|
$pools = json_decode($config['pools'], true);
|
||||||
|
$deviceIds = json_decode($config['devices'], true);
|
||||||
|
if (empty($pools) || empty($deviceIds)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$deviceNum = count($deviceIds);
|
||||||
|
$contactNum = $deviceNum * $config['num'];
|
||||||
|
if (empty($contactNum)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//过滤已删除的数据
|
||||||
|
$packageIds = Db::name('traffic_source_package')
|
||||||
|
->where(['isDel' => 0])
|
||||||
|
->whereIn('id', $pools)
|
||||||
|
->column('id');
|
||||||
|
|
||||||
|
if (empty($packageIds)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = Db::name('traffic_source_package_item')->alias('tpi')
|
||||||
|
->join('traffic_pool tp', 'tp.identifier = tpi.identifier')
|
||||||
|
->join('traffic_source ts', 'ts.identifier = tpi.identifier','left')
|
||||||
|
->join('workbench_import_contact_item wici', 'wici.poolId = tp.id AND wici.workbenchId = '.$workbench->id,'left')
|
||||||
|
->where('tp.mobile', '>',0)
|
||||||
|
->where('wici.id','null')
|
||||||
|
->whereIn('tpi.packageId',$packageIds)
|
||||||
|
->field('tp.id,tpi.packageId,tp.mobile as phone,ts.name')
|
||||||
|
->order('tp.id DESC')
|
||||||
|
->group('tpi.identifier')
|
||||||
|
->limit($contactNum)
|
||||||
|
->select();
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录任务开始
|
||||||
|
* @param string $jobId
|
||||||
|
* @param string $queueLockKey
|
||||||
|
*/
|
||||||
|
protected function logJobStart($jobId, $queueLockKey)
|
||||||
|
{
|
||||||
|
Log::info('开始处理工作台通讯录导入任务: ' . json_encode([
|
||||||
|
'jobId' => $jobId,
|
||||||
|
'queueLockKey' => $queueLockKey
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理任务成功
|
||||||
|
* @param Job $job
|
||||||
|
* @param string $queueLockKey
|
||||||
|
*/
|
||||||
|
protected function handleJobSuccess($job, $queueLockKey)
|
||||||
|
{
|
||||||
|
$job->delete();
|
||||||
|
Cache::rm($queueLockKey);
|
||||||
|
Log::info('工作台通讯录导入任务执行成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理任务错误
|
||||||
|
* @param \Exception $e
|
||||||
|
* @param Job $job
|
||||||
|
* @param string $queueLockKey
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function handleJobError(\Exception $e, $job, $queueLockKey)
|
||||||
|
{
|
||||||
|
Log::error('工作台通讯录导入任务异常:' . $e->getMessage());
|
||||||
|
|
||||||
|
if (!empty($queueLockKey)) {
|
||||||
|
Cache::rm($queueLockKey);
|
||||||
|
Log::info("由于异常释放队列锁: {$queueLockKey}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($job->attempts() > self::MAX_RETRY_ATTEMPTS) {
|
||||||
|
$job->delete();
|
||||||
|
} else {
|
||||||
|
$job->release(Config::get('queue.failed_delay', 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
Touchkebao/.env.development
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# 基础环境变量示例
|
||||||
|
VITE_API_BASE_URL=http://www.yishi.com
|
||||||
|
VITE_API_BASE_URL2=https://kf.quwanzhi.com:9991
|
||||||
|
VITE_API_WS_URL=wss://kf.quwanzhi.com:9993
|
||||||
|
# VITE_API_BASE_URL=https://ckbapi.quwanzhi.com
|
||||||
|
VITE_APP_TITLE=存客宝
|
||||||
6
Touchkebao/.env.production
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# 基础环境变量示例
|
||||||
|
VITE_API_BASE_URL=https://ckbapi.quwanzhi.com
|
||||||
|
VITE_API_BASE_URL2=https://kf.quwanzhi.com:9991
|
||||||
|
VITE_API_WS_URL=wss://kf.quwanzhi.com:9993
|
||||||
|
# VITE_API_BASE_URL=http://www.yishi.com
|
||||||
|
VITE_APP_TITLE=存客宝
|
||||||
64
Touchkebao/.eslintrc.js
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
es2021: true,
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react/recommended",
|
||||||
|
"plugin:react-hooks/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:prettier/recommended", // 这个配置会自动处理大部分冲突
|
||||||
|
],
|
||||||
|
parser: "@typescript-eslint/parser",
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: {
|
||||||
|
jsx: true,
|
||||||
|
},
|
||||||
|
ecmaVersion: 12,
|
||||||
|
sourceType: "module",
|
||||||
|
},
|
||||||
|
plugins: ["react", "react-hooks", "@typescript-eslint", "prettier"],
|
||||||
|
rules: {
|
||||||
|
"prettier/prettier": "error",
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": "warn",
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
|
||||||
|
"react/prop-types": "off",
|
||||||
|
"linebreak-style": "off",
|
||||||
|
"eol-last": "off",
|
||||||
|
"no-empty": "warn",
|
||||||
|
"prefer-const": "warn",
|
||||||
|
// 确保与 Prettier 完全兼容
|
||||||
|
"comma-dangle": "off",
|
||||||
|
"comma-spacing": "off",
|
||||||
|
"comma-style": "off",
|
||||||
|
"object-curly-spacing": "off",
|
||||||
|
"array-bracket-spacing": "off",
|
||||||
|
indent: "off",
|
||||||
|
quotes: "off",
|
||||||
|
semi: "off",
|
||||||
|
"arrow-parens": "off",
|
||||||
|
"no-multiple-empty-lines": "off",
|
||||||
|
"max-len": "off",
|
||||||
|
"space-before-function-paren": "off",
|
||||||
|
"space-before-blocks": "off",
|
||||||
|
"keyword-spacing": "off",
|
||||||
|
"space-infix-ops": "off",
|
||||||
|
"space-in-parens": "off",
|
||||||
|
"space-in-brackets": "off",
|
||||||
|
"object-property-newline": "off",
|
||||||
|
"array-element-newline": "off",
|
||||||
|
"function-paren-newline": "off",
|
||||||
|
"object-curly-newline": "off",
|
||||||
|
"array-bracket-newline": "off",
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
react: {
|
||||||
|
version: "detect",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
27
Touchkebao/.gitattributes
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# 设置默认行为,如果core.autocrlf没有设置,Git会自动处理行尾符
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# 明确指定文本文件使用LF
|
||||||
|
*.js text eol=lf
|
||||||
|
*.jsx text eol=lf
|
||||||
|
*.ts text eol=lf
|
||||||
|
*.tsx text eol=lf
|
||||||
|
*.json text eol=lf
|
||||||
|
*.css text eol=lf
|
||||||
|
*.scss text eol=lf
|
||||||
|
*.html text eol=lf
|
||||||
|
*.md text eol=lf
|
||||||
|
*.yml text eol=lf
|
||||||
|
*.yaml text eol=lf
|
||||||
|
|
||||||
|
# 二进制文件
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.jpeg binary
|
||||||
|
*.gif binary
|
||||||
|
*.ico binary
|
||||||
|
*.svg binary
|
||||||
|
*.woff binary
|
||||||
|
*.woff2 binary
|
||||||
|
*.ttf binary
|
||||||
|
*.eot binary
|
||||||
6
Touchkebao/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
yarn.lock
|
||||||
|
.env
|
||||||
|
.DS_Store
|
||||||
13
Touchkebao/.prettierrc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"semi": true,
|
||||||
|
"trailingComma": "all",
|
||||||
|
"singleQuote": false,
|
||||||
|
"printWidth": 80,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false,
|
||||||
|
"endOfLine": "lf",
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"jsxSingleQuote": false,
|
||||||
|
"quoteProps": "as-needed"
|
||||||
|
}
|
||||||
8
Touchkebao/.vite/deps/_metadata.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"hash": "efe0acf4",
|
||||||
|
"configHash": "2bed34b3",
|
||||||
|
"lockfileHash": "ef01d341",
|
||||||
|
"browserHash": "91bd3b2c",
|
||||||
|
"optimized": {},
|
||||||
|
"chunks": {}
|
||||||
|
}
|
||||||
3
Touchkebao/.vite/deps/package.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
11
Touchkebao/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"bradlc.vscode-tailwindcss",
|
||||||
|
"ms-vscode.vscode-typescript-next",
|
||||||
|
"formulahendry.auto-rename-tag",
|
||||||
|
"christian-kohler.path-intellisense",
|
||||||
|
"ms-vscode.vscode-json"
|
||||||
|
]
|
||||||
|
}
|
||||||
45
Touchkebao/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"files.eol": "\n",
|
||||||
|
"files.insertFinalNewline": true,
|
||||||
|
"files.trimFinalNewlines": true,
|
||||||
|
"files.trimTrailingWhitespace": true,
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit",
|
||||||
|
"source.organizeImports": "never"
|
||||||
|
},
|
||||||
|
"eslint.validate": [
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact"
|
||||||
|
],
|
||||||
|
"eslint.format.enable": false,
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[javascriptreact]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[typescriptreact]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[scss]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[css]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"typescript.preferences.importModuleSpecifier": "relative",
|
||||||
|
"typescript.suggest.autoImports": true,
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"editor.insertSpaces": true,
|
||||||
|
"editor.detectIndentation": false
|
||||||
|
}
|
||||||
95
Touchkebao/devlop.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import os
|
||||||
|
import zipfile
|
||||||
|
import paramiko
|
||||||
|
|
||||||
|
# 配置
|
||||||
|
local_dir = './dist' # 本地要打包的目录
|
||||||
|
zip_name = 'dist.zip'
|
||||||
|
# 上传到服务器的 zip 路径
|
||||||
|
remote_path = '/www/wwwroot/auto-devlop/tkb-wechat/dist.zip' # 服务器上的临时zip路径
|
||||||
|
server_ip = '42.194.245.239'
|
||||||
|
server_port = 6523
|
||||||
|
server_user = 'yongpxu'
|
||||||
|
server_pwd = 'Aa123456789.'
|
||||||
|
# 服务器 dist 相关目录
|
||||||
|
remote_base_dir = '/www/wwwroot/auto-devlop/tkb-wechat'
|
||||||
|
dist_dir = f'{remote_base_dir}/dist'
|
||||||
|
dist1_dir = f'{remote_base_dir}/dist1'
|
||||||
|
dist2_dir = f'{remote_base_dir}/dist2'
|
||||||
|
|
||||||
|
# 美化输出用的函数
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
def info(msg):
|
||||||
|
print(f"\033[36m[INFO {datetime.now().strftime('%H:%M:%S')}] {msg}\033[0m")
|
||||||
|
|
||||||
|
def success(msg):
|
||||||
|
print(f"\033[32m[SUCCESS] {msg}\033[0m")
|
||||||
|
|
||||||
|
def error(msg):
|
||||||
|
print(f"\033[31m[ERROR] {msg}\033[0m")
|
||||||
|
|
||||||
|
def step(msg):
|
||||||
|
print(f"\n\033[35m==== {msg} ====" + "\033[0m")
|
||||||
|
|
||||||
|
# 1. 先运行 pnpm build
|
||||||
|
step('Step 1: 构建项目 (pnpm build)')
|
||||||
|
info('开始执行 pnpm build...')
|
||||||
|
ret = os.system('pnpm build')
|
||||||
|
if ret != 0:
|
||||||
|
error('pnpm build 失败,终止部署!')
|
||||||
|
exit(1)
|
||||||
|
success('pnpm build 完成')
|
||||||
|
|
||||||
|
# 2. 打包
|
||||||
|
step('Step 2: 打包 dist 目录为 zip')
|
||||||
|
info('开始打包 dist 目录...')
|
||||||
|
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
||||||
|
for root, dirs, files in os.walk(local_dir):
|
||||||
|
for file in files:
|
||||||
|
filepath = os.path.join(root, file)
|
||||||
|
arcname = os.path.relpath(filepath, local_dir)
|
||||||
|
zipf.write(filepath, arcname)
|
||||||
|
success('本地打包完成')
|
||||||
|
|
||||||
|
# 3. 上传
|
||||||
|
step('Step 3: 上传 zip 包到服务器')
|
||||||
|
info('开始上传 zip 包...')
|
||||||
|
transport = paramiko.Transport((server_ip, server_port))
|
||||||
|
transport.connect(username=server_user, password=server_pwd)
|
||||||
|
sftp = paramiko.SFTPClient.from_transport(transport)
|
||||||
|
sftp.put(zip_name, remote_path)
|
||||||
|
sftp.close()
|
||||||
|
transport.close()
|
||||||
|
success('上传到服务器完成')
|
||||||
|
|
||||||
|
# 删除本地 dist.zip
|
||||||
|
try:
|
||||||
|
os.remove(zip_name)
|
||||||
|
success('本地 dist.zip 已删除')
|
||||||
|
except Exception as e:
|
||||||
|
error(f'本地 dist.zip 删除失败: {e}')
|
||||||
|
|
||||||
|
# 4. 远程解压并覆盖
|
||||||
|
step('Step 4: 服务器端解压、切换目录')
|
||||||
|
ssh = paramiko.SSHClient()
|
||||||
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
|
ssh.connect(server_ip, server_port, server_user, server_pwd)
|
||||||
|
commands = [
|
||||||
|
f'unzip -oq {remote_path} -d {dist2_dir}', # 静默解压
|
||||||
|
f'rm {remote_path}',
|
||||||
|
f'if [ -d {dist_dir} ]; then mv {dist_dir} {dist1_dir}; fi',
|
||||||
|
f'mv {dist2_dir} {dist_dir}',
|
||||||
|
f'rm -rf {dist1_dir}'
|
||||||
|
]
|
||||||
|
for i, cmd in enumerate(commands, 1):
|
||||||
|
info(f'执行第{i}步: {cmd}')
|
||||||
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
||||||
|
out, err = stdout.read().decode(), stderr.read().decode()
|
||||||
|
# 只打印非 unzip 命令的输出
|
||||||
|
if i != 1 and out.strip():
|
||||||
|
print(out.strip())
|
||||||
|
if err.strip():
|
||||||
|
error(err.strip())
|
||||||
|
ssh.close()
|
||||||
|
success('服务器解压并覆盖完成,部署成功!')
|
||||||
BIN
Touchkebao/favicon.ico
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
19
Touchkebao/index.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>存客宝</title>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<!-- 引入 uni-app web-view SDK(必须) -->
|
||||||
|
<script type="text/javascript" src="/websdk.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
53
Touchkebao/package.json
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"name": "cunkebao",
|
||||||
|
"version": "3.0.0",
|
||||||
|
"license": "MIT",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@ant-design/icons": "^5.6.1",
|
||||||
|
"antd": "^5.13.1",
|
||||||
|
"antd-mobile": "^5.39.1",
|
||||||
|
"antd-mobile-icons": "^0.3.0",
|
||||||
|
"axios": "^1.6.7",
|
||||||
|
"dayjs": "^1.11.13",
|
||||||
|
"dexie": "^4.2.0",
|
||||||
|
"echarts": "^5.6.0",
|
||||||
|
"echarts-for-react": "^3.0.2",
|
||||||
|
"react": "^18.2.0",
|
||||||
|
"react-dom": "^18.2.0",
|
||||||
|
"react-router-dom": "^6.20.0",
|
||||||
|
"react-window": "^1.8.11",
|
||||||
|
"vconsole": "^3.15.1",
|
||||||
|
"xmldom": "^0.6.0",
|
||||||
|
"zustand": "^5.0.6"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.0.14",
|
||||||
|
"@types/react": "^19.1.8",
|
||||||
|
"@types/react-dom": "^19.1.6",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
||||||
|
"@typescript-eslint/parser": "^7.7.0",
|
||||||
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
|
"eslint-plugin-react": "^7.34.1",
|
||||||
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
|
"postcss": "^8.4.38",
|
||||||
|
"postcss-pxtorem": "^6.0.0",
|
||||||
|
"prettier": "^3.2.5",
|
||||||
|
"sass": "^1.75.0",
|
||||||
|
"typescript": "^5.4.5",
|
||||||
|
"vite": "^7.0.5"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "pnpm vite",
|
||||||
|
"build": "pnpm vite build",
|
||||||
|
"build:check": "tsc && pnpm vite build",
|
||||||
|
"preview": "pnpm vite preview",
|
||||||
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
||||||
|
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,scss,css}\"",
|
||||||
|
"lint:check": "eslint src --ext .js,.jsx,.ts,.tsx",
|
||||||
|
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,scss,css}\""
|
||||||
|
}
|
||||||
|
}
|
||||||
4998
Touchkebao/pnpm-lock.yaml
generated
Normal file
8
Touchkebao/postcss.config.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: {
|
||||||
|
'postcss-pxtorem': {
|
||||||
|
rootValue: 16,
|
||||||
|
propList: ['*'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
BIN
Touchkebao/public/assets/animal/发抖.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
Touchkebao/public/assets/animal/猪头.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
Touchkebao/public/assets/animal/跳跳.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Touchkebao/public/assets/animal/转圈.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
Touchkebao/public/assets/blessing/庆祝.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
Touchkebao/public/assets/blessing/烟花.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
Touchkebao/public/assets/blessing/爆竹.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
Touchkebao/public/assets/blessing/發.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/blessing/礼物.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/blessing/福.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Touchkebao/public/assets/blessing/红包.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
Touchkebao/public/assets/face/666.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
Touchkebao/public/assets/face/Emm.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Touchkebao/public/assets/face/亲亲.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/face/偷笑.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
Touchkebao/public/assets/face/傲慢.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/face/再见.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
Touchkebao/public/assets/face/加油.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Touchkebao/public/assets/face/发呆.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Touchkebao/public/assets/face/发怒.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
Touchkebao/public/assets/face/可怜.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
Touchkebao/public/assets/face/右哼哼.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
Touchkebao/public/assets/face/叹气.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Touchkebao/public/assets/face/吃瓜.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Touchkebao/public/assets/face/吐.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/face/呲牙.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
Touchkebao/public/assets/face/咒骂.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/face/哇.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Touchkebao/public/assets/face/嘘.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
Touchkebao/public/assets/face/嘿哈.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
Touchkebao/public/assets/face/囧.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Touchkebao/public/assets/face/困.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
Touchkebao/public/assets/face/坏笑.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Touchkebao/public/assets/face/大哭.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
Touchkebao/public/assets/face/天啊.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Touchkebao/public/assets/face/失望.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
Touchkebao/public/assets/face/奸笑.png
Normal file
|
After Width: | Height: | Size: 15 KiB |