货物同步功能

This commit is contained in:
zhonghua.li
2026-05-26 17:29:46 +08:00
parent 3cbc3d1251
commit 64ed366b4b
2 changed files with 42 additions and 0 deletions

View File

@@ -37,3 +37,13 @@ export function deleteLbGoods(id) {
method: 'delete'
})
}
/** 从 hxrd 第三方分页同步货品,可能较慢 */
export function syncLbGoodsFromHxr(params) {
return request({
url: '/lbGoods/sync-from-hxr',
method: 'post',
params,
timeout: 120000
})
}

View File

@@ -56,6 +56,15 @@
<el-card class="action-container" shadow="never">
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
<el-button
type="warning"
icon="el-icon-refresh"
:loading="syncLoading"
style="margin-left: 12px"
@click="handleSyncFromHxr"
>
同步货品
</el-button>
</el-card>
<el-card class="table-container" shadow="never">
@@ -209,6 +218,7 @@ import {
addLbGoods,
deleteLbGoods,
getLbGoodsList,
syncLbGoodsFromHxr,
updateLbGoods
} from '@/api/lb-goods'
import { getBusinessHeaders } from '@/utils/business-headers'
@@ -263,6 +273,7 @@ export default {
return {
loading: false,
submitLoading: false,
syncLoading: false,
list: [],
total: 0,
dialogVisible: false,
@@ -296,6 +307,27 @@ export default {
const value = headers && headers['X-Tenant-Id']
return value ? String(value).trim() : ''
},
handleSyncFromHxr() {
const tenantId = this.getTenantIdFromBusinessHeaders()
if (!tenantId) {
this.$message.error('未获取到租户ID请先登录或配置业务请求头中的租户')
return
}
this.syncLoading = true
syncLbGoodsFromHxr({ tenantId })
.then((res) => {
const isSuccess = res && (res.success === true || res.code === 200 || res.code === 20000)
if (!isSuccess) {
this.$message.error((res && res.message) || '同步货品失败')
return
}
this.$message.success((res && res.message) || '同步货品成功')
this.fetchList()
})
.finally(() => {
this.syncLoading = false
})
},
fetchList() {
this.loading = true
getLbGoodsList(this.buildListParams())