feat(appearance-patent): 顶部全量「导出」摘掉+每张主管卡加「删除」(2026-11-11 客户「这个可以不要 有下载就行了」「也要加个删除按钮」)
删除走新 DELETE /api/admin/appearance-patent-clean-items/supervisors?supervisor_user_id=…:谓词与卡片「下载」逐字同源(共享 cleanItemConds + supervisorScopeConds,Same SQL 下推),所见即所删;supervisor_user_id 必填、服务侧先挡空值(缺值会让 <if> 不生效=退化成整表删除),日期倒挂同全站口径拒;同一 requireCleanItemsAccess+readCompanyIdOrOwn 正门(非超管只能删本公司行),并打一条带 operatorId/主管/过滤面/删除行数的日志留痕;只删快照明细,不碰结果文件与任务记录。前端破坏性动作先 openAdminConfirm(点名主管与条数、danger),删完回读并在删掉本页最后一张卡时回退页;读不到主管的卡两钮都禁用。护栏:XML_STATEMENT_TOTAL 155→156、NOT_MIGRATED 登记 deleteSupervisorItems、controller 只读判据改为「无 POST/PUT+DELETE 必须在位」、wiring 新增第 4 个发送口(26 处/19 组)。
This commit is contained in:
@@ -5,14 +5,17 @@ import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||
* 我们这边就是按主管划分」)。
|
||||
*
|
||||
* 形态:一主管一卡(对齐「店铺数据记录」页的一店一卡),卡内是该主管名下的汇总——
|
||||
* 条数 / 任务(几个任务、最近任务号)/ 国家 / 最新同步时间 + [下载](导出该主管名下全量 xlsx)。
|
||||
* 条数 / 任务(几个任务、最近任务号)/ 国家 / 最新同步时间 + [下载](导出该主管名下全量 xlsx)
|
||||
* + [删除](删该主管名下明细,2026-11-11 客户「也要加个删除按钮」)。
|
||||
* 明细分页卡片(每明细一卡)已下架:3488 条明细会铺成几千张卡,客户明确不要。
|
||||
* 数据来自 GET /supervisors(后端按「主管本人取自己、普通账户取创建人」的归属表达式聚合,
|
||||
* total 是主管数),与明细导出走同一过滤面(分组/国家/同步起止 + 公司 tab)。
|
||||
* 页签零写操作:明细本身仍走 /export xlsx 看(客户「到时候能下载表格看就行」)。
|
||||
* 页签零出表:明细本身仍走 xlsx 看(客户「到时候能下载表格看就行」);
|
||||
* 顶部不再给「全量导出」——每张卡自带下载与删除,客户口径「这个可以不要 有下载就行了」。
|
||||
* 分组(主管)下拉选中即查(同日四改):客户选了主管就该只看到这一位/这一组的主管卡片。 */
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import {
|
||||
deleteAppearancePatentCleanSupervisor,
|
||||
exportAppearancePatentCleanList,
|
||||
fetchAppearancePatentCleanSupervisors,
|
||||
fetchDedupeTotalGroups,
|
||||
@@ -24,6 +27,7 @@ import { ASIN_COUNTRY_CODES, asinCountryLabel } from '../asin/asin-country.ts'
|
||||
import OldPagination from '@/components/OldPagination.vue'
|
||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||
import { openAdminConfirm } from '@/components/admin-confirm'
|
||||
import { loadFailureMessage } from '@/components/load-failure-model'
|
||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||
|
||||
@@ -36,10 +40,10 @@ const cards = ref<AppearancePatentSupervisorCard[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(10)
|
||||
/** 导出在途锁:避免连点导出把同一份过滤面重复请求两遍。 */
|
||||
const exporting = ref(false)
|
||||
/** 单卡下载在途标记(存 supervisorId,避免连点同一张卡)。 */
|
||||
const downloadingId = ref<number | null>(null)
|
||||
/** 单卡删除在途标记(存 supervisorId;删除是破坏性动作,确认后才置位)。 */
|
||||
const deletingId = ref<number | null>(null)
|
||||
/** 同步台账是累计数据,日期初值故意留空(默认当天会让首屏只剩今天同步的行);见 date-filter-default-today 护栏的 EXEMPT。 */
|
||||
const filter = reactive(createAppearancePatentCleanFilterState())
|
||||
/** 分组(主管)下拉选项:公司 tab 切换时重取;选项失败不拦列表,只回空下拉(可见「全部分组」)。 */
|
||||
@@ -87,30 +91,6 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/** 顶部导出:当前过滤面(含公司 tab 与分组)全量出 xlsx。 */
|
||||
async function exportAll(): Promise<void> {
|
||||
if (exporting.value) return
|
||||
exporting.value = true
|
||||
try {
|
||||
const result = await exportAppearancePatentCleanList({
|
||||
taskId: filter.taskId,
|
||||
asin: filter.asin,
|
||||
country: filter.country,
|
||||
groupId: filter.groupId,
|
||||
startDate: filter.startDate,
|
||||
endDate: filter.endDate,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
saveBlob(result.blob, result.filename)
|
||||
showAdminFeedback(`已导出 ${result.filename}`, 'success')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error && error.message ? error.message : '导出失败,请稍后重试'
|
||||
showAdminFeedback(message, 'error')
|
||||
} finally {
|
||||
exporting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 单卡下载:只导出该主管名下明细(与卡片同一归属口径,supervisor_user_id 收窄)。
|
||||
* 读不到主管的那组没有 id,不给按钮(不猜是哪位主管)。 */
|
||||
async function downloadSupervisor(card: AppearancePatentSupervisorCard): Promise<void> {
|
||||
@@ -137,6 +117,38 @@ async function downloadSupervisor(card: AppearancePatentSupervisorCard): Promise
|
||||
}
|
||||
}
|
||||
|
||||
/** 单卡删除:删该主管名下明细(谓词与「下载」同一过滤面+同一归属表达式)。
|
||||
* 破坏性动作:先弹确认(点名主管与条数、写明不可恢复),确认后真删,再按剩余卡片回退页码——
|
||||
* 删掉本页最后一张卡时不能停在空页上。读不到主管的那组没有 id,不给按钮。 */
|
||||
async function removeSupervisor(card: AppearancePatentSupervisorCard): Promise<void> {
|
||||
if (card.supervisorId == null || deletingId.value !== null) return
|
||||
const label = card.supervisorName || '该主管'
|
||||
const confirmed = await openAdminConfirm({
|
||||
message: `确认删除「${label}」名下的 ${card.itemCount} 条外观专利数据库记录?此操作不可恢复(任务记录与结果文件不受影响)。`,
|
||||
danger: true,
|
||||
})
|
||||
if (!confirmed) return
|
||||
deletingId.value = card.supervisorId
|
||||
try {
|
||||
const deleted = await deleteAppearancePatentCleanSupervisor({
|
||||
supervisorUserId: card.supervisorId,
|
||||
country: filter.country,
|
||||
groupId: filter.groupId,
|
||||
startDate: filter.startDate,
|
||||
endDate: filter.endDate,
|
||||
companyId: companyTab.requestCompanyId,
|
||||
})
|
||||
showAdminFeedback(`已删除「${label}」的 ${deleted} 条记录`, 'success')
|
||||
if (cards.value.length === 1 && page.value > 1) page.value -= 1
|
||||
await load()
|
||||
} catch (error) {
|
||||
const message = error instanceof Error && error.message ? error.message : `删除「${label}」的记录失败`
|
||||
showAdminFeedback(message, 'error')
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function saveBlob(blob: Blob, filename: string): void {
|
||||
const url = URL.createObjectURL(blob)
|
||||
const anchor = document.createElement('a')
|
||||
@@ -220,11 +232,6 @@ onMounted(() => {
|
||||
<section class="panel-box">
|
||||
<LoadFailureBar v-if="loadFailure" :message="loadFailure" @retry="load" />
|
||||
<div class="clean-toolbar">
|
||||
<div class="clean-toolbar-main">
|
||||
<button class="btn" type="button" :disabled="exporting" @click="exportAll">
|
||||
{{ exporting ? '导出中...' : '导出' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="clean-toolbar-side">
|
||||
<span class="clean-summary">共 {{ total }} 位主管 · 本页 {{ cards.length }} 位</span>
|
||||
</div>
|
||||
@@ -261,12 +268,21 @@ onMounted(() => {
|
||||
<button
|
||||
class="btn btn-sm"
|
||||
type="button"
|
||||
:disabled="card.supervisorId == null || downloadingId !== null"
|
||||
:title="card.supervisorId == null ? '读不到主管账号,无法按主管导出(可用顶部导出)' : undefined"
|
||||
:disabled="card.supervisorId == null || downloadingId !== null || deletingId !== null"
|
||||
:title="card.supervisorId == null ? '读不到主管账号,无法按主管导出' : undefined"
|
||||
@click="downloadSupervisor(card)"
|
||||
>
|
||||
{{ downloadingId === card.supervisorId && card.supervisorId != null ? '下载中...' : '下载' }}
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-sm btn-danger"
|
||||
type="button"
|
||||
:disabled="card.supervisorId == null || deletingId !== null || downloadingId !== null"
|
||||
:title="card.supervisorId == null ? '读不到主管账号,无法按主管删除' : undefined"
|
||||
@click="removeSupervisor(card)"
|
||||
>
|
||||
{{ deletingId === card.supervisorId && card.supervisorId != null ? '删除中...' : '删除' }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
@@ -405,18 +421,14 @@ h3 {
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.clean-toolbar-main {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
/* 工具条只剩右侧汇总(顶部「导出」已按客户口径摘掉),用 margin-left:auto 顶到右边保持原位。 */
|
||||
.clean-toolbar-side {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
margin-left: auto;
|
||||
}
|
||||
.clean-summary {
|
||||
color: #5b6f83;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 只读页+导出(2026-11-11 客户需求「数据得导出来」):公司 tab 的值由本发送口从原始入参自己下传
|
||||
* (白名单构造不认识 company_id),取值口形状由 company-tab-wiring 护栏钉住。 */
|
||||
import { http } from '@/api/http'
|
||||
import { errorTextOf } from '../../api/envelope.ts'
|
||||
import { errorTextOf, unwrap } from '../../api/envelope.ts'
|
||||
import {
|
||||
toAppearancePatentCleanExportParams,
|
||||
toAppearancePatentCleanListParams,
|
||||
@@ -131,6 +131,37 @@ export async function exportAppearancePatentCleanList(
|
||||
return { blob: response.data, filename: exportFilenameOf(disposition) }
|
||||
}
|
||||
|
||||
export interface AppearancePatentSupervisorDeleteParams {
|
||||
supervisorUserId: number
|
||||
country?: string
|
||||
groupId?: string
|
||||
startDate?: string
|
||||
endDate?: string
|
||||
companyId?: number | null
|
||||
}
|
||||
|
||||
/** 删除某位主管名下明细(卡片上的「删除」,2026-11-11 客户「也要加个删除按钮」):
|
||||
* 谓词与卡片「下载」逐字同源(同一过滤面 + 同一主管归属表达式),返回实际删除行数。
|
||||
* supervisorUserId 必填——后端缺值按业务错误拒绝(不按主管收窄的删除等于删整个过滤面)。 */
|
||||
export async function deleteAppearancePatentCleanSupervisor(
|
||||
params: AppearancePatentSupervisorDeleteParams,
|
||||
): Promise<number> {
|
||||
const query = toAppearancePatentCleanExportParams({
|
||||
taskId: '',
|
||||
asin: '',
|
||||
country: params.country ?? '',
|
||||
groupId: params.groupId ?? '',
|
||||
startDate: params.startDate ?? '',
|
||||
endDate: params.endDate ?? '',
|
||||
})
|
||||
if (params.companyId != null) query.company_id = params.companyId
|
||||
const { data } = await http.delete<unknown>(APPEARANCE_PATENT_SUPERVISOR_ENDPOINT, {
|
||||
params: { ...query, supervisor_user_id: params.supervisorUserId },
|
||||
})
|
||||
const deleted = unwrap<number>(data)
|
||||
return typeof deleted === 'number' ? deleted : Number(deleted) || 0
|
||||
}
|
||||
|
||||
/** 分组(主管)下拉选项:复用既有 GET /shop-manages/groups(与去重页/店铺管理共用同一分组集,
|
||||
* 不下新端点)。2026-11-11 客户口径「主管就是组长,可以筛选组长来导出,就是分组」——
|
||||
* 选项是分组管理里那一行(DedupeGroupOption {id, name, leaderUserId}),选中后以 group_id
|
||||
|
||||
Reference in New Issue
Block a user