This commit is contained in:
van
2026-04-06 11:15:08 +08:00
parent db7687e7df
commit 679e0dd3af
3 changed files with 63 additions and 15 deletions

View File

@@ -257,6 +257,15 @@ export function recalcProfitBatch(ids) {
})
}
/** 本页订单:利润未手动的按规则重算,仅变化时落库(刷新列表后调用) */
export function syncAutoProfitBatch(ids) {
return request({
url: '/system/jdorder/tools/sync-auto-profit',
method: 'post',
data: { ids }
})
}
// 生成录单格式文本Excel可粘贴格式
export function generateExcelText(query) {
return request({

View File

@@ -1063,7 +1063,7 @@
</template>
<script>
import { listJDOrders, updateJDOrder, delJDOrder, fetchLogisticsManually, batchMarkRebateReceived, generateExcelText, importGroupRebateExcelBatch, listGroupRebateExcelUploads, deleteGroupRebateUpload, recalcProfitBatch } from '@/api/system/jdorder'
import { listJDOrders, getJDOrder, updateJDOrder, delJDOrder, fetchLogisticsManually, batchMarkRebateReceived, generateExcelText, importGroupRebateExcelBatch, listGroupRebateExcelUploads, deleteGroupRebateUpload, recalcProfitBatch, syncAutoProfitBatch } from '@/api/system/jdorder'
import { fillLogisticsByOrderNo, getTokenStatus, getTencentDocAuthUrl, testUserInfo, getAutoWriteConfig, reverseSyncThirdPartyOrderNo } from '@/api/jarvis/tendoc'
import { mapGetters } from 'vuex'
import ListLayout from '@/components/ListLayout'
@@ -1158,7 +1158,9 @@ export default {
// 已复制录单格式的订单ID集合页面级缓存刷新后消失
copiedExcelTextOrderIds: new Set(),
// 选中的行数据
selectedRows: []
selectedRows: [],
// 列表加载后自动同步利润(防快速翻页乱序)
syncAutoProfitSeq: 0
}
},
computed: {
@@ -1312,13 +1314,37 @@ export default {
profitManual: item.profitManual != null ? item.profitManual : 0
}
},
getList() {
this.loading = true
listJDOrders(this.queryParams).then(res => {
assignListFromResponse(res) {
const list = (res.rows || res.data || [])
this.list = list.map(item => this.normalizeOrderListItem(item))
this.total = res.total || 0
},
/** 本页数据与库中规则对齐:仅未锁定利润的订单可能写库;有更新则静默拉一次列表(不再递归同步) */
runSyncAutoProfitAfterListLoad() {
const ids = this.list.map(r => r.id).filter(id => id != null)
if (!ids.length) return
const seq = ++this.syncAutoProfitSeq
if (this._syncAutoProfitTimer) clearTimeout(this._syncAutoProfitTimer)
this._syncAutoProfitTimer = setTimeout(() => {
syncAutoProfitBatch(ids)
.then(res => {
if (seq !== this.syncAutoProfitSeq) return
const u = res && res.data && typeof res.data.updated === 'number' ? res.data.updated : 0
if (u <= 0) return
return listJDOrders(this.queryParams).then(r2 => {
if (seq !== this.syncAutoProfitSeq) return
this.assignListFromResponse(r2)
})
})
.catch(() => {})
}, 120)
},
getList() {
this.loading = true
listJDOrders(this.queryParams).then(res => {
this.assignListFromResponse(res)
this.loading = false
this.runSyncAutoProfitAfterListLoad()
}).catch(() => { this.loading = false })
},
/** 智能查询列表,如果今天数据为空则查询昨天 */
@@ -1327,10 +1353,7 @@ export default {
try {
const res = await listJDOrders(this.queryParams)
let list = (res.rows || res.data || [])
list = list.map(item => this.normalizeOrderListItem(item))
this.list = list
this.total = res.total || 0
this.assignListFromResponse(res)
// 如果今天的数据为空,且是默认查询(没有手动选择日期),则尝试查询昨天
if (this.list.length === 0 && this.isDefaultQuery()) {
@@ -1348,11 +1371,7 @@ export default {
// 查询昨天的数据
const yesterdayRes = await listJDOrders(this.queryParams)
let yesterdayList = (yesterdayRes.rows || yesterdayRes.data || [])
// 为退款相关字段设置默认值
yesterdayList = yesterdayList.map(item => this.normalizeOrderListItem(item))
this.list = yesterdayList
this.total = yesterdayRes.total || 0
this.assignListFromResponse(yesterdayRes)
if (this.list.length > 0) {
this.$message.success(`已查询到昨天(${yesterdayStr})的慢单数据`)
@@ -1362,6 +1381,7 @@ export default {
}
this.loading = false
this.runSyncAutoProfitAfterListLoad()
} catch (error) {
this.loading = false
this.$message.error('查询失败,请稍后重试')
@@ -1591,10 +1611,25 @@ export default {
const reb = hasReb ? Number(row.rebateAmount) : 0
return (pay - reb).toFixed(2)
},
/** 保存后拉取单条,展示服务端重算后的利润/售价 */
patchOrderRowFromServer(id) {
if (id == null) return
getJDOrder(id)
.then(res => {
const raw = res && res.data
if (!raw) return
const idx = this.list.findIndex(r => r.id === id)
if (idx === -1) return
const merged = this.normalizeOrderListItem({ ...this.list[idx], ...raw })
this.$set(this.list, idx, merged)
})
.catch(() => {})
},
persistOrderRow(row, successMsg) {
return updateJDOrder(row)
.then(() => {
if (successMsg) this.$message.success(successMsg)
this.patchOrderRowFromServer(row.id)
})
.catch(() => {
this.$message.error('保存失败')
@@ -1603,10 +1638,12 @@ export default {
},
onOrderSellingPriceTypeChange(row) {
row.sellingPriceManual = 0
row.profitManual = 0
this.persistOrderRow(row)
},
onOrderSellingPriceChange(row) {
row.sellingPriceManual = 1
row.profitManual = 0
this.persistOrderRow(row)
},
onOrderProfitChange(row) {
@@ -1615,6 +1652,7 @@ export default {
},
fillSellingPriceFromConfig(row) {
row.sellingPriceManual = 0
row.profitManual = 0
this.persistOrderRow(row, '已按型号配置回填售价并重算利润')
},
recalcOrderProfitOnly(row) {

View File

@@ -136,7 +136,8 @@
<p style="margin: 0 0 8px 0;"><strong>说明</strong>可保存多套如本地 Ollama远程 API在表格中点击<strong>激活</strong>Jarvis 社媒 AI 仅使用<strong>当前激活</strong>的一套未激活或清空全部时走 Jarvis 默认 Ollama</p>
<ul style="margin: 0; padding-left: 18px;">
<li><strong>Ollama</strong>根地址可空 Jarvis 默认模型可空</li>
<li><strong>OpenAI 兼容</strong>须填完整 Chat Completions URL 与模型名密钥可空</li>
<li><strong>OpenAI 兼容</strong>须填<strong>完整</strong> Chat Completions 地址如火山方舟为 <code>https://ark.cn-beijing.volces.com/api/v3/chat/completions</code>,不要用 Coding/OpenClaw 文档里的 <code>.../api/coding/v3</code>,否则会 404。</li>
<li>方舟模型一般填控制台<strong>推理接入点 ID</strong><code>ep-xxxx</code>不是展示名 glm-4.7</li>
</ul>
</div>
</el-alert>