diff --git a/inventory-backend/app/models/base.py b/inventory-backend/app/models/base.py index e69de29..c095b8f 100644 --- a/inventory-backend/app/models/base.py +++ b/inventory-backend/app/models/base.py @@ -0,0 +1,57 @@ +# app/models/base.py +from app.extensions import db + +class MaterialBase(db.Model): + """ + 基础信息表模型 + 对应数据库表: material_base + """ + __tablename__ = 'material_base' + + # 1. 基础字段 + id = db.Column(db.Integer, primary_key=True) + name = db.Column(db.String(255), nullable=False, comment='基础信息名称') + category = db.Column(db.String(100), comment='类别') + material_type = db.Column(db.String(100), comment='类型') + spec_model = db.Column(db.String(255), comment='规格型号') + unit = db.Column(db.String(50), comment='计量单位') + + # 可见等级 + visibility_level = db.Column(db.Integer, default=0, comment='信息可见等级') + + # 链接与图片 + manual_link = db.Column(db.Text, comment='通用说明书') + product_image = db.Column(db.Text, comment='通用产品图') + + # 启用状态 + is_enabled = db.Column(db.Boolean, default=True, comment='是否启用') + + # ============================================================ + # 关联关系区域 + # ============================================================ + + # 1. 关联采购库存 (StockBuy) + stock_buys = db.relationship('StockBuy', back_populates='material', lazy='dynamic') + + # 2. 关联半成品库存 (StockSemi) + stock_semis = db.relationship('StockSemi', back_populates='material', lazy='dynamic') + + # 3. 关联成品库存 (StockProduct) + stock_products = db.relationship('StockProduct', back_populates='material', lazy='dynamic') + + def to_dict(self): + """ + 序列化方法 + """ + return { + 'id': self.id, + 'name': self.name, + 'category': self.category, + 'type': self.material_type, # 前端字段映射 + 'spec': self.spec_model, # 前端字段映射 + 'unit': self.unit, + 'visibilityLevel': self.visibility_level, + 'generalManual': self.manual_link, + 'generalImage': self.product_image, + 'isEnabled': 1 if self.is_enabled else 0, + } \ No newline at end of file diff --git a/inventory-backend/app/models/material.py b/inventory-backend/app/models/material.py deleted file mode 100644 index 4facd17..0000000 --- a/inventory-backend/app/models/material.py +++ /dev/null @@ -1,57 +0,0 @@ -# app/models/material.py -from app.extensions import db - -class MaterialBase(db.Model): - """ - 基础信息表模型 - 对应数据库表: material_base - """ - __tablename__ = 'material_base' - - # 1. 基础字段 - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(255), nullable=False, comment='基础信息名称') - category = db.Column(db.String(100), comment='类别') - material_type = db.Column(db.String(100), comment='类型') - spec_model = db.Column(db.String(255), comment='规格型号') - unit = db.Column(db.String(50), comment='计量单位') - - # 可见等级 - visibility_level = db.Column(db.Integer, default=0, comment='信息可见等级') - - # 链接与图片 - manual_link = db.Column(db.Text, comment='通用说明书') - product_image = db.Column(db.Text, comment='通用产品图') - - # 启用状态 - is_enabled = db.Column(db.Boolean, default=True, comment='是否启用') - - # ============================================================ - # 关联关系区域 - # ============================================================ - - # 1. 关联采购库存 (StockBuy) - stock_buys = db.relationship('StockBuy', back_populates='material', lazy='dynamic') - - # 2. 关联半成品库存 (StockSemi) - stock_semis = db.relationship('StockSemi', back_populates='material', lazy='dynamic') - - # 3. 关联成品库存 (StockProduct) - stock_products = db.relationship('StockProduct', back_populates='material', lazy='dynamic') - - def to_dict(self): - """ - 序列化方法 - """ - return { - 'id': self.id, - 'name': self.name, - 'category': self.category, - 'type': self.material_type, # 前端字段映射 - 'spec': self.spec_model, # 前端字段映射 - 'unit': self.unit, - 'visibilityLevel': self.visibility_level, - 'generalManual': self.manual_link, - 'generalImage': self.product_image, - 'isEnabled': 1 if self.is_enabled else 0, - } \ No newline at end of file diff --git a/inventory-web/src/api/material_base.ts b/inventory-web/src/api/material_base.ts index bc35c5f..5ebb26e 100644 --- a/inventory-web/src/api/material_base.ts +++ b/inventory-web/src/api/material_base.ts @@ -19,9 +19,10 @@ export function addMaterialBase(data: any) { } // 3. 修改基础信息 (包含状态启用/禁用) +// 【修复点】: 必须在 URL 中拼接 data.id,否则后端会报 405 Method Not Allowed export function updateMaterialBase(data: any) { return request({ - url: '/inbound/base/', + url: `/inbound/base/${data.id}`, method: 'put', data }) @@ -30,7 +31,7 @@ export function updateMaterialBase(data: any) { // 4. 删除基础信息 export function delMaterialBase(id: number) { return request({ - url: `/inbound/base/${id}`, // 注意这里是反引号,用于拼接 URL + url: `/inbound/base/${id}`, method: 'delete' }) } diff --git a/inventory-web/src/views/stock/inbound/buy.vue b/inventory-web/src/views/stock/inbound/buy.vue index bb80654..938b8c1 100644 --- a/inventory-web/src/views/stock/inbound/buy.vue +++ b/inventory-web/src/views/stock/inbound/buy.vue @@ -118,199 +118,254 @@ - +
+ -
-
- - 1. 基础信息 - (请先搜索选择物料) -
- -
- - - - - -
- {{ item.name }} - {{ item.spec }} -
-
-
-
-
- -
- 仅展示状态为“启用”的基础物料 -
-
-
- -
- - - - - - - -
-
-
- -
-
- - 2. 入库详情 -
- -
- - - - - - - - - - - -
- - - - 按批号入库 (Batch) - 按序列号入库 (SN) - - 根据历史记录已锁定入库方式 - - - - - - - - - - - - - - - - - - - +
+
+ + 1. 基础信息 + (请先搜索锁定物料)
- - - - - - - - + + + 点击可查看最近使用的物料,或输入关键词从云端搜索。 + + + - - - - ⚪ 未检 - 🟢 合格 - 🔴 不合格 - - - - - - -
商务与采购信息
- - - - - - - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + +
+
-
- +
+
+ + 2. 入库详情 +
+ +
+ + + + + + + + + + + +
+ + + + 按批号入库 (Batch) + 按序列号入库 (SN) + + 历史锁定 + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + ⚪ 未检 + 🟢 合格 + 🔴 不合格 + + + + + + +
商务与采购信息
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +