按租户拉取goods
This commit is contained in:
@@ -2,6 +2,23 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-card class="filter-container" shadow="never">
|
<el-card class="filter-container" shadow="never">
|
||||||
<el-form :model="queryParams" :inline="true" label-width="90px">
|
<el-form :model="queryParams" :inline="true" label-width="90px">
|
||||||
|
<el-form-item label="租户ID">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.tenantId"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择租户"
|
||||||
|
style="width: 220px"
|
||||||
|
:loading="tenantLoading"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in tenantOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="用户ID">
|
<el-form-item label="用户ID">
|
||||||
<el-input v-model="queryParams.userId" clearable placeholder="所属用户ID" style="width: 140px" />
|
<el-input v-model="queryParams.userId" clearable placeholder="所属用户ID" style="width: 140px" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -65,9 +82,8 @@
|
|||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
icon="el-icon-refresh"
|
icon="el-icon-refresh"
|
||||||
:loading="syncLoading"
|
|
||||||
style="margin-left: 12px"
|
style="margin-left: 12px"
|
||||||
@click="handleSyncFromHxr"
|
@click="openSyncDialog"
|
||||||
>
|
>
|
||||||
同步货品
|
同步货品
|
||||||
</el-button>
|
</el-button>
|
||||||
@@ -139,6 +155,32 @@
|
|||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<el-dialog title="同步货品" :visible.sync="syncDialogVisible" width="520px" @close="resetSyncForm">
|
||||||
|
<el-form ref="syncFormRef" :model="syncForm" :rules="syncFormRules" label-width="100px">
|
||||||
|
<el-form-item label="租户ID" prop="tenantId">
|
||||||
|
<el-select
|
||||||
|
v-model="syncForm.tenantId"
|
||||||
|
filterable
|
||||||
|
clearable
|
||||||
|
placeholder="请选择租户"
|
||||||
|
style="width: 100%"
|
||||||
|
:loading="tenantLoading"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="item in tenantOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="syncDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="syncLoading" @click="submitSyncFromHxr">确定</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<el-dialog title="帮我抢单" :visible.sync="rushBuyDialogVisible" width="520px" @close="resetRushBuyForm">
|
<el-dialog title="帮我抢单" :visible.sync="rushBuyDialogVisible" width="520px" @close="resetRushBuyForm">
|
||||||
<el-form ref="rushBuyFormRef" :model="rushBuyForm" :rules="rushBuyRules" label-width="130px">
|
<el-form ref="rushBuyFormRef" :model="rushBuyForm" :rules="rushBuyRules" label-width="130px">
|
||||||
<el-form-item label="租户ID">
|
<el-form-item label="租户ID">
|
||||||
@@ -254,6 +296,7 @@ import {
|
|||||||
syncLbGoodsFromHxr,
|
syncLbGoodsFromHxr,
|
||||||
updateLbGoods
|
updateLbGoods
|
||||||
} from '@/api/lb-goods'
|
} from '@/api/lb-goods'
|
||||||
|
import { getAllTenantList } from '@/api/tenant'
|
||||||
import { getBusinessHeaders } from '@/utils/business-headers'
|
import { getBusinessHeaders } from '@/utils/business-headers'
|
||||||
|
|
||||||
function emptyForm() {
|
function emptyForm() {
|
||||||
@@ -328,6 +371,15 @@ export default {
|
|||||||
loading: false,
|
loading: false,
|
||||||
submitLoading: false,
|
submitLoading: false,
|
||||||
syncLoading: false,
|
syncLoading: false,
|
||||||
|
syncDialogVisible: false,
|
||||||
|
tenantLoading: false,
|
||||||
|
tenantOptions: [],
|
||||||
|
syncForm: {
|
||||||
|
tenantId: ''
|
||||||
|
},
|
||||||
|
syncFormRules: {
|
||||||
|
tenantId: [{ required: true, message: '请选择租户', trigger: 'change' }]
|
||||||
|
},
|
||||||
rushBuyLoading: false,
|
rushBuyLoading: false,
|
||||||
rushBuyDialogVisible: false,
|
rushBuyDialogVisible: false,
|
||||||
apiToken: '',
|
apiToken: '',
|
||||||
@@ -359,6 +411,7 @@ export default {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
|
tenantId: '',
|
||||||
userId: '',
|
userId: '',
|
||||||
title: '',
|
title: '',
|
||||||
sellerId: '',
|
sellerId: '',
|
||||||
@@ -379,6 +432,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.getTenantOptions()
|
||||||
|
this.initDefaultTenantFilter()
|
||||||
this.fetchList()
|
this.fetchList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -387,31 +442,74 @@ export default {
|
|||||||
const value = headers && headers['X-Tenant-Id']
|
const value = headers && headers['X-Tenant-Id']
|
||||||
return value ? String(value).trim() : ''
|
return value ? String(value).trim() : ''
|
||||||
},
|
},
|
||||||
|
initDefaultTenantFilter() {
|
||||||
|
const tenantId = this.getTenantIdFromBusinessHeaders()
|
||||||
|
if (tenantId) this.queryParams.tenantId = tenantId
|
||||||
|
},
|
||||||
getApiTokenParam() {
|
getApiTokenParam() {
|
||||||
const token = (this.apiToken || '').trim()
|
const token = (this.apiToken || '').trim()
|
||||||
return token ? { token } : {}
|
return token ? { token } : {}
|
||||||
},
|
},
|
||||||
handleSyncFromHxr() {
|
getTenantOptions() {
|
||||||
const tenantId = this.getTenantIdFromBusinessHeaders()
|
this.tenantLoading = true
|
||||||
if (!tenantId) {
|
getAllTenantList()
|
||||||
this.$message.error('未获取到租户ID,请先登录或配置业务请求头中的租户')
|
.then((response) => {
|
||||||
return
|
if (response && (response.code === 20000 || response.code === 200)) {
|
||||||
}
|
const tenantList = Array.isArray(response.data) ? response.data : (response.data?.data || [])
|
||||||
this.syncLoading = true
|
this.tenantOptions = tenantList.map((item) => ({
|
||||||
syncLbGoodsFromHxr({ tenantId, ...this.getApiTokenParam() })
|
value: item.id,
|
||||||
.then((res) => {
|
label: item.tenantName ? `${item.tenantName} (${item.tenantCode || '-'})` : (item.tenantCode || item.id)
|
||||||
const isSuccess = res && (res.success === true || res.code === 200 || res.code === 20000)
|
}))
|
||||||
if (!isSuccess) {
|
} else {
|
||||||
this.$message.error((res && res.message) || '同步货品失败')
|
this.tenantOptions = []
|
||||||
return
|
|
||||||
}
|
}
|
||||||
this.$message.success((res && res.message) || '同步货品成功')
|
})
|
||||||
this.fetchList()
|
.catch(() => {
|
||||||
|
this.tenantOptions = []
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.syncLoading = false
|
this.tenantLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
openSyncDialog() {
|
||||||
|
const defaultTenantId = (this.queryParams.tenantId || '').trim() || this.getTenantIdFromBusinessHeaders()
|
||||||
|
this.syncForm = {
|
||||||
|
tenantId: defaultTenantId || ''
|
||||||
|
}
|
||||||
|
this.syncDialogVisible = true
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.syncFormRef && this.$refs.syncFormRef.clearValidate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
resetSyncForm() {
|
||||||
|
this.syncForm = { tenantId: '' }
|
||||||
|
this.$refs.syncFormRef && this.$refs.syncFormRef.resetFields()
|
||||||
|
},
|
||||||
|
submitSyncFromHxr() {
|
||||||
|
this.$refs.syncFormRef.validate((valid) => {
|
||||||
|
if (!valid) return
|
||||||
|
const tenantId = (this.syncForm.tenantId || '').trim()
|
||||||
|
if (!tenantId) {
|
||||||
|
this.$message.error('请选择租户')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.syncLoading = true
|
||||||
|
syncLbGoodsFromHxr({ tenantId, ...this.getApiTokenParam() })
|
||||||
|
.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.syncDialogVisible = false
|
||||||
|
this.fetchList()
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.syncLoading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
openRushBuyDialog() {
|
openRushBuyDialog() {
|
||||||
this.rushBuyDialogVisible = true
|
this.rushBuyDialogVisible = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
@@ -490,7 +588,7 @@ export default {
|
|||||||
status: parseOptionalInt(this.queryParams.status),
|
status: parseOptionalInt(this.queryParams.status),
|
||||||
currentPage: this.queryParams.currentPage || undefined
|
currentPage: this.queryParams.currentPage || undefined
|
||||||
}
|
}
|
||||||
const tenantId = this.getTenantIdFromBusinessHeaders()
|
const tenantId = (this.queryParams.tenantId || '').trim() || undefined
|
||||||
if (tenantId) params.tenantId = tenantId
|
if (tenantId) params.tenantId = tenantId
|
||||||
if (Array.isArray(this.createdAtRange) && this.createdAtRange.length === 2) {
|
if (Array.isArray(this.createdAtRange) && this.createdAtRange.length === 2) {
|
||||||
params.createdAtStart = this.createdAtRange[0]
|
params.createdAtStart = this.createdAtRange[0]
|
||||||
@@ -513,6 +611,7 @@ export default {
|
|||||||
this.queryParams = {
|
this.queryParams = {
|
||||||
current: 1,
|
current: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
|
tenantId: '',
|
||||||
userId: '',
|
userId: '',
|
||||||
title: '',
|
title: '',
|
||||||
sellerId: '',
|
sellerId: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user