2026-07-05-pl-hazard-cert-by-type.md 2.8 KB

危化品证书按产品类型区分 — Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: 按易制毒/易制爆/双属性区分所需证书(1~3 种),新增 legal_use_cert_url;上传/查看/列表动态展示;历史数据迁移。

Architecture: pl_plan_product 三 URL 字段语义固定;前端 getRequiredCertSlots() 为单一规则源;安排运输仍只校验 hazard_cert_ready(2026-07-04 不变)。

Tech Stack: FastAPI + SQLAlchemy + Pydantic v2;Vue 3 + Element Plus

Spec: docs/superpowers/specs/2026-07-05-pl-hazard-cert-by-type-design.md

Status: ✅ 已实现(2026-07-05)


文件结构

文件 职责
backend/scripts/migrate_pl_plan_product_legal_use_cert_url.sql DDL + 历史 DML
docs/sql/pl_tables.sql CREATE TABLE 同步
docs/sql/shanxia2.0.sql CREATE TABLE 同步
backend/app/models/pl_models.py legal_use_cert_url + comment
backend/app/schemas/pl/plan.py Schema 三字段
backend/app/services/pl_plan_service.py build/update certs
backend/app/api/pl/plan.py 编辑计划合并证书 URL
web-admin/src/api/pl/index.ts TS 类型
web-admin/src/composables/usePlToxicProductCertCheck.ts 槽位规则
web-admin/src/components/business/pl-plan-cert-upload-dialog/index.vue 动态上传
web-admin/src/components/business/pl-plan-hazard-cert-view-table/index.vue 卡片查看
web-admin/src/components/business/pl-plan-list-cert-cell/index.vue 列表证书
web-admin/src/components/business/pl-plan-list-product-cell/index.vue 计划列表
web-admin/src/views/pl/plan-cert/index.vue 齐备确认文案
web-admin/src/components/business/pl-plan-form-dialog/index.vue 透传第三字段

Task 1: 数据库与 Model ✅

  • 迁移 SQL(ADD COLUMN + MODIFY comment + DML)
  • pl_tables.sql / shanxia2.0.sql CREATE TABLE
  • PlPlanProduct.legal_use_cert_url

Task 2: 后端 Schema + Service + API ✅

  • plan.py schemas 三字段
  • build_plan_product / update_plan_product_certs
  • plan.py 编辑计划合并三证书 URL

Task 3: 前端 composable + API ✅

  • PlanProduct.legalUseCertUrl
  • getRequiredCertSlots 等 helper

Task 4: 前端组件 ✅

  • 上传弹窗
  • 查看卡片
  • 两个 list cell

Task 5: 文案与透传 ✅

  • plan-cert/index.vue 确认框
  • pl-plan-form-dialog / usePlContractToPlan

部署注意

mysql ... < backend/scripts/migrate_pl_plan_product_legal_use_cert_url.sql