用户同步功能

This commit is contained in:
zhonghua.li
2026-05-19 08:52:09 +08:00
parent 7bfd7f9f5f
commit 60e1c628bb
2 changed files with 47 additions and 0 deletions

View File

@@ -68,6 +68,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">
@@ -84,6 +93,7 @@
<el-table-column label="联系方式" prop="mobile" min-width="120" show-overflow-tooltip />
<el-table-column label="上级ID" prop="pid" min-width="110" show-overflow-tooltip />
<el-table-column label="上级姓名" prop="pname" min-width="100" show-overflow-tooltip />
<el-table-column label="上级电话" prop="pmobile" min-width="130" show-overflow-tooltip />
<el-table-column label="最高可抢单数" prop="maxOrder" width="110" align="center" />
<el-table-column label="今日购买总金额" prop="todayBuyTotal" min-width="120" show-overflow-tooltip />
<el-table-column label="今日卖出总金额" prop="todaySellTotal" min-width="120" show-overflow-tooltip />
@@ -372,8 +382,10 @@ import {
addLbUser,
deleteLbUser,
getLbUserList,
syncLbUserFromHxr,
updateLbUser
} from '@/api/lb-user'
import { getBusinessHeaders } from '@/utils/business-headers'
function emptyForm() {
return {
@@ -448,6 +460,7 @@ export default {
return {
loading: false,
submitLoading: false,
syncLoading: false,
list: [],
total: 0,
dialogVisible: false,
@@ -602,6 +615,32 @@ export default {
pname: row.pname || ''
}
},
getTenantIdFromBusinessHeaders() {
const headers = getBusinessHeaders()
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
syncLbUserFromHxr({ 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
})
},
handleAdd() {
this.dialogTitle = '新增用户'
this.isEdit = false