<!DOCTYPE html>
|
<html lang="zh-CN">
|
<head>
|
<meta charset="UTF-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<style>
|
* {
|
margin: 0;
|
padding: 0;
|
box-sizing: border-box;
|
}
|
|
body {
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
|
padding: 30px;
|
line-height: 1.8;
|
}
|
|
.breadcrumb {
|
font-size: 14px;
|
color: #999;
|
margin-bottom: 25px;
|
padding: 12px 20px;
|
background: linear-gradient(145deg, #ffffff, #f5f5f5);
|
border-radius: 8px;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
}
|
|
.breadcrumb a {
|
color: #999;
|
text-decoration: none;
|
}
|
|
.update-time {
|
float: right;
|
color: #ccc;
|
font-size: 12px;
|
}
|
|
.intro {
|
line-height: 2;
|
margin-bottom: 40px;
|
color: #555;
|
font-size: 16px;
|
padding: 25px;
|
background: linear-gradient(145deg, #ffffff, #f8f9fa);
|
border-radius: 12px;
|
border-left: 4px solid #0066cc;
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
}
|
|
h1 {
|
font-size: 32px;
|
margin-bottom: 30px;
|
padding-bottom: 20px;
|
border-bottom: 3px solid transparent;
|
border-image: linear-gradient(90deg, #0066cc, #00c6ff);
|
border-image-slice: 1;
|
color: #1a1a2e;
|
font-weight: 700;
|
}
|
|
h2 {
|
font-size: 22px;
|
margin: 40px 0 25px;
|
color: #1a1a2e;
|
font-weight: 700;
|
}
|
|
.content-text {
|
line-height: 1.8;
|
color: #666;
|
margin-bottom: 20px;
|
}
|
|
ul.feature-list {
|
list-style: none;
|
padding-left: 20px;
|
}
|
|
ul.feature-list li {
|
position: relative;
|
padding-left: 20px;
|
margin-bottom: 10px;
|
line-height: 1.8;
|
color: #666;
|
}
|
|
ul.feature-list li:before {
|
content: "■";
|
position: absolute;
|
left: 0;
|
color: #333;
|
}
|
|
.feedback-section {
|
margin: 40px 0;
|
text-align: center;
|
}
|
|
.stars {
|
margin: 20px 0;
|
}
|
|
.stars span {
|
font-size: 30px;
|
margin: 0 10px;
|
color: #ddd;
|
cursor: pointer;
|
}
|
|
.pagination {
|
display: flex;
|
justify-content: space-between;
|
margin-top: 60px;
|
padding-top: 30px;
|
border-top: 1px solid #e0e0e0;
|
}
|
|
.pagination > div {
|
cursor: pointer;
|
max-width: 45%;
|
}
|
|
.pagination > div:hover {
|
color: #0066cc;
|
}
|
|
.api-section {
|
margin: 40px 0;
|
padding: 30px;
|
background: linear-gradient(145deg, #ffffff, #f0f0f0);
|
border-radius: 16px;
|
box-shadow: 0 8px 32px rgba(0, 102, 204, 0.1);
|
transition: all 0.3s ease;
|
}
|
|
.api-section:hover {
|
box-shadow: 0 12px 48px rgba(0, 102, 204, 0.15);
|
transform: translateY(-2px);
|
}
|
|
.api-section h2 {
|
margin-top: 0;
|
background: linear-gradient(135deg, #0066cc, #00c6ff);
|
-webkit-background-clip: text;
|
-webkit-text-fill-color: transparent;
|
background-clip: text;
|
font-size: 24px;
|
font-weight: 700;
|
position: relative;
|
padding-left: 20px;
|
}
|
|
.api-section h2::before {
|
content: '';
|
position: absolute;
|
left: 0;
|
top: 50%;
|
transform: translateY(-50%);
|
width: 6px;
|
height: 24px;
|
background: linear-gradient(135deg, #0066cc, #00c6ff);
|
border-radius: 3px;
|
}
|
|
.api-info {
|
background-color: #fff;
|
padding: 25px;
|
margin: 20px 0;
|
border-radius: 12px;
|
border-left: 5px solid #0066cc;
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
|
transition: all 0.3s ease;
|
}
|
|
.api-info:hover {
|
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
|
}
|
|
.api-method {
|
display: inline-block;
|
padding: 6px 16px;
|
border-radius: 20px;
|
font-weight: 700;
|
margin-right: 12px;
|
font-size: 13px;
|
text-transform: uppercase;
|
letter-spacing: 0.5px;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
transition: all 0.3s ease;
|
}
|
|
.api-method:hover {
|
transform: translateY(-1px);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
}
|
|
.method-post {
|
background: linear-gradient(135deg, #49cc90, #38b57d);
|
color: #fff;
|
}
|
|
.method-get {
|
background: linear-gradient(135deg, #61affe, #4e98eb);
|
color: #fff;
|
}
|
|
.method-put {
|
background: linear-gradient(135deg, #fca130, #e89020);
|
color: #fff;
|
}
|
|
.method-delete {
|
background: linear-gradient(135deg, #f93e3e, #e62e2e);
|
color: #fff;
|
}
|
|
.api-url {
|
font-family: 'Courier New', 'Consolas', monospace;
|
background: linear-gradient(135deg, #2d3748, #1a202c);
|
color: #48bb78;
|
padding: 14px 18px;
|
margin: 15px 0;
|
border-radius: 8px;
|
font-size: 14px;
|
word-break: break-all;
|
border: 1px solid #4a5568;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
position: relative;
|
overflow: hidden;
|
}
|
|
.api-url::before {
|
content: '';
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 4px;
|
height: 100%;
|
background: linear-gradient(180deg, #48bb78, #38a169);
|
}
|
|
table {
|
width: 100%;
|
border-collapse: collapse;
|
margin: 15px 0;
|
background-color: #fff;
|
}
|
|
table th,
|
table td {
|
padding: 12px;
|
text-align: left;
|
border: 1px solid #e0e0e0;
|
font-size: 14px;
|
}
|
|
table th {
|
background: linear-gradient(135deg, #667eea, #764ba2);
|
font-weight: 700;
|
color: #fff;
|
text-transform: uppercase;
|
font-size: 12px;
|
letter-spacing: 0.5px;
|
}
|
|
table tr:hover {
|
background-color: #f8f9fa;
|
transition: background-color 0.2s ease;
|
}
|
|
pre {
|
background: linear-gradient(135deg, #1e1e1e, #2d2d30);
|
color: #d4d4d4;
|
padding: 24px;
|
border-radius: 12px;
|
overflow-x: auto;
|
margin: 20px 0;
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
|
border: 1px solid #3e3e42;
|
position: relative;
|
}
|
|
pre::before {
|
content: '{ }';
|
position: absolute;
|
top: 10px;
|
right: 15px;
|
color: #858585;
|
font-size: 12px;
|
font-weight: bold;
|
}
|
|
code {
|
font-family: 'Courier New', monospace;
|
font-size: 13px;
|
line-height: 1.6;
|
}
|
|
.mock-container {
|
background: linear-gradient(145deg, #ffffff, #f8f9fa);
|
padding: 25px;
|
margin: 25px 0;
|
border-radius: 16px;
|
box-shadow: 0 8px 24px rgba(0, 102, 204, 0.12);
|
border: 2px solid #e3e8ef;
|
transition: all 0.3s ease;
|
}
|
|
.mock-container:hover {
|
box-shadow: 0 12px 32px rgba(0, 102, 204, 0.18);
|
border-color: #0066cc;
|
}
|
|
.mock-btn {
|
background: linear-gradient(135deg, #0066cc, #0052a3);
|
color: #fff;
|
border: none;
|
padding: 12px 28px;
|
border-radius: 25px;
|
cursor: pointer;
|
font-size: 14px;
|
font-weight: 600;
|
margin: 5px;
|
height: 44px;
|
line-height: 20px;
|
box-shadow: 0 4px 15px rgba(0, 102, 204, 0.3);
|
transition: all 0.3s ease;
|
position: relative;
|
overflow: hidden;
|
box-sizing: border-box;
|
}
|
|
.mock-btn::before {
|
content: '';
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
width: 0;
|
height: 0;
|
border-radius: 50%;
|
background: rgba(255, 255, 255, 0.3);
|
transform: translate(-50%, -50%);
|
transition: width 0.6s, height 0.6s;
|
}
|
|
.mock-btn:hover {
|
background: linear-gradient(135deg, #0052a3, #003d7a);
|
box-shadow: 0 6px 20px rgba(0, 102, 204, 0.4);
|
transform: translateY(-2px);
|
}
|
|
.mock-btn:hover::before {
|
width: 300px;
|
height: 300px;
|
}
|
|
.mock-btn:active {
|
transform: translateY(0);
|
box-shadow: 0 2px 10px rgba(0, 102, 204, 0.3);
|
}
|
|
.reset-btn {
|
background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
|
color: #666;
|
border: 1px solid #d0d0d0;
|
padding: 12px 28px;
|
border-radius: 25px;
|
cursor: pointer;
|
font-size: 14px;
|
font-weight: 600;
|
margin: 5px;
|
height: 44px;
|
line-height: 20px;
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
transition: all 0.3s ease;
|
box-sizing: border-box;
|
}
|
|
.reset-btn:hover {
|
background: linear-gradient(135deg, #e0e0e0, #d0d0d0);
|
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
|
transform: translateY(-2px);
|
color: #444;
|
}
|
|
.reset-btn:active {
|
transform: translateY(0);
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
}
|
|
.mode-switch {
|
display: flex;
|
gap: 10px;
|
margin-bottom: 20px;
|
padding: 5px;
|
background: #f0f2f5;
|
border-radius: 25px;
|
width: fit-content;
|
}
|
|
.mode-switch button {
|
padding: 8px 20px;
|
border: none;
|
border-radius: 20px;
|
cursor: pointer;
|
font-size: 13px;
|
font-weight: 600;
|
transition: all 0.3s ease;
|
background: transparent;
|
color: #666;
|
}
|
|
.mode-switch button.active {
|
background: linear-gradient(135deg, #0066cc, #0052a3);
|
color: #fff;
|
box-shadow: 0 2px 10px rgba(0, 102, 204, 0.3);
|
}
|
|
.mode-switch button:hover:not(.active) {
|
background: #e0e0e0;
|
}
|
|
.json-input-container {
|
display: none;
|
}
|
|
.json-input-container.active {
|
display: block;
|
}
|
|
.form-input-container {
|
display: block;
|
}
|
|
.form-input-container.hidden {
|
display: none;
|
}
|
|
.json-textarea {
|
width: 100%;
|
min-height: 200px;
|
padding: 15px;
|
border: 2px solid #e3e8ef;
|
border-radius: 12px;
|
font-family: 'Courier New', monospace;
|
font-size: 13px;
|
line-height: 1.6;
|
resize: vertical;
|
transition: all 0.3s ease;
|
background: #fafbfc;
|
}
|
|
.json-textarea:focus {
|
outline: none;
|
border-color: #0066cc;
|
box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
|
background: #fff;
|
}
|
|
.json-textarea.error {
|
border-color: #f93e3e;
|
background: #fff5f5;
|
}
|
|
.mock-result {
|
background: linear-gradient(145deg, #f8f9fa, #e9ecef);
|
padding: 20px;
|
margin-top: 20px;
|
border-radius: 12px;
|
max-height: 500px;
|
overflow-y: auto;
|
display: none;
|
border: 2px solid #dee2e6;
|
box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05);
|
animation: slideDown 0.3s ease;
|
}
|
|
.mock-result.show {
|
display: block;
|
}
|
|
@keyframes slideDown {
|
from {
|
opacity: 0;
|
transform: translateY(-10px);
|
}
|
to {
|
opacity: 1;
|
transform: translateY(0);
|
}
|
}
|
|
.mock-form {
|
background: linear-gradient(145deg, #ffffff, #f8f9fa);
|
padding: 20px;
|
margin-top: 15px;
|
border-radius: 12px;
|
border: 1px solid #e3e8ef;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
}
|
|
.mock-form h5 {
|
color: #333;
|
margin-bottom: 15px;
|
font-size: 14px;
|
font-weight: 600;
|
}
|
|
.form-group {
|
margin-bottom: 15px;
|
}
|
|
.form-group label {
|
display: block;
|
margin-bottom: 6px;
|
color: #555;
|
font-size: 13px;
|
font-weight: 500;
|
}
|
|
.form-group label .required {
|
color: #f93e3e;
|
margin-left: 3px;
|
}
|
|
.form-group input,
|
.form-group select {
|
width: 100%;
|
padding: 10px 12px;
|
border: 1px solid #d1d5db;
|
border-radius: 6px;
|
font-size: 13px;
|
color: #333;
|
background: #fff;
|
transition: all 0.2s ease;
|
}
|
|
.form-group input:focus,
|
.form-group select:focus {
|
outline: none;
|
border-color: #0066cc;
|
box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
|
}
|
|
.form-group input.error,
|
.form-group select.error {
|
border-color: #f93e3e;
|
background: #fff5f5;
|
}
|
|
.form-group .error-msg {
|
color: #f93e3e;
|
font-size: 12px;
|
margin-top: 5px;
|
display: none;
|
}
|
|
.form-group .error-msg.show {
|
display: block;
|
}
|
|
.error-msg {
|
color: #f93e3e;
|
font-size: 12px;
|
margin-top: 5px;
|
display: none;
|
}
|
|
.error-msg.show {
|
display: block;
|
}
|
|
.error-message {
|
color: #f93e3e;
|
font-size: 12px;
|
margin-top: 5px;
|
display: none;
|
}
|
|
.error-message.show {
|
display: block;
|
}
|
|
.form-group .hint {
|
color: #999;
|
font-size: 12px;
|
margin-top: 4px;
|
}
|
|
.mock-form-actions {
|
display: flex;
|
gap: 10px;
|
margin-top: 20px;
|
}
|
|
.mock-btn-secondary {
|
background: linear-gradient(135deg, #6c757d, #5a6268);
|
color: #fff;
|
border: none;
|
padding: 12px 28px;
|
border-radius: 25px;
|
cursor: pointer;
|
font-size: 14px;
|
font-weight: 600;
|
box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
|
transition: all 0.3s ease;
|
}
|
|
.mock-btn-secondary:hover {
|
background: linear-gradient(135deg, #5a6268, #495057);
|
transform: translateY(-2px);
|
}
|
|
.mock-btn-secondary:active {
|
transform: translateY(0);
|
}
|
|
.tag {
|
display: inline-block;
|
padding: 5px 14px;
|
color: #0b0b0b;
|
border-radius: 12px;
|
font-size: 14px;
|
font-weight: 700;
|
margin-left: 10px;
|
text-transform: uppercase;
|
letter-spacing: 0.5px;
|
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
|
}
|
|
.note {
|
background: linear-gradient(135deg, #fff9e6, #fff3cd);
|
border-left: 5px solid #ffc107;
|
padding: 20px;
|
margin: 20px 0;
|
border-radius: 12px;
|
box-shadow: 0 4px 12px rgba(255, 193, 7, 0.15);
|
position: relative;
|
overflow: hidden;
|
}
|
|
.note::before {
|
content: '⚠';
|
position: absolute;
|
top: 15px;
|
right: 15px;
|
font-size: 24px;
|
opacity: 0.2;
|
}
|
|
.note-title {
|
font-weight: 700;
|
color: #856404;
|
margin-bottom: 10px;
|
font-size: 16px;
|
display: flex;
|
align-items: center;
|
}
|
|
.note-title::before {
|
content: '💡';
|
margin-right: 8px;
|
}
|
|
h3 {
|
font-size: 18px;
|
color: #2c3e50;
|
margin: 20px 0 15px;
|
font-weight: 600;
|
}
|
|
h4 {
|
font-size: 16px;
|
color: #34495e;
|
margin: 18px 0 12px;
|
font-weight: 600;
|
padding-left: 12px;
|
border-left: 3px solid #0066cc;
|
}
|
|
/* 滚动条美化 */
|
::-webkit-scrollbar {
|
width: 8px;
|
height: 8px;
|
}
|
|
::-webkit-scrollbar-track {
|
background: #f1f1f1;
|
border-radius: 4px;
|
}
|
|
::-webkit-scrollbar-thumb {
|
background: linear-gradient(135deg, #667eea, #764ba2);
|
border-radius: 4px;
|
}
|
|
::-webkit-scrollbar-thumb:hover {
|
background: linear-gradient(135deg, #764ba2, #667eea);
|
}
|
|
/* Mock测试折叠功能 */
|
.mock-container {
|
position: relative;
|
}
|
|
.mock-container .mock-toggle-btn {
|
position: absolute;
|
top: 0;
|
right: 0;
|
background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
|
border: 1px solid #d0d0d0;
|
border-radius: 6px;
|
padding: 6px 12px;
|
cursor: pointer;
|
font-size: 12px;
|
font-weight: 600;
|
color: #666;
|
transition: all 0.3s ease;
|
z-index: 10;
|
}
|
|
.mock-container .mock-toggle-btn:hover {
|
background: linear-gradient(135deg, #e0e0e0, #d0d0d0);
|
color: #444;
|
}
|
|
.mock-container .mock-content {
|
transition: all 0.3s ease;
|
overflow: hidden;
|
}
|
|
.mock-container .mock-content.collapsed {
|
max-height: 0;
|
opacity: 0;
|
margin-top: 0;
|
padding-top: 0;
|
padding-bottom: 0;
|
}
|
|
.mock-container .mock-content.expanded {
|
max-height: 2000px;
|
opacity: 1;
|
}
|
|
/* 加载动画 */
|
@keyframes pulse {
|
0%, 100% {
|
opacity: 1;
|
}
|
50% {
|
opacity: 0.5;
|
}
|
}
|
|
.loading {
|
animation: pulse 1.5s ease-in-out infinite;
|
}
|
|
/* 渐入动画 */
|
@keyframes fadeIn {
|
from {
|
opacity: 0;
|
transform: translateY(20px);
|
}
|
to {
|
opacity: 1;
|
transform: translateY(0);
|
}
|
}
|
|
.api-section {
|
animation: fadeIn 0.6s ease-out;
|
}
|
|
/* 代码复制按钮 */
|
.code-wrapper {
|
position: relative;
|
}
|
|
.copy-btn {
|
position: absolute;
|
top: 10px;
|
right: 10px;
|
background: rgba(255, 255, 255, 0.1);
|
color: #d4d4d4;
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
padding: 6px 12px;
|
border-radius: 6px;
|
cursor: pointer;
|
font-size: 12px;
|
transition: all 0.3s ease;
|
opacity: 0;
|
}
|
|
.code-wrapper:hover .copy-btn {
|
opacity: 1;
|
}
|
|
.copy-btn:hover {
|
background: rgba(255, 255, 255, 0.2);
|
border-color: rgba(255, 255, 255, 0.4);
|
}
|
|
/* 成功提示 */
|
.success-icon {
|
color: #49cc90;
|
font-weight: bold;
|
animation: scaleIn 0.3s ease;
|
}
|
|
@keyframes scaleIn {
|
from {
|
transform: scale(0);
|
}
|
to {
|
transform: scale(1);
|
}
|
}
|
</style>
|
</head>
|
<body>
|
<div class="breadcrumb">
|
<a href="#">RCS接口文档</a> > 接口详情
|
<span class="update-time">更新时间:2025-12-29 14:20:00</span>
|
</div>
|
|
<h1>RCS接口文档</h1>
|
|
<div class="intro">
|
<p style="font-size: 16px; margin-bottom: 20px;">欢迎使用中扬RCS开放平台
|
API。本文档提供了完整的接口说明,包含请求参数、返回结果以及示例代码。每个接口都提供了 Mock
|
功能,方便您快速测试和集成。</p>
|
</div>
|
|
<div class="note" style="margin-bottom: 30px;">
|
<div class="note-title">📌 快速对接指南</div>
|
<p style="margin-bottom: 12px;"><strong>接口中标 * 的为常用接口</strong>,初步对接时,只需要调通以下接口:</p>
|
<ul style="list-style: none; padding-left: 0; margin-bottom: 15px;">
|
<li style="padding: 6px 0; padding-left: 25px; position: relative;">
|
<span style="position: absolute; left: 0; color: #0066cc; font-weight: bold;">1.</span>生成任务单
|
</li>
|
<li style="padding: 6px 0; padding-left: 25px; position: relative;">
|
<span style="position: absolute; left: 0; color: #0066cc; font-weight: bold;">2.</span>取消任务单
|
</li>
|
</ul>
|
<p style="margin-bottom: 12px;"><strong>如果上层系统需要接收任务的执行状态</strong>,需要提供以下接口,供调度系统回调:
|
</p>
|
<ul style="list-style: none; padding-left: 0; margin-bottom: 15px;">
|
<li style="padding: 6px 0; padding-left: 25px; position: relative;">
|
<span style="position: absolute; left: 0; color: #0066cc; font-weight: bold;">•</span>任务执行通知接口
|
</li>
|
</ul>
|
<p style="background: #fff3cd; padding: 10px 15px; border-radius: 6px; margin-top: 15px; border-left: 4px solid #ffc107;">
|
⚠️ <strong>超时设置:</strong>中扬调度系统调用上层系统的接口,获取连接超时时间默认为 <strong>30秒</strong>,数据返回超时时间默认为
|
<strong>60秒</strong>,超时情况下,调度系统会返回连接失败。
|
</p>
|
</div>
|
|
<div class="api-info" style="margin-bottom: 30px;">
|
<h3 style="color: #2c3e50; font-size: 18px; margin-bottom: 15px; padding-left: 0; border-left: none;">📋
|
对接约定</h3>
|
<ul style="list-style: none; padding-left: 0;">
|
<li style="padding: 10px 15px; margin-bottom: 8px; background: #f8f9fa; border-radius: 6px; border-left: 3px solid #667eea;">
|
<strong style="color: #667eea;">统一格式:</strong>为接口统一并兼容,所有的参数都为字符串格式。
|
</li>
|
<li style="padding: 10px 15px; margin-bottom: 8px; background: #f8f9fa; border-radius: 6px; border-left: 3px solid #667eea;">
|
<strong style="color: #667eea;">术语约定:</strong>文本涉及到的 AGV、robot、机器人术语、CTU为同一术语,不要混淆。
|
</li>
|
<li style="padding: 10px 15px; margin-bottom: 8px; background: #f8f9fa; border-radius: 6px; border-left: 3px solid #667eea;">
|
<strong style="color: #667eea;">版本兼容:</strong>为兼容以前版本,消息上报字段会比列出的字段要多,上层平台根据业务截取需要的字段。
|
</li>
|
<li style="padding: 10px 15px; margin-bottom: 8px; background: #f8f9fa; border-radius: 6px; border-left: 3px solid #667eea;">
|
<strong style="color: #667eea;">容器定义:</strong>应用于叉车、CTU等项目中,料箱、托盘、载具都可称为容器。
|
</li>
|
</ul>
|
</div>
|
|
<!-- 接口概览 -->
|
<section id="api-overview" class="api-section">
|
<h2>接口概览</h2>
|
<div class="api-info">
|
<h3>🔗 基础信息</h3>
|
<table style="margin-top: 15px;">
|
<tbody>
|
<tr>
|
<td style="width: 30%; font-weight: bold; background: #f8f9fa;">基础 URL</td>
|
<td><code style="background: #282c34; color: #48bb78; padding: 4px 8px; border-radius: 4px;">http://IP:PORT</code>
|
</td>
|
</tr>
|
<tr>
|
<td style="font-weight: bold; background: #f8f9fa;">请求格式</td>
|
<td><code>application/json</code></td>
|
</tr>
|
<tr>
|
<td style="font-weight: bold; background: #f8f9fa;">返回格式</td>
|
<td><code>application/json</code></td>
|
</tr>
|
<tr>
|
<td style="font-weight: bold; background: #f8f9fa;">字符编码</td>
|
<td><code>UTF-8</code></td>
|
</tr>
|
</tbody>
|
</table>
|
</div>
|
|
<div class="api-info">
|
<h3>📋 通用请求参数</h3>
|
<p style="margin-bottom: 15px; color: #666;">以下参数为所有接口的通用参数,每次调用时需要携带:</p>
|
<table>
|
<thead>
|
<tr>
|
<th style="width: 20%;">参数名</th>
|
<th style="width: 15%;">是否必填</th>
|
<th>描述</th>
|
</tr>
|
</thead>
|
<tbody>
|
<tr>
|
<td><code>reqTime</code></td>
|
<td><span style="color: #999;">选填</span></td>
|
<td>请求时间戳,格式: <code>yyyy-MM-dd HH:mm:ss</code>。由上层系统设定。</td>
|
</tr>
|
<!-- <tr>
|
<td><code>clientCode</code></td>
|
<td><span style="color: #999;">选填</span></td>
|
<td>客户端编号,如 PDA、HCWMS 等。如果填写,需先在 RCS-2000 系统配置,上层系统调用时进行填写,当多系统调用时,调度系统可以进行调用方区分。</td>
|
</tr>-->
|
<tr>
|
<td><code>tokenCode</code></td>
|
<td><span style="color: #999;">选填</span></td>
|
<td>令牌号,由调度系统颁发。如果填写,需先在 RCS-2000 系统配置,上层系统调用时进行填写。</td>
|
</tr>
|
</tbody>
|
</table>
|
</div>
|
|
<div class="api-info">
|
<h3>📤 通用返回值定义</h3>
|
<p style="margin-bottom: 15px; color: #666;">所有接口的响应都遵循以下统一格式:</p>
|
<table>
|
<thead>
|
<tr>
|
<th style="width: 20%;">参数名</th>
|
<th style="width: 15%;">是否必填</th>
|
<th>描述</th>
|
</tr>
|
</thead>
|
<tbody>
|
<tr>
|
<td><code>code</code></td>
|
<td><span style="color: #f93e3e; font-weight: bold;">必填</span></td>
|
<td>返回编号,<code>200</code> 表示成功,<code>1~N</code> 表示失败</td>
|
</tr>
|
<tr>
|
<td><code>message</code></td>
|
<td><span style="color: #f93e3e; font-weight: bold;">必填</span></td>
|
<td>返回消息,<code>请求成功</code> 表示成功,内容为详细的错误描述</td>
|
</tr>
|
<tr>
|
<td><code>data</code></td>
|
<td><span style="color: #999;">选填</span></td>
|
<td>返回的数据结构,具体内容根据接口而定</td>
|
</tr>
|
</tbody>
|
</table>
|
</div>
|
|
</section>
|
|
<!-- 动态加载的接口内容 -->
|
<div id="api-container">
|
<!-- 接口内容将通过JavaScript动态加载 -->
|
</div>
|
|
<!-- 错误码说明 -->
|
<section id="error-codes" class="api-section">
|
<h2>错误码说明</h2>
|
<div class="api-info">
|
<h3>通用错误码</h3>
|
<table>
|
<thead>
|
<tr>
|
<th>错误码</th>
|
<th>说明</th>
|
<th>解决方案</th>
|
</tr>
|
</thead>
|
<tbody>
|
<tr>
|
<td>200</td>
|
<td>成功</td>
|
<td>-</td>
|
</tr>
|
<tr>
|
<td>500</td>
|
<td>参数错误</td>
|
<td>检查请求参数是否完整和正确</td>
|
</tr>
|
|
</tbody>
|
</table>
|
</div>
|
</section>
|
|
|
<div class="feedback-section">
|
<p style="color: #999;">以上内容对您有帮助吗?</p>
|
<div class="stars">
|
<span>☆</span>
|
<span>☆</span>
|
<span>☆</span>
|
<span>☆</span>
|
<span>☆</span>
|
</div>
|
</div>
|
|
<div class="pagination">
|
<div class="prev-page">
|
<div style="color: #999; font-size: 14px; margin-bottom: 10px;">上一篇</div>
|
<div style="color: #333; font-size: 16px;">平台规范</div>
|
</div>
|
<div class="next-page">
|
<div style="color: #999; font-size: 14px; margin-bottom: 10px; text-align: right;">下一篇</div>
|
<div style="color: #333; font-size: 16px; text-align: right;">应用接入引导</div>
|
</div>
|
</div>
|
|
<script>
|
// 动态加载API配置并渲染接口内容
|
function loadApiConfigs() {
|
try {
|
// 直接定义API配置数据,避免CORS错误
|
const apiConfigs = [
|
{
|
"apiId": "api-task-create",
|
"name": "生成任务单",
|
"description": "创建搬运任务",
|
"isCommon": true,
|
"method": "POST",
|
"url": "/api/open/bus/submit",
|
"menu": {
|
"category": "任务管理",
|
"order": 1
|
},
|
"request": {
|
"parameters": [
|
{
|
"name": "batchNo",
|
"type": "string",
|
"required": true,
|
"description": "批次编号(上层系统生成,唯一标识)",
|
"default": "122334"
|
},
|
{
|
"name": "tasks",
|
"type": "array",
|
"required": true,
|
"description": "任务数组,包含具体的任务详情",
|
"items": [
|
{
|
"name": "taskNo",
|
"type": "string",
|
"required": true,
|
"description": "任务编号(上层系统生成,唯一标识)",
|
"default": "TASK20231220001"
|
},
|
{
|
"name": "oriSta",
|
"type": "string",
|
"required": false,
|
"description": "起点站点编号"
|
},
|
{
|
"name": "destSta",
|
"type": "string",
|
"required": false,
|
"description": "终点站点编号"
|
},
|
{
|
"name": "oriLoc",
|
"type": "string",
|
"required": false,
|
"description": "起点库位编号"
|
},
|
{
|
"name": "destLoc",
|
"type": "string",
|
"required": false,
|
"description": "终点库位编号"
|
},
|
{
|
"name": "priority",
|
"type": "int",
|
"required": false,
|
"description": "优先级:1-300,默认为1",
|
"default": 1
|
}
|
]
|
}
|
],
|
"example": {
|
"batchNo": "122334",
|
"tasks": [
|
{
|
"taskNo": "TASK20231220001",
|
"oriLoc": "A100100101",
|
"destSta": "STA001",
|
"priority": 1
|
},
|
{
|
"taskNo": "TASK20231220001",
|
"oriSta": "STA002",
|
"destLoc": "B02-03-05",
|
"priority": 2
|
}
|
]
|
}
|
},
|
"response": {
|
"parameters": [
|
{
|
"name": "code",
|
"type": "integer",
|
"description": "返回编号,200表示成功,1~N表示失败"
|
},
|
{
|
"name": "message",
|
"type": "string",
|
"description": "返回消息,请求成功表示成功,内容为详细的错误描述"
|
},
|
{
|
"name": "data",
|
"type": "object",
|
"description": "返回的数据结构"
|
},
|
{
|
"name": "timestamp",
|
"type": "integer",
|
"description": "时间戳"
|
}
|
],
|
"example": {
|
"code": 200,
|
"message": "任务创建成功",
|
"data": {
|
"taskNo": "TASK20231220001",
|
"taskId": "T1234567890",
|
"status": "ASSIGN"
|
},
|
"timestamp": 1671526800000
|
}
|
}
|
},
|
{
|
"apiId": "api-task-cancel",
|
"name": "取消任务",
|
"description": "取消搬运任务",
|
"isCommon": false,
|
"method": "POST",
|
"url": "/api/open/bus/cancel",
|
"menu": {
|
"category": "任务管理",
|
"order": 2
|
},
|
"request": {
|
"parameters": [
|
{
|
"name": "taskNo",
|
"type": "string",
|
"required": true,
|
"description": "任务编号",
|
"default": "TASK20231220001"
|
}
|
],
|
"example": {
|
"taskNo": "TASK20231220001"
|
}
|
},
|
"response": {
|
"parameters": [
|
{
|
"name": "code",
|
"type": "integer",
|
"description": "返回编号,200表示成功,1~N表示失败"
|
},
|
{
|
"name": "message",
|
"type": "string",
|
"description": "返回消息,请求成功表示成功,内容为详细的错误描述"
|
},
|
{
|
"name": "timestamp",
|
"type": "integer",
|
"description": "时间戳"
|
}
|
],
|
"example": {
|
"code": 200,
|
"message": "任务取消成功",
|
"timestamp": 1671526800000
|
}
|
}
|
},
|
{
|
"apiId": "api-task-allocate",
|
"name": "申请入库接口",
|
"description": "申请任务入库",
|
"isCommon": true,
|
"method": "POST",
|
"url": "/api/open/task/allocate",
|
"menu": {
|
"category": "任务管理",
|
"order": 3
|
},
|
"request": {
|
"parameters": [
|
{
|
"name": "staNo",
|
"type": "string",
|
"required": true,
|
"description": "站点编号",
|
"default": "1001"
|
},
|
{
|
"name": "barcode",
|
"type": "string",
|
"required": true,
|
"description": "托盘码",
|
"default": "80000001"
|
}
|
],
|
"example": {
|
"staNo": "1001",
|
"barcode": "80000001"
|
}
|
},
|
"response": {
|
"parameters": [
|
{
|
"name": "code",
|
"type": "integer",
|
"description": "返回编号,200表示成功,1~N表示失败"
|
},
|
{
|
"name": "message",
|
"type": "string",
|
"description": "返回消息,请求成功表示成功,内容为详细的错误描述"
|
},
|
{
|
"name": "data",
|
"type": "object",
|
"description": "返回的数据结构"
|
},
|
{
|
"name": "timestamp",
|
"type": "integer",
|
"description": "时间戳"
|
}
|
],
|
"example": {
|
"code": 200,
|
"message": "申请入库成功",
|
"data": {
|
"taskNo": "TASK20231220001",
|
"locNo": "A100100101",
|
"batchNo": "TASK20231220001"
|
},
|
"timestamp": 1671526800000
|
}
|
}
|
},
|
{
|
"apiId": "api-task-notice",
|
"name": "任务状态通知",
|
"description": "通知任务状态变更",
|
"isCommon": false,
|
"method": "POST",
|
"url": "/api/open/bus/notice",
|
"menu": {
|
"category": "任务管理",
|
"order": 4
|
},
|
"request": {
|
"parameters": [
|
{
|
"name": "taskNo",
|
"type": "string",
|
"required": true,
|
"description": "任务编号",
|
"default": "TASK20231220001"
|
},
|
{
|
"name": "status",
|
"type": "string",
|
"required": true,
|
"description": "任务状态",
|
"default": "COMPLETE"
|
}
|
],
|
"example": {
|
"taskNo": "TASK20231220001",
|
"status": "COMPLETE"
|
}
|
},
|
"response": {
|
"parameters": [
|
{
|
"name": "code",
|
"type": "integer",
|
"description": "返回编号,200表示成功,1~N表示失败"
|
},
|
{
|
"name": "message",
|
"type": "string",
|
"description": "返回消息,请求成功表示成功,内容为详细的错误描述"
|
},
|
{
|
"name": "timestamp",
|
"type": "integer",
|
"description": "时间戳"
|
}
|
],
|
"example": {
|
"code": 200,
|
"message": "状态通知成功",
|
"timestamp": 1671526800000
|
}
|
}
|
},
|
{
|
"apiId": "api-task-priority",
|
"name": "任务优先级调整",
|
"description": "调整任务优先级",
|
"isCommon": false,
|
"method": "POST",
|
"url": "/api/open/bus/priority",
|
"menu": {
|
"category": "任务管理",
|
"order": 5
|
},
|
"request": {
|
"parameters": [
|
{
|
"name": "taskNo",
|
"type": "string",
|
"required": true,
|
"description": "任务编号",
|
"default": "TASK20231220001"
|
},
|
{
|
"name": "priority",
|
"type": "int",
|
"required": true,
|
"description": "优先级:1-300",
|
"default": 10
|
}
|
],
|
"example": {
|
"taskNo": "TASK20231220001",
|
"priority": 10
|
}
|
},
|
"response": {
|
"parameters": [
|
{
|
"name": "code",
|
"type": "integer",
|
"description": "返回编号,200表示成功,1~N表示失败"
|
},
|
{
|
"name": "message",
|
"type": "string",
|
"description": "返回消息,请求成功表示成功,内容为详细的错误描述"
|
},
|
{
|
"name": "timestamp",
|
"type": "integer",
|
"description": "时间戳"
|
}
|
],
|
"example": {
|
"code": 200,
|
"message": "优先级调整成功",
|
"timestamp": 1671526800000
|
}
|
}
|
}
|
];
|
|
// 渲染接口内容
|
const apiContainer = document.getElementById('api-container');
|
apiContainer.innerHTML = '';
|
|
apiConfigs.forEach(config => {
|
apiContainer.appendChild(renderApiSection(config));
|
});
|
|
} catch (error) {
|
console.error('Failed to load API configs:', error);
|
}
|
}
|
|
// 渲染单个API章节
|
function renderApiSection(config) {
|
const section = document.createElement('section');
|
section.id = config.apiId;
|
section.className = 'api-section';
|
|
// 标题
|
const h2 = document.createElement('h2');
|
h2.textContent = config.name + (config.isCommon ? '*' : '');
|
if (config.isCommon) {
|
const tag = document.createElement('span');
|
tag.className = 'tag';
|
tag.textContent = '常用';
|
h2.appendChild(tag);
|
}
|
section.appendChild(h2);
|
|
// API信息
|
const apiInfo = document.createElement('div');
|
apiInfo.className = 'api-info';
|
|
// API方法和描述
|
const h3 = document.createElement('h3');
|
const methodSpan = document.createElement('span');
|
methodSpan.className = `api-method method-${config.method.toLowerCase()}`;
|
methodSpan.textContent = config.method;
|
h3.appendChild(methodSpan);
|
const descSpan = document.createElement('span');
|
descSpan.textContent = ' ' + config.description;
|
h3.appendChild(descSpan);
|
apiInfo.appendChild(h3);
|
|
// API URL
|
const apiUrl = document.createElement('div');
|
apiUrl.className = 'api-url';
|
apiUrl.textContent = config.url;
|
apiInfo.appendChild(apiUrl);
|
|
// 请求参数
|
if (config.request && config.request.parameters) {
|
const h4 = document.createElement('h4');
|
h4.textContent = '请求参数';
|
apiInfo.appendChild(h4);
|
|
const table = document.createElement('table');
|
const thead = document.createElement('thead');
|
const headerRow = document.createElement('tr');
|
headerRow.innerHTML = `
|
<th style="width: 20%;">参数名</th>
|
<th style="width: 15%;">类型</th>
|
<th style="width: 15%;">必填</th>
|
<th>说明</th>
|
`;
|
thead.appendChild(headerRow);
|
table.appendChild(thead);
|
|
const tbody = document.createElement('tbody');
|
config.request.parameters.forEach(param => {
|
const row = document.createElement('tr');
|
row.innerHTML = `
|
<td><code>${param.name}</code></td>
|
<td>${param.type}</td>
|
<td><span style="color: ${param.required ? '#f93e3e; font-weight: bold;' : '#999;'};">${param.required ? '是' : '否'}</span></td>
|
<td>${param.description}</td>
|
`;
|
tbody.appendChild(row);
|
|
// 如果是数组类型,渲染数组元素参数
|
if (param.type === 'array' && param.items) {
|
const h4Items = document.createElement('h4');
|
h4Items.textContent = `${param.name}数组元素参数`;
|
apiInfo.appendChild(h4Items);
|
|
const tableItems = document.createElement('table');
|
const theadItems = document.createElement('thead');
|
const headerRowItems = document.createElement('tr');
|
headerRowItems.innerHTML = `
|
<th style="width: 20%;">参数名</th>
|
<th style="width: 15%;">类型</th>
|
<th style="width: 15%;">必填</th>
|
<th>说明</th>
|
`;
|
theadItems.appendChild(headerRowItems);
|
tableItems.appendChild(theadItems);
|
|
const tbodyItems = document.createElement('tbody');
|
param.items.forEach(itemParam => {
|
const rowItem = document.createElement('tr');
|
rowItem.innerHTML = `
|
<td><code>${itemParam.name}</code></td>
|
<td>${itemParam.type}</td>
|
<td><span style="color: ${itemParam.required ? '#f93e3e; font-weight: bold;' : '#999;'};">${itemParam.required ? '是' : '否'}</span></td>
|
<td>${itemParam.description}</td>
|
`;
|
tbodyItems.appendChild(rowItem);
|
});
|
tableItems.appendChild(tbodyItems);
|
apiInfo.appendChild(tableItems);
|
}
|
});
|
table.appendChild(tbody);
|
apiInfo.appendChild(table);
|
}
|
|
// 请求示例
|
if (config.request && config.request.example) {
|
const h4 = document.createElement('h4');
|
h4.textContent = '请求示例';
|
apiInfo.appendChild(h4);
|
|
const pre = document.createElement('pre');
|
const code = document.createElement('code');
|
code.textContent = JSON.stringify(config.request.example, null, 2);
|
pre.appendChild(code);
|
apiInfo.appendChild(pre);
|
}
|
|
// 返回示例
|
if (config.response && config.response.example) {
|
const h4 = document.createElement('h4');
|
h4.textContent = '返回示例';
|
apiInfo.appendChild(h4);
|
|
const pre = document.createElement('pre');
|
const code = document.createElement('code');
|
code.textContent = JSON.stringify(config.response.example, null, 2);
|
pre.appendChild(code);
|
apiInfo.appendChild(pre);
|
}
|
|
section.appendChild(apiInfo);
|
|
// Mock测试
|
if (config.mock) {
|
const mockContainer = document.createElement('div');
|
mockContainer.className = 'mock-container';
|
|
const h4 = document.createElement('h4');
|
h4.textContent = 'Mock 测试';
|
mockContainer.appendChild(h4);
|
|
const toggleBtn = document.createElement('button');
|
toggleBtn.className = 'mock-toggle-btn';
|
toggleBtn.onclick = function() { toggleMockContent(this); };
|
toggleBtn.textContent = '展开';
|
mockContainer.appendChild(toggleBtn);
|
|
const mockContent = document.createElement('div');
|
mockContent.className = 'mock-content collapsed';
|
|
// 模式切换
|
const modeSwitch = document.createElement('div');
|
modeSwitch.className = 'mode-switch';
|
|
const formBtn = document.createElement('button');
|
formBtn.className = 'active';
|
formBtn.onclick = function() { switchInputMode(config.apiId.replace('api-', ''), 'form'); };
|
formBtn.id = `${config.apiId.replace('api-', '')}-form-btn`;
|
formBtn.textContent = '表单输入';
|
modeSwitch.appendChild(formBtn);
|
|
const jsonBtn = document.createElement('button');
|
jsonBtn.onclick = function() { switchInputMode(config.apiId.replace('api-', ''), 'json'); };
|
jsonBtn.id = `${config.apiId.replace('api-', '')}-json-btn`;
|
jsonBtn.textContent = 'JSON输入';
|
modeSwitch.appendChild(jsonBtn);
|
|
mockContent.appendChild(modeSwitch);
|
|
// Mock表单
|
const mockForm = document.createElement('div');
|
mockForm.className = 'mock-form';
|
|
// 表单输入容器
|
const formContainer = document.createElement('div');
|
formContainer.className = 'form-input-container';
|
formContainer.id = `${config.apiId.replace('api-', '')}-form-container`;
|
|
const h5 = document.createElement('h5');
|
h5.textContent = '请求参数';
|
formContainer.appendChild(h5);
|
|
// 渲染表单字段
|
if (config.mock.formFields) {
|
config.mock.formFields.forEach(field => {
|
const formGroup = document.createElement('div');
|
formGroup.className = 'form-group';
|
|
const label = document.createElement('label');
|
label.textContent = field.label + (field.required ? ' <span class="required">*</span>' : '');
|
formGroup.appendChild(label);
|
|
if (field.type === 'select') {
|
const select = document.createElement('select');
|
select.id = `${config.apiId.replace('api-', '')}-${field.name}`;
|
if (field.options) {
|
field.options.forEach(option => {
|
const opt = document.createElement('option');
|
opt.value = option.value;
|
opt.textContent = option.label;
|
if (option.value === field.default) {
|
opt.selected = true;
|
}
|
select.appendChild(opt);
|
});
|
}
|
formGroup.appendChild(select);
|
} else {
|
const input = document.createElement('input');
|
input.type = field.type;
|
input.id = `${config.apiId.replace('api-', '')}-${field.name}`;
|
input.placeholder = field.default || '';
|
input.value = field.default || '';
|
formGroup.appendChild(input);
|
}
|
|
if (field.required) {
|
const errorMsg = document.createElement('div');
|
errorMsg.className = 'error-msg';
|
errorMsg.id = `${config.apiId.replace('api-', '')}-${field.name}-error`;
|
errorMsg.textContent = `请输入${field.label}`;
|
formGroup.appendChild(errorMsg);
|
}
|
|
formContainer.appendChild(formGroup);
|
});
|
}
|
|
mockForm.appendChild(formContainer);
|
|
// JSON输入容器
|
const jsonContainer = document.createElement('div');
|
jsonContainer.className = 'json-input-container';
|
jsonContainer.id = `${config.apiId.replace('api-', '')}-json-container`;
|
|
const h5Json = document.createElement('h5');
|
h5Json.textContent = 'JSON输入';
|
jsonContainer.appendChild(h5Json);
|
|
const textarea = document.createElement('textarea');
|
textarea.className = 'json-textarea';
|
textarea.id = `${config.apiId.replace('api-', '')}-json`;
|
textarea.value = JSON.stringify(config.mock.jsonExample, null, 2);
|
jsonContainer.appendChild(textarea);
|
|
const jsonError = document.createElement('div');
|
jsonError.className = 'error-msg';
|
jsonError.id = `${config.apiId.replace('api-', '')}-json-error`;
|
jsonError.textContent = '请输入有效的JSON格式';
|
jsonContainer.appendChild(jsonError);
|
|
mockForm.appendChild(jsonContainer);
|
|
// 表单操作按钮
|
const formActions = document.createElement('div');
|
formActions.className = 'mock-form-actions';
|
|
const mockBtn = document.createElement('button');
|
mockBtn.className = 'mock-btn';
|
mockBtn.onclick = function() { mockApiRequest(config.apiId.replace('api-', ''), config); };
|
mockBtn.textContent = '执行 Mock 请求';
|
formActions.appendChild(mockBtn);
|
|
const resetBtn = document.createElement('button');
|
resetBtn.className = 'reset-btn';
|
resetBtn.onclick = function() { resetApiForm(config.apiId.replace('api-', ''), config); };
|
resetBtn.textContent = '重置';
|
formActions.appendChild(resetBtn);
|
|
mockForm.appendChild(formActions);
|
mockContent.appendChild(mockForm);
|
|
// Mock结果
|
const resultDiv = document.createElement('div');
|
resultDiv.id = `mock-${config.apiId.replace('api-', '')}-result`;
|
resultDiv.className = 'mock-result';
|
mockContent.appendChild(resultDiv);
|
|
mockContainer.appendChild(mockContent);
|
section.appendChild(mockContainer);
|
}
|
|
return section;
|
}
|
|
// Mock API请求
|
function mockApiRequest(apiId, config) {
|
let params;
|
const isJsonMode = document.getElementById(`${apiId}-json-container`).classList.contains('active');
|
|
if (isJsonMode) {
|
params = getParamsFromJson(`${apiId}-json`);
|
if (!params) return;
|
} else {
|
const formParams = getParamsFromForm(apiId);
|
params = {};
|
Object.keys(formParams).forEach(key => {
|
params[key] = formParams[key];
|
});
|
}
|
|
const resultDiv = document.getElementById(`mock-${apiId}-result`);
|
resultDiv.classList.add('show');
|
resultDiv.innerHTML = '<p style="color: #999;" class="loading">⏳ 正在发送请求...</p>';
|
|
setTimeout(() => {
|
let response;
|
if (config.mock.responseTemplate) {
|
response = JSON.parse(JSON.stringify(config.mock.responseTemplate));
|
// 替换模板变量
|
if (response.data === '{{taskResults}}' && params.tasks && Array.isArray(params.tasks)) {
|
response.data = params.tasks.map(taskNo => ({
|
taskNo: taskNo,
|
success: true,
|
msg: null
|
}));
|
}
|
if (response.data && response.data.taskNo === '{{taskNo}}') {
|
response.data.taskNo = params.taskNo;
|
}
|
if (response.data && response.data.taskId === '{{taskId}}') {
|
response.data.taskId = 'T' + Math.random().toString(36).substr(2, 10);
|
}
|
if (response.timestamp === '{{timestamp}}') {
|
response.timestamp = Date.now();
|
}
|
} else {
|
response = {
|
code: 200,
|
message: '请求成功'
|
};
|
}
|
|
resultDiv.innerHTML = `
|
<p style="color: #49cc90; font-weight: bold;">✓ 请求成功</p>
|
<pre><code>${JSON.stringify(response, null, 2)}</code></pre>
|
`;
|
}, 1000);
|
}
|
|
// 重置API表单
|
function resetApiForm(apiId, config) {
|
// 重置表单字段
|
const inputs = document.querySelectorAll(`#${apiId}-form-container input, #${apiId}-form-container select`);
|
inputs.forEach(input => {
|
const fieldName = input.id.replace(`${apiId}-`, '');
|
const fieldConfig = config.mock.formFields.find(f => f.name === fieldName);
|
if (fieldConfig) {
|
input.value = fieldConfig.default || '';
|
}
|
input.classList.remove('error');
|
});
|
|
// 重置JSON输入
|
const textarea = document.getElementById(`${apiId}-json`);
|
if (textarea) {
|
textarea.value = JSON.stringify(config.mock.jsonExample, null, 2);
|
}
|
|
// 隐藏错误信息
|
const errors = document.querySelectorAll(`[id^="${apiId}-"][id$="-error"]`);
|
errors.forEach(error => error.classList.remove('show'));
|
|
// 隐藏结果
|
const resultDiv = document.getElementById(`mock-${apiId}-result`);
|
if (resultDiv) {
|
resultDiv.classList.remove('show');
|
resultDiv.innerHTML = '';
|
}
|
}
|
|
// 页面加载完成后加载API配置
|
window.addEventListener('DOMContentLoaded', loadApiConfigs);
|
|
// 切换Mock内容展开/折叠
|
function toggleMockContent(element) {
|
const mockContent = element.nextElementSibling;
|
if (mockContent) {
|
mockContent.classList.toggle('collapsed');
|
mockContent.classList.toggle('expanded');
|
element.textContent = mockContent.classList.contains('expanded') ? '收起' : '展开';
|
}
|
}
|
|
// 切换输入模式
|
function switchInputMode(formId, mode) {
|
const formBtn = document.getElementById(`${formId}-form-btn`);
|
const jsonBtn = document.getElementById(`${formId}-json-btn`);
|
const formContainer = document.getElementById(`${formId}-form-container`);
|
const jsonContainer = document.getElementById(`${formId}-json-container`);
|
|
if (mode === 'form') {
|
formBtn.classList.add('active');
|
jsonBtn.classList.remove('active');
|
formContainer.classList.remove('hidden');
|
jsonContainer.classList.remove('active');
|
} else {
|
formBtn.classList.remove('active');
|
jsonBtn.classList.add('active');
|
formContainer.classList.add('hidden');
|
jsonContainer.classList.add('active');
|
}
|
}
|
|
// 从表单获取参数
|
function getParamsFromForm(formId) {
|
const params = {};
|
const inputs = document.querySelectorAll(`#${formId}-form-container input, #${formId}-form-container select`);
|
inputs.forEach(input => {
|
const key = input.id.replace(`${formId}-`, '');
|
params[key] = input.value.trim();
|
});
|
return params;
|
}
|
|
// 从JSON获取参数
|
function getParamsFromJson(jsonId) {
|
const textarea = document.getElementById(jsonId);
|
const errorDiv = document.getElementById(`${jsonId}-error`);
|
|
try {
|
const json = JSON.parse(textarea.value);
|
textarea.classList.remove('error');
|
errorDiv.classList.remove('show');
|
return json;
|
} catch (e) {
|
textarea.classList.add('error');
|
errorDiv.classList.add('show');
|
return null;
|
}
|
}
|
|
// 监听来自父窗口的消息
|
window.addEventListener('message', function(event) {
|
if (event.data.type === 'scrollToSection') {
|
const sectionId = event.data.sectionId;
|
const section = document.getElementById(sectionId);
|
if (section) {
|
section.scrollIntoView({ behavior: 'smooth' });
|
}
|
}
|
});
|
</script>
|
</body>
|
</html>
|