/** * 预算成本深化 + 人员证件库 API。 * 成本中心主档 /cost-centers、人材机价格库 /price-items、人员证件库 /personnel-certs。 */ import { http } from './http' export interface CostCenter { id: number code: string name: string ccType: string owner: string /** 上级成本中心 id(责任中心多级树);空/0 表示根节点。 */ parentId?: number parentName: string budgetTotal: number actualTotal: number status: string createdAt: string } /** * 成本中心责任树节点(GET /cost-centers/tree)。除主档字段外带 level(顶层 0)、 * children(下级,递归)与含整棵子树的 rollupBudget / rollupActual / rollupRate 上卷。 */ export interface CostCenterTreeNode { id: number code: string name: string ccType: string owner: string parentId?: number parentName: string budgetTotal: number actualTotal: number status: string level: number rollupBudget: number rollupActual: number rollupRate: number children: CostCenterTreeNode[] } export interface PriceItem { id: number category: string name: string spec: string unit: string unitPrice: number region: string supplier: string priceType: string effectiveDate: string createdAt: string } export interface PersonnelCert { id: number personName: string dept: string certType: string certNo: string issuer: string issueDate: string expireDate: string status: string createdAt: string } /** * 标准成本台账。totalStandard=料+工+费、variance=actual-standard 由后端 create/update 自动计算。 * 需甲方规则:料/工/费的实际归集来源与工时费率属甲方核算口径,前端为手填+自动汇总框架。 */ export interface StandardCost { id: number productCode: string productName: string materialCost: number laborCost: number overheadCost: number totalStandard: number actualCost: number variance: number period: string /** 归属成本中心(用于按成本中心上卷汇总),可空。 */ costCenter: string note: string createdAt: string } /** 标准成本按成本中心上卷的一行汇总。 */ export interface CostCenterRollup { costCenter: string count: number materialCost: number laborCost: number overheadCost: number totalStandard: number actualCost: number variance: number } /** GET /standard-costs/rollup 返回结构:按成本中心分组 + 6 口径总计。 */ export interface StandardCostRollup { byCostCenter: CostCenterRollup[] totalMaterial: number totalLabor: number totalOverhead: number totalStandard: number totalActual: number totalVariance: number } /** * 成本中心责任树上卷的一个节点(GET /standard-costs/rollup-tree 的 tree 项)。 * selfXxx = 直挂本中心的料/工/费/标准/实际/差异(不含子树); * rollupXxx = 含本节点 + 整棵子树之和;count = 直挂本中心的台账条目数; * children = 下级成本中心节点(递归)。 */ export interface CostCenterRollupNode { costCenterId: number | null costCenter: string ccType: string level: number count: number selfMaterial: number selfLabor: number selfOverhead: number selfStandard: number selfActual: number selfVariance: number rollupMaterial: number rollupLabor: number rollupOverhead: number rollupStandard: number rollupActual: number rollupVariance: number children: CostCenterRollupNode[] } /** GET /standard-costs/rollup-tree 返回结构:成本中心树(多级上卷)+ 6 口径总计。 */ export interface StandardCostRollupTree { tree: CostCenterRollupNode[] totalMaterial: number totalLabor: number totalOverhead: number totalStandard: number totalActual: number totalVariance: number } export const CC_TYPES = ['项目', '部门', '公司', '工序'] export const PRICE_CATEGORIES = ['人工', '材料', '机械'] export const PRICE_TYPES = ['信息价', '市场价', '历史中标价', '企业标准价'] export const CERT_TYPES = ['身份证', '一级建造师', '二级建造师', '安全员证', '特种作业证', '职称证书', '学历证书'] /** GET /cost-centers[?ccType=&status=] */ export function listCostCenters(filter?: { ccType?: string; status?: string }): Promise { return http.get('/cost-centers', filter) } export function createCostCenter(input: Partial): Promise { return http.post('/cost-centers', input) } export function updateCostCenter(id: number | string, input: Partial): Promise { return http.put(`/cost-centers/${encodeURIComponent(String(id))}`, input) } export function deleteCostCenter(id: number | string): Promise { return http.del(`/cost-centers/${encodeURIComponent(String(id))}`) } /** GET /cost-centers/tree[?status=] —— 成本中心责任树(含预算/实际多级上卷)。 */ export function listCostCenterTree(status?: string): Promise { return http.get('/cost-centers/tree', status ? { status } : undefined) } /** GET /price-items[?category=&priceType=] */ export function listPriceItems(filter?: { category?: string; priceType?: string }): Promise { return http.get('/price-items', filter) } export function createPriceItem(input: Partial): Promise { return http.post('/price-items', input) } /** GET /personnel-certs[?certType=&status=] */ export function listPersonnelCerts(filter?: { certType?: string; status?: string }): Promise { return http.get('/personnel-certs', filter) } export function createPersonnelCert(input: Partial): Promise { return http.post('/personnel-certs', input) } export function updatePersonnelCert(id: number | string, input: Partial): Promise { return http.put(`/personnel-certs/${encodeURIComponent(String(id))}`, input) } export function deletePersonnelCert(id: number | string): Promise { return http.del(`/personnel-certs/${encodeURIComponent(String(id))}`) } /** GET /standard-costs[?period=] —— 标准成本台账。 */ export function listStandardCosts(filter?: { period?: string }): Promise { return http.get('/standard-costs', filter) } /** GET /standard-costs/rollup[?period=] —— 按成本中心上卷汇总料/工/费/标准/实际/差异 + 总计。 */ export function listStandardCostRollup(period?: string): Promise { return http.get('/standard-costs/rollup', period ? { period } : undefined) } /** GET /standard-costs/rollup-tree[?period=] —— 按成本中心责任树多级上卷(嵌套树)+ 6 口径总计。 */ export function listStandardCostRollupTree(period?: string): Promise { return http.get('/standard-costs/rollup-tree', period ? { period } : undefined) } export function createStandardCost(input: Partial): Promise { return http.post('/standard-costs', input) } export function updateStandardCost(id: number | string, input: Partial): Promise { return http.put(`/standard-costs/${encodeURIComponent(String(id))}`, input) } export function deleteStandardCost(id: number | string): Promise { return http.del(`/standard-costs/${encodeURIComponent(String(id))}`) }