通讯录导入前端
This commit is contained in:
@@ -0,0 +1,332 @@
|
||||
.container {
|
||||
padding: 12px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.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);
|
||||
margin-bottom: 16px;
|
||||
|
||||
: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: 8px;
|
||||
|
||||
: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) {
|
||||
.container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.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,464 @@
|
||||
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 {
|
||||
ContactImportTask,
|
||||
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<ContactImportTask | null>(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
|
||||
left={
|
||||
<Button
|
||||
fill="none"
|
||||
size="small"
|
||||
onClick={() => navigate("/workspace/contact-import/list")}
|
||||
>
|
||||
返回
|
||||
</Button>
|
||||
}
|
||||
title="任务详情"
|
||||
right={
|
||||
<Button
|
||||
fill="none"
|
||||
size="small"
|
||||
onClick={() => navigate(`/workspace/contact-import/form/${task.id}`)}
|
||||
>
|
||||
<EditOutlined /> 编辑
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<PullToRefresh onRefresh={handleRefresh}>
|
||||
<div className={style.container}>
|
||||
{/* 任务操作栏 */}
|
||||
<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
|
||||
size="small"
|
||||
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>
|
||||
|
||||
{/* 标签页 */}
|
||||
<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,229 @@
|
||||
.container {
|
||||
padding: 12px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.section {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
|
||||
:global(.adm-card-body) {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin-top: 24px;
|
||||
padding: 16px;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
// Form样式覆盖
|
||||
:global {
|
||||
.adm-form-item {
|
||||
margin-bottom: 20px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.adm-form-item-label {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.adm-input {
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 6px;
|
||||
padding: 10px 12px;
|
||||
font-size: 14px;
|
||||
|
||||
&:focus {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #bfbfbf;
|
||||
}
|
||||
}
|
||||
|
||||
.adm-selector {
|
||||
.adm-selector-item {
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 6px;
|
||||
margin: 4px;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
|
||||
&.adm-selector-item-active {
|
||||
border-color: #1890ff;
|
||||
background-color: #e6f7ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.adm-stepper {
|
||||
.adm-stepper-button {
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
||||
&:hover {
|
||||
border-color: #1890ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
}
|
||||
|
||||
.adm-stepper-input {
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
height: 32px;
|
||||
margin: 0 4px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.adm-picker {
|
||||
.adm-picker-view-column {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.adm-button {
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
|
||||
&.adm-button-primary {
|
||||
background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
|
||||
border: none;
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #40a9ff 0%, #1890ff 100%);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 表单验证错误样式
|
||||
:global(.adm-form-item-feedback-error) {
|
||||
color: #ff4d4f;
|
||||
font-size: 12px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
:global(.adm-form-item-has-error) {
|
||||
.adm-input {
|
||||
border-color: #ff4d4f;
|
||||
|
||||
&:focus {
|
||||
border-color: #ff4d4f;
|
||||
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.adm-selector-item {
|
||||
border-color: #ff4d4f;
|
||||
}
|
||||
|
||||
.adm-stepper-button,
|
||||
.adm-stepper-input {
|
||||
border-color: #ff4d4f;
|
||||
}
|
||||
}
|
||||
|
||||
// 响应式设计
|
||||
@media (max-width: 480px) {
|
||||
.container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.sectionTitle {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin-top: 16px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
:global {
|
||||
.adm-form-item-label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.adm-input {
|
||||
padding: 8px 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.adm-selector-item {
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.adm-button {
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载状态
|
||||
.loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
// 提示信息
|
||||
.tip {
|
||||
background: #f6ffed;
|
||||
border: 1px solid #b7eb8f;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
color: #52c41a;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background: #fff7e6;
|
||||
border: 1px solid #ffd591;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
color: #fa8c16;
|
||||
line-height: 1.5;
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import {
|
||||
Button,
|
||||
Toast,
|
||||
Form,
|
||||
Input,
|
||||
Selector,
|
||||
Stepper,
|
||||
DatePicker,
|
||||
Card,
|
||||
Space,
|
||||
} from "antd-mobile";
|
||||
import NavCommon from "@/components/NavCommon";
|
||||
import Layout from "@/components/Layout/Layout";
|
||||
import {
|
||||
createContactImportTask,
|
||||
updateContactImportTask,
|
||||
fetchContactImportTaskDetail,
|
||||
fetchDeviceGroups,
|
||||
} from "../list/api";
|
||||
import {
|
||||
CreateContactImportTaskData,
|
||||
UpdateContactImportTaskData,
|
||||
ContactImportTask,
|
||||
DeviceGroup,
|
||||
} from "../list/data";
|
||||
import style from "./index.module.scss";
|
||||
|
||||
const ContactImportForm: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id?: string }>();
|
||||
const isEdit = !!id;
|
||||
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [deviceGroups, setDeviceGroups] = useState<DeviceGroup[]>([]);
|
||||
const [taskData, setTaskData] = useState<ContactImportTask | null>(null);
|
||||
const [showStartTimePicker, setShowStartTimePicker] = useState(false);
|
||||
const [showEndTimePicker, setShowEndTimePicker] = useState(false);
|
||||
const [startTime, setStartTime] = useState<Date | null>(null);
|
||||
const [endTime, setEndTime] = useState<Date | null>(null);
|
||||
|
||||
// 备注类型选项
|
||||
const remarkTypeOptions = [
|
||||
{ label: "公司名称", value: "公司名称" },
|
||||
{ label: "职位", value: "职位" },
|
||||
{ label: "部门", value: "部门" },
|
||||
{ label: "地区", value: "地区" },
|
||||
{ label: "行业", value: "行业" },
|
||||
{ label: "来源", value: "来源" },
|
||||
{ label: "标签", value: "标签" },
|
||||
{ label: "自定义", value: "自定义" },
|
||||
];
|
||||
|
||||
// 获取设备组列表
|
||||
const loadDeviceGroups = async () => {
|
||||
try {
|
||||
const data = await fetchDeviceGroups();
|
||||
setDeviceGroups(data);
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
content: "获取设备组失败",
|
||||
icon: "fail",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 获取任务详情(编辑模式)
|
||||
const loadTaskDetail = async () => {
|
||||
if (!id) return;
|
||||
|
||||
try {
|
||||
const data = await fetchContactImportTaskDetail(id);
|
||||
if (data) {
|
||||
setTaskData(data);
|
||||
form.setFieldsValue({
|
||||
name: data.name,
|
||||
deviceGroups: data.deviceGroups,
|
||||
num: data.num,
|
||||
clientId: data.clientId,
|
||||
remarkType: data.remarkType,
|
||||
remarkValue: data.remarkValue,
|
||||
startTime: data.startTime,
|
||||
endTime: data.endTime,
|
||||
maxImportsPerDay: data.maxImportsPerDay,
|
||||
importInterval: data.importInterval,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
content: "获取任务详情失败",
|
||||
icon: "fail",
|
||||
});
|
||||
navigate("/workspace/contact-import/list");
|
||||
}
|
||||
};
|
||||
|
||||
// 提交表单
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
setLoading(true);
|
||||
|
||||
const taskData: CreateContactImportTaskData | UpdateContactImportTaskData = {
|
||||
name: values.name,
|
||||
deviceGroups: values.deviceGroups,
|
||||
num: values.num,
|
||||
clientId: values.clientId,
|
||||
remarkType: values.remarkType,
|
||||
remarkValue: values.remarkValue,
|
||||
startTime: values.startTime,
|
||||
endTime: values.endTime,
|
||||
maxImportsPerDay: values.maxImportsPerDay,
|
||||
importInterval: values.importInterval,
|
||||
};
|
||||
|
||||
if (isEdit && id) {
|
||||
await updateContactImportTask({ ...taskData, id });
|
||||
Toast.show({
|
||||
content: "更新成功",
|
||||
icon: "success",
|
||||
});
|
||||
} else {
|
||||
await createContactImportTask(taskData);
|
||||
Toast.show({
|
||||
content: "创建成功",
|
||||
icon: "success",
|
||||
});
|
||||
}
|
||||
|
||||
navigate("/workspace/contact-import/list");
|
||||
} catch (error) {
|
||||
Toast.show({
|
||||
content: isEdit ? "更新失败" : "创建失败",
|
||||
icon: "fail",
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 重置表单
|
||||
const handleReset = () => {
|
||||
form.resetFields();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadDeviceGroups();
|
||||
if (isEdit) {
|
||||
loadTaskDetail();
|
||||
}
|
||||
}, [id, isEdit]);
|
||||
|
||||
return (
|
||||
<Layout
|
||||
header={
|
||||
<NavCommon
|
||||
left={
|
||||
<Button
|
||||
fill="none"
|
||||
size="small"
|
||||
onClick={() => navigate("/workspace/contact-import/list")}
|
||||
>
|
||||
返回
|
||||
</Button>
|
||||
}
|
||||
title={isEdit ? "编辑通讯录导入" : "新建通讯录导入"}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<div className={style.container}>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
className={style.form}
|
||||
initialValues={{
|
||||
num: 50,
|
||||
maxImportsPerDay: 100,
|
||||
importInterval: 30,
|
||||
startTime: "09:00",
|
||||
endTime: "18:00",
|
||||
}}
|
||||
>
|
||||
{/* 基本信息 */}
|
||||
<Card className={style.section}>
|
||||
<div className={style.sectionTitle}>基本信息</div>
|
||||
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="任务名称"
|
||||
rules={[{ required: true, message: "请输入任务名称" }]}
|
||||
>
|
||||
<Input placeholder="请输入任务名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="deviceGroups"
|
||||
label="设备组"
|
||||
rules={[{ required: true, message: "请选择设备组" }]}
|
||||
>
|
||||
<Selector
|
||||
multiple
|
||||
options={deviceGroups.map(group => ({
|
||||
label: `${group.name} (${group.deviceCount}台设备)`,
|
||||
value: group.id,
|
||||
}))}
|
||||
placeholder="请选择设备组"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
{/* 导入配置 */}
|
||||
<Card className={style.section}>
|
||||
<div className={style.sectionTitle}>导入配置</div>
|
||||
|
||||
<Form.Item
|
||||
name="num"
|
||||
label="导入数量"
|
||||
rules={[{ required: true, message: "请设置导入数量" }]}
|
||||
>
|
||||
<Stepper min={1} max={1000} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="clientId"
|
||||
label="客户端ID"
|
||||
rules={[{ required: true, message: "请输入客户端ID" }]}
|
||||
>
|
||||
<Input placeholder="请输入客户端ID" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="remarkType"
|
||||
label="备注类型"
|
||||
rules={[{ required: true, message: "请选择备注类型" }]}
|
||||
>
|
||||
<Selector
|
||||
options={remarkTypeOptions}
|
||||
placeholder="请选择备注类型"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="remarkValue"
|
||||
label="备注内容"
|
||||
rules={[{ required: true, message: "请输入备注内容" }]}
|
||||
>
|
||||
<Input placeholder="请输入备注内容" />
|
||||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
{/* 时间配置 */}
|
||||
<Card className={style.section}>
|
||||
<div className={style.sectionTitle}>时间配置</div>
|
||||
|
||||
<Form.Item
|
||||
name="startTime"
|
||||
label="开始时间"
|
||||
rules={[{ required: true, message: "请选择开始时间" }]}
|
||||
>
|
||||
<Input
|
||||
readOnly
|
||||
value={startTime ? `${startTime.getHours().toString().padStart(2, '0')}:${startTime.getMinutes().toString().padStart(2, '0')}` : ""}
|
||||
placeholder="请选择开始时间"
|
||||
onClick={() => setShowStartTimePicker(true)}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="endTime"
|
||||
label="结束时间"
|
||||
rules={[{ required: true, message: "请选择结束时间" }]}
|
||||
>
|
||||
<Input
|
||||
readOnly
|
||||
value={endTime ? `${endTime.getHours().toString().padStart(2, '0')}:${endTime.getMinutes().toString().padStart(2, '0')}` : ""}
|
||||
placeholder="请选择结束时间"
|
||||
onClick={() => setShowEndTimePicker(true)}
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<DatePicker
|
||||
visible={showStartTimePicker}
|
||||
title="选择开始时间"
|
||||
precision="minute"
|
||||
value={startTime}
|
||||
onClose={() => setShowStartTimePicker(false)}
|
||||
onConfirm={(val) => {
|
||||
setStartTime(val);
|
||||
form.setFieldValue('startTime', `${val.getHours().toString().padStart(2, '0')}:${val.getMinutes().toString().padStart(2, '0')}`);
|
||||
setShowStartTimePicker(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
<DatePicker
|
||||
visible={showEndTimePicker}
|
||||
title="选择结束时间"
|
||||
precision="minute"
|
||||
value={endTime}
|
||||
onClose={() => setShowEndTimePicker(false)}
|
||||
onConfirm={(val) => {
|
||||
setEndTime(val);
|
||||
form.setFieldValue('endTime', `${val.getHours().toString().padStart(2, '0')}:${val.getMinutes().toString().padStart(2, '0')}`);
|
||||
setShowEndTimePicker(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
<Form.Item
|
||||
name="maxImportsPerDay"
|
||||
label="每日最大导入数"
|
||||
rules={[{ required: true, message: "请设置每日最大导入数" }]}
|
||||
>
|
||||
<Stepper min={1} max={10000} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="importInterval"
|
||||
label="导入间隔(分钟)"
|
||||
rules={[{ required: true, message: "请设置导入间隔" }]}
|
||||
>
|
||||
<Stepper min={1} max={1440} />
|
||||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
{/* 操作按钮 */}
|
||||
<div className={style.actions}>
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Button
|
||||
color="primary"
|
||||
size="large"
|
||||
block
|
||||
loading={loading}
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
{isEdit ? "更新任务" : "创建任务"}
|
||||
</Button>
|
||||
<Button
|
||||
size="large"
|
||||
block
|
||||
onClick={handleReset}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
export default ContactImportForm;
|
||||
@@ -0,0 +1,84 @@
|
||||
import request from "@/api/request";
|
||||
import {
|
||||
ContactImportTask,
|
||||
CreateContactImportTaskData,
|
||||
UpdateContactImportTaskData,
|
||||
ContactImportRecord,
|
||||
PaginatedResponse,
|
||||
ImportStats,
|
||||
} from "./data";
|
||||
|
||||
// 获取通讯录导入任务列表
|
||||
export function fetchContactImportTasks(
|
||||
params = { type: 6, page: 1, limit: 10 },
|
||||
): Promise<{ code: number; msg: string; data: { list: ContactImportTask[] } }> {
|
||||
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");
|
||||
}
|
||||
130
Cunkebao/src/pages/mobile/workspace/contact-import/list/data.ts
Normal file
130
Cunkebao/src/pages/mobile/workspace/contact-import/list/data.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
// 通讯录导入任务状态
|
||||
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,247 @@
|
||||
.container {
|
||||
padding: 12px;
|
||||
background-color: #f5f5f5;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.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) {
|
||||
.container {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.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
|
||||
left={
|
||||
<Button
|
||||
fill="none"
|
||||
size="small"
|
||||
onClick={() => navigate("/workspace")}
|
||||
>
|
||||
返回
|
||||
</Button>
|
||||
}
|
||||
title="通讯录导入"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<div className={style.container}>
|
||||
{/* 搜索和操作栏 */}
|
||||
<div className={style.toolbar}>
|
||||
<div className={style.searchBox}>
|
||||
<Input
|
||||
placeholder="搜索任务名称或备注类型"
|
||||
prefix={<SearchOutlined />}
|
||||
value={searchKeyword}
|
||||
onChange={(e) => handleSearch(e.target.value)}
|
||||
allowClear
|
||||
/>
|
||||
</div>
|
||||
<div className={style.actions}>
|
||||
<Button
|
||||
size="small"
|
||||
fill="none"
|
||||
onClick={loadTasks}
|
||||
loading={loading}
|
||||
>
|
||||
<ReloadOutlined />
|
||||
</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
size="small"
|
||||
onClick={() => navigate("/workspace/contact-import/form")}
|
||||
>
|
||||
<PlusOutlined /> 新建
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 任务列表 */}
|
||||
<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,
|
||||
LinkOutlined,
|
||||
ClockCircleOutlined,
|
||||
ContactsOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import Layout from "@/components/Layout/Layout";
|
||||
import MeauMobile from "@/components/MeauMobile/MeauMoible";
|
||||
@@ -69,6 +70,17 @@ const Workspace: React.FC = () => {
|
||||
path: "/workspace/traffic-distribution",
|
||||
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 (
|
||||
|
||||
@@ -15,6 +15,9 @@ import AIAssistant from "@/pages/mobile/workspace/ai-assistant/AIAssistant";
|
||||
import TrafficDistribution from "@/pages/mobile/workspace/traffic-distribution/list/index";
|
||||
import TrafficDistributionDetail from "@/pages/mobile/workspace/traffic-distribution/detail/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 AiAnalyzer from "@/pages/mobile/workspace/ai-analyzer";
|
||||
|
||||
@@ -154,6 +157,27 @@ const workspaceRoutes = [
|
||||
element: <TrafficDistributionDetail />,
|
||||
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;
|
||||
|
||||
@@ -556,12 +556,12 @@ class WorkbenchController extends Controller
|
||||
}
|
||||
break;
|
||||
case self::TYPE_IMPORT_CONTACT:
|
||||
if (!empty($item->importContact)) {
|
||||
$item->config = $item->importContact;
|
||||
$item->config->devices = json_decode($item->config->devices, true);
|
||||
$item->config->pools = json_decode($item->config->pools, true);
|
||||
if (!empty($workbench->importContact)) {
|
||||
$workbench->config = $workbench->importContact;
|
||||
$workbench->config->devices = json_decode($workbench->config->devices, true);
|
||||
$workbench->config->pools = json_decode($workbench->config->pools, true);
|
||||
}
|
||||
unset($item->importContact, $item->import_contact);
|
||||
unset($workbench->importContact, $workbench->import_contact);
|
||||
break;
|
||||
}
|
||||
unset(
|
||||
@@ -991,11 +991,12 @@ class WorkbenchController extends Controller
|
||||
}
|
||||
break;
|
||||
case self::TYPE_IMPORT_CONTACT: //联系人导入
|
||||
$config = WorkbenchImportContact::where('workbenchId',$id)->find();;
|
||||
$config = WorkbenchImportContact::where('workbenchId',$id)->find();
|
||||
if ($config) {
|
||||
$newConfig = new WorkbenchImportContact;
|
||||
$newConfig->devices = json_encode($config->deveiceGroups);
|
||||
$newConfig->pools = json_encode($config->pools);
|
||||
$newConfig->workbenchId = $newWorkbench->id;
|
||||
$newConfig->devices = $config->devices;
|
||||
$newConfig->pools = $config->pools;
|
||||
$newConfig->num = $config->num;
|
||||
$newConfig->clearContact = $config->clearContact;
|
||||
$newConfig->remark = $config->remark;
|
||||
|
||||
@@ -64,7 +64,7 @@ class Workbench extends Model
|
||||
|
||||
public function importContact()
|
||||
{
|
||||
return $this->hasOne('WorkbenchTrafficConfig', 'workbenchId', 'id');
|
||||
return $this->hasOne('WorkbenchImportContact', 'workbenchId', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ class WorkbenchImportContactJob
|
||||
*/
|
||||
protected function getDeviceList($workbench, $config)
|
||||
{
|
||||
$deviceIds = json_decode($config['deviceId'], true);
|
||||
$deviceIds = json_decode($config['devices'], true);
|
||||
if (empty($deviceIds)) {
|
||||
return [];
|
||||
}
|
||||
@@ -313,7 +313,7 @@ class WorkbenchImportContactJob
|
||||
protected function getContactFromDatabase($workbench,$config)
|
||||
{
|
||||
$pools = json_decode($config['pools'], true);
|
||||
$deviceIds = json_decode($config['deviceId'], true);
|
||||
$deviceIds = json_decode($config['devices'], true);
|
||||
if (empty($pools) || empty($deviceIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user