李浩杰 vor 4 Jahren
Ursprung
Commit
d131191045
64 geänderte Dateien mit 3568 neuen und 244 gelöschten Zeilen
  1. 9 0
      app/Exceptions/ImportError.php
  2. 30 9
      app/Http/Controllers/Admin/InnerDeviceController.php
  3. 114 0
      app/Http/Controllers/Admin/OrderDeviceController.php
  4. 110 0
      app/Http/Controllers/Admin/PartController.php
  5. 3 2
      app/Http/Controllers/Admin/ProjectUserController.php
  6. 118 0
      app/Http/Controllers/Admin/ProjectUserRoleController.php
  7. 112 0
      app/Http/Controllers/Admin/RepairDeviceController.php
  8. 129 0
      app/Http/Controllers/Admin/UserAuthController.php
  9. 30 30
      app/Http/Controllers/Admin/UserController.php
  10. 91 1
      app/Http/Controllers/Api/mini/DataController.php
  11. 7 0
      app/Http/Controllers/Api/mini/ProjectController.php
  12. 6 2
      app/Http/Controllers/Api/mini/ProjectRoleController.php
  13. 28 0
      app/Http/Controllers/Api/mini/UserAuthController.php
  14. 90 0
      app/Imports/InnerDeviceImport.php
  15. 16 0
      app/Models/DeviceName.php
  16. 0 3
      app/Models/InnerDevice.php
  17. 19 5
      app/Models/ProjectUser.php
  18. 3 0
      app/Models/User.php
  19. 29 0
      app/Models/UserAuth.php
  20. 1 0
      composer.json
  21. 37 0
      database/migrations/2021_01_09_220211_create_user_auths_table.php
  22. 30 0
      database/migrations/2021_01_10_094507_add_quantity_to_inner_devices.php
  23. 1 1
      database/seeds/AdminMenuSeeder.php
  24. 113 0
      database/seeds/admin_menus.sql
  25. 5 5
      mini/app.json
  26. 31 8
      mini/custom-tab-bar/index.js
  27. 1 1
      mini/custom-tab-bar/index.wxml
  28. 3 1
      mini/pages/account/index.js
  29. 8 4
      mini/pages/account/index.wxml
  30. 60 4
      mini/pages/bind/index.js
  31. 1 1
      mini/pages/bind/index.json
  32. 34 3
      mini/pages/bind/index.wxml
  33. 1 1
      mini/pages/data-center/index.wxml
  34. 147 25
      mini/pages/data/index.js
  35. 38 30
      mini/pages/data/index.wxml
  36. 1 2
      mini/pages/data/index.wxss
  37. 1 1
      mini/pages/filter-data/index.wxml
  38. BIN
      public/设备导入模板.xlsx
  39. 32 19
      resources/views/admin/inner-devices/create.blade.php
  40. 33 20
      resources/views/admin/inner-devices/edit.blade.php
  41. 176 41
      resources/views/admin/inner-devices/index.blade.php
  42. 53 0
      resources/views/admin/order-devices/create.blade.php
  43. 54 0
      resources/views/admin/order-devices/edit.blade.php
  44. 228 0
      resources/views/admin/order-devices/index.blade.php
  45. 53 0
      resources/views/admin/parts/create.blade.php
  46. 54 0
      resources/views/admin/parts/edit.blade.php
  47. 230 0
      resources/views/admin/parts/index.blade.php
  48. 53 0
      resources/views/admin/project-user-roles/create.blade.php
  49. 53 0
      resources/views/admin/project-user-roles/edit.blade.php
  50. 219 0
      resources/views/admin/project-user-roles/index.blade.php
  51. 53 0
      resources/views/admin/repair-devices/create.blade.php
  52. 54 0
      resources/views/admin/repair-devices/edit.blade.php
  53. 239 0
      resources/views/admin/repair-devices/index.blade.php
  54. 53 0
      resources/views/admin/user-auth/create.blade.php
  55. 54 0
      resources/views/admin/user-auth/edit.blade.php
  56. 242 0
      resources/views/admin/user-auth/index.blade.php
  57. 2 2
      resources/views/admin/users/create.blade.php
  58. 1 1
      resources/views/admin/users/edit.blade.php
  59. 34 22
      resources/views/admin/users/index.blade.php
  60. 74 0
      resources/views/share/name-select-form.blade.php
  61. 64 0
      resources/views/share/name-select.blade.php
  62. 3 0
      routes/api.php
  63. BIN
      storage/framework/laravel-excel/laravel-excel-LF357h9OiX60NFxClIVS5Q4tlqe6K8IC.tmp
  64. BIN
      storage/framework/laravel-excel/laravel-excel-gb9BNT5rIjP5gyYBZW87ARbuK5xsrXWZ.tmp

+ 9 - 0
app/Exceptions/ImportError.php

xqd
@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Exceptions;
+
+
+class ImportError extends \Exception
+{
+
+}

+ 30 - 9
app/Http/Controllers/Admin/InnerDeviceController.php

xqd xqd xqd xqd xqd xqd xqd
@@ -2,17 +2,14 @@
 
 namespace App\Http\Controllers\Admin;
 
-use App\Models\AdminRoleModel;
-use App\Models\Department;
+use App\Exceptions\ImportError;
+use App\Imports\InnerDeviceImport;
 use App\Models\Device;
 use App\Models\DeviceName;
 use App\Models\InnerDevice;
 use App\Models\Option;
-use App\Models\Road;
-use App\Models\Role;
-use App\Models\Spec;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Log;
+use Maatwebsite\Excel\Facades\Excel;
 
 class InnerDeviceController extends BaseController
 {
@@ -20,6 +17,8 @@ class InnerDeviceController extends BaseController
     
     protected $device;
 
+    protected $device_name;
+
     protected $department;
 
     protected $model_name = '设备';
@@ -34,11 +33,12 @@ class InnerDeviceController extends BaseController
     {
         $this->model = new InnerDevice();
         $this->device = new Device();
+        $this->device_name = new DeviceName();
     }
 
     public function index()
     {
-        $options = $this->device->getDeviceOptions();
+        $options = $this->device_name->getNameSpecOptions();
         $statuses = Option::get('inner_devices', 'status');
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
         return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'options', 'statuses'));
@@ -69,6 +69,7 @@ class InnerDeviceController extends BaseController
             $item->device_name_name = $item->device_name ? $item->device_name->name : '';
             $item->spec_name = $item->spec ? $item->spec->name : '';
             $item->status = $item->option ? '<div style="color: ' . $item->option->color . '">' . $item->option->name . '</div>' : '';
+            $item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
         }
 
 
@@ -78,7 +79,7 @@ class InnerDeviceController extends BaseController
     public function create()
     {
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
-        $options = $this->device->getDeviceOptions();
+        $options = $this->device_name->getNameSpecOptions();
         $status_options = Option::get('inner_devices', 'status');
         return view($this->view_path . 'create', compact('model', 'model_name','pre_uri', 'options', 'status_options'));
     }
@@ -104,10 +105,17 @@ class InnerDeviceController extends BaseController
         return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
     }
 
+    public function exportTemplate(Request $request)
+    {
+        return response()->download(public_path() . '/设备导入模板.xlsx', '设备导入模板.xlsx', [
+            'Content-Type: application/vnd.ms-excel'
+        ]);
+    }
+
     public function edit(Request $request)
     {
         if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
-        $options = $this->device->getDeviceOptions();
+        $options = $this->device_name->getNameSpecOptions();
         $status_options = Option::get('inner_devices', 'status');
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
         return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'options', 'status_options'));
@@ -138,4 +146,17 @@ class InnerDeviceController extends BaseController
         return response()->json(['status' => 'success', 'info' => '操作成功']);
     }
 
+    public function import(Request $request)
+    {
+        if(!$request->hasFile('file')) {
+            return response()->json(['status' => 'error', 'info' => '参数错误']);
+        }
+        $file = $request->file('file');
+        try {
+            Excel::import(new InnerDeviceImport(), $file);
+        } catch (ImportError $e) {
+            return response()->json(['status' => 'error', 'info' => $e->getMessage()]);
+        }
+        return response()->json(['status' => 'success', 'info' => '上传成功']);
+    }
 }

+ 114 - 0
app/Http/Controllers/Admin/OrderDeviceController.php

xqd
@@ -0,0 +1,114 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\DeviceName;
+use App\Models\InnerDevice;
+use App\Models\OrderDevice;
+use Illuminate\Http\Request;
+
+class OrderDeviceController extends BaseController
+{
+    protected $model;
+
+    protected $department;
+
+    protected $model_name = '调用记录';
+
+    protected $pre_uri = '/admin/OrderDevice/';
+
+    protected $view_path = 'admin.order-devices.';
+
+    protected $redirect_index = '/admin/OrderDevice/index';
+
+    public function __construct()
+    {
+        $this->model = new OrderDevice();
+    }
+
+    public function index(Request $request)
+    {
+        $inner_device = InnerDevice::find($request->input('inner_device_id'));
+        $inner_device->device_name_name = $inner_device->device_name ? $inner_device->device_name->name : '';
+        $inner_device->spec_name = $inner_device->spec ? $inner_device->spec->name : '';
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'inner_device'));
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->orderBy('created_at', 'desc');
+
+        $tmp_items = collect(['name']);
+        foreach($tmp_items as $tmp_item) {
+            if($request->has($tmp_item) && !empty($request->input($tmp_item))) {
+                $items = $items->where($tmp_item, 'like', '%' . $request->input($tmp_item) . '%');
+            }
+        }
+
+        $select_items = collect(['inner_device_id']);
+        foreach($select_items as $select_item) {
+            if($request->has($select_item) && !empty($request->input($select_item))) {
+                $items = $items->where($select_item, '=', $request->input($select_item));
+            }
+        }
+
+        $items = $items->paginate();
+
+        foreach ($items as $item) {
+            $item->user_name = $item->user ? $item->user->name : '';
+            $item->project_name = $item->project ? $item->project->name : '';
+            $item->money = $item->money / 100;
+        }
+
+        return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
+    }
+
+    public function create()
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri'));
+    }
+
+    public function store(Request $request)
+    {
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'store');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->create($data);
+        if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
+        return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
+    }
+
+    public function edit(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item'));
+    }
+
+    public function update(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'update');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->where('id', $request->input('id'))->update($data);
+        if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
+        return back()->with(['sg_success_info' => '编辑成功']);
+    }
+
+    public function delete(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return response()->json(['status' => 'fail', 'info' => '找不到要删除的数据']);
+        $res = $item->delete();
+        if (!$res) return response()->json(['status' => 'fail', 'info' => '删除失败']);
+        return response()->json(['status' => 'success', 'info' => '操作成功']);
+    }
+}

+ 110 - 0
app/Http/Controllers/Admin/PartController.php

xqd
@@ -0,0 +1,110 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\DeviceName;
+use App\Models\InnerDevice;
+use App\Models\OrderDevice;
+use App\Models\Part;
+use Illuminate\Http\Request;
+
+class PartController extends BaseController
+{
+    protected $model;
+
+    protected $department;
+
+    protected $model_name = '维修部件';
+
+    protected $pre_uri = '/admin/Part/';
+
+    protected $view_path = 'admin.parts.';
+
+    protected $redirect_index = '/admin/Part/index';
+
+    public function __construct()
+    {
+        $this->model = new Part();
+    }
+
+    public function index(Request $request)
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'index', compact('model', 'model_name','pre_uri'));
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->orderBy('created_at', 'desc');
+
+        $tmp_items = collect(['name']);
+        foreach($tmp_items as $tmp_item) {
+            if($request->has($tmp_item) && !empty($request->input($tmp_item))) {
+                $items = $items->where($tmp_item, 'like', '%' . $request->input($tmp_item) . '%');
+            }
+        }
+
+        $select_items = collect(['repair_device_id']);
+        foreach($select_items as $select_item) {
+            if($request->has($select_item) && !empty($request->input($select_item))) {
+                $items = $items->where($select_item, '=', $request->input($select_item));
+            }
+        }
+
+        $items = $items->paginate();
+
+        foreach ($items as $item) {
+            $item->price = $item->price / 100;
+        }
+
+        return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
+    }
+
+    public function create()
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri'));
+    }
+
+    public function store(Request $request)
+    {
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'store');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->create($data);
+        if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
+        return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
+    }
+
+    public function edit(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item'));
+    }
+
+    public function update(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'update');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->where('id', $request->input('id'))->update($data);
+        if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
+        return back()->with(['sg_success_info' => '编辑成功']);
+    }
+
+    public function delete(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return response()->json(['status' => 'fail', 'info' => '找不到要删除的数据']);
+        $res = $item->delete();
+        if (!$res) return response()->json(['status' => 'fail', 'info' => '删除失败']);
+        return response()->json(['status' => 'success', 'info' => '操作成功']);
+    }
+}

+ 3 - 2
app/Http/Controllers/Admin/ProjectUserController.php

xqd xqd xqd
@@ -36,7 +36,7 @@ class ProjectUserController extends BaseController
 
     public function get(Request $request)
     {
-        $items = $this->model->where('project_id', '=', $request->input('project_id'))->with('user', 'projectRole');
+        $items = $this->model->with('user', 'projectRole');
 
         if($request->input('name')) {
             $user_ids = User::where('name', 'like', '%' . $request->input('name') . '')->pluck('id')->unique();
@@ -45,7 +45,7 @@ class ProjectUserController extends BaseController
             }
         }
 
-        $select_items = collect([]);
+        $select_items = collect(['project_id', 'user_id']);
         foreach($select_items as $select_item) {
             if($request->has($select_item) && !empty($request->input($select_item))) {
                 $items = $items->where($select_item, '=', $request->input($select_item));
@@ -57,6 +57,7 @@ class ProjectUserController extends BaseController
         foreach($items as $item) {
             $item->user_name = $item->user ? $item->user->name : '';
             $item->role_name = $item->projectRole ? $item->projectRole->name : '';
+            $item->project_name = $item->project ? $item->project->name : '';
         }
 
         return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);

+ 118 - 0
app/Http/Controllers/Admin/ProjectUserRoleController.php

xqd
@@ -0,0 +1,118 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\Project;
+use App\Models\ProjectRole;
+use App\Models\ProjectUser;
+use App\Models\User;
+use Illuminate\Http\Request;
+
+class ProjectUserRoleController extends BaseController
+{
+    protected $model;
+
+    protected $department;
+
+    protected $model_name = '角色';
+
+    protected $pre_uri = '/admin/ProjectUserRole/';
+
+    protected $view_path = 'admin.project-user-roles.';
+
+    protected $redirect_index = '/admin/ProjectUserRole/index';
+
+    public function __construct()
+    {
+        $this->model = new ProjectUser();
+    }
+
+    public function index(Request $request)
+    {
+        $user = User::find($request->input('user_id'));
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'user'));
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->with('user', 'projectRole');
+
+        if($request->input('name')) {
+            $user_ids = User::where('name', 'like', '%' . $request->input('name') . '')->pluck('id')->unique();
+            if(count($user_ids) > 0) {
+                $items = $items->whereIn('user_id', $user_ids);
+            }
+        }
+
+        $select_items = collect(['project_id', 'user_id']);
+        foreach($select_items as $select_item) {
+            if($request->has($select_item) && !empty($request->input($select_item))) {
+                $items = $items->where($select_item, '=', $request->input($select_item));
+            }
+        }
+
+        $items = $items->paginate();
+
+        foreach($items as $item) {
+            $item->user_name = $item->user ? $item->user->name : '';
+            $item->role_name = $item->projectRole ? $item->projectRole->name : '';
+            $item->project_name = $item->project ? $item->project->name : '';
+        }
+
+        return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
+    }
+
+    public function create()
+    {
+        $project_options = (new Project())->getOptions();
+        $role_options = (new ProjectRole())->getOptions();
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri', 'role_options', 'project_options'));
+    }
+
+    public function store(Request $request)
+    {
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'store');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->create($data);
+        if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
+        return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
+    }
+
+    public function edit(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        $project_options = (new Project())->getOptions();
+        $role_options = (new ProjectRole())->getOptions();
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'project_options', 'role_options'));
+    }
+
+    public function update(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'update');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->where('id', $request->input('id'))->update($data);
+        if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
+        return back()->with(['sg_success_info' => '编辑成功']);
+    }
+
+    public function delete(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return response()->json(['status' => 'fail', 'info' => '找不到要删除的数据']);
+        $res = $item->delete();
+        if (!$res) return response()->json(['status' => 'fail', 'info' => '删除失败']);
+        return response()->json(['status' => 'success', 'info' => '操作成功']);
+    }
+
+}

+ 112 - 0
app/Http/Controllers/Admin/RepairDeviceController.php

xqd
@@ -0,0 +1,112 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\InnerDevice;
+use App\Models\RepairDevice;
+use Illuminate\Http\Request;
+
+class RepairDeviceController extends BaseController
+{
+    protected $model;
+
+    protected $department;
+
+    protected $model_name = '维修记录';
+
+    protected $pre_uri = '/admin/RepairDevice/';
+
+    protected $view_path = 'admin.repair-devices.';
+
+    protected $redirect_index = '/admin/RepairDevice/index';
+
+    public function __construct()
+    {
+        $this->model = new RepairDevice();
+    }
+
+    public function index(Request $request)
+    {
+        $inner_device = InnerDevice::find($request->input('inner_device_id'));
+        $inner_device->device_name_name = $inner_device->device_name ? $inner_device->device_name->name : '';
+        $inner_device->spec_name = $inner_device->spec ? $inner_device->spec->name : '';
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'inner_device'));
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->orderBy('created_at', 'desc');
+
+        $tmp_items = collect(['name']);
+        foreach($tmp_items as $tmp_item) {
+            if($request->has($tmp_item) && !empty($request->input($tmp_item))) {
+                $items = $items->where($tmp_item, 'like', '%' . $request->input($tmp_item) . '%');
+            }
+        }
+
+        $select_items = collect(['inner_device_id']);
+        foreach($select_items as $select_item) {
+            if($request->has($select_item) && !empty($request->input($select_item))) {
+                $items = $items->where($select_item, '=', $request->input($select_item));
+            }
+        }
+
+        $items = $items->paginate();
+
+        foreach ($items as $item) {
+            $item->user_name = $item->user ? $item->user->name : '';
+            $item->project_name = $item->project ? $item->project->name : '';
+        }
+
+        return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
+    }
+
+    public function create()
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri'));
+    }
+
+    public function store(Request $request)
+    {
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'store');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->create($data);
+        if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
+        return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
+    }
+
+    public function edit(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item'));
+    }
+
+    public function update(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'update');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->where('id', $request->input('id'))->update($data);
+        if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
+        return back()->with(['sg_success_info' => '编辑成功']);
+    }
+
+    public function delete(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return response()->json(['status' => 'fail', 'info' => '找不到要删除的数据']);
+        $res = $item->delete();
+        if (!$res) return response()->json(['status' => 'fail', 'info' => '删除失败']);
+        return response()->json(['status' => 'success', 'info' => '操作成功']);
+    }
+}

+ 129 - 0
app/Http/Controllers/Admin/UserAuthController.php

xqd
@@ -0,0 +1,129 @@
+<?php
+
+namespace App\Http\Controllers\Admin;
+
+use App\Models\ProjectUser;
+use App\Models\User;
+use App\Models\UserAuth;
+use Illuminate\Http\Request;
+
+class UserAuthController extends BaseController
+{
+    protected $model;
+
+    protected $department;
+
+    protected $model_name = '用户授权';
+
+    protected $pre_uri = '/admin/UserAuth/';
+
+    protected $view_path = 'admin.user-auth.';
+
+    protected $redirect_index = '/admin/UserAuth/index';
+
+    public function __construct()
+    {
+        $this->model = new UserAuth();
+    }
+
+    public function index()
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'index', compact('model', 'model_name','pre_uri'));
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->orderBy('created_at', 'desc');
+
+        $tmp_items = collect(['name']);
+        foreach($tmp_items as $tmp_item) {
+            if($request->has($tmp_item) && !empty($request->input($tmp_item))) {
+                $items = $items->where($tmp_item, 'like', '%' . $request->input($tmp_item) . '%');
+            }
+        }
+
+        $select_items = collect([]);
+        foreach($select_items as $select_item) {
+            if($request->has($select_item) && !empty($request->input($select_item))) {
+                $items = $items->where($select_item, '=', $request->input($select_item));
+            }
+        }
+
+        $items = $items->paginate();
+
+        foreach($items as $item) {
+            $item->project_name = $item->project ? $item->project->name : '';
+            $item->project_role_name = $item->project_role ? $item->project_role->name : '';
+            $item->active_label = $item->getActive('label');
+            $item->phone = $item->user ? $item->user->phone : '';
+            $item->avatar = $item->user ? '<img style="width: 40px; height: 40px" src="' . $item->user->avatar . '"  />' : '';
+        }
+
+        return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
+    }
+
+    public function change(Request $request)
+    {
+        $item = $this->model->find($request->input('id'));
+        if(!$item) return response()->json(['status' => 'fail', 'info' => '找不到数据']);
+        if($request->input('active') == 1) {
+            ProjectUser::firstOrCreate([
+                'project_id' => $item['project_id'],
+                'user_id' => $item['user_id'],
+                'project_role_id' => $item['project_role_id']
+            ]);
+            User::where('user_id', $item['user_id'])->update(['name' => $item['name']]);
+            $item->update(['active' => 1]);
+        }
+        return response()->json(['status' => 'success', 'info' => '操作成功']);
+    }
+
+    public function create()
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri'));
+    }
+
+    public function store(Request $request)
+    {
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'store');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->create($data);
+        if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
+        return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
+    }
+
+    public function edit(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item'));
+    }
+
+    public function update(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
+        if(empty($request->input('data')) || !is_array($request->input('data'))) return back()->withErrors(['sg_error_info' => '数据错误']);
+        $validator = $this->model->getValidator($request, 'update');
+        if($validator->fails()) {
+            return back()->withErrors($validator)->withInput();
+        }
+        $data = $request->input('data');
+        $res = $this->model->where('id', $request->input('id'))->update($data);
+        if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
+        return back()->with(['sg_success_info' => '编辑成功']);
+    }
+
+    public function delete(Request $request)
+    {
+        if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return response()->json(['status' => 'fail', 'info' => '找不到要删除的数据']);
+        $res = $item->delete();
+        if (!$res) return response()->json(['status' => 'fail', 'info' => '删除失败']);
+        return response()->json(['status' => 'success', 'info' => '操作成功']);
+    }
+}

+ 30 - 30
app/Http/Controllers/Admin/UserController.php

xqd xqd xqd xqd
@@ -66,10 +66,10 @@ class UserController extends BaseController
         }
 
         $items = $items->paginate();
-        foreach($items as $item) {
-            $item->role_name = $item->getProjectRoleName();
-            $item->project_name = $item->getProjectName();
-        }
+//        foreach($items as $item) {
+//            $item->role_name = $item->getProjectRoleName();
+//            $item->project_name = $item->getProjectName();
+//        }
         return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
     }
 
@@ -92,20 +92,20 @@ class UserController extends BaseController
         }
 
         $data = $request->input('data');
-        $project_id = $data['project_id'];
-        $project_role_id = $data['project_role_id'];
+//        $project_id = $data['project_id'];
+//        $project_role_id = $data['project_role_id'];
         unset($data['password_confirmation']);
-        unset($data['project_id']);
-        unset($data['project_role_id']);
+//        unset($data['project_id']);
+//        unset($data['project_role_id']);
         $data['password'] = bcrypt($data['password']);
         $res = $this->model->create($data);
-        if($project_id || $project_role_id) {
-            ProjectUser::create([
-                'project_id' => $project_id,
-                'project_role_id' => $project_role_id,
-                'user_id' => $res['id']
-            ]);
-        }
+//        if($project_id || $project_role_id) {
+//            ProjectUser::create([
+//                'project_id' => $project_id,
+//                'project_role_id' => $project_role_id,
+//                'user_id' => $res['id']
+//            ]);
+//        }
         if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
         return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
     }
@@ -118,10 +118,10 @@ class UserController extends BaseController
 //        $role_options = array_merge([['id' => '', 'name' => '项目角色']], $role_options);
 //        $project_options = array_merge([['id' => '', 'name' => '项目']], $project_options);
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
-        $project_user = ProjectUser::where('user_id', $item->id)->first();
-        $project_id = $project_user ? $project_user->project_id : '';
-        $project_role_id = $project_user ? $project_user->project_role_id : '';
-        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'role_options', 'project_options', 'project_id', 'project_role_id'));
+//        $project_user = ProjectUser::where('user_id', $item->id)->first();
+//        $project_id = $project_user ? $project_user->project_id : '';
+//        $project_role_id = $project_user ? $project_user->project_role_id : '';
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'role_options', 'project_options'));
     }
 
     public function update(Request $request)
@@ -139,19 +139,19 @@ class UserController extends BaseController
         } else {
             unset($data['password']);
         }
-        $project_id = $data['project_id'];
-        $project_role_id = $data['project_role_id'];
+//        $project_id = $data['project_id'];
+//        $project_role_id = $data['project_role_id'];
         unset($data['password_confirmation']);
-        unset($data['project_id']);
-        unset($data['project_role_id']);
+//        unset($data['project_id']);
+//        unset($data['project_role_id']);
         $res = $this->model->where('id', $request->input('id'))->update($data);
-        if($project_id || $project_role_id) {
-            ProjectUser::updateOrCreate([
-                'project_id' => $project_id,
-                'project_role_id' => $project_role_id,
-                'user_id' => $request->input('id')
-            ]);
-        }
+//        if($project_id || $project_role_id) {
+//            ProjectUser::updateOrCreate([
+//                'project_id' => $project_id,
+//                'project_role_id' => $project_role_id,
+//                'user_id' => $request->input('id')
+//            ]);
+//        }
         if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
         return back()->with(['sg_success_info' => '编辑成功']);
     }

+ 91 - 1
app/Http/Controllers/Api/mini/DataController.php

xqd xqd
@@ -344,8 +344,98 @@ class DataController extends BaseController
         return $this->success(['data' => compact('year_money', 'month_money')]);
     }
 
+    public function getSingleStat(Request $request)
+    {
+        $items = Order::where('type', 1);
+        $date = $request->input('date');
+        $project_id = $request->input('project_id') ? $request->input('project_id') : Project::first()->id;
+        $project = Project::find($project_id);
+        $items = $items->where('project_id', $project->id);
+        $sort_type = $request->input('sort_type') == 'year' ? 'year' : 'month';
+        $date = $date ? $date : Carbon::now()->toDateString();
+        $values = [];
+        $names = [];
+        $name = $sort_type == 'year' ? '每年租赁金额' : '每月租赁金额';
+        if($sort_type == 'month') {
+            $start_at = Carbon::createFromTimeString($date . ' 00:00:00')->toDateTimeString();
+            $end_at = Carbon::createFromTimeString($date . ' 00:00:00')->addYear()->toDateTimeString();
+            $items = $items->where([
+                ['created_at', '>=', $start_at],
+                ['created_at', '<', $end_at]
+            ]);
+            $items = $items->get();
+            for($i = 1; $i < 13; ++$i) {
+                $start_at = Carbon::createFromTimeString($date . ' 00:00:00')->addMonths($i - 1)->toDateTimeString();
+                $end_at = Carbon::createFromTimeString($date . ' 00:00:00')->addMonths($i)->toDateTimeString();
+                $value = $items->where('created_at', '>=', $start_at)->where('created_at', '<', $end_at)->sum('money') / 100;
+                array_push($values, $value);
+                array_push($names, $i . '月');
+            }
+        } else {
+            $start_at = Carbon::createFromTimeString($date . ' 00:00:00')->toDateTimeString();
+            $end_at = Carbon::now()->addYear(1)->toDateTimeString();
+            $items = $items->where([
+                ['created_at', '>=', $start_at],
+                ['created_at', '<', $end_at]
+            ]);
+            $items = $items->get();
+            $cnt = 1;
+            $next_year = Carbon::now()->toDateTimeString();
+            do {
+                $start_at = Carbon::createFromTimeString($date . ' 00:00:00')->addYears($cnt - 1)->toDateTimeString();
+                $end_at = Carbon::createFromTimeString($date . ' 00:00:00')->addYears($cnt)->toDateTimeString();
+                $value = $items->where('created_at', '>=', $start_at)->where('created_at', '<', $end_at)->sum('money') / 100;
+                array_push($values, $value);
+                array_push($names, Carbon::createFromTimeString($date . ' 00:00:00')->addYear($cnt - 1)->year . '年');
+                $cnt = $cnt + 1;
+            } while($cnt < 10 && $end_at <= $next_year);
+
+        }
+        return $this->success(['data' => compact('values', 'names', 'project', 'name')]);
+    }
+
+    public function getMaxStat(Request $request)
+    {
+        $date = $request->input('date');
+        $date = $date ? $date : Carbon::now()->toDateString();
+        $start_at = Carbon::createFromTimeString($date . ' 00:00:00')->toDateTimeString();
+        $end_at = Carbon::now()->toDateTimeString();
+        $items = OrderDevice::where([
+            ['created_at', '>=', $start_at],
+            ['created_at', '<', $end_at]
+        ]);
+        $in_items = ['device_ids', 'device_name_ids', 'spec_ids', 'rent_type_ids'];
+        $key_items = ['device_id', 'device_name_id', 'spec_id', 'rent_type_id'];
+        foreach ($in_items as $key => $item) {
+            if($request->input($item)) {
+                $item_ids = collect($request->input($item))->filter(function($id) {
+                    return $id;
+                });
+                if($item_ids && $item_ids->count() > 0) {
+                    $items = $items->whereIn($key_items[$key], $item_ids);
+                }
+            }
+        }
+        $items = $items->get();
+        $projects = Project::all();
+        foreach ($projects as $project) {
+            $project->max_price = $items->where('project_id', $project->id)->max('price') / 100;
+        }
+        $orderBy = $request->input('orderBy');
+        if($orderBy == 'asc') $projects = $projects->sortBy('max_price');
+        else $projects = $projects->sortByDesc('max_price');
+        $values = $projects->pluck('max_price');
+        $names = $projects->pluck('name');
+        return $this->success(['data' => compact('values', 'names')]);
+    }
+
     public function projectStat(Request $request)
     {
+        if($request->input('chartIndex') == 0) {
+            return $this->getSingleStat($request);
+        } else if($request->input('chartIndex') == 2) {
+            return $this->getMaxStat($request);
+        }
         $items = Order::where('type', 1);
         $date = $request->input('date');
         if($date) {
@@ -363,7 +453,7 @@ class DataController extends BaseController
             $project->money = 0;
             foreach ($items as $key => $val) {
                 if($key == $project->id) {
-                    $project->money = $val / 1000;
+                    $project->money = $val / 100;
                     break;
                 }
             }

+ 7 - 0
app/Http/Controllers/Api/mini/ProjectController.php

xqd
@@ -82,6 +82,13 @@ class ProjectController extends BaseController
         return $this->success(['msg' => '创建成功', 'data' => $items->items()]);
     }
 
+    public function getTotal()
+    {
+        $user = Auth::guard('mini')->user();
+        $total = ProjectUser::where('user_id', $user->id)->count();
+        return $this->success(['msg' => '操作成功', 'data' => $total]);
+    }
+
     public function getAll(Request $request)
     {
         if($request->input('type') == 'drop_menu') {

+ 6 - 2
app/Http/Controllers/Api/mini/ProjectRoleController.php

xqd
@@ -46,9 +46,13 @@ class ProjectRoleController extends BaseController
         return $this->success(['msg' => '创建成功', 'data' => $items->items()]);
     }
 
-    public function getAll()
+    public function getAll(Request $request)
     {
-        $items = $this->model->get();
+        $items = $this->model;
+        if($request->input('limit')) {
+            $items = $items->where('level', '<', 5);
+        }
+        $items = $items->get();
         return $this->success(['msg' => '创建成功', 'data' => $items]);
     }
 

+ 28 - 0
app/Http/Controllers/Api/mini/UserAuthController.php

xqd
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\UserAuth;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+
+class UserAuthController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new UserAuth();
+    }
+
+    public function create(Request $request)
+    {
+        $data = $request->only(['name', 'project_id', 'project_role_id', 'remark']);
+        $user = Auth::guard('mini')->user();
+        $user_id = $user ? $user->id : '';
+        $data['user_id'] = $user_id;
+        $data['active'] = 2;
+        $this->model->create($data);
+        return $this->success(['data' => '操作成功']);
+    }
+}

+ 90 - 0
app/Imports/InnerDeviceImport.php

xqd
@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Imports;
+
+use App\Exceptions\ImportError;
+use App\Models\DeviceName;
+use App\Models\InnerDevice;
+use App\Models\Option;
+use App\Models\Project;
+use App\Models\ProjectZone;
+use App\Models\Road;
+use App\Models\Spec;
+use App\Models\WorkPoint;
+use App\Models\Zone;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
+use Maatwebsite\Excel\Concerns\ToCollection;
+use PhpOffice\PhpSpreadsheet\Shared\Date;
+
+class InnerDeviceImport implements ToCollection
+{
+    protected $model;
+
+    protected $zone;
+
+    protected $road;
+
+    protected $project_zone;
+
+    public function __construct()
+    {
+        $this->model = new InnerDevice();
+    }
+
+    public function formatDate($date)
+    {
+        if(empty($date)) return '';
+        return Date::excelToDateTimeObject($date)->format('Y-m-d');
+    }
+
+    public function collection(Collection $rows)
+    {
+        if(count($rows) <= 1) {
+            /** @noinspection PhpUnhandledExceptionInspection */
+//            throw new ImportError('表格为空');
+            return false;
+        };
+        foreach ($rows as $key => $row) {
+            if($key == 0) continue;
+            if(!isset($row[0])) break;
+            $device_name = DeviceName::firstOrCreate([
+                'name' => $row[1]
+            ]);
+            $spec = Spec::firstOrCreate([
+                'device_name_id' => $device_name->id,
+                'name' => $row[2]
+            ]);
+
+            $work_point = WorkPoint::firstOrCreate([
+                'name' => $row[8]
+            ])->first();
+            $status = Option::where([
+                ['table', '=', 'inner_devices'],
+                ['column', '=', 'status'],
+                ['name', '=', $row[9]]
+            ])->first();
+
+
+            $data = [
+                'number' => $row[0],
+                'device_name_id' => $device_name ? $device_name->id : '',
+                'spec_id' => $spec ? $spec->id : '',
+                'produce_date' => $this->formatDate($row[3]),
+                'buy_origin' => $row[4],
+                'manufacturer' => $row[5],
+                'shape' => $row[6],
+                'work_point_id' => $work_point ? $work_point->id : '',
+                'status' => $status ? $status->id : '',
+                'quantity' => (int)$row[7]
+            ];
+            $this->model->create($data);
+//            $num = (int)$row[7];
+//            for($i = 0; $i < $num; ++$i) {
+//                $this->model->create($data);
+//            }
+        }
+        return true;
+    }
+}

+ 16 - 0
app/Models/DeviceName.php

xqd
@@ -8,4 +8,20 @@ class DeviceName extends BaseModel
     {
         return $this->belongsTo('App\Models\Device', 'device_id');
     }
+
+    public function getNameSpecOptions()
+    {
+        $names = DeviceName::select('name as text', 'id as value')->get();
+        $names = $names->prepend($this->transObject(['text' => '设备名称', 'value' => '']));
+        foreach($names as $name) {
+            $specs  = Spec::where('device_name_id', $name->value)->select('name as text', 'id as value')->get();
+            $name->specs = $specs->prepend($this->transObject(['text' => '规格型号', 'value' => '']));
+        }
+        return $names;
+    }
+
+    public function transObject($items)
+    {
+        return json_decode(json_encode($items));
+    }
 }

+ 0 - 3
app/Models/InnerDevice.php

xqd
@@ -45,9 +45,6 @@ class InnerDevice extends BaseModel
             'number.required' => '固定资产编号'
         ]);
         $validator->after(function ($validator) use($request) {
-            if (!$request->input('device_id')) {
-                $validator->errors()->add('device_id', '设备类型必填');
-            }
             if (!$request->input('device_name_id')) {
                 $validator->errors()->add('device_name_id', '设备名称必填');
             }

+ 19 - 5
app/Models/ProjectUser.php

xqd
@@ -16,13 +16,27 @@ class ProjectUser extends BaseModel
         return $this->belongsTo('App\Models\User', 'user_id');
     }
 
+    public function project()
+    {
+        return $this->belongsTo('App\Models\Project', 'project_id');
+    }
+
     public function getValidator(Request $request, $type)
     {
-        $validator = Validator::make($request->input('data'), [
-            'user_id' => 'required'
-        ], [
-            'user_id.required' => '用户必选'
-        ]);
+        if($type == 'store') {
+            $validator = Validator::make($request->input('data'), [
+                'user_id' => 'required'
+            ], [
+                'user_id.required' => '用户必选'
+            ]);
+        } else {
+            $validator = Validator::make($request->input('data'), [
+                'project_role_id' => 'required'
+            ], [
+                'project_role_id.required' => '角色必选'
+            ]);
+        }
+
         return $validator;
     }
 }

+ 3 - 0
app/Models/User.php

xqd
@@ -99,6 +99,9 @@ class User extends Authenticatable
     {
         $project_role_ids = ProjectUser::where('user_id', $this['id'])->pluck('project_role_id');
         $project_role = ProjectRole::whereIn('id', $project_role_ids)->orderBy('level', 'desc')->first();
+        if($project_role) {
+            $project_role->rights = $project_role->getRights();
+        }
         return $project_role;
     }
 

+ 29 - 0
app/Models/UserAuth.php

xqd
@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Models;
+
+class UserAuth extends BaseModel
+{
+    public function user()
+    {
+        return $this->belongsTo('App\Models\User', 'user_id');
+    }
+
+    public function project()
+    {
+        return $this->belongsTo('App\Models\Project', 'project_id');
+    }
+
+    public function project_role()
+    {
+        return $this->belongsTo('App\Models\ProjectRole', 'project_role_id');
+    }
+
+    public function getActive($type)
+    {
+        if($type == 'label') {
+            return $this['active'] == 1 ? '<span class="layui-badge layui-bg-blue">通过</span>' : '<span class="layui-badge layui-bg-orange">待审核</span>';
+        }
+        return $this['active'];
+    }
+}

+ 1 - 0
composer.json

xqd
@@ -14,6 +14,7 @@
         "laravel/framework": "5.5.*",
         "laravel/passport": "^4.0",
         "laravel/tinker": "~1.0",
+        "maatwebsite/excel": "^3.1",
         "overtrue/laravel-wechat": "^5.1"
     },
     "require-dev": {

+ 37 - 0
database/migrations/2021_01_09_220211_create_user_auths_table.php

xqd
@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserAuthsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_auths', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('name', 200)->nullable();
+            $table->unsignedInteger('user_id')->nullable();
+            $table->unsignedInteger('project_id')->nullable();
+            $table->unsignedInteger('project_role_id')->nullable();
+            $table->string('remark', 200)->nullable();
+            $table->tinyInteger('active')->nullable()->default(2)->comment('1激活,2未激活');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_auths');
+    }
+}

+ 30 - 0
database/migrations/2021_01_10_094507_add_quantity_to_inner_devices.php

xqd
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddQuantityToInnerDevices extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('inner_devices', function (Blueprint $table) {
+            $table->unsignedInteger('quantity')->after('id')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+}

+ 1 - 1
database/seeds/AdminMenuSeeder.php

xqd
@@ -14,7 +14,7 @@ class AdminMenuSeeder extends Seeder
     public function run()
     {
         $fileSystem = new Filesystem();
-        $database = $fileSystem->get(base_path('database/seeds') . '/' . 'railway_two.sql');
+        $database = $fileSystem->get(base_path('database/seeds') . '/' . 'admin_menus.sql');
         DB::connection()->getPdo()->exec($database);
     }
 }

+ 113 - 0
database/seeds/admin_menus.sql

xqd
@@ -0,0 +1,113 @@
+-- phpMyAdmin SQL Dump
+-- version 4.7.4
+-- https://www.phpmyadmin.net/
+--
+-- Host: 127.0.0.1:3306
+-- Generation Time: 2021-01-10 11:18:42
+-- 服务器版本: 5.7.19
+-- PHP Version: 7.3.10
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET AUTOCOMMIT = 0;
+START TRANSACTION;
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- Database: `railway_two`
+--
+
+-- --------------------------------------------------------
+
+--
+-- 表的结构 `admin_menus`
+--
+
+DROP TABLE IF EXISTS `admin_menus`;
+CREATE TABLE IF NOT EXISTS `admin_menus` (
+  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+  `pid` int(11) NOT NULL,
+  `path` char(60) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'URL',
+  `name` char(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '节点的名字',
+  `display` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1为显示为菜单,0则不显示',
+  `sort` int(11) NOT NULL DEFAULT '1' COMMENT '排序',
+  `level` tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几级菜单',
+  `ico` char(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '菜单图标',
+  `mark` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '备注',
+  `created_at` timestamp NULL DEFAULT NULL,
+  `updated_at` timestamp NULL DEFAULT NULL,
+  `deleted_at` timestamp NULL DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `idx_deleted_at` (`deleted_at`)
+) ENGINE=MyISAM AUTO_INCREMENT=630 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+
+--
+-- 转存表中的数据 `admin_menus`
+--
+
+INSERT INTO `admin_menus` (`id`, `pid`, `path`, `name`, `display`, `sort`, `level`, `ico`, `mark`, `created_at`, `updated_at`, `deleted_at`) VALUES
+(1, 0, '#', '系统管理', 0, 2, 1, 'fa-globe', '', '2016-12-31 16:00:00', '2020-11-28 04:07:16', NULL),
+(2, 0, '#', '账号管理', 1, 100, 1, 'fa-users', '', '2016-12-31 16:00:00', '2020-12-03 05:24:31', NULL),
+(3, 0, '#', '商品管理', 0, 98, 1, 'fa-calendar', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(5, 0, '#', '公共权限', 0, 0, 1, 'fa-cart-plus', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(6, 0, '#', '缓存管理', 0, 94, 1, 'fa-magic', '', '2016-12-31 16:00:00', '2020-11-28 04:06:58', NULL),
+(7, 0, '#', '数据报表', 0, 96, 1, 'fa-globe', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(9, 0, '#', '参数设置', 0, 95, 1, 'fa-bar-chart-o', '', '2017-01-04 10:32:17', '2020-11-28 04:06:49', NULL),
+(103, 1, 'Base/Menus/index', '菜单管理', 1, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(104, 1, 'Base/Role/index', '角色管理', 1, 0, 2, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(105, 1, 'Base/User/index', '账号管理', 1, 0, 2, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(501, 5, 'Base/Index/index', '首页(必选)', 0, 0, 2, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(502, 5, 'Base/Index/welcome', '欢迎页', 0, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(503, 5, 'Base/Login/logout', '退出页', 0, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(519, 103, 'Base/Menus/create', '添加菜单', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(520, 103, 'Base/Menus/update', '修改菜单', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(521, 103, 'Base/Menus/destroy', '删除菜单', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(522, 104, 'Base/Role/create', '添加角色', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(523, 104, 'Base/Role/update', '修改角色', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(524, 104, 'Base/Role/auth', '角色授权', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(525, 104, 'Base/Role/destroy', '删除角色', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(526, 105, 'Base/User/update', '编辑用户', 0, 0, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(543, 5, 'Base/Attachment/upload', '编辑器上传', 0, 0, 2, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(544, 105, 'Base/User/auth', '为用户授权', 0, 1, 3, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(578, 1, 'Base/Crud/create', 'Crud', 1, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(579, 6, 'Cache/File/clearcache', '清空缓存', 1, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(580, 6, 'Cache/File/clearview', '清空模板缓存', 1, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(581, 6, 'Cache/File/clearsessions', '强制在线用户下线', 1, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(582, 6, 'Cache/File/index', '文件管理', 1, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(583, 6, 'Cache/File/view', '文件查看', 0, 0, 1, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(596, 1, 'Base/Settings/index', '系统配置', 1, 0, 2, '', '', '2016-03-29 11:42:29', '2016-03-29 11:42:29', NULL),
+(597, 2, 'AdminUser/index', '账号列表', 1, 100, 2, '', '账号列表', '2017-04-04 22:39:13', '2020-12-03 05:24:42', NULL),
+(613, 0, '#', '项目管理', 1, 120, 1, 'iconfont icon-xiangmu', '项目管理', '2020-12-03 05:33:10', '2020-12-03 05:39:54', NULL),
+(542, 5, 'Foundation/Attachment/webupload', '文件上传', 0, 0, 2, '', '', '2016-12-31 16:00:00', '2016-12-31 16:00:00', NULL),
+(604, 596, 'Base/Settings/create', '添加', 0, 1, 1, '', ' ', '2017-05-30 20:56:09', '2017-05-30 20:56:09', NULL),
+(605, 596, 'Base/Settings/update', '修改', 0, 1, 1, '', ' ', '2017-05-30 20:56:09', '2017-05-30 20:56:09', NULL),
+(606, 596, 'Base/Settings/destroy', '删除', 0, 1, 1, '', ' ', '2017-05-30 20:56:09', '2017-05-30 20:56:09', NULL),
+(607, 596, 'Base/Settings/view', '查看', 0, 1, 1, '', ' ', '2017-05-30 20:56:09', '2017-05-30 20:56:09', NULL),
+(608, 596, 'Base/Settings/check', '选择数据', 0, 1, 1, '', ' ', '2017-05-30 20:56:09', '2017-05-30 20:56:09', NULL),
+(609, 1, 'Base/Photos/index', '图片管理', 1, 1, 2, '', '图片管理', '2017-08-01 22:43:20', '2017-08-01 22:43:21', NULL),
+(612, 0, '#', '订单管理', 1, 110, 1, 'iconfont icon-icon', '订单管理', '2020-12-03 05:27:41', '2020-12-03 05:40:07', NULL),
+(614, 0, '#', '角色管理', 1, 130, 1, 'iconfont icon-role', '角色管理', '2020-12-03 05:39:38', '2020-12-03 05:42:28', NULL),
+(615, 612, 'Order/index', '订单列表', 1, 100, 2, 'fa-bar-chart-o', '订单列表', '2020-12-03 05:40:32', '2020-12-03 05:40:55', NULL),
+(616, 613, 'Project/index', '项目列表', 1, 100, 2, 'fa-bar-chart-o', '项目列表', '2020-12-03 05:41:31', '2020-12-03 05:41:31', NULL),
+(617, 614, 'ProjectRole/index', '角色列表', 1, 100, 2, 'fa-bar-chart-o', '角色列表', '2020-12-03 05:42:03', '2020-12-24 05:51:42', NULL),
+(618, 0, '#', '设备管理', 1, 150, 1, 'iconfont icon-shebei', '设备管理', '2020-12-03 05:43:56', '2020-12-03 05:49:41', NULL),
+(619, 618, 'InnerDevice/index', '内部设备列表', 1, 100, 2, 'fa-bar-chart-o', '内部设备列表', '2020-12-03 05:44:24', '2021-01-09 14:42:34', NULL),
+(620, 0, '/', '首页', 1, 160, 1, 'iconfont icon-shouye', '首页', '2020-12-03 05:46:20', '2020-12-03 05:49:33', NULL),
+(621, 0, '#', '用户管理', 1, 140, 1, 'iconfont icon-yonghu', '用户管理', '2020-12-03 05:48:56', '2020-12-03 05:48:56', NULL),
+(622, 621, '/User/index', '用户列表', 1, 100, 2, 'fa-bar-chart-o', '用户列表', '2020-12-03 05:50:13', '2020-12-03 05:50:13', NULL),
+(623, 621, 'UserReset/index', '密码重置', 1, 90, 2, 'fa-bar-chart-o', '密码重置', '2020-12-03 17:16:37', '2020-12-03 17:16:37', NULL),
+(624, 618, 'Device/index', '设备类型', 1, 90, 2, 'fa-bar-chart-o', '设备类型', '2020-12-23 17:10:37', '2020-12-23 17:10:37', NULL),
+(625, 618, 'DeviceName/index', '设备名称', 1, 80, 2, 'fa-bar-chart-o', '设备名称', '2020-12-23 17:11:18', '2020-12-23 17:11:18', NULL),
+(626, 618, 'Spec/index', '规格型号', 1, 70, 2, 'fa-bar-chart-o', '规格型号', '2020-12-23 17:11:36', '2020-12-23 17:11:36', NULL),
+(628, 614, 'ProjectRoleRight/index', '权限管理', 1, 80, 2, 'fa-bar-chart-o', '权限管理', '2020-12-30 09:38:06', '2020-12-30 09:44:38', NULL),
+(629, 621, 'UserAuth/index', '用户授权', 1, 80, 2, 'fa-bar-chart-o', '用户授权', '2021-01-09 14:20:16', '2021-01-09 14:21:50', NULL);
+COMMIT;
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

+ 5 - 5
mini/app.json

xqd xqd
@@ -1,9 +1,11 @@
 {
   "pages": [
-    "pages/data/index",
-    "pages/filter-data/index",
-    "pages/data-center/index",
     "pages/index/index",
+    "pages/bind/index",
+    "pages/account/index",
+    "pages/data-center/index",
+    "pages/filter-data/index",
+    "pages/data/index",
     "pages/filter/index",
     "pages/add-inner-device/index",
     "pages/project/index",
@@ -15,9 +17,7 @@
     "pages/notification/index",
     "pages/about/index",
     "pages/feedback/index",
-    "pages/account/index",
     "pages/password/index",
-    "pages/bind/index",
     "pages/user/index",
     "pages/note-detail/index",
     "pages/draft/index",

+ 31 - 8
mini/custom-tab-bar/index.js

xqd xqd xqd
@@ -6,17 +6,20 @@ Component({
 			{
 				icon: 'home-o',
 				text: '首页',
-				url: '/pages/index/index'
+				url: '/pages/index/index',
+				hidden: false
 			},
 			{
 				icon: 'bar-chart-o',
 				text: '数据中心',
-				url: '/pages/data/index'
+				url: '/pages/data/index',
+				hidden: true
 			},
 			{
 				icon: 'user-o',
 				text: '个人中心',
-				url: '/pages/account/index'
+				url: '/pages/account/index',
+				hidden: false
 			}
 		],
 		role: ''
@@ -29,10 +32,21 @@ Component({
 	},
 
 	methods: {
-		onChange(event) {
-			this.setData({ active: event.detail });
+		onChange(e) {
+			this.setData({ active: e.detail });
+			var active = e.detail
+			var cnt = -1;
+			var list = this.data.list
+			var url = '';
+			for(var i = 0; i < list.length; ++i) {
+				if(!list[i].hidden) cnt = cnt + 1;
+				if(cnt == active) {
+					url = list[i].url
+					break;
+				}
+			}
 			wx.switchTab({
-				url: this.data.list[event.detail].url
+				url: url
 			});
 		},
 
@@ -42,13 +56,22 @@ Component({
 			var role = userInfo ? userInfo.topRole : ''
 			var list = this.data.initList
 			if(role && role.key == 'leader') {
-				list = this.data.initList.slice(1)
+				// list = this.data.initList.slice(1)
+				list[0].hidden = true;
+			}
+			if(role && role.rights && role.rights.dataView) {
+				list[1].hidden = false;
 			}
 			this.setData({
 				list: list
 			})
+			var active = -1;
+			for(var i = 0; i < list.length; ++i) {
+				if(!list[i].hidden) active = active + 1;
+				if(list[i].url == '/' + page.route) break;
+			}
 			this.setData({
-				active: this.data.list.findIndex(item => item.url === `/${page.route}`)
+				active: active
 			});
 			if(role) {
 				this.setData({role})

+ 1 - 1
mini/custom-tab-bar/index.wxml

xqd
@@ -1,3 +1,3 @@
 <van-tabbar active="{{ active }}" bind:change="onChange">
-  <van-tabbar-item icon="{{ item.icon }}" wx:for="{{ list }}" wx:key="index">{{ item.text }}</van-tabbar-item>
+  <van-tabbar-item icon="{{ item.icon }}" wx:for="{{ list }}" wx:key="index" wx:if="{{!item.hidden}}">{{ item.text }}</van-tabbar-item>
 </van-tabbar>

+ 3 - 1
mini/pages/account/index.js

xqd xqd
@@ -8,7 +8,8 @@ Page({
    * 页面的初始数据
    */
   data: {
-    userInfo: null
+    userInfo: null,
+    project_num: 0
   },
 
   /**
@@ -51,6 +52,7 @@ Page({
         hasUserInfo: true
       })
     }
+    api.getByName(this, 'projects/getTotal', 'project_num');
   },
 
   /**

+ 8 - 4
mini/pages/account/index.wxml

xqd xqd
@@ -10,10 +10,14 @@
             <image src="./out.png" alt="" mode="widthFix" style="width:40rpx"></image>
           </view>
         </view>
-        <view class="sg-font-small sg-flex sg-align-center" style="justify-content: space-between;">
-          <view wx:if="userInfo">所属项目个数 | xx个</view>
+        <view class="sg-font-small sg-flex sg-align-center" style="justify-content: space-between;" >
+          <view wx:if="userInfo">所属项目个数 | {{project_num}}个</view>
           <view bindtap="navigate" data-url="{{userInfo ? '/pages/user/index' : '/pages/login/index'}}">{{ userInfo ? '修改用户信息' : '点击按钮进行登录操作' }}</view>
         </view>
+        <view wx:if="{{project_num <= 0}}" class="sg-margin-tb-sm sg-pad-sm sg-primary sg-font-xs sg-white sg-flex sg-align-center sg-space-between" style="background: #4281F0; border-radius: 5px" bindtap="navigate" data-url="/pages/bind/index">
+          <view>联系管理员进行授权,进行项目查看</view>
+          <van-icon name="arrow"></van-icon>
+        </view>
       </view>
     </view>
     <view wx:if="{{!userInfo}}"
@@ -24,11 +28,11 @@
     </view>
   </view>
   <view class="sg-white-bg">
-    <view class="sg-flex sg-align-center sg-space-between sg-pad sg-bottom-border" bindtap="navigate"
+    <!-- <view class="sg-flex sg-align-center sg-space-between sg-pad sg-bottom-border" bindtap="navigate"
       data-url="/pages/bind/index">
       <view>绑定微信</view>
       <van-icon class="sg-icon" name="arrow"></van-icon>
-    </view>
+    </view> -->
     <view class="sg-flex sg-align-center sg-space-between sg-pad sg-bottom-border" bindtap="navigate"
       data-url="/pages/password/index">
       <view>修改密码</view>

+ 60 - 4
mini/pages/bind/index.js

xqd xqd xqd
@@ -1,13 +1,19 @@
 // pages/bind/index.js
 import util from '../../utils/util'
-
+import http from '../../utils/http'
+import api from '../../utils/api'
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    projects: [],
+    projectIndex: -1,
+    roles: [],
+    roleIndex: -1,
+    name: '',
+    remark: ''
   },
 
   /**
@@ -17,12 +23,61 @@ Page({
 
   },
 
+  onInputChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    var val = e.detail.value
+    this.setData({
+      [name]: val
+    })
+  },
+
   getUserInfo: function(e) {
+    var that = this;
     util.wechatLogin(e, false, function(res) {
-      util.success('绑定成功')
+      that.submit()
     }, true)
   },
 
+  submit: function() {
+    if(!this.data.name) {
+      util.error('真实姓名必填')
+      return false;
+    }
+    if(!this.data.projectIndex < 0) {
+      util.error('所属项目必填')
+      return false;
+    }
+    if(!this.data.roleIndex < 0) {
+      util.error('申请角色不能为空')
+      return false;
+    }
+    if(this.data.remark.length < 10) {
+      util.error('备注需10个字以上')
+      return false;
+    }
+    var project = this.data.projects[this.data.projectIndex]
+    var role = this.data.roles[this.data.roleIndex]
+    http({
+      url: 'user-auth/create',
+      data: {
+        name: this.data.name,
+        project_id: project ? project.id : '',
+        project_role_id: role ? role.id : '',
+        remark: this.data.remark
+      },
+      success: function(res) {
+        util.success('操作成功')
+      }
+    })
+  },
+
+  bindPickerChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail.value
+    })
+  },
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
@@ -34,7 +89,8 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-
+    api.getByName(this, 'projects/getAll', 'projects')
+    api.getByName(this, 'project-roles/getAll', 'roles', {'limit': true})
   },
 
   /**

+ 1 - 1
mini/pages/bind/index.json

xqd
@@ -1,4 +1,4 @@
 {
-  "navigationBarTitleText": "绑定微信通知",
+  "navigationBarTitleText": "用户授权",
   "usingComponents": {}
 }

+ 34 - 3
mini/pages/bind/index.wxml

xqd
@@ -1,6 +1,37 @@
 <!--pages/bind/index.wxml-->
-<view class="sg-container">
+<view class="sg-container sg-white-bg">
   <view class="sg-pad">
-    <van-button type="primary" block open-type="getUserInfo" bind:getuserinfo="getUserInfo">绑定微信</van-button>
+    <view class="sg-pick-box">
+      <view class="sg-pick-item sg-pad-tb-sm sg-flex sg-align-center sg-bottom-border sg-space-between">
+        <view class="sg-pick-name">真实姓名</view>
+        <input type="text" value="{{name}}" placeholder="请输入真实姓名" data-name="name" bindchange="onInputChange" class="sg-gray-color" style="text-align: right"/>
+      </view>
+      <view class="sg-pick-item sg-pad-tb-sm sg-flex sg-align-center sg-bottom-border sg-space-between">
+        <view class="sg-pick-name">所属项目</view>
+        <picker bindchange="bindPickerChange" value="{{projectIndex}}" range="{{projects}}" range-key="name"
+          data-name="projectIndex">
+          <view class="picker sg-gray-color">
+            {{projectIndex >= 0 ? projects[projectIndex].name : '请选择添加项目'}}
+          </view>
+        </picker>
+      </view>
+      <view class="sg-pick-item sg-pad-tb-sm sg-flex sg-align-center sg-space-between">
+        <view class="sg-pick-name">申请角色</view>
+        <picker bindchange="bindPickerChange" value="{{roleIndex}}" range="{{roles}}" range-key="name"
+          data-name="roleIndex">
+          <view class="picker sg-gray-color">
+            {{roleIndex >= 0 ? roles[roleIndex].name : '请选择角色'}}
+          </view>
+        </picker>
+      </view>
+      <view class="sg-pick-item sg-pad-tb-sm sg-bottom-border">
+        <view class="sg-pick-name">备注</view>
+        <textarea value="{{remark}}" placeholder="请填写10个字以上的备注描述以便管理员能快速通过授权" data-name="remark" bindinput="onInputChange" class="sg-gray-color sg-pad-tb-sm" maxlength="200"/>
+        <view class="sg-text-right sg-gray-color sg-pad-tb-sm">{{remark.length}}/200</view>
+      </view>
+    </view>
+    <view class="sg-margin-tb">
+      <van-button type="info" block open-type="getUserInfo" bind:getuserinfo="getUserInfo">提交</van-button>
+    </view>
   </view>
-</view>
+</view>

+ 1 - 1
mini/pages/data-center/index.wxml

xqd
@@ -3,7 +3,7 @@
   <view class="sg-flex sg-pad sg-align-center sg-index-bg">
     <view class="sg-white-bg sg-pad-sm sg-flex-grow sg-gray-color sg-flex sg-align-center" bindtap="switchShow"
       data-show="{{true}}" data-name="projectShow">
-      <view class="sg-flex-grow">{{project_names ? project_names : '选择查看项目'}}</view>
+      <view class="sg-flex-grow">{{'选择查看项目'}}</view>
       <van-icon name="arrow-down"></van-icon>
     </view>
     <van-icon name="search" class="sg-icon sg-white sg-pad-sm" style="padding-right: 0" bindtap="getData"></van-icon>

+ 147 - 25
mini/pages/data/index.js

xqd xqd xqd xqd
@@ -45,7 +45,14 @@ Page({
    */
   data: {
     projects: [],
+    project_id: '',
     project_ids: [],
+    sort_types: [
+      { text: '筛选类型', value: '' },
+      { text: '按年筛选', value: 'year' },
+      { text: '按月筛选', value: 'month' }
+    ],
+    sort_type: '',
     project_names: '',
     year_money: '0',
     month_money: '0',
@@ -98,8 +105,17 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    var that = this
-    api.getByName(this, 'projects/getAll', 'projects', {});
+    app.resetDataFilter()
+    api.getByName(this, 'projects/getAll', 'projects', {type: 'drop_menu'});
+  },
+
+  changeChartIndex: function(e) {
+    var type = e.currentTarget.dataset.type
+    var chartIndex = this.data.chartIndex
+    chartIndex = type == '+' ? (chartIndex + 1) : (chartIndex - 1)
+    if(chartIndex < 0 || chartIndex > 2) return false;
+    this.setData({chartIndex})
+    this.getChartData()
   },
 
   updateValue: function (e) {
@@ -139,52 +155,153 @@ Page({
   getChartData: function () {
     var chartIndex = this.data.chartIndex
     var that = this
-    if (chartIndex == 1) {
-      http({
-        url: 'data/projectStat',
-        data: {
-          date: this.data.date,
-          orderBy: this.data.orderBy
-        },
-        success: function (res) {
-          if (res.code == 0) {
-            that.setData({
-              data: res.data
-            })
-            that.updateChart()
-          }
-        }
-      })
+    var data = {
+      date: this.data.date,
+      orderBy: this.data.orderBy,
+      chartIndex: chartIndex,
+      project_id: this.data.project_id,
+      sort_type: this.data.sort_type
     }
+    data = Object.assign({}, data, this.data.filter)
+    http({
+      url: 'data/projectStat',
+      data: data,
+      success: function (res) {
+        if (res.code == 0) {
+          that.setData({
+            data: res.data
+          })
+          that.updateChart()
+        }
+      }
+    })
+  },
+  onChange(e) {
+    var name = e.currentTarget.dataset.name
+    var val = e.detail
+    this.setData({
+      [name]: val
+    })
+    this.getChartData()
   },
   updateChart: function () {
     var data = this.data.data
-    option.legend = {
-      data: data.legends
-    }
     var chartIndex = this.data.chartIndex
-    if (chartIndex == 1) {
+    if(chartIndex == 0) {
       option.xAxis = [{
         type: 'value'
       }]
+      
+      option.legend = {
+        data: data.legends,
+        bottom: 40
+      }
+      var title = '设备租赁费用明细'
+      var date = this.data.date
+      date = date.length > 7 ? date.substr(0, 4) + '年' : ''
+      title = (data.project ? data.project.name + '-' : '-') + date + title
+      option.title = {
+        text: title,
+        left: 'center',
+        bottom: 20
+      }
       option.yAxis = [{
         type: 'category',
-        axisTick: {
-          show: false
+        data: data.names
+      }];
+      var values = data.values
+      
+      option.series = [{
+        label: {
+          show: true
         },
+        name: data.name,
+        type: 'bar',
+        data: values
+      }]
+      option.grid = {
+        left: 20,
+        right: 20,
+        bottom: 60,
+        top: 0,
+        containLabel: true
+      }
+    } else if (chartIndex == 1) {
+      option.xAxis = [{
+        type: 'value'
+      }]
+      
+      option.legend = {
+        data: data.legends,
+        bottom: 40
+      }
+      var title = '项目租赁总费用排行'
+      var date = this.data.date
+      date = date.length > 7 ? date.substr(0, 7) : ''
+      title = date + title
+      option.title = {
+        text: title,
+        left: 'center',
+        bottom: 20
+      }
+      option.yAxis = [{
+        type: 'category',
         data: data.names
       }];
       var values = data.values
       
       option.series = [{
         label: {
-          show: false
+          show: true
         },
         name: '租赁费用',
         type: 'bar',
         data: values
       }]
+      option.grid = {
+        left: 20,
+        right: 20,
+        bottom: 60,
+        top: 0,
+        containLabel: true
+      }
       // chart.resize({width: '80vw', height: '80vh'})
+    } else {
+      option.xAxis = [{
+        type: 'value'
+      }]
+      
+      option.legend = {
+        data: data.legends,
+        bottom: 40
+      }
+      var title = '设备最大单价费用排行'
+      option.title = {
+        text: title,
+        left: 'center',
+        bottom: 20
+      }
+      option.yAxis = [{
+        type: 'category',
+        data: data.names
+      }];
+      var values = data.values
+      
+      option.series = [{
+        label: {
+          show: true
+        },
+        name: '租赁最大单价',
+        type: 'bar',
+        data: values
+      }]
+      option.grid = {
+        left: 20,
+        right: 20,
+        bottom: 60,
+        top: 0,
+        containLabel: true
+      }
     }
 
     chart.setOption(option)
@@ -226,6 +343,11 @@ Page({
    */
   onShow: function () {
     this.getTabBar().init();
+    var filter = wx.getStorageSync('sg-data-filters')
+    this.setData({
+      filter: filter
+    })
+    this.getChartData()
   },
 
   navigate: function (e) {

+ 38 - 30
mini/pages/data/index.wxml

xqd xqd
@@ -1,21 +1,15 @@
 <!--pages/data/index.wxml-->
 <view class="sg-container sg-index-bg">
   <van-popup show="{{ projectShow }}" position="bottom" custom-style="height: 100%;">
-    <view>
-      <view class="sg-flex sg-align-center sg-space-between sg-fix-top sg-white-bg sg-pad sg-white-bg"
-        style="box-sizing: border-box;z-index:100">
-        <view></view>
-        <view class="sg-bold">选择项目</view>
-        <view class="sg-gray-color" bindtap="closeProject" data-show="{{false}}" data-name="projectShow">确定</view>
-      </view>
-      <view class="sg-list sg-pad" style="margin-top: 80rpx">
-        <view wx:for="{{projects}}" wx:key="index"
-          class="sg-flex sg-align-center sg-space-between sg-pad-tb-sm sg-bottom-border {{item.checked ? 'sg-index-color' : ''}}"
-          bindtap="switchCheck" data-index="{{index}}">
-          <view>{{item.name}}</view>
-          <van-icon name="{{item.checked ? 'passed' : 'circle'}}" class="sg-icon" />
-        </view>
-      </view>
+    <van-dropdown-menu>
+      <van-dropdown-item value="{{ project_id }}" options="{{ projects }}" bind:change="onChange"
+        data-name="project_id" />
+      <van-dropdown-item value="{{ sort_type }}" options="{{ sort_types }}" bind:change="onChange"
+        data-name="sort_type" />
+    </van-dropdown-menu>
+    <view class="sg-pad">
+      <van-button type="info" block bind:click="switchShow" data-show="{{false}}" data-name="projectShow">确定
+      </van-button>
     </view>
   </van-popup>
   <view class="sg-white sg-bold sg-flex sg-align-center sg-space-around">
@@ -39,26 +33,40 @@
   </view>
   <view class="sg-white-bg sg-chart-box">
     <view class="sg-flex sg-pad sg-align-center sg-space-between">
-      <view>
-        <van-icon name="ascending" wx:if="{{orderBy == 'asc'}}" class="sg-index-color sg-icon-lg" bindtap="updateValue" data-name="orderBy" data-value="desc"/>
-        <van-icon name="descending" wx:else class="sg-index-color sg-icon-lg" bindtap="updateValue" data-name="orderBy" data-value="asc"/>
+      <view wx:if="{{chartIndex == 0}}">
+        <van-icon name="setting-o" class="sg-icon-lg" bindtap="switchShow" data-name="projectShow"
+          data-show="{{true}}" />
+      </view>
+      <view wx:elif="{{chartIndex == 1}}">
+        <van-icon name="ascending" wx:if="{{orderBy == 'asc'}}" class="sg-index-color sg-icon-lg" bindtap="updateValue"
+          data-name="orderBy" data-value="desc" />
+        <van-icon name="descending" wx:else class="sg-index-color sg-icon-lg" bindtap="updateValue" data-name="orderBy"
+          data-value="asc" />
+      </view>
+      <view wx:elif="{{chartIndex == 2}}">
+        <van-icon name="ascending" wx:if="{{orderBy == 'asc'}}" class="sg-index-color sg-icon-lg sg-margin-right"
+          bindtap="updateValue" data-name="orderBy" data-value="desc" />
+        <van-icon name="descending" wx:else class="sg-index-color sg-icon-lg sg-margin-right" bindtap="updateValue"
+          data-name="orderBy" data-value="asc" />
+        <van-icon name="filter-o" class="sg-index-color sg-icon-lg" bindtap="navigate"
+          data-url="/pages/filter-data/index" />
       </view>
       <view class="sg-flex sg-align-center">
-        <!-- <view class="sg-radio-group sg-flex sg-align-center sg-fon-small sg-margin-right sg-light-gray-bg">
-            <view class="sg-radio {{index == dateIndex ? 'sg-shadow sg-selected sg-index-bg sg-white sg-bold' : ''}}"
-              wx:for="{{dateTypes}}" wx:key="index" data-index="{{index}}" data-name="dateIndex" bindtap="radioChange">
-              {{item.name}}</view>
-          </view> -->
-        <van-icon name="notes-o" class="sg-icon-lg sg-margin-right" bindtap="switchShow" data-name="dateShow"
-          data-show="{{true}}"></van-icon>
-        <van-icon name="filter-o" class="sg-icon-lg" bindtap="navigate" data-url="/pages/filter-data/index">
-        </van-icon>
+        <view class="sg-flex sg-align-center" bindtap="navigate" data-url="/pages/data-center/index">
+          <van-icon name="search" class="sg-icon-lg sg-index-color" bindtap="switchShow" data-name="dateShow"
+            data-show="{{true}}"></van-icon>
+          <text class="sg-index-color">条件查找</text>
+        </view>
       </view>
     </view>
-    <view class="sg-chart sg-flex sg-align-center sg-justify-center">
-      <!-- <van-icon name="arrow-left" class="sg-icon-lg sg-index-color" hidden="{{chartIndex == 0}}"/> -->
+    <view class="sg-chart sg-flex sg-align-center sg-space-between" hidden="{{projectShow}}">
+      <view hidden="{{chartIndex == 0}}" bindtap="changeChartIndex" data-type="-">
+        <van-icon name="arrow-left" class="sg-icon-lg sg-index-color" />
+      </view>
       <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
-      <!-- <van-icon name="arrow" class="sg-icon-lg sg-index-color"  hidden="{{chartIndex == 2}}"/> -->
+      <view hidden="{{chartIndex == 0}}" hidden="{{chartIndex == 2}}" bindtap="changeChartIndex" data-type="+">
+        <van-icon name="arrow" class="sg-icon-lg sg-index-color" />
+      </view>
     </view>
   </view>
 </view>

+ 1 - 2
mini/pages/data/index.wxss

xqd
@@ -19,7 +19,6 @@
   margin-bottom: 200rpx;
 }
 .sg-chart {
-  width: 90vw;
+  width: 100vw;
   height: 70vh;
-  margin-left: 5vw;
 }

+ 1 - 1
mini/pages/filter-data/index.wxml

xqd
@@ -55,7 +55,7 @@
                   data-name="spec_ids" data-index="{{index}}"  disabled="{{ device_name_ids.length > 1 }}"/>
               </van-dropdown-menu>
               <van-button icon="cross" color="#1989fa" type="danger" bindtap="delete"
-                data-name="spec_ids" data-index="{{index}}" disabled="{{index == 0}}" disabled="{{ device_name_ids.length > 1 }}"></van-button>
+                data-name="spec_ids" data-index="{{index}}" disabled="{{index == 0}}"></van-button>
             </view>
           </view>
           <view class="sg-margin-tb">

BIN
public/设备导入模板.xlsx


+ 32 - 19
resources/views/admin/inner-devices/create.blade.php

xqd xqd
@@ -7,25 +7,36 @@
 @endsection
 
 @section('content')
-    <div class="layui-container sg-create-container">
-        <div class="layui-col-sm8 layui-col-sm-offset2">
-            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
-
-                {{ csrf_field() }}
-                @include('share.device-select-form', ['device_id' => '', 'device_name_id' => '', 'spec_id' => '', 'options' => $options])
-                @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => (old('data') ? old('data')['status'] : ''), 'options' => $status_options])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => (old('data') ? old('data')['number'] : '')])
-                @include('share.layui-form-item', ['id' => 'sg-produce-date', 'type' => 'date', 'name' => 'produce_date', 'label' => '出厂日期', 'required' => true, 'value' => (old('data') ? old('data')['produce_date'] : '')])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'shape', 'label' => '外形尺寸', 'required' => true, 'value' => (old('data') ? old('data')['shape'] : '')])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'buy_origin', 'label' => '采购原值', 'required' => true, 'value' => (old('data') ? old('data')['buy_origin'] : '')])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'manufacturer', 'label' => '生产厂家', 'required' => true, 'value' => (old('data') ? old('data')['manufacturer'] : '')])
-                <div class="layui-form-item">
-                    <div class="layui-input-block">
-                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
-                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
-                    </div>
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            创建设备
+            <div class="sg-card-create">
+                <button id="sg-back-btn" class="layui-btn layui-btn-sm">返回</button>
+            </div>
+        </div>
+        <div class="layui-card-body">
+            <div class="layui-container sg-create-container">
+                <div class="layui-col-sm8 layui-col-sm-offset2">
+                    <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
+
+                        {{ csrf_field() }}
+                        @include('share.name-select-form', ['device_name_id' => '', 'spec_id' => '', 'options' => $options])
+                        @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => (old('data') ? old('data')['status'] : ''), 'options' => $status_options])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => (old('data') ? old('data')['number'] : '')])
+                        @include('share.layui-form-item', ['id' => 'sg-produce-date', 'type' => 'date', 'name' => 'produce_date', 'label' => '出厂日期', 'required' => true, 'value' => (old('data') ? old('data')['produce_date'] : '')])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'shape', 'label' => '外形尺寸', 'required' => true, 'value' => (old('data') ? old('data')['shape'] : '')])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'buy_origin', 'label' => '采购原值', 'required' => true, 'value' => (old('data') ? old('data')['buy_origin'] : '')])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'manufacturer', 'label' => '生产厂家', 'required' => true, 'value' => (old('data') ? old('data')['manufacturer'] : '')])
+                        <div class="layui-form-item">
+                            <div class="layui-input-block">
+                                <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                            </div>
+                        </div>
+                    </form>
                 </div>
-            </form>
+            </div>
+
         </div>
     </div>
 @endsection
@@ -46,7 +57,9 @@
                 //     }
                 // });
 
-                console.log($('.sg-select-date')[0]);
+                $('#sg-back-btn').on('click', function () {
+                    window.history.go(-1)
+                });
 
                 laydate.render({
                     elem: '.sg-select-date'

+ 33 - 20
resources/views/admin/inner-devices/edit.blade.php

xqd xqd
@@ -7,28 +7,39 @@
 @endsection
 
 @section('content')
-    <div class="layui-container sg-create-container">
-        <div class="layui-col-sm8 layui-col-sm-offset2">
-            <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
-
-                {{ csrf_field() }}
-                <input type="hidden" name="id" value="{{ $item->id }}">
-                @include('share.device-select-form', ['device_id' => $item->device_id, 'device_name_id' => $item->device_name_id, 'spec_id' => $item->spec_id, 'options' => $options])
-                @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => $item->status, 'options' => $status_options])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => $item->number])
-                @include('share.layui-form-item', ['id' => 'sg-produce-date', 'type' => 'date', 'name' => 'produce_date', 'label' => '出厂日期', 'required' => true, 'value' => $item->produce_date])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'shape', 'label' => '外形尺寸', 'required' => true, 'value' => $item->shape])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'buy_origin', 'label' => '采购原值', 'required' => true, 'value' => $item->buy_origin])
-                @include('share.layui-form-item', ['type' => 'input', 'name' => 'manufacturer', 'label' => '生产厂家', 'required' => true, 'value' => $item->manufacturer])
-                <div class="layui-form-item">
-                    <div class="layui-input-block">
-                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
-                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
-                    </div>
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            编辑设备
+            <div class="sg-card-create">
+                <button id="sg-back-btn" class="layui-btn layui-btn-sm">返回</button>
+            </div>
+        </div>
+        <div class="layui-card-body">
+            <div class="layui-container sg-create-container">
+                <div class="layui-col-sm8 layui-col-sm-offset2">
+                    <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
+
+                        {{ csrf_field() }}
+                        <input type="hidden" name="id" value="{{ $item->id }}">
+                        @include('share.name-select-form', ['device_name_id' => $item->device_name_id, 'spec_id' => $item->spec_id, 'options' => $options])
+                        @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => $item->status, 'options' => $status_options])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => $item->number])
+                        @include('share.layui-form-item', ['id' => 'sg-produce-date', 'type' => 'date', 'name' => 'produce_date', 'label' => '出厂日期', 'required' => true, 'value' => $item->produce_date])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'shape', 'label' => '外形尺寸', 'required' => true, 'value' => $item->shape])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'buy_origin', 'label' => '采购原值', 'required' => true, 'value' => $item->buy_origin])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'manufacturer', 'label' => '生产厂家', 'required' => true, 'value' => $item->manufacturer])
+                        <div class="layui-form-item">
+                            <div class="layui-input-block">
+                                <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                            </div>
+                        </div>
+                    </form>
                 </div>
-            </form>
+            </div>
         </div>
     </div>
+
 @endsection
 
 @section('footer')
@@ -47,7 +58,9 @@
                 //     }
                 // });
 
-                console.log($('.sg-select-date')[0]);
+                $('#sg-back-btn').on('click', function () {
+                    window.history.go(-1)
+                });
 
                 laydate.render({
                     elem: '.sg-select-date'

+ 176 - 41
resources/views/admin/inner-devices/index.blade.php

xqd xqd xqd xqd xqd xqd
@@ -2,7 +2,44 @@
 
 @section('header')
     <style>
-
+        .sg-search-box {
+            display: flex;
+            align-items: center;
+            justify-content: space-between;
+        }
+        .sg-import-box {
+            display: none;
+        }
+        .sg-import-box.sg-show {
+            display: block;
+        }
+        .sg-import-box .layui-col-sm8 {
+            float: none;
+        }
+        .layui-card .layui-form-item .layui-inline {
+            margin-bottom: 0;
+        }
+        .sg-export-list {
+            margin: 50px 0;
+        }
+        .sg-export-list .sg-item {
+            margin: 20px 0;
+        }
+        .sg-export-list .sg-item .sg-title {
+            margin: 20px 0;
+        }
+        .sg-export-list .sg-item .sg-desc,
+        .sg-export-list .sg-item ul {
+            color: rgb(140, 140, 140);
+            margin-left: 30px;
+        }
+        .sg-down-link {
+            color: blue;
+            text-decoration: underline;
+        }
+        .sg-down-link:hover {
+            color: blue;
+        }
     </style>
 @endsection
 
@@ -15,33 +52,40 @@
             </div>
         </div>
         <div class="layui-card-body">
-            <form class="layui-form" id="sg-search-form">
-                <div class="layui-form-item layui-row">
-                    @include('share.device-select', ['device_id' => '', 'device_name_id' => '', 'spec_id' => '', 'options' => $options])
-                    <div class="layui-inline">
-                        <div class="layui-input-inline">
-                            <select name="status">
-                                <option value="0">状态</option>
-                                @foreach($statuses as $option)
-                                    <option value="{{ $option['id'] }}" {{ request('status') == $option['id'] ? 'selected' : ''  }}>{{ $option['name'] }}</option>
-                                @endforeach
-                            </select>
+            <div class="sg-search-box">
+                <form class="layui-form" id="sg-search-form">
+                    <div class="layui-form-item layui-row" style="margin-bottom: 0">
+                        @include('share.name-select', ['device_name_id' => '', 'spec_id' => '', 'options' => $options])
+                        <div class="layui-inline">
+                            <div class="layui-input-inline">
+                                <select name="status">
+                                    <option value="0">状态</option>
+                                    @foreach($statuses as $option)
+                                        <option value="{{ $option['id'] }}" {{ request('status') == $option['id'] ? 'selected' : ''  }}>{{ $option['name'] }}</option>
+                                    @endforeach
+                                </select>
+                            </div>
                         </div>
-                    </div>
-                    <div class="layui-inline">
-                        <div class="layui-input-inline">
-                            <input type="text" name="number" placeholder="请输入固定资产编号" autocomplete="off" class="layui-input" value="{{ request('number') }}">
+                        <div class="layui-inline">
+                            <div class="layui-input-inline">
+                                <input type="text" name="number" placeholder="请输入固定资产编号" autocomplete="off" class="layui-input" value="{{ request('number') }}">
+                            </div>
+                        </div>
+                        <div class="layui-inline">
+                            <div class="layui-btn" id="sg-search-btn">搜索</div>
                         </div>
                     </div>
-                    <div class="layui-inline">
-                        <div class="layui-btn" id="sg-search-btn">搜索</div>
-                    </div>
+                </form>
+                <div>
+                    <button id="sg-import-all" class="layui-btn layui-btn-normal">导入</button>
                 </div>
-            </form>
+            </div>
             <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
             <script type="text/html" id="sg-table-bar">
                 <div class="layui-btn-group">
                     <div class="layui-btn-group">
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="apply">调用记录</a>
+                        <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="repair">维修记录</a>
                         <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                         <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
                     </div>
@@ -49,6 +93,27 @@
             </script>
         </div>
     </div>
+    <div id="sg-import-box" class="sg-import-box">
+        <div class="layui-row">
+            {{--<input type="file" id="sg-upload-file">--}}
+            <div class="layui-col-sm8 layui-col-sm-offset2">
+                <div class="sg-export-list">
+                    <div class="sg-item">
+                        <h3 class="sg-title">一、请按照数据模板的格式准备要导入的数据。<a href="{{ $pre_uri . 'exportTemplate?t=' . time() }}" class="sg-down-link">点击下载</a>《设备导入模板》</h3>
+                        <ul>
+                            <li>注意事项</li>
+                            <li>1、模板中的表头名称不能更改,表头行不能删除</li>
+                            <li>2、导入文件请勿超过 20 MB</li>
+                        </ul>
+                    </div>
+                    <div class="sg-item">
+                        <h3 class="sg-title">二、请选择需要导入的文件</h3>
+                        <div class="sg-desc"><input type="file" id="sg-upload-file"></div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
 @endsection
 
 @section('footer')
@@ -62,20 +127,84 @@
                     laydate = layui.laydate,
                     top_window = window;
 
+                $('#sg-import-all').click(function() {
+                    layer.open({
+                        title: '导入项目',
+                        type: 1,
+                        area: ['90%', '90%'],
+                        content: $('#sg-import-box'),
+                        btn: ['导入', '取消'],
+                        yes: function () {
+                            importFile();
+                        }
+                    });
+                    // $('#sg-upload-file').click();
+                });
+
+                function importFile() {
+                    var file = $('#sg-upload-file')[0].files[0];
+                    if(file) {
+                        var name = file['name'];
+                        var ext = name.split('.').pop();
+                        if(['xls', 'xlsx'].indexOf(ext) !== -1) {
+                            var formData = new FormData();
+                            formData.append('file', file);
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'import',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: formData,
+                                contentType: false,
+                                cache: false,
+                                processData: false,
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        layer.msg('上传成功', {
+                                            icon: 1
+                                        });
+                                        setTimeout(function() {
+                                            top_window.location.reload();
+                                        }, 1000)
+                                    } else {
+                                        layer.alert(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                },
+                                error: function () {
+                                    layer.msg('导入失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        }
+                    } else {
+                        layer.msg('只支持xls,xlsx格式的文件', {
+                            icon: 2
+                        });
+                    }
+                    this.value = '';
+                }
+
                 table.render({
                     elem: '#sg-main-table',
                     url: '{{ $pre_uri }}' + 'get',
                     cellMinWidth: 80,
                     cols: [[
                         { field: 'id', title: 'ID', align: 'center' },
-                        { field: 'device_type', title: '类型', align: 'center' },
+                        { field: 'number', title: '固定资产编号', align: 'center' },
                         { field: 'device_name_name', title: '名称', align: 'center' },
                         { field: 'spec_name', title: '规格型号', align: 'center' },
-                        { field: 'number', title: '固定资产编号', align: 'center' },
                         { field: 'produce_date', title: '出厂日期', align: 'center' },
+                        { field: 'buy_origin', title: '采购原值', align: 'center' },
+                        { field: 'manufacturer', title: '生产厂家', align: 'center' },
                         { field: 'shape', title: '外形尺寸', align: 'center' },
+                        { field: 'quantity', title: '数量', align: 'center' },
+                        { field: 'work_point_name', title: '目前工点', align: 'center' },
                         { field: 'status', title: '状态', align: 'center' },
-                        { title: '操作', align:'center', toolbar: '#sg-table-bar' }
+                        { title: '操作', align:'center', toolbar: '#sg-table-bar', width: '200' },
                     ]],
                     page: {
                         layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
@@ -119,15 +248,20 @@
                             });
                         });
                     } else if(obj.event === 'edit') {
-                        layer.open({
-                            title: '编辑成员',
-                            type: 2,
-                            area: ['90%', '90%'],
-                            content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
-                            end: function () {
-                                top_window.location.reload();
-                            }
-                        });
+                        window.location = '{{ $pre_uri }}' + 'edit?id=' + data.id;
+                        {{--layer.open({--}}
+                            {{--title: '编辑成员',--}}
+                            {{--type: 2,--}}
+                            {{--area: ['90%', '90%'],--}}
+                            {{--content: '{{ $pre_uri }}' + 'edit?id=' + data.id,--}}
+                            {{--end: function () {--}}
+                                {{--top_window.location.reload();--}}
+                            {{--}--}}
+                        {{--});--}}
+                    } else if(obj.event === 'apply') {
+                        window.location = '/admin/OrderDevice/index?inner_device_id=' + data.id;
+                    } else if(obj.event === 'repair') {
+                        window.location = '/admin/RepairDevice/index?inner_device_id=' + data.id;
                     }
                 });
 
@@ -178,15 +312,16 @@
                 // });
 
                 $('#sg-create-btn').on('click', function () {
-                    layer.open({
-                        title: '创建' + '{{ $model_name }}',
-                        type: 2,
-                        area: ['90%', '90%'],
-                        content: '{{ $pre_uri }}' + 'create',
-                        end: function () {
-                            top_window.location.reload();
-                        }
-                    });
+                    window.location = '{{ $pre_uri }}' + 'create';
+                    {{--layer.open({--}}
+                        {{--title: '创建' + '{{ $model_name }}',--}}
+                        {{--type: 2,--}}
+                        {{--area: ['90%', '90%'],--}}
+                        {{--content: '{{ $pre_uri }}' + 'create',--}}
+                        {{--end: function () {--}}
+                            {{--top_window.location.reload();--}}
+                        {{--}--}}
+                    {{--});--}}
                 });
 
                 $('#sg-table-top-container').on('click', '.btn-delete-many', function () {

+ 53 - 0
resources/views/admin/order-devices/create.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
+
+                {{ csrf_field() }}
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => (old('data') ? old('data')['key'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => (old('data') ? old('data')['level'] : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 54 - 0
resources/views/admin/order-devices/edit.blade.php

xqd
@@ -0,0 +1,54 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
+
+                {{ csrf_field() }}
+                <input type="hidden" name="id" value="{{ $item->id }}">
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => ($item->name ? $item->name : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => ($item->key ? $item->key : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => ($item->level ? $item->level : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 228 - 0
resources/views/admin/order-devices/index.blade.php

xqd
@@ -0,0 +1,228 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            {{ $model_name }}管理-{{$inner_device->device_name_name}}-{{$inner_device->spec_name}}
+            <div class="sg-card-create">
+                @if(request('inner_device_id'))
+                    <button id="sg-back-btn" class="layui-btn layui-btn-sm">返回</button>
+                @else
+                    <button id="sg-create-btn" class="layui-btn layui-btn-sm">创建</button>
+                @endif
+            </div>
+        </div>
+        <div class="layui-card-body">
+            <form class="layui-form" id="sg-search-form">
+                <input type="hidden" name="inner_device_id" value="{{ request('inner_device_id') }}">
+                <div class="layui-form-item layui-row">
+                    <div class="layui-inline">
+                        <div class="layui-input-inline">
+                            <input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{{ request('name') }}">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <div class="layui-btn" id="sg-search-btn">搜索</div>
+                    </div>
+                </div>
+            </form>
+            <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
+            <script type="text/html" id="sg-table-bar">
+                <div class="layui-btn-group">
+                    <div class="layui-btn-group">
+                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
+                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
+                    </div>
+                </div>
+            </script>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['table', 'layer'], function(){
+                var table = layui.table,
+                    layer = layui.layer,
+                    form = layui.form,
+                    laydate = layui.laydate,
+                    top_window = window;
+
+                $('#sg-back-btn').on('click', function () {
+                    window.history.go(-1);
+                });
+                table.render({
+                    elem: '#sg-main-table',
+                    url: '{{ $pre_uri }}' + 'get',
+                    cellMinWidth: 80,
+                    cols: [[
+                        { field: 'id', title: 'ID', align: 'center' },
+                        { field: 'user_name', title: '调用人', align: 'center' },
+                        { field: 'project_name', title: '调用项目', align: 'center' },
+                        { field: 'start_date', title: '调用开始时间', align: 'center' },
+                        { field: 'end_date', title: '调用结束时间', align: 'center' },
+                        // { title: '操作', align:'center', toolbar: '#sg-table-bar' }
+                    ]],
+                    page: {
+                        layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
+                        limit: 15
+                    },
+                    even: true,
+                    where: transformToJson($('#sg-search-form').serializeArray()),
+                    done: function(res, curr, count) {
+
+                    }
+                });
+                table.on('tool(tableEvent)', function(obj){
+                    var data = obj.data;
+                    if(obj.event === 'delete'){
+                        layer.confirm('确定要删除吗?', function(index) {
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'delete',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: {
+                                    id: data.id
+                                },
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        obj.del();
+                                    } else {
+                                        layer.msg(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                    layer.close(index);
+                                },
+                                error: function () {
+                                    layer.close(index);
+                                    layer.msg('删除失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        });
+                    } else if(obj.event === 'edit') {
+                        layer.open({
+                            title: '编辑成员',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
+                    }
+                });
+
+                if($('#search-begin-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-begin-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                if($('#search-end-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-end-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                function transformToJson(formData){
+                    var obj={};
+                    for (var i in formData) {
+                        obj[formData[i].name]=formData[i]['value'];
+                    }
+                    return obj;
+                }
+
+                function updateTableBySearch() {
+                    table.reload('sg-main-table', {
+                        where: transformToJson($('#sg-search-form').serializeArray()),
+                        page: {
+                            curr: 1
+                        }
+                    });
+                }
+
+                $('#sg-search-btn').click(function() {
+                    updateTableBySearch();
+                });
+                // $('#sg-search-form').change(function () {
+                //     updateTableBySearch();
+                // });
+                //
+                // form.on('select()', function(){
+                //     updateTableBySearch();
+                // });
+
+                $('#sg-create-btn').on('click', function () {
+                    layer.open({
+                        title: '创建' + '{{ $model_name }}',
+                        type: 2,
+                        area: ['90%', '90%'],
+                        content: '{{ $pre_uri }}' + 'create',
+                        end: function () {
+                            top_window.location.reload();
+                        }
+                    });
+                });
+
+                $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
+                    layer.confirm('确定要删除所有选中行吗?', function () {
+                        var data = table.checkStatus('sg-main-table').data;
+                        if(data.length <= 0) {
+                            layer.msg('选择不能为空', {
+                                icon: 2
+                            });
+                            return false;
+                        }
+                        var ids = [];
+                        for(var i = 0; i < data.length; ++i) {
+                            ids.push(data[i]['id']);
+                        }
+                        $.ajax({
+                            method: 'POST',
+                            url: '{{ $pre_uri }}' + 'deleteMany',
+                            headers: {
+                                'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                            },
+                            data: {
+                                ids: JSON.stringify(ids)
+                            },
+                            success: function (data) {
+                                if(data.status === 'success') {
+                                    top_window.location.reload();
+                                } else {
+                                    layer.msg(data.info, {
+                                        icon: 2
+                                    });
+                                }
+
+                            },
+                            error: function () {
+                                layer.msg('删除失败', {
+                                    icon: 2
+                                });
+                            }
+                        });
+                    })
+                });
+            });
+        })
+    </script>
+@endsection

+ 53 - 0
resources/views/admin/parts/create.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
+
+                {{ csrf_field() }}
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => (old('data') ? old('data')['key'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => (old('data') ? old('data')['level'] : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 54 - 0
resources/views/admin/parts/edit.blade.php

xqd
@@ -0,0 +1,54 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
+
+                {{ csrf_field() }}
+                <input type="hidden" name="id" value="{{ $item->id }}">
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => ($item->name ? $item->name : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => ($item->key ? $item->key : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => ($item->level ? $item->level : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 230 - 0
resources/views/admin/parts/index.blade.php

xqd
@@ -0,0 +1,230 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            {{ $model_name }}管理
+        </div>
+        <div class="layui-card-body">
+            <form class="layui-form" id="sg-search-form">
+                <input type="hidden" name="repair_device_id" value="{{ request('repair_device_id') }}">
+                <div class="layui-form-item layui-row">
+                    <div class="layui-inline">
+                        <div class="layui-input-inline">
+                            <input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{{ request('name') }}">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <div class="layui-btn" id="sg-search-btn">搜索</div>
+                    </div>
+                </div>
+            </form>
+            <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
+            <script type="text/html" id="sg-table-bar">
+                <div class="layui-btn-group">
+                    <div class="layui-btn-group">
+                        <a class="layui-btn layui-btn-xs" lay-event="part">维修部件</a>
+                    </div>
+                </div>
+            </script>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['table', 'layer'], function(){
+                var table = layui.table,
+                    layer = layui.layer,
+                    form = layui.form,
+                    laydate = layui.laydate,
+                    top_window = window;
+
+                $('#sg-back-btn').on('click', function () {
+                    window.history.go(-1);
+                });
+                table.render({
+                    elem: '#sg-main-table',
+                    url: '{{ $pre_uri }}' + 'get',
+                    cellMinWidth: 80,
+                    cols: [[
+                        { field: 'id', title: 'ID', align: 'center' },
+                        { field: 'name', title: '维修部位', align: 'center' },
+                        { field: 'change', title: '更换配件', align: 'center' },
+                        { field: 'price', title: '配件价格', align: 'center' },
+                        // { field: 'remark', title: '备注', align: 'center' },
+                        // { title: '操作', align:'center', toolbar: '#sg-table-bar' }
+                    ]],
+                    page: {
+                        layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
+                        limit: 15
+                    },
+                    even: true,
+                    where: transformToJson($('#sg-search-form').serializeArray()),
+                    done: function(res, curr, count) {
+
+                    }
+                });
+                table.on('tool(tableEvent)', function(obj){
+                    var data = obj.data;
+                    if(obj.event === 'delete'){
+                        layer.confirm('确定要删除吗?', function(index) {
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'delete',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: {
+                                    id: data.id
+                                },
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        obj.del();
+                                    } else {
+                                        layer.msg(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                    layer.close(index);
+                                },
+                                error: function () {
+                                    layer.close(index);
+                                    layer.msg('删除失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        });
+                    } else if(obj.event === 'edit') {
+                        layer.open({
+                            title: '编辑成员',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
+                    } else if(obj.event === 'part') {
+                        layer.open({
+                            title: '维修部件',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '/admin/Part/index?repair_device_id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
+                    }
+                });
+
+                if($('#search-begin-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-begin-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                if($('#search-end-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-end-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                function transformToJson(formData){
+                    var obj={};
+                    for (var i in formData) {
+                        obj[formData[i].name]=formData[i]['value'];
+                    }
+                    return obj;
+                }
+
+                function updateTableBySearch() {
+                    table.reload('sg-main-table', {
+                        where: transformToJson($('#sg-search-form').serializeArray()),
+                        page: {
+                            curr: 1
+                        }
+                    });
+                }
+
+                $('#sg-search-btn').click(function() {
+                    updateTableBySearch();
+                });
+                // $('#sg-search-form').change(function () {
+                //     updateTableBySearch();
+                // });
+                //
+                // form.on('select()', function(){
+                //     updateTableBySearch();
+                // });
+
+                $('#sg-create-btn').on('click', function () {
+                    layer.open({
+                        title: '创建' + '{{ $model_name }}',
+                        type: 2,
+                        area: ['90%', '90%'],
+                        content: '{{ $pre_uri }}' + 'create',
+                        end: function () {
+                            top_window.location.reload();
+                        }
+                    });
+                });
+
+                $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
+                    layer.confirm('确定要删除所有选中行吗?', function () {
+                        var data = table.checkStatus('sg-main-table').data;
+                        if(data.length <= 0) {
+                            layer.msg('选择不能为空', {
+                                icon: 2
+                            });
+                            return false;
+                        }
+                        var ids = [];
+                        for(var i = 0; i < data.length; ++i) {
+                            ids.push(data[i]['id']);
+                        }
+                        $.ajax({
+                            method: 'POST',
+                            url: '{{ $pre_uri }}' + 'deleteMany',
+                            headers: {
+                                'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                            },
+                            data: {
+                                ids: JSON.stringify(ids)
+                            },
+                            success: function (data) {
+                                if(data.status === 'success') {
+                                    top_window.location.reload();
+                                } else {
+                                    layer.msg(data.info, {
+                                        icon: 2
+                                    });
+                                }
+
+                            },
+                            error: function () {
+                                layer.msg('删除失败', {
+                                    icon: 2
+                                });
+                            }
+                        });
+                    })
+                });
+            });
+        })
+    </script>
+@endsection

+ 53 - 0
resources/views/admin/project-user-roles/create.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
+
+                {{ csrf_field() }}
+                <input type="hidden" name="data[user_id]" value="{{ request('user_id') }}">
+                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_id', 'label' => '项目', 'selected_id' => (old('data') ? old('data')['project_id'] : ''), 'options' => $project_options])
+                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_role_id', 'label' => '角色', 'selected_id' => (old('data') ? old('data')['project_role_id'] : ''), 'options' => $role_options])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 53 - 0
resources/views/admin/project-user-roles/edit.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
+
+                {{ csrf_field() }}
+                <input type="hidden" name="id" value="{{ $item->id }}">
+                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_id', 'label' => '项目', 'selected_id' => $item->user_id, 'options' => $project_options])
+                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_role_id', 'label' => '角色', 'selected_id' => $item->project_role_id, 'options' => $role_options])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 219 - 0
resources/views/admin/project-user-roles/index.blade.php

xqd
@@ -0,0 +1,219 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            {{ $model_name }}管理:{{$user->name}}
+            <div class="sg-card-create">
+                <button id="sg-create-btn" class="layui-btn layui-btn-sm">创建</button>
+            </div>
+        </div>
+        <div class="layui-card-body">
+            <form class="layui-form" id="sg-search-form">
+                <input type="hidden" name="user_id" value="{{ request('user_id') }}">
+                {{--<div class="layui-form-item layui-row">--}}
+                    {{--<div class="layui-inline">--}}
+                        {{--<div class="layui-input-inline">--}}
+                            {{--<input type="text" name="name" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{{ request('name') }}">--}}
+                        {{--</div>--}}
+                    {{--</div>--}}
+                    {{--<div class="layui-inline">--}}
+                        {{--<div class="layui-btn" id="sg-search-btn">搜索</div>--}}
+                    {{--</div>--}}
+                {{--</div>--}}
+            </form>
+            <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
+            <script type="text/html" id="sg-table-bar">
+                <div class="layui-btn-group">
+                    <div class="layui-btn-group">
+                        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
+                        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
+                    </div>
+                </div>
+            </script>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['table', 'layer'], function(){
+                var table = layui.table,
+                    layer = layui.layer,
+                    form = layui.form,
+                    laydate = layui.laydate,
+                    top_window = window;
+
+                table.render({
+                    elem: '#sg-main-table',
+                    url: '{{ $pre_uri }}' + 'get',
+                    cellMinWidth: 80,
+                    cols: [[
+                        { field: 'id', title: 'ID', align: 'center' },
+                        { field: 'project_name', title: '项目', align: 'center' },
+                        { field: 'role_name', title: '角色', align: 'center' },
+                        { title: '操作', align:'center', toolbar: '#sg-table-bar' }
+                    ]],
+                    page: {
+                        layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
+                        limit: 15
+                    },
+                    even: true,
+                    where: transformToJson($('#sg-search-form').serializeArray()),
+                    done: function(res, curr, count) {
+
+                    }
+                });
+                table.on('tool(tableEvent)', function(obj){
+                    var data = obj.data;
+                    if(obj.event === 'delete'){
+                        layer.confirm('确定要删除吗?', function(index) {
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'delete',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: {
+                                    id: data.id
+                                },
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        obj.del();
+                                    } else {
+                                        layer.msg(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                    layer.close(index);
+                                },
+                                error: function () {
+                                    layer.close(index);
+                                    layer.msg('删除失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        });
+                    } else if(obj.event === 'edit') {
+                        layer.open({
+                            title: '编辑成员',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
+                    }
+                });
+
+                if($('#search-begin-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-begin-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                if($('#search-end-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-end-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                function transformToJson(formData){
+                    var obj={};
+                    for (var i in formData) {
+                        obj[formData[i].name]=formData[i]['value'];
+                    }
+                    return obj;
+                }
+
+                function updateTableBySearch() {
+                    table.reload('sg-main-table', {
+                        where: transformToJson($('#sg-search-form').serializeArray()),
+                        page: {
+                            curr: 1
+                        }
+                    });
+                }
+
+                $('#sg-search-btn').click(function() {
+                    updateTableBySearch();
+                });
+                // $('#sg-search-form').change(function () {
+                //     updateTableBySearch();
+                // });
+                //
+                // form.on('select()', function(){
+                //     updateTableBySearch();
+                // });
+
+                $('#sg-create-btn').on('click', function () {
+                    layer.open({
+                        title: '创建' + '{{ $model_name }}',
+                        type: 2,
+                        area: ['90%', '90%'],
+                        content: '{{ $pre_uri }}' + 'create?user_id=' + '{{ request('user_id') }}',
+                        end: function () {
+                            top_window.location.reload();
+                        }
+                    });
+                });
+
+                $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
+                    layer.confirm('确定要删除所有选中行吗?', function () {
+                        var data = table.checkStatus('sg-main-table').data;
+                        if(data.length <= 0) {
+                            layer.msg('选择不能为空', {
+                                icon: 2
+                            });
+                            return false;
+                        }
+                        var ids = [];
+                        for(var i = 0; i < data.length; ++i) {
+                            ids.push(data[i]['id']);
+                        }
+                        $.ajax({
+                            method: 'POST',
+                            url: '{{ $pre_uri }}' + 'deleteMany',
+                            headers: {
+                                'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                            },
+                            data: {
+                                ids: JSON.stringify(ids)
+                            },
+                            success: function (data) {
+                                if(data.status === 'success') {
+                                    top_window.location.reload();
+                                } else {
+                                    layer.msg(data.info, {
+                                        icon: 2
+                                    });
+                                }
+
+                            },
+                            error: function () {
+                                layer.msg('删除失败', {
+                                    icon: 2
+                                });
+                            }
+                        });
+                    })
+                });
+            });
+        })
+    </script>
+@endsection

+ 53 - 0
resources/views/admin/repair-devices/create.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
+
+                {{ csrf_field() }}
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => (old('data') ? old('data')['key'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => (old('data') ? old('data')['level'] : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 54 - 0
resources/views/admin/repair-devices/edit.blade.php

xqd
@@ -0,0 +1,54 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
+
+                {{ csrf_field() }}
+                <input type="hidden" name="id" value="{{ $item->id }}">
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => ($item->name ? $item->name : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => ($item->key ? $item->key : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => ($item->level ? $item->level : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 239 - 0
resources/views/admin/repair-devices/index.blade.php

xqd
@@ -0,0 +1,239 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            {{ $model_name }}管理-{{$inner_device->device_name_name}}-{{$inner_device->spec_name}}
+            <div class="sg-card-create">
+                @if(request('inner_device_id'))
+                    <button id="sg-back-btn" class="layui-btn layui-btn-sm">返回</button>
+                @else
+                    <button id="sg-create-btn" class="layui-btn layui-btn-sm">创建</button>
+                @endif
+            </div>
+        </div>
+        <div class="layui-card-body">
+            <form class="layui-form" id="sg-search-form">
+                <input type="hidden" name="inner_device_id" value="{{ request('inner_device_id') }}">
+                <div class="layui-form-item layui-row">
+                    <div class="layui-inline">
+                        <div class="layui-input-inline">
+                            <input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{{ request('name') }}">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <div class="layui-btn" id="sg-search-btn">搜索</div>
+                    </div>
+                </div>
+            </form>
+            <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
+            <script type="text/html" id="sg-table-bar">
+                <div class="layui-btn-group">
+                    <div class="layui-btn-group">
+                        <a class="layui-btn layui-btn-xs" lay-event="part">维修部件</a>
+                    </div>
+                </div>
+            </script>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['table', 'layer'], function(){
+                var table = layui.table,
+                    layer = layui.layer,
+                    form = layui.form,
+                    laydate = layui.laydate,
+                    top_window = window;
+
+                $('#sg-back-btn').on('click', function () {
+                    window.history.go(-1);
+                });
+                table.render({
+                    elem: '#sg-main-table',
+                    url: '{{ $pre_uri }}' + 'get',
+                    cellMinWidth: 80,
+                    cols: [[
+                        { field: 'id', title: 'ID', align: 'center' },
+                        { field: 'user_name', title: '提交人', align: 'center' },
+                        { field: 'project_name', title: '项目', align: 'center' },
+                        { field: 'money', title: '金额', align: 'center' },
+                        { field: 'reason', title: '维修原因', align: 'center' },
+                        { field: 'day', title: '维修天数', align: 'center' },
+                        { field: 'remark', title: '备注', align: 'center' },
+                        { title: '操作', align:'center', toolbar: '#sg-table-bar' }
+                    ]],
+                    page: {
+                        layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
+                        limit: 15
+                    },
+                    even: true,
+                    where: transformToJson($('#sg-search-form').serializeArray()),
+                    done: function(res, curr, count) {
+
+                    }
+                });
+                table.on('tool(tableEvent)', function(obj){
+                    var data = obj.data;
+                    if(obj.event === 'delete'){
+                        layer.confirm('确定要删除吗?', function(index) {
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'delete',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: {
+                                    id: data.id
+                                },
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        obj.del();
+                                    } else {
+                                        layer.msg(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                    layer.close(index);
+                                },
+                                error: function () {
+                                    layer.close(index);
+                                    layer.msg('删除失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        });
+                    } else if(obj.event === 'edit') {
+                        layer.open({
+                            title: '编辑成员',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '{{ $pre_uri }}' + 'edit?id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
+                    } else if(obj.event === 'part') {
+                        layer.open({
+                            title: '维修部件',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '/admin/Part/index?repair_device_id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
+                    }
+                });
+
+                if($('#search-begin-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-begin-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                if($('#search-end-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-end-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                function transformToJson(formData){
+                    var obj={};
+                    for (var i in formData) {
+                        obj[formData[i].name]=formData[i]['value'];
+                    }
+                    return obj;
+                }
+
+                function updateTableBySearch() {
+                    table.reload('sg-main-table', {
+                        where: transformToJson($('#sg-search-form').serializeArray()),
+                        page: {
+                            curr: 1
+                        }
+                    });
+                }
+
+                $('#sg-search-btn').click(function() {
+                    updateTableBySearch();
+                });
+                // $('#sg-search-form').change(function () {
+                //     updateTableBySearch();
+                // });
+                //
+                // form.on('select()', function(){
+                //     updateTableBySearch();
+                // });
+
+                $('#sg-create-btn').on('click', function () {
+                    layer.open({
+                        title: '创建' + '{{ $model_name }}',
+                        type: 2,
+                        area: ['90%', '90%'],
+                        content: '{{ $pre_uri }}' + 'create',
+                        end: function () {
+                            top_window.location.reload();
+                        }
+                    });
+                });
+
+                $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
+                    layer.confirm('确定要删除所有选中行吗?', function () {
+                        var data = table.checkStatus('sg-main-table').data;
+                        if(data.length <= 0) {
+                            layer.msg('选择不能为空', {
+                                icon: 2
+                            });
+                            return false;
+                        }
+                        var ids = [];
+                        for(var i = 0; i < data.length; ++i) {
+                            ids.push(data[i]['id']);
+                        }
+                        $.ajax({
+                            method: 'POST',
+                            url: '{{ $pre_uri }}' + 'deleteMany',
+                            headers: {
+                                'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                            },
+                            data: {
+                                ids: JSON.stringify(ids)
+                            },
+                            success: function (data) {
+                                if(data.status === 'success') {
+                                    top_window.location.reload();
+                                } else {
+                                    layer.msg(data.info, {
+                                        icon: 2
+                                    });
+                                }
+
+                            },
+                            error: function () {
+                                layer.msg('删除失败', {
+                                    icon: 2
+                                });
+                            }
+                        });
+                    })
+                });
+            });
+        })
+    </script>
+@endsection

+ 53 - 0
resources/views/admin/user-auth/create.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
+
+                {{ csrf_field() }}
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => (old('data') ? old('data')['key'] : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => (old('data') ? old('data')['level'] : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 54 - 0
resources/views/admin/user-auth/edit.blade.php

xqd
@@ -0,0 +1,54 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-container sg-create-container">
+        <div class="layui-col-sm8 layui-col-sm-offset2">
+            <form class="layui-form" method="POST" action="{{ $pre_uri . 'update' }}">
+
+                {{ csrf_field() }}
+                <input type="hidden" name="id" value="{{ $item->id }}">
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => ($item->name ? $item->name : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'key', 'label' => '键值', 'required' => true, 'value' => ($item->key ? $item->key : '')])
+                @include('share.layui-form-item', ['type' => 'input', 'name' => 'level', 'label' => '级别', 'required' => true, 'value' => ($item->level ? $item->level : '')])
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
+                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                </div>
+            </form>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['form', 'laydate'], function(){
+                var form = layui.form;
+                var laydate = layui.laydate;
+
+                // form.verify({
+                //     integer: function (value) {
+                //         var pattern = /^[1-9]\d*$/;
+                //         if(!(pattern.test(value) || value === '0')) {
+                //             return '组员人数必须为大于等于0的整数';
+                //         }
+                //     }
+                // });
+
+                laydate.render({
+                    elem: '.sg-select-date'
+                });
+            });
+        })
+    </script>
+@endsection

+ 242 - 0
resources/views/admin/user-auth/index.blade.php

xqd
@@ -0,0 +1,242 @@
+@extends('admin.layout-content')
+
+@section('header')
+    <style>
+
+    </style>
+@endsection
+
+@section('content')
+    <div class="layui-card">
+        <div class="layui-card-header sg-card-header">
+            {{ $model_name }}管理
+        </div>
+        <div class="layui-card-body">
+            <form class="layui-form" id="sg-search-form">
+                <div class="layui-form-item layui-row">
+                    <div class="layui-inline">
+                        <div class="layui-input-inline">
+                            <input type="text" name="name" placeholder="请输入名称" autocomplete="off" class="layui-input" value="{{ request('name') }}">
+                        </div>
+                    </div>
+                    <div class="layui-inline">
+                        <div class="layui-btn" id="sg-search-btn">搜索</div>
+                    </div>
+                </div>
+            </form>
+            <table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
+            <script type="text/html" id="sg-table-bar">
+                <div class="layui-btn-group">
+                    @{{# if(d.active != 1) { }}
+                    <a class="layui-btn layui-btn-xs" lay-event="pass">通过</a>
+                    @{{# } }}
+                    <div class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</div>
+                </div>
+            </script>
+        </div>
+    </div>
+@endsection
+
+@section('footer')
+    <script>
+        $(function () {
+            layui.use(['table', 'layer'], function(){
+                var table = layui.table,
+                    layer = layui.layer,
+                    form = layui.form,
+                    laydate = layui.laydate,
+                    top_window = window;
+
+                table.render({
+                    elem: '#sg-main-table',
+                    url: '{{ $pre_uri }}' + 'get',
+                    cellMinWidth: 80,
+                    cols: [[
+                        { field: 'id', title: 'ID', align: 'center' },
+                        { field: 'avatar', title: '头像', align: 'center' },
+                        { field: 'phone', title: '手机号', align: 'center' },
+                        { field: 'name', title: '真实姓名', align: 'center' },
+                        { field: 'project_name', title: '申请项目', align: 'center' },
+                        { field: 'project_role_name', title: '申请角色', align: 'center' },
+                        { field: 'remark', title: '备注', align: 'center' },
+                        { field: 'created_at', title: '提交时间', align: 'center' },
+                        { field: 'active_label', title: '状态', align: 'center' },
+                        { title: '操作', align:'center', toolbar: '#sg-table-bar' }
+                    ]],
+                    page: {
+                        layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
+                        limit: 15
+                    },
+                    even: true,
+                    where: transformToJson($('#sg-search-form').serializeArray()),
+                    done: function(res, curr, count) {
+
+                    }
+                });
+                table.on('tool(tableEvent)', function(obj){
+                    var data = obj.data;
+                    if(obj.event === 'pass') {
+                        layer.confirm('确定要通过吗?', function(index) {
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'change',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: {
+                                    active: 1,
+                                    id: data.id
+                                },
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        top_window.location.reload();
+                                    } else {
+                                        layer.msg(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                    layer.close(index);
+                                },
+                                error: function () {
+                                    layer.close(index);
+                                    layer.msg('删除失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        });
+                    } else if(obj.event === 'delete') {
+                        layer.confirm('确定删除吗?', function(index) {
+                            $.ajax({
+                                method: 'POST',
+                                url: '{{ $pre_uri }}' + 'delete',
+                                headers: {
+                                    'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                                },
+                                data: {
+                                    active: 1,
+                                    id: data.id
+                                },
+                                success: function (data) {
+                                    if(data.status === 'success') {
+                                        top_window.location.reload();
+                                    } else {
+                                        layer.msg(data.info, {
+                                            icon: 2
+                                        });
+                                    }
+                                    layer.close(index);
+                                },
+                                error: function () {
+                                    layer.close(index);
+                                    layer.msg('删除失败', {
+                                        icon: 2
+                                    });
+                                }
+                            });
+                        });
+                    }
+                });
+
+                if($('#search-begin-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-begin-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                if($('#search-end-date').length > 0) {
+                    laydate.render({
+                        elem: '#search-end-date',
+                        done: function () {
+                            updateTableBySearch();
+                        }
+                    });
+                }
+
+                function transformToJson(formData){
+                    var obj={};
+                    for (var i in formData) {
+                        obj[formData[i].name]=formData[i]['value'];
+                    }
+                    return obj;
+                }
+
+                function updateTableBySearch() {
+                    table.reload('sg-main-table', {
+                        where: transformToJson($('#sg-search-form').serializeArray()),
+                        page: {
+                            curr: 1
+                        }
+                    });
+                }
+
+                $('#sg-search-btn').click(function() {
+                    updateTableBySearch();
+                });
+                // $('#sg-search-form').change(function () {
+                //     updateTableBySearch();
+                // });
+                //
+                // form.on('select()', function(){
+                //     updateTableBySearch();
+                // });
+
+                $('#sg-create-btn').on('click', function () {
+                    layer.open({
+                        title: '创建' + '{{ $model_name }}',
+                        type: 2,
+                        area: ['90%', '90%'],
+                        content: '{{ $pre_uri }}' + 'create',
+                        end: function () {
+                            top_window.location.reload();
+                        }
+                    });
+                });
+
+                $('#sg-table-top-container').on('click', '.btn-delete-many', function () {
+                    layer.confirm('确定要删除所有选中行吗?', function () {
+                        var data = table.checkStatus('sg-main-table').data;
+                        if(data.length <= 0) {
+                            layer.msg('选择不能为空', {
+                                icon: 2
+                            });
+                            return false;
+                        }
+                        var ids = [];
+                        for(var i = 0; i < data.length; ++i) {
+                            ids.push(data[i]['id']);
+                        }
+                        $.ajax({
+                            method: 'POST',
+                            url: '{{ $pre_uri }}' + 'deleteMany',
+                            headers: {
+                                'X-CSRF-TOKEN': '{{ csrf_token() }}'
+                            },
+                            data: {
+                                ids: JSON.stringify(ids)
+                            },
+                            success: function (data) {
+                                if(data.status === 'success') {
+                                    top_window.location.reload();
+                                } else {
+                                    layer.msg(data.info, {
+                                        icon: 2
+                                    });
+                                }
+
+                            },
+                            error: function () {
+                                layer.msg('删除失败', {
+                                    icon: 2
+                                });
+                            }
+                        });
+                    })
+                });
+            });
+        })
+    </script>
+@endsection

+ 2 - 2
resources/views/admin/users/create.blade.php

xqd
@@ -13,8 +13,8 @@
 
                 {{ csrf_field() }}
                 @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '姓名', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
-                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_id', 'label' => '项目', 'selected_id' => (old('data') ? old('data')['project_id'] : ''), 'options' => $project_options])
-                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_role_id', 'label' => '项目角色', 'selected_id' => (old('data') ? old('data')['project_role_id'] : ''), 'options' => $role_options])
+                {{--@include('share.layui-form-item', ['type' => 'select', 'name' => 'project_id', 'label' => '项目', 'selected_id' => (old('data') ? old('data')['project_id'] : ''), 'options' => $project_options])--}}
+                {{--@include('share.layui-form-item', ['type' => 'select', 'name' => 'project_role_id', 'label' => '项目角色', 'selected_id' => (old('data') ? old('data')['project_role_id'] : ''), 'options' => $role_options])--}}
                 @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'input', 'name' => 'phone', 'label' => '手机号', 'required' => true, 'value' => ''])
                 @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'password', 'name' => 'password', 'label' => '密码', 'required' => true, 'value' => ''])
                 @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'password', 'name' => 'password_confirmation', 'label' => '确认密码', 'required' => true, 'value' => ''])

+ 1 - 1
resources/views/admin/users/edit.blade.php

xqd
@@ -15,7 +15,7 @@
                 <input type="hidden" name="id" value="{{ $item->id }}">
                 <input type="hidden" name="is_root" value="1">
                 @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '用户名', 'required' => true, 'value' => $item->name])
-                @include('share.layui-form-item', ['type' => 'select', 'name' => 'role_id', 'label' => '角色', 'selected_id' => $item->role_id, 'options' => $role_options])
+                {{--@include('share.layui-form-item', ['type' => 'select', 'name' => 'role_id', 'label' => '角色', 'selected_id' => $item->role_id, 'options' => $role_options])--}}
                 @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'input', 'name' => 'phone', 'label' => '手机号', 'required' => true, 'value' => $item->phone])
                 @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'password', 'name' => 'password', 'label' => '密码', 'value' => '', 'placeholder' => '请输入密码,不修改留空'])
                 @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'password', 'name' => 'password_confirmation', 'label' => '确认密码', 'value' => ''])

+ 34 - 22
resources/views/admin/users/index.blade.php

xqd xqd xqd xqd
@@ -17,26 +17,26 @@
         <div class="layui-card-body">
             <form class="layui-form" id="sg-search-form">
                 <div class="layui-form-item layui-row">
-                    <div class="layui-inline">
-                        <div class="layui-input-inline">
-                            <select name="project_id">
-                                <option value="">项目</option>
-                                @foreach($project_options as $option)
-                                    <option value="{{ $option['id'] }}" {{ request('project_id') == $option['id'] ? 'selected' : ''  }}>{{ $option['name'] }}</option>
-                                @endforeach
-                            </select>
-                        </div>
-                    </div>
-                    <div class="layui-inline">
-                        <div class="layui-input-inline">
-                            <select name="project_role_id">
-                                <option value="">项目角色</option>
-                                @foreach($role_options as $option)
-                                    <option value="{{ $option['id'] }}" {{ request('project_role_id') == $option['id'] ? 'selected' : ''  }}>{{ $option['name'] }}</option>
-                                @endforeach
-                            </select>
-                        </div>
-                    </div>
+                    {{--<div class="layui-inline">--}}
+                        {{--<div class="layui-input-inline">--}}
+                            {{--<select name="project_id">--}}
+                                {{--<option value="">项目</option>--}}
+                                {{--@foreach($project_options as $option)--}}
+                                    {{--<option value="{{ $option['id'] }}" {{ request('project_id') == $option['id'] ? 'selected' : ''  }}>{{ $option['name'] }}</option>--}}
+                                {{--@endforeach--}}
+                            {{--</select>--}}
+                        {{--</div>--}}
+                    {{--</div>--}}
+                    {{--<div class="layui-inline">--}}
+                        {{--<div class="layui-input-inline">--}}
+                            {{--<select name="project_role_id">--}}
+                                {{--<option value="">项目角色</option>--}}
+                                {{--@foreach($role_options as $option)--}}
+                                    {{--<option value="{{ $option['id'] }}" {{ request('project_role_id') == $option['id'] ? 'selected' : ''  }}>{{ $option['name'] }}</option>--}}
+                                {{--@endforeach--}}
+                            {{--</select>--}}
+                        {{--</div>--}}
+                    {{--</div>--}}
                     <div class="layui-inline">
                         <div class="layui-input-inline">
                             <input type="text" name="name" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{{ request('name') }}">
@@ -51,6 +51,7 @@
             <script type="text/html" id="sg-table-bar">
                 <div class="layui-btn-group">
                     <div class="layui-btn-group">
+                        <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="role">角色管理</a>
                         <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                         <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
                     </div>
@@ -75,10 +76,11 @@
                     url: '{{ $pre_uri }}' + 'get',
                     cellMinWidth: 80,
                     cols: [[
+                        { field: 'id', title: 'ID', align: 'center' },
                         { field: 'name', title: '姓名', align: 'center' },
                         { field: 'phone', title: '手机号', align: 'center' },
-                        { field: 'project_name', title: '项目', align: 'center' },
-                        { field: 'role_name', title: '项目角色', align: 'center' },
+                        // { field: 'project_name', title: '项目', align: 'center' },
+                        // { field: 'role_name', title: '项目角色', align: 'center' },
                         { field: 'created_at', title: '创建时间', align: 'center' },
                         { title: '操作', align:'center', toolbar: '#sg-table-bar' }
                     ]],
@@ -133,6 +135,16 @@
                                 top_window.location.reload();
                             }
                         });
+                    } else if(obj.event === 'role') {
+                        layer.open({
+                            title: '角色管理',
+                            type: 2,
+                            area: ['90%', '90%'],
+                            content: '/admin/ProjectUserRole/index?user_id=' + data.id,
+                            end: function () {
+                                top_window.location.reload();
+                            }
+                        });
                     }
                 });
 

+ 74 - 0
resources/views/share/name-select-form.blade.php

xqd
@@ -0,0 +1,74 @@
+<?php
+?>
+<style type="text/css">
+
+</style>
+<div class="layui-form-item {{ $errors->has('device_name_id') ? 'has-error' : '' }}">
+    <label class="layui-form-label" style="padding: 0px;">设备名称</label>
+    <div class="layui-input-block">
+        <select name="device_name_id" lay-filter="device_name_id">
+            @foreach($options as $option)
+                <option value="{{$option->value}}" {{$option->value == $device_name_id ? 'selected' : ''}}>{{$option->text}}</option>
+            @endforeach
+        </select>
+        @if($errors->has('device_name_id'))
+            <span class="help-block">{{ $errors->first('device_name_id') }}</span>
+        @endif
+    </div>
+    @if($errors->has('device_name_id'))
+        <span class="help-block">{{ $errors->first('device_name_id') }}</span>
+    @endif
+</div>
+
+@if(!isset($hide_spec))
+<div class="layui-form-item {{ $errors->has('spec_id') ? 'has-error' : '' }}">
+    <label class="layui-form-label" style="padding: 0px;">规格型号</label>
+    <div class="layui-input-block">
+        <select name="spec_id" lay-filter="spec_id">
+        </select>
+        @if($errors->has('spec_id'))
+            <span class="help-block">{{ $errors->first('spec_id') }}</span>
+        @endif
+    </div>
+</div>
+@endif
+<script>
+    $(function() {
+        layui.use(['form'], function() {
+            let form = layui.form;
+            let device_names = JSON.parse('{!! $options !!}');
+            let specs = [];
+            let device_name_id = '{{ $device_name_id }}';
+            let spec_id = '{{ $spec_id }}';
+            let hide_spec = '{{ isset($hide_spec) ? "yes" : "no" }}';
+            // console.log(hide_spec)
+
+            form.on('select(device_name_id)', function(data) {
+                device_name_id = data.value;
+                spec_id = '';
+                updateSpec()
+            });
+
+            updateSpec();
+
+            function updateSpec() {
+                let name_index = getIndex(device_names, device_name_id);
+                specs = device_names[name_index].specs;
+                let options = '';
+                for(let i = 0; i < specs.length; ++i) {
+                    options += '<option value=' + specs[i].value + (parseInt(specs[i].value) === parseInt(spec_id) ? ' selected' : '') + '>' + specs[i].text + '</option>'
+                }
+                $("select[name='spec_id']").html(options);
+                form.render('select');
+            }
+
+            function getIndex(list, id) {
+                id = parseInt(id);
+                for(var i = 0; i < list.length; ++i) {
+                    if(list[i].value === id) return i;
+                }
+                return 0;
+            }
+        })
+    })
+</script>

+ 64 - 0
resources/views/share/name-select.blade.php

xqd
@@ -0,0 +1,64 @@
+<?php
+?>
+<style type="text/css">
+    #sg-device-select-app {
+        display: inline;
+    }
+</style>
+<div id="sg-device-select-app">
+    <div class="layui-inline">
+        <div class="layui-input-inline">
+            <select name="device_name_id" lay-filter="device_name_id">
+                @foreach($options as $option)
+                    <option value="{{$option->value}}" {{$option->value == $device_name_id ? 'selected' : ''}}>{{$option->text}}</option>
+                @endforeach
+            </select>
+        </div>
+    </div>
+    @if(!isset($hide_spec))
+    <div class="layui-inline">
+        <div class="layui-input-inline">
+            <select name="spec_id" lay-filter="spec_id">
+            </select>
+        </div>
+    </div>
+    @endif
+</div>
+<script>
+    $(function() {
+        layui.use(['form'], function() {
+            let form = layui.form;
+            let device_names = JSON.parse('{!! $options !!}');
+            let specs = [];
+            let device_name_id = '{{ $device_name_id }}';
+            let hide_spec = '{{ isset($hide_spec) ? "yes" : "no" }}';
+
+
+            form.on('select(device_name_id)', function(data) {
+                device_name_id = data.value;
+                updateSpec()
+            });
+
+            updateSpec();
+
+            function updateSpec() {
+                let name_index = getIndex(device_names, device_name_id);
+                specs = device_names[name_index].specs;
+                let options = '';
+                for(let i = 0; i < specs.length; ++i) {
+                    options += '<option value=' + specs[i].value + '>' + specs[i].text + '</option>'
+                }
+                $("select[name='spec_id']").html(options);
+                form.render('select');
+            }
+
+            function getIndex(list, id) {
+                id = parseInt(id);
+                for(var i = 0; i < list.length; ++i) {
+                    if(list[i].value === id) return i;
+                }
+                return 0;
+            }
+        })
+    })
+</script>

+ 3 - 0
routes/api.php

xqd xqd
@@ -29,6 +29,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\mini', 'prefix' =>
     $api->any('projects/getUsers', 'ProjectController@getUsers');
     $api->any('projects/deleteUser', 'ProjectController@deleteUser');
     $api->any('projects/updateUser', 'ProjectController@updateUser');
+    $api->any('projects/getTotal', 'ProjectController@getTotal');
 
     $api->any('project-roles/create', 'ProjectRoleController@create');
     $api->any('project-roles/get', 'ProjectRoleController@get');
@@ -99,4 +100,6 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\mini', 'prefix' =>
     $api->any('feedback/create', 'FeedbackController@create');
 
     $api->any('rights/get', 'RightController@get');
+
+    $api->any('user-auth/create', 'UserAuthController@create');
 });

BIN
storage/framework/laravel-excel/laravel-excel-LF357h9OiX60NFxClIVS5Q4tlqe6K8IC.tmp


BIN
storage/framework/laravel-excel/laravel-excel-gb9BNT5rIjP5gyYBZW87ARbuK5xsrXWZ.tmp