1
This commit is contained in:
@@ -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可粘贴格式)
|
// 生成录单格式文本(Excel可粘贴格式)
|
||||||
export function generateExcelText(query) {
|
export function generateExcelText(query) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -1063,7 +1063,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<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 { fillLogisticsByOrderNo, getTokenStatus, getTencentDocAuthUrl, testUserInfo, getAutoWriteConfig, reverseSyncThirdPartyOrderNo } from '@/api/jarvis/tendoc'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import ListLayout from '@/components/ListLayout'
|
import ListLayout from '@/components/ListLayout'
|
||||||
@@ -1158,7 +1158,9 @@ export default {
|
|||||||
// 已复制录单格式的订单ID集合(页面级缓存,刷新后消失)
|
// 已复制录单格式的订单ID集合(页面级缓存,刷新后消失)
|
||||||
copiedExcelTextOrderIds: new Set(),
|
copiedExcelTextOrderIds: new Set(),
|
||||||
// 选中的行数据
|
// 选中的行数据
|
||||||
selectedRows: []
|
selectedRows: [],
|
||||||
|
// 列表加载后自动同步利润(防快速翻页乱序)
|
||||||
|
syncAutoProfitSeq: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -1312,13 +1314,37 @@ export default {
|
|||||||
profitManual: item.profitManual != null ? item.profitManual : 0
|
profitManual: item.profitManual != null ? item.profitManual : 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
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() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
listJDOrders(this.queryParams).then(res => {
|
listJDOrders(this.queryParams).then(res => {
|
||||||
const list = (res.rows || res.data || [])
|
this.assignListFromResponse(res)
|
||||||
this.list = list.map(item => this.normalizeOrderListItem(item))
|
|
||||||
this.total = res.total || 0
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.runSyncAutoProfitAfterListLoad()
|
||||||
}).catch(() => { this.loading = false })
|
}).catch(() => { this.loading = false })
|
||||||
},
|
},
|
||||||
/** 智能查询列表,如果今天数据为空则查询昨天 */
|
/** 智能查询列表,如果今天数据为空则查询昨天 */
|
||||||
@@ -1327,10 +1353,7 @@ export default {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await listJDOrders(this.queryParams)
|
const res = await listJDOrders(this.queryParams)
|
||||||
let list = (res.rows || res.data || [])
|
this.assignListFromResponse(res)
|
||||||
list = list.map(item => this.normalizeOrderListItem(item))
|
|
||||||
this.list = list
|
|
||||||
this.total = res.total || 0
|
|
||||||
|
|
||||||
// 如果今天的数据为空,且是默认查询(没有手动选择日期),则尝试查询昨天
|
// 如果今天的数据为空,且是默认查询(没有手动选择日期),则尝试查询昨天
|
||||||
if (this.list.length === 0 && this.isDefaultQuery()) {
|
if (this.list.length === 0 && this.isDefaultQuery()) {
|
||||||
@@ -1348,11 +1371,7 @@ export default {
|
|||||||
|
|
||||||
// 查询昨天的数据
|
// 查询昨天的数据
|
||||||
const yesterdayRes = await listJDOrders(this.queryParams)
|
const yesterdayRes = await listJDOrders(this.queryParams)
|
||||||
let yesterdayList = (yesterdayRes.rows || yesterdayRes.data || [])
|
this.assignListFromResponse(yesterdayRes)
|
||||||
// 为退款相关字段设置默认值
|
|
||||||
yesterdayList = yesterdayList.map(item => this.normalizeOrderListItem(item))
|
|
||||||
this.list = yesterdayList
|
|
||||||
this.total = yesterdayRes.total || 0
|
|
||||||
|
|
||||||
if (this.list.length > 0) {
|
if (this.list.length > 0) {
|
||||||
this.$message.success(`已查询到昨天(${yesterdayStr})的慢单数据`)
|
this.$message.success(`已查询到昨天(${yesterdayStr})的慢单数据`)
|
||||||
@@ -1362,6 +1381,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
this.runSyncAutoProfitAfterListLoad()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.$message.error('查询失败,请稍后重试')
|
this.$message.error('查询失败,请稍后重试')
|
||||||
@@ -1591,10 +1611,25 @@ export default {
|
|||||||
const reb = hasReb ? Number(row.rebateAmount) : 0
|
const reb = hasReb ? Number(row.rebateAmount) : 0
|
||||||
return (pay - reb).toFixed(2)
|
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) {
|
persistOrderRow(row, successMsg) {
|
||||||
return updateJDOrder(row)
|
return updateJDOrder(row)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (successMsg) this.$message.success(successMsg)
|
if (successMsg) this.$message.success(successMsg)
|
||||||
|
this.patchOrderRowFromServer(row.id)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message.error('保存失败')
|
this.$message.error('保存失败')
|
||||||
@@ -1603,10 +1638,12 @@ export default {
|
|||||||
},
|
},
|
||||||
onOrderSellingPriceTypeChange(row) {
|
onOrderSellingPriceTypeChange(row) {
|
||||||
row.sellingPriceManual = 0
|
row.sellingPriceManual = 0
|
||||||
|
row.profitManual = 0
|
||||||
this.persistOrderRow(row)
|
this.persistOrderRow(row)
|
||||||
},
|
},
|
||||||
onOrderSellingPriceChange(row) {
|
onOrderSellingPriceChange(row) {
|
||||||
row.sellingPriceManual = 1
|
row.sellingPriceManual = 1
|
||||||
|
row.profitManual = 0
|
||||||
this.persistOrderRow(row)
|
this.persistOrderRow(row)
|
||||||
},
|
},
|
||||||
onOrderProfitChange(row) {
|
onOrderProfitChange(row) {
|
||||||
@@ -1615,6 +1652,7 @@ export default {
|
|||||||
},
|
},
|
||||||
fillSellingPriceFromConfig(row) {
|
fillSellingPriceFromConfig(row) {
|
||||||
row.sellingPriceManual = 0
|
row.sellingPriceManual = 0
|
||||||
|
row.profitManual = 0
|
||||||
this.persistOrderRow(row, '已按型号配置回填售价并重算利润')
|
this.persistOrderRow(row, '已按型号配置回填售价并重算利润')
|
||||||
},
|
},
|
||||||
recalcOrderProfitOnly(row) {
|
recalcOrderProfitOnly(row) {
|
||||||
|
|||||||
@@ -136,7 +136,8 @@
|
|||||||
<p style="margin: 0 0 8px 0;"><strong>说明:</strong>可保存多套(如本地 Ollama、远程 API),在表格中点击<strong>激活</strong>后,Jarvis 社媒 AI 仅使用<strong>当前激活</strong>的一套。未激活或清空全部时走 Jarvis 默认 Ollama。</p>
|
<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;">
|
<ul style="margin: 0; padding-left: 18px;">
|
||||||
<li><strong>Ollama</strong>:根地址可空(用 Jarvis 默认),模型可空。</li>
|
<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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
|
|||||||
Reference in New Issue
Block a user