Selaa lähdekoodia

采购管理,完善导出功能

haozi 5 vuotta sitten
vanhempi
commit
4f492bd51d

+ 121 - 0
app/Filters/ProcurementCheckSheetFilters.php

@@ -0,0 +1,121 @@
+<?php
+
+
+namespace App\Filters;
+
+
+
+use App\Procurement;
+use App\ProcurementDeliverie;
+use App\Supplier;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Http\Request;
+
+class ProcurementCheckSheetFilters
+{
+    protected $request;
+    protected $queryBuilder;
+    protected $procurementDeliveryQuery;
+    protected $procurementQuery;
+    protected $supplierQuery;
+    protected $array_filter;
+    protected $filters = [
+        'id','status','signed_at','supplier_id'
+    ];
+    protected $params = [];
+
+    public function __construct(Request $request)
+    {
+        $this->request = $request;
+        $this->params = $request->all();
+    }
+
+    public function apply($builder)
+    {
+        $this->queryBuilder = $builder;
+        $filters = array_filter($this->request->only($this->filters));
+        $this->beforeApply();
+
+        foreach ($filters as $filter => $value) {
+            if (method_exists($this, $filter)) {
+                $this->$filter($value, $this->queryBuilder);
+            }
+        }
+        $this->afterApply();
+        return $this->queryBuilder;
+    }
+
+    private function isSearchLike($str):bool
+    {
+        if (substr($str, 0, 1) == "%" || substr($str, strlen($str) - 1, 1) == "%") {
+            return true;
+        }
+        return false;
+    }
+
+    private function searchWay($query, $param, $column)
+    {
+        if ($this->isSearchLike($param)) {
+            $query->where($column, 'like', $param);
+        } else {
+            $query->whereIn($column, array_filter(preg_split('/[,, ]+/is', $param)));
+        }
+        return $query;
+    }
+    private function getProcurementDeliveryQuery():Builder
+    {
+        if(!$this->procurementDeliveryQuery)
+            $this->procurementDeliveryQuery = ProcurementDeliverie::query()->selectRaw('id');
+        return $this->procurementDeliveryQuery;
+    }
+    private function getProcurementQuery():Builder
+    {
+        if(!$this->procurementQuery)
+            $this->procurementQuery = Procurement::query()->selectRaw('id');
+        return $this->procurementQuery;
+    }
+    private function getSupplierQuery():Builder
+    {
+        if(!$this->supplierQuery)
+            $this->supplierQuery = Supplier::query()->selectRaw('id');
+        return $this->supplierQuery;
+    }
+    public function id($id)
+    {
+        $this->queryBuilder->whereIn('id',$id);
+    }
+    public function status($status)
+    {
+        $this->queryBuilder->where('status',$status);
+    }
+
+    public function supplier_id($supplier_id)
+    {
+        $this->searchWay($this->getSupplierQuery(),$supplier_id,'supplier_id');
+    }
+    public function signed_at($signed_at)
+    {
+        $this->getProcurementDeliveryQuery()->where('signed_at','>=',"{$signed_at} 00:00:00")->where('signed_at','<=',"{$signed_at} 23:59:59");
+    }
+
+    public function beforeApply()
+    {
+        if(isset($this->params['data'])){
+            $ids = explode(',',$this->params['data']);
+            $this->id($ids);
+        }
+    }
+
+    public function afterApply()
+    {
+        if($this->procurementDeliveryQuery)
+            $this->queryBuilder->whereIn('procurement_delivery_id',$this->procurementDeliveryQuery);
+
+        if($this->procurementQuery)
+            $this->getProcurementQuery()->whereIn('procurement_id',$this->procurementQuery);
+
+        if($this->supplierQuery)
+            $this->getSupplierQuery()->whereIn('supplier_id',$this->supplierQuery);
+
+    }
+}

+ 14 - 2
app/Filters/ProcurementFilters.php

@@ -23,7 +23,7 @@ class ProcurementFilters
     protected $customerQuery;
     protected $array_filter;
     protected $filters = [
-        'owner_id','material_id','company_name','created_at_start','created_at_end','supplier_id'
+        'id','owner_id','material_id','company_name','created_at_start','created_at_end','supplier_id'
     ];
     protected $params = [];
 
@@ -37,6 +37,8 @@ class ProcurementFilters
     {
         $this->queryBuilder = $builder;
         $filters = array_filter($this->request->only($this->filters));
+        $this->beforeApply();
+
         foreach ($filters as $filter => $value) {
             if (method_exists($this, $filter)) {
                 $this->$filter($value, $this->queryBuilder);
@@ -109,7 +111,10 @@ class ProcurementFilters
     {
         $this->getCustomerQuery()->where('company_name','like',$company_name);
     }
-
+    public function id($id)
+    {
+        $this->queryBuilder->whereIn('id',$id);
+    }
     public function owner_id($owner_id)
     {
         $this->searchWay($this->getOwnerQuery(),$owner_id,'owner_id');
@@ -124,6 +129,13 @@ class ProcurementFilters
         $this->searchWay($this->getMaterialQuery(),$material_id,'id');
     }
 
+    public function beforeApply()
+    {
+        if(isset($this->params['data'])){
+            $ids = explode(',',$this->params['data']);
+            $this->id($ids);
+        }
+    }
 
     public function afterApply()
     {

+ 166 - 8
app/Http/Controllers/ProcurementController.php

@@ -3,14 +3,21 @@
 namespace App\Http\Controllers;
 
 use App\Components\AsyncResponse;
+use App\Filters\ProcurementCheckSheetFilters;
 use App\Filters\ProcurementFilters;
-use App\Http\Requests\EnquiryRequest;
+use App\Http\Requests\Procurement\EnquiryRequest;
+use App\Http\Requests\Procurement\ProcurementRequest;
+use App\Http\Requests\Procurement\ProofRequest;
 use App\Material;
 use App\Procurement;
 use App\ProcurementCheckSheet;
+use App\ProcurementDeliverie;
 use App\ProcurementTotalBill;
+use App\Services\common\ExportService;
 use App\Services\OwnerMaterialService;
+use App\Services\ProcurementTotalBillService;
 use App\Supplier;
+use Carbon\Traits\Date;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 
@@ -49,7 +56,10 @@ class ProcurementController extends Controller
         $ownerMaterialService=app(OwnerMaterialService::class);
         $owners=$ownerMaterialService->getOwnerPermittingWithMaterial();
         $materials=Material::query()->select('id','name')->get();
-        return view('procurement/procurement/index',compact('procurements','owners','materials','paginateParams'));
+        $date=date('Y-m-d');
+        $countReceive=ProcurementDeliverie::query()->where('signed_at',$date)->count();
+        $countProcurement=Procurement::query()->where('type',0)->where('created_at','like',$date.'%')->count();
+        return view('procurement/procurement/index',compact('procurements','owners','materials','paginateParams','countReceive','countProcurement'));
     }
 
 
@@ -69,9 +79,10 @@ class ProcurementController extends Controller
         $procurement=$this->newProcurement($param);
         return redirect('procurement/procurement/index')->with('successTip','新采购单“'.$procurement->code.'”添加成功');
     }
-    public function createProcurement(Request $request)
+    public function createProcurement(ProcurementRequest $request)
     {
         $this->gate('采购管理-采购-新建');
+        $request->validated();
         $param=$request->all(['owner_material_id','quantity','amount','unit_price']);
         try {
             $procurement=$this->newProcurement($param);
@@ -85,7 +96,7 @@ class ProcurementController extends Controller
     public function createEnquiry(EnquiryRequest $request)
     {
         $this->gate('采购管理-采购-新建');
-        $validated = $request->validated();
+        $request->validated();
         $param=$request->all(['owner_material_id']);
         try {
             $procurement=new Procurement([
@@ -108,9 +119,10 @@ class ProcurementController extends Controller
             return ['success' => false,'message' => $e->getMessage()];
         }
     }
-    public function createProof(Request $request)
+    public function createProof(ProofRequest $request)
     {
         $this->gate('采购管理-采购-新建');
+        $request->validated();
         $param=$request->all(['owner_material_id']);
         try {
             $procurement=new Procurement([
@@ -158,17 +170,30 @@ class ProcurementController extends Controller
         //
     }
 
-    public function checkBill(Request $request)
+    public function checkBill(Request $request,ProcurementCheckSheetFilters $filters)
     {
         $this->gate('采购管理-财务-对账单');
         $paginateParams=$request->input();
         $procurementCheckSheets=ProcurementCheckSheet::query()
-            ->with(['procurementDelivery.procurement.supplier','procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.receiver',])
+            ->filter($filters)
+            ->with(['procurementDelivery.procurement.supplier','procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.receiver'])
             ->paginate($param['paginate'] ?? 50);
         $suppliers=Supplier::query()->select('id','name')->get();
         $materials=Material::query()->select('id','name')->get();
         return view('procurement/finance/checkBill',compact('procurementCheckSheets','suppliers','paginateParams','materials'));
     }
+    public function fillInvoice(Request $request){
+        $this->gate('采购管理-财务-对账单');
+        $id=$request->input('procurementCheckSheetId');
+        $invoice_number=$request->input('invoice_number');
+        try {
+            $procurementCheckSheet=ProcurementCheckSheet::query()->where('id',$id)->update(['invoice_number'=>$invoice_number]);
+            if ($procurementCheckSheet) return ['success' => true,'data' => $invoice_number];
+            else return ['success' => false, 'message' => '添加失败'];
+        } catch (\Exception $e) {
+            return ['success' => false,'message' => $e->getMessage()];
+        }
+    }
 
     public function procurementBill(Request $request,ProcurementFilters $filters)
     {
@@ -190,8 +215,141 @@ class ProcurementController extends Controller
     {
         $this->gate('采购管理-财务-月账单报表');
         $paginateParams=$request->input();
-        $procurementTotalBills=ProcurementTotalBill::query()->with('supplier')->paginate($param['paginate'] ?? 50);
+        /** @var ProcurementTotalBillService $procurementTotalBillService*/
+        $procurementTotalBillService=app(ProcurementTotalBillService::class);
+        $procurementTotalBills=$procurementTotalBillService->paginate($paginateParams);
         $suppliers=Supplier::query()->select('id','name')->get();
         return view('procurement/finance/monthlyBillReport',compact('suppliers','procurementTotalBills','paginateParams'));
     }
+    //采购导出
+    public function procurementExport(Request $request,ProcurementFilters $filters){
+        $this->gate('采购管理-采购-查询');
+        $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
+        $procurements = Procurement::query()
+            ->filter($filters)
+            ->with(['initiator','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
+                $query->with('customer')->whereIn('id',$owner_ids);
+            }])->get();
+
+        $procurementStatus=Procurement::status;
+        $procurementType=Procurement::type;
+        $row = ['采购编号','项目','单据类型','采购公司','耗材编号','耗材','尺寸大小','特殊要求','材质规格','采购数量','销售单价(元)','送货数量','销售总价(元)','采购单状态','联系方式'];
+        $list = [];
+        foreach ($procurements as $procurement){
+            $list[] = [
+                $procurement->code,
+                $procurement->ownerMaterial->owner ? $procurement->ownerMaterial->owner->name :'',
+                is_null($procurement->type) ? '' :$procurementType[$procurement->type],
+                $procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->company_name :'',
+                $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->code :'',
+                $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->name :'',
+                $procurement->ownerMaterial ? $procurement->ownerMaterial->size :'',
+                $procurement->ownerMaterial ? $procurement->ownerMaterial->special :'',
+                $procurement->ownerMaterial ? $procurement->ownerMaterial->specification :'',
+                $procurement->quantity,
+                $procurement->unit_price,
+                '',//送货数量
+                '',//销售总价
+                is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
+                $procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->phone :'',
+            ];
+        }
+        return app(ExportService::class)->json($row,$list,"采购管理-采购报表记录");
+    }
+    //对账单报表导出
+    public function checkBillExport(Request $request,ProcurementCheckSheetFilters $filters){
+        $this->gate('采购管理-财务-对账单');
+        $procurementCheckSheets=ProcurementCheckSheet::query()
+            ->filter($filters)
+            ->with(['procurementDelivery.procurement.supplier','procurementDelivery.procurement.ownerMaterial.material','procurementDelivery.receiver'])
+            ->get();
+        $procurementCheckSheetStatus=ProcurementCheckSheet::status;
+        $row = ['采购编号','采购日期','送货日期','供应商名称','耗材编号','耗材','采购数量','送货数量','签收人','签收日期','应付金额','发票号','状态'];
+        $list = [];
+        foreach ($procurementCheckSheets as $procurementCheckSheet){
+            $list[] = [
+                $procurementCheckSheet->procurementDelivery->procurement ? $procurementCheckSheet->procurementDelivery->procurement->code : '',
+                $procurementCheckSheet->procurementDelivery->procurement ? $procurementCheckSheet->procurementDelivery->procurement->created_at :'',
+                $procurementCheckSheet->procurementDelivery ? $procurementCheckSheet->procurementDelivery->created_at :'',
+                $procurementCheckSheet->procurementDelivery->procurement->supplier ? $procurementCheckSheet->procurementDelivery->procurement->supplier->name :'',
+                $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material ? $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material->code :'',
+                $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material ? $procurementCheckSheet->procurementDelivery->procurement->ownerMaterial->material->name :'',
+                $procurementCheckSheet->procurementDelivery->procurement ? $procurementCheckSheet->procurementDelivery->procurement->quantity :'',
+                $procurementCheckSheet->procurementDelivery ? $procurementCheckSheet->procurementDelivery->amount :'',
+                $procurementCheckSheet->procurementDelivery->receiver ? $procurementCheckSheet->procurementDelivery->receiver->name :'',
+                $procurementCheckSheet->procurementDelivery ? $procurementCheckSheet->procurementDelivery->signed_at :'',
+                $procurementCheckSheet->account_payable,
+                $procurementCheckSheet->invoice_number,
+                is_null($procurementCheckSheet->status) ? '' :$procurementCheckSheetStatus[$procurementCheckSheet->status],
+            ];
+        }
+        return app(ExportService::class)->json($row,$list,"采购管理-对账单报表记录");
+    }
+    //采购账单导出
+    public function procurementBillExport(Request $request,ProcurementFilters $filters){
+        $this->gate('采购管理-财务-采购账单');
+        $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
+        $procurements = Procurement::query()
+            ->filter($filters)
+            ->with(['initiator','supplier','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
+                $query->with('customer')->whereIn('id',$owner_ids);
+            }])->get();
+
+        $procurementStatus=Procurement::status;
+        $row = ['采购编号','采购日期','接单日期','签收日期','项目名称','采购公司','供应商','耗材编号','耗材','尺寸大小','特殊要求',
+                '材质规格','采购数量','销售数量','收货数量','采购单价(元)','销售单价(元)','应收金额(元)','应付金额(元)','状态'];
+        $list = [];
+        foreach ($procurements as $procurement){
+            $list[] = [
+                $procurement->code,
+                $procurement->created_at,
+                '',//接单日期
+                '',//签收日期
+                $procurement->ownerMaterial->owner ? $procurement->ownerMaterial->owner->name :'',
+                $procurement->ownerMaterial->owner->customer ? $procurement->ownerMaterial->owner->customer->company_name :'',
+                $procurement->supplier ? $procurement->supplier->name :'',
+                $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->code :'',
+                $procurement->ownerMaterial->material ? $procurement->ownerMaterial->material->name :'',
+                $procurement->ownerMaterial ? $procurement->ownerMaterial->size :'',
+                $procurement->ownerMaterial ? $procurement->ownerMaterial->special :'',
+                $procurement->ownerMaterial ? $procurement->ownerMaterial->specification :'',
+                $procurement->quantity,
+                $procurement->amount,
+                '',//收货数量
+                $procurement->cost_price,
+                $procurement->unit_price,
+                '',//应收金额
+                '',//应付金额
+                is_null($procurement->status) ? '' :$procurementStatus[$procurement->status],
+            ];
+        }
+        return app(ExportService::class)->json($row,$list,"采购账单报表记录");
+    }
+    //月账单报表导出
+    public function procurementTotalBillExport(Request $request){
+        $this->gate('采购管理-财务-月账单报表');
+        /** @var ProcurementTotalBillService $procurementTotalBillService*/
+        $procurementTotalBillService=app(ProcurementTotalBillService::class);
+        if ($request->input('checkAllSign')){
+            $params = $request->input();
+            unset($params["checkAllSign"]);
+            $procurementTotalBills=$procurementTotalBillService->get($params);
+        }else{
+            $procurementTotalBills=$procurementTotalBillService->get(["id"=>$request->data]);
+        }
+        $procurementTotalBillStatus=ProcurementTotalBill::status;
+        $row = ['对账编号','账单日期','提交日期','供应商','总金额','状态'];
+        $list = [];
+        foreach ($procurementTotalBills as $procurementTotalBill){
+            $list[] = [
+                $procurementTotalBill->id,
+                $procurementTotalBill->counting_month,
+                $procurementTotalBill->created_at,
+                $procurementTotalBill->supplier ? $procurementTotalBill->supplier :'',
+                $procurementTotalBill->total_payable,
+                $procurementTotalBill->status ? $procurementTotalBillStatus[$procurementTotalBill->status] :'',
+            ];
+        }
+        return app(ExportService::class)->json($row,$list,"采购管理-月账单报表记录");
+    }
 }

+ 3 - 1
app/Http/Requests/EnquiryRequest.php → app/Http/Requests/Procurement/EnquiryRequest.php

@@ -1,11 +1,13 @@
 <?php
 
-namespace App\Http\Requests;
+namespace App\Http\Requests\Procurement;
 
+use App\Traits\RequestApiFormValidation;
 use Illuminate\Foundation\Http\FormRequest;
 
 class EnquiryRequest extends FormRequest
 {
+    use RequestApiFormValidation;
     /**
      * Determine if the user is authorized to make this request.
      *

+ 12 - 2
app/Http/Requests/ProcurementRequest.php → app/Http/Requests/Procurement/ProcurementRequest.php

@@ -1,11 +1,13 @@
 <?php
 
-namespace App\Http\Requests;
+namespace App\Http\Requests\Procurement;
 
+use App\Traits\RequestApiFormValidation;
 use Illuminate\Foundation\Http\FormRequest;
 
 class ProcurementRequest extends FormRequest
 {
+    use RequestApiFormValidation;
     /**
      * Determine if the user is authorized to make this request.
      *
@@ -24,7 +26,15 @@ class ProcurementRequest extends FormRequest
     public function rules()
     {
         return [
-            //
+            'owner_id'=>'required',
+            'owner_material_id'=>'required',
+        ];
+    }
+    public function messages()
+    {
+        return [
+            'owner_id.required' => '项目必选',
+            'owner_material_id.required' => '项目耗材编码必选',
         ];
     }
 }

+ 14 - 3
app/Http/Requests/ProofRequest.php → app/Http/Requests/Procurement/ProofRequest.php

@@ -1,11 +1,13 @@
 <?php
 
-namespace App\Http\Requests;
+namespace App\Http\Requests\Procurement;
 
+use App\Traits\RequestApiFormValidation;
 use Illuminate\Foundation\Http\FormRequest;
 
 class ProofRequest extends FormRequest
 {
+    use RequestApiFormValidation;
     /**
      * Determine if the user is authorized to make this request.
      *
@@ -13,7 +15,7 @@ class ProofRequest extends FormRequest
      */
     public function authorize()
     {
-        return false;
+        return true;
     }
 
     /**
@@ -24,7 +26,16 @@ class ProofRequest extends FormRequest
     public function rules()
     {
         return [
-            //
+            'owner_id'=>'required',
+            'owner_material_id'=>'required',
+        ];
+    }
+
+    public function messages()
+    {
+        return [
+            'owner_id.required' => '项目必选',
+            'owner_material_id.required' => '项目耗材编码必选',
         ];
     }
 }

+ 1 - 0
app/Procurement.php

@@ -27,6 +27,7 @@ class Procurement extends Model
         5 => "完结",
         6 => "下单失败",
         7 => "待出账",
+        8 => "待接单(已过期)",
     ];
 
     protected $fillable=[

+ 10 - 0
app/ProcurementCheckSheet.php

@@ -12,10 +12,20 @@ class ProcurementCheckSheet extends Model
     use ModelLogChanging;
     use ModelTimeFormat;
 
+    const status=[
+        0 => "未出账",
+        1 => "已出账",
+        2 => "已完结",
+    ];
     protected $fillable=[
         'procurement_delivery_id','invoice_number', 'account_payable', 'auditor','status','created_at'
     ];
     public function procurementDelivery(){
         return $this->belongsTo('App\ProcurementDeliverie','procurement_delivery_id','id');
     }
+
+    public function scopeFilter($query, $filters)
+    {
+        return $filters->apply($query);
+    }
 }

+ 11 - 0
app/ProcurementTotalBill.php

@@ -12,10 +12,21 @@ class ProcurementTotalBill extends Model
     use ModelLogChanging;
     use ModelTimeFormat;
 
+    const status=[
+        0 => "未出账",
+        1 => "已出账",
+        2 => "已完结",
+    ];
+
     protected $fillable=[
         'counting_month','supplier_id','status'
     ];
     public function supplier(){
         return $this->belongsTo('App\Supplier','supplier_id','id');
     }
+    //截取账单日期为月
+    public function getCountingMonthAttribute($value)
+    {
+        return substr($value,0,7);
+    }
 }

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -61,6 +61,7 @@ use App\Services\ProcessMethodService;
 use App\Services\ProcessService;
 use App\Services\ProcessStatisticService;
 use App\Services\ProcurementService;
+use App\Services\ProcurementTotalBillService;
 use App\Services\ProvinceService;
 use App\Services\RealtimePendingOrdersService;
 use App\Services\RejectedBillItemService;
@@ -204,6 +205,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('ProcessesContentService',ProcessesContentService::class);
         app()->singleton('ProvinceService',ProvinceService::class);
         app()->singleton('ProcurementService',ProcurementService::class);
+        app()->singleton('ProcurementTotalBillService',ProcurementTotalBillService::class);
         app()->singleton('RealtimePendingOrdersService',RealtimePendingOrdersService::class);
         app()->singleton('RegionService',RegionService::class);
         app()->singleton('RejectedBillItemService',RejectedBillItemService::class);

+ 34 - 0
app/Services/ProcurementTotalBillService.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Services;
+
+use App\Owner;
+use App\Procurement;
+use App\ProcurementTotalBill;
+use App\Services\common\QueryService;
+use Illuminate\Support\Facades\Auth;
+use App\Traits\ServiceAppAop;
+
+
+class ProcurementTotalBillService
+{
+    use ServiceAppAop;
+
+    private function conditionQuery(array $param){
+        $procurementTotalBills=ProcurementTotalBill::query()->with('supplier');
+        $columnQueryRules=[
+            'supplier_id' => ['multi' => ','],
+            'counting_month' => ['like' => ''],
+        ];
+        $procurementTotalBills = app(QueryService::class)->query($param,$procurementTotalBills,$columnQueryRules,"procurement_total_bills");
+        return $procurementTotalBills;
+    }
+
+    public function paginate(array $param){
+        $procurementTotalBills = $this->conditionQuery($param);
+        return $procurementTotalBills->paginate($param['paginate'] ?? 50);
+    }
+    public function get(array $params){
+        return $this->conditionQuery($params)->get();
+    }
+}

+ 28 - 0
app/Traits/RequestApiFormValidation.php

@@ -0,0 +1,28 @@
+<?php
+
+
+namespace App\Traits;
+
+
+use Illuminate\Contracts\Validation\Validator;
+use Illuminate\Validation\ValidationException;
+use Symfony\Component\HttpFoundation\Response;
+
+trait RequestApiFormValidation
+{
+    // 重写ajax请求验证错误响应格式(防止验证422报错)
+    protected function failedValidation(Validator $validator)
+    {
+        // 此处自定义表单验证错误信息
+        $data = [
+            'code' => 200,
+            'success' => false,
+            'errors' => $validator->errors()
+        ];
+        $response = new Response(json_encode($data));
+        throw (new ValidationException($validator, $response))
+            ->errorBag($this->errorBag)
+            ->redirectTo($this->getRedirectUrl());
+    }
+
+}

+ 24 - 0
resources/views/procurement/finance/_fillInvoiceNumber.blade.php

@@ -0,0 +1,24 @@
+<div class="modal " id="fill-invoice-number" tabindex="-1" >
+    <div class="modal-dialog modal-lg">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title text-center">填写发票号</h5>
+                <button type="button" class="close" data-dismiss="modal">
+                    <span>&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                    <div class="form-group row">
+                        <label for="invoice_number" class="col-2 col-form-label text-right">发票号</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control "  name="invoice_number" autocomplete="off"  v-model="invoice_number">
+                        </div>
+                    </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary"  data-dismiss="modal" >关闭</button>
+                <button type="button" class="btn btn-primary" @click="fillInvoice">提交</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 55 - 15
resources/views/procurement/finance/checkBill.blade.php

@@ -13,8 +13,8 @@
             导出Excel
         </button>
         <div class="dropdown-menu">
-            <a class="dropdown-item" @click="procurementExport(false)" href="javascript:">导出勾选内容</a>
-            <a class="dropdown-item" @click="procurementExport(true)" href="javascript:">导出所有页</a>
+            <a class="dropdown-item" @click="checkBillExport(false)" href="javascript:">导出勾选内容</a>
+            <a class="dropdown-item" @click="checkBillExport(true)" href="javascript:">导出所有页</a>
         </div>
         </span>
         </div>
@@ -27,7 +27,7 @@
             <tr id="header"></tr>
             <tr v-for="(procurementCheckSheet,i) in procurementCheckSheets">
                 <td>
-                    <input class="checkItem" type="checkbox" :value="procurementCheckSheet" v-model="checkData">
+                    <input class="checkItem" type="checkbox" :value="procurementCheckSheet.id" v-model="checkData">
                 </td>
                 <td class="">@{{ procurementCheckSheet.procurement_code }}</td>
                 <td class="text-muted">@{{ procurementCheckSheet.procurement_at }}</td>
@@ -41,10 +41,13 @@
                 <td class="text-muted">@{{ procurementCheckSheet.signed_at }}</td>
                 <td class="text-muted">@{{ procurementCheckSheet.account_payable }}</td>
                 <td><span>@{{ procurementCheckSheet.invoice_number }}</span></td>
-                <td><span>@{{ procurementCheckSheet.status }}</span></td>
-                <td><a class="text-primary">填写发票号</a></td>
+                <td><span>@{{ procurement_check_sheet_status[procurementCheckSheet.status] }}</span></td>
+                <td><a class="text-primary" @click="fillInvoiceNumber(procurementCheckSheet.id)" v-if="!procurementCheckSheet.invoice_number">填写发票号</a></td>
             </tr>
         </table>
+        @can('采购管理-财务-对账单')
+            @include('procurement.finance._fillInvoiceNumber')
+        @endcan
         <div class="text-info h5 btn btn">{{$procurementCheckSheets->count()}}/@{{ sum }}</div>
         <div>{{$procurementCheckSheets->appends($paginateParams)->links()}}</div>
     </div>
@@ -99,25 +102,24 @@
                 ],
                 checkData: [],
                 sum:{!! $procurementCheckSheets->total() !!},
-
+                procurement_check_sheet_status:{!! json_encode(\App\ProcurementCheckSheet::status,JSON_UNESCAPED_UNICODE) !!},
+                invoice_number:'',procurementCheckSheetId:null,
             },
             mounted: function () {
                 $(".tooltipTarget").tooltip({'trigger': 'hover'});
                 $('#list').removeClass('d-none');
                 let data = [
                     [
-                        {name: 'created_at_start', type: 'dateTime', tip: '选择显示指定日期的起始时间'},
-                        {name: 'created_at_end', type: 'dateTime', tip: '选择显示指定日期的结束时间'},
+                        {name: 'signed_at', type: 'dateTime', tip: '选择显示指定的签收日期'},
                         {
                             name: 'supplier_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的供应商'],
                             placeholder: ['供应商', '定位或多选供应商'], data: this.suppliers
                         },
                         {
-                            name: 'material_id',
-                            type: 'select_multiple_select',
+                            name: 'status', type: 'select',
                             tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的耗材'],
-                            placeholder: ['耗材', '定位或多选耗材'],
-                            data: this.materials
+                            placeholder: '对账单状态',
+                            data: [{name:0,value:'未出账'},{name:1,value:'已出账'},{name:2,value:'已完结'},],
                         },
                     ],
                 ];
@@ -128,7 +130,7 @@
                 this.form.init();
                 let column = [
                     {
-                        name: 'cloneCheckAll', customization: true, type: 'checkAll',
+                        name: 'cloneCheckAll', customization: true, type: 'checkAll',column:'id',
                         dom: $('#cloneCheckAll').removeClass('d-none'), neglect: true
                     },
                     {name: 'code', value: '采购编号', neglect: true},
@@ -166,14 +168,52 @@
                 checkAll(e) {
                     if (e.target.checked) {
                         this.procurementCheckSheets.forEach((el, i) => {
-                            if (this.checkData.indexOf(el) == '-1') {
-                                this.checkData.push(el);
+                            if (this.checkData.indexOf(el.id) == '-1') {
+                                this.checkData.push(el.id);
                             }
                         });
                     } else {
                         this.checkData = [];
                     }
                 },
+                fillInvoiceNumber(id){
+                    let _this=this;
+                    _this.procurementCheckSheetId=id;
+                    $('#fill-invoice-number').modal('show');
+                },
+                fillInvoice(){
+                    let _this=this;
+                    if (!_this.procurementCheckSheetId)return;
+                    if (!_this.invoice_number){
+                        tempTip.setDuration(3000);
+                        tempTip.show('发票号不可为空!');
+                    }
+                    let url = '{{url('procurement/finance/fillInvoice')}}';
+                    let params = {invoice_number:_this.invoice_number,procurementCheckSheetId:_this.procurementCheckSheetId};
+                    window.axios.post(url,params).then(function (res) {
+                        if (!res.data.success){
+                            tempTip.setDuration(3000);
+                            tempTip.show(res.data.message);
+                        }else {
+                            _this.procurementCheckSheets.forEach(function (procurementCheckSheet) {
+                                if (procurementCheckSheet.id===_this.procurementCheckSheetId){
+                                    procurementCheckSheet.invoice_number=_this.invoice_number;
+                                }
+                            });
+                            $("#fill-invoice-number").modal('hide');
+                            tempTip.setDuration(3000);
+                            tempTip.showSuccess('添加发票号成功!');
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('添加发票号失败!网络错误:'+err);
+                    });
+                },
+                checkBillExport(selectAll){
+                    let url = '{{url('procurement/finance/checkBillExport')}}';
+                    let token='{{ csrf_token() }}';
+                    excelExport(selectAll,this.checkData,url,this.sum,token);
+                },
 
             }
         });

+ 12 - 8
resources/views/procurement/finance/monthlyBillReport.blade.php

@@ -27,14 +27,14 @@
             <tr id="header"></tr>
             <tr v-for="(procurementTotalBill,i) in procurementTotalBills">
                 <td>
-                    <input class="checkItem" type="checkbox" :value="procurementTotalBill" v-model="checkData">
+                    <input class="checkItem" type="checkbox" :value="procurementTotalBill.id" v-model="checkData">
                 </td>
                 <td class="text-primary">@{{ procurementTotalBill.id }}</td>
                 <td class="text-muted">@{{ procurementTotalBill.counting_month }}</td>
                 <td class="text-muted">@{{ procurementTotalBill.created_at }}</td>
                 <td class="text-muted">@{{ procurementTotalBill.supplier_name }}</td>
                 <td>@{{ procurementTotalBill.total_payable }}</td>
-                <td><span>@{{ procurementTotalBill.status }}</span></td>
+                <td><span>@{{ procurement_total_bill_status[procurementTotalBill.status] }}</span></td>
                 <td>
                     <span class="btn btn-sm btn-outline-success">查看对账单</span>
                 </td>
@@ -69,6 +69,7 @@
                 ],
                 checkData: [],
                 sum:{!! $procurementTotalBills->total() !!},
+                procurement_total_bill_status:{!! json_encode(\App\ProcurementTotalBill::status,JSON_UNESCAPED_UNICODE) !!},
 
             },
             mounted: function () {
@@ -76,8 +77,7 @@
                 $('#list').removeClass('d-none');
                 let data = [
                     [
-                        {name: 'created_at_start', type: 'dateTime', tip: '选择显示指定日期的起始时间'},
-                        {name: 'created_at_end', type: 'dateTime', tip: '选择显示指定日期的结束时间'},
+                        {name:'counting_month',type:'dateMonth',tip:'选择账单日期',placeholder: '----年--月'},
                         {
                             name: 'supplier_id', type: 'select_multiple_select', tip: ['输入关键词快速定位下拉列表,回车确定', '选择要显示的供应商'],
                             placeholder: ['供应商', '定位或多选供应商'], data: this.suppliers
@@ -91,7 +91,7 @@
                 this.form.init();
                 let column = [
                     {
-                        name: 'cloneCheckAll', customization: true, type: 'checkAll',
+                        name: 'cloneCheckAll', customization: true, type: 'checkAll',column:'id',
                         dom: $('#cloneCheckAll').removeClass('d-none'), neglect: true
                     },
                     {name: 'id', value: '对账编号', neglect: true},
@@ -122,15 +122,19 @@
                 checkAll(e) {
                     if (e.target.checked) {
                         this.procurementTotalBills.forEach((el, i) => {
-                            if (this.checkData.indexOf(el) == '-1') {
-                                this.checkData.push(el);
+                            if (this.checkData.indexOf(el.id) == '-1') {
+                                this.checkData.push(el.id);
                             }
                         });
                     } else {
                         this.checkData = [];
                     }
                 },
-
+                procurementTotalBillExport(selectAll){
+                    let url = '{{url('procurement/finance/procurementTotalBillExport')}}';
+                    let token='{{ csrf_token() }}';
+                    excelExport(selectAll,this.checkData,url,this.sum,token);
+                },
             }
         });
     </script>

+ 13 - 7
resources/views/procurement/finance/procurementBill.blade.php

@@ -13,8 +13,8 @@
             导出Excel
         </button>
         <div class="dropdown-menu">
-            <a class="dropdown-item" @click="{{--procurementExport(false)--}}" href="javascript:">导出勾选内容</a>
-            <a class="dropdown-item" @click="{{--procurementExport(true)--}}" href="javascript:">导出所有页</a>
+            <a class="dropdown-item" @click="procurementBillExport(false)" href="javascript:">导出勾选内容</a>
+            <a class="dropdown-item" @click="procurementBillExport(true)" href="javascript:">导出所有页</a>
         </div>
         </span>
         </div>
@@ -27,7 +27,7 @@
             <tr id="header"></tr>
             <tr v-for="(procurement,i) in procurements">
                 <td>
-                    <input class="checkItem" type="checkbox" :value="procurement" v-model="checkData">
+                    <input class="checkItem" type="checkbox" :value="procurement.id" v-model="checkData">
                 </td>
                 <td class="">@{{ procurement.code }}</td>
                 <td class="">@{{ procurement.created_at }}</td>
@@ -48,7 +48,7 @@
                 <td>@{{ procurement.unit_price }}</td>
                 <td></td>
                 <td></td>
-                <td><span>@{{ procurement.status }}</span></td>
+                <td><span>@{{ procurement_status[procurement.status] }}</span></td>
                 <td>
                     <span class="btn btn-sm btn-outline-danger">锁定</span>
                     <span class="btn btn-sm btn-outline-success">修改采购单价</span>
@@ -103,6 +103,7 @@
                 ],
                 checkData: [],
                 sum:{!! $procurements->total() !!},
+                procurement_status:{!! json_encode(\App\Procurement::status,JSON_UNESCAPED_UNICODE) !!},
 
             },
             mounted: function () {
@@ -134,7 +135,7 @@
                 this.form.init();
                 let column = [
                     {
-                        name: 'cloneCheckAll', customization: true, type: 'checkAll',
+                        name: 'cloneCheckAll', customization: true, type: 'checkAll',column:'id',
                         dom: $('#cloneCheckAll').removeClass('d-none'), neglect: true
                     },
                     {name: 'code', value: '采购编号', neglect: true},
@@ -179,14 +180,19 @@
                 checkAll(e) {
                     if (e.target.checked) {
                         this.procurements.forEach((el, i) => {
-                            if (this.checkData.indexOf(el) == '-1') {
-                                this.checkData.push(el);
+                            if (this.checkData.indexOf(el.id) == '-1') {
+                                this.checkData.push(el.id);
                             }
                         });
                     } else {
                         this.checkData = [];
                     }
                 },
+                procurementBillExport(selectAll){
+                    let url = '{{url('procurement/finance/procurementBillExport')}}';
+                    let token='{{ csrf_token() }}';
+                    excelExport(selectAll,this.checkData,url,this.sum,token);
+                },
 
             }
         });

+ 6 - 6
resources/views/procurement/procurement/_addEnquiry.blade.php

@@ -12,22 +12,22 @@
                     <div class="form-group row">
                         <label for="owner_id" class="col-2 col-form-label text-right text-primary">项目名称{{old('owner_id')}} *</label>
                         <div class="col-8 form-inline">
-                            <select id="owner_id" name="owner_id" class="form-control {{--@error('owner_id') is-invalid @enderror--}} col-4" :class="errors.owner_id ? 'is-invalid' : ''" v-model="owner_id" @change="selectOwner" required>
+                            <select id="owner_id" name="owner_id" class="form-control col-4" :class="errors.owner_id ? 'is-invalid' : ''" v-model="owner_id" @change="selectOwner" required>
                                 <option v-for="owner in owners" :value="owner.name">@{{owner.value}}</option>
                             </select>
                             <input type="text" class="form-control-sm ml-2" placeholder="输入关键字定位项目" @input="owner_seek">
+                            <span class="invalid-feedback" role="alert" v-if="errors.owner_id">
+                                <strong>@{{ errors.owner_id[0] }}</strong>
+                            </span>
                         </div>
-                        <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.owner_id">
-                            <strong>@{{ errors.owner_id[0] }}</strong>
-                        </span>
                     </div>
                     <div class="form-group row">
                         <label for="owner_material_id" class="col-2 col-form-label text-right text-primary">项目耗材编号{{old('owner_material_id')}} *</label>
                         <div class="col-8">
-                            <select id="owner_material_id" name="owner_material_id" :class="errors.owner_material_id ? 'is-invalid' : ''" class="form-control {{--@error('owner_material_id') is-invalid @enderror--}} col-4" v-model="owner_material_id" @change="ownerMaterial" required>
+                            <select id="owner_material_id" name="owner_material_id" :class="errors.owner_material_id ? 'is-invalid' : ''" class="form-control col-4" v-model="owner_material_id" @change="ownerMaterial" required>
                                 <option v-for="ownerMaterial in ownerMaterials" :value="ownerMaterial.id">@{{ownerMaterial.material_code}}</option>
                             </select>
-                            <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.owner_material_id">
+                            <span class="invalid-feedback" role="alert" v-if="errors.owner_material_id">
                                 <strong>@{{ errors.owner_material_id[0] }}</strong>
                             </span>
                         </div>

+ 10 - 30
resources/views/procurement/procurement/_addProcurement.blade.php

@@ -12,26 +12,24 @@
                     <div class="form-group row">
                         <label for="owner_id" class="col-2 col-form-label text-right text-primary">项目名称{{old('owner_id')}} *</label>
                         <div class="col-8 form-inline">
-                            <select id="owner_id" name="owner_id" class="form-control @error('owner_id') is-invalid @enderror col-4" v-model="owner_id" @change="selectOwner" required>
+                            <select id="owner_id" name="owner_id" class="form-control col-4" :class="errors.owner_id ? 'is-invalid' : ''" v-model="owner_id" @change="selectOwner" required>
                                 <option v-for="owner in owners" :value="owner.name">@{{owner.value}}</option>
                             </select>
                             <input type="text" class="form-control-sm ml-2" placeholder="输入关键字定位项目" @input="owner_seek">
-                        </div>
-                        <div class="col-sm-5">
-                            <p class="form-control-static text-danger small font-weight-bold" >{{ $errors->first('owner_id') }}</p>
+                            <span class="invalid-feedback" role="alert" v-if="errors.owner_id">
+                                <strong>@{{ errors.owner_id[0] }}</strong>
+                            </span>
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="owner_material_id" class="col-2 col-form-label text-right text-primary">项目耗材编号{{old('owner_material_id')}} *</label>
                         <div class="col-8">
-                            <select id="owner_material_id" name="owner_material_id" class="form-control @error('owner_material_id') is-invalid @enderror col-4" v-model="owner_material_id" @change="ownerMaterial" required>
+                            <select id="owner_material_id" name="owner_material_id" class="form-control col-4" :class="errors.owner_material_id ? 'is-invalid' : ''" v-model="owner_material_id" @change="ownerMaterial" required>
                                 <option v-for="ownerMaterial in ownerMaterials" :value="ownerMaterial.id">@{{ownerMaterial.material_code}}</option>
                             </select>
-                            @error('owner_material_id')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
+                            <span class="invalid-feedback" role="alert" v-if="errors.owner_material_id">
+                                <strong>@{{ errors.owner_material_id[0] }}</strong>
                             </span>
-                            @enderror
                         </div>
                     </div>
                     <div class="form-group row">
@@ -61,37 +59,19 @@
                     <div class="form-group row">
                         <label for="quantity" class="col-2 col-form-label text-right">采购数量</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('quantity') is-invalid @enderror"
-                                   v-model="quantity"  name="quantity" autocomplete="off" value="{{ old('quantity') }}" required>
-                            @error('quantity')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
-                            </span>
-                            @enderror
+                            <input type="text" class="form-control" v-model="quantity"  name="quantity" autocomplete="off" value="{{ old('quantity') }}" required>
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="amount" class="col-2 col-form-label text-right">销售数量</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('amount') is-invalid @enderror"
-                                   name="amount" autocomplete="off" value="{{ old('amount') }}" @input="countTotalPrice" v-model="amount" required>
-                            @error('amount')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
-                            </span>
-                            @enderror
+                            <input type="text" class="form-control" name="amount" autocomplete="off" value="{{ old('amount') }}" @input="countTotalPrice" v-model="amount" required>
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="unit_price" class="col-2 col-form-label text-right">销售单价</label>
                         <div class="col-8">
-                            <input type="text" class="form-control @error('unit_price') is-invalid @enderror"
-                                   name="unit_price" autocomplete="off" value="{{ old('unit_price') }}" @input="countTotalPrice" v-model="unit_price" required>
-                            @error('unit_price')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
-                            </span>
-                            @enderror
+                            <input type="text" class="form-control" name="unit_price" autocomplete="off" value="{{ old('unit_price') }}" @input="countTotalPrice" v-model="unit_price" required>
                         </div>
                     </div>
                     <div class="form-group row">

+ 7 - 9
resources/views/procurement/procurement/_addProof.blade.php

@@ -12,26 +12,24 @@
                     <div class="form-group row">
                         <label for="owner_id" class="col-2 col-form-label text-right text-primary">项目名称{{old('owner_id')}} *</label>
                         <div class="col-8 form-inline">
-                            <select id="owner_id" name="owner_id" class="form-control @error('owner_id') is-invalid @enderror col-4" v-model="owner_id" @change="selectOwner" required>
+                            <select id="owner_id" name="owner_id" class="form-control col-4" :class="errors.owner_id ? 'is-invalid' : ''" v-model="owner_id" @change="selectOwner" required>
                                 <option v-for="owner in owners" :value="owner.name">@{{owner.value}}</option>
                             </select>
                             <input type="text" class="form-control-sm ml-2" placeholder="输入关键字定位项目" @input="owner_seek">
-                        </div>
-                        <div class="col-sm-5">
-                            <p class="form-control-static text-danger small font-weight-bold" >{{ $errors->first('owner_id') }}</p>
+                            <span class="invalid-feedback" role="alert" v-if="errors.owner_id">
+                                <strong>@{{ errors.owner_id[0] }}</strong>
+                            </span>
                         </div>
                     </div>
                     <div class="form-group row">
                         <label for="owner_material_id" class="col-2 col-form-label text-right text-primary">项目耗材编号{{old('owner_material_id')}} *</label>
                         <div class="col-8">
-                            <select id="owner_material_id" name="owner_material_id" class="form-control @error('owner_material_id') is-invalid @enderror col-4" v-model="owner_material_id" @change="ownerMaterial" required>
+                            <select id="owner_material_id" name="owner_material_id" :class="errors.owner_material_id ? 'is-invalid' : ''" class="form-control col-4" v-model="owner_material_id" @change="ownerMaterial" required>
                                 <option v-for="ownerMaterial in ownerMaterials" :value="ownerMaterial.id">@{{ownerMaterial.material_code}}</option>
                             </select>
-                            @error('owner_material_id')
-                            <span class="invalid-feedback" role="alert">
-                                <strong>{{ $message }}</strong>
+                            <span class="invalid-feedback" role="alert" v-if="errors.owner_material_id">
+                                <strong>@{{ errors.owner_material_id[0] }}</strong>
                             </span>
-                            @enderror
                         </div>
                     </div>
                     <div class="form-group row">

+ 1 - 0
resources/views/procurement/procurement/create.blade.php

@@ -144,6 +144,7 @@
                 unit_price:'{{old('unit_price')}}',
                 total_price:'{{old('total_price')}}',
                 ownerMaterials:[],
+                errors:{},
             },
             methods:{
                 owner_seek:function (e) {

+ 62 - 32
resources/views/procurement/procurement/index.blade.php

@@ -13,8 +13,8 @@
                     <div class="card">
                         <div class="card-body row">
                             <span class="fa fa-shopping-cart fa-4x offset-md-3" style="color: #4c2584"></span>
-                            <span class="ml-3 mt-2">
-                                <h5 class="font-weight-bold">数量</h5>
+                            <span class="ml-4 mt-2">
+                                <h5 class="font-weight-bold">@{{ countReceive }}</h5>
                                 <p class="text-muted">今日收货次数</p>
                             </span>
                         </div>
@@ -24,8 +24,8 @@
                     <div class="card">
                         <div class="card-body row">
                             <span class="fa fa-file-o fa-4x offset-md-3" style="color: #9fcdff"></span>
-                            <span class="ml-3 mt-2">
-                                <h5 class="font-weight-bold">数量</h5>
+                            <span class="ml-4 mt-2">
+                                <h5 class="font-weight-bold">@{{ countProcurement }}</h5>
                                 <p class="text-muted">今日发起采购次数</p>
                             </span>
                         </div>
@@ -35,7 +35,7 @@
                     <div class="card">
                         <div class="card-body row">
                             <span class="fa fa-calendar-o fa-4x offset-md-3" style="color: #2ca02c"></span>
-                            <span class="ml-3 mt-2">
+                            <span class="ml-4 mt-2">
                         <h5 class="font-weight-bold">数量</h5>
                         <p class="text-muted">今日对账金额</p>
                         </span>
@@ -53,8 +53,8 @@
             导出Excel
         </button>
         <div class="dropdown-menu">
-            <a class="dropdown-item" @click="{{--procurementExport(false)--}}" href="javascript:">导出勾选内容</a>
-            <a class="dropdown-item" @click="{{--procurementExport(true)--}}" href="javascript:">导出所有页</a>
+            <a class="dropdown-item" @click="procurementExport(false)" href="javascript:">导出勾选内容</a>
+            <a class="dropdown-item" @click="procurementExport(true)" href="javascript:">导出所有页</a>
         </div>
         </span>
             <span class="btn btn-sm btn-outline-info ml-2" @click="addProcurement">新增采购</span>
@@ -80,7 +80,7 @@
             <tr id="header"></tr>
             <tr v-for="(procurement,i) in procurements">
                 <td>
-                    <input class="checkItem" type="checkbox" :value="procurement" v-model="checkData">
+                    <input class="checkItem" type="checkbox" :value="procurement.id" v-model="checkData">
                 </td>
                 <td class="">@{{ procurement.code }}</td>
                 <td v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.name }}</td>
@@ -99,8 +99,8 @@
                 <td><span>@{{ procurement_status[procurement.status] }}</span></td>
                 <td v-if="procurement.owner_material.owner.customer">@{{ procurement.owner_material.owner.customer.phone }}</td>
                 <td>
-                    <span class="btn btn-sm btn-outline-danger">取消</span>
-                    <span class="btn btn-sm btn-outline-success">发起采购</span>
+                    <span class="btn btn-sm btn-outline-danger" v-if="procurement.supplier_id">取消</span>
+                    <span class="btn btn-sm btn-outline-success" v-if="procurement.type==1">发起采购</span>
                 </td>
             </tr>
         </table>
@@ -116,6 +116,8 @@
         let vue = new Vue({
             el: '#list',
             data: {
+                countReceive:{!! $countReceive !!},
+                countProcurement:{!! $countProcurement !!},
                 procurements:{!! $procurements->toJson() !!}['data'],
                 owners:[
                         @foreach($owners as $owner)
@@ -180,7 +182,7 @@
                 this.form.init();
                 let column = [
                     {
-                        name: 'cloneCheckAll', customization: true, type: 'checkAll',
+                        name: 'cloneCheckAll', customization: true, type: 'checkAll',column:'id',
                         dom: $('#cloneCheckAll').removeClass('d-none'), neglect: true
                     },
                     {name: 'code', value: '采购编号', neglect: true},
@@ -221,8 +223,8 @@
                 checkAll(e) {
                     if (e.target.checked) {
                         this.procurements.forEach((el, i) => {
-                            if (this.checkData.indexOf(el) == '-1') {
-                                this.checkData.push(el);
+                            if (this.checkData.indexOf(el.id) == '-1') {
+                                this.checkData.push(el.id);
                             }
                         });
                     } else {
@@ -280,35 +282,63 @@
                     let _this=this;
                     let url = '{{url('procurement/procurement/createProcurement')}}';
                     let params = {owner_material_id:_this.owner_material_id,quantity:_this.quantity,amount:_this.amount,unit_price:_this.unit_price};
-                    window.tempTip.postBasicRequest(url,params,res=>{
-                        this.procurements.push(res);
-                        this.$forceUpdate();
-                        $("#add-procurement").modal('hide');
-                        return '新增采购单成功';
-                    },true);
+                    window.axios.post(url,params).then(function (res) {
+                        if (!res.data.success){
+                            _this.errors=res.data.errors;
+                        }else {
+                            _this.procurements.push(res.data.data);
+                            $("#add-procurement").modal('hide');
+                            tempTip.setDuration(3000);
+                            tempTip.showSuccess('新增采购单成功!');
+
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('新增采购单失败!网络错误:'+err);
+                    });
                 },
                 createEnquiry(){
                     let _this=this;
                     let url = '{{url('procurement/procurement/createEnquiry')}}';
                     let params = {owner_id:_this.owner_id,owner_material_id:_this.owner_material_id};
-                    window.tempTip.postBasicRequest(url,params,res=>{
-                        if (res.errors)_this.errors=res.errors;
-                        this.procurements.push(res);
-                        this.$forceUpdate();
-                        $("#add-enquiry").modal('hide');
-                        return '新增询价单成功';
-                    },true);
+                    window.axios.post(url,params).then(function (res) {
+                        if (!res.data.success){
+                            _this.errors=res.data.errors;
+                        }else {
+                            _this.procurements.push(res.data.data);
+                            $("#add-enquiry").modal('hide');
+                            tempTip.setDuration(3000);
+                            tempTip.showSuccess('新增询价单成功!');
+
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('新增询价单失败!网络错误:'+err);
+                    });
                 },
                 createProof(){
                     let _this=this;
                     let url = '{{url('procurement/procurement/createProof')}}';
                     let params = {owner_id:_this.owner_id,owner_material_id:_this.owner_material_id};
-                    window.tempTip.postBasicRequest(url,params,res=>{
-                        this.procurements.push(res);
-                        this.$forceUpdate();
-                        $("#add-proof").modal('hide');
-                        return '新增打样单成功';
-                    },true);
+                    window.axios.post(url,params).then(function (res) {
+                        if (!res.data.success){
+                            _this.errors=res.data.errors;
+                        }else {
+                            _this.procurements.push(res.data.data);
+                            $("#add-proof").modal('hide');
+                            tempTip.setDuration(3000);
+                            tempTip.showSuccess('新增打样单成功!');
+
+                        }
+                    }).catch(function (err) {
+                        tempTip.setDuration(3000);
+                        tempTip.show('新增打样单失败!网络错误:'+err);
+                    });
+                },
+                procurementExport(selectAll){
+                    let url = '{{url('procurement/procurement/procurementExport')}}';
+                    let token='{{ csrf_token() }}';
+                    excelExport(selectAll,this.checkData,url,this.sum,token);
                 },
 
             }

+ 5 - 0
routes/web.php

@@ -729,12 +729,17 @@ Route::group(['prefix'=>'procurement'],function () {
         Route::post('createProcurement','ProcurementController@createProcurement');
         Route::post('createEnquiry','ProcurementController@createEnquiry');
         Route::post('createProof','ProcurementController@createProof');
+        Route::any('procurementExport','ProcurementController@procurementExport');
     });
     /** 财务 */
     Route::group(['prefix'=>'finance'],function(){
         Route::get('checkBill','ProcurementController@checkBill');
         Route::get('procurementBill','ProcurementController@procurementBill');
         Route::get('monthlyBillReport','ProcurementController@monthlyBillReport');
+        Route::post('fillInvoice','ProcurementController@fillInvoice');
+        Route::any('procurementTotalBillExport','ProcurementController@procurementTotalBillExport');
+        Route::any('procurementBillExport','ProcurementController@procurementBillExport');
+        Route::any('checkBillExport','ProcurementController@checkBillExport');
     });
     Route::get('relating',function (){return view('procurement.menuProcurement');});
 });