Merge branch 'develop'
This commit is contained in:
@@ -59,6 +59,7 @@ class ApprovalInstances extends Model
|
||||
'current_step',
|
||||
'finished_at',
|
||||
'deadline_at',
|
||||
'round'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
@@ -69,6 +70,27 @@ class ApprovalInstances extends Model
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
|
||||
|
||||
// ====== ====== ====== 映射业务表 ====== ====== ======
|
||||
protected const BIZ_CLASS = [
|
||||
'stock_orders' => \app\common\model\StockOrders::class,
|
||||
'purchase_orders' => \app\common\model\PurchaseOrders::class,
|
||||
];
|
||||
|
||||
public function getBizTypeAttribute($value)
|
||||
{
|
||||
return self::BIZ_CLASS[$value] ?? $value;
|
||||
}
|
||||
|
||||
public function bizInfo()
|
||||
{
|
||||
return $this->morphTo('bizInfo', 'biz_type', 'biz_id');
|
||||
}
|
||||
// ====== ====== ====== 映射表业务 ====== ====== ======
|
||||
|
||||
|
||||
|
||||
public function records()
|
||||
{
|
||||
return $this->hasMany(ApprovalRecords::class, 'instance_id', 'id');
|
||||
@@ -84,18 +106,16 @@ class ApprovalInstances extends Model
|
||||
return $this->belongsTo(User::class, 'initiator_id', 'id');
|
||||
}
|
||||
|
||||
public function bizInfo()
|
||||
{
|
||||
return $this->belongsTo(StockOrders::class, 'biz_id', 'id');
|
||||
}
|
||||
// public function bizInfo2()
|
||||
// {
|
||||
// return $this->belongsTo(StockOrders::class, 'biz_id', 'id');
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取当前步骤的所有审批记录(pending 状态)
|
||||
*/
|
||||
public function currentStepRecords()
|
||||
{
|
||||
return $this->approvalRecords()
|
||||
->where('step_index', $this->current_step)
|
||||
->where('status', 'pending');
|
||||
return $this->approvalRecords()->where('step_index', $this->current_step)->where('status', 'pending');
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ class ApprovalRecords extends Model
|
||||
'status',
|
||||
'comment',
|
||||
'approved_at',
|
||||
'round'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PurchaseOrderItems extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'purchase_order_items';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'purchase_order_id', 'stock_id', 'stock_items_id', 'stock_items_uqid', 'quantity', 'unit_price', 'total_price', 'remark'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function purchaseOrder()
|
||||
{
|
||||
return $this->belongsTo(PurchaseOrders::class, 'purchase_order_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function stockOrder()
|
||||
{
|
||||
return $this->belongsTo(StockOrders::class, 'stock_id', 'id');
|
||||
}
|
||||
|
||||
public function stockOrderItems()
|
||||
{
|
||||
return $this->belongsTo(StockOrderItems::class, 'stock_items_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class PurchaseOrders extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
* The connection name for the model.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $connection = 'mysql';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'purchase_orders';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'order_no', 'pi_no', 'buyer_id', 'buyer_name', 'contract_file', 'status', 'remark', 'is_draft', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasMany(PurchaseOrderItems::class, 'purchase_order_id', 'id');
|
||||
}
|
||||
|
||||
public function buyer()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'buyer_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user