This commit is contained in:
2025-10-21 23:27:21 +08:00
parent 9cc0ee358c
commit 12b6a51bcd
3 changed files with 375 additions and 0 deletions

11
src/api/public/order.js Normal file
View File

@@ -0,0 +1,11 @@
import request from '@/utils/request'
// 提交公开订单
export function submitPublicOrder(data) {
return request({
url: '/public/order/submit',
method: 'post',
data
})
}

View File

@@ -85,6 +85,12 @@ export const constantRoutes = [
component: () => import('@/views/public/CommentGenerator'), component: () => import('@/views/public/CommentGenerator'),
hidden: true hidden: true
}, },
// 公开订单提交页(不使用 Layout无侧边栏
{
path: '/public/order-submit',
component: () => import('@/views/public/order-submit/index'),
hidden: true
},
// 慢单管理(移到公共路由,无需权限) // 慢单管理(移到公共路由,无需权限)
{ {
path: '/sloworder', path: '/sloworder',

View File

@@ -0,0 +1,358 @@
<template>
<div class="public-order-container">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>订单提交台</span>
<span class="header-desc">请按照格式提交订单信息</span>
</div>
<el-form :model="form" label-width="80px" label-position="top">
<el-form-item label="输入订单信息">
<el-input
v-model="form.command"
type="textarea"
:rows="12"
placeholder="请按照以下格式输入订单信息:&#10;单:&#10;2025-01-01 001&#10;备注:测试订单&#10;分销标记H-TF&#10;型号ZQD180F-EB200&#10;链接https://...&#10;下单付款1650&#10;后返金额50&#10;地址张三13800138000上海市浦东新区...&#10;物流链接https://...&#10;订单号1234567890&#10;下单人:张三"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitOrder" :loading="loading" size="medium">
<i class="el-icon-upload"></i> 提交订单
</el-button>
<el-button @click="clearAll" size="medium">
<i class="el-icon-delete"></i> 清空
</el-button>
</el-form-item>
</el-form>
<el-divider>响应结果</el-divider>
<div v-if="resultList.length === 0" style="padding: 12px 0;">
<el-empty description="暂无响应" />
</div>
<div v-else>
<div v-for="(msg, idx) in resultList" :key="idx" class="msg-block">
<div class="msg-header">
<span> {{ idx + 1 }} </span>
<el-button size="mini" type="success" @click="copyOne(msg)">复制此段</el-button>
</div>
<el-input :value="msg" type="textarea" :rows="8" readonly />
</div>
<div style="margin-top: 8px;">
<el-button size="mini" type="primary" @click="copyAll">复制全部</el-button>
</div>
</div>
<!-- 使用说明 -->
<el-divider>使用说明</el-divider>
<div class="usage-guide">
<el-collapse>
<el-collapse-item title="订单格式说明" name="1">
<div class="guide-content">
<p><strong>请严格按照以下格式填写订单信息</strong></p>
<pre class="format-example">
2025-01-01 001
备注测试订单
分销标记H-TF
型号ZQD180F-EB200
链接https://item.jd.com/...
下单付款1650
后返金额50
地址张三13800138000上海市浦东新区张江高科技园区...
物流链接https://...
订单号1234567890
下单人张三</pre>
<p class="tips"><i class="el-icon-warning"></i> 提示每个字段都不能省略否则会提交失败</p>
</div>
</el-collapse-item>
<el-collapse-item title="注意事项" name="2">
<div class="guide-content">
<ul>
<li>请确保订单信息准确无误</li>
<li>每次只能提交一个订单</li>
<li>提交成功后会显示确认信息</li>
<li>如遇错误请检查格式是否正确</li>
<li>请勿频繁提交系统有限流保护</li>
</ul>
</div>
</el-collapse-item>
</el-collapse>
</div>
</el-card>
</div>
</template>
<script>
import { submitPublicOrder } from '@/api/public/order'
export default {
name: 'PublicOrderSubmit',
data() {
return {
form: { command: '' },
loading: false,
resultList: []
}
},
methods: {
copyOne(text) {
if (!text) return
this.doCopy(text)
},
copyAll() {
if (!this.resultList || this.resultList.length === 0) return
const text = this.resultList.join('\n\n')
this.doCopy(text)
},
doCopy(text) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
this.$message.success('复制成功')
}).catch(() => {
this.fallbackCopyText(text)
})
} else {
this.fallbackCopyText(text)
}
},
fallbackCopyText(text) {
const ta = document.createElement('textarea')
ta.value = text
document.body.appendChild(ta)
ta.focus()
ta.select()
try {
document.execCommand('copy')
this.$message.success('复制成功')
} catch (e) {
this.$message.error('复制失败')
}
document.body.removeChild(ta)
},
submitOrder() {
const cmd = (this.form.command || '').trim()
if (!cmd) {
this.$message.error('请输入订单信息')
return
}
// 检查是否以"单:"开头
if (!cmd.startsWith('单:') && !cmd.startsWith('单:')) {
this.$message.error('订单信息必须以"单:"开头')
return
}
this.loading = true
submitPublicOrder({ command: cmd }).then(res => {
this.loading = false
if (res && (res.code === 200 || res.msg === '操作成功')) {
const data = res.data
if (Array.isArray(data)) {
this.resultList = data
} else if (typeof data === 'string') {
this.resultList = data ? [data] : []
} else {
this.resultList = []
}
// 检查是否有警告信息
this.checkWarningAlert(this.resultList)
// 如果没有警告,显示成功提示
if (!this.hasWarning(this.resultList)) {
this.$message.success('订单提交成功')
}
} else {
this.$message.error(res && res.msg ? res.msg : '提交失败')
this.resultList = []
}
}).catch(error => {
this.loading = false
const errorMsg = error.response?.data?.msg || error.message || '提交失败,请稍后重试'
this.$message.error(errorMsg)
this.resultList = []
})
},
clearAll() {
this.form.command = ''
this.resultList = []
},
checkWarningAlert(resultList) {
if (!resultList || resultList.length === 0) return
// 检查是否有以[炸弹]开头的警告消息
const warningMessages = resultList
.filter(msg => {
return msg && typeof msg === 'string' && msg.trim().includes('[炸弹]')
})
.map(msg => {
// 移除所有的[炸弹]标记
return msg.trim().replace(/\[炸弹\]\s*/g, '').trim()
})
if (warningMessages.length > 0) {
// 显示警告弹窗
this.$alert(warningMessages.join('\n\n'), '⚠️ 警告提示', {
confirmButtonText: '我已知晓',
type: 'warning',
center: true,
customClass: 'warning-alert-dialog',
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
dangerouslyUseHTMLString: false
}).catch(() => {})
}
},
hasWarning(resultList) {
if (!resultList || resultList.length === 0) return false
return resultList.some(msg => msg && typeof msg === 'string' && msg.trim().includes('[炸弹]'))
}
}
}
</script>
<style scoped>
.public-order-container {
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.box-card {
max-width: 1000px;
width: 100%;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.clearfix {
display: flex;
align-items: center;
justify-content: space-between;
}
.clearfix span:first-child {
font-size: 18px;
font-weight: 600;
color: #303133;
}
.header-desc {
font-size: 12px;
color: #909399;
font-weight: normal;
}
.msg-block {
margin-bottom: 12px;
}
.msg-header {
display: flex;
align-items: center;
justify-content: space-between;
margin: 6px 0;
font-weight: 500;
color: #606266;
}
.usage-guide {
margin-top: 20px;
}
.guide-content {
padding: 10px;
}
.guide-content p {
margin: 10px 0;
line-height: 1.8;
color: #606266;
}
.format-example {
background-color: #f5f7fa;
padding: 15px;
border-radius: 4px;
border-left: 3px solid #409eff;
font-family: 'Courier New', monospace;
font-size: 13px;
line-height: 1.6;
overflow-x: auto;
margin: 15px 0;
}
.tips {
color: #e6a23c;
font-size: 13px;
padding: 10px;
background-color: #fdf6ec;
border-radius: 4px;
border: 1px solid #f5dab1;
}
.guide-content ul {
list-style: none;
padding: 0;
}
.guide-content ul li {
padding: 8px 0;
color: #606266;
line-height: 1.6;
}
.guide-content ul li:before {
content: "•";
color: #409eff;
font-weight: bold;
display: inline-block;
width: 1em;
margin-left: 10px;
}
</style>
<style>
/* 全局样式:警告弹窗 */
.warning-alert-dialog {
width: 80vw !important;
max-width: 800px !important;
min-width: 400px !important;
}
.warning-alert-dialog .el-message-box__header {
padding: 20px 20px 15px !important;
}
.warning-alert-dialog .el-message-box__title {
font-size: 18px !important;
font-weight: 700 !important;
}
.warning-alert-dialog .el-message-box__message {
font-size: 15px !important;
font-weight: 600 !important;
color: #e6a23c !important;
white-space: pre-wrap !important;
word-break: break-word !important;
line-height: 1.8 !important;
max-height: 60vh !important;
overflow-y: auto !important;
padding: 15px 20px !important;
}
.warning-alert-dialog .el-message-box__btns {
text-align: center !important;
padding: 15px 20px 20px !important;
}
.warning-alert-dialog .el-message-box__btns .el-button {
padding: 12px 40px !important;
font-size: 14px !important;
font-weight: 600 !important;
}
</style>