@@ -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 = "请按照以下格式输入订单信息: 单: 2025-01-01 001 备注:测试订单 分销标记:H-TF 型号:ZQD180F-EB200 链接:https://... 下单付款:1650 后返金额:50 地址:张三13800138000上海市浦东新区... 物流链接:https://... 订单号:1234567890 下单人:张三"
/ >
< / 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 : 100 vh ;
background : linear - gradient ( 135 deg , # 667 eea 0 % , # 764 ba2 100 % ) ;
padding : 20 px ;
display : flex ;
align - items : center ;
justify - content : center ;
}
. box - card {
max - width : 1000 px ;
width : 100 % ;
box - shadow : 0 4 px 20 px rgba ( 0 , 0 , 0 , 0.15 ) ;
}
. clearfix {
display : flex ;
align - items : center ;
justify - content : space - between ;
}
. clearfix span : first - child {
font - size : 18 px ;
font - weight : 600 ;
color : # 303133 ;
}
. header - desc {
font - size : 12 px ;
color : # 909399 ;
font - weight : normal ;
}
. msg - block {
margin - bottom : 12 px ;
}
. msg - header {
display : flex ;
align - items : center ;
justify - content : space - between ;
margin : 6 px 0 ;
font - weight : 500 ;
color : # 606266 ;
}
. usage - guide {
margin - top : 20 px ;
}
. guide - content {
padding : 10 px ;
}
. guide - content p {
margin : 10 px 0 ;
line - height : 1.8 ;
color : # 606266 ;
}
. format - example {
background - color : # f5f7fa ;
padding : 15 px ;
border - radius : 4 px ;
border - left : 3 px solid # 409 eff ;
font - family : 'Courier New' , monospace ;
font - size : 13 px ;
line - height : 1.6 ;
overflow - x : auto ;
margin : 15 px 0 ;
}
. tips {
color : # e6a23c ;
font - size : 13 px ;
padding : 10 px ;
background - color : # fdf6ec ;
border - radius : 4 px ;
border : 1 px solid # f5dab1 ;
}
. guide - content ul {
list - style : none ;
padding : 0 ;
}
. guide - content ul li {
padding : 8 px 0 ;
color : # 606266 ;
line - height : 1.6 ;
}
. guide - content ul li : before {
content : "•" ;
color : # 409 eff ;
font - weight : bold ;
display : inline - block ;
width : 1 em ;
margin - left : 10 px ;
}
< / style >
< style >
/* 全局样式:警告弹窗 */
. warning - alert - dialog {
width : 80 vw ! important ;
max - width : 800 px ! important ;
min - width : 400 px ! important ;
}
. warning - alert - dialog . el - message - box _ _header {
padding : 20 px 20 px 15 px ! important ;
}
. warning - alert - dialog . el - message - box _ _title {
font - size : 18 px ! important ;
font - weight : 700 ! important ;
}
. warning - alert - dialog . el - message - box _ _message {
font - size : 15 px ! 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 : 60 vh ! important ;
overflow - y : auto ! important ;
padding : 15 px 20 px ! important ;
}
. warning - alert - dialog . el - message - box _ _btns {
text - align : center ! important ;
padding : 15 px 20 px 20 px ! important ;
}
. warning - alert - dialog . el - message - box _ _btns . el - button {
padding : 12 px 40 px ! important ;
font - size : 14 px ! important ;
font - weight : 600 ! important ;
}
< / style >