This commit is contained in:
van
2026-11-05 15:31:01 +08:00
parent a3b996a026
commit afc2ed62af
4 changed files with 303 additions and 1 deletions
+24
View File
@@ -92,6 +92,30 @@ export function resetAllLlmConfig() {
})
}
// 闲鱼品类模板:发货说明、装箱清单、型号覆盖
export function listXianyuCopyTemplates() {
return request({
url: '/jarvis/social-media/xianyu-template',
method: 'get'
})
}
export function saveXianyuCopyTemplate(data) {
return request({
url: '/jarvis/social-media/xianyu-template/save',
method: 'post',
data
})
}
export function deleteXianyuCopyTemplate(data) {
return request({
url: '/jarvis/social-media/xianyu-template/delete',
method: 'post',
data
})
}
/** 连通测试:可选 profileId、message,不传 profileId 则用 Jarvis 当前激活/默认 */
export function testLlmProfile(data) {
return request({
@@ -37,7 +37,7 @@
<li><strong>小红书文案模板</strong>:用于生成小红书风格文案,占位符:%s = 商品名称,%s = 价格信息,%s = 关键词</li>
<li><strong>抖音文案模板</strong>:用于生成抖音风格文案,占位符:%s = 商品名称,%s = 价格信息,%s = 关键词</li>
<li><strong>通用文案模板</strong>:用于生成通用风格文案,占位符:%s = 商品名称,%s = 价格信息,%s = 关键词</li>
<li><strong>闲鱼·正文基础</strong>:只拼进「代下单」,在标题/型号行之后</li>
<li><strong>闲鱼·正文基础</strong>:只拼进「代下单」,在标题/型号行之后。装箱清单和发货说明在「闲鱼 → 品类模板」</li>
<li><strong>闲鱼·代下单补充</strong>:接在正文基础之后;留空则不出现。保存接口不允许空内容,清空请点「恢复默认」</li>
<li><strong>闲鱼·教你下单尾部</strong>:接在「更新日期」后的附加说明</li>
<li><strong>闲鱼·标题清洗正则</strong>:从标题、型号备注中删除匹配片段(须为合法 Java 正则)</li>
@@ -0,0 +1,269 @@
<template>
<div class="xianyu-template-container">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span class="card-title">
<i class="el-icon-document"></i>
闲鱼品类模板
</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-refresh"
@click="loadAll">
刷新
</el-button>
</div>
<el-alert
v-if="redisAvailable === false"
title="当前未连接 Redis,无法读取或保存模板。"
type="warning"
:closable="false"
show-icon
style="margin-bottom: 16px;" />
<el-alert
type="info"
:closable="false"
show-icon
style="margin-bottom: 16px;">
<div slot="default">
装箱清单按品类保存,某个型号需要单独清单时再加型号覆盖。型号会先去掉营销词再匹配,命中后整段替换品类清单。标题用语(如洗碗机对应嵌入式洗碗机)显示在表格里供对照。保存后立即生效。
</div>
</el-alert>
<div class="section-title">发货说明</div>
<div class="template-status">
<el-tag :type="shipNote.isDefault ? 'info' : 'success'" size="small">
{{ shipNote.isDefault ? '内置默认' : '已自定义' }}
</el-tag>
</div>
<el-input
v-model="shipNote.value"
type="textarea"
:rows="3"
placeholder="当天付款当天排单,物流到达前电话联系预约安装。" />
<div class="section-actions">
<el-button type="primary" size="small" :loading="savingShip" @click="saveShip">保存发货说明</el-button>
<el-button
v-if="!shipNote.isDefault"
size="small"
icon="el-icon-refresh-left"
@click="resetShip">
恢复默认
</el-button>
</div>
</el-card>
<el-card class="box-card" style="margin-top: 16px;">
<div slot="header">
<span class="card-title">品类装箱清单</span>
</div>
<el-table :data="categories" border stripe empty-text="暂无品类">
<el-table-column prop="category" label="品类" width="110" />
<el-table-column prop="skeleton" label="标题用语" width="140" />
<el-table-column label="装箱清单" min-width="280">
<template slot-scope="scope">
<el-input
v-model="scope.row.packList"
type="textarea"
:rows="2"
placeholder="留空表示生成时不出现这一行" />
</template>
</el-table-column>
<el-table-column label="操作" width="150" align="center">
<template slot-scope="scope">
<el-button
type="text"
size="small"
:loading="savingCategory === scope.row.category"
@click="savePackList(scope.row)">
保存
</el-button>
<el-button type="text" size="small" @click="clearPackList(scope.row)">清空</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<el-card class="box-card" style="margin-top: 16px;">
<div slot="header" class="clearfix">
<span class="card-title">型号覆盖清单</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
icon="el-icon-plus"
@click="openSkuDialog()">
新增型号
</el-button>
</div>
<el-table :data="skuNotes" border stripe empty-text="还没有型号覆盖,生成时使用品类清单">
<el-table-column prop="model" label="型号" min-width="140" show-overflow-tooltip />
<el-table-column prop="packList" label="装箱清单" min-width="280" show-overflow-tooltip />
<el-table-column label="操作" width="140" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" @click="openSkuDialog(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="removeSku(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<el-dialog
:title="skuForm.oldName ? '编辑型号清单' : '新增型号清单'"
:visible.sync="skuDialogVisible"
width="520px"
append-to-body>
<el-form label-width="72px">
<el-form-item label="型号">
<el-input v-model="skuForm.model" placeholder="与发品页填写的型号一致,营销词会自动去掉" />
</el-form-item>
<el-form-item label="清单">
<el-input v-model="skuForm.packList" type="textarea" :rows="4" placeholder="命中该型号时整段替换品类清单" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button @click="skuDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="savingSku" @click="saveSku">保存</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listXianyuCopyTemplates, saveXianyuCopyTemplate, deleteXianyuCopyTemplate } from '@/api/jarvis/socialMediaPrompt'
export default {
name: 'XianyuTemplate',
data() {
return {
redisAvailable: true,
shipNote: { value: '', isDefault: true },
categories: [],
skuNotes: [],
savingShip: false,
savingCategory: '',
savingSku: false,
skuDialogVisible: false,
skuForm: { oldName: '', model: '', packList: '' }
}
},
created() {
this.loadAll()
},
methods: {
async loadAll() {
const res = await listXianyuCopyTemplates()
if (res.code !== 200 || !res.data) {
return
}
this.redisAvailable = res.data.redisAvailable !== false
this.shipNote = res.data.shipNote || { value: '', isDefault: true }
this.categories = Array.isArray(res.data.categories) ? res.data.categories : []
this.skuNotes = Array.isArray(res.data.skuNotes) ? res.data.skuNotes : []
},
async saveShip() {
this.savingShip = true
try {
const res = await saveXianyuCopyTemplate({ type: 'ship', value: this.shipNote.value })
if (res.code === 200) {
this.$message.success(res.msg || '保存成功')
await this.loadAll()
}
} finally {
this.savingShip = false
}
},
resetShip() {
this.$confirm('恢复为内置发货说明?', '提示', { type: 'warning' }).then(async () => {
const res = await deleteXianyuCopyTemplate({ type: 'ship' })
if (res.code === 200) {
this.$message.success(res.msg || '已恢复默认')
await this.loadAll()
}
}).catch(() => {})
},
async savePackList(row) {
this.savingCategory = row.category
try {
const res = await saveXianyuCopyTemplate({
type: 'packlist',
name: row.category,
value: row.packList
})
if (res.code === 200) {
this.$message.success(res.msg || '保存成功')
await this.loadAll()
}
} finally {
this.savingCategory = ''
}
},
clearPackList(row) {
this.$confirm('清空后,这个品类生成文案时不再出现装箱清单。', '提示', { type: 'warning' }).then(async () => {
const res = await deleteXianyuCopyTemplate({ type: 'packlist', name: row.category })
if (res.code === 200) {
this.$message.success(res.msg || '已清空')
await this.loadAll()
}
}).catch(() => {})
},
openSkuDialog(row) {
if (row) {
this.skuForm = { oldName: row.model, model: row.model, packList: row.packList || '' }
} else {
this.skuForm = { oldName: '', model: '', packList: '' }
}
this.skuDialogVisible = true
},
async saveSku() {
this.savingSku = true
try {
const res = await saveXianyuCopyTemplate({
type: 'sku',
name: this.skuForm.model,
oldName: this.skuForm.oldName,
value: this.skuForm.packList
})
if (res.code === 200) {
const savedModel = res.data && res.data.model
this.$message.success(savedModel ? ('已保存,匹配型号:' + savedModel) : (res.msg || '保存成功'))
this.skuDialogVisible = false
await this.loadAll()
}
} finally {
this.savingSku = false
}
},
removeSku(row) {
this.$confirm('删除型号「' + row.model + '」后,将改用品类装箱清单。', '提示', { type: 'warning' }).then(async () => {
const res = await deleteXianyuCopyTemplate({ type: 'sku', name: row.model })
if (res.code === 200) {
this.$message.success(res.msg || '已删除')
await this.loadAll()
}
}).catch(() => {})
}
}
}
</script>
<style scoped>
.xianyu-template-container {
padding: 12px;
}
.card-title {
font-weight: 600;
}
.section-title {
margin-bottom: 8px;
font-weight: 600;
}
.template-status {
margin-bottom: 8px;
}
.section-actions {
margin-top: 12px;
}
</style>
@@ -6,6 +6,12 @@
<i class="el-icon-edit-outline"></i>
闲鱼文案(手动)
</span>
<el-button
style="float: right; padding: 3px 0"
type="text"
@click="goTemplate">
维护品类模板
</el-button>
</div>
<div class="input-section">
@@ -188,6 +194,9 @@ export default {
if (this.resizeTimer) clearTimeout(this.resizeTimer)
},
methods: {
goTemplate() {
this.$router.push('/xianyu/xianyu-template')
},
checkMobile() {
this.mobile = document.documentElement.clientWidth < 768
},