1
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
/** 导出近几个月利润和单量纯文本(不调用大模型) */
|
||||||
|
export function exportOrderProfitText(query) {
|
||||||
|
return request({
|
||||||
|
url: '/jarvis/order-profit-analysis/export-text',
|
||||||
|
method: 'get',
|
||||||
|
params: query,
|
||||||
|
timeout: 120000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 预览统计 JSON(不调用大模型) */
|
/** 预览统计 JSON(不调用大模型) */
|
||||||
export function previewOrderProfitStats(query) {
|
export function previewOrderProfitStats(query) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<el-alert
|
<el-alert
|
||||||
v-if="!mobileLayout"
|
v-if="!mobileLayout"
|
||||||
title="先按日/周/月汇总 jd_order(参与统计、已退款不计入利润),再套「DS提示词」里的「慢单利润分析」调用当前激活大模型。定时:每天 21:00 推当天日报,周一 08:20 推上周,每月 1 日 08:30 推上月。"
|
title="日/周/月可预览或调用大模型。近几个月的利润和单量用「导出文本」,复制后贴给本地助手,不调用远程大模型。定时:每天 21:00 推当天日报,周一 08:20 推上周,每月 1 日 08:30 推上月。"
|
||||||
type="info"
|
type="info"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
show-icon
|
show-icon
|
||||||
@@ -30,6 +30,14 @@
|
|||||||
:style="{ width: mobileLayout ? '100%' : '220px' }"
|
:style="{ width: mobileLayout ? '100%' : '220px' }"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="导出">
|
||||||
|
<div class="export-inline">
|
||||||
|
<span>近</span>
|
||||||
|
<el-input-number v-model="exportMonths" :min="1" :max="24" :step="1" controls-position="right" />
|
||||||
|
<span>个月</span>
|
||||||
|
<el-button type="primary" plain icon="el-icon-document" :loading="exportLoading" @click="exportLocalText">导出文本</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item v-if="!mobileLayout">
|
<el-form-item v-if="!mobileLayout">
|
||||||
<el-button type="primary" icon="el-icon-search" :loading="statsLoading" @click="loadStats">预览统计</el-button>
|
<el-button type="primary" icon="el-icon-search" :loading="statsLoading" @click="loadStats">预览统计</el-button>
|
||||||
<el-button type="success" icon="el-icon-magic-stick" :loading="submitting" @click="runAnalyze(false)">AI 分析</el-button>
|
<el-button type="success" icon="el-icon-magic-stick" :loading="submitting" @click="runAnalyze(false)">AI 分析</el-button>
|
||||||
@@ -249,6 +257,15 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<el-dialog title="利润与单量文本" :visible.sync="exportDialogVisible" :width="mobileLayout ? '92%' : '720px'" append-to-body>
|
||||||
|
<p class="log-dialog-meta">{{ exportMeta }}</p>
|
||||||
|
<el-input type="textarea" :value="exportText" :autosize="{ minRows: 12, maxRows: 22 }" readonly />
|
||||||
|
<div slot="footer">
|
||||||
|
<el-button icon="el-icon-download" @click="downloadExport">下载 txt</el-button>
|
||||||
|
<el-button type="primary" icon="el-icon-document-copy" @click="copyText(exportText)">复制</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog :title="logDialogTitle" :visible.sync="logDialogVisible" :width="mobileLayout ? '92%' : '640px'" append-to-body>
|
<el-dialog :title="logDialogTitle" :visible.sync="logDialogVisible" :width="mobileLayout ? '92%' : '640px'" append-to-body>
|
||||||
<p class="log-dialog-meta">{{ logDialogMeta }}</p>
|
<p class="log-dialog-meta">{{ logDialogMeta }}</p>
|
||||||
<pre class="report-text">{{ logDialogReport }}</pre>
|
<pre class="report-text">{{ logDialogReport }}</pre>
|
||||||
@@ -262,7 +279,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { previewOrderProfitStats, analyzeOrderProfit, latestOrderProfitAnalysis, testOrderProfitPush, listOrderProfitSendLogs, listOrderProfitCallLogs } from '@/api/system/orderProfitAnalysis'
|
import { previewOrderProfitStats, analyzeOrderProfit, latestOrderProfitAnalysis, testOrderProfitPush, listOrderProfitSendLogs, listOrderProfitCallLogs, exportOrderProfitText } from '@/api/system/orderProfitAnalysis'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'SlowOrderProfitAnalysis',
|
name: 'SlowOrderProfitAnalysis',
|
||||||
@@ -288,7 +305,12 @@ export default {
|
|||||||
logDialogTitle: '发送内容',
|
logDialogTitle: '发送内容',
|
||||||
logDialogMeta: '',
|
logDialogMeta: '',
|
||||||
logDialogReport: '',
|
logDialogReport: '',
|
||||||
llmJson: ''
|
llmJson: '',
|
||||||
|
exportMonths: 6,
|
||||||
|
exportLoading: false,
|
||||||
|
exportDialogVisible: false,
|
||||||
|
exportText: '',
|
||||||
|
exportMeta: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -596,18 +618,60 @@ export default {
|
|||||||
this.statsLoading = false
|
this.statsLoading = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
copyReport() {
|
async exportLocalText() {
|
||||||
if (!this.report) return
|
const months = Number(this.exportMonths)
|
||||||
const text = this.report
|
if (!months || months < 1 || months > 24) {
|
||||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
this.$message.warning('导出月数请填 1 到 24')
|
||||||
navigator.clipboard.writeText(text).then(() => {
|
|
||||||
this.$message.success('已复制')
|
|
||||||
}).catch(() => this.fallbackCopy(text))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.fallbackCopy(text)
|
this.exportLoading = true
|
||||||
|
try {
|
||||||
|
const res = await exportOrderProfitText({
|
||||||
|
months,
|
||||||
|
date: this.queryDate()
|
||||||
|
})
|
||||||
|
if (res.code !== 200 || !res.data || !res.data.text) {
|
||||||
|
this.$message.error((res && res.msg) || '导出失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.exportText = res.data.text
|
||||||
|
const chars = res.data.chars || res.data.text.length
|
||||||
|
this.exportMeta = (res.data.begin || '') + ' 至 ' + (res.data.end || '') + ' · ' + chars + ' 字 · 不调用远程大模型,可直接粘贴给本地助手'
|
||||||
|
this.exportDialogVisible = true
|
||||||
|
this.copyText(this.exportText, '已复制,可粘贴给本地助手')
|
||||||
|
} catch (e) {
|
||||||
|
this.$message.error('导出失败:' + (e.message || '未知错误'))
|
||||||
|
} finally {
|
||||||
|
this.exportLoading = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fallbackCopy(text) {
|
downloadExport() {
|
||||||
|
if (!this.exportText) return
|
||||||
|
const blob = new Blob([this.exportText], { type: 'text/plain;charset=utf-8' })
|
||||||
|
const a = document.createElement('a')
|
||||||
|
const name = '利润与单量-近' + (this.exportMonths || '') + '个月.txt'
|
||||||
|
a.href = URL.createObjectURL(blob)
|
||||||
|
a.download = name
|
||||||
|
document.body.appendChild(a)
|
||||||
|
a.click()
|
||||||
|
document.body.removeChild(a)
|
||||||
|
URL.revokeObjectURL(a.href)
|
||||||
|
},
|
||||||
|
copyReport() {
|
||||||
|
this.copyText(this.report)
|
||||||
|
},
|
||||||
|
copyText(text, okText) {
|
||||||
|
if (!text) return
|
||||||
|
const done = okText || '已复制'
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(text).then(() => {
|
||||||
|
this.$message.success(done)
|
||||||
|
}).catch(() => this.fallbackCopy(text, done))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.fallbackCopy(text, done)
|
||||||
|
},
|
||||||
|
fallbackCopy(text, okText) {
|
||||||
const ta = document.createElement('textarea')
|
const ta = document.createElement('textarea')
|
||||||
ta.value = text
|
ta.value = text
|
||||||
ta.style.position = 'fixed'
|
ta.style.position = 'fixed'
|
||||||
@@ -616,9 +680,9 @@ export default {
|
|||||||
ta.select()
|
ta.select()
|
||||||
try {
|
try {
|
||||||
document.execCommand('copy')
|
document.execCommand('copy')
|
||||||
this.$message.success('已复制')
|
this.$message.success(okText || '已复制')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$message.error('复制失败')
|
this.$message.error('复制失败,请在弹窗里手动复制')
|
||||||
}
|
}
|
||||||
document.body.removeChild(ta)
|
document.body.removeChild(ta)
|
||||||
}
|
}
|
||||||
@@ -716,6 +780,15 @@ export default {
|
|||||||
.profit-analysis--mobile .el-date-editor.el-input {
|
.profit-analysis--mobile .el-date-editor.el-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
.export-inline {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.export-inline .el-input-number {
|
||||||
|
width: 110px;
|
||||||
|
}
|
||||||
.mobile-actions {
|
.mobile-actions {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
|
|||||||
Reference in New Issue
Block a user