Преглед на файлове

客户管理-项目列表字段精简
增加仓库小组的配置

Zhouzhendong преди 5 години
родител
ревизия
9ae328fc66

+ 0 - 1
app/Console/Commands/MakeServiceCommand.php

@@ -45,7 +45,6 @@ class MakeServiceCommand extends Command
             mkdir('app\\Services',666,false);
         }
         preg_match('/(.*?)Service/',$this->argument('name'),$resultNames);
-        var_dump($this->argument('name'),$resultNames);
         if(count($resultNames)==0) {
             $fileName = $this->argument('name');
             $modelName = $this->argument('name');

+ 9 - 5
app/Http/Controllers/CustomerController.php

@@ -93,11 +93,12 @@ class CustomerController extends Controller
         if(!Gate::allows('客户管理-项目-查询')){ return redirect('denied');  }
         /** @var OwnerService $service */
         $service = app('OwnerService');
-        $owners = $service->paginate(request()->input(),['customer',"contracts","userOwnerGroup","ownerStoragePriceModels","ownerAreaReport"=>function($query){
+        $owners = $service->paginate(request()->input(),['customer',"userOwnerGroup","userWorkGroup",
+            "ownerStoragePriceModels",/*"ownerAreaReport"=>function($query){
             $month = date('Y-m');
             /** @var Builder $query */
-            $query->where("counting_month","like",$month."%");
-        }]);
+           /*$query->where("counting_month","like",$month."%");
+        }*/]);
         $models = app('OwnerService')->getIntersectPermitting();
         $customers = app('CustomerService')->getSelection();
         $ownerGroups = app('UserOwnerGroupService')->getSelection();
@@ -157,9 +158,10 @@ class CustomerController extends Controller
         if(!Gate::allows('客户管理-项目-录入')){ return redirect('denied');  }
         $customers = app('CustomerService')->getSelection();
         $ownerGroups = app('UserOwnerGroupService')->getSelection();
+        $userGroups = app('UserWorkGroupService')->getSelection(["id","name","warehouse_id"]);
         $warehouses = app('WarehouseService')->getSelection();
         $owner = null;
-        return response()->view('customer.project.create',compact("customers","ownerGroups","owner","warehouses"));
+        return response()->view('customer.project.create',compact("customers","ownerGroups","owner","warehouses","userGroups"));
     }
 
     public function projectUpdate()
@@ -179,6 +181,7 @@ class CustomerController extends Controller
             "linkman"               => request("linkman"),
             "phone_number"          => request("phone_number"),
             "user_owner_group_id"   => request("owner_group_id"),
+            "user_workgroup_id"     => request("user_workgroup_id"),
             "waring_line_on"        => request("waring_line_on"),
             "description"           => request("description"),
         ]);
@@ -212,9 +215,10 @@ class CustomerController extends Controller
             $owner->owner_price_direct_logistics_count) $isExist = true;
         $customers = app('CustomerService')->getSelection();
         $ownerGroups = app('UserOwnerGroupService')->getSelection();
+        $userGroups = app('UserWorkGroupService')->getSelection(["id","name","warehouse_id"]);
         $warehouses = app('WarehouseService')->getSelection();
         $type = request("type");
-        return response()->view('customer.project.create',compact("customers","ownerGroups","warehouses",'owner',"isExist", "type"));
+        return response()->view('customer.project.create',compact("customers","ownerGroups","warehouses",'owner',"isExist", "type","userGroups"));
     }
 
     public function projectArea(Request $request)

+ 6 - 1
app/Owner.php

@@ -30,7 +30,8 @@ class Owner extends Model
         "user_owner_group_id",  //项目组ID
         "waring_line_on",       //月单量预警
         "description",          //描述
-        "warehouse_id"          //仓库ID
+        "warehouse_id",         //仓库ID
+        "user_workgroup_id"     //仓库小组(工作组)
     ];
 
     public static function filterAuthorities(){
@@ -79,6 +80,10 @@ class Owner extends Model
     {   //项目组
         return $this->hasOne(UserOwnerGroup::class,"id","user_owner_group_id");
     }
+    public function userWorkGroup()
+    {   //工作组
+        return $this->belongsTo(UserWorkgroup::class,"user_workgroup_id","id");
+    }
     public function ownerStoragePriceModels()
     {   //仓储计费
         return $this->belongsToMany(OwnerStoragePriceModel::class,"owner_storage_price_model_owner","owner_id","owner_storage_price_model_id");

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -89,6 +89,7 @@ use App\Services\WaybillFinancialService;
 use App\Services\WeighExceptedService;
 use App\Services\OrderFreezeService;
 use App\Services\RegionService;
+use App\Services\UserWorkGroupService;
 use Illuminate\Queue\Events\JobFailed;
 use Illuminate\Support\Facades\Queue;
 use Illuminate\Support\Facades\Schema;
@@ -224,6 +225,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('UnitService',UnitService::class);
         app()->singleton('UserOwnerGroupService',UserOwnerGroupService::class);
         app()->singleton('UserService',UserService::class);
+        app()->singleton('UserWorkGroupService',UserWorkGroupService::class);
         app()->singleton('WarehouseService',WarehouseService::class);
         app()->singleton('WaybillFinancialService',WaybillFinancialService::class);
         app()->singleton('WeighExceptedService',WeighExceptedService::class);

+ 20 - 0
app/Services/UserWorkGroupService.php

@@ -0,0 +1,20 @@
+<?php 
+
+namespace App\Services;
+
+use App\Traits\ServiceAppAop;
+use App\UserWorkGroup;
+
+class UserWorkGroupService
+{
+    use ServiceAppAop;
+    protected $modelClass=UserWorkGroup::class;
+
+    public function getSelection($column = ['id','name']){
+        if (!is_array($column)) {
+            $column = [$column];
+        }
+        return UserWorkGroup::query()->select($column)->get();
+    }
+
+}

+ 32 - 0
database/migrations/2021_02_19_155516_change_owners_table_add_column_user_workgroup_id.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class ChangeOwnersTableAddColumnUserWorkgroupId extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('owners', function (Blueprint $table) {
+            $table->bigInteger("user_workgroup_id")->nullable()->index()->comment("仓库小组");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('owners', function (Blueprint $table) {
+            $table->dropColumn("user_workgroup_id");
+        });
+    }
+}

+ 8 - 0
resources/views/customer/project/create.blade.php

@@ -94,6 +94,7 @@
                     customer_name : "{{ isset($owner) ? ($owner->customer ? $owner->customer->name : '') : ''}}",
                     owner_group_name : "{{ isset($owner) ? ($owner->userOwnerGroup ? $owner->userOwnerGroup->name : '') : ''}}",
                     owner_group_id : "{{$owner->user_owner_group_id ?? ''}}",
+                    user_workgroup_id : "{{$owner->user_workgroup_id ?? ''}}",
                     warehouse_id : "{{ $owner->warehouse_id ?? ''}}",
                     tax_rate : "{{$owner->tax_rate ?? ''}}",
                     linkman : "{{$owner->linkman ?? ''}}",
@@ -112,6 +113,11 @@
                     {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
                     @endforeach
                 ],
+                userGroups : [
+                    @foreach($userGroups as $userGroup)
+                    {id:"{{$userGroup->id}}",name:"{{$userGroup->name}}",warehouse_id:"{{$userGroup->warehouse_id}}"},
+                    @endforeach
+                ],
                 warehouses:[
                     @foreach($warehouses as $warehouse)
                     {id:"{{$warehouse->id}}",name:"{{$warehouse->name}}"},
@@ -379,6 +385,7 @@
                     let old = this.ownerTemp;
                     if (params.customer_id !== old.customer_id ||
                     params.owner_group_id !== old.owner_group_id ||
+                    params.user_workgroup_id !== old.user_workgroup_id ||
                     params.warehouse_id !== old.warehouse_id ||
                     params.tax_rate !== old.tax_rate ||
                     params.waring_line_on !== old.waring_line_on ||
@@ -395,6 +402,7 @@
                             this.errors = [];
                             this.ownerTemp.customer_id = res.customer_id;
                             this.ownerTemp.owner_group_id = res.owner_group_id;
+                            this.ownerTemp.user_workgroup_id = res.user_workgroup_id;
                             this.ownerTemp.warehouse_id = res.warehouse_id;
                             this.ownerTemp.tax_rate = res.tax_rate;
                             this.ownerTemp.waring_line_on = res.waring_line_on;

+ 29 - 49
resources/views/customer/project/index.blade.php

@@ -14,22 +14,22 @@
                                 <label class="text-dark font-weight-bold col-3"><span v-if="i==0">仓储:</span></label>
                                 <a target="_blank" :href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=storage'" class="text-decoration-none">@{{ model.counting_type }}-@{{ model.using_type }}</a>
                             </div>
-                            <hr class="m-1">
+                            <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceOperations'].length>0">
                             <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceOperations']">
                                 <label class="text-dark font-weight-bold col-3"><span v-if="i==0">作业:</span></label>
                                 <a target="_blank" :href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=operation'" class="text-decoration-none">@{{ model.name }}</a>
                             </div>
-                            <hr class="m-1">
+                            <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceExpresses'].length>0">
                             <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceExpresses']">
                                 <label class="text-dark font-weight-bold col-3"><span v-if="i==0">快递:</span></label>
                                 <a target="_blank" :href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=express'" class="text-decoration-none">@{{ model.name }}</a>
                             </div>
-                            <hr class="m-1">
+                            <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceLogistics'].length>0">
                             <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceLogistics']">
                                 <label class="text-dark font-weight-bold col-3"><span v-if="i==0">物流:</span></label>
                                 <a target="_blank" :href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=logistic'" class="text-decoration-none">@{{ model.name }}</a>
                             </div>
-                            <hr class="m-1">
+                            <hr class="m-1" v-if="priceModel[thisClickIndex]['ownerPriceDirectLogistics'].length>0">
                             <div class="row" v-for="(model,i) in priceModel[thisClickIndex]['ownerPriceDirectLogistics']">
                                 <label class="text-dark font-weight-bold col-3"><span v-if="i==0">直发车:</span></label>
                                 <a target="_blank" :href="'{{url('customer/project')}}/'+thisClickIndex+'/edit?type=directLogistic'" class="text-decoration-none">@{{ model.name }}</a>
@@ -66,31 +66,19 @@
                     <td>
                         <label><input type="checkbox" :value="owner.id" v-model="checkData"></label>
                     </td>
-                    <td>
-                        <a :href="'{{url('customer/project')}}/'+owner.id+'/edit'"><button class="btn btn-sm btn0sm btn-outline-info">编辑</button></a>
-                    </td>
-                    <td>@{{ owner.customer_name }}</td>
-                    <td>@{{ owner.tax_rate ? owner.tax_rate+'%' : '' }}</td>
                     <td>@{{ owner.name }}</td>
-                    <td>@{{ owner.code }}</td>
+                    <td>@{{ owner.customer_name }}</td>
+                    <td>@{{ owner.user_owner_group_name }}</td>
+                    <td>@{{ owner.user_work_group_name }}</td>
                     <td>@{{ owner.created_at }}</td>
-                    <td colspan="2">
-                        <div class="p-0">
-                            <small v-for="contract in owner.contracts">@{{ contract.number }}<label class="ml-2">@{{ contract.salesman }}</label><br></small>
-                        </div>
-                    </td>
                     <td>@{{ owner.customer_company_name }}</td>
-                    <td>@{{ owner.linkman }}</td>
-                    <td>@{{ owner.phone_number }}</td>
-                    <td>@{{ owner.user_owner_group_name }}</td>
+                    <td>@{{ owner.is_activation }}</td>
+                    <td>
+                        <a :href="'{{url('customer/project')}}/'+owner.id+'/edit'"><button class="btn btn-sm btn0sm btn-outline-info">编辑</button></a>
+                    </td>
                     <td>
                         <button class="btn btn-sm btn-info text-white" @click="showModal(owner)">各项计价</button>
                     </td>
-                    <td>@{{ owner.owner_storage_price_model_using_type }}</td>
-                    <td>@{{ owner.owner_area_report_accounting_area }}</td>
-                    <td>@{{ owner.waring_line_on }}</td>
-                    <td>@{{ owner.is_activation }}</td>
-                    <td>@{{ owner.description }}</td>
                 </tr>
             </table>
             {{$owners->appends($params)->links()}}
@@ -110,24 +98,25 @@
                     @foreach($owners as $owner)
                     {   id : "{{$owner->id}}",
                         customer_name:"{{$owner->customer ? $owner->customer->name : ''}}",
-                        tax_rate  : "{{$owner->tax_rate}}",
+                        //tax_rate  : "{{--{{$owner->tax_rate}}--}}",
                         name : "{{$owner->name}}",
-                        code : "{{$owner->code}}",
+                        //code : "{{--{{$owner->code}}--}}",
                         created_at : "{{$owner->created_at}}",
-                        contracts : [
-                            @foreach($owner->contracts as $contract)
+                        /*contracts : [
+                            {{--@foreach($owner->contracts as $contract)
                             { number:"{{$contract->contract_number}}",salesman:"{{$contract->salesman}}" },
-                            @endforeach
-                        ],
+                            @endforeach--}}
+                        ],*/
                         customer_company_name:"{{$owner->customer ? $owner->customer->company_name : ''}}",
-                        linkman:"{{$owner->linkman}}",
-                        phone_number:"{{$owner->phone_number}}",
+                        //linkman:"{{--{{$owner->linkman}}--}}",
+                        //phone_number:"{{--{{$owner->phone_number}}--}}",
                         user_owner_group_name:"{{$owner->userOwnerGroup ? $owner->userOwnerGroup->name : ''}}",
-                        owner_storage_price_model_using_type:"{{ implode(",",array_unique(array_column(($owner->ownerStoragePriceModels)->toArray(),"using_type")))  }}",
-                        owner_area_report_accounting_area : "{{ $owner->ownerAreaReport ? $owner->ownerAreaReport->accounting_area : '' }}",
-                        waring_line_on : "{{$owner->waring_line_on}}",
+                        user_work_group_name:"{{$owner->userWorkGroup ? $owner->userWorkGroup->name : ''}}",
+                        //owner_storage_price_model_using_type:"{{--{{ implode(",",array_unique(array_column(($owner->ownerStoragePriceModels)->toArray(),"using_type")))  }}--}}",
+                        //owner_area_report_accounting_area : "{{--{{ $owner->ownerAreaReport ? $owner->ownerAreaReport->accounting_area : '' }}--}}",
+                        //waring_line_on : "{{--{{$owner->waring_line_on}}--}}",
                         is_activation : "{{$owner->deleted_at ? '否' : '是'}}",
-                        description : "{{$owner->description}}",
+                        //description : "{{--{{$owner->description}}--}}",
                         ownerStoragePriceModels : {!! $owner->ownerStoragePriceModels !!},
                     },
                     @endforeach
@@ -175,24 +164,15 @@
                 let column = [
                     {name:'cloneCheckAll',customization:true,type:'checkAll',column:'id',
                         dom:$('#cloneCheckAll').removeClass('d-none'), neglect: true},
-                    {name:'operating',value: '操作', neglect: true},
-                    {name:'customer',value: '客户'},
-                    {name:'tax_rate',value: '税率%', neglect: true},
                     {name:'name',value: '项目'},
-                    {name:'code',value: '货主代码'},
+                    {name:'customer',value: '客户'},
+                    {name:'user_owner_group_name',value: '项目小组'},
+                    {name:'user_work_group_name',value: '仓库小组'},
                     {name:'created_at',value: '创建日期'},
-                    {name:'contract_number',value: '合同号', neglect: true},
-                    {name:'salesman',value: '销售名称', neglect: true},
                     {name:'customer_full_name',value: '公司全称'},
-                    {name:'linkman',value: '联系人'},
-                    {name:'phone_number',value: '联系电话'},
-                    {name:'workgroup',value: '项目小组'},
-                    {name:'relating_price',value: '关联报价', neglect: true},
-                    {name:'type',value: '用仓类型'},
-                    {name:'current_month_counting_area',value: '当月结算面积', neglect: true},
-                    {name:'waring_line_on',value: '月单量预警', neglect: true},
                     {name:'is_activating',value: '是否激活', neglect: true},
-                    {name:'description',value: '项目描述'},
+                    {name:'operating',value: '操作', neglect: true},
+                    {name:'relating_price',value: '关联报价', neglect: true},
                 ];
                 let _this=this;
                 setTimeout(function () {

+ 9 - 0
resources/views/customer/project/part/_two.blade.php

@@ -25,6 +25,15 @@
         <strong>@{{ errors.warehouse_id[0] }}</strong>
     </span>
 </div>
+<div class="row mt-3">
+    <label for="user_workgroup_id" class="col-2">仓库小组</label>
+    <select id="user_workgroup_id" v-model="owner.user_workgroup_id" @change="selectGroup()" class="form-control form-control-sm col-4 mb-0" :class="errors.user_workgroup_id ? 'is-invalid' : ''" >
+        <option v-for="userGroup in userGroups" :value="userGroup.id" v-if="userGroup.warehouse_id == owner.warehouse_id">@{{ userGroup.name }}</option>
+    </select>
+    <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.user_workgroup_id">
+        <strong>@{{ errors.user_workgroup_id[0] }}</strong>
+    </span>
+</div>
 <div class="row mt-3">
     <label for="tax_rate" class="col-2">税率<span class="badge badge-secondary">%</span></label>
     <input type="number" v-model="owner.tax_rate" step="0.01" id="tax_rate" class="form-control form-control-sm col-3 mb-0" :class="errors.tax_rate ? 'is-invalid' : ''">