更新细节
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\adminapi\lists\BaseAdminDataLists;
|
||||||
use app\common\model\quotation\Quotation;
|
use app\common\model\quotation\Quotation;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报价单列表
|
* 报价单列表
|
||||||
@ -38,7 +38,7 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
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
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return Quotation::where($this->searchWhere)
|
return Db::name('Quotation')->alias('q')
|
||||||
->with('product')
|
->where($this->searchWhere)
|
||||||
->field(['id', 'customer_id', 'quotation_date', 'contacts', 'contacts_phone', 'create_user', 'invoice_type', 'amount_including_tax', 'freight', 'other_fee', 'total_amount'])
|
->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)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['q.id' => 'desc'])
|
||||||
->select()
|
->select()->each(function($item, $key){
|
||||||
|
//关联数据后续添加
|
||||||
|
$item['approve_no'] = '付款单号';
|
||||||
|
$item['approve_step'] = '流程步骤';
|
||||||
|
$item['approve_settle_status'] = 1;
|
||||||
|
return $item;
|
||||||
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +81,11 @@ class QuotationLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
*/
|
*/
|
||||||
public function count(): int
|
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();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$quotation = Quotation::create([
|
$quotation = Quotation::create([
|
||||||
|
'org_id' => $params['org_id'] ?? 0,
|
||||||
|
'dept_id' => $params['dept_id'] ?? 0,
|
||||||
'customer_id' => $params['customer_id'] ?? 0,
|
'customer_id' => $params['customer_id'] ?? 0,
|
||||||
'approve_id' => $params['approve_id'] ?? 0,
|
'approve_id' => $params['approve_id'] ?? 0,
|
||||||
'quotation_date' => $params['quotation_date'] ?? '',
|
'quotation_date' => $params['quotation_date'] ?? '',
|
||||||
@ -89,6 +91,8 @@ class QuotationLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Quotation::where('id', $params['id'])->update([
|
Quotation::where('id', $params['id'])->update([
|
||||||
|
'org_id' => $params['org_id'] ?? 0,
|
||||||
|
'dept_id' => $params['dept_id'] ?? 0,
|
||||||
'customer_id' => $params['customer_id'] ?? 0,
|
'customer_id' => $params['customer_id'] ?? 0,
|
||||||
'approve_id' => $params['approve_id'] ?? 0,
|
'approve_id' => $params['approve_id'] ?? 0,
|
||||||
'quotation_date' => $params['quotation_date'] ?? '',
|
'quotation_date' => $params['quotation_date'] ?? '',
|
||||||
@ -151,6 +155,8 @@ class QuotationLogic extends BaseLogic
|
|||||||
$quotation = Quotation::findOrEmpty($params['id']);
|
$quotation = Quotation::findOrEmpty($params['id']);
|
||||||
$quotation->product;
|
$quotation->product;
|
||||||
$quotation->custom;
|
$quotation->custom;
|
||||||
|
$quotation->org;
|
||||||
|
$quotation->dept;
|
||||||
$quotation->annex = json_decode($quotation->annex, true);
|
$quotation->annex = json_decode($quotation->annex, true);
|
||||||
return $quotation->toArray();
|
return $quotation->toArray();
|
||||||
}
|
}
|
||||||
|
@ -46,5 +46,25 @@ class Quotation extends BaseModel
|
|||||||
return $this->belongsTo(\app\common\model\custom\Custom::class, 'customer_id');
|
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