恢复修改的数据
This commit is contained in:
@@ -1,13 +1,124 @@
|
||||
import type { FileInfo, PageResult } from '@/types/api'
|
||||
import type { FileInfo } from '@/types/api'
|
||||
import type {
|
||||
AfterSales,
|
||||
AfterSalesPayload,
|
||||
Project,
|
||||
ProjectListResult,
|
||||
ProjectQuery,
|
||||
ProjectStatistics,
|
||||
RequirementDetailVo,
|
||||
} from '@/types/business/project'
|
||||
import { request } from '@/utils/request'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { toProjectDetail } from '@/utils/projectVo'
|
||||
|
||||
// TODO(api): 待接口文档到位后,将以下 mock 替换为 request<T> 调用
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// 列表:真实接口
|
||||
// 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
|
||||
// businessType → eq 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 {
|
||||
beginTime: query.startDate ? `${query.startDate} 00:00:00` : undefined,
|
||||
endTime: query.endDate ? `${query.endDate} 23:59:59` : undefined,
|
||||
}
|
||||
}
|
||||
if (query.timeShortcut === 'all') return {}
|
||||
|
||||
const start = new Date()
|
||||
if (query.timeShortcut === '3m') start.setMonth(start.getMonth() - 3)
|
||||
else if (query.timeShortcut === '6m') start.setMonth(start.getMonth() - 6)
|
||||
else start.setFullYear(start.getFullYear() - 1)
|
||||
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',
|
||||
params: {
|
||||
pageNum: query.pageNum,
|
||||
pageSize: query.pageSize,
|
||||
// 空串不出现在 querystring 里,与后端 eqIfText 的「有值才等值匹配」语义一致
|
||||
key: query.keyword || undefined,
|
||||
businessType: query.businessType || undefined,
|
||||
status: query.status || undefined,
|
||||
...toTimeRange(query),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务类型筛选条件(左侧筛选栏「业务类型」的值域 + 件数)。
|
||||
*
|
||||
* <p>与列表分开取:`/list` 的 `requirementStatistics` 后端恒为 null,统计由本端点单独下发,
|
||||
* 且是**全量口径**(不随筛选、分页变化),所以进页面拉一次即可。</p>
|
||||
*/
|
||||
export function getProjectFilterConditions(): Promise<ProjectStatistics> {
|
||||
return request<ProjectStatistics>({
|
||||
url: '/web/requirementPool/getFilterConditions',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// 详情:真实接口
|
||||
// GET /web/requirementPool/get/{id} → ProjectRequirementUserController#get
|
||||
// → ProjectRequirementServiceImpl#queryRequirementByUserId
|
||||
// 出参 ProjectRequirementUserVo,经 utils/projectVo.ts 映射成详情页沿用的 Project 形态。
|
||||
// ⚠️ id 传的是**需求 id**(vm_project_requirement.id)= 列表行 RdProjectVo.id。
|
||||
// 未立项的需求也能查到(项目侧字段为空);不存在 / 非本人 → 后端 data 为 null。
|
||||
//
|
||||
// 文件 / 售后:**仍是前端 mock** —— 该 Controller 只有 create / list / get /
|
||||
// serviceTypeList 四个接口,没有附件上传、售后提交/取消的后端实现。
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/** 构造 mock 文件信息 */
|
||||
function mockFile(name: string, size: number, uploadTime: string): FileInfo {
|
||||
@@ -17,7 +128,7 @@ function mockFile(name: string, size: number, uploadTime: string): FileInfo {
|
||||
/** 详情 mock 所属项目 id */
|
||||
const DETAIL_ID = 'project-004'
|
||||
|
||||
/** 项目列表 mock(6 条,覆盖全部状态,internet/iot 混合) */
|
||||
/** 项目列表 mock(6 条,覆盖全部状态,internet/iot 混合)——仅详情页链路在用 */
|
||||
const MOCK_PROJECTS: Project[] = [
|
||||
{
|
||||
id: 'project-001',
|
||||
@@ -176,49 +287,15 @@ const PROJECT_DETAIL: Project = {
|
||||
},
|
||||
}
|
||||
|
||||
/** 提交时间快捷区间匹配 */
|
||||
function matchTimeShortcut(submitTime: string, shortcut: ProjectQuery['timeShortcut']): boolean {
|
||||
if (shortcut === 'all') return true
|
||||
// mock 时间为 '2026-8-17 14:00',替换为 / 保证各环境可解析
|
||||
const time = new Date(submitTime.replaceAll('-', '/')).getTime()
|
||||
const start = new Date()
|
||||
if (shortcut === '3m') start.setMonth(start.getMonth() - 3)
|
||||
if (shortcut === '6m') start.setMonth(start.getMonth() - 6)
|
||||
if (shortcut === '1y') start.setFullYear(start.getFullYear() - 1)
|
||||
return time >= start.getTime()
|
||||
}
|
||||
|
||||
/** 项目列表(筛选 + 分页,pageSize 固定 8) */
|
||||
export function getProjectList(query: ProjectQuery): Promise<PageResult<Project>> {
|
||||
const filtered = MOCK_PROJECTS.filter((item) => {
|
||||
if (
|
||||
query.keyword
|
||||
&& !item.projectName.includes(query.keyword)
|
||||
&& !item.projectNo.includes(query.keyword)
|
||||
) {
|
||||
return false
|
||||
}
|
||||
if (query.businessType !== 'all' && item.businessType !== query.businessType) return false
|
||||
if (query.status !== 'all' && item.status !== query.status) return false
|
||||
if (!matchTimeShortcut(item.submitTime, query.timeShortcut)) return false
|
||||
return true
|
||||
})
|
||||
const pageSize = query.pageSize > 0 ? query.pageSize : 8
|
||||
const start = (query.page - 1) * pageSize
|
||||
return Promise.resolve({
|
||||
list: filtered.slice(start, start + pageSize),
|
||||
total: filtered.length,
|
||||
})
|
||||
}
|
||||
|
||||
/** 项目详情(不存在返回 null;仅详情项目返回完整数据) */
|
||||
/** 项目详情(真实接口;不存在 / 非本人需求返回 null) */
|
||||
export function getProjectDetail(id: string): Promise<Project | null> {
|
||||
if (id === DETAIL_ID) return Promise.resolve({ ...PROJECT_DETAIL })
|
||||
const found = MOCK_PROJECTS.find((item) => item.id === id) ?? null
|
||||
return Promise.resolve(found ? { ...found } : null)
|
||||
return request<RequirementDetailVo | null>({
|
||||
url: `/web/requirementPool/get/${id}`,
|
||||
method: 'get',
|
||||
}).then((vo) => (vo ? toProjectDetail(vo) : null))
|
||||
}
|
||||
|
||||
/** 上传项目文件(追加进详情文件列表) */
|
||||
/** 上传项目文件(mock:追加进详情文件列表) */
|
||||
export function uploadProjectFile(file: File): Promise<FileInfo> {
|
||||
const info: FileInfo = {
|
||||
name: file.name,
|
||||
@@ -230,7 +307,7 @@ export function uploadProjectFile(file: File): Promise<FileInfo> {
|
||||
return Promise.resolve({ ...info })
|
||||
}
|
||||
|
||||
/** 删除项目文件(按索引从详情文件列表移除) */
|
||||
/** 删除项目文件(mock:按索引从详情文件列表移除) */
|
||||
export function deleteProjectFile(index: number): Promise<void> {
|
||||
if (index >= 0 && index < PROJECT_DETAIL.files.length) {
|
||||
PROJECT_DETAIL.files.splice(index, 1)
|
||||
@@ -238,7 +315,7 @@ export function deleteProjectFile(index: number): Promise<void> {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
/** 提交售后工单 */
|
||||
/** 提交售后工单(mock) */
|
||||
export function submitAfterSales(
|
||||
projectId: string,
|
||||
payload: AfterSalesPayload,
|
||||
@@ -255,7 +332,7 @@ export function submitAfterSales(
|
||||
return Promise.resolve({ ...result, attachments: [...result.attachments] })
|
||||
}
|
||||
|
||||
/** 取消售后工单 */
|
||||
/** 取消售后工单(mock) */
|
||||
export function cancelAfterSales(projectId: string): Promise<AfterSales> {
|
||||
const result: AfterSales = {
|
||||
status: '无',
|
||||
|
||||
Reference in New Issue
Block a user