Browse Source

Merge branch 'master' of http://git.9026.com/Silent/RailwayTwo

whj 4 years ago
parent
commit
d1174626ea
35 changed files with 1015 additions and 452 deletions
  1. 138 0
      app/Http/Controllers/Admin/Inner/Device/NamesController.php
  2. 20 11
      app/Http/Controllers/Admin/InnerDeviceController.php
  3. 1 1
      app/Http/Controllers/Admin/ProjectController.php
  4. 8 5
      app/Http/Controllers/Admin/RepairDeviceController.php
  5. 16 0
      app/Http/Controllers/Admin/SpecController.php
  6. 39 22
      app/Imports/InnerDeviceImport.php
  7. 94 0
      app/Imports/SpecImport.php
  8. 12 5
      app/Models/DeviceName.php
  9. 15 8
      app/Models/InnerDevice.php
  10. 39 0
      app/Models/InnerDeviceNamesModel.php
  11. 45 0
      app/Repositories/Inner/Device/Criteria/MultiWhere.php
  12. 21 0
      app/Repositories/Inner/Device/NamesRepository.php
  13. 0 106
      database/migrations/2021_01_24_100701_add_all_devices_table_comment.php
  14. 0 69
      database/migrations/2021_01_24_113828_add_all_user_table_comment.php
  15. 0 87
      database/migrations/2021_01_24_134009_add_all_project_table_comment.php
  16. 0 72
      database/migrations/2021_01_24_141328_add_all_order_table_comment.php
  17. 1 0
      mini/app.js
  18. 47 14
      mini/pages/data/index.js
  19. 1 1
      mini/pages/index/index.js
  20. 2 1
      mini/pages/order/index.js
  21. 6 4
      mini/pages/order/index.wxml
  22. 2 1
      mini/pages/user/index.js
  23. 2 1
      mini/project.config.json
  24. 3 3
      mini/utils/env.js
  25. 4 1
      readme.md
  26. 4 3
      resources/views/admin/inner-devices/create.blade.php
  27. 2 1
      resources/views/admin/inner-devices/edit.blade.php
  28. 18 1
      resources/views/admin/inner-devices/index.blade.php
  29. 88 0
      resources/views/admin/inner/device/names/check.blade.php
  30. 86 0
      resources/views/admin/inner/device/names/edit.blade.php
  31. 105 0
      resources/views/admin/inner/device/names/index.blade.php
  32. 32 0
      resources/views/admin/inner/device/names/view.blade.php
  33. 141 13
      resources/views/admin/specs/index.blade.php
  34. 15 14
      resources/views/share/name-select-form.blade.php
  35. 8 8
      resources/views/share/name-select.blade.php

+ 138 - 0
app/Http/Controllers/Admin/Inner/Device/NamesController.php

xqd
@@ -0,0 +1,138 @@
+<?php
+/**
+ *  内部设备名称
+ *  @author  system
+ *  @version    1.0
+ *  @date 2021-01-25 13:37:36
+ *
+ */
+namespace App\Http\Controllers\Admin\Inner\Device;
+use App\Http\Controllers\Admin\Controller;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\Inner\Device\Criteria\MultiWhere;
+use App\Repositories\Inner\Device\NamesRepository;
+
+class NamesController extends Controller
+{
+    private $repository;
+
+    public function __construct(NamesRepository $repository) {
+        if(!$this->repository) $this->repository = $repository;
+    }
+
+    function index(Request $request) {
+        $search['keyword'] = $request->input('keyword');
+        $query = $this->repository->pushCriteria(new MultiWhere($search));
+
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+        $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
+        }else{
+            $query = $query->pushCriteria(new OrderBy('updated_at','DESC'));
+        }
+        $list = $query->paginate();
+        return view('admin.inner.device.names.index',compact('list'));
+    }
+
+
+    function check(Request $request) {
+        $request = $request->all();
+        $search['keyword'] = $request->input('keyword');
+        $orderby = array();
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+            $orderby[$request['sort_field']] = $request['sort_field_by'];
+        }
+        $list = $this->repository->search($search,$orderby);
+        return view('admin.inner.device.names.check',compact('list'));
+    }
+
+
+    /**
+     * 添加
+     * 
+     */
+    public function create(Request $request)
+    {
+        if($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+        return view('admin.inner.device.names.edit');
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave(){
+        $data = (array) request('data');
+        $id = $this->repository->create($data);
+        if($id) {
+            $url[] = array('url'=>U( 'Inner/Device/Names/index'),'title'=>'返回列表');
+            $url[] = array('url'=>U( 'Inner/Device/Names/create'),'title'=>'继续添加');
+            $this->showMessage('添加成功',$url);
+        }else{
+            $url[] = array('url'=>U( 'Inner/Device/Names/index'),'title'=>'返回列表');
+            return $this->showWarning('添加失败',$url);
+        }
+    }
+    
+    /**
+     * 
+     * 修改
+     * 
+     * 
+     */
+    public function update(Request $request) {
+        if($request->method() == 'POST') {
+            return $this->_updateSave();
+        }
+        $data = $this->repository->find($request->get('id'));
+        return view('admin.inner.device.names.edit',compact('data'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave() {
+        $data = (array) request('data');
+        $ok = $this->repository->update(request('id'),$data);
+        if($ok) {
+            $url[] = array('url'=>U( 'Inner/Device/Names/index'),'title'=>'返回列表');
+            return $this->showMessage('操作成功',urldecode(request('_referer')));
+        }else{
+            $url[] = array('url'=>U( 'Inner/Device/Names/index'),'title'=>'返回列表');
+            return $this->showWarning('操作失败',$url);
+        }
+    }
+
+    public function view(Request $request) {
+        $data = $this->repository->find(request('id'));
+        return view('admin.inner.device.names.view',compact('data'));
+    }
+
+
+    /**
+     *
+     * 状态改变
+     *
+     */
+    public function status(Request $request) {
+        $ok = $this->repository->updateStatus(request('id'),request('status'));
+        if($ok) {
+            return $this->showMessage('操作成功');
+        }else{
+            return $this->showWarning('操作失败');
+        }
+    }
+    
+    /**
+     * 删除
+     */
+    public function destroy(Request $request) {
+        $bool = $this->repository->destroy($request->get('id'));
+        if($bool) {
+            return  $this->showMessage('操作成功');
+        }else{
+            return  $this->showWarning("操作失败");
+        }
+    }
+}

+ 20 - 11
app/Http/Controllers/Admin/InnerDeviceController.php

xqd xqd xqd xqd xqd
@@ -12,6 +12,7 @@ use App\Models\Project;
 use App\Models\WorkPoint;
 use Illuminate\Http\Request;
 use Maatwebsite\Excel\Facades\Excel;
+use phpDocumentor\Reflection\DocBlock;
 
 class InnerDeviceController extends BaseController
 {
@@ -43,13 +44,14 @@ class InnerDeviceController extends BaseController
     {
         $options = $this->device_name->getNameSpecOptions();
         $statuses = Option::get('inner_devices', 'status');
+        $project_id = Project::getOptions();
         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'));
+        return view($this->view_path . 'index', compact('model', 'model_name','pre_uri', 'options', 'statuses','project_id'));
     }
 
     public function get(Request $request)
     {
-        $items = $this->model->where('id', '>', 0)->with(['device', 'spec', 'device_name']);
+        $items = $this->model->where('id', '>', 0)->with(['device', 'spec', 'device_name','inner_device_names']);
 
         $tmp_items = collect(['number']);
         foreach($tmp_items as $tmp_item) {
@@ -58,19 +60,26 @@ class InnerDeviceController extends BaseController
             }
         }
 
-        $select_items = collect(['device_id', 'device_name_id', 'spec_id', 'status', 'work_point_id']);
+        $spec_items = collect(['spec_name']);
+        foreach($spec_items as $spec_item) {
+            if($request->has($spec_item) && !empty($request->input($spec_item))) {
+                $items = $items->where($spec_item, 'like', '%' . $request->input($spec_item) . '%');
+            }
+        }
+
+        $select_items = collect(['device_id', 'device_name_id', 'spec_id', 'status', 'work_point_id','project_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->orderBy('updated_at', 'desc')->paginate();
-
+//        dd($items);
         foreach ($items as $item) {
             $item->device_type = $item->device ? $item->device->name : '';
-            $item->device_name_name = $item->device_name ? $item->device_name->name : '';
-            $item->spec_name = $item->spec ? $item->spec->name : '';
+            $item->device_name_name = $item->inner_device_names ? $item->inner_device_names->name : '';
+            $item->spec_name = $item->spec_name ? $item->spec_name : '';
             $item->status = $item->getStatusLabel();
             $item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
             $item->project_name = $item->project ? $item->project->name : '';
@@ -102,10 +111,10 @@ class InnerDeviceController extends BaseController
             return back()->withErrors($validator)->withInput();
         }
         $data = $request->input('data');
-        $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
+        $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', 'project_id', 'work_point_id']));
         $res = $this->model->create($data);
         if(empty($res)) return back()->withErrors(['sg_error_info' => '保存失败']);
-        return redirect($this->pre_uri . 'create')->with(['sg_success_info' => '创建成功']);
+        return redirect($this->pre_uri . 'index')->with(['sg_success_info' => '创建成功']);
     }
 
     public function exportTemplate(Request $request)
@@ -134,10 +143,10 @@ class InnerDeviceController extends BaseController
             return back()->withErrors($validator)->withInput();
         }
         $data = $request->input('data');
-        $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_id', 'project_id', 'work_point_id']));
+        $data = array_merge($data, $request->only(['device_id', 'device_name_id', 'spec_name', 'project_id', 'work_point_id']));
         $res = $this->model->where('id', $request->input('id'))->update($data);
         if(!$res) return back()->withErrors(['sg_error_info' => '数据库保存失败!']);
-        return back()->with(['sg_success_info' => '编辑成功']);
+        return redirect($this->pre_uri . 'index')->with(['sg_success_info' => '编辑成功']);
     }
 
     public function delete(Request $request)

+ 1 - 1
app/Http/Controllers/Admin/ProjectController.php

xqd
@@ -132,7 +132,7 @@ class ProjectController extends BaseController
     public function change(Request $request)
     {
         $this->model->where('id', $request->input('id'))->update(['active' => $request->input('active')]);
-        Notification::sendProjectInfo($request->input('id'));
+//        Notification::sendProjectInfo($request->input('id'));
         return response()->json(['status' => 'success', 'info' => '操作成功']);
     }
 

+ 8 - 5
app/Http/Controllers/Admin/RepairDeviceController.php

xqd xqd xqd xqd
@@ -3,6 +3,8 @@
 namespace App\Http\Controllers\Admin;
 
 use App\Models\InnerDevice;
+use App\Models\InnerDeviceNamesModel;
+use App\Models\Option;
 use App\Models\Part;
 use App\Models\RepairDevice;
 use Illuminate\Http\Request;
@@ -44,8 +46,8 @@ class RepairDeviceController extends BaseController
 
     public function get(Request $request)
     {
-        $items = $this->model->orderBy('created_at', 'desc');
-
+        $items = $this->model->orderBy('created_at', 'desc')->with(['inner_device']);
+        //搜索名字
         $tmp_items = collect(['name']);
         foreach($tmp_items as $tmp_item) {
             if($request->has($tmp_item) && !empty($request->input($tmp_item))) {
@@ -53,6 +55,7 @@ class RepairDeviceController extends BaseController
             }
         }
 
+        //搜索内部设备id
         $select_items = collect(['inner_device_id']);
         foreach($select_items as $select_item) {
             if($request->has($select_item) && !empty($request->input($select_item))) {
@@ -67,10 +70,10 @@ class RepairDeviceController extends BaseController
             $item->user_phone = $item->user ? $item->user->phone : '';
             $item->project_name = $item->project ? $item->project->name : '';
             $item->number = $item->inner_device ? $item->inner_device->number : '';
-            $item->spec_name = $item->inner_device ? ($item->inner_device->spec ? $item->inner_device->spec->name : '') : '';
-            $item->status_label = $item->inner_device ? $item->inner_device->getStatusLabel() : '';
-            $item->device_name = $item->inner_device ? ($item->inner_device->device_name ? $item->inner_device->device_name->name : '') : '';
+            $item->spec_name = $item->inner_device ? ($item->inner_device->spec_name ? $item->inner_device->spec_name : '') : '';
+            $item->device_name = $item->inner_device ? ($item->inner_device->device_name ? $item->inner_device->devices_name->name : '') : '';
             $item->work_point_name = $item->work_point ? $item->work_point->name : '';
+            $item->status_label = $item->inner_device ? ($item->inner_device->option ? $item->inner_device->option->name :'' ) : '';
         }
 
         return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);

+ 16 - 0
app/Http/Controllers/Admin/SpecController.php

xqd xqd
@@ -1,6 +1,9 @@
 <?php
 namespace App\Http\Controllers\Admin;
 
+use App\Exceptions\ImportError;
+use App\Imports\SpecImport;
+use Maatwebsite\Excel\Facades\Excel;
 use App\Models\AdminRoleModel;
 use App\Models\AdminUserModel;
 use App\Models\Device;
@@ -123,4 +126,17 @@ class SpecController extends BaseController
         if (!$res) return response()->json(['status' => 'fail', 'info' => '删除失败']);
         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 SpecImport(), $file);
+        } catch (ImportError $e) {
+            return response()->json(['status' => 'error', 'info' => $e->getMessage()]);
+        }
+        return response()->json(['status' => 'success', 'info' => '上传成功']);
+    }
 }

+ 39 - 22
app/Imports/InnerDeviceImport.php

xqd xqd xqd xqd
@@ -5,6 +5,7 @@ namespace App\Imports;
 use App\Exceptions\ImportError;
 use App\Models\DeviceName;
 use App\Models\InnerDevice;
+use App\Models\InnerDeviceNamesModel;
 use App\Models\Option;
 use App\Models\Project;
 use App\Models\ProjectZone;
@@ -33,38 +34,59 @@ class InnerDeviceImport implements ToCollection
         $this->model = new InnerDevice();
     }
 
-    public function formatDate($date)
-    {
-        if(empty($date)) return '';
-        return Date::excelToDateTimeObject($date)->format('Y-m-d');
+    function excelTime($date, $time = false) {
+        if(function_exists('GregorianToJD')){
+            if (is_numeric( $date )) {
+                $jd = GregorianToJD( 1, 1, 1970 );
+                $gregorian = JDToGregorian( $jd + intval ( $date ) - 25569 );
+                $date = explode( '/', $gregorian );
+                $date_str = str_pad( $date [2], 4, '0', STR_PAD_LEFT )
+                    ."-". str_pad( $date [0], 2, '0', STR_PAD_LEFT )
+                    ."-". str_pad( $date [1], 2, '0', STR_PAD_LEFT )
+                    . ($time ? " 00:00:00" : '');
+                return $date_str;
+            }
+        }else{
+            $date=$date>25568?$date+1:25569;
+            /*There was a bug if Converting date before 1-1-1970 (tstamp 0)*/
+            $ofs=(70 * 365 + 17+2) * 86400;
+            $date = date("Y-m-d",($date * 86400) - $ofs).($time ? " 00:00:00" : '');
+        }
+//        dd($date);
+        return $date;
     }
 
     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]
-            ]);
-
+            if(empty($row[0])&&empty($row[1])&&empty($row[2]))
+            {
+                break;
+            }
+            //设备名称
+            if ($row[1])
+            {
+                $device_name = InnerDeviceNamesModel::firstOrCreate([
+                    'name' => $row[1],
+                    'sort' => 1,
+                    'status' => 1
+                ]);
+            }
+            $spec_name = $row[2];
             $project = null;
             $work_point = null;
+            //项目
             if($row[7]) {
                 $project = Project::firstOrCreate([
                     'name' => $row[7]
                 ]);
             }
-
+            //工点
             if($project && $row[8]) {
                 $work_point = WorkPoint::firstOrCreate([
                     'project_id' => $project->id,
@@ -78,12 +100,11 @@ class InnerDeviceImport implements ToCollection
                 ['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]),
+                'spec_name' => $spec_name ? $spec_name : '',
+                'produce_date' => $this->excelTime($row[3]),
                 'buy_origin' => $row[4],
                 'manufacturer' => $row[5],
                 'shape' => $row[6],
@@ -92,10 +113,6 @@ class InnerDeviceImport implements ToCollection
                 'status' => $status ? $status->id : ''
             ];
             $this->model->create($data);
-//            $num = (int)$row[7];
-//            for($i = 0; $i < $num; ++$i) {
-//                $this->model->create($data);
-//            }
         }
         return true;
     }

+ 94 - 0
app/Imports/SpecImport.php

xqd
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Imports;
+
+use App\Exceptions\ImportError;
+use App\Models\Device;
+use App\Models\DeviceName;
+use App\Models\InnerDevice;
+use App\Models\InnerDeviceNamesModel;
+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 SpecImport implements ToCollection
+{
+    protected $model;
+
+    protected $zone;
+
+    protected $road;
+
+    protected $project_zone;
+
+    public function __construct()
+    {
+        $this->model = new Spec();
+    }
+
+    public function collection(Collection $rows)
+    {
+        if(count($rows) <= 1) {
+            /** @noinspection PhpUnhandledExceptionInspection */
+            return false;
+        };
+        foreach ($rows as $key => $row) {
+            if($key == 0) continue;
+            if(empty($row[0])&&empty($row[1])&&empty($row[2]))
+            {
+                break;
+            }
+            //设备类型
+            $device_id = null;
+            $device_name_id = null;
+            if ($row[1])
+            {
+                $device_id = Device::firstOrCreate([
+                    'name' => $row[1],
+                    'sort' => 1,
+                ]);
+            }
+            //设备名称
+            if ($row[2] == "项目自填(必须填写)")
+            {
+                continue;
+            }else
+            {
+                if($device_id && $row[2]) {
+                    $device_name_id = DeviceName::firstOrCreate([
+                        'device_id' => $device_id->id,
+                        'name' => $row[2],
+                        'sort' => 1,
+                        'status' => 1
+                    ]);
+                }
+            }
+
+            $name = null;
+            if ($row[3] == "项目自填(必须填写)")
+            {
+                $name = '';
+            }
+            else{
+                $name = $row[3];
+            }
+            $data = [
+                'name' => $name,
+                'device_name_id' => $device_name_id ? $device_name_id->id : '',
+                'device_id' => $device_id ? $device_id->id : '',
+                'sort' => 1
+            ];
+            $this->model->create($data);
+        }
+        return true;
+    }
+}

+ 12 - 5
app/Models/DeviceName.php

xqd
@@ -11,12 +11,19 @@ class DeviceName extends BaseModel
 
     public function getNameSpecOptions()
     {
-        $names = DeviceName::select('name as text', 'id as value')->get();
+//        $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' => '']));
+//        }
+//        dd($names);
+        $names = InnerDeviceNamesModel::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' => '']));
-        }
+//        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;
     }
 

+ 15 - 8
app/Models/InnerDevice.php

xqd xqd xqd
@@ -32,6 +32,9 @@ class InnerDevice extends BaseModel
         return $this->belongsTo('App\Models\DeviceName', 'device_name_id');
     }
 
+    public function devices_name(){
+        return $this->hasOne(InnerDeviceNamesModel::class,'id','device_name_id');
+    }
     public function option()
     {
         return $this->belongsTo('App\Models\Option', 'status');
@@ -44,14 +47,14 @@ class InnerDevice extends BaseModel
         ], [
             'number.required' => '固定资产编号'
         ]);
-        $validator->after(function ($validator) use($request) {
-            if (!$request->input('device_name_id')) {
-                $validator->errors()->add('device_name_id', '设备名称必填');
-            }
-            if (!$request->input('spec_id')) {
-                $validator->errors()->add('spec_id', '规格型号必填');
-            }
-        });
+//        $validator->after(function ($validator) use($request) {
+//            if (!$request->input('device_name_id')) {
+//                $validator->errors()->add('device_name_id', '设备名称必填');
+//            }
+//            if (!$request->input('spec_id')) {
+//                $validator->errors()->add('spec_id', '规格型号必填');
+//            }
+//        });
         return $validator;
     }
 
@@ -59,4 +62,8 @@ class InnerDevice extends BaseModel
     {
         return $this['option'] ? '<div style="color: ' . $this['option']['color'] . '">' . $this['option']['name'] . '</div>' : '';
     }
+
+    public function inner_device_names(){
+        return $this->hasOne(InnerDeviceNamesModel::class,'id','device_name_id');
+    }
 }

+ 39 - 0
app/Models/InnerDeviceNamesModel.php

xqd
@@ -0,0 +1,39 @@
+<?php
+namespace App\Models;
+use App\Models\BaseModel;
+/**
+ *  @description 内部设备名称
+ *  @author  system;
+ *  @version    1.0
+ *  @date 2021-01-25 13:37:36
+ *
+ */
+class InnerDeviceNamesModel extends BaseModel
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     *
+     */
+    protected $table = 'inner_device_names';
+    /**
+    主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+                           'name',
+                           'sort',
+                           'status'
+                          ];
+
+}

+ 45 - 0
app/Repositories/Inner/Device/Criteria/MultiWhere.php

xqd
@@ -0,0 +1,45 @@
+<?php
+/**
+ * User: Mike
+ * Email: m@9026.com
+ * Date: 2017/1/12
+ * Time: 17:52
+ */
+
+namespace App\Repositories\Inner\Device\Criteria;
+
+
+
+
+use App\Repositories\Base\Criteria;
+use App\Repositories\Contracts\RepositoryInterface as Repository;
+
+class MultiWhere extends Criteria {
+
+    private $search = [];
+
+    /**
+     * MultiWhere constructor.
+     * @param array $search
+     *
+     */
+    public function __construct(array $search)
+    {
+        $this->search = $search;
+    }
+
+    /**
+    * @param $model
+    * @param RepositoryInterface $repository
+    * @return mixed
+    */
+    public function apply($model, Repository $repository)
+    {
+          if(isset($this->search['updated_at']) && $this->search['updated_at']) {
+                                    $model = $model->where('updated_at',$this->search['updated_at']);
+                                 }
+
+         return $model;
+    }
+
+}

+ 21 - 0
app/Repositories/Inner/Device/NamesRepository.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ *   内部设备名称
+ *  @author  system
+ *  @version    1.0
+ *  @date 2021-01-25 13:37:36
+ *
+ */
+namespace App\Repositories\Inner\Device;
+
+use App\Repositories\Base\Repository;
+
+
+class NamesRepository extends Repository {
+
+    public function model() {
+        return \App\Models\InnerDeviceNamesModel::class;
+    }
+
+    
+}

+ 0 - 106
database/migrations/2021_01_24_100701_add_all_devices_table_comment.php

xqd
@@ -1,106 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Support\Facades\DB;
-
-class AddAllDevicesTableComment extends Migration
-{
-    public function boot()
-    {
-        Schema::defaultStringLength(191);
-    }
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        //inner_devices表
-        Schema::table('inner_devices', function (Blueprint $table) {
-            $table->string('device_name_id')->comment('设备名称编号')->change();
-            $table->string('quantity')->comment('数量')->change();
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('project_id')->comment('项目名称id')->change();
-            $table->string('work_point_id')->comment('工点id')->change();
-        });
-        DB::statement("ALTER TABLE `inner_devices` comment '内部设备表'");
-
-        //order_devices 租赁设备表
-        Schema::table('order_devices', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('order_id')->comment('订单id')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('project_id')->comment('项目名称id')->change();
-            $table->string('device_id')->comment('设备类型id')->change();
-            $table->string('inner_device_id')->comment('内部设备id')->change();
-            $table->string('spec_id')->comment('设备类型id')->change();
-            $table->string('device_name_id')->comment('设备名称编号')->change();
-            $table->string('quantity')->comment('数量')->change();
-            $table->string('price')->comment('单价 单位:分')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-            $table->string('start_date')->comment('租赁开始时间')->change();
-            $table->string('end_date')->comment('租赁结束时间')->change();
-        });
-        DB::statement("ALTER TABLE `order_devices` comment '租赁设备表'");
-
-
-        //devices表
-        Schema::table('devices', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('设备类型名称')->change();
-            $table->string('sort')->comment('排序等级')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `devices` comment '设备类型表'");
-
-
-        //device_names表
-        Schema::table('device_names', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('设备名称')->change();
-            $table->string('sort')->comment('排序等级')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `device_names` comment '设备名称表'");
-
-
-        //repair_devices 表
-        Schema::table('repair_devices', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('project_id')->comment('项目id')->change();
-            $table->string('work_point_id')->comment('工点id')->change();
-            $table->string('inner_device_id')->comment('内部设备id')->change();
-            $table->string('money')->comment('维修总金额')->change();
-            $table->string('reason')->comment('维修原因')->change();
-            $table->string('day')->comment('维修日期')->change();
-            $table->string('remark')->comment('备注')->change();
-            $table->string('start_date')->comment('开始时间')->change();
-            $table->string('end_date')->comment('结束时间')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-
-        });
-        DB::statement("ALTER TABLE `repair_devices` comment '维修记录表'");
-
-
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        //
-    }
-}

+ 0 - 69
database/migrations/2021_01_24_113828_add_all_user_table_comment.php

xqd
@@ -1,69 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddAllUserTableComment extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        //users 表
-        Schema::table('users', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('role_id')->comment('角色id')->change();
-            $table->string('phone')->comment('联系电话')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('password')->comment('密码')->change();
-            $table->string('open_id')->comment('微信open_id')->change();
-            $table->string('union_id')->comment('微信union_id')->change();
-            $table->string('nickname')->comment('昵称')->change();
-            $table->string('avatar')->comment('头像')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-
-        });
-        DB::statement("ALTER TABLE `users` comment '用户表'");
-
-        //user_resets 表
-        Schema::table('user_resets', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('phone')->comment('联系电话')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-
-        });
-        DB::statement("ALTER TABLE `user_resets` comment '用户密码重置记录表'");
-
-        //user_auths 表
-        Schema::table('user_auths', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('phone')->comment('联系电话')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('project_id')->comment('项目id')->change();
-            $table->string('project_role_id')->comment('项目申请的角色id')->change();
-            $table->string('remark')->comment('备注')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `user_auths` comment '用户授权表'");
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        //
-    }
-}

+ 0 - 87
database/migrations/2021_01_24_134009_add_all_project_table_comment.php

xqd
@@ -1,87 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddAllProjectTableComment extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        //project_roles 表
-        Schema::table('project_roles', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('level')->comment('级别')->change();
-        });
-        DB::statement("ALTER TABLE `project_roles` comment '项目角色表'");
-
-        //project_role_rights 表
-        Schema::table('project_role_rights', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('right_id')->comment('权限id')->change();
-            $table->string('project_role_id')->comment('项目角色id')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `project_role_rights` comment '项目角色权限管理表'");
-
-        //rights 表
-        Schema::table('rights', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('key')->comment('键')->change();
-            $table->string('sort')->comment('排序等级')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `rights` comment '权限表'");
-
-        //project_users 表
-        Schema::table('project_users', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('project_id')->comment('项目id')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('project_role_id')->comment('项目角色id')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `project_users` comment '项目用户表'");
-
-        //projects 表
-        Schema::table('projects', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('项目名称')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `projects` comment '项目表'");
-
-        //work_points 表
-        Schema::table('work_points', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('项目名称')->change();
-            $table->string('project_id')->comment('项目id')->change();
-            $table->string('status')->comment('状态')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `work_points` comment '工点管理表'");
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        //
-    }
-}

+ 0 - 72
database/migrations/2021_01_24_141328_add_all_order_table_comment.php

xqd
@@ -1,72 +0,0 @@
-<?php
-
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Database\Migrations\Migration;
-
-class AddAllOrderTableComment extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        //orders 表
-        Schema::table('orders', function (Blueprint $table) {
-            $table->string('work_point_id')->comment('工点id')->change();
-            $table->string('remark')->comment('备注')->change();
-            $table->string('status')->comment('状态')->change();
-            $table->string('order_number')->comment('订单号')->change();
-            $table->string('project_id')->comment('项目id')->change();
-            $table->string('user_id')->comment('用户id')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `orders` comment '订单表'");
-
-        //specs 表
-        Schema::table('specs', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('device_name_id')->comment('设备名称id')->change();
-            $table->string('device_id')->comment('设备id')->change();
-            $table->string('sort')->comment('排序等级')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `specs` comment '设备规格表'");
-
-        //roles 表
-        Schema::table('roles', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('key')->comment('键名')->change();
-            $table->string('sort')->comment('排序等级')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `roles` comment '角色表'");
-
-        //rent_types 表
-        Schema::table('rent_types', function (Blueprint $table) {
-            $table->string('id')->comment('自增id')->change();
-            $table->string('name')->comment('名称')->change();
-            $table->string('sort')->comment('排序等级')->change();
-            $table->string('created_at')->comment('创建时间')->change();
-            $table->string('updated_at')->comment('更新时间')->change();
-        });
-        DB::statement("ALTER TABLE `rent_types` comment '租赁类型表'");
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        //
-    }
-}

+ 1 - 0
mini/app.js

xqd
@@ -49,6 +49,7 @@ App({
     userInfo: null
   },
   updateUserInfo: function (info) {
+    console.log(info)
     this.globalData.userInfo = info
     wx.setStorageSync('sg-userinfo', info)
   },

+ 47 - 14
mini/pages/data/index.js

xqd xqd xqd xqd xqd xqd xqd
@@ -106,15 +106,15 @@ Page({
    */
   onLoad: function (options) {
     app.resetDataFilter()
-    api.getByName(this, 'projects/getAll', 'projects', {type: 'drop_menu'});
+    api.getByName(this, 'projects/getAll', 'projects', { type: 'drop_menu' });
   },
 
-  changeChartIndex: function(e) {
+  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})
+    if (chartIndex < 0 || chartIndex > 2) return false;
+    this.setData({ chartIndex })
     this.getChartData()
   },
 
@@ -187,11 +187,11 @@ Page({
   updateChart: function () {
     var data = this.data.data
     var chartIndex = this.data.chartIndex
-    if(chartIndex == 0) {
+    if (chartIndex == 0) {
       option.xAxis = [{
         type: 'value'
       }]
-      
+
       option.legend = {
         data: data.legends,
         bottom: 40
@@ -207,10 +207,21 @@ Page({
       }
       option.yAxis = [{
         type: 'category',
-        data: data.names
+        data: data.names,
+        axisLabel: {
+          color: "#000",
+          interval: 0,
+          formatter: function (value) {
+            if (value.length > 4) {
+              return value.substring(0, 4) + "...";
+            } else {
+              return value;
+            }
+          }
+        },
       }];
       var values = data.values
-      
+
       option.series = [{
         label: {
           show: true
@@ -230,7 +241,7 @@ Page({
       option.xAxis = [{
         type: 'value'
       }]
-      
+
       option.legend = {
         data: data.legends,
         bottom: 40
@@ -246,10 +257,21 @@ Page({
       }
       option.yAxis = [{
         type: 'category',
-        data: data.names
+        data: data.names,
+        axisLabel: {
+          color: "#000",
+          interval: 0,
+          formatter: function (value) {
+            if (value.length > 4) {
+              return value.substring(0, 4) + "...";
+            } else {
+              return value;
+            }
+          }
+        },
       }];
       var values = data.values
-      
+
       option.series = [{
         label: {
           show: true
@@ -270,7 +292,7 @@ Page({
       option.xAxis = [{
         type: 'value'
       }]
-      
+
       option.legend = {
         data: data.legends,
         bottom: 40
@@ -283,10 +305,21 @@ Page({
       }
       option.yAxis = [{
         type: 'category',
-        data: data.names
+        data: data.names,
+        axisLabel: {
+          color: "#000",
+          interval: 0,
+          formatter: function (value) {
+            if (value.length > 4) {
+              return value.substring(0, 4) + "...";
+            } else {
+              return value;
+            }
+          }
+        },
       }];
       var values = data.values
-      
+
       option.series = [{
         label: {
           show: true

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

xqd
@@ -94,7 +94,7 @@ Page({
     this.getList()
   },
   getList: function() {
-    if(this.data.touchBottom) return false;
+    // if(this.data.touchBottom) return false;
 
     var that = this
     http({

+ 2 - 1
mini/pages/order/index.js

xqd xqd
@@ -38,6 +38,7 @@ Page({
    */
   onLoad: function (options) {
     // project_id
+    console.log(options)
     var id = options.id ? options.id : 1
     var type = options.type ? options.type : 'list'
     var tabIndex = options.index ? options.index : 0
@@ -47,7 +48,7 @@ Page({
       tabIndex
     })
     api.getProject(this)
-    api.getByName(this, 'work-points/get', 'work_points', {type: 'drop_menu'});
+    api.getByName(this, 'work-points/get', 'work_points', {type: 'drop_menu',project_id:id});
     api.getByName(this, 'orders/getRole', 'role', {id: id});
     this.getList();
   },

+ 6 - 4
mini/pages/order/index.wxml

xqd
@@ -3,15 +3,17 @@
   <view class="sg-top-box sg-fix-top sg-white-bg">
     <view class="sg-search-box sg-flex sg-align-center">
       <van-dropdown-menu>
-        <van-dropdown-item value="{{ work_point_id }}" options="{{ work_points }}" bind:change="onDropChange" data-name="work_point_id"/>
+        <van-dropdown-item value="{{ work_point_id }}" options="{{ work_points }}" bind:change="onDropChange"
+          data-name="work_point_id" />
       </van-dropdown-menu>
-      <van-search value="{{ keyword }}" placeholder="请输入订单号或提交人搜索" use-right-icon-slot class="sg-flex-grow" left-icon="none" bind:change="onDropChange" data-name="keyword">
+      <van-search value="{{ keyword }}" placeholder="请输入订单号或提交人搜索" use-right-icon-slot class="sg-flex-grow"
+        left-icon="none" bind:change="onDropChange" data-name="keyword">
         <van-icon name="search" class="sg-index-color sg-icon" slot="right-icon" bindtap="search"></van-icon>
       </van-search>
     </view>
     <view class="sg-tabs sg-flex sg-align-center sg-white-bg sg-pad sg-bottom-border sg-top-border sg-font-small">
-      <view wx:for="{{tabs}}" wx:key="index" class="sg-tab {{tabIndex == index ? 'sg-selected' : ''}}"
-        bindtap="switchTab" data-index="{{index}}" hidden="{{ type=='check' && index > 2 }}">{{ item }}</view>
+      <view wx:for="{{tabs}}"  wx:key="index" class="sg-tab {{tabIndex == index ? 'sg-selected' : ''}}"
+        bindtap="switchTab"   data-index="{{index}}" hidden="{{ type=='check' && index > 2 }}">{{ item }}</view>
     </view>
   </view>
   <view class="sg-list-box sg-pad">

+ 2 - 1
mini/pages/user/index.js

xqd
@@ -95,12 +95,13 @@ Page({
   },
 
   updateInfo: function() {
+    console.log(this.data.phone)
     http({
       url: 'users/update',
       data: {
         avatar: this.data.avatar,
         name: this.data.name,
-        phone: this.data.phone
+        phone: this.data.userInfo.phone
       },
       success: function (res) {
         if (res.code == 0) {

+ 2 - 1
mini/project.config.json

xqd
@@ -21,8 +21,9 @@
     "checkSiteMap": true,
     "uploadWithSourceMap": true,
     "compileHotReLoad": false,
-    "useMultiFrameRuntime": false,
+    "useMultiFrameRuntime": true,
     "useApiHook": true,
+    "useApiHostProcess": true,
     "babelSetting": {
       "ignore": [],
       "disablePlugins": [],

+ 3 - 3
mini/utils/env.js

xqd
@@ -1,3 +1,3 @@
-const isTest = false;
-export const baseUrl = isTest ? 'http://app.rt/api/mini/' : 'https://t18.9026.com/api/mini/';
-export const imgHost = isTest ? 'http://app.rt/images/' : 'https://t18.9026.com/images/'
+const isTest = true;
+export const baseUrl = isTest ? 'http://172.31.31.144/api/mini/' : 'https://t18.9026.com/api/mini/';
+export const imgHost = isTest ? 'http://172.31.31.144/images/' : 'https://t18.9026.com/images/'

+ 4 - 1
readme.md

xqd
@@ -40,4 +40,7 @@ https://share.mubu.com/doc/4Bid7O5TWS
 小程序问题
 https://docs.qq.com/doc/DVHd2SnFlcWJHQWZ2
 
-https://docs.qq.com/doc/DVFZCWmlvSGpvYXlm
+https://docs.qq.com/doc/DVFZCWmlvSGpvYXlm
+
+数据字典
+在doc目录

+ 4 - 3
resources/views/admin/inner-devices/create.blade.php

xqd xqd xqd
@@ -20,7 +20,8 @@
                     <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.name-select-form', ['device_name_id' => '', 'options' => $options])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'spec_name', 'label' => '规格型号', 'required' => true, 'value' => (old('data') ? old('data')['spec_id'] : '')])
                         @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => (old('data') ? old('data')['status'] : ''), 'options' => $status_options])
                         @include('share.project-work-point-select-form', ['project_id' => '', 'work_point_id' => '', 'options' => $project_work_point_options])
                         @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => (old('data') ? old('data')['number'] : '')])
@@ -30,7 +31,7 @@
                         @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 id="btnSubmit" class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                                 <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                             </div>
                         </div>
@@ -59,7 +60,7 @@
                 // });
 
                 $('#sg-back-btn').on('click', function () {
-                    window.history.go(-1)
+                    window.history.go(-1);
                 });
 
                 laydate.render({

+ 2 - 1
resources/views/admin/inner-devices/edit.blade.php

xqd
@@ -21,7 +21,8 @@
 
                         {{ 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.name-select-form', ['device_name_id' => $item->device_name_id,'options' => $options])
+                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'spec_name', 'label' => '规格型号', 'required' => true, 'value' => $item->spec_name])
                         @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => $item->status, 'options' => $status_options])
                         @include('share.project-work-point-select-form', ['project_id' => $item->project_id, 'work_point_id' => $item->work_point_id, 'options' => $project_work_point_options])
                         @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => $item->number])

+ 18 - 1
resources/views/admin/inner-devices/index.blade.php

xqd xqd
@@ -55,7 +55,7 @@
             <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])
+                        @include('share.name-select', ['device_name_id' => '', 'options' => $options])
                         <div class="layui-inline">
                             <div class="layui-input-inline">
                                 <select name="status">
@@ -66,11 +66,28 @@
                                 </select>
                             </div>
                         </div>
+                        <div class="layui-inline">
+                            <div class="layui-input-inline">
+                                <select name="project_id">
+                                    <option value="0">在用项目</option>
+                                    @foreach($project_id 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">
                                 <input type="text" name="number" placeholder="请输入固定资产编号" autocomplete="off" class="layui-input" value="{{ request('number') }}">
                             </div>
                         </div>
+
+                        <div class="layui-inline">
+                            <div class="layui-input-inline">
+                                <input type="text" name="spec_name" placeholder="请输入规格型号" autocomplete="off" class="layui-input" value="{{ request('spec_name') }}">
+                            </div>
+                        </div>
+
                         <div class="layui-inline">
                             <div class="layui-btn" id="sg-search-btn">搜索</div>
                         </div>

+ 88 - 0
resources/views/admin/inner/device/names/check.blade.php

xqd
@@ -0,0 +1,88 @@
+@extends('admin.layout')
+
+@section('content')
+		<div class="row">
+			<div class="col-sm-12">
+				<div class="ibox float-e-margins">
+					<div class="ibox-title">
+						<h5>内部设备名称</h5>
+						<div class="ibox-tools">
+							<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+							</a>
+						</div>
+					</div>
+					<div class="ibox-content">
+						<div class="row">
+							<form method="GET" action="" accept-charset="UTF-8">
+
+								<div class="col-sm-4">
+									<div class="input-group">
+										<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control">
+								<span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+									</div>
+								</div>
+							</form>
+							@if(role('Inner/Device/Names/create'))
+								<div class="col-sm-3 pull-right">
+									<a href="{{ U('Inner/Device/Names/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
+								</div>
+							@endif
+						</div>
+
+						<table class="table table-striped table-bordered table-hover dataTables-example dataTable dataCheckTable">
+							<thead>
+							<tr>
+								<th><input class="btSelectAll" name="btSelectAll" type="checkbox"></th>
+								
+            <th class="sorting" data-sort="created_at"> 创建时间 </th>
+            <th class="sorting" data-sort="id"> ID </th>
+            <th class="sorting" data-sort="name"> 设备名 </th>
+            <th class="sorting" data-sort="sort"> 排序 </th>
+            <th class="sorting" data-sort="status"> 状态 0禁用 1启用   </th>
+            <th class="sorting" data-sort="updated_at"> 更新时间 </th>
+								<th width="22%">相关操作</th>
+							</tr>
+							</thead>
+							<tbody>
+							@if(isset($list))
+								@foreach($list as $key => $item)
+									<tr>
+									<td><input data-json='{!! json_encode($item) !!}'  name="btSelectItem" class="data_key" type="checkbox" value="{{ $item->id or 0 }}" /></td>
+									
+            <td>{{ $item->created_at }}</td>
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->name }}</td>
+            <td>{{ $item->sort }}</td>
+            <td>{{ $item->status }}</td>
+            <td>{{ $item->updated_at }}</td>
+									<td>
+										@if(role('Inner/Device/Names/view'))
+											<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Inner/Device/Names/view',['id'=>$item->id])}}'});"  class="btn btn-primary ">查看</button>
+										@endif
+									</td>
+								</tr>
+								@endforeach
+							@endif
+
+							</tbody>
+						</table>
+						<div class="row">
+							<div class="col-sm-6">
+								<div class="dataTables_info" id="DataTables_Table_0_info"
+									 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。</div>
+							</div>
+							<div class="col-sm-6">
+								<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+									{!! $list->setPath('')->appends(Request::all())->render() !!}
+								</div>
+							</div>
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+	@include('admin.tools.check_script');
+
+@endsection

+ 86 - 0
resources/views/admin/inner/device/names/edit.blade.php

xqd
@@ -0,0 +1,86 @@
+@extends('admin.layout')
+
+@section('content')
+
+<?php
+    if(!isset($data)) $data = array();
+    if(!$data && session("data")){
+        $data = session("data");
+    }
+    if(!$data && session('_old_input')){
+        $data = session("_old_input");
+    }
+?>
+	<div class="row">
+		<div class="col-sm-12">
+			<div class="ibox float-e-margins">
+				<div class="ibox-title">
+					<h5>内部设备名称</h5>
+					<div class="ibox-tools">
+						<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+						</a>
+					</div>
+				</div>
+				<div class="ibox-content">
+                    @if(role('Inner/Device/Names/index'))
+				    <div class="row">
+    					<div class="col-sm-3 pull-right">
+    					   <a href="{{ U('Inner/Device/Names/index')}}" class="btn btn-sm btn-primary pull-right">返回列表</a>
+    					</div>
+					</div>
+                    @endif
+
+		            <div class="row">
+                        <div class="col-lg-10">
+                            <form name="form_product" id="form-validation" action="" class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+
+                                    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">设备名</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_name" name="data[name]" class="form-control" value="{{ $data['name'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">排序</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_sort" name="data[sort]" class="form-control" value="{{ $data['sort'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">状态 0禁用 1启用  </label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_status" name="data[status]" class="form-control" value="{{ $data['status'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>
+                                
+                                <div class="form-group">
+                                    <label class="control-label col-sm-3">&nbsp;</label>
+                                    <div class="col-sm-9">
+                                        <input type="hidden" name="_referer" value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
+                                        <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
+                                        <input type="submit" class="btn btn-success" style="margin-right:20px;">
+                                        <input type="reset" class="btn btn-default" >
+                                    </div>
+                                </div>
+        
+                            </form>
+                        </div>
+                        <!-- /.col-lg-10 -->
+                    </div>
+                    <!-- /.row -->
+				</div>
+			</div>
+		</div>
+	</div>
+
+@endsection

+ 105 - 0
resources/views/admin/inner/device/names/index.blade.php

xqd
@@ -0,0 +1,105 @@
+@extends('admin.layout') 
+
+@section('content')
+	<div class="row">
+		<div class="col-sm-12">
+			<div class="ibox float-e-margins">
+				<div class="ibox-title">
+					<h5>内部设备名称</h5>
+					<div class="ibox-tools">
+						<a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+						</a>
+					</div>
+				</div>
+				<div class="ibox-content">
+				    <div class="row">
+				        <form method="GET" action="" accept-charset="UTF-8">
+
+				        <div class="col-sm-4">
+				            <div class="input-group">
+								<input type="text" value="{{Request::get('keyword')}}"	placeholder="请输入关键词" name="keyword"class="input-sm form-control"> 
+								<span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+    						</div>
+				        </div>
+				        </form>
+						@if(role('Inner/Device/Names/create'))
+    					<div class="col-sm-3 pull-right">
+    					   <a href="{{ U('Inner/Device/Names/create')}}" class="btn btn-sm btn-primary pull-right">添加</a>
+    					</div>
+						@endif
+					</div>
+					
+					<table class="table table-striped table-bordered table-hover dataTables-example dataTable">
+						<thead>
+    						<tr>
+								
+            <th class="sorting" data-sort="id"> ID </th>
+            <th class="sorting" data-sort="name"> 设备名 </th>
+            <th class="sorting" data-sort="sort"> 排序 </th>
+            <th class="sorting" data-sort="status"> 状态 0禁用 1启用   </th>
+								<th class="sorting" data-sort="created_at"> 创建时间 </th>
+
+								<th class="sorting" data-sort="updated_at"> 更新时间 </th>
+        						<th width="22%">相关操作</th>
+        					</tr>
+						</thead>
+						<tbody>
+						@if(isset($list))
+							@foreach($list as $key => $item)							<tr>
+								
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->name }}</td>
+            <td>{{ $item->sort }}</td>
+            <td>{{ $item->status }}</td>
+								<td>{{ $item->created_at }}</td>
+
+								<td>{{ $item->updated_at }}</td>
+								<td>
+									<div class="btn-group">
+										<button data-toggle="dropdown"
+											class="btn btn-warning btn-sm dropdown-toggle"
+											aria-expanded="false">
+											操作 <span class="caret"></span>
+										</button>
+										<ul class="dropdown-menu">
+
+
+											@if(role('Inner/Device/Names/update'))
+											<li><a href="{{ U('Inner/Device/Names/update',['id'=>$item->id])}}" class="font-bold">修改</a></li>
+											@endif
+
+											@if(role('Inner/Device/Names/destroy'))
+											<li class="divider"></li>
+											<li><a href="{{ U('Inner/Device/Names/destroy',['id'=>$item->id])}}" onclick="return confirm('你确定执行删除操作?');">删除</a></li>
+											@endif
+
+										</ul>
+									</div>
+								@if(role('Inner/Device/Names/view'))
+										<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Inner/Device/Names/view',['id'=>$item->id])}}'});"  class="btn btn-primary ">查看</button>
+									@endif
+								</td>
+							</tr>
+							@endforeach
+							@endif
+
+						</tbody>
+					</table>
+					<div class="row">
+						<div class="col-sm-6">
+							<div class="dataTables_info" id="DataTables_Table_0_info"
+								role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。</div>
+						</div>
+						<div class="col-sm-6">
+						<div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+						{!! $list->setPath('')->appends(Request::all())->render() !!}
+						</div>
+						</div>
+					</div>
+				</div>
+			</div>
+		</div>
+	</div>
+@endsection

+ 32 - 0
resources/views/admin/inner/device/names/view.blade.php

xqd
@@ -0,0 +1,32 @@
+@extends('admin.layout')
+
+@section('content')
+<div class="row">
+    <div class="ibox-content">
+        <div class="list-group">
+                                 
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">设备名</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['name'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">排序</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['sort'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">状态 0禁用 1启用  </h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['status'] or ''}}</p>
+                                                 
+               </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 141 - 13
resources/views/admin/specs/index.blade.php

xqd xqd xqd xqd
@@ -2,7 +2,47 @@
 
 @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;
+        }
+        #sg-import-all{
 
+        }
     </style>
 @endsection
 
@@ -15,19 +55,22 @@
             </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, 'hide_spec' => true])
-                    <div class="layui-inline">
-                        <div class="layui-input-inline">
-                            <input type="text" name="name" placeholder="请输入规格型号" autocomplete="off" class="layui-input" value="{{ request('name') }}">
+                <form class="layui-form layui-inline" id="sg-search-form">
+                    <div class="layui-form-item layui-row">
+                        @include('share.device-select', ['device_id' => '', 'device_name_id' => '', 'spec_id' => '', 'options' => $options, 'hide_spec' => true])
+                        <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>
-                    <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>
             <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">
@@ -39,6 +82,28 @@
             </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')
@@ -52,15 +117,78 @@
                     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: 'device_name_name', title: '设备名称', align: 'center' },
-                        { field: 'name', title: '规格型号', align: 'center' },
+                        { field: 'device_type', title: '租赁设备类型', align: 'center' },
+                        { field: 'device_name_name', title: '租赁设备名称', align: 'center' },
+                        { field: 'name', title: '设备规格型号', align: 'center' },
                         { field: 'sort', title: '排序', align: 'center' },
                         { title: '操作', align:'center', toolbar: '#sg-table-bar' }
                     ]],

+ 15 - 14
resources/views/share/name-select-form.blade.php

xqd xqd
@@ -20,18 +20,19 @@
     @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
+{{--@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>--}}
+        {{--<text name="spec_id" lay-filter="spec_id"></text>--}}
+        {{--@if($errors->has('spec_id'))--}}
+            {{--<span class="help-block">{{ $errors->first('spec_id') }}</span>--}}
+        {{--@endif--}}
+    {{--</div>--}}
+{{--</div>--}}
+{{--@endif--}}
 <script>
     $(function() {
         layui.use(['form'], function() {
@@ -39,8 +40,8 @@
             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" }}';
+            {{--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) {

+ 8 - 8
resources/views/share/name-select.blade.php

xqd
@@ -15,14 +15,14 @@
             </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
+    {{--@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() {