liu
4 天以前 749cb2f4ad815c5a68c19fe961d5ca2149a84dd4
src/api/crm/contract/index.ts
@@ -1,4 +1,4 @@
import type { PageParam, PageResult } from '../../../packages/effects/request/src';
import type { PageParam, PageResult } from '@vben/request';
import type { CrmPermissionApi } from '#/api/crm/permission';
@@ -18,8 +18,12 @@
    ownerUserId: number;
    ownerUserName?: string;
    ownerUserDeptName?: string;
    processInstanceId: number;
    auditStatus: number;
    // 以下为审核派生字段,由后端在审核时写入,前端只读展示
    reviewerId?: number; // 审核人ID(实际执行审核的用户)
    reviewerName?: string; // 审核人姓名
    reviewTime?: Date; // 审核时间
    reviewRemark?: string; // 审核意见(审核通过时的意见 / 审核不通过时的原因)
    orderDate: Date;
    startTime: Date;
    endTime: Date;
@@ -28,6 +32,8 @@
    totalPrice: number;
    depositPrice?: number; // 定金金额,单位:元
    totalReceivablePrice: number;
    totalInvoicePrice?: number; // 已开票金额(含审批中),单位:元
    unInvoicePrice?: number; // 未开票金额,单位:元
    signContactId: number;
    signContactName?: string;
    signUserId: number;
@@ -41,6 +47,14 @@
    contactName?: string;
    orderId?: number; // 关联 ERP 销售订单编号
    orderNo?: string; // ERP 销售订单单号
    contractType?: string; // 合同类型(供用电/能源服务等)
    voltageLevel?: string; // 电压等级
    electricityType?: string; // 用电类型
    contractCapacity?: number; // 合同容量(kVA)
    tariffMode?: string; // 电价模式
    meterMode?: string; // 计量方式
    payCycle?: number; // 缴费周期(月)
    commandCount?: number; // 指令数量
  }
  /** 合同产品信息 */
@@ -60,11 +74,6 @@
    totalPrice: number;
  }
  /** 审批流程 */
  export interface ApproveProcess {
    key: string;
    name: string;
  }
}
/** 查询合同列表 */
@@ -125,18 +134,42 @@
  return requestClient.download('/crm/contract/export-excel', { params });
}
/** 提交审核 */
export function submitContract(id: number, processDefinitionKey: string) {
/**
 * 提交合同审批(未提交 / 审核不通过 → 审批中)
 *
 * 审批人由「系统管理 - 审批配置」按业务类型统一配置,提交时无需指定;
 * 未启用审批或未配置有效审批人时后端会抛出业务异常。
 */
export function submitContract(id: number) {
  return requestClient.put('/crm/contract/submit', null, {
    params: { id, processDefinitionKey },
    params: { id },
  });
}
/** 获取合同审批流程列表 */
export function getContractApproveProcessList() {
  return requestClient.get<CrmContractApi.ApproveProcess[]>(
    '/crm/contract/approve-process-list',
  );
/**
 * 获得合同的审批人编号集合
 *
 * 供列表页判断当前登录用户是否应展示「审核 / 审核不通过」按钮;未配置时返回空数组。
 */
export function getContractApproverIds() {
  return requestClient.get<number[]>('/crm/contract/approver-ids');
}
/**
 * 审核合同(审批中 → 审核通过 / 审核不通过)
 *
 * 仅审批配置中的审批人可调用(多人时或签);pass=false 时 reviewRemark(不通过原因)必填。
 */
export function auditContract(
  id: number,
  pass: boolean,
  reviewRemark?: string,
) {
  return requestClient.put('/crm/contract/audit', {
    id,
    pass,
    reviewRemark,
  });
}
/** 合同转移 */