物品扫码领用与库存
This commit is contained in:
@@ -40,8 +40,9 @@ class InvItem extends Model
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'company_id', 'item_code', 'item_name',
|
||||
'category_id', 'spec_model', 'unit', 'is_consumable', 'stock_qty', 'manage_user_id', 'location', 'remark',
|
||||
protected $fillable = ['id', 'company_id', 'item_code', 'item_name',
|
||||
'category_id', 'spec_model', 'unit', 'is_consumable', 'allow_qr_claim', 'qr_code', 'qr_code_url',
|
||||
'stock_qty', 'manage_user_id', 'location', 'remark',
|
||||
'sort', 'status',
|
||||
'created_at', 'updated_at'];
|
||||
|
||||
|
||||
@@ -40,24 +40,42 @@ class InvRequisition extends Model
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'order_no', 'applicant_company_id', 'dept_id', 'applicant_id', 'applicant_name', 'leader_id', 'manager_id', 'borrow_reason', 'use_start_date', 'use_end_date', 'status', 'is_returned', 'remark', 'created_at', 'updated_at'];
|
||||
protected $fillable = ['id', 'order_no', 'applicant_company_id', 'dept_id', 'applicant_id', 'applicant_name', 'leader_id', 'manager_id', 'borrow_reason', 'use_start_date', 'use_end_date', 'status', 'claim_type', 'qr_claim_time', 'proxy_claim_user_id', 'proxy_claim_user_name', 'is_returned', 'remark', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
// 领取方式常量
|
||||
const CLAIM_TYPE_NORMAL = 1; // 正常申请
|
||||
const CLAIM_TYPE_QR = 2; // 扫码领取
|
||||
const CLAIM_TYPE_PROXY = 3; // 管理员代领
|
||||
|
||||
const STATUS_DRAFT = 0; // 草稿
|
||||
const STATUS_LEADER = 10; // 待直属上级审批
|
||||
const STATUS_MANAGE = 20; // 待管理员审批
|
||||
const STATUS_APPROVED = 30; // 已通过
|
||||
const STATUS_REJECTEDT = 40; // 已驳回
|
||||
const STATUS_CANCELED = 50; // 已取消
|
||||
/**
|
||||
* 领取方式文本
|
||||
*/
|
||||
public static function getClaimTypeText($type)
|
||||
{
|
||||
return [
|
||||
self::CLAIM_TYPE_NORMAL => '正常申请',
|
||||
self::CLAIM_TYPE_QR => '扫码领取',
|
||||
self::CLAIM_TYPE_PROXY => '管理员代领',
|
||||
][$type] ?? '未知';
|
||||
}
|
||||
|
||||
public function approval()
|
||||
{
|
||||
return $this->hasMany('app\common\model\InvRequisitionApprove',
|
||||
'requisition_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 领用明细关联
|
||||
*/
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany('app\common\model\InvRequisitionItem',
|
||||
'requisition_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* 物品库存变化记录模型
|
||||
*/
|
||||
class InvStockLog extends Model
|
||||
{
|
||||
protected $table = 'inv_stock_log';
|
||||
|
||||
protected $fillable = [
|
||||
'company_id',
|
||||
'item_id',
|
||||
'item_name_snap',
|
||||
'change_type',
|
||||
'change_qty',
|
||||
'before_qty',
|
||||
'after_qty',
|
||||
'biz_type',
|
||||
'biz_no',
|
||||
'operator_id',
|
||||
'operator_name',
|
||||
'remark',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public const CHANGE_TYPE_IN = 1; // 入库
|
||||
public const CHANGE_TYPE_OUT_CLAIM = 2; // 出库(领用)
|
||||
public const CHANGE_TYPE_OUT_LOSS = 3; // 出库(损耗)
|
||||
public const CHANGE_TYPE_IN_RETURN = 4; // 入库(归还)
|
||||
|
||||
public const BIZ_TYPE_PURCHASE = 1; // 采购入库
|
||||
public const BIZ_TYPE_QR_CLAIM = 2; // 扫码领取
|
||||
public const BIZ_TYPE_PROXY_CLAIM = 3; // 管理员代领
|
||||
public const BIZ_TYPE_NORMAL_CLAIM = 4; // 正常领用(审批后)
|
||||
public const BIZ_TYPE_RETURN = 5; // 归还入库
|
||||
public const BIZ_TYPE_LOSS = 6; // 损耗出库
|
||||
|
||||
/**
|
||||
* 变动类型文本
|
||||
*/
|
||||
public static function getChangeTypeText($type)
|
||||
{
|
||||
return [
|
||||
self::CHANGE_TYPE_IN => '入库',
|
||||
self::CHANGE_TYPE_OUT_CLAIM => '出库(领用)',
|
||||
self::CHANGE_TYPE_OUT_LOSS => '出库(损耗)',
|
||||
self::CHANGE_TYPE_IN_RETURN => '入库(归还)',
|
||||
][$type] ?? '未知';
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务类型文本
|
||||
*/
|
||||
public static function getBizTypeText($type)
|
||||
{
|
||||
return [
|
||||
self::BIZ_TYPE_PURCHASE => '采购入库',
|
||||
self::BIZ_TYPE_QR_CLAIM => '扫码领取',
|
||||
self::BIZ_TYPE_PROXY_CLAIM => '管理员代领',
|
||||
self::BIZ_TYPE_NORMAL_CLAIM => '正常领用',
|
||||
self::BIZ_TYPE_RETURN => '归还入库',
|
||||
self::BIZ_TYPE_LOSS => '损耗出库',
|
||||
][$type] ?? '未知';
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联物品
|
||||
*/
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(InvItem::class, 'item_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user