Quellcode durchsuchen

客户管理日志记录,合同记录
订单管理-查询结果差异BUG修复

Zhouzhendong vor 5 Jahren
Ursprung
Commit
d8909e524f
35 geänderte Dateien mit 827 neuen und 128 gelöschten Zeilen
  1. 5 0
      app/Customer.php
  2. 9 6
      app/CustomerLog.php
  3. 3 0
      app/CustomerLogStatus.php
  4. 3 2
      app/Http/Controllers/CustomerBaseController.php
  5. 5 9
      app/Http/Controllers/CustomerController.php
  6. 24 50
      app/Http/Controllers/CustomerLogController.php
  7. 46 0
      app/Http/Controllers/CustomerLogStatusController.php
  8. 46 0
      app/Http/Controllers/OwnerContractController.php
  9. 8 0
      app/Http/Controllers/OwnerController.php
  10. 12 8
      app/Http/Controllers/TestController.php
  11. 19 0
      app/Observers/OwnerObserver.php
  12. 5 2
      app/Owner.php
  13. 28 0
      app/OwnerContract.php
  14. 12 2
      app/Providers/AppServiceProvider.php
  15. 34 0
      app/Services/CustomerLogService.php
  16. 33 0
      app/Services/CustomerLogStatusService.php
  17. 12 2
      app/Services/CustomerService.php
  18. 2 1
      app/Services/OrderService.php
  19. 34 4
      app/Services/OwnerService.php
  20. 1 1
      app/Services/WaybillService.php
  21. 1 1
      app/UploadFile.php
  22. 0 2
      database/factories/OwnerFactory.php
  23. 49 0
      database/migrations/2020_12_17_172306_create_owner_contracts_table.php
  24. 3 3
      resources/js/utilities/tempTip.js
  25. 16 0
      resources/sass/text.scss
  26. 47 0
      resources/views/customer/customer/_addContract.blade.php
  27. 37 1
      resources/views/customer/customer/_customerLog.blade.php
  28. 246 6
      resources/views/customer/customer/index.blade.php
  29. 12 6
      resources/views/customer/customerLogStatus/_edit.blade.php
  30. 40 3
      resources/views/customer/customerLogStatus/index.blade.php
  31. 0 10
      resources/views/customer/project/create.blade.php
  32. 12 6
      resources/views/customer/project/index.blade.php
  33. 1 1
      resources/views/maintenance/priceModel/express/index.blade.php
  34. 15 1
      routes/web.php
  35. 7 1
      文档/WAS项目规范.md

+ 5 - 0
app/Customer.php

@@ -24,4 +24,9 @@ class Customer extends Model
     {
         return $this->hasMany(CustomerLog::class,'customer_id','id');
     }
+
+    public function owners()
+    {   //子项目
+        return $this->hasMany(Owner::class,"customer_id","id");
+    }
 }

+ 9 - 6
app/CustomerLog.php

@@ -2,25 +2,28 @@
 
 namespace App;
 
+use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
 class CustomerLog extends Model
 {
+    use ModelTimeFormat;
+
     protected $fillable = ['customer_id', 'customer_log_status_id', 'user_id', 'description'];
     protected $guarded = ['id'];
 
-    public function customerLogStatus(): BelongsTo
-    {
-        return $this->belongsTo(CustomerLogStatus::class);
+
+    public function status()
+    {   //状态
+        return $this->belongsTo(CustomerLogStatus::class,"customer_log_status_id","id");
     }
 
-    public function user(): BelongsTo
+    public function user()
     {
         return $this->belongsTo(User::class);
     }
 
-    public function customer(): BelongsTo
+    public function customer()
     {
         return $this->belongsTo(Customer::class);
     }

+ 3 - 0
app/CustomerLogStatus.php

@@ -2,10 +2,13 @@
 
 namespace App;
 
+use App\Traits\ModelTimeFormat;
 use Illuminate\Database\Eloquent\Model;
 
 class CustomerLogStatus extends Model
 {
+    use ModelTimeFormat;
+
     protected $fillable = ['name', 'description'];
     protected $guarded = ['id'];
 }

+ 3 - 2
app/Http/Controllers/CustomerBaseController.php

@@ -13,12 +13,13 @@ class CustomerBaseController extends Controller
     /**
      * Display a listing of the resource.
      *
+     * @param Request $request
      * @return Response
      */
-    public function index()
+    public function index(Request $request)
     {
         if(!Gate::allows('客户-查询')){ return redirect('denied');  }
-        $customers = app('CustomerService')->paginate();
+        $customers = app('CustomerService')->paginate($request->input(),["owners.contracts.files"]);
         return response()->view('customer.customer.index',compact("customers"));
     }
 

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

@@ -89,7 +89,7 @@ class CustomerController extends Controller
         if(!Gate::allows('客户管理-项目-查询')){ return redirect('denied');  }
         /** @var OwnerService $service */
         $service = app('OwnerService');
-        $owners = $service->paginate(['customer_id'=>true],['customer',"userOwnerGroup","ownerStoragePriceModels","ownerAreaReport"=>function($query){
+        $owners = $service->paginate(['customer_id'=>true],['customer',"contracts","userOwnerGroup","ownerStoragePriceModels","ownerAreaReport"=>function($query){
             $month = date('Y-m');
             /** @var Builder $query */
             $query->where("counting_month","like",$month."%");
@@ -102,7 +102,7 @@ class CustomerController extends Controller
         if(!Gate::allows('客户管理-项目-查询')){ return redirect('denied');  }
         /** @var OwnerService $service */
         $service = app('OwnerService');
-        $withs = ['customer',"userOwnerGroup","ownerStoragePriceModels","ownerAreaReport"=>function($query){
+        $withs = ['customer',"userOwnerGroup","contracts","ownerStoragePriceModels","ownerAreaReport"=>function($query){
             $month = date('Y-m');
             /** @var Builder $query */
             $query->where("counting_month","like",$month."%");
@@ -112,7 +112,7 @@ class CustomerController extends Controller
         if ($request->checkAllSign ?? false) unset($params['checkAllSign']);
         else $params = ["id"=>$request->data ?? ''];
         $owners = $service->get($params,$withs);
-        $column = ["客户","税率","项目","货主代码","合同号","创建日期","销售名称","公司全称","联系人","联系电话","项目小组","用仓类型","当月结算面积","月单量预警","是否激活","项目描述"];
+        $column = ["客户","税率","项目","货主代码","创建日期","合同号","销售名称","公司全称","联系人","联系电话","项目小组","用仓类型","当月结算面积","月单量预警","是否激活","项目描述"];
         $list = [];
         foreach ($owners as $owner){
             $list[] = [
@@ -120,9 +120,9 @@ class CustomerController extends Controller
                 $owner->tax_rate,
                 $owner->name,
                 $owner->code,
-                $owner->contract_number,
                 $owner->created_at,
-                $owner->salesman,
+                implode("\r\n",array_column($owner->contracts,"contract_number")),
+                implode("\r\n",array_column($owner->contracts,"salesman")),
                 $owner->customer ? $owner->customer->company_name : '',
                 $owner->linkman,
                 $owner->phone_number,
@@ -174,8 +174,6 @@ class CustomerController extends Controller
             app('OwnerService')->update($owner,[
                 "customer_id"           => $params["customer_id"],
                 "tax_rate"              => $params["tax_rate"],
-                "contract_number"       => $params["contract_number"],
-                "salesman"              => $params["salesman"],
                 "linkman"               => $params["linkman"],
                 "phone_number"          => $params["phone_number"],
                 "user_owner_group_id"   => $params["owner_group_id"],
@@ -192,8 +190,6 @@ class CustomerController extends Controller
                 "code"                  => $params["code"],
                 "customer_id"           => $params["customer_id"],
                 "tax_rate"              => $params["tax_rate"],
-                "contract_number"       => $params["contract_number"],
-                "salesman"              => $params["salesman"],
                 "linkman"               => $params["linkman"],
                 "phone_number"          => $params["phone_number"],
                 "user_owner_group_id"   => $params["owner_group_id"],

+ 24 - 50
app/Http/Controllers/CustomerLogController.php

@@ -2,67 +2,41 @@
 
 namespace App\Http\Controllers;
 
-use App\Customer;
+
 use App\CustomerLog;
-use App\CustomerLogStatus;
-use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
 
 class CustomerLogController extends Controller
 {
-    public function __construct()
-    {
-        $this->middleware('auth');
-    }
-
-    public function index(Request $request)
-    {
-        $customerLog = CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$request->id) ->orderByDesc('updated_at')->paginate();
-        return view('customer.customerLog.index', compact('customerLog'));
-    }
-
-    public function show($customerLog_id)
-    {
-        $customerLog =CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$customerLog_id)->first();
-        return view('customer.customerLog.show', compact('customerLog'));
-    }
-
-    public function create(CustomerLog $customerLog)
+    public function get(Request $request)
     {
-        $customers = Customer::all();
-        $customerLogStatuses = CustomerLogStatus::all();
-        return view('customer.customerLog.createAndEdit', compact('customerLog', 'customers', 'customerLogStatuses'));
+        $customerId = $request->input("customer_id");
+        if (!$customerId)return ["success"=>false,"data"=>"非法参数"];
+        return ["success"=>true,"data"=>app("CustomerLogService")->get(["customer_id"=>$customerId],["status:id,name","user:id,name"])];
     }
 
-    public function store(Request $request): RedirectResponse
+    public function update(Request $request)
     {
-        $data = $request->all();
-        $data['user_id'] = auth()->id();
-        $customerLog = CustomerLog::query()->create($data);
-        return redirect()->route('customerLog.show', $customerLog->id)->with('message', 'Created successfully.');
+        $id = $request->input("id");
+        if (!$id) return ["success"=>false,"data"=>"非法参数"];
+        return ["success"=>true,"data"=>app("CustomerLogService")->update(["id"=>$id],["description"=>$request->input("description")])];
     }
 
-    public function edit(CustomerLog $customerLog)
+    public function store(Request $request)
     {
-        $this->authorize('update', $customerLog);
-        $customers = Customer::all();
-        $customerLogStatuses = CustomerLogStatus::all();
-        return view('customer.customerLog.createAndEdit', compact('customerLog', 'customers', 'customerLogStatuses'));
-    }
-
-    public function update(Request $request, CustomerLog $customerLog)
-    {
-        $this->authorize('update', $customerLog);
-        $customerLog->update($request->all());
-
-        return redirect()->route('customerLog.show', $customerLog->id)->with('message', 'Updated successfully.');
-    }
-
-    public function destroy(CustomerLog $customerLog)
-    {
-        $this->authorize('destroy', $customerLog);
-        $customerLog->delete();
-
-        return redirect()->route('customerLog.index')->with('message', 'Deleted successfully.');
+        $customerId = $request->input("customer_id");
+        $description = $request->input("description");
+        $customerLogStatusId = $request->input("customer_log_status_id");
+        if (!$customerId || !$description || !$customerLogStatusId)return ["success"=>false,"data"=>"检查您的输入"];
+        /** @var CustomerLog $log */
+        $log = app("CustomerLogService")->create([
+            "customer_id" => $customerId,
+            "description" => $description,
+            "customer_log_status_id" => $customerLogStatusId,
+            "user_id" => Auth::id(),
+        ]);
+        $log->load(["status:id,name","user:id,name"]);
+        return ["success"=>true,"data"=>$log];
     }
 }

+ 46 - 0
app/Http/Controllers/CustomerLogStatusController.php

@@ -3,6 +3,9 @@
 namespace App\Http\Controllers;
 
 use App\CustomerLogStatus;
+use App\Services\LogService;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Validator;
 
 
 class CustomerLogStatusController extends Controller
@@ -17,4 +20,47 @@ class CustomerLogStatusController extends Controller
         $customerLogStatuses = CustomerLogStatus::query()->paginate();
         return view('customer.customerLogStatus.index', compact('customerLogStatuses'));
     }
+
+    public function get()
+    {
+        return ["success"=>true,"data"=>app("CustomerLogStatusService")->getSelection()];
+    }
+
+    public function save(Request $request)
+    {
+        $errors = $this->validator($request->input(),$request->input("id"))->errors();
+        if (count($errors) > 0)return ["success"=>true,"data"=>["errors"=>$errors]];
+        if ($request->input("id")){
+            app("CustomerLogStatusService")->update(["id"=>$request->input("id")],
+                ["name"=>$request->input("name"),"description"=>$request->input("description")]);
+            LogService::log(__METHOD__,"修改客户状态",json_encode($request->input(),JSON_UNESCAPED_UNICODE));
+            return ["success"=>true];
+        }
+        /** @var CustomerLogStatus $model */
+        $model = app("CustomerLogStatusService")->create(["name"=>$request->input("name"),"description"=>$request->input("description")]);
+        LogService::log(__METHOD__,"录入客户状态",$model->toJson());
+        return ["success"=>true,"data"=>$model];
+    }
+
+    private function validator($params, $id)
+    {
+        return Validator::make($params,[
+            "name" => ['max:50','required',$id?"unique:customer_log_statuses,name,$id":'unique:customer_log_statuses,name']
+        ],[
+            'required'=>':attribute 为必填项',
+            'max'=>':attribute 最大为50个字符',
+            'unique'=>':attribute 已存在',
+        ],[
+            "name" => "名称"
+        ]);
+    }
+
+    public function destroy(Request $request)
+    {
+        $id = $request->input("id");
+        if (!$id) return ["success"=>false,"data"=>"非法参数!"];
+        app("CustomerLogStatusService")->destroy($request->input("id"));
+        LogService::log(__METHOD__,"删除客户状态",$id);
+        return ["success"=>true];
+    }
 }

+ 46 - 0
app/Http/Controllers/OwnerContractController.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\OwnerContract;
+use App\UploadFile;
+use Faker\Provider\Uuid;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Gate;
+
+class OwnerContractController extends Controller
+{
+    public function store(Request $request)
+    {
+        if(!Gate::allows('客户-编辑')){ return ['success'=>false,"data"=>"无权操作"];  }
+        $owner_id = $request->input("owner_id");
+        $contract_number = $request->input("contract_number");
+        if (!$owner_id || !$contract_number)return ["success"=>false,"data"=>"非法参数"];
+        $remark = $request->input("remark");
+        $contract = OwnerContract::query()->create([
+            "owner_id" => $owner_id,
+            "contract_number" => $contract_number,
+            "salesman" => Auth::user()['name'],
+            "remark" => $remark,
+        ]);
+        $files = $request->file("files");
+        if ($files){
+            $uploadFiles = [];
+            foreach ($files as $file){
+                $suffix = strtolower($file->getClientOriginalExtension());
+                $path = $file->storeAs("contract",Uuid::uuid().".".$suffix);
+                $uploadFiles[] = [
+                    "table_name"    => "contracts",
+                    "table_id"      => $contract->id,
+                    "url"           => $path,
+                    "type"          => $suffix,
+                    "file_name"     => $file->getClientOriginalName(),
+                ];
+            }
+            UploadFile::query()->insert($uploadFiles);
+        }
+        $contract->load(["owner","files"]);
+        return ["success"=>true,"data"=>$contract];
+    }
+}

+ 8 - 0
app/Http/Controllers/OwnerController.php

@@ -170,4 +170,12 @@ class OwnerController extends Controller
         app('LogService')->log(__METHOD__, __FUNCTION__, json_encode($request->toArray()), Auth::user()['id']);
         return ['success' => 'true', 'owner' => $owner];
     }
+
+    public function get(Request $request)
+    {
+        $params = [
+            "customer_id" => $request->input("customer_id"),
+        ];
+        return ["success"=>true,"data"=>app("OwnerService")->get($params)];
+    }
 }

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

@@ -106,26 +106,30 @@ class TestController extends Controller
     }
     public function zzd()
     {
-        $row = 1;
         foreach (StoreItems::query()->with(["depository","store"])->where("store_id",0)->cursor() as  $flight){
             $sql = <<<sql
  select ASNNO from DOC_ASN_DETAILS left join bas_sku on DOC_ASN_DETAILS.SKU= BAS_SKU.SKU 
  WHERE asnlineno = ? AND skudescrc = ? 
- AND BAS_SKU.sku = ? AND alternate_sku1 = ? AND expectedqty_each = ?
+ AND BAS_SKU.sku = ? AND alternate_sku1 = ? AND expectedqty_each = ? and LINESTATUS = '99'
 sql;
             $param = [$flight->asn_line_code,$flight->name,$flight->sku,$flight->barcode,$flight->amount];
 if ($flight->depository)$sql.= " AND LOTATT05 = '".$flight->depository->code."' ";
 else $sql .="  AND LOTATT05 IS NULL";
-            $r = DB::connection("oracle")->selectOne(DB::raw($sql),$param);
-            if ($r){
-                $store = Store::query()->where("asn_code",$r->asnno)->first();
+            $r = DB::connection("oracle")->select(DB::raw($sql),$param);
+            $dd = [];
+            foreach ($r as $data){
+                $store = Store::query()->where("asn_code",$data->asnno)->where("stored_method","快速入库")->first();
                 if ($store){
-                    $row = StoreItems::query()->where("id",$flight->id)->where("store_id",0)->update(["store_id"=>$store->id]);
+                    $dd[] = $store->id;
+                }
+            }
+            if($dd){
+                if (count($dd) == 1){
+                    StoreItems::query()->where("id",$flight->id)->where("store_id",0)->update(["store_id"=>$dd[0]]);
+                    echo "更改ID“".$flight->id."”的store_id为:".$dd[0]."<br>";
                 }
             }
-            $row++;
         }
-        echo "已处理:".$row."<br/>";
     }
 
     public function mergeCarrier(){

+ 19 - 0
app/Observers/OwnerObserver.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Observers;
+
+use App\Owner;
+
+class OwnerObserver
+{
+    /**
+     * 监听插入事件
+     *
+     * @param  \App\Owner  $owner
+     * @return void
+     */
+    public function created(Owner $owner)
+    {
+        app("OwnerService")->syncPush($owner);
+    }
+}

+ 5 - 2
app/Owner.php

@@ -21,8 +21,6 @@ class Owner extends Model
         'deleted_at',           //删除时间
         "customer_id",          //客户ID
         "tax_rate",             //税率
-        "contract_number",      //合同号
-        "salesman",             //销售名称
         "linkman",              //联系人
         "phone_number",         //联系电话
         "user_owner_group_id",  //项目组ID
@@ -60,6 +58,11 @@ class Owner extends Model
         return $this->belongsTo(OrderTrackingOwner::class,'id','owner_id');
     }
 
+    public function contracts()
+    {   //合同
+        return $this->hasMany(OwnerContract::class,"owner_id","id");
+    }
+
     public function order(){
         return $this->hasOne(Order::class,'owner_id','id');
     }

+ 28 - 0
app/OwnerContract.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App;
+
+use App\Traits\ModelTimeFormat;
+use Illuminate\Database\Eloquent\Model;
+
+class OwnerContract extends Model
+{
+    use ModelTimeFormat;
+
+    protected $fillable=[
+        "contract_number",  //合同号
+        "salesman",         //销售名称
+        "remark",           //备注
+        "owner_id",         //外键货主
+    ];
+
+    public function files()
+    {   //合同文件
+        return $this->hasMany(UploadFile::class,"table_id","id")
+            ->where("table_name","contracts");
+    }
+    public function owner()
+    {   //货主
+        return $this->belongsTo(Owner::class,"owner_id","id");
+    }
+}

+ 12 - 2
app/Providers/AppServiceProvider.php

@@ -3,6 +3,8 @@
 namespace App\Providers;
 
 use App\Http\Controllers\Controller;
+use App\Observers\OwnerObserver;
+use App\Owner;
 use App\Services\AuthorityService;
 use App\Services\BatchService;
 use App\Services\CacheService;
@@ -10,6 +12,8 @@ use App\Services\CommodityService;
 use App\Services\common\BatchUpdateService;
 use App\Services\CommodityBarcodeService;
 use App\Services\common\DataHandlerService;
+use App\Services\CustomerLogService;
+use App\Services\CustomerLogStatusService;
 use App\Services\CustomerService;
 use App\Services\DepositoryService;
 use App\Services\FeatureService;
@@ -103,6 +107,7 @@ class AppServiceProvider extends ServiceProvider
     public function boot()
     {
         $this->loadingService();
+        $this->loadEvent();
         //
         Schema::defaultStringLength(191);
         Queue::failing(function (JobFailed $event) {
@@ -195,8 +200,13 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('WarehouseService',WarehouseService::class);
         app()->singleton('WaybillFinancialService',WaybillFinancialService::class);
         app()->singleton('WeighExceptedService',WeighExceptedService::class);
-
+        app()->singleton('CustomerLogStatusService',CustomerLogStatusService::class);
+        app()->singleton('CustomerLogService',CustomerLogService::class);
+        app()->singleton('CustomerLogService',CustomerLogService::class);
     }
 
-
+    private function loadEvent()
+    {
+        Owner::observe(OwnerObserver::class);
+    }
 }

+ 34 - 0
app/Services/CustomerLogService.php

@@ -0,0 +1,34 @@
+<?php 
+
+namespace App\Services; 
+
+use App\CustomerLog;
+
+Class CustomerLogService
+{ 
+    public function get(array $params, array $withs=[])
+    {
+        $query = CustomerLog::query()->with($withs)->orderByDesc('id');
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->get();
+    }
+
+    public function update(array $params, array $values)
+    {
+        $query = CustomerLog::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->update($values);
+    }
+
+    public function create(array $values)
+    {
+        return CustomerLog::query()->create($values);
+    }
+
+}

+ 33 - 0
app/Services/CustomerLogStatusService.php

@@ -0,0 +1,33 @@
+<?php 
+
+namespace App\Services; 
+
+use App\CustomerLogStatus;
+
+Class CustomerLogStatusService
+{ 
+    public function update(array $params, array $values)
+    {
+        $query = CustomerLogStatus::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->update($values);
+    }
+
+    public function create(array $values)
+    {
+        return CustomerLogStatus::query()->create($values);
+    }
+
+    public function destroy($id)
+    {
+        return CustomerLogStatus::destroy($id);
+    }
+
+    public function getSelection(array $column = ["id","name"])
+    {
+        return CustomerLogStatus::query()->get($column);
+    }
+}

+ 12 - 2
app/Services/CustomerService.php

@@ -3,6 +3,8 @@
 namespace App\Services;
 
 use App\Customer;
+use App\Services\common\QueryService;
+use Illuminate\Database\Eloquent\Builder;
 
 Class CustomerService
 {
@@ -11,9 +13,17 @@ Class CustomerService
         return Customer::query()->select($column)->get();
     }
 
-    public function paginate($paginate = 50)
+    public function paginate(array $params, array $withs=[])
     {
-        return Customer::query()->orderByDesc('id')->paginate($paginate);
+        $query = Customer::query()->with($withs)->orderByDesc('id');
+        $columnQueryRules=[
+            'company_name' => ['like' => ''],
+            'contact_man' => ['like' => ''],
+            'phone' => ['multi' => ','],
+        ];
+        /** @var Builder $query */
+        $query = app(QueryService::class)->query($params,$query,$columnQueryRules,"customers");
+        return $query->paginate($params["paginate"] ?? 50);
     }
 
     public function create(array $params)

+ 2 - 1
app/Services/OrderService.php

@@ -113,7 +113,7 @@ class OrderService
         }
         if ($alternate_sku1){
             if ($checkAllSign) $detailsOrderno = $this->getOrdersNo($alternate_sku1,false);
-            else $detailsOrderno = $this->getOrdersNo($alternate_sku1,true, $request->page ?? 1, $request->paginate ?? 50);
+            else $detailsOrderno = $this->getOrdersNo($alternate_sku1,true, $params['page'] ?? 1, $params['paginate'] ?? 50);
             if (count($detailsOrderno)>0){
                 $sql.=' AND orderno IN (';
                 foreach ($detailsOrderno as $index => $no){
@@ -266,6 +266,7 @@ class OrderService
                 $sql.=")";
             }
         }
+        if (isset($params["alternate_sku1"]))$page = 1;
         if ($paginate && $page)$sql.=" and ROWNUM<='".$page*$paginate."')";
         if ($paginate && $page)$sql.=" header where header.rn>'".($page-1)*$paginate."' ";
         $sql.=")DOC_ORDER_HEADER left join DOC_ORDER_DETAILS on DOC_ORDER_DETAILS.ORDERNO=DOC_ORDER_HEADER.ORDERNO

+ 34 - 4
app/Services/OwnerService.php

@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Collection;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
 
 Class OwnerService
 {
@@ -180,8 +181,7 @@ Class OwnerService
         if ($withs)$query->with($withs);
         if ($authority){
             $ids = $user->getPermittingOwnerIdsAttribute();
-            if ($ids) $query->whereIn("id",$ids);
-            else return null;
+            $query->whereIn("id",$ids);
         }
         if ($notShowSoftDelete) $query->whereNull('deleted_at');
         $query = $this->query($query,$params);
@@ -196,8 +196,7 @@ Class OwnerService
         if ($withs)$query->with($withs);
         if ($authority){
             $ids = $user->getPermittingOwnerIdsAttribute();
-            if ($ids) $query->whereIn("id",$ids);
-            else return null;
+            $query->whereIn("id",$ids);
         }
         if ($notShowSoftDelete) $query->whereNull('deleted_at');
         $query = $this->query($query,$params);
@@ -245,4 +244,35 @@ Class OwnerService
             return Owner::query()->firstOrCreate(["code"=>$code],["code"=>$code,"name"=>$code]);
         });
     }
+
+    /**
+     * 向FLUX同步推送WAS本地录入信息
+     *
+     * @param array|Owner|integer $owner
+     * @return bool
+     */
+    public function syncPush($owner)
+    {
+        if (is_array($owner)){
+            $owner = new Owner();
+            foreach ($owner as $column=>$value){
+                $owner[$column] = $value;
+            }
+        }
+        if (is_numeric($owner)){
+            $owner = Owner::query()->find($owner);
+            if (!$owner)return false;
+        }
+        $wms = DB::connection("oracle")->selectOne(DB::raw("SELECT CUSTOMERID FROM BAS_CUSTOMER WHERE CUSTOMER_TYPE = ? AND CUSTOMERID = ?"),["OW",$owner->code]);
+        if (!$wms && $owner->code){
+            $query = DB::raw(<<<sql
+    INSERT INTO BAS_CUSTOMER(CUSTOMERID,CUSTOMER_TYPE,DESCR_C,ADDTIME,EDITTIME)
+        VALUES(?,?,?,TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'),TO_DATE(?,'yyyy-mm-dd hh24:mi:ss'))
+sql
+            );
+            $date = date('Y-m-d H:i:s');
+            DB::connection("oracle")->insert($query,[$owner->code,'OW',$owner->name,$date,$date]);
+        }
+        return true;
+    }
 }

+ 1 - 1
app/Services/WaybillService.php

@@ -40,7 +40,7 @@ Class WaybillService
             'uriType' => ['alias' => 'type'],
             'id' => ['multi' => ','],
         ];
-        $waybills = app(QueryService::class)->query($param,$waybills,$columnQueryRules,"waybills");//dd($waybills->sql());
+        $waybills = app(QueryService::class)->query($param,$waybills,$columnQueryRules,"waybills");
         return $waybills;
     }
 

+ 1 - 1
app/UploadFile.php

@@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
 class UploadFile extends Model
 {
     protected $fillable=[
-        'table_name','table_id','url','type'
+        'table_name','table_id','url','type',"name"
     ];
 }

+ 0 - 2
database/factories/OwnerFactory.php

@@ -11,8 +11,6 @@ $factory->define(Owner::class, function (Faker $faker) {
         'code' => \Illuminate\Support\Str::random(5).date('yymmdd'),                 //代码
         'checking_count' => mt_rand(0,5),       //审核数量
         "tax_rate" => mt_rand(0,100) / 10,             //税率
-        "contract_number" => \Illuminate\Support\Str::random(5).date('yymmdd'),      //合同号
-        "salesman" => $faker->name,             //销售名称
         "linkman" => $faker->name,              //联系人
         "phone_number" => $faker->phoneNumber,         //联系电话
         "user_owner_group_id" => factory(\App\UserOwnerGroup::class),  //项目组ID

+ 49 - 0
database/migrations/2020_12_17_172306_create_owner_contracts_table.php

@@ -0,0 +1,49 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateOwnerContractsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('owner_contracts', function (Blueprint $table) {
+            $table->id();
+            $table->string("contract_number",30)->index()->comment("合同号");
+            $table->string("salesman",20)->comment("销售名称");
+            $table->string("remark")->comment("备注");
+            $table->bigInteger("owner_id")->comment("外键货主");
+            $table->timestamps();
+        });
+        Schema::table("owners",function (Blueprint $table){
+            $table->dropColumn("contract_number");
+            $table->dropColumn("salesman");
+        });
+        Schema::table("upload_files",function (Blueprint $table){
+            $table->string("file_name")->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('owner_contracts');
+        Schema::table("owners",function (Blueprint $table){
+            $table->string('contract_number')->nullable()->comment('合同号');
+            $table->string('salesman')->nullable()->comment('销售名称');
+        });
+        Schema::table("upload_files",function (Blueprint $table){
+            $table->dropColumn("file_name");
+        });
+    }
+}

+ 3 - 3
resources/js/utilities/tempTip.js

@@ -117,11 +117,11 @@ const tempTip={
         $('body').append(tiper);
         $input.focus()
     },
-    postBasicRequest(url, params, successMsg, successExe, isPriority = false) {
+    postBasicRequest(url, params, successExe, isPriority = false) {
         if (isPriority)this.setIndex(1099);
         window.axios.post(url,params).then(res=> {
             if (res.data.success){
-                successExe(res.data.data);
+                let successMsg = successExe(res.data.data);
                 if (successMsg){
                     this.setDuration(2000);
                     this.showSuccess(successMsg);
@@ -130,7 +130,7 @@ const tempTip={
             }
             this.setDuration(3000);
             this.show(res.data.data);
-        }).catch(function (err) {
+        }).catch(err=> {
             this.setDuration(3000);
             this.show('网络异常:'+err);
         });

+ 16 - 0
resources/sass/text.scss

@@ -59,4 +59,20 @@
 .cursor-pointer{
     color: dodgerblue;
     cursor: pointer;
+}
+
+.text-overflow-replace{
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    pointer-events: none
+}
+
+.form-font{
+    margin-bottom: 1.5px;
+    padding-top: 0.3rem;
+    text-align: center;
+    border: 1px solid rgba(0,0,0,.2);
+    border-radius: 0.3rem;
+    margin-right: 0;
 }

+ 47 - 0
resources/views/customer/customer/_addContract.blade.php

@@ -0,0 +1,47 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="addContract">
+    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <div class="container-fluid">
+                    <div class="row">
+                        <label class="col-2" for="owner">所属项目</label>
+                        <span class="fa fa-edit col-1 form-font"></span>
+                        <select id="owner" type="text" class="form-control form-control-sm ml-0 col-5" v-if="index !== ''">
+                            <option v-for="owner in owners[customers[index].id]" :value="owner.id">@{{ owner.name }}</option>
+                        </select>
+                    </div>
+                    <div class="row mt-2">
+                        <label class="col-2" for="contract_number">合同号</label>
+                        <span class="fa fa-pencil col-1 form-font"></span>
+                        <input id="contract_number" type="text" class="form-control form-control-sm ml-0 col-7">
+                    </div>
+                    <div class="row mt-2">
+                        <label class="col-2" for="files">合同附件</label>
+                        <input id="files" hidden multiple="multiple" type="file" @change="uploadFiles($event)">
+                        <div class="col-7 pl-0">
+                            <p v-for="(file,i) in files" class="border w-100 p-1" style="border-radius: 0.3rem">
+                                <span class="fa fa-file ml-1"></span>&nbsp; @{{ file.name }}(<span class="text-primary">@{{ file.size | size }}</span>)
+                                <span class="pull-right cursor-pointer text-danger close" @click="deleteFile(i)">&times;</span>
+                            </p>
+                            <p><button class="btn btn-success" @click="selectFile()">
+                                    <span class="fa fa-files-o"></span>&nbsp;
+                                    <span v-if="files && files.length>0">继续上传</span>
+                                    <span v-else>选择文件</span>
+                            </button></p>
+                        </div>
+                    </div>
+                    <div class="row mt-2">
+                        <label class="col-2" for="remark">合同备注</label>
+                        <textarea class="form-control form-control-sm col-8" id="remark"></textarea>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-success" @click="submitContract()">提交</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 37 - 1
resources/views/customer/customer/_customerLog.blade.php

@@ -2,7 +2,43 @@
     <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
         <div class="modal-content">
             <div class="modal-header">
-
+                <button type="button" class="btn btn-outline-info pull-left" @click="addLog()">新增</button>
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <table class="table table-sm table-hover table-striped" v-if="index !== ''">
+                    <tr>
+                        <th>状态</th>
+                        <th>操作者</th>
+                        <th>说明</th>
+                        <th>操作时间</th>
+                    </tr>
+                    <tr v-for="(log,i) in customerLogs[customers[index]['id']]">
+                        <td>
+                            <select id="logStatusName" v-if="!log.id" class="form-control form-control-sm" :id="'logStatus-'+log.id">
+                                <option v-for="logStatus in logStatuses" :value="logStatus.id">@{{ logStatus.name }}</option>
+                            </select>
+                            <label v-else for="logStatusName">
+                                @{{ log.status.name }}
+                            </label>
+                        </td>
+                        <td>@{{ log.user.name }}</td>
+                        <td style="max-width: 100px" class="cursor-pointer" @mouseenter="textClass($event,true)" @mouseleave="textClass($event,false)">
+                            <div class="text-overflow-replace" v-if="currentLogIndex !== i" @click="edit(i,log.user)">
+                                @{{ log.description }}
+                            </div>
+                            <div v-if="currentLogIndex === i && i===0">
+                                <textarea class="form-control form-control-sm" v-text="log.description" :id="'description-'+log.id"></textarea>
+                            </div>
+                        </td>
+                        <td>@{{ log.created_at }}</td>
+                    </tr>
+                </table>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-success" v-if="currentLogIndex !== ''" @click="editLog()">保存</button>
+                <button type="button" class="btn btn-danger" v-if="currentLogIndex !== ''" @click="closeEditLog()">取消</button>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
             </div>
         </div>
     </div>

+ 246 - 6
resources/views/customer/customer/index.blade.php

@@ -6,12 +6,14 @@
         @component('customer.menu')@endcomponent
         @component('customer.customer.menu')@endcomponent
     </div>
-    <div class="container-fluid card" id="container">
+    <div class="d-none container-fluid card" id="container">
         <div class="card-body mt-2">
+            <div id="form_div" class="mb-2"></div>
             @if(Session::has('successTip'))
                 <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
             @endif
             @include("customer.customer._customerLog")
+            @include("customer.customer._addContract")
             <table class="table table-striped table-hover text-nowrap">
                 <tr>
                     <th>序号</th>
@@ -27,7 +29,7 @@
                     <th>创建时间</th>
                     <th>操作</th>
                 </tr>
-                <tr v-for="(customer,i) in customers">
+                <tr v-for="(customer,i) in customers" :id="'model-'+customer.id">
                     <td>@{{ i+1 }}</td>
                     <td>@{{ customer.code }}</td>
                     <td>@{{ customer.name }}</td>
@@ -36,11 +38,15 @@
                     <td>@{{ customer.contact_man }}</td>
                     <td>@{{ customer.phone }}</td>
                     <td>@{{ customer.remark }}</td>
-                    <td><span class="cursor-pointer" data-toggle="modal" data-target="#modal">查看</span></td>
-                    <td>#</td>
+                    <td><span class="cursor-pointer" @click="showCustomerLog(customer.id,i)">查看</span></td>
+                    <td v-if="customer.contractQuantity>0" class="cursor-pointer" @click="showContract(customer.id)"><span class="fa" :class="contractIds['_'+customer.id] === true ? 'fa-angle-double-down' : 'fa-angle-double-right'"></span>@{{ customer.contractQuantity }}份合同</td>
+                    <td v-else>#</td>
                     <td>@{{ customer.created_at }}</td>
                     <td>
-                        @can("客户-编辑")<a :href="'{{url('customer/customer')}}/'+customer.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>@endcan
+                        @can("客户-编辑")
+                            <button class="btn btn-sm btn-outline-success" @click="addContract(i)">新建合同</button>
+                            <a :href="'{{url('customer/customer')}}/'+customer.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>
+                        @endcan
                         @can("客户-删除")<button class="btn btn-sm btn-outline-danger" @click="destroy(customer.id,i,customer.name)">删</button>@endcan
                     </td>
                 </tr>
@@ -50,13 +56,68 @@
 @stop
 
 @section('lastScript')
+    <script type="text/javascript" src="{{mix('js/queryForm/queryForm.js')}}"></script>
     <script>
         new Vue({
             el:"#container",
             data:{
-                customers :  {!!  $customers->toJson() !!}['data']
+                customers :  {!!  $customers->toJson() !!}['data'],
+                customerLogs : [],
+                index:'',
+                currentLogIndex:"",
+                logStatuses:[],
+                contractIds:[],
+                owners:[],
+                files:[],
+            },
+            mounted(){
+                $('#container').removeClass('d-none');
+                this.rendering();
+                let data=[
+                    [
+                        {name:'company_name',type:'input',tip:'可在检索值前加百分号(%)进行模糊搜索',placeholder:'公司名称'},
+                        {name:'contact_man',type:'input',tip:'可在检索值前加百分号(%)进行模糊搜索',placeholder:'联系人'},
+                        {name:'phone',type:'input',tip:'可在检索值前加百分号(%)进行模糊搜索',placeholder:'联系电话'},
+                    ]
+                ];
+                new query({
+                    el:"#form_div",
+                    condition:data,
+                }).init();
             },
             methods:{
+                selectFile(){
+                    $("#files").click();
+                },
+                uploadFiles(event){
+                    let files = event.target.files;
+                    for(let i=0;i<files.length;i++){
+                        this.files.push(files[i]);
+                    }
+                },
+                deleteFile(index){
+                    this.$delete(this.files,index);
+                },
+                rendering() {
+                    this.customers.forEach((customer,i)=> {
+                        let contracts = [];
+                        if (customer.owners)
+                        customer.owners.forEach(owner=> {
+                            if (owner.contracts)
+                            owner.contracts.forEach(contract=>{
+                                contracts.push({
+                                    number:contract.contract_number,
+                                    salesman:contract.salesman,
+                                    remark:contract.remark,
+                                    ownerName:owner.name,
+                                    files:contract.files ? contract.files : []});
+                            });
+                        });
+                        customer["contractQuantity"] = contracts.length;
+                        this._renderingHtml(customer.id,contracts);
+                    });
+                    this.$forceUpdate();
+                },
                 destroy(id,index,name){
                     window.tempTip.confirm("确定要删除"+name+"吗?",()=>{
                         window.axios.delete("{{url('customer/customer')}}/"+id)
@@ -75,6 +136,185 @@
                         })
                     })
                 },
+                showCustomerLog(id,index){
+                    this.index = index;
+                    if (this.customerLogs[id]){
+                        $("#modal").modal('show');
+                        return;
+                    }
+                    let url="{{url('customer/customer/getLog')}}";
+                    let params = {customer_id:id};
+                    window.tempTip.postBasicRequest(url,params,(res)=> {
+                        this.customerLogs[id] = res;
+                        this.$forceUpdate();
+                        $("#modal").modal('show');
+                    });
+                },
+                textClass(event,isOver){
+                    event = event.target.children[0];
+                    if (isOver){event.classList.remove("text-overflow-replace");}
+                    else {event.classList.add("text-overflow-replace");}
+                },
+                edit(index,user){
+                    let id = "{{\Illuminate\Support\Facades\Auth::id()}}";
+                    if (id != user.id) return;
+                    if (index === 0)this.currentLogIndex=index;
+                    else this.currentLogIndex='';
+                },
+                closeEditLog(){
+                    this.currentLogIndex = '';
+                    if (this.customerLogs[this.customers[this.index]['id']][0].id === ''){
+                        this.$delete(this.customerLogs[this.customers[this.index]['id']],0);
+                    }
+                },
+                editLog(){
+                    let log = this.customerLogs[this.customers[this.index]['id']][this.currentLogIndex];
+                    if (log.id === ''){
+                        let description = $("#description-"+log.id)[0].value;
+                        let logStatus = $("#logStatus-"+log.id)[0].value;
+                        let url="{{url('customer/customer/storeLog')}}";
+                        let params = {customer_id:this.customers[this.index]['id'],description:description,customer_log_status_id:logStatus};
+                        window.tempTip.postBasicRequest(url,params,(res)=>{
+                            this.customerLogs[this.customers[this.index]['id']][0] = res;
+                            this.currentLogIndex = '';
+                            this.$forceUpdate();
+                            return "成功创建客户日志";
+                        },true);
+                        return;
+                    }
+                    let url="{{url('customer/customer/editLog')}}";
+                    let description = $("#description-"+log.id)[0].value;
+                    let params = {id:log.id,description:description};
+                    window.tempTip.postBasicRequest(url,params,(res)=> {
+                        this.customerLogs[this.customers[this.index]['id']][this.currentLogIndex].description = description;
+                        this.currentLogIndex = '';
+                        this.$forceUpdate();
+                        return "修改说明成功!";
+                    },true);
+                },
+                addLog(){
+                    if (this.logStatuses.length < 1)window.tempTip.postBasicRequest("{{url('customer/customer/getLogStatus')}}",{},(res)=>{
+                        this.logStatuses = res;
+                    },true);
+                    let logs = this.customerLogs[this.customers[this.index]['id']];
+                    if (logs.length > 0 && logs[0].id === "")return;
+                    logs.unshift({
+                        id:"",
+                        status:{name:""},
+                        user:{name:"{{\Illuminate\Support\Facades\Auth::user()->name}}"},
+                        description:"",
+                        created_at:"",
+                    });
+                    this.currentLogIndex = 0;
+                    this.$forceUpdate();
+                },
+                showContract(id){
+                    if (this.contractIds['_'+id] &&  this.contractIds['_'+id]===true){
+                        this.contractIds['_'+id] = false;
+                        $("#customer-"+id).slideUp(undefined,function () {
+                            $("#customer-tr-"+id).addClass("d-none");
+                        });
+                    }else {
+                        $("#customer-tr-"+id).removeClass("d-none");
+                        this.contractIds['_'+id] = true;
+                        $("#customer-"+id).slideDown();
+                    }
+                    this.$forceUpdate();
+                },
+                _renderingHtml(id,contracts){
+                    let domId   = "customer-"+id;
+                    let trDomId = "customer-tr-"+id;
+                    let html = "<tr class='d-none' id='"+trDomId+"'><td colspan='12'>"+
+                        "<div id='"+domId+"'><table class='table table-sm'>"+
+                        "<tr><th>合同号</th><th>销售姓名</th><th>所属项目</th><th>备注</th><th>附件</th></tr>";
+                    contracts.forEach(contract=> {
+                        html = this._createContractList(html,contract.number,contract.salesman,contract.ownerName,contract.remark,contract.files);
+                    });
+                    html += "</table></div></td></tr>";
+                    $("#model-"+id).after(html);
+                    $("#"+domId).slideUp();
+                },
+                _createContractList(html,number,salesman,ownerName,remark,files){
+                    html += "<tr><td>"+number+"</td><td>"+salesman+"</td><td>"+ownerName+"</td><td><div style='white-space: normal;max-width: 200px' '>"+remark+"</div</td><td class='p-0'>";
+                    if (files) files.forEach(function (file) {
+                        let url = file.url;
+                        let name = file.file_name;
+                        if (file.type === 'jpg' || file.type === 'png'){
+                            html += "<a target='_blank' href='"+url+"' class='small'><span class='fa fa-file-image-o'></span>"+name+"</a><br>";
+                        }else html += "<a target='_blank' href='"+url+"' download='"+url+"' class='small'><span class='fa fa-link'></span>"+name+"</a><br>";
+                    });
+                    html += "</td></tr>";
+                    return html;
+                },
+                addContract(index){
+                    this.index = index;
+                    let id = this.customers[index].id;
+                    if (!this.owners[id]){
+                        let url = "{{url("maintenance/owner/get")}}";
+                        let params = {customer_id:id};
+                        window.tempTip.postBasicRequest(url,params,(res)=> {
+                            this.owners[id] = res;
+                            this.$forceUpdate();
+                        });
+                    }
+                    $("#addContract").modal("show");
+                },
+                submitContract(){
+                    window.tempTip.setIndex(1099);
+                    let owner = document.getElementById("owner").value;
+                    let number = document.getElementById("contract_number").value;
+                    let remark = document.getElementById("remark").value;
+                    if (!owner || !number){
+                        window.tempTip.show("项目与合同号为必输项");
+                        return;
+                    }
+                    let formData = new FormData();
+                    this.files.forEach(file=>{
+                        formData.append("files[]",file);
+                    });
+                    formData.append("owner_id",owner);
+                    formData.append("contract_number",number);
+                    formData.append("remark",remark);
+                    window.tempTip.setDuration(9999);
+                    window.tempTip.waitingTip("新建中,请耐心等候......");
+                    window.axios.post('{{url('customer/ownerContract/store')}}',formData,{
+                        'Content-Type':'multipart/form-data'
+                    }).then(res=>{
+                        if (res.data.success){
+                            window.tempTip.cancelWaitingTip();
+                            window.tempTip.setDuration(2000);
+                            window.tempTip.showSuccess("新建合同“"+number+"”成功");
+                            $("#addContract").modal("hide");
+                            this.files = [];
+                            let id = this.customers[this.index].id;
+                            let html = this._createContractList('',
+                                res.data.data.contract_number,
+                                res.data.data.salesman,
+                                res.data.data.owner ? res.data.data.owner.name : '',
+                                res.data.data.remark,
+                                res.data.data.files);
+                            $("#customer-tr-"+id).after(html);
+                            return;
+                        }
+                        window.tempTip.cancelWaitingTip();
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show(res.data.data);
+                    }).catch(err=>{
+                        window.tempTip.cancelWaitingTip();
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show('网络错误:'+err);
+                    });
+                }
+            },
+            filters:{
+                size:function (val) {
+                    if (!val)return '';
+                    val = Number(parseInt(val/1024));
+                    if (val >= 1024){
+                        return  parseInt(val/1024)+"MB";
+                    }
+                    return val+"KB";
+                }
             },
         });
     </script>

+ 12 - 6
resources/views/customer/customerLogStatus/_edit.blade.php

@@ -1,17 +1,23 @@
 <div class="modal fade" tabindex="-1" role="dialog" id="modal">
-    <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
+    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
         <div class="modal-content">
             <div class="modal-header">
                 <button type="button" class="close" data-dismiss="modal">&times;</button>
             </div>
             <div class="modal-body">
                 <div class="row">
-                    <label class="col-3" for="name">名称</label>
-                    <input class="col-9" id="name" type="text" v-model="status.name">
+                    <label class="col-2 offset-1" for="name">名称</label>
+                    <input class="col-7 form-control form-control-sm" :class="errors.name ? 'is-invalid' : ''" id="name" type="text" v-model="status.name">
+                    <span class="invalid-feedback mt-0 offset-3" role="alert" v-if="errors.name">
+                        <strong>@{{ errors.name[0] }}</strong>
+                    </span>
                 </div>
-                <div class="row">
-                    <label class="col-3" for="description">说明</label>
-                    <textarea class="col-9" id="description" type="text" v-model="status.description"></textarea>
+                <div class="row mt-2">
+                    <label class="col-2 offset-1" for="description">说明</label>
+                    <textarea class="col-7 form-control form-control-sm" :class="errors.description ? 'is-invalid' : ''" id="description" type="text" v-model="status.description"></textarea>
+                    <span class="invalid-feedback mt-0 offset-3" role="alert" v-if="errors.description">
+                        <strong>@{{ errors.description[0] }}</strong>
+                    </span>
                 </div>
             </div>
             <div class="modal-footer">

+ 40 - 3
resources/views/customer/customerLogStatus/index.blade.php

@@ -31,7 +31,7 @@
                         <td>@{{ model.updatedAt }}</td>
                         <td>
                             @can("客户管理-客户-客户状态-编辑")<button class="btn btn-sm btn-outline-info" @click="openModal(model)">改</button>@endcan
-                            @can("客户管理-客户-客户状态-删除")<button class="btn btn-sm btn-outline-danger" @click="deleteModel(model)">删</button>@endcan
+                            @can("客户管理-客户-客户状态-删除")<button class="btn btn-sm btn-outline-danger" @click="deleteModel(model,i)">删</button>@endcan
                         </td>
                     </tr>
                 </table>
@@ -53,6 +53,7 @@
                         , 'updatedAt':"{{$customerLogStatus->updated_at}}"},
                     @endforeach
                 ],
+                errors:[],
             },
             mounted(){
                 $("#container").removeClass("d-none");
@@ -63,8 +64,44 @@
                    else this.status={id:"",name:"",description:""};
                    $("#modal").modal("show");
                 },
-                deleteModel(model){
-                    window.tempTip.postBasicRequest();
+                submitCustomerLogStatus(){
+                    let url="{{url('customer/customer/customerLogStatus/save')}}";
+                    let msg=this.status.id ? "成功修改状态“"+this.status.name+"”"  : "成功新增状态“"+this.status.name+"”";
+                    window.tempTip.postBasicRequest(url,this.status,(res)=>{
+                        if(res && res.errors){
+                            this.errors = res.errors;
+                            return '';
+                        }
+                        if (this.status.id){
+                            this.models.some((model)=> {
+                                if (model.id === this.status.id){
+                                    model.name = this.status.name;
+                                    model.description = this.status.description;
+                                    return true;
+                                }
+                            });
+                        }else this.models.unshift({
+                            id:res.id,
+                            name:res.name,
+                            description:res.description,
+                            createdAt:res.created_at,
+                            updatedAt:res.updated_at,
+                        });
+
+                        $("#modal").modal("hide");
+                        return msg;
+                    },true);
+                },
+                deleteModel(model,index){
+                    let url="{{url('customer/customer/customerLogStatus/destroy')}}";
+                    let params = {id:model.id};
+                    let msg="成功删除状态“"+model.name+"”";
+                    window.tempTip.confirm("您确定要删除“"+model.name+"”吗?",()=>{
+                        window.tempTip.postBasicRequest(url,params,res=>{
+                            this.$delete(this.models,index);
+                            return msg;
+                        });
+                    });
                 },
             },
         });

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

@@ -69,14 +69,6 @@
                         <strong>@{{ errors.waring_line_on[0] }}</strong>
                     </span>
                 </div>
-                <div class="row mt-3">
-                    <label for="contract_number" class="col-2">合同号</label>
-                    <input type="text" v-model="owner.contract_number" id="contract_number" class="form-control form-control-sm col-7"  name="contract_number">
-                </div>
-                <div class="row mt-3">
-                    <label for="salesman" class="col-2">销售名称</label>
-                    <input type="text" v-model="owner.salesman" id="salesman" class="form-control form-control-sm col-7"  name="salesman">
-                </div>
                 <div class="row mt-3">
                     <label for="linkman" class="col-2">联系人</label>
                     <input type="text" v-model="owner.linkman" id="linkman" class="form-control form-control-sm col-7"  name="linkman">
@@ -108,8 +100,6 @@
                     owner_group_id : "{{old('owner_group_id') ?? ($owner->user_owner_group_id ?? '')}}",
                     owner_storage_price_model_id : "{{old('owner_storage_price_model_id') ?? ($owner->owner_storage_price_model_id ?? '')}}".split(','),
                     tax_rate : "{{old('tax_rate') ?? ($owner->tax_rate ?? '')}}",
-                    contract_number : "{{old('contract_number') ?? ($owner->contract_number ?? '')}}",
-                    salesman : "{{old('salesman') ?? ($owner->salesman ?? '')}}",
                     linkman : "{{old('linkman') ?? ($owner->linkman ?? '')}}",
                     phone_number : "{{old('phone_number') ?? ($owner->phone_number ?? '')}}",
                     description : "{{old('description') ?? ($owner->description ?? '')}}",

+ 12 - 6
resources/views/customer/project/index.blade.php

@@ -72,9 +72,12 @@
                     <td>@{{ owner.tax_rate ? owner.tax_rate+'%' : '' }}</td>
                     <td>@{{ owner.name }}</td>
                     <td>@{{ owner.code }}</td>
-                    <td>@{{ owner.contract_number }}</td>
                     <td>@{{ owner.created_at }}</td>
-                    <td>@{{ owner.salesman }}</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>
@@ -107,9 +110,12 @@
                         tax_rate  : "{{$owner->tax_rate}}",
                         name : "{{$owner->name}}",
                         code : "{{$owner->code}}",
-                        contract_number : "{{$owner->contract_number}}",
                         created_at : "{{$owner->created_at}}",
-                        salesman : "{{$owner->salesman}}",
+                        contracts : [
+                            @foreach($owner->contracts as $contract)
+                            { number:"{{$contract->contract_number}}",salesman:"{{$contract->salesman}}" },
+                            @endforeach
+                        ],
                         customer_company_name:"{{$owner->customer ? $owner->customer->company_name : ''}}",
                         linkman:"{{$owner->linkman}}",
                         phone_number:"{{$owner->phone_number}}",
@@ -138,9 +144,9 @@
                     {name:'tax_rate',value: '税率%', neglect: true},
                     {name:'name',value: '项目'},
                     {name:'code',value: '货主代码'},
-                    {name:'contract_number',value: '合同号'},
                     {name:'created_at',value: '创建日期'},
-                    {name:'salesman',value: '销售名称'},
+                    {name:'contract_number',value: '合同号', neglect: true},
+                    {name:'salesman',value: '销售名称', neglect: true},
                     {name:'customer_full_name',value: '公司全称'},
                     {name:'linkman',value: '联系人'},
                     {name:'phone_number',value: '联系电话'},

+ 1 - 1
resources/views/maintenance/priceModel/express/index.blade.php

@@ -138,7 +138,7 @@
                 },
                 addDetail(){
                     if (this.provinces === null){
-                        window.tempTip.postBasicRequest('{{url('maintenance/province/get')}}',{},undefined,data=>{
+                        window.tempTip.postBasicRequest('{{url('maintenance/province/get')}}',{},data=>{
                             this.provinces = data;
                         });
                     }

+ 15 - 1
routes/web.php

@@ -48,6 +48,9 @@ Route::group(['prefix'=>'maintenance'],function(){
     Route::group(['prefix'=>'owners'],function(){
         Route::get('recycle','OwnerController@recycle');
     });
+    Route::group(['prefix'=>'owner'],function (){
+        Route::post("get","OwnerController@get");
+    });
     /** 教程 */
     Route::group(['prefix'=>'tutorial'],function(){
         Route::post('showContent/{id}', 'TutorialController@showContent');
@@ -597,9 +600,20 @@ Route::group(['prefix'=>'customer'],function(){
     });
     Route::get('relating',function (){return view('customer.relating');});
     Route::group(['prefix' => 'customer'], function () {
-        Route::resource('customerLogStatus', 'CustomerLogStatusController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]);
+        Route::get('customerLogStatus', 'CustomerLogStatusController@index');
+        Route::post('getLog', 'CustomerLogController@get');
+        Route::post('editLog', 'CustomerLogController@update');
+        Route::post('getLogStatus', 'CustomerLogStatusController@get');
+        Route::post('storeLog', 'CustomerLogController@store');
+        Route::group(['prefix' => 'customerLogStatus'], function () {
+            Route::post('save', 'CustomerLogStatusController@save');
+            Route::post('destroy', 'CustomerLogStatusController@destroy');
+        });
         Route::resource('customerLog', 'CustomerLogController', ['only' => ['index', 'show', 'create', 'store', 'update', 'edit', 'destroy']]);
     });
+    Route::group(['prefix' => 'ownerContract'], function () {
+        Route::post('store', 'OwnerContractController@store');
+    });
     Route::resource('customer', 'CustomerBaseController');
 
 });

+ 7 - 1
文档/WAS项目规范.md

@@ -12,7 +12,7 @@
 	动作方法的命名
 		用及物动词,不及物动词都可以,可以有副词在动词前后,不能是“名词前动词后”描述动作,或不能“名词+形容词”来描述动作
 	代码命名
-	    文件命名统一为驼峰单数命名且首字母大写(视图文件非大写)加对应功能块(例如:user模块:Model:User  controller:UserController service:UserService)
+	    文件命名统一为驼峰单数命名且首字母大写(视图文件非大写)加对应功能块名称(例如:user模块:Model:User  controller:UserController service:UserService)
 	    数据库命名:表名为复数,多词使用下划线连接,中间表为单数(对于中间表而言建议根据首字母在26个英文字母中的顺序排列连接表)
 ##控制器
 	限制
@@ -40,6 +40,9 @@
 		在控制器中调用时,如服务与控制器同前缀名的,服务器对象统一命名:$service,服务与控制器不同前缀名的不可以这样命名对象
 ##视图
 	路径文件夹与文件命名
+	
+##方法
+    方法应该按照其作用域来规定其属性,例如:对于后端而言仅供类内部调用的方法应该使用private,对于前端而言仅供其他函数调用的方法应该使用下划线(_)开头命名
 
 ##Request处理
 	参数调用
@@ -74,6 +77,9 @@
 	有外键关系的自字义自段,不添加至$appends,仅存在为getAttrbute()方法,如需要调用,在相应结果集添加with(''),前端在{!! !!}调用完默认结果集后,@foreach循环再追加这些自定义自段
 	使用$appends的属性,如有外键关系方法被调用,应当在之前增加"$this->外键方法->相应字段"这种方式优先调取(当作属性使用而不是方法), 外部使用with(将关联表注明)
 	不能使用get开头的自定义方法,需要用到的用框架定义的getXXXAttribute()这种方式
+	模型关系的定义
+	    注意相互的从属关系:hasOne是父模型对于子模型的定义,belongsTo是子模型对于父模型的声明(一般而言:本表存在关联表的外键使用belongsTo,关联表存在本表的外键使用hasOne)
+	    建议:对于超长模型命名可忽略同级的前缀。(示例:user与userLog 模型关系可直接称之log)
 ##控制台命令
 	将命令的实际逻辑写成Service方法,方便复用调用和测试
 ##数据库