cmvr-wms/sql/wms_purchase_operation_log_20261008.sql
lixiaolong 4bf9d95a73 feat(warehouse): 仓库模块功能增强与性能优化
- 添加产品筛选选项接口支持品牌、分类、单位过滤
- 实现采购任务汇总统计功能
- 增加采购操作日志记录到货、验收、批次管理等操作
- 优化前端资源加载策略采用异步组件按需加载
- 集成 Element UI 主题颜色配置支持自定义主题
- 添加静态资源加载失败自动重试恢复机制
- 完善采购批次管理支持状态变更和批量分配
- 增强项目预算权限控制支持采购相关操作权限
- 优化数据库查询增加采购状态和批次条件筛选
- 添加采购到货验收流程的操作记录和撤销功能
2026-10-09 17:32:04 +08:00

30 lines
1.6 KiB
SQL

-- 采购操作历史。脚本可重复执行。
create table if not exists purchase_operation_log (
id bigint(20) not null auto_increment comment '主键',
purchase_request_id bigint(20) not null comment '采购申请ID',
request_no varchar(64) default null comment '采购申请单号快照',
operation_type varchar(32) not null comment '操作类型',
operation_title varchar(100) not null comment '操作标题',
operation_detail varchar(1000) default null comment '操作说明',
operator_id bigint(20) default null comment '操作人用户ID',
operator_name varchar(64) default null comment '操作人账号快照',
create_time datetime not null comment '操作时间',
primary key (id),
key idx_purchase_operation_request (purchase_request_id, id),
key idx_purchase_operation_type (operation_type)
) engine=innodb default charset=utf8mb4 comment='采购操作历史';
-- 给上线前已有的采购申请补一条起始记录,避免详情时间线为空。
insert into purchase_operation_log(purchase_request_id, request_no, operation_type,
operation_title, operation_detail, operator_id,
operator_name, create_time)
select pr.id, pr.request_no, 'MIGRATION', '历史采购申请',
concat('物料:', pr.material_name, ';数量:', cast(pr.quantity as char),
ifnull(concat(' ', pr.unit), '')),
pr.applicant_id, coalesce(pr.create_by, pr.applicant_name, 'system'),
coalesce(pr.create_time, sysdate())
from purchase_request pr
where not exists (
select 1 from purchase_operation_log pol where pol.purchase_request_id = pr.id
);