更新细节
This commit is contained in:
parent
67d6897ea4
commit
55368eb92e
@ -18,7 +18,7 @@ namespace app\adminapi\lists\quotation;
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\quotation\Quotation;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 报价单列表
|
||||
@ -38,7 +38,7 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['customer_id', 'contacts', 'create_user'],
|
||||
'=' => ['q.customer_id', 'q.contacts', 'q.create_user'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,12 +54,21 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Quotation::where($this->searchWhere)
|
||||
->with('product')
|
||||
->field(['id', 'customer_id', 'quotation_date', 'contacts', 'contacts_phone', 'create_user', 'invoice_type', 'amount_including_tax', 'freight', 'other_fee', 'total_amount'])
|
||||
return Db::name('Quotation')->alias('q')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('q.delete_time')
|
||||
->leftJoin('orgs o','o.id = q.org_id')
|
||||
->leftJoin('dept d','d.id = q.dept_id')
|
||||
->field('q.*, d.name as dept_name, o.name as org_name')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->order(['q.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
//关联数据后续添加
|
||||
$item['approve_no'] = '付款单号';
|
||||
$item['approve_step'] = '流程步骤';
|
||||
$item['approve_settle_status'] = 1;
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
@ -72,7 +81,11 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Quotation::where($this->searchWhere)->count();
|
||||
return Db::name('Quotation')->alias('q')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('q.delete_time')
|
||||
->leftJoin('orgs o','o.id = q.org_id')
|
||||
->leftJoin('dept d','d.id = q.dept_id')->count();
|
||||
}
|
||||
|
||||
}
|
@ -42,6 +42,8 @@ class QuotationLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$quotation = Quotation::create([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'customer_id' => $params['customer_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'quotation_date' => $params['quotation_date'] ?? '',
|
||||
@ -89,6 +91,8 @@ class QuotationLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
Quotation::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'customer_id' => $params['customer_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'quotation_date' => $params['quotation_date'] ?? '',
|
||||
@ -151,6 +155,8 @@ class QuotationLogic extends BaseLogic
|
||||
$quotation = Quotation::findOrEmpty($params['id']);
|
||||
$quotation->product;
|
||||
$quotation->custom;
|
||||
$quotation->org;
|
||||
$quotation->dept;
|
||||
$quotation->annex = json_decode($quotation->annex, true);
|
||||
return $quotation->toArray();
|
||||
}
|
||||
|
@ -46,5 +46,25 @@ class Quotation extends BaseModel
|
||||
return $this->belongsTo(\app\common\model\custom\Custom::class, 'customer_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 关联org
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 11:01
|
||||
*/
|
||||
public function org()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 关联dept
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 11:01
|
||||
*/
|
||||
public function dept()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user