feat 完善注释
This commit is contained in:
@@ -12,55 +12,29 @@ import { request, serializeQuery } from '@/utils/request'
|
||||
import { formatDate } from '@/utils/format'
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// 列表:真实接口
|
||||
// GET /web/requirementPool/list → ProjectRequirementUserController#list
|
||||
// → ProjectRequirementServiceImpl#queryUserPageList
|
||||
// 入参 RdProjectBo + PageQuery;出参 ProjectRequirementAndCountVo
|
||||
// { requirementPage: { total, rows: RdProjectVo[] }, requirementStatistics: null }
|
||||
// 鉴权:需登录态(匿名 401);每请求带 clientid 头(见 utils/request.ts 拦截器)。
|
||||
// 筛选参数实测(tools/probe_project_api.py):
|
||||
// key → like projectName OR projectNo OR requirementDesc
|
||||
// businessTypes → IN business_type(**多选**;值是提报表主键 id,不是类型名)
|
||||
// status → eq status(码值,见 RdProjectStatus)
|
||||
// beginTime/endTime → between create_time(不是 submit_time!)
|
||||
// pageNum/pageSize → PageQuery
|
||||
// ⚠️ 主表已改为**需求表** vm_project_requirement(LEFT JOIN 项目表),未立项的需求也会出现;
|
||||
// 未立项行 progress 为 null(显示「—」)、status 回落需求表中的 INITIATING。
|
||||
// ⚠️ 列表行的 businessType 是 SQL 里 JOIN 提报表**翻译后的中文名称**(如「互联网软件」),
|
||||
// 与筛选参数 businessType(提报表 id)**不是同一口径**,渲染时不能用 typeCounts 反查。
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// 业务类型筛选条件:真实接口
|
||||
// GET /web/requirementPool/getFilterConditions
|
||||
// → ProjectRequirementUserController#getFilterConditions
|
||||
// → ProjectRequirementServiceImpl#getFilterConditions
|
||||
// 出参 ProjectRequirementStatisticsVo:
|
||||
// { total: 该用户需求总数,
|
||||
// businessTypeCounts: [{ businessTypeId, businessTypeLabel, count }] }
|
||||
// 口径:**全量、不分页**,所以件数不会随 pageNum/pageSize 变化,适合当筛选栏的固定值域;
|
||||
// businessTypeId = vm_project_submission 主键 id(直接回传当 businessType 筛选参数);
|
||||
// businessTypeLabel = 该表的 business_type 名称;提报表里没命中的脏数据不计入。
|
||||
// ⚠️ /list 响应里的 requirementStatistics 后端仍是注释状态(实测恒 null),统计一律走本端点。
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/** 两位补零 */
|
||||
function pad(value: number): string {
|
||||
return String(value).padStart(2, '0')
|
||||
}
|
||||
|
||||
/** Date → 'yyyy-MM-dd HH:mm:ss'(后端 RdProjectBo.beginTime/endTime 是 Date,实测该格式可绑定) */
|
||||
function toDateTime(date: Date, endOfDay: boolean): string {
|
||||
const ymd = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
|
||||
return `${ymd} ${endOfDay ? '23:59:59' : '00:00:00'}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交时间条件 → 后端 `beginTime` / `endTime`(都落在 `create_time` 上)。
|
||||
*
|
||||
* <p>自选区间优先(UI 上两组互斥,这里再兜一层);结束日一律补到 23:59:59,
|
||||
* 否则 `endTime=2026-09-30` 会被绑成当天 00:00:00 而漏掉当天数据。</p>
|
||||
*/
|
||||
function toTimeRange(query: ProjectQuery): { beginTime?: string; endTime?: string } {
|
||||
if (query.startDate || query.endDate) {
|
||||
return {
|
||||
@@ -77,21 +51,15 @@ function toTimeRange(query: ProjectQuery): { beginTime?: string; endTime?: strin
|
||||
return { beginTime: toDateTime(start, false), endTime: toDateTime(new Date(), true) }
|
||||
}
|
||||
|
||||
/** 项目列表(真实接口:服务端筛选 + 分页;业务类型统计走 getProjectFilterConditions) */
|
||||
export function getProjectList(query: ProjectQuery): Promise<ProjectListResult> {
|
||||
return request<ProjectListResult>({
|
||||
url: '/web/requirementPool/list',
|
||||
method: 'get',
|
||||
// 多选数组必须走 serializeQuery,展开成 businessTypes[0]=…&businessTypes[1]=…
|
||||
//(与 api/cases.ts 同一做法;不传则走 axios 默认的 businessTypes[]=,实测后端也能绑,
|
||||
// 但这里取与文档/案例库一致的索引形式,避免依赖框架默认行为)
|
||||
paramsSerializer: { serialize: serializeQuery },
|
||||
params: {
|
||||
pageNum: query.pageNum,
|
||||
pageSize: query.pageSize,
|
||||
// 空串不出现在 querystring 里,与后端 eqIfText 的「有值才等值匹配」语义一致
|
||||
key: query.keyword || undefined,
|
||||
// 多选:空数组不发;非空由 serializeQuery 展开成 businessTypes[0]=…&businessTypes[1]=…
|
||||
businessTypes: query.businessTypes.length > 0 ? [...query.businessTypes] : undefined,
|
||||
status: query.status || undefined,
|
||||
...toTimeRange(query),
|
||||
@@ -99,12 +67,6 @@ export function getProjectList(query: ProjectQuery): Promise<ProjectListResult>
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务类型筛选条件(左侧筛选栏「业务类型」的值域 + 件数)。
|
||||
*
|
||||
* <p>与列表分开取:`/list` 的 `requirementStatistics` 后端恒为 null,统计由本端点单独下发,
|
||||
* 且是**全量口径**(不随筛选、分页变化),所以进页面拉一次即可。</p>
|
||||
*/
|
||||
export function getProjectFilterConditions(): Promise<ProjectStatistics> {
|
||||
return request<ProjectStatistics>({
|
||||
url: '/web/requirementPool/getFilterConditions',
|
||||
@@ -112,17 +74,6 @@ export function getProjectFilterConditions(): Promise<ProjectStatistics> {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 已完成项目(申请售后页「项目名称」下拉的候选)。
|
||||
*
|
||||
* <p>直接复用列表接口做状态过滤:`status=COMPLETED` 在后端比的是
|
||||
* `COALESCE(vm_rd_project.status, vm_project_requirement.status)`,而 `COMPLETED` 只会
|
||||
* 出现在**项目表**(未立项的需求是 `INITIATING`)⇒ 结果天然就是「自己名下已立项且已完成的项目」,
|
||||
* 与后端申请售后的准入校验(只有 COMPLETED 可申请)口径一致。</p>
|
||||
*
|
||||
* <p>售后申请场景下候选量级不大,一次取回较大分页(后端无专用端点);后端默认排序
|
||||
* `update_time DESC`。返回行的 `id` = **需求 id**,正是申请接口要传的那个 id。</p>
|
||||
*/
|
||||
export function getCompletedProjects(): Promise<RdProjectVo[]> {
|
||||
return request<ProjectListResult>({
|
||||
url: '/web/requirementPool/list',
|
||||
@@ -136,7 +87,6 @@ export function getCompletedProjects(): Promise<RdProjectVo[]> {
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// 详情:真实接口(**4 个页签各一个端点**,同帧并行取回后合并)
|
||||
// GET /web/requirementPool/get/progress/{id} → ProjectRequirementProgressVo
|
||||
// GET /web/requirementPool/get/files/{id} → ProjectRequirementFilesVo
|
||||
// GET /web/requirementPool/get/finance/{id} → ProjectRequirementFinanceVo
|
||||
@@ -144,26 +94,10 @@ export function getCompletedProjects(): Promise<RdProjectVo[]> {
|
||||
// → ProjectRequirementUserController#getProgress / #getFiles / #getFinance / #getAfterSales
|
||||
// → ProjectRequirementServiceImpl#queryProgress / queryFiles / queryFinance / queryAfterSales
|
||||
//
|
||||
// 4 个 VO 都继承 ProjectRequirementBaseVo(基础信息始终带)⇒ 任一响应里都有项目名 /
|
||||
// 编号 / 业务类型 / 状态 / 提交时间,所以详情页顶部信息卡只依赖其中一支即可,切页签不缺数据。
|
||||
// 首屏用 getProjectDetailBundle **同帧并行**发 4 个请求(一次到位,避免首屏缺数据);
|
||||
// **之后每次点击页签**再用 getProjectDetailTab 只拉对应那一支(点一次 = 一次请求),
|
||||
// 响应回填到 store 里的 bundle 后重新映射 ⇒ 页面始终是**最新数据**,不重拉另外三支。
|
||||
// 出参由 stores/modules/project.ts 缓存成 bundle,经 utils/projectVo.ts#toProjectDetail
|
||||
// 映射成详情页沿用的 Project 形态。
|
||||
// ⚠️ id 传的是**需求 id**(vm_project_requirement.id)= 列表行 RdProjectVo.id;
|
||||
// 未立项的需求也能查到(项目侧字段为空);不存在 / 非本人 → 后端 4 支 data 均为 null。
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 详情页签(= `RequirementDetailBundle` 的键名,也就是 4 个端点的后缀)。
|
||||
*
|
||||
* <p>`views/project/detail.vue` 里的 `DetailTab` 是同一组值;那边不 import 本模块
|
||||
* (页面层不直接依赖 api),靠字面量对齐。</p>
|
||||
*/
|
||||
export type ProjectDetailTab = 'progress' | 'files' | 'finance' | 'afterSales'
|
||||
|
||||
/** 页签 → 端点(4 支都继承 ProjectRequirementBaseVo,基础信息任一支都有) */
|
||||
const DETAIL_TAB_URL: Record<ProjectDetailTab, string> = {
|
||||
progress: '/web/requirementPool/get/progress',
|
||||
files: '/web/requirementPool/get/files',
|
||||
@@ -171,14 +105,6 @@ const DETAIL_TAB_URL: Record<ProjectDetailTab, string> = {
|
||||
afterSales: '/web/requirementPool/get/afterSales',
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个页签取数(**点一次页签 = 一次请求**,拿该页签的最新数据)。
|
||||
*
|
||||
* <p>返回类型按页签收窄:`getProjectDetailTab(id, 'finance')` → `RequirementFinanceVo | null`,
|
||||
* 所以调用方可以直接把结果写回 bundle 的对应键。</p>
|
||||
*
|
||||
* <p>`null` = 需求不存在 / 不属于当前用户(后端 `data: null`),调用方应保留现有数据并提示。</p>
|
||||
*/
|
||||
export function getProjectDetailTab<T extends ProjectDetailTab>(
|
||||
id: string,
|
||||
tab: T,
|
||||
@@ -189,12 +115,6 @@ export function getProjectDetailTab<T extends ProjectDetailTab>(
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情四支并行取回(**首屏用**);任一为 null ⇒ 整个 bundle 为 null。
|
||||
*
|
||||
* <p>4 支同源(都查同一行需求),正常不会只缺一支;缺一支即视为「需求不存在 / 非本人」,
|
||||
* 详情页走整页空态。</p>
|
||||
*/
|
||||
export function getProjectDetailBundle(id: string): Promise<RequirementDetailBundle | null> {
|
||||
return Promise.all([
|
||||
getProjectDetailTab(id, 'progress'),
|
||||
@@ -208,31 +128,12 @@ export function getProjectDetailBundle(id: string): Promise<RequirementDetailBun
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// 售后(**真实接口**)
|
||||
// 申请 POST /web/requirementPool/afterSales/request body ProjectRequirementActionBo
|
||||
// 撤回 POST /web/requirementPool/afterSales/withdraw body ProjectRequirementActionBo
|
||||
// → ProjectRequirementUserController#requestAfterSale / #withdrawAfterSale
|
||||
// → ProjectRequirementServiceImpl#requestAfterSale / #withdrawAfterSale
|
||||
// 附件上传 POST /web/workOrderDraft/upload(multipart,字段名 `file`)—— 只传 OSS 不落业务表;
|
||||
// 提交时下发 `attachmentOssIds`,后端转存进 `vm_project_requirement_attachment`
|
||||
// (phase = AFTER_SALE、target_id = 售后工单 id),OSS 文件不重复上传。
|
||||
//
|
||||
// ⚠️ 后端业务校验(失败抛 ServiceException,由统一 request 层弹提示):
|
||||
// · 只有「已完成(COMPLETED)」的项目能申请售后;
|
||||
// · 已有 REQUESTED / IN_PROGRESS 的售后时拒绝重复申请;
|
||||
// · 撤回只允许 REQUESTED 状态,撤回后售后置 WITHDRAWN、项目回到已完成。
|
||||
// ⚠️ 撤回接口收的是**需求 id**(不是售后工单 id),与后端 `checkOwner` 的校验口径一致。
|
||||
//
|
||||
// ⚠️ 详情页「项目文件」页签的上传 / 删除**仍无用户端接口**(上传入口在需求提报页),
|
||||
// 所以这里不再保留 mock —— 详情数据来自真实接口,塞本地假数据会让刷新前后不一致。
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 上传售后附件(复用需求提报的 OSS 上传口)。
|
||||
*
|
||||
* <p>只传 OSS、不落业务表;返回项带 `ossId`,提交时由后端转存成售后附件。
|
||||
* 后端响应没有文件大小,大小取本地 `File.size`。</p>
|
||||
*/
|
||||
export function uploadAfterSalesFile(file: File): Promise<AfterSalesAttachment> {
|
||||
const data = new FormData()
|
||||
data.append('file', file)
|
||||
@@ -250,12 +151,6 @@ export function uploadAfterSalesFile(file: File): Promise<AfterSalesAttachment>
|
||||
}))
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请售后(用户端)。
|
||||
*
|
||||
* <p>`id` 是**需求 id**(= 详情页路由参数);`payload` 的 `reason` / `note` 分别对应
|
||||
* 页面的「问题描述」与「补充备注」。</p>
|
||||
*/
|
||||
export function submitAfterSales(
|
||||
id: string,
|
||||
payload: AfterSalesPayload,
|
||||
@@ -268,17 +163,11 @@ export function submitAfterSales(
|
||||
type: payload.type,
|
||||
reason: payload.reason,
|
||||
note: payload.note,
|
||||
// 空数组是安全的(后端 `appendAttachments` 对空集合直接 return,不 NPE)
|
||||
attachmentOssIds: payload.attachmentOssIds,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回售后申请(用户端)。
|
||||
*
|
||||
* <p>`id` 传**需求 id**;`reason` 是撤回原因(选填,后端会存进 `withdraw_reason`)。</p>
|
||||
*/
|
||||
export function cancelAfterSales(id: string, reason = ''): Promise<void> {
|
||||
return request<void>({
|
||||
url: '/web/requirementPool/afterSales/withdraw',
|
||||
|
||||
Reference in New Issue
Block a user