This commit is contained in:
van
2026-10-22 00:25:45 +08:00
parent 029a8a1a97
commit 5bac007465
4 changed files with 145 additions and 282 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ export default {
{ path: '/jd-instruction/index', label: '中控', icon: 'el-icon-s-operation', permissions: ['jdorder:instruction:list'] },
{ path: '/mobile/fadan', label: '发单', icon: 'el-icon-edit-outline' },
{ path: '/mobile/xianyu-publish', label: '发品', icon: 'el-icon-goods' },
{ path: '/mobile/zhongcao', label: '种草', icon: 'el-icon-chat-dot-round' }
{ path: '/mobile/profit', label: '报表', icon: 'el-icon-data-analysis' }
]
return items.filter(it => !it.permissions || auth.hasPermiOr(it.permissions))
},
+7 -3
View File
@@ -136,11 +136,15 @@ export const constantRoutes = [
name: 'MobileXianyuPublish',
meta: { title: '发品' }
},
{
path: 'profit',
component: () => import('@/views/system/jdorder/profit-analysis'),
name: 'MobileProfit',
meta: { title: '报表' }
},
{
path: 'zhongcao',
component: () => import('@/views/mobile/zhongcao/index'),
name: 'MobileZhongcao',
meta: { title: '种草' }
redirect: '/mobile/profit'
}
]
}
-267
View File
@@ -1,267 +0,0 @@
<template>
<div class="app-container mobile-zhongcao">
<el-card class="box-card">
<el-form :model="form" label-position="top" class="main-form">
<el-form-item label="商品标题" required>
<el-input
v-model="form.title"
type="textarea"
:rows="3"
placeholder="必填"
clearable
/>
</el-form-item>
<el-form-item label="型号" required>
<el-input v-model="form.model" placeholder="必填" clearable />
</el-form-item>
<el-form-item label="商品类型" required>
<el-input
v-model="form.goodsType"
placeholder="必填,如:冰箱、空调、洗衣机"
clearable
/>
</el-form-item>
<el-form-item>
<el-button type="primary" class="btn-main" :loading="loading" @click="handleGenerate">
生成种草文案
</el-button>
<el-button :disabled="!hasInput" @click="clearAll">清空</el-button>
</el-form-item>
</el-form>
<el-alert
v-if="seedNoteError"
:title="seedNoteError"
type="warning"
:closable="false"
show-icon
class="warn-alert"
/>
<div v-if="result.seedNote || result.daixiadan" class="result-wrap">
<template v-if="result.seedNote">
<el-divider content-position="left">种草文案(AI)</el-divider>
<div class="card-bar">
<span class="card-t">高转化种草</span>
<el-button type="primary" size="small" @click="copyText(result.seedNote)">复制</el-button>
</div>
<div class="result-body">{{ result.seedNote }}</div>
</template>
<el-collapse v-if="result.daixiadan" class="extra-collapse">
<el-collapse-item title="同步生成的闲鱼代下单 / 教你下单(模板拼接)" name="1">
<div v-if="result.daixiadan" class="sub-block">
<div class="card-bar">
<span class="card-t">代下单</span>
<el-button type="text" size="small" @click="copyText(result.daixiadan)">复制</el-button>
</div>
<pre class="pre-text">{{ result.daixiadan }}</pre>
</div>
<div v-if="result.jiaonixiadan" class="sub-block">
<div class="card-bar">
<span class="card-t">教你下单</span>
<el-button type="text" size="small" @click="copyText(result.jiaonixiadan)">复制</el-button>
</div>
<pre class="pre-text">{{ result.jiaonixiadan }}</pre>
</div>
</el-collapse-item>
</el-collapse>
</div>
</el-card>
</div>
</template>
<script>
import { generateXianyuWenan } from '@/api/jarvis/socialMedia'
export default {
name: 'MobileZhongcao',
data() {
return {
form: {
title: '',
model: '',
goodsType: ''
},
loading: false,
seedNoteError: '',
result: {
seedNote: '',
daixiadan: '',
jiaonixiadan: ''
}
}
},
computed: {
hasInput() {
return !!(this.form.title || this.form.model || this.form.goodsType)
}
},
methods: {
clearAll() {
this.form = { title: '', model: '', goodsType: '' }
this.seedNoteError = ''
this.result = { seedNote: '', daixiadan: '', jiaonixiadan: '' }
},
async handleGenerate() {
const title = (this.form.title || '').trim()
const model = (this.form.model || '').trim()
const goodsType = (this.form.goodsType || '').trim()
if (!title) {
this.$message.warning('请填写商品标题')
return
}
if (!model) {
this.$message.warning('请填写型号')
return
}
if (!goodsType) {
this.$message.warning('请填写商品类型')
return
}
this.loading = true
this.seedNoteError = ''
this.result = { seedNote: '', daixiadan: '', jiaonixiadan: '' }
try {
const res = await generateXianyuWenan({
title,
remark: model,
goods_title: title,
goods_model: model,
goods_type: goodsType,
generateSeedNote: true
})
if (res.code === 200 && res.data) {
const data = res.data
if (data.success) {
this.result.daixiadan = data.daixiadan || ''
this.result.jiaonixiadan = data.jiaonixiadan || ''
this.result.seedNote = (data.seedNote || '').trim()
if (data.seedNoteError) {
this.seedNoteError = data.seedNoteError
}
if (this.result.seedNote) {
this.$message.success('种草文案已生成')
} else if (this.seedNoteError) {
this.$message.warning('种草失败,已保留闲鱼基础文案')
} else {
this.$message.success('已生成')
}
} else {
this.$message.error(data.error || '生成失败')
}
} else {
this.$message.error(res.msg || '请求失败')
}
} catch (e) {
console.error(e)
this.$message.error('请求异常:' + (e.message || ''))
} finally {
this.loading = false
}
},
copyText(text) {
if (!text) {
this.$message.warning('无可复制内容')
return
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(() => {
this.$message.success('已复制')
}).catch(() => this.fallbackCopy(text))
} else {
this.fallbackCopy(text)
}
},
fallbackCopy(text) {
const ta = document.createElement('textarea')
ta.value = text
ta.style.position = 'fixed'
ta.style.left = '-9999px'
document.body.appendChild(ta)
ta.select()
try {
document.execCommand('copy')
this.$message.success('已复制')
} catch (err) {
this.$message.error('复制失败')
}
document.body.removeChild(ta)
}
}
}
</script>
<style scoped>
.mobile-zhongcao {
padding-bottom: 16px;
}
.box-card {
margin: 0 12px;
max-width: 720px;
margin-left: auto;
margin-right: auto;
}
.main-form ::v-deep .el-form-item {
margin-bottom: 14px;
}
.btn-main {
margin-right: 8px;
}
.warn-alert {
margin-bottom: 16px;
}
.result-wrap {
margin-top: 8px;
}
.card-bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.card-t {
font-weight: 600;
font-size: 14px;
}
.result-body {
white-space: pre-wrap;
word-break: break-word;
font-size: 13px;
line-height: 1.6;
padding: 12px;
background: #f9fafc;
border-radius: 4px;
max-height: 420px;
overflow-y: auto;
}
.extra-collapse {
margin-top: 16px;
}
.sub-block {
margin-bottom: 12px;
}
.pre-text {
white-space: pre-wrap;
word-break: break-word;
font-size: 12px;
margin: 0;
padding: 8px;
background: #fafafa;
border-radius: 4px;
max-height: 240px;
overflow-y: auto;
}
@media (max-width: 768px) {
.box-card {
margin-left: 8px;
margin-right: 8px;
}
.btn-main {
width: 100%;
margin-right: 0;
margin-bottom: 8px;
}
}
</style>
+137 -11
View File
@@ -1,19 +1,20 @@
<template>
<div class="app-container profit-analysis" v-loading="loading">
<div class="app-container profit-analysis" :class="{ 'profit-analysis--mobile': mobileLayout }" v-loading="loading">
<el-card class="filter-card">
<div slot="header" class="filter-card-header">
<span class="filter-card-title">慢单利润 / 订单 AI 分析</span>
</div>
<el-alert
v-if="!mobileLayout"
title="先按日/周/月汇总 jd_order(参与统计、已退款不计入利润),再套「DS提示词」里的「慢单利润分析」调用当前激活大模型。定时:每天 21:00 推当天日报,周一 08:20 推上周,每月 1 日 08:30 推上月。"
type="info"
:closable="false"
show-icon
class="hint-alert"
/>
<el-form :inline="true" size="small">
<el-form :inline="!mobileLayout" :label-position="mobileLayout ? 'top' : 'right'" size="small">
<el-form-item label="周期">
<el-radio-group v-model="periodType" @change="onPeriodChange">
<el-radio-group v-model="periodType" class="period-group" @change="onPeriodChange">
<el-radio-button label="day">日报</el-radio-button>
<el-radio-button label="week">周报</el-radio-button>
<el-radio-button label="month">月报</el-radio-button>
@@ -26,23 +27,30 @@
:value-format="dateValueFormat"
:placeholder="datePlaceholder"
clearable
style="width: 220px"
:style="{ width: mobileLayout ? '100%' : '220px' }"
/>
</el-form-item>
<el-form-item>
<el-form-item v-if="!mobileLayout">
<el-button type="primary" icon="el-icon-search" @click="loadStats">预览统计</el-button>
<el-button type="success" icon="el-icon-magic-stick" :loading="analyzing" @click="runAnalyze(false)">AI 分析</el-button>
<el-button type="warning" icon="el-icon-s-promotion" :loading="analyzing" @click="runAnalyze(true)">分析并推送</el-button>
<el-button type="danger" plain icon="el-icon-position" :loading="testing" @click="runTest">测试推送</el-button>
<el-button icon="el-icon-time" @click="loadLatest">最近一次</el-button>
</el-form-item>
<div v-else class="mobile-actions">
<el-button type="primary" icon="el-icon-search" @click="loadStats">看数据</el-button>
<el-button icon="el-icon-time" @click="loadLatest">最近一次</el-button>
<el-button class="span-2" type="warning" icon="el-icon-s-promotion" :loading="analyzing" @click="runAnalyze(true)">分析并推送</el-button>
<el-button type="success" plain icon="el-icon-magic-stick" :loading="analyzing" @click="runAnalyze(false)">只分析</el-button>
<el-button type="danger" plain icon="el-icon-position" :loading="testing" @click="runTest">测试推送</el-button>
</div>
</el-form>
</el-card>
<div v-if="current" class="range-line">统计区间 {{ current.beginDate }} ~ {{ current.endDate }}<span v-if="current.label"> · {{ current.label }}</span></div>
<el-row v-if="current" :gutter="16" class="summary-row">
<el-col v-for="item in summaryItems" :key="item.key" :xs="24" :sm="12" :md="8" :lg="4">
<el-col v-for="item in summaryItems" :key="item.key" :xs="12" :sm="12" :md="8" :lg="4">
<el-card class="summary-card" shadow="hover">
<div class="summary-title">{{ item.title }}</div>
<div class="summary-value">{{ item.display }}</div>
@@ -51,7 +59,27 @@
</el-col>
</el-row>
<el-row v-if="current" :gutter="16" class="table-row">
<div v-if="mobileLayout && current" class="mobile-groups">
<div class="group-title">分销类型</div>
<div v-for="row in current.byKind || []" :key="'kind-' + row.name" class="group-row">
<div class="group-name">{{ row.name }}</div>
<div class="group-meta">有效 {{ fmtNum(row.validOrderCount) }} · 退款 {{ fmtNum(row.refundCount) }} · 利润 {{ money(row.totalProfit) }} · {{ fmtNum(row.profitRatePct) }}%</div>
</div>
<div class="group-title">分销标记</div>
<div v-for="row in current.byMark || []" :key="'mark-' + row.kind + '-' + row.name" class="group-row">
<div class="group-name">{{ row.name }} <span class="group-kind">{{ row.kind }}</span></div>
<div class="group-meta">{{ fmtNum(row.orderCount) }} 单 · 付款 {{ money(row.payment) }} · 利润 {{ money(row.profit) }}</div>
</div>
<div v-if="!(current.byMark || []).length" class="group-empty">无</div>
<div class="group-title">型号</div>
<div v-for="row in current.byModel || []" :key="'model-' + row.name" class="group-row">
<div class="group-name">{{ row.name }}</div>
<div class="group-meta">{{ fmtNum(row.orderCount) }} 单 · 利润 {{ money(row.profit) }}</div>
</div>
<div v-if="!(current.byModel || []).length" class="group-empty">无</div>
</div>
<el-row v-if="current && !mobileLayout" :gutter="16" class="table-row">
<el-col :xs="24">
<el-card shadow="hover">
<div slot="header">分销类型(自有单 / 代下单 F-W·F-H / 代下单单)</div>
@@ -73,7 +101,7 @@
</el-col>
</el-row>
<el-row v-if="current" :gutter="16" class="table-row">
<el-row v-if="current && !mobileLayout" :gutter="16" class="table-row">
<el-col :xs="24" :lg="12">
<el-card shadow="hover">
<div slot="header">分销标记</div>
@@ -133,7 +161,18 @@
<span>发送记录</span>
<el-button type="text" icon="el-icon-refresh" :loading="logsLoading" @click="loadSendLogs">刷新</el-button>
</div>
<el-table :data="sendLogs" stripe size="small" max-height="420" empty-text="暂无发送记录">
<div v-if="mobileLayout" class="log-list">
<div v-if="!sendLogs.length" class="group-empty">暂无发送记录</div>
<div v-for="row in sendLogs" :key="row.id || row.sentAt + row.periodLabel" class="log-item" @click="showLogReport(row)">
<div class="log-item-top">
<span>{{ row.periodLabel || '—' }}</span>
<el-tag :type="row.pushed ? 'success' : 'danger'" size="mini">{{ row.pushed ? '已推送' : '失败' }}</el-tag>
</div>
<div class="log-item-sub">{{ row.sentAt }} · {{ triggerLabel(row.trigger) }} · 利润 {{ money(row.totalProfit) }}</div>
<div v-if="row.pushError || row.aiError" class="log-item-err">{{ row.pushError || row.aiError }}</div>
</div>
</div>
<el-table v-else :data="sendLogs" stripe size="small" max-height="420" empty-text="暂无发送记录">
<el-table-column prop="sentAt" label="时间" width="160" />
<el-table-column prop="trigger" label="来源" width="88">
<template slot-scope="scope">
@@ -162,12 +201,12 @@
</el-table>
</el-card>
<el-dialog title="发送内容" :visible.sync="logDialogVisible" width="640px" append-to-body>
<el-dialog title="发送内容" :visible.sync="logDialogVisible" :width="mobileLayout ? '92%' : '640px'" append-to-body>
<p class="log-dialog-meta">{{ logDialogMeta }}</p>
<pre class="report-text">{{ logDialogReport }}</pre>
</el-dialog>
<el-card v-if="stats" class="json-card" shadow="hover">
<el-card v-if="stats && !mobileLayout" class="json-card" shadow="hover">
<div slot="header">提交给模型 {{ llmChars }} 字符(无缩进列数组;框内换行只为方便看,上方卡片仍是完整对象)</div>
<el-input type="textarea" :value="statsJson" :autosize="{ minRows: 8, maxRows: 22 }" readonly />
</el-card>
@@ -201,6 +240,9 @@ export default {
}
},
computed: {
mobileLayout() {
return this.$store.getters.device === 'mobile'
},
datePickerType() {
if (this.periodType === 'month') return 'month'
return 'date'
@@ -537,4 +579,88 @@ export default {
font-size: 14px;
color: #303133;
}
.profit-analysis--mobile .period-group {
display: flex;
width: 100%;
}
.profit-analysis--mobile .period-group ::v-deep .el-radio-button {
flex: 1;
}
.profit-analysis--mobile .period-group ::v-deep .el-radio-button__inner {
width: 100%;
padding-left: 0;
padding-right: 0;
}
.profit-analysis--mobile .el-form-item {
display: block;
margin-right: 0;
}
.profit-analysis--mobile .el-date-editor.el-input {
width: 100%;
}
.mobile-actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.mobile-actions .el-button {
margin: 0;
width: 100%;
}
.mobile-actions .span-2 {
grid-column: 1 / -1;
}
.profit-analysis--mobile .summary-value {
font-size: 18px;
}
.mobile-groups,
.log-list {
margin-bottom: 12px;
}
.group-title {
margin: 12px 0 6px;
font-size: 14px;
font-weight: 600;
color: #303133;
}
.group-row,
.log-item {
margin-bottom: 8px;
padding: 10px 12px;
background: #fff;
border: 1px solid #ebeef5;
border-radius: 6px;
}
.group-name,
.log-item-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
font-size: 14px;
color: #303133;
word-break: break-all;
}
.group-kind {
flex: none;
color: #909399;
font-size: 12px;
}
.group-meta,
.log-item-sub {
margin-top: 4px;
color: #606266;
font-size: 12px;
line-height: 1.5;
}
.log-item-err,
.group-empty {
margin-top: 4px;
color: #e6a23c;
font-size: 12px;
}
.group-empty {
margin-top: 0;
color: #909399;
}
</style>