Commit d92e639f authored by 皮倩雯's avatar 皮倩雯

fix: '定时任务优化'

parent f4001def
Pipeline #77037 passed with stages
.lookModal {
width: 100%;
height: 700px;
display: flex;
flex-direction: column;
overflow: hidden;
.header {
display: flex;
flex-wrap: wrap;
align-items: center;
width: 100%;
padding: 5px 10px;
.select {
margin: 0 10px;
}
.radioList {
margin: 0px 10px;
}
}
.table {
flex: 1;
overflow: hidden;
padding: 10px 10px 0px 10px;
:global {
.ant-table-wrapper {
height: 100%;
.ant-spin-nested-loading {
height: 100%;
.ant-spin-container {
height: 100%;
.ant-table.ant-table-small {
height: 100%;
.ant-table-container {
height: 100%;
}
}
}
}
}
}
}
.footer {
padding: 10px;
display: flex;
justify-content: flex-end;
}
}
......@@ -16,11 +16,11 @@ import {
Select,
} from 'antd';
import {
SearchOutlined,
FundViewOutlined,
EditTwoTone,
DeleteOutlined,
PlusOutlined,
CalendarOutlined,
ZoomInOutlined,
} from '@ant-design/icons';
import 'moment/dist/locale/zh-cn';
import styles from './index.less';
......@@ -28,22 +28,28 @@ import {
GetIISAgentConfig,
DeleteIISAgentConfig,
AddIISAgentConfig,
GetIISAgentLog,
} from '@/services/scheduledTasks/api';
import AddModal from './components/AddModal';
import LookModal from './components/LookModal';
import PushTest from './components/PushTest/PushTest';
const { Option } = Select;
let timer = null;
const ScheduledTasks = () => {
const [loading, setLoading] = useState(false); // 源数据
const [requestUrl, setRequestUrl] = useState(''); // 接口名称筛选
const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
const [keepTableList, setKeepTableList] = useState([]);
const [addVisible, setAddVisible] = useState(false);
const [lookVisible, setLookVisible] = useState(false);
const [type, setType] = useState('');
const [recordItem, setRecordItem] = useState();
const [pushTestVisible, setPushTestVisible] = useState(false);
const typeValue = useRef('重复执行');
const [columnsData, setColumnsData] = useState([]);
const scroll = useRef();
const [logList, setLogList] = useState([]);
const columns = [
{
......@@ -172,8 +178,83 @@ const ScheduledTasks = () => {
useEffect(() => {
getTableList();
setColumnsData(columns);
getIISAgentLog();
return () => {
clearInterval(timer);
timer = null;
};
}, []);
const getIISAgentLog = () => {
// const worker = new Worker('logWorker.js');
// GetIISAgentLog().then(res => {
// if (res.code === 0) {
// debugger;
// worker.postMessage(res.data);
// worker.onmessage = e => {
// setLogList(e.data);
// debugger;
// scroll.current.scrollTop = scroll.current.scrollHeight;
// timer = setTimeout(() => {
// getIISAgentLog();
// }, 2000);
// };
// } else {
// notification.error({
// message: '提示',
// duration: 3,
// description: res.msg,
// });
// clearInterval(timer);
// timer = null;
// }
// });
GetIISAgentLog().then(res => {
if (res.code === 0) {
let arr = [];
arr.push(
res.data.split(/(\r\n)|(\n)/).map((item, index) => {
// eslint-disable-next-line react/no-danger
let mes = item?.indexOf('[信息]');
let warn = item?.indexOf('[警告]');
if (mes !== -1) {
return (
<div
style={{ color: 'aqua' }}
key={index}
dangerouslySetInnerHTML={{ __html: item }}
/>
);
} else if (warn !== -1) {
return (
<div
style={{ color: 'yellow' }}
key={index}
dangerouslySetInnerHTML={{ __html: item }}
/>
);
} else {
return <div key={index} dangerouslySetInnerHTML={{ __html: item }} />;
}
}),
);
setLogList(arr);
scroll.current.scrollTop = scroll.current.scrollHeight;
timer = setTimeout(() => {
getIISAgentLog();
}, 2000);
} else {
notification.error({
message: '提示',
duration: 3,
description: res.msg,
});
clearInterval(timer);
timer = null;
}
});
};
const getTableList = (search, planType) => {
let newSearch = search ? search : requestUrl;
let newType = planType ? planType : typeValue.current;
......@@ -199,17 +280,6 @@ const ScheduledTasks = () => {
});
};
const changeSwitch = (e, record) => {
// AddIISAgentConfig({ ...record, Enabled: e }).then(res => {
// if (res.code === 0) {
// getTableList();
// message.success(e ? `开启成功!` : `关闭成功!`);
// } else {
// message.error(res.msg);
// }
// });
};
const TestDesc = val => {
setRecordItem(val);
setPushTestVisible(true);
......@@ -256,6 +326,10 @@ const ScheduledTasks = () => {
setAddVisible(true);
};
const handleLook = () => {
setLookVisible(true);
};
const onOk = val => {
changeTable(val);
typeValue.current = val;
......@@ -305,6 +379,17 @@ const ScheduledTasks = () => {
/>
</div>
<div className={styles.headRight}>
<Button
icon={<ZoomInOutlined className={styles.icon} />}
onClick={handleLook}
style={{
marginLeft: '25px',
verticalAlign: 'middle',
marginTop: '-3px',
}}
>
调用日志
</Button>
<Button
icon={<PlusOutlined className={styles.icon} />}
type="primary"
......@@ -331,10 +416,19 @@ const ScheduledTasks = () => {
editData(record);
}, // 双击
})}
scroll={{ y: 'calc(100vh - 225px)' }}
scroll={{ y: 'calc(100% - 40px)' }}
pagination={false}
loading={loading}
/>
</div>
<div className={styles.footer}>
<CalendarOutlined style={{ color: '#1685ff' }} />
<span style={{ marginLeft: '10px', fontWeight: 'bold' }}>运行日志</span>
<div className={styles.runLog} ref={scroll}>
{logList}
<div className={styles.blinkingCursor}>|</div>
</div>
</div>
<AddModal
visible={addVisible}
onCancel={() => setAddVisible(false)}
......@@ -342,6 +436,11 @@ const ScheduledTasks = () => {
type={type}
record={recordItem}
/>
<LookModal
visible={lookVisible}
onCancel={() => setLookVisible(false)}
keepTableList={keepTableList}
/>
<PushTest
visible={pushTestVisible}
onCancel={() => setPushTestVisible(false)}
......
.scheduledTasks {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
.head {
padding: 10px;
background: white;
margin-bottom: 2px;
width: 100%;
height: 52px;
display: flex;
justify-content: space-between;
align-items: center;
.headLeft{
.headLeft {
display: flex;
align-items: center;
}
}
.table {
height: calc(100% - 53px);
flex: 1;
width: 100%;
background-color: white;
padding: 10px;
overflow: hidden;
margin-bottom: 3px;
:global {
.ant-table-wrapper {
height: 100%;
.ant-spin-nested-loading {
height: 100%;
.ant-spin-container {
height: 100%;
.ant-table.ant-table-small {
height: 100%;
.ant-table-container {
height: calc(100vh - 185px);
height: 100%;
}
}
}
}
}
}
}
.footer {
height: 350px;
width: 100%;
background-color: white;
padding: 10px;
:global {
::-webkit-scrollbar-thumb {
border-radius: 0;
}
::-webkit-scrollbar {
display: none;
}
}
.runLog {
margin-top: 5px;
width: 100%;
height: 305px;
background-color: #000040;
overflow-y: scroll;
color: #808080;
padding: 0 10px;
@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.blinkingCursor {
color: #ffffff;
animation: blink 1s infinite;
}
}
}
.icon {
......
......@@ -8,3 +8,12 @@ export const GetIISAgentConfig = param =>
export const DeleteIISAgentConfig = param =>
get(`${PUBLISH_SERVICE}/MessageConfig/DeleteIISAgentConfig`, param); // 删除助理服务器配置
export const GetIISAgentLog = param =>
get(`${PUBLISH_SERVICE}/MessageConfig/GetIISAgentLog`, param); // 删除助理服务器配置
export const GetIISAgentSite = param =>
get(`${PUBLISH_SERVICE}/MessageConfig/GetIISAgentSite`, param); // 获取 siteName
export const QueryIISAgentCalllog = data =>
post(`${PUBLISH_SERVICE}/MessageConfig/QueryIISAgentCalllog`, data); // 获取调用日志的接口
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment