Commit 963d2f1b by lizhilin

更新

parent 470c9c93
......@@ -5,6 +5,7 @@
use App\Admin\Repositories\Covenant;
use App\Models\Covenant as ModelsCovenant;
use App\Models\Lawyer as ModelLawyer;
use App\Models\Principal as ModelPrincipal;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
......@@ -12,6 +13,7 @@
use App\Admin\Actions\CovenantClosed;
use App\Admin\Actions\CovenantReturn;
use Dcat\Admin\Admin;
use Illuminate\Support\Facades\DB;
class CovenantController extends AdminController
{
......@@ -22,7 +24,7 @@ class CovenantController extends AdminController
*/
protected function grid()
{
return Grid::make(ModelsCovenant::with(['principal', 'lawyer']), function (Grid $grid) {
return Grid::make(ModelsCovenant::with(['lawyer']), function (Grid $grid) {
$grid->model()->orderBy('id', 'DESC');
//$grid->column('id')->sortable();
$grid->column('number');
......@@ -31,7 +33,7 @@ protected function grid()
return Covenant::CTYPE[$val];
});
$grid->column('sign_at');
$grid->column('principal.name', '委托人');
$grid->column('principal', '委托人');
$grid->column('lawyer.name', '办案律师');
$grid->column('amount');
$grid->column('payment_method')->display(function ($val) {
......@@ -56,7 +58,7 @@ protected function grid()
$filter->panel();
$filter->like('number')->width(3);
$filter->like('cname')->width(3);
$filter->like('principal.name', '委托人')->width(3);
$filter->like('principal', '委托人')->width(3);
$filter->like('lawyer.name', '办案律师')->width(3);
$filter->equal('ctype')->select(Covenant::CTYPE)->width(3);
$filter->equal('payment_method')->select(Covenant::PAYMENT_METHOD)->width(3);
......@@ -125,7 +127,7 @@ protected function form()
}
}
return Form::make(new Covenant(), function (Form $form) use ($lawyers) {
$form = Form::make(new Covenant(), function (Form $form) use ($lawyers) {
$form->display('id');
$form->text('number')->required();
$form->select('ctype')->options(Covenant::CTYPE)->default(1);
......@@ -147,5 +149,17 @@ protected function form()
$form->display('created_at');
$form->display('updated_at');
});
$form->saved(
function (Form $form, $result) {
$cid = $form->getKey();
if (isset($_POST['principal_id']) && $_POST['principal_id']) {
$pObj = ModelPrincipal::find($_POST['principal_id']);
$pname = $pObj->name ? $pObj->name : $pObj->company;
DB::table('covenant')->where("id", $cid)->update(['principal' => $pname]);
}
}
);
return $form;
}
}
......@@ -97,7 +97,6 @@ protected function form()
->when(1, function (Form $form) {
$form->text('company');
$form->text('tax_number');
$form->text('address');
$form->text('tel');
$form->text('bank_name');
$form->text('bank_account');
......@@ -106,7 +105,6 @@ protected function form()
->when(2, function (Form $form) {
$form->text('name');
$form->text('identity_card');
$form->text('address', '联系地址');
})
->options([
1 => '单位',
......@@ -114,6 +112,7 @@ protected function form()
])
->default(1);
$form->text('address');
$form->text('phone');
$form->disableCreatingCheck();
......
......@@ -2,7 +2,7 @@
namespace App\Admin\Controllers;
use App\Admin\Repositories\Principal;
use App\Models\Principal as ModelsPrincipal;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Form;
......@@ -58,9 +58,10 @@ protected function grid()
$grid->tools(function (Grid\Tools $tools) use ($grid, $cid) {
$principal = $number = '';
if ($cid) {
$obj = ModelsCovenant::find($cid);
$principal = $obj->principal;
$number = $obj->number;
$cobj = ModelsCovenant::find($cid);
$pObj = ModelsPrincipal::find($cobj->principal_id);
$principal = $pObj->name;
$number = $cobj->number;
}
$card_info = "  合同编号:{$number}   委托人:{$principal}";
......
......@@ -2,7 +2,7 @@
namespace App\Admin\Controllers;
use App\Admin\Repositories\Principal;
use App\Models\Principal as ModelsPrincipal;
use App\Models\Covenant as ModelsCovenant;
use App\Models\CovenantReceivePayment as ModelsCovenantReceivePayment;
use Dcat\Admin\Form;
......@@ -70,7 +70,8 @@ protected function grid()
$invoiced_money = $received_money = $received_noinvoiced = $invoiced_noreceived = 0;
if ($cid) {
$cobj = ModelsCovenant::find($cid);
$principal = $cobj->principal;
$pObj = ModelsPrincipal::find($cobj->principal_id);
$principal = $pObj->name;
$cnumber = $cobj->number;
$lobj = ModelsLawyer::find($cobj->lawyer_id);
$lnumber = $lobj->number;
......
......@@ -3,7 +3,7 @@
namespace App\Admin\Repositories;
use App\Models\Covenant as ModelsCovenant;
use App\Models\Principal;
use App\Models\Principal as ModelsPrincipal;
use App\Models\CovenantReceivePayment;
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Grid;
......@@ -80,7 +80,7 @@ public function getList(array $param)
$list = [];
$note_monitor = DB::table("covenant_receive_payment as rp")
->select(DB::raw('rp.cid, c.cname,c.ctype,c.number as cnum,c.principal,l.number as lnum,l.name as lname,sum(invoiced_money) as invoiced_money,sum(received_amount) as received_amount'))
->select(DB::raw('rp.cid, c.cname,c.ctype,c.number as cnum,c.principal,c.principal_id,l.number as lnum,l.name as lname,sum(invoiced_money) as invoiced_money,sum(received_amount) as received_amount'))
//->select(['rp.cid', 'c.cname', 'c.ctype', 'c.number as cnum', 'c.principal', 'l.number as lnum', 'l.name as lname', 'sum(invoiced_money) as invoiced_money'])
->leftJoin('covenant as c', 'rp.cid', '=', 'c.id')
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id');
......@@ -167,6 +167,7 @@ public function getList(array $param)
$tmp['covenant_num'] = $item->cnum;
$tmp['covenant_name'] = $item->cname;
$tmp['covenant_type'] = $item->ctype ? ModelsCovenant::CTYPE[$item->ctype] : '';
$tmp['principal'] = $item->principal;
$tmp['invoice_amount'] = $item->invoiced_money;
$tmp['receipt_money'] = $item->received_amount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment