Эх сурвалжийг харах

采购管理页面调整,添加提前确定权限,并添加对应权限下功能

hu hao 5 жил өмнө
parent
commit
cf5e2cdce5

+ 4 - 0
app/Http/Controllers/ProcurementController.php

@@ -70,6 +70,7 @@ class ProcurementController extends Controller
         $procurements = Procurement::query()
             ->orderByDesc('id')
             ->filter($filters)
+            ->withCount('procurementQuotations')
             ->with(['initiator','ownerMaterial.file','ownerMaterial.material','supplier','ownerMaterial.owner'=>function($query)use($owner_ids){
                 $query->with('customer')->whereIn('id',$owner_ids);
             },'procurementDeliveries','procurementQuotations.supplier'])
@@ -80,6 +81,7 @@ class ProcurementController extends Controller
             })
             ->paginate($param['paginate'] ?? 50);
         foreach ($procurements as $procurement){
+            if ($procurement->procurement_quotations_count>0 && $procurement->status==0) $procurement->status=1;
             if (empty($procurement->procurementDeliveries))continue;
             if (Carbon::now()->gt($procurement['deadline'])){
                 $procurement->isFinishEnquiry=true;
@@ -348,6 +350,7 @@ class ProcurementController extends Controller
         $owner_ids=app('UserService')->getPermittingOwnerIds(auth()->user());
         $procurements = Procurement::query()
             ->filter($filters)
+            ->withCount('procurementQuotations')
             ->with(['initiator','ownerMaterial.material','ownerMaterial.owner'=>function($query)use($owner_ids){
                 $query->with('customer')->whereIn('id',$owner_ids);
             },'procurementDeliveries'])
@@ -358,6 +361,7 @@ class ProcurementController extends Controller
             })
             ->get();
         foreach ($procurements as $procurement){
+            if ($procurement->procurement_quotations_count>0 && $procurement->status==0) $procurement->status=1;
             if (empty($procurement->procurementDeliveries))continue;
             $procurement->deliver_amount=$procurement->procurementDeliveries->sum('amount');
         }

+ 12 - 23
app/Http/Controllers/TestController.php

@@ -1466,31 +1466,20 @@ TEXT;
 
     public function testProcurement()
     {
-        $procurementDeliveries=ProcurementDeliverie::query()
-            ->where('receipt_amount',0)
-            ->where('created_at','>=','2021-04-01 00:00:00')
-            ->where('created_at','<',Carbon::now()->toDateTimeString())
+        $procurementTotals = ProcurementTotalBill::query()
+            ->where('status', 1)
+            ->where('counting_month', '2021-04-01')
             ->get();
-        foreach ($procurementDeliveries as $procurementDelivery){
-            $procurementDelivery->update(['receipt_amount'=>$procurementDelivery->amount]);
-        }
-        $procurementCheckSheets=ProcurementCheckSheet::query()
-            ->with('procurementDelivery.procurement')
-            ->where('account_payable',0)
-            ->where('created_at','>=','2021-04-01 00:00:00')
-            ->where('created_at','<',Carbon::now()->toDateTimeString())
-            ->get();
-        foreach ($procurementCheckSheets as $procurementCheckSheet){
-            if ($procurementCheckSheet->id==913)continue;
-            $procurementCheckSheet->update(['account_payable'=>$procurementCheckSheet['procurementDelivery']['receipt_amount']*$procurementCheckSheet['procurementDelivery']['procurement']['cost_price']]);
+        foreach ($procurementTotals as $procurementTotalBill) {
+            /** @var  ProcurementTotalBill $procurementTotalBill */
+            $procurementTotalBill->setCurrentMothProcurements();
+            if (isset($procurementTotalBill->procurementCheckSheets)) {
+                $procurementCheckSheets = $procurementTotalBill->procurementCheckSheets;
+                foreach ($procurementCheckSheets as $procurementCheckSheet) {
+                    $procurementCheckSheet->update(['status' => 2]);//2 已出账
+                }
+            }
         }
-        $procurementCheckSheet=ProcurementCheckSheet::query()->find(914);
-        ProcurementTotalBill::query()->create([
-            'counting_month'=>'2021-05-01',
-            'supplier_id'=>84,
-            'status'=>0,
-            'total_payable'=>$procurementCheckSheet->account_payable,
-        ]);
     }
 }
 

+ 2 - 1
app/Http/Controllers/api/thirdPart/weixin/ProcurementController.php

@@ -223,7 +223,8 @@ class ProcurementController extends Controller
     public function markProcurementTotalBillStatus(Request $request): \Illuminate\Http\JsonResponse//供应商提交对账单
     {
         $id=$request->input('id');
-        $procurementTotalBill=ProcurementTotalBill::query()->find($id)->update(['status'=>1]);//1:已出账
+        $procurementTotalBill=ProcurementTotalBill::query()->find($id);
+        $procurementTotalBill->update(['status'=>1]);//1:已出账
         /** @var  ProcurementTotalBill $procurementTotalBill */
         $procurementTotalBill->setCurrentMothProcurements();
         if (isset($procurementTotalBill->procurementCheckSheets)){

+ 35 - 0
database/migrations/2021_05_11_113944_add_procurement_authorities.php

@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddProcurementAuthorities extends Migration
+{
+    protected $authorities = [
+        "采购管理-采购-提前确定",
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->authorities as $authority){
+            \App\Authority::query()->firstOrCreate(["name"=>$authority],["name"=>$authority,"alias_name"=>$authority]);
+        }
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        foreach ($this->authorities as $authority){
+            \App\Authority::query()->where("name",$authority)->delete();
+        }
+    }
+}

+ 1 - 1
resources/views/procurement/procurement/_addQuantity.blade.php

@@ -2,7 +2,7 @@
     <div class="modal-dialog modal-lg modal-dialog-centered">
         <div class="modal-content">
             <div class="modal-header">
-                <h5 class="modal-title text-center">添加采购数量和销售数量</h5>
+                <h5 class="modal-title text-center">完善采购数量和销售数量</h5>
                 <button type="button" class="close" data-dismiss="modal">
                     <span>&times;</span>
                 </button>

+ 36 - 24
resources/views/procurement/procurement/index.blade.php

@@ -66,19 +66,39 @@
                 <td>
                     <input class="checkItem" type="checkbox" :value="procurement.id">
                 </td>
-                <td><span>@{{ procurement.code }}</span></td>
+                <td><span class="text-center">@{{ procurement.code }}</span></td>
                 <td>
+                    <span v-if="procurement_status[procurement.status]!='订单取消'">
+                        <span class="btn btn-sm btn-outline-secondary" v-if="procurement.status<3"
+                              @click="cancel(procurement.id,procurement.type,procurement.code)">取消</span>
+                         @can('采购管理-采购-提前确定')
+                        <span class="btn btn-sm btn-outline-success" v-if="procurement_type[procurement.type]=='询价单' && procurement.status==1"
+                              @click="initiateProcurement(procurement)">发起采购</span>
+                        <span class="btn btn-sm btn-outline-info" v-if="procurement_type[procurement.type]=='采购单' && procurement.status==1"
+                              @click="initiateProcurement(procurement)">提前确定</span>
+                        @else
+                            <span class="btn btn-sm btn-outline-success" v-if="procurement_type[procurement.type]=='询价单' && procurement.isFinishEnquiry"
+                                  @click="initiateProcurement(procurement)">发起采购</span>
+{{--                            <span class="btn btn-sm btn-outline-info" v-if="procurement_type[procurement.type]=='采购单' && procurement.status==1"--}}
+{{--                                  @click="initiateProcurement(procurement)">提前确定</span>--}}
+                        @endcan
+                    </span>
+                </td>
+                <td class="text-center">
+                    <span :class="[procurement.type==1?'text-info font-weight-bold':procurement.type==2?'text-success font-weight-bold':'']">@{{ procurement_type[procurement.type] }}</span>
+                </td>
+                <td class="text-center">
                     <span :class="[procurement.status==10?'text-danger font-weight-bold':procurement.status==9?'text-success font-weight-bold':'']"  >@{{ procurement_status[procurement.status] }}</span>
                 </td>
-                <td><span v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.name }}</span></td>
-                <td>@{{ procurement_type[procurement.type] }}</td>
+
+                <td class="text-center text-muted"><span v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.name }}</span></td>
 {{--                <td><span v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.customer? procurement.owner_material.owner.customer.company_name:'' }}</span></td>--}}
-                <td class="tooltipTarget" style="max-width: 200px;overflow:hidden"><span v-if="procurement.owner_material">@{{ procurement.owner_material.material_code }}</span></td>
-                <td><span v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.name }}</span></td>
-                <td><span v-if="procurement.owner_material">@{{ procurement.owner_material.size }}</span></td>
-                <td><span v-if="procurement.owner_material">@{{ procurement.owner_material.special }}</span></td>
-                <td><span v-if="procurement.owner_material">@{{ procurement.owner_material.specification }}</span></td>
-                <td>
+                <td class="tooltipTarget text-center" style="max-width: 200px;overflow:hidden"><span v-if="procurement.owner_material">@{{ procurement.owner_material.material_code }}</span></td>
+                <td class="text-center text-muted"><span v-if="procurement.owner_material.material">@{{ procurement.owner_material.material.name }}</span></td>
+                <td class="text-center"><span v-if="procurement.owner_material">@{{ procurement.owner_material.size }}</span></td>
+                <td class="text-center text-muted"><span v-if="procurement.owner_material">@{{ procurement.owner_material.special }}</span></td>
+                <td class="text-center"><span v-if="procurement.owner_material">@{{ procurement.owner_material.specification }}</span></td>
+                <td class="text-center">
                     <div class="align-center text-center" >
                             <span v-if="procurement.owner_material.file">
                         <a target='_blank' :href="getDownFileUrl(procurement.owner_material)" class="text-primary text-decoration is-hover"  style="cursor: default" >
@@ -104,23 +124,15 @@
                         <b class="col-12" @click="unfold(i)" v-else>点击收起明细</b>
                     </div>
                 </td>
-                <td>@{{ procurement.quantity }}</td>
+                <td class="text-center">@{{ procurement.quantity }}</td>
 {{--                <td>--}}
 {{--                    <span v-if="procurement_type[procurement.type]=='询价单'">@{{ procurement.cost_price }}</span>--}}
 {{--                    <span >@{{ procurement.cost_price }}</span>--}}
 {{--                </td>--}}
-                <td><span>@{{ procurement.unit_price }}</span></td>
-                <td><span v-if="procurement.deliver_amount">@{{ procurement.deliver_amount }}</span></td>
-                <td><span>@{{ procurement.quantity*procurement.unit_price }}</span></td>
-                <td><span v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.customer? procurement.owner_material.owner.customer.phone:'' }}</span></td>
-                <td>
-                    <span v-if="procurement_status[procurement.status]!='订单取消'">
-                        <span class="btn btn-sm btn-outline-danger" v-if="procurement.status<3"
-                              @click="cancel(procurement.id,procurement.type,procurement.code)">取消</span>
-                        <span class="btn btn-sm btn-outline-success" v-if="procurement_type[procurement.type]=='询价单' && procurement.isFinishEnquiry"
-                              @click="initiateProcurement(procurement)">发起采购</span>
-                    </span>
-                </td>
+                <td class="text-center"><span>@{{ procurement.unit_price }}</span></td>
+                <td class="text-center"><span v-if="procurement.deliver_amount">@{{ procurement.deliver_amount }}</span></td>
+                <td class="text-center"><span>@{{ procurement.quantity*procurement.unit_price }}</span></td>
+                <td class="text-muted"><span v-if="procurement.owner_material.owner">@{{ procurement.owner_material.owner.customer? procurement.owner_material.owner.customer.phone:'' }}</span></td>
             </tr>
         </table>
         <div class="text-info h5 btn btn">{{$procurements->count()}}/@{{ sum }}</div>
@@ -216,9 +228,10 @@
                 this.form.init();
                 let column = [
                     {name: 'code', value: '采购编号', neglect: true,class: 'text-center'},
+                    {name: '操作', value: '操作', neglect: true,class: 'text-center'},
+                    {name: 'type', value: '单据类型', class: 'text-center'},
                     {name: '采购单状态', value: '采购单状态', neglect: true,class: 'text-center'},
                     {name: 'owner_id', value: '项目', class: 'text-center'},
-                    {name: 'type', value: '单据类型', class: 'text-center'},
                     // {name: 'company_name', value: '采购公司', class: 'text-center'},
                     {name: 'material_code', value: '耗材编号', class: 'text-center'},
                     {name: 'material_name', value: '耗材'},
@@ -237,7 +250,6 @@
                     {name: '送货数量', value: '送货数量', neglect: true,class: 'text-center'},
                     {name: '销售总价', value: '销售总价(元)', neglect: true,class: 'text-center'},
                     {name: '联系方式', value: '联系方式', neglect: true,class: 'text-center'},
-                    {name: '操作', value: '操作', neglect: true,class: 'text-center'},
                 ];
 
                 new Header({