编辑 | blame | 历史 | 原始文档

合同审批流程变更

变更说明

  1. 销售报价取消 BPM 审核:销售报价单不再走审批流程,简化为草稿 → 已转合同两种状态
  2. 合同审批动态选择流程:创建合同后,需用户手动选择审批流程并提交审批(类似采购申请)

数据库变更 SQL

-- =============================================
-- 1. 合同产品表字段变更(移除旧字段)
-- =============================================
ALTER TABLE `crm_contract_product` DROP COLUMN `product_id`;
ALTER TABLE `crm_contract_product` DROP COLUMN `product_price`;

-- =============================================
-- 2. BPM 分类创建(合同审批)
-- =============================================
INSERT INTO `bpm_category` (`name`, `code`, `description`, `status`, `sort`, `creator`, `create_time`, `updater`, `update_time`, `deleted`)
VALUES ('合同审批', 'contract_approve', '合同审批流程分类', 0, 0, '1', NOW(), '1', NOW(), b'0');

-- =============================================
-- 3. 销售报价状态字段更新(简化状态)
-- =============================================
-- 状态值变更:0=草稿, 10=已转合同
-- 原 status 字段值需要清理:10(审批中)、20(已通过)、30(已拒绝)、40(已取消) 改为 0(草稿)
UPDATE `crm_sale_quotation` SET `status` = 0 WHERE `status` IN (10, 20, 30, 40);
-- 已转合同的保持不变(status=50 改为 status=10)
UPDATE `crm_sale_quotation` SET `status` = 10 WHERE `status` = 50;

-- =============================================
-- 4. 合同审批状态字段更新(设置默认值)
-- =============================================
-- 将 audit_status 为 NULL 的记录设置为 0(未提交)
UPDATE `crm_contract` SET `audit_status` = 0 WHERE `audit_status` IS NULL;

-- =============================================
-- 4. 报价单产品明细表(如果表不存在需创建,已存在则补充字段)
-- =============================================
-- 如果 crm_sale_quotation_product 表不存在,执行创建
CREATE TABLE IF NOT EXISTS `crm_sale_quotation_product` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
  `quotation_id` bigint NOT NULL COMMENT '报价单编号',
  `item_id` bigint NOT NULL COMMENT 'MDM物料编号',
  `item_unit_id` bigint DEFAULT NULL COMMENT '计量单位编号',
  `item_price` decimal(24,6) NOT NULL DEFAULT 0 COMMENT '物料原价(冗余)',
  `quotation_price` decimal(24,6) NOT NULL COMMENT '报价单价',
  `count` decimal(24,6) NOT NULL COMMENT '数量',
  `total_price` decimal(24,6) NOT NULL COMMENT '小计金额',
  `tax_percent` decimal(10,2) DEFAULT NULL COMMENT '税率(%)',
  `tax_price` decimal(24,6) DEFAULT NULL COMMENT '税额',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  `creator` varchar(64) DEFAULT NULL COMMENT '创建者',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updater` varchar(64) DEFAULT NULL COMMENT '更新者',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  PRIMARY KEY (`id`),
  KEY `idx_quotation_id` (`quotation_id`)
) ENGINE=InnoDB COMMENT='CRM 销售报价单产品明细';

-- 如果表已存在但缺少 item_price 字段,执行补充
-- ALTER TABLE `crm_sale_quotation_product` 
-- ADD COLUMN `item_price` decimal(24,6) NOT NULL DEFAULT 0 COMMENT '物料原价(冗余)' AFTER `item_unit_id`;

涉及页面

  • 销售报价单列表页面
  • 销售报价单表单页面
  • 合同列表页面
  • 合同详情页面

API 变更

合同接口新增

方法 路径 说明
GET /crm/contract/approve-process-list 获取合同审批流程列表
PUT /crm/contract/submit 提交合同审批(需传 processDefinitionKey)

submit 接口参数变更:

参数 类型 必填 说明
id Long 合同编号
processDefinitionKey String 流程定义 Key(用户选择)

销售报价单接口变更

移除的接口

方法 路径 说明
PUT /crm/sale-quotation/submit 提交审批(已移除)
GET /crm/sale-quotation/approve-process-list 获取审批流程列表(已移除)

状态变更

旧状态值 旧状态名 新状态值 新状态名
0 草稿 0 草稿

| 10 | 审批中 | - | 已移除 |
| 20 | 已通过 | - | 已移除 |
| 30 | 已拒绝 | - | 已移除 |
| 40 | 已取消 | - | 已移除 |
| 50 | 已转合同 | 10 | 已转合同 |


前端修改点

1. 合同列表页面 - 提交审批

新增提交审批弹窗:

<!-- 提交审批弹窗 -->
<el-dialog title="选择审批流程" v-model="submitDialogVisible" width="400px">
  <el-form label-width="100px">
    <el-form-item label="审批流程" required>
      <el-select v-model="selectedProcessKey" placeholder="请选择" style="width: 100%">
        <el-option v-for="item in processList" :key="item.key" :label="item.name" :value="item.key" />
      </el-select>
    </el-form-item>
  </el-form>
  <template #footer>
    <el-button @click="submitDialogVisible = false">取消</el-button>
    <el-button type="primary" @click="confirmSubmit" :loading="submitLoading">确定</el-button>
  </template>
</el-dialog>

JS 方法:

import { getContractApproveProcessList, submitContract } from '@/api/crm/contract'

methods: {
  async handleSubmit(row) {
    const { data } = await getContractApproveProcessList()
    this.processList = data
    this.currentRow = row
    this.selectedProcessKey = null
    this.submitDialogVisible = true
  },
  async confirmSubmit() {
    if (!this.selectedProcessKey) {
      this.$message.warning('请选择审批流程')
      return
    }
    this.submitLoading = true
    try {
      await submitContract(this.currentRow.id, this.selectedProcessKey)
      this.$message.success('提交成功')
      this.submitDialogVisible = false
      this.getList()
    } finally {
      this.submitLoading = false
    }
  }
}

操作按钮调整:

<el-table-column label="操作" width="280">
  <template #default="{ row }">
    <el-button v-if="row.auditStatus === 0" type="primary" size="small" @click="handleUpdate(row)">编辑</el-button>
    <el-button v-if="row.auditStatus === 0" type="success" size="small" @click="handleSubmit(row)">提交审批</el-button>
    <el-button v-if="row.auditStatus === 0" type="danger" size="small" @click="handleDelete(row)">删除</el-button>
    <el-button v-if="row.auditStatus === 20" type="warning" size="small" @click="handleGenerateOrder(row)">生成订单</el-button>
  </template>
</el-table-column>

2. 合同状态显示

<!-- 合同审批状态 -->
<el-tag v-if="row.auditStatus === 0" type="info">未提交</el-tag>
<el-tag v-if="row.auditStatus === 10" type="warning">审批中</el-tag>
<el-tag v-if="row.auditStatus === 20" type="success">审核通过</el-tag>
<el-tag v-if="row.auditStatus === 30" type="danger">审核不通过</el-tag>

3. 销售报价单列表页面

移除审批相关操作按钮:

<!-- 移除以下按钮 -->
<!-- <el-button v-if="row.status === 0" type="success" size="small" @click="handleSubmit(row)">提交审批</el-button> -->

<!-- 保留按钮 -->
<el-button v-if="row.status === 0" type="primary" size="small" @click="handleUpdate(row)">编辑</el-button>
<el-button v-if="row.status === 0" type="warning" size="small" @click="handleConvertContract(row)">转合同</el-button>
<el-button v-if="row.status === 0" type="danger" size="small" @click="handleDelete(row)">删除</el-button>
<el-button v-if="row.contractId" type="primary" size="small" @click="handleViewContract(row)">查看合同</el-button>

4. 报价单状态显示

<!-- 状态标签 -->
<el-tag v-if="row.status === 0" type="info">草稿</el-tag>
<el-tag v-if="row.status === 10" type="success">已转合同</el-tag>

5. API 文件修改

// /src/api/crm/contract.js

// 新增 API
export function getContractApproveProcessList() {
  return request({ url: '/crm/contract/approve-process-list', method: 'get' })
}

export function submitContract(id, processDefinitionKey) {
  return request({ url: '/crm/contract/submit', method: 'put', params: { id, processDefinitionKey } })
}

// /src/api/crm/saleQuotation.js

// 移除以下 API
// export function submitSaleQuotation(id, processDefinitionKey) { ... }
// export function getSaleQuotationApproveProcessList() { ... }

// 保留以下 API
export function createSaleQuotation(data) { ... }
export function updateSaleQuotation(data) { ... }
export function deleteSaleQuotation(ids) { ... }
export function getSaleQuotation(id) { ... }
export function getSaleQuotationPage(params) { ... }
export function convertSaleQuotationToContract(id) { ... }

业务流程变更

新流程

报价单(草稿) → 转合同 → 合同(草稿) → 用户选择审批流程 → 提交审批 → BPM审批 → 审批通过 → 生成订单

流程说明:
1. 销售报价不再需要审批,草稿状态可直接转合同
2. 合同创建后为草稿状态,需用户手动选择审批流程并提交
3. 点击"提交审批"按钮后,弹出流程选择框,用户选择流程后提交


注意事项

  1. 合同审批 BPM 分类:需要在 BPM 管理后台创建分类编码为 contract_approve 的分类
  2. 合同审批流程:需要在该分类下配置至少一个激活的审批流程
  3. 流程选择:如果只有一个流程,前端可以直接提交;如果有多个流程,需要用户选择
  4. 转合同后:报价转合同后,合同为草稿状态,需手动提交审批