diff --git a/src/api/lb-goods.js b/src/api/lb-goods.js
index f979f20..5027f69 100644
--- a/src/api/lb-goods.js
+++ b/src/api/lb-goods.js
@@ -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
+ })
+}
diff --git a/src/views/lb-business/goods-package-predict/index.vue b/src/views/lb-business/goods-package-predict/index.vue
index 0f8a30b..4f91152 100644
--- a/src/views/lb-business/goods-package-predict/index.vue
+++ b/src/views/lb-business/goods-package-predict/index.vue
@@ -56,6 +56,15 @@
新增
+
+ 同步货品
+
@@ -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())