fix(tenant): 收紧双站后台边界并补齐货架管理

This commit is contained in:
yml
2026-11-15 22:28:40 +08:00
parent a68eb815a9
commit 0cb385d84f
42 changed files with 831 additions and 97 deletions
@@ -476,6 +476,34 @@
gap: 8px;
}
.tenant-offer-form {
display: grid;
gap: 14px;
}
.tenant-offer-form label {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
color: #475569;
font-size: 13px;
}
.tenant-offer-form .el-input-number {
width: 160px;
}
.tenant-offer-form small {
color: #94a3b8;
font-size: 11px;
line-height: 1.5;
}
.tenant-offer-form .el-button {
justify-self: start;
}
@media (max-width: 760px) {
.listing-detail-header,
.listing-workspace {
@@ -22,13 +22,17 @@ import {
adminOfflineListing,
adminTransferListingOwner,
emptyListingSalePriceConfig,
fetchAdminTenantListingOffer,
fetchAdminListing,
fetchListingSalePriceConfig,
updateAdminTenantListingOffer,
type AdminExternalListingAdjustMode,
type PublishSalePriceConfig,
type Listing,
type TenantListingOffer,
} from '@/features/listings'
import { useAdminSessionStore } from '@/stores/adminSession'
import { useDistributionSiteStore } from '@/stores/distributionSite'
import {
listingReviewStatusLabel,
listingStatusLabel,
@@ -57,6 +61,7 @@ import {
import { calculatePlatformPricing, roundRatio as roundPricingRatio } from '@/shared/utils/pricing'
const adminSession = useAdminSessionStore()
const siteStore = useDistributionSiteStore()
const route = useRoute()
const router = useRouter()
@@ -83,6 +88,10 @@ const userOptions = ref<AdminUserItem[]>([])
const selectedUser = ref<AdminUserItem | null>(null)
const externalAdjustVisible = ref(false)
const externalAdjustSaving = ref(false)
const tenantOffer = ref<TenantListingOffer | null>(null)
const tenantOfferSaving = ref(false)
const tenantOfferStatus = ref<'enabled' | 'disabled'>('enabled')
const tenantOfferPriceYuan = ref<number | undefined>(undefined)
const salePriceConfig = ref<PublishSalePriceConfig>(emptyListingSalePriceConfig)
const externalAdjustModes: Array<{ label: string; value: AdminExternalListingAdjustMode }> = [
{ label: '按降价金额', value: 'discount_amount' },
@@ -113,6 +122,9 @@ const canTransfer = computed(() => !!listing.value && listing.value.status !== '
const canAdjustExternal = computed(
() => !!listing.value?.is_external_upload && adminSession.hasPermission('listing:edit_external')
)
const canManageTenantOffer = computed(
() => siteStore.isTenant && adminSession.hasPermission('listing:approve')
)
const externalAdjustmentLocked = computed(
() =>
!listing.value ||
@@ -292,11 +304,51 @@ async function loadListing() {
loading.value = true
try {
listing.value = await fetchAdminListing(String(route.params.id))
if (siteStore.isTenant) {
try {
tenantOffer.value = await fetchAdminTenantListingOffer(Number(route.params.id))
tenantOfferStatus.value =
tenantOffer.value.display_status === 'disabled' ? 'disabled' : 'enabled'
tenantOfferPriceYuan.value =
tenantOffer.value.price_cent && tenantOffer.value.price_cent > 0
? centToYuan(tenantOffer.value.price_cent)
: undefined
} catch {
tenantOffer.value = null
}
}
} finally {
loading.value = false
}
}
async function saveTenantOffer() {
if (!listing.value || !canManageTenantOffer.value) return
if (tenantOfferPriceYuan.value !== undefined && tenantOfferPriceYuan.value < 0) {
ElMessage.warning('本站售价不能小于 0')
return
}
tenantOfferSaving.value = true
try {
tenantOffer.value = await updateAdminTenantListingOffer(listing.value.id, {
display_status: tenantOfferStatus.value,
price_cent:
tenantOfferPriceYuan.value === undefined ? null : yuanToCent(tenantOfferPriceYuan.value),
})
tenantOfferStatus.value =
tenantOffer.value.display_status === 'disabled' ? 'disabled' : 'enabled'
tenantOfferPriceYuan.value =
tenantOffer.value.price_cent && tenantOffer.value.price_cent > 0
? centToYuan(tenantOffer.value.price_cent)
: undefined
ElMessage.success('本站货架已更新')
} catch (error) {
ElMessage.error(readError(error, '本站货架更新失败'))
} finally {
tenantOfferSaving.value = false
}
}
async function openExternalAdjustment() {
if (!listing.value || !canAdjustExternal.value || externalAdjustmentLocked.value) return
const row = listing.value
@@ -856,6 +908,51 @@ async function openScreenshot(url: string) {
</dl>
</section>
<section v-if="siteStore.isTenant" class="detail-panel side-panel tenant-offer-panel">
<div class="panel-heading">
<h2>本站货架</h2>
<el-tag
size="small"
:type="tenantOfferStatus === 'enabled' ? 'success' : 'info'"
effect="plain"
>
{{ tenantOfferStatus === 'enabled' ? '展示中' : '已隐藏' }}
</el-tag>
</div>
<div class="tenant-offer-form">
<label>
<span>展示状态</span>
<el-switch
v-model="tenantOfferStatus"
active-value="enabled"
inactive-value="disabled"
:disabled="!canManageTenantOffer"
/>
</label>
<label>
<span>本站售价</span>
<el-input-number
v-model="tenantOfferPriceYuan"
:min="0"
:precision="2"
:step="1"
:disabled="!canManageTenantOffer"
controls-position="right"
placeholder="使用货源价"
/>
</label>
<small>不填写时按货源价格 {{ formatCentWithSymbol(listing.price_cent) }} 展示</small>
<el-button
v-if="canManageTenantOffer"
type="primary"
:loading="tenantOfferSaving"
@click="saveTenantOffer"
>
保存本站货架
</el-button>
</div>
</section>
<section class="detail-panel primary-panel">
<div class="panel-heading">
<h2>库存资产</h2>
@@ -1089,14 +1089,14 @@ function formatRatioNumber(value: number) {
<el-button type="warning" :disabled="!canOperate" @click="openAction('abnormal')"
>标记异常</el-button
>
<el-tooltip :content="closeActionTip" placement="top">
<el-tooltip v-if="hasBuyerRole" :content="closeActionTip" placement="top">
<span>
<el-button type="danger" :disabled="!canOperate" @click="confirmCloseAction"
>客服关闭</el-button
>
</span>
</el-tooltip>
<el-tooltip :content="sealActionTip" placement="top">
<el-tooltip v-if="hasBuyerRole" :content="sealActionTip" placement="top">
<span>
<el-button type="danger" plain :disabled="!canOperate" @click="confirmSealAction"
>封存订单</el-button
@@ -24,10 +24,12 @@ import { useAdminPaginatedTable } from '@/features/admin/composables/useAdminPag
import { realnameStatusLabel, userStatusLabel } from '@/shared/utils/statusLabels'
import { formatDateTime } from '@/shared/utils/time'
import { useAdminSessionStore } from '@/stores/adminSession'
import { useDistributionSiteStore } from '@/stores/distributionSite'
import AdminTablePagination from '../components/AdminTablePagination.vue'
import AdminUserDetailDrawer from '../components/AdminUserDetailDrawer.vue'
const adminSession = useAdminSessionStore()
const siteStore = useDistributionSiteStore()
const canAdjustWallet = computed(() => adminSession.hasPermission('user:wallet_adjust'))
const canAdjustGrowthPoints = computed(() => adminSession.hasPermission('user:growth_points'))
const canAdjustGrowthLevel = computed(() => adminSession.hasPermission('user:growth_level'))
@@ -469,7 +471,7 @@ function moneyCent(value: number | string | undefined) {
@clear="queryUsers"
/>
</el-form-item>
<el-form-item label="所属站点">
<el-form-item v-if="!siteStore.isTenant" label="所属站点">
<el-select
v-model="filters.tenant_id"
clearable