mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 06:29:20 +08:00
feat: 发布商品选中类目后校验店铺发布权并提示
This commit is contained in:
@@ -41,6 +41,16 @@ export async function listPddPublishCatsApi(
|
||||
);
|
||||
}
|
||||
|
||||
/** 校验类目路径是否有发布权 */
|
||||
export async function checkPddPublishCatAuthApi(
|
||||
data: PddGoodsPublishDTO.CatAuthQuery,
|
||||
) {
|
||||
return requestClient.post<PddGoodsPublishVO.CatAuth>(
|
||||
'/channel/pdd/goods/publish/meta/check-cat-auth',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/** 运费模板列表 */
|
||||
export async function listPddPublishLogisticsApi(
|
||||
data: PddGoodsPublishDTO.LogisticsQuery,
|
||||
|
||||
@@ -63,6 +63,12 @@ export namespace PddGoodsPublishDTO {
|
||||
parentCatId?: number;
|
||||
}
|
||||
|
||||
export interface CatAuthQuery {
|
||||
pddShopId: number;
|
||||
/** 根 → 叶 */
|
||||
catPath: number[];
|
||||
}
|
||||
|
||||
export interface LogisticsQuery {
|
||||
pddShopId: number;
|
||||
page?: number;
|
||||
@@ -104,6 +110,12 @@ export namespace PddGoodsPublishVO {
|
||||
leaf?: boolean;
|
||||
}
|
||||
|
||||
export interface CatAuth {
|
||||
authorized: boolean;
|
||||
failedCatId?: number;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export interface LogisticsPage {
|
||||
totalCount?: number;
|
||||
templates?: LogisticsTemplate[];
|
||||
|
||||
+93
-2
@@ -35,6 +35,7 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
checkPddPublishCatAuthApi,
|
||||
createPddPublishSpecIdApi,
|
||||
getPddPublishCatTemplateApi,
|
||||
getPddPublishLogisticsTemplateDetailApi,
|
||||
@@ -388,6 +389,11 @@ const catDegradeHint = computed(() => {
|
||||
return '本地类目未就绪:已降级为拼多多授权类目逐级加载;搜索仅匹配已展开节点。同步成功后可跨层搜索';
|
||||
});
|
||||
|
||||
/** 当前选中叶子是否有发布权;null=未校验/不适用 */
|
||||
const catAuthAuthorized = ref<boolean | null>(null);
|
||||
const catAuthMessage = ref('');
|
||||
const catAuthChecking = ref(false);
|
||||
|
||||
const skuSelectOptions = computed(() =>
|
||||
skuOptions.value.map((s) => ({
|
||||
label: `${s.productName} / ${s.name}${s.skuCode ? ` (${s.skuCode})` : ''}`,
|
||||
@@ -411,7 +417,7 @@ function mapLocalCatNode(c: {
|
||||
leaf?: boolean;
|
||||
}): CatCascaderNode {
|
||||
return {
|
||||
label: c.catName,
|
||||
label: c.catName || `类目${c.catId}`,
|
||||
value: c.catId,
|
||||
isLeaf: !!c.leaf,
|
||||
};
|
||||
@@ -440,6 +446,38 @@ async function fetchCatChildren(parentCatId: number): Promise<CatCascaderNode[]>
|
||||
return list.map(mapPopCatNode);
|
||||
}
|
||||
|
||||
/** 选中叶子后再校验发布权(不在选择器展开时实时标权) */
|
||||
async function refreshCatAuth(fullPath: number[]) {
|
||||
catAuthAuthorized.value = null;
|
||||
catAuthMessage.value = '';
|
||||
if (!form.pddShopId || !fullPath.length) {
|
||||
return;
|
||||
}
|
||||
// 降级已是授权树,展开选中默认有权
|
||||
if (!localCatReady.value) {
|
||||
catAuthAuthorized.value = true;
|
||||
return;
|
||||
}
|
||||
catAuthChecking.value = true;
|
||||
try {
|
||||
const res = await checkPddPublishCatAuthApi({
|
||||
pddShopId: form.pddShopId,
|
||||
catPath: fullPath,
|
||||
});
|
||||
catAuthAuthorized.value = !!res?.authorized;
|
||||
catAuthMessage.value =
|
||||
res?.message ||
|
||||
(res?.authorized
|
||||
? '当前店铺有权发布该类目'
|
||||
: '当前店铺无权发布该类目');
|
||||
} catch (e: any) {
|
||||
catAuthAuthorized.value = null;
|
||||
catAuthMessage.value = e?.message || '类目权限校验失败';
|
||||
} finally {
|
||||
catAuthChecking.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 展开时按需加载子类目(本地库或拼多多接口) */
|
||||
const catLoadData: CascaderProps['loadData'] = async (selectedOptions) => {
|
||||
// 跨层搜索结果为扁平叶子,不走懒加载
|
||||
@@ -577,7 +615,11 @@ async function applyCatSelection(catId: number, pathIds?: string, pathLabel?: st
|
||||
specAxes.value = [];
|
||||
specCatalog.value = [];
|
||||
specValueDraftByRow.value = {};
|
||||
await refreshCatAuth(path);
|
||||
if (!form.pddShopId || !form.catId) return;
|
||||
if (catAuthAuthorized.value === false) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const [tpl, specs] = await Promise.all([
|
||||
getPddPublishCatTemplateApi({
|
||||
@@ -678,6 +720,8 @@ watch(
|
||||
form.catPath = [];
|
||||
form.catId = undefined;
|
||||
selectedCatPathLabel.value = '';
|
||||
catAuthAuthorized.value = null;
|
||||
catAuthMessage.value = '';
|
||||
form.costTemplateId = undefined;
|
||||
costTemplateDetail.value = null;
|
||||
catTemplate.value = null;
|
||||
@@ -1059,6 +1103,8 @@ async function onCatChange(path: number[]) {
|
||||
form.catId = undefined;
|
||||
selectedCatPathLabel.value = '';
|
||||
pinnedSelectedCat.value = null;
|
||||
catAuthAuthorized.value = null;
|
||||
catAuthMessage.value = '';
|
||||
catTemplate.value = null;
|
||||
parentSpecs.value = [];
|
||||
form.goodsPropValues = {};
|
||||
@@ -1079,6 +1125,8 @@ async function onCatChange(path: number[]) {
|
||||
form.catId = undefined;
|
||||
selectedCatPathLabel.value = '';
|
||||
pinnedSelectedCat.value = null;
|
||||
catAuthAuthorized.value = null;
|
||||
catAuthMessage.value = '';
|
||||
catTemplate.value = null;
|
||||
parentSpecs.value = [];
|
||||
clearSkuRows();
|
||||
@@ -1311,6 +1359,14 @@ function validateForm(): boolean {
|
||||
message.warning('请选择叶子类目');
|
||||
return false;
|
||||
}
|
||||
if (catAuthAuthorized.value === false) {
|
||||
message.warning(catAuthMessage.value || '当前店铺无权发布该类目');
|
||||
return false;
|
||||
}
|
||||
if (catAuthChecking.value) {
|
||||
message.warning('正在校验类目发布权限,请稍候');
|
||||
return false;
|
||||
}
|
||||
if (!form.costTemplateId) {
|
||||
message.warning('请选择运费模板');
|
||||
return false;
|
||||
@@ -1553,6 +1609,8 @@ function resetAll() {
|
||||
form.catPath = [];
|
||||
form.catId = undefined;
|
||||
selectedCatPathLabel.value = '';
|
||||
catAuthAuthorized.value = null;
|
||||
catAuthMessage.value = '';
|
||||
form.costTemplateId = undefined;
|
||||
costTemplateDetail.value = null;
|
||||
form.marketPriceYuan = undefined;
|
||||
@@ -1681,6 +1739,34 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
已选:{{ selectedCatPathLabel }}
|
||||
</p>
|
||||
<Alert
|
||||
v-if="catAuthChecking"
|
||||
class="mt-2"
|
||||
type="info"
|
||||
show-icon
|
||||
message="正在校验该类目是否有发布权…"
|
||||
/>
|
||||
<Alert
|
||||
v-else-if="form.catId && catAuthAuthorized === true"
|
||||
class="mt-2"
|
||||
type="success"
|
||||
show-icon
|
||||
message="当前店铺有权发布该类目"
|
||||
/>
|
||||
<Alert
|
||||
v-else-if="form.catId && catAuthAuthorized === false"
|
||||
class="mt-2"
|
||||
type="error"
|
||||
show-icon
|
||||
:message="catAuthMessage || '当前店铺无权发布该类目'"
|
||||
/>
|
||||
<Alert
|
||||
v-else-if="form.catId && catAuthMessage && catAuthAuthorized === null"
|
||||
class="mt-2"
|
||||
type="warning"
|
||||
show-icon
|
||||
:message="catAuthMessage"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="运费模板" required>
|
||||
<Select
|
||||
@@ -2114,7 +2200,12 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<Space>
|
||||
<Button @click="handleClose">取消</Button>
|
||||
<Button type="primary" :loading="submitting" @click="handleSubmit">
|
||||
<Button
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
:disabled="catAuthAuthorized === false || catAuthChecking"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
发布到拼多多
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
Reference in New Issue
Block a user