李浩杰 4 éve
szülő
commit
f2b289162f
80 módosított fájl, 3590 hozzáadás és 59 törlés
  1. 1 2
      app/Http/Controllers/Admin/TestController.php
  2. 125 0
      app/Http/Controllers/Api/mini/DataController.php
  3. 28 0
      app/Http/Controllers/Api/mini/DeviceNameController.php
  4. 27 1
      app/Http/Controllers/Api/mini/InnerDeviceController.php
  5. 63 0
      app/Http/Controllers/Api/mini/NotificationController.php
  6. 6 18
      app/Http/Controllers/Api/mini/OrderController.php
  7. 27 0
      app/Http/Controllers/Api/mini/PartController.php
  8. 60 0
      app/Http/Controllers/Api/mini/RepairDeviceController.php
  9. 5 0
      app/Http/Controllers/Api/mini/SpecController.php
  10. 23 0
      app/Http/Controllers/Api/mini/UseRecordController.php
  11. 8 0
      app/Models/Notification.php
  12. 23 0
      app/Models/Order.php
  13. 8 0
      app/Models/Part.php
  14. 11 0
      app/Models/RepairDevice.php
  15. 16 0
      app/Models/UseRecord.php
  16. 40 0
      database/migrations/2020_12_20_005551_create_repair_devices_table.php
  17. 34 0
      database/migrations/2020_12_20_005707_create_parts_table.php
  18. 30 0
      database/migrations/2020_12_20_013917_add_repair_device_id_to_parts.php
  19. 36 0
      database/migrations/2020_12_20_022008_create_use_records_table.php
  20. 34 0
      database/migrations/2020_12_20_035228_create_notifications_table.php
  21. 30 0
      database/migrations/2020_12_20_035758_add_user_id_to_notification.php
  22. 30 0
      database/migrations/2020_12_20_041324_add_content_to_notification.php
  23. 3 2
      database/seeds/InnerDeviceStatusSeeder.php
  24. 29 6
      mini/app.js
  25. 17 5
      mini/app.json
  26. 7 0
      mini/app.wxss
  27. 12 2
      mini/components/inner-device-card/index.js
  28. 1 0
      mini/components/inner-device-card/index.wxml
  29. 60 0
      mini/components/inner-order-item/index.js
  30. 4 0
      mini/components/inner-order-item/index.json
  31. 48 0
      mini/components/inner-order-item/index.wxml
  32. 225 0
      mini/components/inner-order-item/index.wxss
  33. 60 0
      mini/components/out-order-item/index.js
  34. 4 0
      mini/components/out-order-item/index.json
  35. 39 0
      mini/components/out-order-item/index.wxml
  36. 222 0
      mini/components/out-order-item/index.wxss
  37. 1 1
      mini/custom-tab-bar/index.js
  38. 250 0
      mini/ec-canvas/ec-canvas.js
  39. 4 0
      mini/ec-canvas/ec-canvas.json
  40. 4 0
      mini/ec-canvas/ec-canvas.wxml
  41. 4 0
      mini/ec-canvas/ec-canvas.wxss
  42. 21 0
      mini/ec-canvas/echarts.js
  43. 121 0
      mini/ec-canvas/wx-canvas.js
  44. 2 2
      mini/pages/create-order/index.js
  45. 236 1
      mini/pages/data/index.js
  46. 1 0
      mini/pages/data/index.json
  47. 84 1
      mini/pages/data/index.wxml
  48. 24 1
      mini/pages/data/index.wxss
  49. 14 3
      mini/pages/device-inner/index.js
  50. 6 7
      mini/pages/device-inner/index.wxml
  51. 233 0
      mini/pages/draft/index.js
  52. 4 0
      mini/pages/draft/index.json
  53. 26 0
      mini/pages/draft/index.wxml
  54. 21 0
      mini/pages/draft/index.wxss
  55. 156 0
      mini/pages/filter-data/index.js
  56. 4 0
      mini/pages/filter-data/index.json
  57. 89 0
      mini/pages/filter-data/index.wxml
  58. 9 0
      mini/pages/filter-data/index.wxss
  59. 2 2
      mini/pages/index/index.wxml
  60. 74 0
      mini/pages/note-detail/index.js
  61. 4 0
      mini/pages/note-detail/index.json
  62. 10 0
      mini/pages/note-detail/index.wxml
  63. 1 0
      mini/pages/note-detail/index.wxss
  64. 154 0
      mini/pages/notification/index.js
  65. 4 0
      mini/pages/notification/index.json
  66. 48 0
      mini/pages/notification/index.wxml
  67. 49 0
      mini/pages/notification/index.wxss
  68. 2 1
      mini/pages/order-inner/index.js
  69. 2 1
      mini/pages/order/index.js
  70. 7 2
      mini/pages/project/index.js
  71. 1 1
      mini/pages/project/index.wxml
  72. 211 0
      mini/pages/repair/index.js
  73. 4 0
      mini/pages/repair/index.json
  74. 102 0
      mini/pages/repair/index.wxml
  75. 48 0
      mini/pages/repair/index.wxss
  76. 85 0
      mini/pages/use-record/index.js
  77. 4 0
      mini/pages/use-record/index.json
  78. 48 0
      mini/pages/use-record/index.wxml
  79. 1 0
      mini/pages/use-record/index.wxss
  80. 19 0
      routes/api.php

+ 1 - 2
app/Http/Controllers/Admin/TestController.php

xqd
@@ -17,8 +17,7 @@ class TestController extends Controller
 {
     public function index(Request $request)
     {
-        $a = json_decode(json_encode(['name' => 'a']));
-        dd($a->name);
+        dd(in_array('2020', ['2020']));
     	return view('admin.test.index');
     }
 }

+ 125 - 0
app/Http/Controllers/Api/mini/DataController.php

xqd
@@ -0,0 +1,125 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Order;
+use App\Models\Project;
+use Carbon\Carbon;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Log;
+
+class DataController extends BaseController
+{
+    protected $order;
+
+    public function __construct()
+    {
+        $this->order = new Order();
+    }
+
+    public function getYearsAndMonths(Request $request)
+    {
+        $years = [
+            ['text' => '所有年', 'value' => '']
+        ];
+
+        $this_year = Carbon::now()->year;
+        for($i = 5; $i >= 0; $i--) {
+            array_push($years, [
+                'text' => $this_year - $i,
+                'value' => $this_year - $i
+            ]);
+        }
+        $months = [];
+        for($i = 1; $i < 13; ++$i) {
+            array_push($months, [
+                'text' => $i . '月',
+                'value' => $i
+            ]);
+        }
+        $month = Carbon::now()->month;
+        $now = Carbon::now()->toDateString();
+        return $this->success(['data' => [
+            ['key' => 'year', 'values' => $years, 'defaultIndex' => count($years) - 1],
+            ['key' => 'month', 'values' => $months, 'defaultIndex' => $month]
+        ], 'now' => $now]);
+    }
+
+    public function getDateInfo()
+    {
+        $now = Carbon::now();
+        $date = $now->year . '-' . $now->month;
+        $min_date = Carbon::now()->subYears(1)->getTimestamp() * 1000;
+        return $this->success(['data' => compact('date', 'min_date')]);
+    }
+
+    public function getStat(Request $request)
+    {
+        $date = $request->input('date') ? $request->input('date') : '2020-1';
+        $date_data = $this->parseDate($date);
+        $date = Carbon::createFromDate($date_data['year'], $date_data['month'], $date_data['day'])->toDateTimeString();
+        $ids = $request->input('project_ids');
+        $orders = $this->order->whereIn('project_id', $ids)->where('created_at', '>=', $date)->orderBy('created_at')->get();
+        $names = [];
+        $values = [];
+        // year|month
+        $type = $request->input('type') ? $request->input('type') : 'year';
+        $cnt = 0;
+        $projects = Project::whereIn('id', $ids)->get();
+
+        foreach($orders as $item) {
+            if($this->inDate($names, $item->created_at, $type)) {
+                foreach ($projects as $key => $project) {
+                    $values[$key][$cnt-1] = $project->id == $item->project_id ? $values[$key][$cnt-1] + 1 : $values[$key][$cnt-1];
+                }
+
+            } else {
+                $names[$cnt] = $type == 'year' ? substr($item->created_at, 0, 7) : substr($item->created_at, 0, 10);
+                foreach ($projects as $key => $project) {
+                    $values[$key][$cnt] = $project->id == $item->project_id ? 1 : 0;
+                }
+                $cnt = $cnt + 1;
+            }
+        }
+        $legends = $projects->pluck('name');
+
+        $total_project = $orders->sum('money') / 100;
+        $tmp = Carbon::createFromTimeString($date);
+        if($tmp->month == 12) {
+            $next_month = Carbon::createFromDate($tmp->year + 1, 1, 1)->toDateTimeString();
+        } else {
+            $next_month = Carbon::createFromDate($tmp->year, $tmp->month + 1, 1)->toDateTimeString();
+        }
+        $total_month = $orders->where('created_at', '<', $next_month)->sum('money') / 100;
+        return $this->success(['data' => compact('values', 'names', 'legends', 'total_project', 'total_month')]);
+    }
+
+    public function inDate($dates, $created_at, $type)
+    {
+        $date = $type == 'year' ? substr($created_at, 0, 7) : substr($created_at, 0, 10);
+        return in_array($date, $dates);
+    }
+
+    public function parseDate($date)
+    {
+        $now = Carbon::now();
+        if(!$date) return ['year' => $now->year, 'month' => $now->month, 'day' => $now->day];
+        $items = explode('-', $date);
+        $year = $now->year;
+        $month = $now->month;
+        $day = $now->day;
+        if(isset($items[0])) {
+            $year = (int)$items[0];
+            $year = $year > 2010 && $year < 2050 ? $year : $now->year;
+        }
+        if(isset($items[1])) {
+            $month = (int)$items[1];
+            $month = $month > 0 && $month < 13 ? $month : $now->month;
+        }
+        if(isset($item[2])) {
+            $day = (int)$items[2];
+            $day = $day > 0 && $day < 32 ? $date : 1;
+        }
+        return compact('year', 'month', 'day');
+    }
+}

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

xqd
@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\DeviceName;
+use App\Models\Spec;
+use Illuminate\Http\Request;
+
+class DeviceNameController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new DeviceName();
+    }
+
+    public function get(Request $request)
+    {
+        if($request->input('type') == 'drop_menu') {
+            $items = $this->model->select('name as text', 'id as value')->get();
+            $items = $items->prepend(collect(['text' => '设备名称', 'value' => '']));
+            return $this->success(['data' => $items]);
+        }
+        $items = $this->model->get();
+        return $this->success(['data' => $items]);
+    }
+}

+ 27 - 1
app/Http/Controllers/Api/mini/InnerDeviceController.php

xqd
@@ -58,10 +58,36 @@ class InnerDeviceController extends BaseController
             }
         }
 //        $items = $items->orderBy('created_at');
+        $stat_items = [];
+        if($request->input('stat')) {
+            $stat_items = $this->getStat($items);
+        }
+
         $items = $items->paginate();
         foreach($items as $item) {
             $item->status = Option::find($item->status);
         }
-        return $this->success(['data' => $items->items()]);
+        return $this->success(['data' => $items->items(), 'stat' => $stat_items]);
+    }
+
+    public function getStat($items)
+    {
+        $items = $items->get();
+        $types = ['free', 'using', 'repair', 'scrap'];
+        $result = [];
+        foreach ($types as $type) {
+            $id = Option::get('inner_devices', 'status', $type);
+            $num = $items->where('status', $id)->count();
+            $result[$type] = $num;
+        }
+        return $result;
+    }
+
+    public function detail(Request $request)
+    {
+        $item = $this->model->with('workPoint', 'spec', 'device', 'device_name')->find($request->input('id'));
+        if(!$item) $this->error(['msg' => '未找到设备']);
+        $item['status'] = Option::find($item['status']);
+        return $this->success(['data' => $item]);
     }
 }

+ 63 - 0
app/Http/Controllers/Api/mini/NotificationController.php

xqd
@@ -0,0 +1,63 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Notification;
+use App\Models\Order;
+use App\Models\Part;
+use App\Models\Spec;
+use App\Models\UseRecord;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+
+class NotificationController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new Notification();
+    }
+
+    public function getStat(Request $request)
+    {
+        $user = Auth::guard('mini')->user();
+        $not_read = $this->model->where('user_id', $user->id)->where('is_read', 2)->count();
+        $is_read = $this->model->where('user_id', $user->id)->where('is_read', 1)->count();
+        return $this->success(['data' => [$not_read, $is_read]]);
+    }
+
+    public function get(Request $request)
+    {
+        $user = Auth::guard('mini')->user();
+        $is_read = $request->input('is_read');
+        $items = $this->model->where('user_id', $user->id)->where('is_read', $is_read);
+        $items = $items->paginate();
+        return $this->success(['data' => $items->items()]);
+    }
+
+    public function change(Request $request)
+    {
+        $user = Auth::guard('mini')->user();
+        if($request->input('type') == 'has_read') {
+            $this->model->where('user_id', $user->id)->update(['is_read' => 1]);
+        } else if($request->input('type') == 'empty') {
+            $this->model->where('user_id', $user->id)->where('is_read', 1)->delete();
+        } else if($request->input('type') == 'read_one') {
+            $this->model->where('id', $request->input('id'))->update(['is_read' => 1]);
+        }
+        return $this->success();
+    }
+
+    public function detail(Request $request)
+    {
+        $item = $this->model->find($request->input('id'));
+        if(!$item) return $this->error(['msg' => '通知不存在']);
+        $order = Order::find($item->order_id);
+        if($order) {
+            $order->formatOrder($order);
+            $item->order = $order;
+        }
+        return $this->success(['data' => $item]);
+    }
+}

+ 6 - 18
app/Http/Controllers/Api/mini/OrderController.php

xqd xqd
@@ -251,9 +251,12 @@ class OrderController extends BaseController
     {
         $items = $this->model->join('users', 'orders.user_id', '=', 'users.id')->select('orders.*', 'users.id as user_id', 'users.name');
         $search_items = [
-            ['project_id', $request->input('project_id')],
-            ['is_draft', 2]
+            ['project_id', $request->input('project_id')]
         ];
+        $is_draft = $request->input('is_draft');
+        if($is_draft) {
+            $search_items['is_draft'] = $is_draft;
+        }
         if($request->input('status')) {
             $status = Option::get('orders', 'status', $request->input('status'));
             if($status) {
@@ -275,23 +278,8 @@ class OrderController extends BaseController
         }
         $items = $items->orderBy('updated_at', 'desc');
         $items = $items->paginate();
-        $type = $request->input('type');
-        $type = $type ? $type : 0;
         foreach($items as $item) {
-            if($type == 1) {
-                $item->devices = OrderDevice::where('order_id', $item->id)->get();
-                foreach($item->devices as $device) {
-                    $device->device = Device::find($device->device_id);
-                    $device->device_name = DeviceName::find($device->device_name_id);
-                    $device->spec = Spec::find($device->spec_id);
-                    $device->rent_type = RentType::find($device->rent_type_id);
-                }
-            } else if($type == 2) {
-                $item->devices = $item->innerDevices;
-            }
-            $item->user_name = $item->user ? $item->user->name : '';
-            $this->formatOrder($item);
-            $item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
+            $item->formatOrder($item);
         }
         return $this->success(['data' => $items->items()]);
     }

+ 27 - 0
app/Http/Controllers/Api/mini/PartController.php

xqd
@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Part;
+use App\Models\Spec;
+use App\Models\UseRecord;
+use Illuminate\Http\Request;
+
+class PartController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new Part();
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->where('repair_device_id', $request->input('id'))->get();
+        foreach($items as $item) {
+            $item->date = substr($item->created_at, 0, 10);
+        }
+        return $this->success(['data' => $items]);
+    }
+}

+ 60 - 0
app/Http/Controllers/Api/mini/RepairDeviceController.php

xqd
@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\InnerDevice;
+use App\Models\Option;
+use App\Models\Part;
+use App\Models\Project;
+use App\Models\RentType;
+use App\Models\RepairDevice;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+
+class RepairDeviceController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new RepairDevice();
+    }
+
+    public function create(Request $request)
+    {
+        $project = Project::find($request->input('project_id'));
+        if(!$project) return $this->error(['msg' => '找不到项目']);
+//        $user = Auth::guard('mini')->user();
+
+        $data = $request->only(['project_id', 'work_point_id', 'inner_device_id', 'reason', 'day', 'remark', 'money']);
+        $data['money'] = $this->transMoney($request->input('money'));
+
+        $repair = $this->model->create($data);
+        $repair_status = Option::get('inner_devices', 'status', 'repair');
+        InnerDevice::where('id', $data['inner_device_id'])->update([
+            'status' => $repair_status
+        ]);
+        if(!$repair) return $this->error(['msg' => '订单失败']);
+        $parts = $request->input('parts');
+        if($parts) {
+            foreach($parts as $item) {
+                $price = $this->transMoney($item['price']);
+                $item['price'] = $price;
+                Part::create(array_merge($item, [
+                    'repair_device_id' => $repair->id
+                ]));
+            }
+        }
+
+        return $this->success();
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->where('inner_device_id', $request->input('id'))->with('parts')->get();
+        foreach($items as $item) {
+            $item->date = substr($item->created_at, 0 ,10);
+        }
+        return $this->success(['data' => $items]);
+    }
+}

+ 5 - 0
app/Http/Controllers/Api/mini/SpecController.php

xqd
@@ -24,4 +24,9 @@ class SpecController extends BaseController
         $items = $this->model->get();
         return $this->success(['data' => $items]);
     }
+
+    public function getStat(Request $request)
+    {
+
+    }
 }

+ 23 - 0
app/Http/Controllers/Api/mini/UseRecordController.php

xqd
@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Http\Controllers\Api\mini;
+
+use App\Models\Spec;
+use App\Models\UseRecord;
+use Illuminate\Http\Request;
+
+class UseRecordController extends BaseController
+{
+    protected $model;
+
+    public function __construct()
+    {
+        $this->model = new UseRecord();
+    }
+
+    public function get(Request $request)
+    {
+        $items = $this->model->where('inner_device_id', $request->input('id'))->with('project', 'user')->get();
+        return $this->success(['data' => $items]);
+    }
+}

+ 8 - 0
app/Models/Notification.php

xqd
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Models;
+
+class Notification extends BaseModel
+{
+    //
+}

+ 23 - 0
app/Models/Order.php

xqd
@@ -79,4 +79,27 @@ class Order extends BaseModel
         }
         $this->update(['money' => $total]);
     }
+
+    public function formatOrder($item)
+    {
+        if($item->type == 1) {
+            $item->devices = OrderDevice::where('order_id', $item->id)->get();
+            foreach($item->devices as $device) {
+                $device->device = Device::find($device->device_id);
+                $device->device_name = DeviceName::find($device->device_name_id);
+                $device->spec = Spec::find($device->spec_id);
+                $device->rent_type = RentType::find($device->rent_type_id);
+            }
+        } else if($item->type == 2) {
+            $item->devices = $item->innerDevices;
+        }
+        $item->user_name = $item->user ? $item->user->name : '';
+        $item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
+
+        $option = Option::find($item->status);
+        $item->status = $item->getStatusName();
+        $item->status_key = $option ? $option['key'] : '';
+        $item->color = $option ? $option['color'] : '';
+        $item->date_time = substr($item->created_at, 0, 16);
+    }
 }

+ 8 - 0
app/Models/Part.php

xqd
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Models;
+
+class Part extends BaseModel
+{
+    //
+}

+ 11 - 0
app/Models/RepairDevice.php

xqd
@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+class RepairDevice extends BaseModel
+{
+    public function parts()
+    {
+        return $this->hasMany('App\Models\Part', 'repair_device_id');
+    }
+}

+ 16 - 0
app/Models/UseRecord.php

xqd
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+class UseRecord extends BaseModel
+{
+    public function user()
+    {
+        return $this->belongsTo('App\Models\User', 'user_id');
+    }
+
+    public function project()
+    {
+        return $this->belongsTo('App\Models\Project', 'project_id');
+    }
+}

+ 40 - 0
database/migrations/2020_12_20_005551_create_repair_devices_table.php

xqd
@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateRepairDevicesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('repair_devices', function (Blueprint $table) {
+            $table->increments('id');
+            $table->unsignedInteger('project_id')->nullable();
+            $table->unsignedInteger('work_point_id')->nullable();
+            $table->unsignedInteger('inner_device_id')->nullable();
+            $table->unsignedInteger('money')->nullable();
+            $table->string('reason', 200)->nullable();
+            $table->unsignedInteger('day')->nullable();
+            $table->string('remark', 200)->nullable();
+            $table->date('start_date')->nullable();
+            $table->date('end_date')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('repair_devices');
+    }
+}

+ 34 - 0
database/migrations/2020_12_20_005707_create_parts_table.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreatePartsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('parts', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('name', 200)->nullable();
+            $table->string('change', 200)->nullable();
+            $table->unsignedInteger('price')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('parts');
+    }
+}

+ 30 - 0
database/migrations/2020_12_20_013917_add_repair_device_id_to_parts.php

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

+ 36 - 0
database/migrations/2020_12_20_022008_create_use_records_table.php

xqd
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUseRecordsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('use_records', function (Blueprint $table) {
+            $table->increments('id');
+            $table->unsignedInteger('project_id')->nullable();
+            $table->unsignedInteger('user_id')->nullable();
+            $table->unsignedInteger('inner_device_id')->nullable();
+            $table->date('start_date')->nullable();
+            $table->date('end_date')->nullable();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('use_records');
+    }
+}

+ 34 - 0
database/migrations/2020_12_20_035228_create_notifications_table.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateNotificationsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('notifications', function (Blueprint $table) {
+            $table->increments('id');
+            $table->unsignedInteger('order_id')->nullable();
+            $table->string('name', 200)->nullable();
+            $table->tinyInteger('is_read')->nullable('1是2否');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('notifications');
+    }
+}

+ 30 - 0
database/migrations/2020_12_20_035758_add_user_id_to_notification.php

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

+ 30 - 0
database/migrations/2020_12_20_041324_add_content_to_notification.php

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

+ 3 - 2
database/seeds/InnerDeviceStatusSeeder.php

xqd
@@ -15,8 +15,9 @@ class InnerDeviceStatusSeeder extends Seeder
         $column = 'status';
         $items = [
             ['name' => '闲置中', 'key' => 'free', 'color' => '#07c160'],
-            ['name' => '使用中', 'key' => 'using', 'color' => '#ff976a'],
-            ['name' => '故障', 'key' => 'error', 'color' => '#ee0a24']
+            ['name' => '使用中', 'key' => 'using', 'color' => '#ee0a24'],
+            ['name' => '维修', 'key' => 'repair', 'color' => '#ff976a'],
+            ['name' => '报废', 'key' => 'scrap', 'color' => 'black']
         ];
         \App\Models\Option::where([
             ['table', '=', $table],

+ 29 - 6
mini/app.js

xqd xqd xqd
@@ -3,7 +3,7 @@ App({
   onLaunch: function () {
 
     var userinfo = wx.getStorageSync('sg-userinfo')
-    if(!userinfo) {
+    if (!userinfo) {
       wx.redirectTo({
         url: '/pages/login/index',
       })
@@ -19,8 +19,8 @@ App({
     // 登录
     // wx.login({
     //   success: res => {
-        // 发送 res.code 到后台换取 openId, sessionKey, unionId
-      // }
+    // 发送 res.code 到后台换取 openId, sessionKey, unionId
+    // }
     // })
     // 获取用户信息
     // wx.getSetting({
@@ -46,21 +46,44 @@ App({
   globalData: {
     userInfo: null
   },
-  loginCallback: function(data) {
+  loginCallback: function (data) {
     this.updateUserInfo(data)
     wx.switchTab({
       url: '/pages/index/index',
     })
   },
-  updateUserInfo: function(info) {
+  updateUserInfo: function (info) {
     this.globalData.userInfo = info
     wx.setStorageSync('sg-userinfo', info)
   },
-  logout: function(res) {
+  logout: function (res) {
     this.globalData.userInfo = null
     wx.setStorageSync('sg-userinfo', null)
     wx.navigateTo({
       url: '/pages/login/index'
     })
+  },
+  resetFilter: function () {
+    var data = {
+      project_ids: [''],
+      work_point_ids: [''],
+      device_id: '',
+      device_name_id: '',
+      spec_id: ''
+    }
+    wx.setStorageSync('sg-device-filters', data)
+  },
+  resetDataFilter: function () {
+    var data = {
+      devices: [],
+      device_ids: [''],
+      names: [],
+      device_name_ids: [''],
+      specs: [],
+      spec_ids: [''],
+      rent_types: [],
+      rent_type_ids: ['']
+    }
+    wx.setStorageSync('sg-data-filters', data)
   }
 })

+ 17 - 5
mini/app.json

xqd xqd xqd
@@ -1,14 +1,21 @@
 {
   "pages": [
+    "pages/data/index",
+    "pages/filter-data/index",
+    "pages/index/index",
+    "pages/note-detail/index",
+    "pages/draft/index",
+    "pages/notification/index",
+    "pages/project/index",
+    "pages/use-record/index",
     "pages/device-inner/index",
+    "pages/repair/index",
     "pages/filter/index",
-    "pages/project/index",
     "pages/order-inner/index",
     "pages/order/index",
     "pages/add-inner-device/index",
     "pages/create-order/index",
     "pages/create-order-inner/index",
-    "pages/index/index",
     "pages/order-detail-inner/index",
     "pages/order-detail/index",
     "pages/account/index",
@@ -16,8 +23,7 @@
     "pages/project-user/index",
     "pages/create-project/index",
     "pages/login/index",
-    "pages/logs/logs",
-    "pages/data/index"
+    "pages/logs/logs"
   ],
   "tabBar": {
     "custom": true,
@@ -57,9 +63,15 @@
     "van-dropdown-menu": "@vant/weapp/dropdown-menu/index",
     "van-dropdown-item": "@vant/weapp/dropdown-item/index",
     "inner-device-card": "/components/inner-device-card/index",
+    "out-order-item": "/components/out-order-item/index",
+    "inner-order-item": "/components/inner-order-item/index",
     "van-checkbox": "@vant/weapp/checkbox/index",
     "van-checkbox-group": "@vant/weapp/checkbox-group/index",
     "van-tab": "@vant/weapp/tab/index",
-    "van-tabs": "@vant/weapp/tabs/index"
+    "van-tabs": "@vant/weapp/tabs/index",
+    "van-collapse": "@vant/weapp/collapse/index",
+    "van-collapse-item": "@vant/weapp/collapse-item/index",
+    "van-picker": "@vant/weapp/picker/index",
+    "ec-canvas": "/ec-canvas/ec-canvas"
   }
 }

+ 7 - 0
mini/app.wxss

xqd xqd
@@ -134,6 +134,9 @@
 .sg-icon {
   font-size: 1.2rem;
 }
+.sg-icon-lg {
+  font-size: 1.5rem;
+}
 .sg-header {
   font-size: 1.2rem;
   font-weight: bold;
@@ -219,3 +222,7 @@
   border-radius: 50%;
   margin-right: 20rpx;
 }
+ec-canvas {
+  width: 100%;
+  height: 100%;
+}

+ 12 - 2
mini/components/inner-device-card/index.js

xqd xqd
@@ -4,7 +4,12 @@ Component({
    * 组件的属性列表
    */
   properties: {
-    item: Object
+    item: Object,
+    action: {
+      type: String,
+      // record
+      value: ''
+    }
   },
 
   /**
@@ -18,6 +23,11 @@ Component({
    * 组件的方法列表
    */
   methods: {
-
+    navigate: function(e) {
+      var url = e.currentTarget.dataset.url
+      wx.navigateTo({
+        url: url,
+      })
+    },
   }
 })

+ 1 - 0
mini/components/inner-device-card/index.wxml

xqd
@@ -7,6 +7,7 @@
       <view class="sg-dot" style="background: {{item.status ? item.status.color : ''}}"></view>
       <view class="sg-status-name">{{item.status ? item.status.name : ''}}</view>
     </view>
+    <van-icon class="sg-action sg-index-color sg-icon" wx:if="{{action=='record'}}" name="notes-o" bindtap="navigate" data-url="/pages/use-record/index?id={{item.id}}"></van-icon>
   </view>
   <view class="sg-body sg-font-xs sg-bottom-border sg-pad-bottom-sm">
     <view class="sg-item sg-margin-tb-sm sg-flex">

+ 60 - 0
mini/components/inner-order-item/index.js

xqd
@@ -0,0 +1,60 @@
+// components/out-order-item/index.js
+import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    item: Object
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    navigate: function(e) {
+      wx.navigateTo({
+        url: e.currentTarget.dataset.url,
+      })
+    },
+    doAction: function(e) {
+      var type = e.currentTarget.dataset.type
+      if(type == 'edit' || type == 'detail') {
+        this.navigate(e)
+      } else if(type == 'confirm') {
+        var that = this
+        var order = e.currentTarget.dataset.order
+        Dialog.confirm({
+          title: '提示',
+          message: '确定订单吗',
+        })
+          .then(() => {
+            that.submitCheck(order)
+          })
+      }
+    },
+    submitCheck(order) {
+      var that = this
+      http({
+        url: 'orders/check',
+        data: {
+          id: order.id,
+          type: 'confirm',
+          remark: order.remark
+        },
+        success: function (res) {
+          if (res.code == 0) {
+            that.triggerEvent("itemChange")
+          }
+        }
+      })
+    },
+  }
+})

+ 4 - 0
mini/components/inner-order-item/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 48 - 0
mini/components/inner-order-item/index.wxml

xqd
@@ -0,0 +1,48 @@
+<!--components/out-order-item/index.wxml-->
+<view class="sg-item sg-white-bg sg-pad sg-margin-bottom sg-font-small" data-url="/pages/order-detail-inner/index?id={{item.id}}"
+        bindtap="navigate">
+        <view class="sg-top sg-bottom-border">
+          <view class="sg-order-status sg-flex sg-align-center sg-space-between sg-margin-bottom sg-font-xs">
+            <view class="sg-order sg-gray-color">订单号:{{item.order_number}}</view>
+            <view class="sg-status sg-bold" style="color: {{item.color}}">{{item.status}}</view>
+          </view>
+          <view class="sg-device-info sg-font-xs">
+            <view class="sg-table-row sg-flex sg-align-center sg-space-around sg-pad-tb-sm sg-top-border">
+              <view class="sg-table-column">资产编号</view>
+              <view class="sg-table-column">设备名称</view>
+              <view class="sg-table-column">开始时间</view>
+              <view class="sg-table-column">结束时间</view>
+            </view>
+            <view class="sg-table-row sg-flex sg-align-center sg-space-around sg-pad-tb-sm sg-top-border" wx:for="{{item.devices}}" wx:for-item="j_item" wx:for-index="j_index"
+              wx:key="j_index">
+              <view class="sg-table-column">{{j_item.number}}</view>
+              <view class="sg-table-column">{{j_item.name}}</view>
+              <view class="sg-table-column">{{j_item.pivot ? j_item.pivot.start_date : ''}}</view>
+              <view class="sg-table-column">{{j_item.pivot ? j_item.pivot.end_date : ''}}</view>
+            </view>
+          </view>
+        </view>
+        <view class="sg-bottom sg-flex sg-align-center sg-space-between">
+          <view class="sg-left">
+            <view class="sg-left-item sg-margin-tb-sm">需求工点:{{item.work_point_name}}</view>
+            <view class="sg-left-item sg-margin-tb-sm">提交人:{{item.user_name}}</view>
+            <view class="sg-left-item sg-margin-tb-sm">创建时间:{{item.date_time}}</view>
+          </view>
+          <block wx:if="{{item.status=='管理员 - 已审核' && role && role.project_role.key == 'machine'}}">
+            <view class="sg-right sg-green-bg sg-pad-sm sg-white" catchtap="doAction" data-type="confirm"
+              data-order="{{item}}">确认订单</view>
+          </block>
+          <block wx:elif="{{item.status_key=='reject'}}">
+            <view class="sg-right sg-red-bg sg-pad-sm sg-white" catchtap="doAction" data-type="edit"
+              data-url="/pages/create-order-inner/index?id={{item.project_id}}&order_id={{item.id}}&type=edit">重新修订</view>
+          </block>
+          <block wx:elif="{{item.status_key=='pass' && role && role.project_role && role.project_role.key=='machine'}}">
+            <view class="sg-right sg-green-bg sg-pad-sm sg-white" catchtap="doAction" data-type="edit"
+              data-url="/pages/create-order-inner/index?id={{item.project_id}}&order_id={{item.id}}&type=edit">归还/续租</view>
+          </block>
+          <block wx:else>
+            <view class="sg-right sg-index-bg sg-pad-sm sg-white" catchtap="doAction" data-type="detail"
+              data-url="/pages/order-detail-inner/index?id={{item.id}}">查看详情</view>
+          </block>
+        </view>
+      </view>

+ 225 - 0
mini/components/inner-order-item/index.wxss

xqd
@@ -0,0 +1,225 @@
+/* components/out-order-item/index.wxss */
+/**app.wxss**/
+.sg-container {
+  min-height: 100vh;
+  padding-bottom: 100rpx;
+  background: #f0f0f0;
+}
+.sg-light-gray-bg {
+  background: #f0f0f0;
+}
+.sg-bg {
+  width: 100%;
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: -1;
+}
+.sg-pad-top {
+  padding-top: 30rpx;
+}
+.sg-pad-bottom {
+  padding-bottom: 30rpx;
+}
+.sg-pad-bottom-sm {
+  padding-bottom: 15rpx;
+}
+.sg-pad-tb-sm {
+  padding-bottom: 15rpx;
+  padding-top: 15rpx;
+}
+.sg-pad-sm {
+  padding: 15rpx;
+}
+.sg-pad {
+  padding: 30rpx;
+}
+.sg-pad-lg {
+  padding: 50rpx;
+  box-sizing: border-box;
+}
+.sg-center {
+  text-align: center;
+}
+.sg-primary-color {
+  color: #195ED7;
+}
+.sg-white {
+  color: white;
+}
+.sg-center {
+  margin-left: auto;
+  margin-right: auto;
+}
+.sg-white-bg {
+  background: white;
+}
+.sg-gray-color {
+  color: rgba(16, 16, 16, 0.5);
+}
+.sg-gray-bg {
+  background: rgba(16, 16, 16, 0.5);
+}
+.sg-bold {
+  font-weight: bold;
+}
+.sg-border {
+  border: 1px solid #ebedf0;
+}
+.sg-bottom-border {
+  border-bottom: 1px solid #ebedf0;
+}
+.sg-top-border {
+  border-top: 1px solid #ebedf0;
+}
+.sg-border-right {
+  border-right: 1px solid #ebedf0;
+}
+.sg-margin {
+  margin: 30rpx;
+}
+.sg-margin-top-sm {
+  margin-top: 30rpx;
+}
+.sg-margin-top {
+  margin-top: 50rpx;
+}
+.sg-margin-bottom {
+  margin-bottom: 30rpx;
+}
+.sg-margin-right {
+  margin-right: 30rpx;
+}
+.sg-margin-tb {
+  margin: 30rpx 0;
+}
+.sg-pad-tb {
+  padding: 30rpx 0;
+}
+.sg-pad-tb-sm {
+  padding: 15rpx 0;
+}
+.sg-margin-tb-sm {
+  margin: 15rpx 0;
+}
+.sg-shadow {
+  box-shadow: 0px 4px 6px 1px #c9c9c9;
+}
+.sg-icon-img {
+  width: 50rpx;
+}
+.sg-font-lg {
+  font-size: 1.2rem;
+}
+.sg-font-xs {
+  font-size: 0.8rem;
+}
+.sg-font-small {
+  font-size: 0.9rem;
+}
+.sg-index-bg {
+  background-color: #5693FC;
+}
+.sg-index-color {
+  color: #5693FC;
+}
+.sg-tabs .sg-tab.sg-selected {
+  color: #5693FC;
+  border-color: #5693FC;
+}
+.sg-avatar {
+  width: 80rpx;
+  border-radius: 50%;
+  border: 2px solid white;
+}
+.sg-icon {
+  font-size: 1.2rem;
+}
+.sg-header {
+  font-size: 1.2rem;
+  font-weight: bold;
+}
+.sg-flex {
+  display: flex;
+}
+.sg-align-center {
+  align-items: center;
+}
+.sg-space-between {
+  justify-content: space-between;
+}
+.sg-just-center {
+  justify-content: center;
+}
+.sg-space-around {
+  justify-content: space-around;
+}
+.sg-flex-grow {
+  flex-grow: 1;
+}
+.sg-bottom-submit-box {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  width: 100%;
+  background: white;
+}
+.sg-big-avatar {
+  width: 130rpx;
+  margin-right: 30rpx;
+  border-radius: 50%;
+}
+.sg-red {
+  color: #ee0a24;
+}
+.sg-red-bg {
+  background: #ee0a24;
+  color: white;
+}
+.sg-green {
+  color: #07c160;
+}
+.sg-green-bg {
+  background: #07c160;
+  color: white;
+}
+.sg-black {
+  color: black;
+}
+.sg-yellow {
+  color: #ff976a;
+}
+.sg-fix-bottom {
+  width: 100%;
+  position: fixed;
+  z-index: 100;
+  left: 0;
+  bottom: 0;
+}
+.sg-text-right {
+  text-align: right;
+}
+.sg-fix-top {
+  position: fixed;
+  left: 0;
+  top: 0;
+  width: 100%;
+}
+.sg-calendar .van-calendar {
+  z-index: 3000;
+}
+.sg-flex-column {
+  flex-direction: column;
+}
+.sg-block {
+  width: 100%;
+}
+.sg-dot {
+  width: 20rpx;
+  height: 20rpx;
+  border-radius: 50%;
+  margin-right: 20rpx;
+}
+.sg-width-50 {
+  width: 50%;
+}

+ 60 - 0
mini/components/out-order-item/index.js

xqd
@@ -0,0 +1,60 @@
+// components/inner-order-item/index.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    item: Object
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    navigate: function(e) {
+      wx.navigateTo({
+        url: e.currentTarget.dataset.url,
+      })
+    },
+    doAction: function(e) {
+      var type = e.currentTarget.dataset.type
+      if(type == 'edit' || type == 'detail') {
+        this.navigate(e)
+      } else if(type == 'confirm') {
+        var that = this
+        var order = e.currentTarget.dataset.order
+        Dialog.confirm({
+          title: '提示',
+          message: '确定订单吗',
+        })
+          .then(() => {
+            that.submitCheck(order)
+          })
+      }
+    },
+  
+    submitCheck(order) {
+      var that = this
+      http({
+        url: 'orders/check',
+        data: {
+          id: order.id,
+          type: 'confirm',
+          remark: order.remark
+        },
+        success: function (res) {
+          if (res.code == 0) {
+            
+          }
+        }
+      })
+    },
+  }
+})

+ 4 - 0
mini/components/out-order-item/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 39 - 0
mini/components/out-order-item/index.wxml

xqd
@@ -0,0 +1,39 @@
+<!--components/inner-order-item/index.wxml-->
+<view class="sg-item sg-white-bg sg-pad sg-margin-bottom sg-font-small" data-url="/pages/order-detail/index?id={{item.id}}" bindtap="navigate">
+  <view class="sg-top sg-bottom-border">
+    <view class="sg-order-status sg-flex sg-align-center sg-space-between sg-margin-bottom sg-font-xs">
+      <view class="sg-order sg-gray-color">订单号:{{item.order_number}}</view>
+      <view class="sg-status sg-bold" style="color: {{item.color}}">{{item.status}}</view>
+    </view>
+    <view class="sg-device-info">
+      <view class="sg-label">租借设备概要:</view>
+      <view class="sg-device-item sg-flex sg-align-center sg-space-between sg-margin-tb-sm" wx:for="{{item.devices}}"
+        wx:for-item="j_item" wx:for-index="j_index" wx:key="j_index">
+        <view class="sg-name">
+          {{j_index+1}}.{{j_item.device ? j_item.device.name : ''}}-{{j_item.device_name ? j_item.device_name.name : ''}}-{{j_item.spec ? j_item.spec.name : ''}}
+        </view>
+        <view class="sg-price">¥{{j_item.price/100}}×{{j_item.quantity}}</view>
+      </view>
+    </view>
+    <view class="sg-total sg-text-right sg-margin-tb-sm">合计:¥{{item.money/100}}</view>
+  </view>
+  <view class="sg-bottom sg-flex sg-align-center sg-space-between">
+    <view class="sg-left">
+      <view class="sg-left-item sg-margin-tb-sm">需求工点:{{item.work_point_name}}</view>
+      <view class="sg-left-item sg-margin-tb-sm">提交人:{{item.user_name}}</view>
+      <view class="sg-left-item sg-margin-tb-sm">创建时间:{{item.date_time}}</view>
+    </view>
+    <block wx:if="{{item.status=='项目经理 - 已审核' && role && role.project_role.key == 'work'}}">
+      <view class="sg-right sg-green-bg sg-pad-sm sg-white" catchtap="doAction" data-type="confirm"
+        data-order="{{item}}">确认订单</view>
+    </block>
+    <block wx:elif="{{item.status_key=='reject'}}">
+      <view class="sg-right sg-red-bg sg-pad-sm sg-white" catchtap="doAction" data-type="edit"
+        data-url="/pages/create-order/index?id={{item.project_id}}&order_id={{item.id}}&type=edit">重新修订</view>
+    </block>
+    <block wx:else>
+      <view class="sg-right sg-index-bg sg-pad-sm sg-white" catchtap="doAction" data-type="detail"
+        data-url="/pages/order-detail/index?id={{item.id}}">查看详情</view>
+    </block>
+  </view>
+</view>

+ 222 - 0
mini/components/out-order-item/index.wxss

xqd
@@ -0,0 +1,222 @@
+/* components/inner-order-item/index.wxss */
+/**app.wxss**/
+.sg-container {
+  min-height: 100vh;
+  padding-bottom: 100rpx;
+  background: #f0f0f0;
+}
+.sg-light-gray-bg {
+  background: #f0f0f0;
+}
+.sg-bg {
+  width: 100%;
+  position: fixed;
+  top: 0;
+  left: 0;
+  z-index: -1;
+}
+.sg-pad-top {
+  padding-top: 30rpx;
+}
+.sg-pad-bottom {
+  padding-bottom: 30rpx;
+}
+.sg-pad-bottom-sm {
+  padding-bottom: 15rpx;
+}
+.sg-pad-tb-sm {
+  padding-bottom: 15rpx;
+  padding-top: 15rpx;
+}
+.sg-pad-sm {
+  padding: 15rpx;
+}
+.sg-pad {
+  padding: 30rpx;
+}
+.sg-pad-lg {
+  padding: 50rpx;
+  box-sizing: border-box;
+}
+.sg-center {
+  text-align: center;
+}
+.sg-primary-color {
+  color: #195ED7;
+}
+.sg-white {
+  color: white;
+}
+.sg-center {
+  margin-left: auto;
+  margin-right: auto;
+}
+.sg-white-bg {
+  background: white;
+}
+.sg-gray-color {
+  color: rgba(16, 16, 16, 0.5);
+}
+.sg-gray-bg {
+  background: rgba(16, 16, 16, 0.5);
+}
+.sg-bold {
+  font-weight: bold;
+}
+.sg-border {
+  border: 1px solid #ebedf0;
+}
+.sg-bottom-border {
+  border-bottom: 1px solid #ebedf0;
+}
+.sg-top-border {
+  border-top: 1px solid #ebedf0;
+}
+.sg-border-right {
+  border-right: 1px solid #ebedf0;
+}
+.sg-margin {
+  margin: 30rpx;
+}
+.sg-margin-top-sm {
+  margin-top: 30rpx;
+}
+.sg-margin-top {
+  margin-top: 50rpx;
+}
+.sg-margin-bottom {
+  margin-bottom: 30rpx;
+}
+.sg-margin-right {
+  margin-right: 30rpx;
+}
+.sg-margin-tb {
+  margin: 30rpx 0;
+}
+.sg-pad-tb {
+  padding: 30rpx 0;
+}
+.sg-pad-tb-sm {
+  padding: 15rpx 0;
+}
+.sg-margin-tb-sm {
+  margin: 15rpx 0;
+}
+.sg-shadow {
+  box-shadow: 0px 4px 6px 1px #c9c9c9;
+}
+.sg-icon-img {
+  width: 50rpx;
+}
+.sg-font-lg {
+  font-size: 1.2rem;
+}
+.sg-font-xs {
+  font-size: 0.8rem;
+}
+.sg-font-small {
+  font-size: 0.9rem;
+}
+.sg-index-bg {
+  background-color: #5693FC;
+}
+.sg-index-color {
+  color: #5693FC;
+}
+.sg-tabs .sg-tab.sg-selected {
+  color: #5693FC;
+  border-color: #5693FC;
+}
+.sg-avatar {
+  width: 80rpx;
+  border-radius: 50%;
+  border: 2px solid white;
+}
+.sg-icon {
+  font-size: 1.2rem;
+}
+.sg-header {
+  font-size: 1.2rem;
+  font-weight: bold;
+}
+.sg-flex {
+  display: flex;
+}
+.sg-align-center {
+  align-items: center;
+}
+.sg-space-between {
+  justify-content: space-between;
+}
+.sg-just-center {
+  justify-content: center;
+}
+.sg-space-around {
+  justify-content: space-around;
+}
+.sg-flex-grow {
+  flex-grow: 1;
+}
+.sg-bottom-submit-box {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  width: 100%;
+  background: white;
+}
+.sg-big-avatar {
+  width: 130rpx;
+  margin-right: 30rpx;
+  border-radius: 50%;
+}
+.sg-red {
+  color: #ee0a24;
+}
+.sg-red-bg {
+  background: #ee0a24;
+  color: white;
+}
+.sg-green {
+  color: #07c160;
+}
+.sg-green-bg {
+  background: #07c160;
+  color: white;
+}
+.sg-black {
+  color: black;
+}
+.sg-yellow {
+  color: #ff976a;
+}
+.sg-fix-bottom {
+  width: 100%;
+  position: fixed;
+  z-index: 100;
+  left: 0;
+  bottom: 0;
+}
+.sg-text-right {
+  text-align: right;
+}
+.sg-fix-top {
+  position: fixed;
+  left: 0;
+  top: 0;
+  width: 100%;
+}
+.sg-calendar .van-calendar {
+  z-index: 3000;
+}
+.sg-flex-column {
+  flex-direction: column;
+}
+.sg-block {
+  width: 100%;
+}
+.sg-dot {
+  width: 20rpx;
+  height: 20rpx;
+  border-radius: 50%;
+  margin-right: 20rpx;
+}

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

xqd
@@ -1,6 +1,6 @@
 Component({
 	data: {
-		active: 2,
+		active: 0,
 		list: [
 			{
 				icon: 'home-o',

+ 250 - 0
mini/ec-canvas/ec-canvas.js

xqd
@@ -0,0 +1,250 @@
+import WxCanvas from './wx-canvas';
+import * as echarts from './echarts';
+
+let ctx;
+
+function compareVersion(v1, v2) {
+  v1 = v1.split('.')
+  v2 = v2.split('.')
+  const len = Math.max(v1.length, v2.length)
+
+  while (v1.length < len) {
+    v1.push('0')
+  }
+  while (v2.length < len) {
+    v2.push('0')
+  }
+
+  for (let i = 0; i < len; i++) {
+    const num1 = parseInt(v1[i])
+    const num2 = parseInt(v2[i])
+
+    if (num1 > num2) {
+      return 1
+    } else if (num1 < num2) {
+      return -1
+    }
+  }
+  return 0
+}
+
+Component({
+  properties: {
+    canvasId: {
+      type: String,
+      value: 'ec-canvas'
+    },
+
+    ec: {
+      type: Object
+    },
+
+    forceUseOldCanvas: {
+      type: Boolean,
+      value: false
+    }
+  },
+
+  data: {
+    isUseNewCanvas: false
+  },
+
+  ready: function () {
+    // Disable prograssive because drawImage doesn't support DOM as parameter
+    // See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
+    echarts.registerPreprocessor(option => {
+      if (option && option.series) {
+        if (option.series.length > 0) {
+          option.series.forEach(series => {
+            series.progressive = 0;
+          });
+        }
+        else if (typeof option.series === 'object') {
+          option.series.progressive = 0;
+        }
+      }
+    });
+
+    if (!this.data.ec) {
+      console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
+        + 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
+      return;
+    }
+
+    if (!this.data.ec.lazyLoad) {
+      this.init();
+    }
+  },
+
+  methods: {
+    init: function (callback) {
+      const version = wx.getSystemInfoSync().SDKVersion
+
+      const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
+      const forceUseOldCanvas = this.data.forceUseOldCanvas;
+      const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
+      this.setData({ isUseNewCanvas });
+
+      if (forceUseOldCanvas && canUseNewCanvas) {
+        console.warn('开发者强制使用旧canvas,建议关闭');
+      }
+
+      if (isUseNewCanvas) {
+        // console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
+        // 2.9.0 可以使用 <canvas type="2d"></canvas>
+        this.initByNewWay(callback);
+      } else {
+        const isValid = compareVersion(version, '1.9.91') >= 0
+        if (!isValid) {
+          console.error('微信基础库版本过低,需大于等于 1.9.91。'
+            + '参见:https://github.com/ecomfe/echarts-for-weixin'
+            + '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
+          return;
+        } else {
+          console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
+          this.initByOldWay(callback);
+        }
+      }
+    },
+
+    initByOldWay(callback) {
+      // 1.9.91 <= version < 2.9.0:原来的方式初始化
+      ctx = wx.createCanvasContext(this.data.canvasId, this);
+      const canvas = new WxCanvas(ctx, this.data.canvasId, false);
+
+      echarts.setCanvasCreator(() => {
+        return canvas;
+      });
+      // const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
+      const canvasDpr = 1
+      var query = wx.createSelectorQuery().in(this);
+      query.select('.ec-canvas').boundingClientRect(res => {
+        if (typeof callback === 'function') {
+          this.chart = callback(canvas, res.width, res.height, canvasDpr);
+        }
+        else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
+          this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
+        }
+        else {
+          this.triggerEvent('init', {
+            canvas: canvas,
+            width: res.width,
+            height: res.height,
+            canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
+          });
+        }
+      }).exec();
+    },
+
+    initByNewWay(callback) {
+      // version >= 2.9.0:使用新的方式初始化
+      const query = wx.createSelectorQuery().in(this)
+      query
+        .select('.ec-canvas')
+        .fields({ node: true, size: true })
+        .exec(res => {
+          const canvasNode = res[0].node
+          this.canvasNode = canvasNode
+
+          const canvasDpr = wx.getSystemInfoSync().pixelRatio
+          const canvasWidth = res[0].width
+          const canvasHeight = res[0].height
+
+          const ctx = canvasNode.getContext('2d')
+
+          const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
+          echarts.setCanvasCreator(() => {
+            return canvas
+          })
+
+          if (typeof callback === 'function') {
+            this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
+          } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
+            this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
+          } else {
+            this.triggerEvent('init', {
+              canvas: canvas,
+              width: canvasWidth,
+              height: canvasHeight,
+              dpr: canvasDpr
+            })
+          }
+        })
+    },
+    canvasToTempFilePath(opt) {
+      if (this.data.isUseNewCanvas) {
+        // 新版
+        const query = wx.createSelectorQuery().in(this)
+        query
+          .select('.ec-canvas')
+          .fields({ node: true, size: true })
+          .exec(res => {
+            const canvasNode = res[0].node
+            opt.canvas = canvasNode
+            wx.canvasToTempFilePath(opt)
+          })
+      } else {
+        // 旧的
+        if (!opt.canvasId) {
+          opt.canvasId = this.data.canvasId;
+        }
+        ctx.draw(true, () => {
+          wx.canvasToTempFilePath(opt, this);
+        });
+      }
+    },
+
+    touchStart(e) {
+      if (this.chart && e.touches.length > 0) {
+        var touch = e.touches[0];
+        var handler = this.chart.getZr().handler;
+        handler.dispatch('mousedown', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.dispatch('mousemove', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.processGesture(wrapTouch(e), 'start');
+      }
+    },
+
+    touchMove(e) {
+      if (this.chart && e.touches.length > 0) {
+        var touch = e.touches[0];
+        var handler = this.chart.getZr().handler;
+        handler.dispatch('mousemove', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.processGesture(wrapTouch(e), 'change');
+      }
+    },
+
+    touchEnd(e) {
+      if (this.chart) {
+        const touch = e.changedTouches ? e.changedTouches[0] : {};
+        var handler = this.chart.getZr().handler;
+        handler.dispatch('mouseup', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.dispatch('click', {
+          zrX: touch.x,
+          zrY: touch.y
+        });
+        handler.processGesture(wrapTouch(e), 'end');
+      }
+    }
+  }
+});
+
+function wrapTouch(event) {
+  for (let i = 0; i < event.touches.length; ++i) {
+    const touch = event.touches[i];
+    touch.offsetX = touch.x;
+    touch.offsetY = touch.y;
+  }
+  return event;
+}

+ 4 - 0
mini/ec-canvas/ec-canvas.json

xqd
@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 4 - 0
mini/ec-canvas/ec-canvas.wxml

xqd
@@ -0,0 +1,4 @@
+<!-- 新的:接口对其了H5 -->
+<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
+<!-- 旧的 -->
+<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>

+ 4 - 0
mini/ec-canvas/ec-canvas.wxss

xqd
@@ -0,0 +1,4 @@
+.ec-canvas {
+  width: 100%;
+  height: 100%;
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 21 - 0
mini/ec-canvas/echarts.js


+ 121 - 0
mini/ec-canvas/wx-canvas.js

xqd
@@ -0,0 +1,121 @@
+export default class WxCanvas {
+  constructor(ctx, canvasId, isNew, canvasNode) {
+    this.ctx = ctx;
+    this.canvasId = canvasId;
+    this.chart = null;
+    this.isNew = isNew
+    if (isNew) {
+      this.canvasNode = canvasNode;
+    }
+    else {
+      this._initStyle(ctx);
+    }
+
+    // this._initCanvas(zrender, ctx);
+
+    this._initEvent();
+  }
+
+  getContext(contextType) {
+    if (contextType === '2d') {
+      return this.ctx;
+    }
+  }
+
+  // canvasToTempFilePath(opt) {
+  //   if (!opt.canvasId) {
+  //     opt.canvasId = this.canvasId;
+  //   }
+  //   return wx.canvasToTempFilePath(opt, this);
+  // }
+
+  setChart(chart) {
+    this.chart = chart;
+  }
+
+  attachEvent() {
+    // noop
+  }
+
+  detachEvent() {
+    // noop
+  }
+
+  _initCanvas(zrender, ctx) {
+    zrender.util.getContext = function () {
+      return ctx;
+    };
+
+    zrender.util.$override('measureText', function (text, font) {
+      ctx.font = font || '12px sans-serif';
+      return ctx.measureText(text);
+    });
+  }
+
+  _initStyle(ctx) {
+    var styles = ['fillStyle', 'strokeStyle', 'globalAlpha',
+      'textAlign', 'textBaseAlign', 'shadow', 'lineWidth',
+      'lineCap', 'lineJoin', 'lineDash', 'miterLimit', 'fontSize'];
+
+    styles.forEach(style => {
+      Object.defineProperty(ctx, style, {
+        set: value => {
+          if (style !== 'fillStyle' && style !== 'strokeStyle'
+            || value !== 'none' && value !== null
+          ) {
+            ctx['set' + style.charAt(0).toUpperCase() + style.slice(1)](value);
+          }
+        }
+      });
+    });
+
+    ctx.createRadialGradient = () => {
+      return ctx.createCircularGradient(arguments);
+    };
+  }
+
+  _initEvent() {
+    this.event = {};
+    const eventNames = [{
+      wxName: 'touchStart',
+      ecName: 'mousedown'
+    }, {
+      wxName: 'touchMove',
+      ecName: 'mousemove'
+    }, {
+      wxName: 'touchEnd',
+      ecName: 'mouseup'
+    }, {
+      wxName: 'touchEnd',
+      ecName: 'click'
+    }];
+
+    eventNames.forEach(name => {
+      this.event[name.wxName] = e => {
+        const touch = e.touches[0];
+        this.chart.getZr().handler.dispatch(name.ecName, {
+          zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
+          zrY: name.wxName === 'tap' ? touch.clientY : touch.y
+        });
+      };
+    });
+  }
+
+  set width(w) {
+    if (this.canvasNode) this.canvasNode.width = w
+  }
+  set height(h) {
+    if (this.canvasNode) this.canvasNode.height = h
+  }
+
+  get width() {
+    if (this.canvasNode)
+      return this.canvasNode.width
+    return 0
+  }
+  get height() {
+    if (this.canvasNode)
+      return this.canvasNode.height
+    return 0
+  }
+}

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

xqd
@@ -9,14 +9,14 @@ Page({
    */
   data: {
     tabs: ['设备租赁订单', '租赁设备添加'],
-    tabIndex: 1,
+    tabIndex: 0,
     work_points: [],
     pointIndex: -1,
     id: -1,
     project: null,
     remark: '',
     devices: [],
-    showAdd: true,
+    showAdd: false,
     device_types: [],
     rent_types: [],
     typeIndex: -1,

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

xqd xqd
@@ -1,20 +1,241 @@
 // pages/data/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+const app = getApp()
+import * as echarts from '../../ec-canvas/echarts';
+
+let chart = null;
+let option = {}
+
+function initChart(canvas, width, height, dpr) {
+  chart = echarts.init(canvas, null, {
+    width: width,
+    height: height,
+    devicePixelRatio: dpr // new
+  });
+  canvas.setChart(chart);
+
+  option = {
+    legend: {
+      data: []
+    },
+    xAxis: {
+      type: 'category',
+      data: []
+    },
+    yAxis: {
+      type: 'value'
+    },
+    series: [{
+      data: [],
+      type: 'bar'
+    }]
+  };
+
+  chart.setOption(option);
+  return chart;
+}
+
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-
+    projects: [],
+    project_ids: [],
+    project_names: '',
+    total_project: '0',
+    total_month: '0',
+    projectShow: false,
+    index: 0,
+    show: false,
+    isSearch: true,
+    charts: [{
+      name: '柱状图',
+      type: 'bar'
+    }, {
+      name: '折线图',
+      type: 'line'
+    }, {
+      name: '饼状图',
+      type: 'pie'
+    }, {
+      name: '明细图',
+      type: 'detail'
+    }, {
+      name: '雷达图',
+      type: 'radar'
+    }],
+    chartIndex: 0,
+    dateTypes: [{
+      name: '按年',
+      type: 'year'
+    }, {
+      name: '按月',
+      type: 'month'
+    }],
+    dateIndex: 0,
+    dateShow: false,
+    years_months: [],
+    date: '',
+    yearDate: '',
+    monthDate: '',
+    max_date: (new Date()).getTime(),
+    min_date: (new Date()).getTime(),
+    filter: {},
+    data: [],
+    ec: {
+      onInit: initChart
+    }
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    var that = this
+    api.getByName(this, 'projects/getAll', 'projects', {}, function (res) {
+      that.getData()
+    });
+    api.getByName(this, 'data/getYearsAndMonths', 'years_months');
+    // var maxDate = (new Date()).getTime()
+    // var minDate = (new Date()).getTime() - 2 * 365 * 24 * 3600 * 1000
+    // this.setData({
+    //   minDate,
+    //   maxDate
+    // })
+    this.getDateInfo()
+    app.resetDataFilter()
+  },
+
+  switchCheck: function(e) {
+    var index = e.currentTarget.dataset.index
+    var projects = this.data.projects
+    projects[index].checked = projects[index].checked ? false : true
+    this.setData({projects})
+  },
+
+  closeProject: function(e) {
+    var project_ids = []
+    var project_names = []
+    var projects = this.data.projects
+    for(var i = 0; i < projects.length; ++i) {
+      if(projects[i].checked) {
+        project_ids.push(projects[i].id)
+        project_names.push(projects[i].name)
+      }
+    }
+    project_names = project_names.join(',')
+    this.setData({project_ids, project_names})
+    this.switchShow(e)
+    this.getData()
+  },
+
+  getData() {
+    var ids = this.data.project_ids
+    if (ids.length <= 0) return false
+    var data = Object.assign({}, {
+      project_ids: ids,
+      date: this.data.date,
+      type: this.data.dateIndex == 0 ? 'year' : 'month'
+    }, this.data.filter)
+    var that = this
+    api.getByName(this, 'data/getStat', 'data', data, function(res) {
+      that.updateChart()
+    });
+  },
 
+  getDateInfo() {
+    var that = this
+    http({
+      url: 'data/getDateInfo',
+      data: {},
+      success: function (res) {
+        if (res.code == 0) {
+          that.setData(res.data)
+          that.setData({
+            yearDate: res.data.date
+          })
+        }
+      }
+    })
   },
 
+  onDateChange: function (e) {
+    var yearDate = e.detail.value[0].value + '-' + e.detail.value[1].value
+    this.setData({
+      yearDate
+    })
+  },
+  dateConfirm: function (e) {
+    this.switchShow(e)
+    this.updateDate()
+  },
+  monthDateConfirm: function (e) {
+    var date = e.detail
+    var monthDate = util.formatDate(date)
+    this.setData({
+      monthDate
+    })
+    this.switchShow(e)
+    this.updateDate()
+  },
+  updateDate: function () {
+    var date = this.data.dateIndex == 0 ? this.data.yearDate : this.data.monthDate
+    this.setData({
+      date
+    })
+    this.getData()
+  },
+
+  onChange: function (e) {
+    var index = e.detail.value
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: index
+    })
+    if(name == 'chartIndex') {
+      this.updateChart()
+    }
+  },
+  updateChart: function() {
+    var data = this.data.data
+    option.xAxis.data = data.names;
+    option.legend = {
+      data: data.legends
+    }
+    var type = this.data.charts[this.data.chartIndex].type
+    var values = data.values
+    for(var i = 0; i < values.length; ++i) {
+      option.series[i] = {
+        label: {
+          show: true,
+          position: 'top'
+        },
+        name: data.legends[i],
+        type: type,
+        data: values[i]
+      }
+    }
+    chart.setOption(option)
+  },
+
+  radioChange: function (e) {
+    var dateIndex = e.currentTarget.dataset.index
+    this.setData({
+      dateIndex
+    })
+  },
+
+  switchShow: function (e) {
+    var name = e.currentTarget.dataset.name
+    var show = e.currentTarget.dataset.show ? e.currentTarget.dataset.show : !this.data[name]
+    this.setData({
+      [name]: show
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
@@ -26,7 +247,21 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
+    this.getTabBar().init();
+    this.setData({
+      project_id: ''
+    })
+    var filter = wx.getStorageSync('sg-data-filters')
+    this.setData({
+      filter: filter
+    })
+  },
 
+  navigate: function(e) {
+    var url = e.currentTarget.dataset.url
+    wx.navigateTo({
+      url: url,
+    })
   },
 
   /**

+ 1 - 0
mini/pages/data/index.json

xqd
@@ -1,3 +1,4 @@
 {
+  "navigationBarTitleText": "数据中心",
   "usingComponents": {}
 }

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

xqd
@@ -1,2 +1,85 @@
 <!--pages/data/index.wxml-->
-<text>pages/data/index.wxml</text>
+<view class="sg-container sg-index-bg">
+  <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>
+      <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="search"></van-icon>
+  </view>
+  <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>
+    </view>
+  </van-popup>
+  <view class="sg-white sg-bold sg-flex sg-align-center sg-space-around">
+    <view class="sg-center">
+      <view class="sg-font-lg">{{data.total_project}}</view>
+      <view class="sg-font-xs sg-pad-tb-sm">项目累计消费</view>
+    </view>
+    <view class="sg-center">
+      <view class="sg-font-lg">{{data.total_month}}</view>
+      <view class="sg-font-xs sg-pad-tb-sm">当月累计消费</view>
+    </view>
+    <view class="sg-center">
+      <view>时间选择</view>
+      <view class="sg-font-small sg-pad-tb-sm sg-flex sg-align-center">
+        <text>{{date}}</text>
+        <!-- <van-icon name="arrow-down" class="sg-icon"></van-icon> -->
+      </view>
+    </view>
+  </view>
+  <view class="sg-white-bg sg-chart-box sg-pad" wx:if="{{!projectShow && !dateShow}}">
+    <block wx:if="{{project_names}}">
+      <view class="sg-flex sg-pad-tb sg-align-center sg-space-between">
+        <view>
+          <picker bindchange="onChange" value="{{chartIndex}}" range="{{charts}}" range-key="name"
+            data-name="chartIndex" class="sg-flex-grow">
+            <view class="picker sg-flex sg-align-center">
+              <text>{{chartIndex >= 0 ? charts[chartIndex].name : '显示类型'}}</text>
+              <van-icon name="arrow-down"></van-icon>
+            </view>
+          </picker>
+        </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>
+      </view>
+      <view class="sg-chart">
+        <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
+      </view>
+    </block>
+    <block wx:else>
+      <view class="sg-center sg-gray-color sg-font-small">
+        <view>筛选条件暂无</view>
+        <view>请选择需要查看的项目后</view>
+        <view>数据才可进行查看</view>
+      </view>
+    </block>
+  </view>
+  <van-popup show="{{ dateShow && dateIndex == 0 }}" position="bottom" custom-style="height: 60vh">
+    <van-picker columns="{{ years_months }}" bind:change="onDateChange" class="sg-year-picker" title="请选择开始日期"
+      show-toolbar bind:cancel="switchShow" bind:confirm="dateConfirm" data-name="dateShow" data-show="{{false}}" />
+  </van-popup>
+  <van-calendar show="{{ dateShow && dateIndex == 1 }}" bind:close="switchShow" bind:confirm="monthDateConfirm"
+    data-name="dateShow" data-show="{{false}}" min-date="{{min_date}}" max-date="{{max_date}}" class="sg-calendar"
+    position="top" />
+</view>

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

xqd
@@ -1 +1,24 @@
-/* pages/data/index.wxss */
+/* pages/data/index.wxss */
+.sg-chart-box {
+  min-height: 90vh;
+  border-top-right-radius: 50rpx;
+  border-top-left-radius: 50rpx;
+  margin-top: 40rpx;
+}
+.sg-radio-group {
+  padding: 10rpx;
+  border-radius: 40rpx;
+}
+.sg-radio-group  .sg-selected {
+  border-radius: 40rpx;
+}
+.sg-radio-group .sg-radio {
+  padding: 10rpx 30rpx;
+}
+.sg-calendar {
+  margin-bottom: 200rpx;
+}
+.sg-chart {
+  width: 100vw;
+  height: 50vh;
+}

+ 14 - 3
mini/pages/device-inner/index.js

xqd xqd xqd
@@ -17,7 +17,9 @@ Page({
     device: '',
     device_name_id: '',
     spec_id: '',
-    list: []
+    list: [],
+    number: '',
+    stat: null
   },
 
   /**
@@ -39,7 +41,8 @@ Page({
         device_id: data.device_id,
         device_name_id: data.device_name_id,
         spec_id: data.spec_id,
-        page: data.page
+        page: data.page,
+        stat: true
       },
       success: function (res) {
         if (res.code == 0) {
@@ -52,13 +55,21 @@ Page({
           that.setData({
             touchBottom,
             list,
-            isSearch: false
+            isSearch: false,
+            stat: res.stat
           })
         }
       }
     })
   },
 
+  onChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail
+    })
+  },
+
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 6 - 7
mini/pages/device-inner/index.wxml

xqd
@@ -1,29 +1,28 @@
 <!--pages/device-inner/index.wxml-->
 <view class="sg-container">
   <view class="sg-top sg-fix-top">
-    <van-search value="{{ number }}" placeholder="按设备固定资产编号模糊搜索" left-icon="none" use-action-slot use-right-icon-slot bind:change="onChange"
-      bind:search="onSearch">
+    <van-search value="{{ number }}" placeholder="按设备固定资产编号模糊搜索" left-icon="none" use-action-slot use-right-icon-slot bind:change="onChange" data-name="number">
       <van-icon name="search" slot="right-icon" class="sg-icon sg-bold" bindtap="search"/>
       <van-icon name="filter-o" slot="action" class="sg-icon sg-index-color sg-bold" bindtap="navigate" data-url="/pages/filter/index"/>
     </van-search>
     <view class="sg-stat-list sg-pad sg-white-bg sg-flex sg-align-center sg-space-around sg-font-xs sg-gray-color">
       <view class="sg-item">
-        <text>闲置:</text><text class="sg-bold sg-green">125</text>
+        <text>闲置:</text><text class="sg-bold sg-green">{{stat ? stat.free : 0}}</text>
       </view>
       <view class="sg-item">
-        <text>在用:</text><text class="sg-bold sg-red">125</text>
+        <text>在用:</text><text class="sg-bold sg-red">{{stat ? stat.using : 0}}</text>
       </view>
       <view class="sg-item">
-        <text>维修:</text><text class="sg-bold sg-yellow">125</text>
+        <text>维修:</text><text class="sg-bold sg-yellow">{{stat ? stat.repair : 0}}</text>
       </view>
       <view class="sg-item">
-        <text>报废:</text><text class="sg-bold sg-black">125</text>
+        <text>报废:</text><text class="sg-bold sg-black">{{stat ? stat.scrap : 0}}</text>
       </view>
     </view>
   </view>
   <view class="sg-list">
     <block wx:if="{{list.length > 0}}">
-      <inner-device-card item="{{item}}" wx:key="index" wx:for="{{list}}"></inner-device-card>
+      <inner-device-card item="{{item}}" wx:key="index" wx:for="{{list}}" action="record"></inner-device-card>
     </block>
     <block wx:else>
       <view class="sg-text-center sg-center sg-gray-color">没有搜索到设备</view>

+ 233 - 0
mini/pages/draft/index.js

xqd
@@ -0,0 +1,233 @@
+// pages/order/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
+
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    id: -1,
+    project: null,
+    tabs: ['全部订单', '设备租赁', '设备调用'],
+    statuses: ['', '1', '2'],
+    list: [
+      [],
+      [],
+      [],
+      [],
+      []
+    ],
+    pages: [1, 1, 1, 1, 1],
+    tabIndex: 0,
+    touchBottom: [false, false, false, false, false],
+    work_points: [],
+    work_point_id: '',
+    pointIndex: -1,
+    isSearch: false,
+    role: '',
+    // list|check
+    type: 'list'
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var id = options.id ? options.id : 1
+    var type = options.type ? options.type : 'list'
+    var tabIndex = options.index ? options.index : 0
+    this.setData({
+      id,
+      type,
+      tabIndex
+    })
+    api.getProject(this)
+    api.getByName(this, 'work-points/get', 'work_points', {type: 'drop_menu'});
+    api.getByName(this, 'orders/getRole', 'role', {id: id});
+    this.getList();
+  },
+  doAction: function(e) {
+    var type = e.currentTarget.dataset.type
+    if(type == 'edit' || type == 'detail') {
+      this.navigate(e)
+    } else if(type == 'confirm') {
+      var that = this
+      var order = e.currentTarget.dataset.order
+      Dialog.confirm({
+        title: '提示',
+        message: '确定订单吗',
+      })
+        .then(() => {
+          that.submitCheck(order)
+        })
+    }
+  },
+
+  submitCheck(order) {
+    var that = this
+    http({
+      url: 'orders/check',
+      data: {
+        id: order.id,
+        type: 'confirm',
+        remark: order.remark
+      },
+      success: function (res) {
+        if (res.code == 0) {
+          that.search()
+        }
+      }
+    })
+  },
+
+  navigate: function(e) {
+    wx.navigateTo({
+      url: e.currentTarget.dataset.url,
+    })
+  },
+
+  search() {
+    this.setData({
+      list: [
+        [],
+        [],
+        [],
+        [],
+        []
+      ],
+      pages: [1, 1, 1, 1, 1],
+      touchBottom: [false, false, false, false, false],
+      isSearch: true
+    })
+    this.getList()
+  },
+
+  getList: function () {
+    var index = this.data.tabIndex
+    var touchBottom = this.data.touchBottom[index]
+    if (touchBottom) return false;
+    var status = this.data.statuses[index]
+    var page = this.data.pages[index]
+    var that = this
+    var work_point_id = this.data.work_point_id
+    http({
+      url: 'orders/get',
+      data: {
+        project_id: this.data.id,
+        page: page,
+        work_point_id: work_point_id,
+        keyword: this.data.keyword,
+        type: status,
+        is_draft: 1
+      },
+      success: function (res) {
+        if (res.code == 0) {
+          var list = that.data.list
+          var touchBottom = that.data.touchBottom
+          list[index] = list[index].concat(res.data);
+          if (res.data.length <= 0) {
+            touchBottom[index] = true;
+          }
+          that.setData({
+            touchBottom,
+            list,
+            isSearch: false
+          })
+        }
+      }
+    })
+  },
+
+  switchTab: function (e) {
+    var index = e.currentTarget.dataset.index
+    this.setData({
+      tabIndex: index
+    })
+    wx.pageScrollTo({
+      scrollTop: 0,
+      duration: 300
+    })
+    this.search()
+  },
+
+  onChange: function (e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail.value
+    })
+  },
+
+  onDropChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail
+    })
+    if(name == 'work_point_id') {
+      this.search()
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    var index = this.data.tabIndex
+    if(!this.data.isSearch && !this.data.touchBottom[index]) {
+      var pages = this.data.pages
+      pages[index] = pages[index] + 1;
+      this.setData({
+        pages
+      })
+      this.getList()
+    }
+    if(this.data.touchBottom[index]) {
+      util.error('没有更多数据了')
+    }
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/draft/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "草稿箱",
+  "usingComponents": {}
+}

+ 26 - 0
mini/pages/draft/index.wxml

xqd
@@ -0,0 +1,26 @@
+<!--pages/order/index.wxml-->
+<view class="sg-container">
+  <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-menu>
+      <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>
+  </view>
+  <view class="sg-list-box sg-pad">
+    <view class="sg-list" wx:for="{{list}}" hidden="{{tabIndex != index}}" wx:key="index">
+      <block wx:for="{{item}}" wx:for-item="i_item" wx:for-index="i_index" wx:key="i_index">
+        <out-order-item wx:if="{{i_item.type == 1}}" item="{{i_item}}"></out-order-item>
+        <inner-order-item wx:else  item="{{i_item}}"></inner-order-item>
+      </block>
+    </view>
+  </view>
+  <van-dialog id="van-dialog" />
+</view>

+ 21 - 0
mini/pages/draft/index.wxss

xqd
@@ -0,0 +1,21 @@
+/* pages/order/index.wxss */
+.sg-search-box {
+  background: white;
+}
+.sg-search-box .sg-left {
+  margin-right: 30rpx;
+}
+.sg-tabs {
+  justify-content: space-around;
+}
+.sg-tabs .sg-tab {
+  padding-bottom: 15rpx;
+  box-sizing: border-box;
+  border-bottom: 2px solid white;
+}
+.sg-container .sg-tabs {
+  padding-bottom: 15rpx;
+}
+.sg-list-box {
+  margin-top: 200rpx;
+}

+ 156 - 0
mini/pages/filter-data/index.js

xqd
@@ -0,0 +1,156 @@
+// pages/filter/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    active: 0,
+    devices: [],
+    device_ids: [''],
+    names: [],
+    device_name_ids: [''],
+    specs: [],
+    spec_ids: [''],
+    rent_types: [],
+    rent_type_ids: ['']
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    api.getByName(this, 'devices/get', 'devices', {type: 'drop_menu'});
+    api.getByName(this, 'device-names/get', 'names', {type: 'drop_menu'});
+    api.getByName(this, 'specs/get', 'specs', {type: 'drop_menu'});
+    api.getByName(this, 'rent-types/get', 'rent_types', {type: 'drop_menu'});
+  },
+
+  onChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    this.setData({
+      [name]: e.detail
+    })
+    if(['device_id', 'device_name_id'].indexOf(name) != -1) {
+      if(name == 'device_id') {
+        this.setData({
+          device_name_id: '',
+          spec_id: ''
+        })
+      }
+      if(name == 'device_name_id') {
+        this.setData({
+          spec_id: ''
+        })
+      }
+      this.updateNameSpec()
+    }
+  },
+
+  confirm: function() {
+    this.saveFilter()
+    wx.navigateBack()
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  delete: function(e) {
+    var name = e.currentTarget.dataset.name
+    var index = e.currentTarget.dataset.index
+    var items = this.data[name]
+    items.splice(index, 1)
+    this.setData({
+      [name]: items
+    })
+  },
+
+  add: function(e) {
+    var name = e.currentTarget.dataset.name
+    var items = this.data[name]
+    if(!items[items.length - 1]) {
+      util.error('请先选择');
+      return false
+    }
+    items.push('')
+    this.setData({
+      [name]: items
+    })
+  },
+
+  onDropChange: function(e) {
+    var index = e.currentTarget.dataset.index
+    var name = e.currentTarget.dataset.name
+    var val = e.detail
+    var items = this.data[name]
+    items[index] = val
+    this.setData({
+      [name]: items
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    var data = wx.getStorageSync('sg-data-filters')
+    this.setData(data)
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+    this.saveFilter()
+  },
+
+  saveFilter() {
+    var data = {
+      devices: this.data.devices,
+      device_ids: this.data.device_ids,
+      names: this.data.names,
+      device_name_ids: this.data.device_name_ids,
+      specs: this.data.specs,
+      spec_ids: this.data.spec_ids,
+      rent_types: this.data.rent_types,
+      rent_type_ids: this.data.rent_type_ids
+    }
+    wx.setStorageSync('sg-data-filters', data)
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/filter-data/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "所有设备",
+  "usingComponents": {}
+}

+ 89 - 0
mini/pages/filter-data/index.wxml

xqd
@@ -0,0 +1,89 @@
+<!--pages/filter/index.wxml-->
+<view class="sg-container sg-index-bg">
+  <view class="sg-pad sg-white">
+    <view class="sg-flex sg-align-center sg-bold sg-font-lg">
+      <van-icon name="notes-o" class="sg-icon sg-margin-right" />
+      <view>数据筛选选择</view>
+    </view>
+    <view class="sg-pad-tb sg-font-small">请根据你需要查看的数据,选择筛选条件</view>
+  </view>
+  <view class="sg-search-tabs sg-white-bg">
+    <van-tabs active="{{ active }}" bind:change="onChange" class="sg-tabs">
+      <van-tab title="设备类型">
+        <view class="sg-list sg-pad sg-light-gray-bg">
+          <view class="sg-bold sg-text-center sg-center sg-margin-tb">- 请选择设备类型 - </view>
+          <view>
+            <view wx:for="{{device_ids}}" wx:key="index" class="sg-flex sg-align-center">
+              <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right">
+                <van-dropdown-item value="{{ item }}" options="{{ devices }}" bind:change="onDropChange"
+                  data-name="device_ids" data-index="{{index}}" />
+              </van-dropdown-menu>
+              <van-button icon="cross" type="danger" bindtap="delete" data-name="device_ids"
+                data-index="{{index}}"></van-button>
+            </view>
+          </view>
+          <view class="sg-margin-tb">
+            <van-button type="primary" block icon="plus" bindtap="add" data-name="device_ids">新增</van-button>
+          </view>
+        </view>
+      </van-tab>
+      <van-tab title="设备名称">
+        <view class="sg-list sg-pad sg-light-gray-bg">
+          <view class="sg-bold sg-text-center sg-center sg-margin-tb">- 请选择设备名称 - </view>
+          <view>
+            <view wx:for="{{device_name_ids}}" wx:key="index" class="sg-flex sg-align-center">
+              <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right">
+                <van-dropdown-item value="{{ item }}" options="{{ names }}" bind:change="onDropChange"
+                  data-name="device_name_ids" data-index="{{index}}" />
+              </van-dropdown-menu>
+              <van-button icon="cross" type="danger" bindtap="delete"
+                data-name="device_name_ids" data-index="{{index}}"></van-button>
+            </view>
+          </view>
+          <view class="sg-margin-tb">
+            <van-button type="primary" block icon="plus" bindtap="add" data-name="device_name_ids">新增</van-button>
+          </view>
+        </view>
+      </van-tab>
+      <van-tab title="规格型号">
+        <view class="sg-list sg-pad sg-light-gray-bg">
+          <view class="sg-bold sg-text-center sg-center sg-margin-tb">- 请选择规格型号 - </view>
+          <view>
+            <view wx:for="{{spec_ids}}" wx:key="index" class="sg-flex sg-align-center">
+              <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right">
+                <van-dropdown-item value="{{ item }}" options="{{ specs }}" bind:change="onDropChange"
+                  data-name="spec_ids" data-index="{{index}}" />
+              </van-dropdown-menu>
+              <van-button icon="cross" type="danger" bindtap="delete"
+                data-name="spec_ids" data-index="{{index}}"></van-button>
+            </view>
+          </view>
+          <view class="sg-margin-tb">
+            <van-button type="primary" block icon="plus" bindtap="add" data-name="spec_ids">新增</van-button>
+          </view>
+        </view>
+      </van-tab>
+      <van-tab title="特殊条件">
+        <view class="sg-list sg-pad sg-light-gray-bg">
+          <view class="sg-bold sg-text-center sg-center sg-margin-tb">- 请选择特殊条件 - </view>
+          <view>
+            <view wx:for="{{spec_ids}}" wx:key="index" class="sg-flex sg-align-center">
+              <van-dropdown-menu class="sg-flex-grow sg-margin-tb-sm sg-margin-right">
+                <van-dropdown-item value="{{ item }}" options="{{ rent_types }}" bind:change="onDropChange"
+                  data-name="spec_ids" data-index="{{index}}" />
+              </van-dropdown-menu>
+              <!-- <van-button icon="cross" type="danger" bindtap="delete"
+                data-name="spec_ids" data-index="{{index}}"></van-button> -->
+            </view>
+          </view>
+          <!-- <view class="sg-margin-tb">
+            <van-button type="primary" block icon="plus" bindtap="add" data-name="spec_ids">新增</van-button>
+          </view> -->
+        </view>
+      </van-tab>
+    </van-tabs>
+  </view>
+  <view class="sg-fix-bottom">
+    <van-button type="info" block bindtap="confirm">点击确认</van-button>
+  </view>
+</view>

+ 9 - 0
mini/pages/filter-data/index.wxss

xqd
@@ -0,0 +1,9 @@
+/* pages/filter/index.wxss */
+.sg-search-tabs {
+  border-top-left-radius: 30rpx;
+  border-top-right-radius: 30rpx;
+  padding-top: 30rpx;
+}
+.sg-search-tabs .sg-list {
+  min-height: 80vh;
+}

+ 2 - 2
mini/pages/index/index.wxml

xqd
@@ -9,11 +9,11 @@
       <van-icon name="user-o" class="sg-icon"/>
       <view class="sg-top-name">成员添加</view>
     </view>
-    <view class="sg-top-item sg-font-xs">
+    <view class="sg-top-item sg-font-xs" bindtap="navigate" data-url="/pages/draft/index">
       <van-icon name="description" class="sg-icon"/>
       <view class="sg-top-name">草稿箱</view>
     </view>
-    <view class="sg-top-item sg-font-xs sg-right-border">
+    <view class="sg-top-item sg-font-xs sg-right-border" bindtap="navigate" data-url="/pages/notification/index">
       <van-icon name="comment-o" class="sg-icon"/>
       <view class="sg-top-name">消息提示</view>
     </view>

+ 74 - 0
mini/pages/note-detail/index.js

xqd
@@ -0,0 +1,74 @@
+// pages/note-detail/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    id: 1,
+    note: null
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var id = options.id ? options.id : 1
+    this.setData({
+      id
+    })
+    api.getByName(this, 'notifications/detail', 'note', {id: id});
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/note-detail/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "租赁通知",
+  "usingComponents": {}
+}

+ 10 - 0
mini/pages/note-detail/index.wxml

xqd
@@ -0,0 +1,10 @@
+<!--pages/note-detail/index.wxml-->
+<view class="sg-container">
+  <view class="sg-bold sg-pad sg-white-bg">{{note.name}}</view>
+  <view class="sg-pad">
+    <view class="sg-gray-color sg-font-xs sg-pad-tb-sm">{{note.created_at}}</view>
+    <view class="sg-pad-tb">{{note.content}}</view>
+    <out-order-item wx:if="{{note.order.type == 1}}" item="{{note.order}}"></out-order-item>
+    <inner-order-item wx:else item="{{note.order}}"></inner-order-item>
+  </view>
+</view>

+ 1 - 0
mini/pages/note-detail/index.wxss

xqd
@@ -0,0 +1 @@
+/* pages/note-detail/index.wxss */

+ 154 - 0
mini/pages/notification/index.js

xqd
@@ -0,0 +1,154 @@
+// pages/create-order/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    tabs: ['未读', '已读'],
+    tabIndex: 0,
+    list: [[], []],
+    is_read: [2, 1],
+    touchBottom: [false, false],
+    pages: [1, 1],
+    stat: [0, 0]
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    api.getByName(this, 'notifications/getStat', 'stat');
+    this.getList();
+  },
+
+  switchTab: function (e) {
+    var index = e.currentTarget.dataset.index
+    this.setData({
+      tabIndex: index
+    })
+    wx.pageScrollTo({
+      scrollTop: 0,
+      duration: 300
+    })
+    this.search()
+  },
+
+  search() {
+    this.setData({
+      list: [
+        [],
+        []
+      ],
+      pages: [1, 1],
+      touchBottom: [false, false]
+    })
+    this.getList()
+  },
+
+  getList: function () {
+    var that = this
+    var index = this.data.tabIndex
+    var is_read = this.data.is_read[index]
+    http({
+      url: 'notifications/get',
+      data: {
+        is_read: is_read
+      },
+      success: function (res) {
+        if (res.code == 0) {
+          var list = that.data.list
+          var touchBottom = that.data.touchBottom
+          list[index] = list[index].concat(res.data);
+          if (res.data.length <= 0) {
+            touchBottom[index] = true;
+          }
+          that.setData({
+            touchBottom,
+            list
+          })
+        }
+      }
+    })
+  },
+
+  doAction: function(e) {
+    var type = e.currentTarget.dataset.type
+    var that = this
+    http({
+      url: 'notifications/change',
+      data: {
+        type: type
+      },
+      success: function (res) {
+        if (res.code == 0) {
+          that.search()
+          that.getStat()
+        }
+      }
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+    var index = this.data.tabIndex
+    if(!this.data.isSearch && !this.data.touchBottom[index]) {
+      var pages = this.data.pages
+      pages[index] = pages[index] + 1;
+      this.setData({
+        pages
+      })
+      this.getList()
+    }
+    if(this.data.touchBottom[index]) {
+      util.error('没有更多数据了')
+    }
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/notification/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "消息通知",
+  "usingComponents": {}
+}

+ 48 - 0
mini/pages/notification/index.wxml

xqd
@@ -0,0 +1,48 @@
+<!--pages/create-order/index.wxml-->
+<view class="sg-container">
+  <view class="sg-tabs sg-flex sg-align-center sg-space-around">
+    <block wx:for="{{tabs}}" wx:key="index">
+      <view class="sg-tab sg-pad {{index == tabIndex ? 'sg-seleted' : 'sg-gray-color'}}" bindtap="switchTab"
+        data-index="{{index}}">{{item}}({{stat[index]}})</view>
+    </block>
+  </view>
+  <view class="sg-pad" wx:if="{{tabIndex == 0}}">
+    <view class="sg-item sg-white-bg sg-pad" wx:for="{{list[0]}}" wx:key="index" bindtap="navigate" data-url="/pages/note-detail/index?id={{item.id}}">
+      <view class="sg-flex sg-align-center sg-space-between sg-font-small">
+        <view class="sg-flex sg-align-center">
+          <view class="sg-margin-right">{{item.created_at}}</view>
+          <view>{{item.name}}</view>
+        </view>
+        <van-button type="danger" round size="mini">new</van-button>
+      </view>
+      <view class="sg-gray-color sg-pad-tb-sm sg-bottom-border">{{item.content}}</view>
+      <view class="sg-flex sg-align-center sg-space-between sg-pad-tb-sm">
+        <view>查看详情</view>
+        <van-icon name="arrow" />
+      </view>
+    </view>
+  </view>
+  <view class="sg-pad" wx:if="{{tabIndex == 1}}">
+    <view class="sg-item sg-white-bg sg-pad" wx:for="{{list[1]}}" wx:key="index" bindtap="navigate" data-url="/pages/note-detail/index?id={{item.id}}">
+      <view class="sg-flex sg-align-center sg-space-between sg-font-small">
+        <view class="sg-flex sg-align-center">
+          <view class="sg-margin-right">{{item.created_at}}</view>
+          <view>{{item.name}}</view>
+        </view>
+      </view>
+      <view class="sg-gray-color sg-pad-tb-sm sg-bottom-border">{{item.content}}</view>
+      <view class="sg-flex sg-align-center sg-space-between sg-pad-tb-sm">
+        <view>查看详情</view>
+        <van-icon name="arrow" />
+      </view>
+    </view>
+  </view>
+  <block wx:if="{{tabIndex == 0}}">
+    <view class="sg-submit-box sg-pad sg-fix-bottom sg-flex sg-align-center sg-center" bindtap="doAction" data-type="has_read">
+      全部已读
+    </view>
+  </block>
+  <view class="sg-submit-box sg-fix-bottom sg-flex sg-align-center sg-center" wx:if="{{tabIndex == 1}}">
+    <view class="sg-action sg-draft sg-pad sg-border-right" bindtap="doAction" data-type="empty">全部清空</view>
+  </view>
+</view>

+ 49 - 0
mini/pages/notification/index.wxss

xqd
@@ -0,0 +1,49 @@
+/* pages/create-order/index.wxss */
+.sg-tabs {
+  background: white;
+}
+.sg-tab {
+  width: 50%;
+  box-sizing: border-box;
+  text-align: center;
+}
+.sg-tab:first-child {
+  border-right: 1px solid #ebedf0;
+}
+.sg-form-item {
+  display: flex;
+  width: 100%;
+  box-sizing: border-box;
+}
+.sg-form-item .sg-label {
+  padding-right: 30rpx;
+  min-width: 150rpx;
+}
+.sg-form-item .sg-input {
+  flex-grow: 1;
+  text-align: right;
+}
+.sg-submit-box {
+  justify-content: center;
+  background: white;
+}
+.sg-device-list .sg-item {
+  background: white;
+  align-items: center;
+}
+.sg-device-list .sg-item .sg-left {
+  display: flex;
+  height: 80rpx;
+}
+.sg-device-list .sg-item .sg-right {
+  height: 80rpx;
+}
+.sg-submit-box .sg-action {
+  width: 50%;
+}
+.sg-submit-box.sg-fix-bottom {
+  z-index: 0;
+}
+.sg-custom {
+  min-width: 200rpx;
+}

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

xqd
@@ -132,7 +132,8 @@ Page({
         page: page,
         work_point_id: work_point_id,
         keyword: this.data.keyword,
-        type: 2
+        type: 2,
+        is_draft: 2
       },
       success: function (res) {
         if (res.code == 0) {

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

xqd
@@ -122,7 +122,8 @@ Page({
         page: page,
         work_point_id: work_point_id,
         keyword: this.data.keyword,
-        type: 1
+        type: 1,
+        is_draft: 2
       },
       success: function (res) {
         if (res.code == 0) {

+ 7 - 2
mini/pages/project/index.js

xqd xqd
@@ -61,7 +61,8 @@ Page({
     }, {
       img: 'http://t18.9026.com/mini/rent-check.png',
       title: '维修上报',
-      desc: '设备维修上报'
+      desc: '设备维修上报',
+      url: '/pages/repair/index'
     }]
   },
 
@@ -80,8 +81,12 @@ Page({
   },
 
   navigate: function(e) {
+    var url = e.currentTarget.dataset.url
+    if(url == '/pages/device-inner/index?id=' + this.data.id) {
+      app.resetFilter();
+    }
     wx.navigateTo({
-      url: e.currentTarget.dataset.url,
+      url: url,
     })
   },
 

+ 1 - 1
mini/pages/project/index.wxml

xqd
@@ -51,7 +51,7 @@
       <text class="sg-sub-title sg-gray-color">内部设备管理</text>
     </view>
     <view class="sg-menu-list">
-      <view class="sg-item sg-flex sg-align-center sg-pad" wx:for="{{device_depot_menus}}" wx:key="index">
+      <view class="sg-item sg-flex sg-align-center sg-pad" wx:for="{{device_depot_menus}}" wx:key="index" bindtap="navigate" data-url="{{item.url}}?id={{id}}" data-title="{{item.title}}">
         <image class="sg-img" src="{{item.img}}" mode="widthFix"></image>
         <view class="sg-name sg-margin-top-sm">{{item.title}}</view>
         <view class="sg-desp sg-margin-top-sm sg-gray-color sg-font-xs">{{item.desc}}</view>

+ 211 - 0
mini/pages/repair/index.js

xqd
@@ -0,0 +1,211 @@
+// pages/create-order/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    tabs: ['维修记录填写', '维修配件添加'],
+    tabIndex: 0,
+    work_points: [],
+    pointIndex: -1,
+    id: -1,
+    project: null,
+    remark: '',
+    inner_devices: [],
+    deviceIndex: -1,
+    parts: [],
+    part_name: '',
+    part_change: '',
+    part_price: '',
+    showAdd: false,
+    order_id: '',
+    // create/edit
+    type: 'create',
+    // create/edit
+    dialog_type: 'create',
+    default_dates: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var id = options.id ? options.id : 1
+    var type = options.type ? options.type : 'create'
+    var order_id = options.order_id ? options.order_id : ''
+    this.setData({
+      id,
+      type,
+      order_id
+    })
+    api.getProject(this)
+    api.getByName(this, 'work-points/get', 'work_points');
+    api.getByName(this, 'inner-devices/get', 'inner_devices');
+  },
+
+  submit: function(e) {
+    if(this.data.pointIndex < 0) {
+      util.error('需求工点必填');
+      return false;
+    }
+    if(this.data.deviceIndex < 0) {
+      util.error('维修设备必填');
+      return false;
+    }
+    var work_point = this.data.work_points[this.data.pointIndex]
+    var device = this.data.inner_devices[this.data.deviceIndex]
+    var url = 'repair-devices/create'
+    http({
+      url: url,
+      data: {
+        project_id: this.data.id,
+        work_point_id: work_point.id,
+        inner_device_id: device.id,
+        money: this.data.money,
+        reason: this.data.reason,
+        day: this.data.day,
+        remark: this.data.remark,
+        parts: this.data.parts
+      },
+      success: function(res) {
+        if(res.code == 0) {
+          util.success('操作成功')
+        }
+      }
+    })
+  },
+
+  switchTab: function(e) {
+    this.setData({
+      tabIndex: e.currentTarget.dataset.index
+    })
+  },
+
+  delete: function(e) {
+    var parts = this.data.parts
+    var index = e.currentTarget.dataset.index
+    parts.splice(index, 1)
+    this.setData({
+      parts
+    })
+  },
+
+  add: function() {
+    if(!this.data.part_name) {
+      util.error('维修部位必填');
+      return false;
+    }
+    if(!this.data.part_change) {
+      util.error('更换配件必填');
+      return false;
+    }
+    if(!this.data.part_price) {
+      util.error('配件价格必填');
+      return false;
+    }
+    var parts = this.data.parts
+    var part = {
+      name: this.data.part_name,
+      change: this.data.part_change,
+      price: this.data.part_price
+    }
+    parts.push(part)
+    this.setData({
+      parts
+    })
+  },
+
+  onChange: function(e) {
+    var name = e.currentTarget.dataset.name
+    var val = e.detail.value
+    
+    this.setData({
+      [name]: val
+    })
+  },
+
+  switchShowAdd: function(e) {
+    var show = e.currentTarget.dataset.show
+    if(show) {
+      this.setData({
+        part_name: '',
+        part_change: '',
+        part_price: '',
+      })
+    }
+    this.setData({
+      showAdd: show,
+      dialog_type: 'create'
+    })
+  },
+
+  switchShowDate: function(e) {
+    this.setData({
+      showDate: e.currentTarget.dataset.show
+    })
+  },
+
+  confirmDate: function(e) {
+    this.switchShowDate(e)
+    var [start_date, end_date] = e.detail;
+    start_date = util.formatDate(start_date)
+    end_date = util.formatDate(end_date)
+    this.setData({
+      start_date,
+      end_date
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/repair/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "维修上报",
+  "usingComponents": {}
+}

+ 102 - 0
mini/pages/repair/index.wxml

xqd
@@ -0,0 +1,102 @@
+<!--pages/create-order/index.wxml-->
+<view class="sg-container">
+  <view class="sg-tabs sg-flex sg-align-center sg-space-around">
+    <block wx:for="{{tabs}}" wx:key="index">
+      <view class="sg-tab sg-pad {{index == tabIndex ? 'sg-seleted' : 'sg-gray-color'}}" bindtap="switchTab"
+        data-index="{{index}}">{{item}}</view>
+    </block>
+  </view>
+  <view class="sg-order-box" wx:if="{{tabIndex == 0}}">
+    <view class="sg-form">
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">项目名称</view>
+        <input value="{{project ? project.name : ''}}" class="sg-input" disabled="true"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">需求工点</view>
+        <picker bindchange="onChange" value="{{pointIndex}}" range="{{work_points}}" range-key="name"
+          data-name="pointIndex" class="sg-input">
+          <view class="picker sg-gray-color">
+            {{pointIndex >= 0 ? work_points[pointIndex].name : '选择所需的工点'}}
+          </view>
+        </picker>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">维修设备</view>
+        <picker bindchange="onChange" value="{{deviceIndex}}" range="{{inner_devices}}" range-key="name"
+          data-name="deviceIndex" class="sg-input">
+          <view class="picker sg-gray-color">
+            {{deviceIndex >= 0 ? inner_devices[deviceIndex].name : '选择需要维修的设备'}}
+          </view>
+        </picker>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">维修总金额</view>
+        <input value="{{money}}" class="sg-input" bindinput="onChange" data-name="money" placeholder="请填写维修总金额"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">维修原因</view>
+        <input value="{{reason}}" class="sg-input" bindinput="onChange" data-name="reason" placeholder="请填写维修原因"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">维修日期</view>
+        <input value="{{day}}" class="sg-input" bindinput="onChange" data-name="day" placeholder="请填写维修天数"></input>
+      </view>
+      <view class="sg-form-item sg-pad sg-top-border">
+        <view class="sg-label">备注</view>
+        <input value="{{remark}}" class="sg-input" bindinput="onChange" data-name="remark" placeholder="订单备注填写"></input>
+      </view>
+    </view>
+  </view>
+  <van-calendar show="{{ showDate }}" bind:close="switchShowDate" bind:confirm="confirmDate" data-show="{{false}}"
+    type="range" class="sg-calendar" default-date="{{default_dates}}" />
+  <view class="sg-device-box" wx:if="{{tabIndex == 1}}">
+    <view class="sg-device-list sg-top-border">
+      <block wx:if="{{parts.length <= 0}}">
+        <view class="sg-center sg-pad">暂无维修配件</view>
+      </block>
+      <block wx:else>
+        <view class="sg-item sg-flex sg-align-center sg-bottom-border" wx:for="{{parts}}" wx:key="index"
+          bindtap="selectDevice" data-index="{{index}}">
+          <view class="sg-left sg-flex-grow sg-pad sg-flex-column">
+            <view class="sg-left-top sg-flex sg-justify-center sg-space-between">
+              <view class="sg-name">{{item.name}}-{{item.change}}</view>
+              <view class="sg-left-right sg-quantity-price sg-gray-color">
+                ¥<text>{{item.price}}</text>
+              </view>
+            </view>
+          </view>
+          <view class="sg-right sg-red-bg sg-pad sg-flex sg-align-center" bindtap="delete" data-index="{{index}}">删除</view>
+        </view>
+      </block>
+    </view>
+  </view>
+  <van-dialog show="{{ showAdd }}" use-slot title="{{dialog_type == 'create' ? '维修配件添加' : '修改设备'}}" show-cancel-button
+    bind:confirm="add" z-index="1">
+    <view class="sg-add-device-box sg-pad sg-font-small">
+      <view class="sg-form-item sg-pad-tb sg-top-border">
+        <view class="sg-label">设备维修部位</view>
+        <input value="{{part_name}}" class="sg-input" bindinput="onChange" data-name="part_name"
+          placeholder="请输入设备维修部位"></input>
+      </view>
+      <view class="sg-form-item sg-pad-tb sg-top-border">
+        <view class="sg-label">需要更换配件</view>
+        <input value="{{part_change}}" class="sg-input" bindinput="onChange" data-name="part_change"
+          placeholder="请输入更换的配件"></input>
+      </view>
+      <view class="sg-form-item sg-pad-tb sg-top-border">
+        <view class="sg-label">更换配件价格</view>
+        <input value="{{part_price}}" class="sg-input" bindinput="onChange" data-name="part_price"
+          placeholder="请输入更换配件价格(元)"></input>
+      </view>
+    </view>
+  </van-dialog>
+  <block wx:if="{{tabIndex == 1}}">
+    <view class="sg-submit-box sg-pad sg-fix-bottom sg-flex sg-align-center sg-center" bindtap="switchShowAdd" data-show="true">
+      <van-icon name="plus" /><text>立即添加</text>
+    </view>
+  </block>
+  <view class="sg-submit-box sg-fix-bottom sg-flex sg-align-center sg-center" wx:if="{{tabIndex == 0}}">
+    <view class="sg-action sg-pad sg-index-bg sg-white" bindtap="submit" data-type='save'>提交</view>
+  </view>
+</view>

+ 48 - 0
mini/pages/repair/index.wxss

xqd
@@ -0,0 +1,48 @@
+/* pages/create-order/index.wxss */
+.sg-tabs {
+  background: white;
+}
+.sg-tab {
+  width: 50%;
+  box-sizing: border-box;
+  text-align: center;
+}
+.sg-tab:first-child {
+  border-right: 1px solid #ebedf0;
+}
+.sg-form-item {
+  display: flex;
+  width: 100%;
+  box-sizing: border-box;
+}
+.sg-form-item .sg-label {
+  padding-right: 30rpx;
+  min-width: 150rpx;
+}
+.sg-form-item .sg-input {
+  flex-grow: 1;
+  text-align: right;
+}
+.sg-order-box {
+  background: white;
+}
+.sg-submit-box {
+  justify-content: center;
+  background: white;
+}
+.sg-device-list .sg-item {
+  background: white;
+  align-items: center;
+}
+.sg-device-list .sg-item .sg-left {
+  display: flex;
+}
+.sg-submit-box .sg-action {
+  width: 100%;
+}
+.sg-submit-box.sg-fix-bottom {
+  z-index: 0;
+}
+.sg-custom {
+  min-width: 200rpx;
+}

+ 85 - 0
mini/pages/use-record/index.js

xqd
@@ -0,0 +1,85 @@
+// pages/use-record/index.js
+import http from '../../utils/http'
+import util from '../../utils/util'
+import api from '../../utils/api'
+
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    inner_device: null,
+    id: '',
+    activeNames: ['1', '2'],
+    records: [],
+    repair_devices: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    var id = options.id ? options.id : 1
+    this.setData({
+      id
+    })
+    api.getByName(this, 'inner-devices/detail', 'inner_device', {id: id});
+    api.getByName(this, 'use-records/get', 'records', {id: id});
+    api.getByName(this, 'repair-devices/get', 'repair_devices', {id: id});
+  },
+
+  onChange(event) {
+    this.setData({
+      activeNames: event.detail,
+    });
+  },
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 4 - 0
mini/pages/use-record/index.json

xqd
@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "工作阅历",
+  "usingComponents": {}
+}

+ 48 - 0
mini/pages/use-record/index.wxml

xqd
@@ -0,0 +1,48 @@
+<!--pages/use-record/index.wxml-->
+<view class="sg-container sg-pad">
+  <inner-device-card item="{{inner_device}}" wx:key="index"></inner-device-card>
+  <van-collapse value="{{ activeNames }}" bind:change="onChange">
+    <van-collapse-item title="历史阅历" name="1">
+      <view class="sg-list">
+        <block wx:if="{{records.length > 0}}">
+          <view class="sg-item" wx:for="{{records}}" wx:key="index">
+            <view class="sg-date sg-flex sg-align-center sg-space-between sg-index-color sg-bold sg-pad-tb-sm sg-bottom-border">
+              <view>{{item.start_date}}</view>
+              <view>-</view>
+              <view>{{item.end_date}}</view>
+            </view>
+            <view class="sg-flex sg-align-center sg-bottom-border sg-space-between sg-pad-tb-sm">
+              <view>调用项目</view>
+              <view class="sg-bold sg-black">{{item.project ? item.project.name : ''}}</view>
+            </view>
+            <view class="sg-flex sg-align-center sg-bottom-border sg-space-between sg-pad-tb-sm">
+              <view>调用人员</view>
+              <view class="sg-bold sg-black">{{item.user ? item.user.name : ''}}</view>
+            </view>
+          </view>
+        </block>
+        <block wx:else class="sg-center">暂无历史阅历</block>
+      </view>
+    </van-collapse-item>
+    <van-collapse-item title="维修记录" name="2">
+      <block wx:if="{{repair_devices.length > 0}}">
+          <view class="sg-item" wx:for="{{repair_devices}}" wx:key="index">
+            <view class="sg-date sg-flex sg-align-center sg-space-between sg-index-color sg-bold sg-pad-tb-sm sg-bottom-border">
+              <view>{{item.date}}</view>
+              <view>维修部位</view>
+              <view>金额</view>
+            </view>
+            <view class="sg-part-list">
+              <view wx:for="{{item.parts}}" wx:for-item="j_item" wx:for-index="j_index" wx:key="j_index" class="sg-flex sg-align-center sg-space-between sg-pad-tb-sm">
+                <view>更换配件{{j_index + 1}}</view>
+                <view>{{j_item.name}}</view>
+                <view>¥{{j_item.price/100}}</view>
+              </view>
+            </view>
+            <view class="sg-center sg-bold sg-black sg-pad-tb-sm">维修合计金额:¥{{item.money/100}}</view>
+          </view>
+        </block>
+        <block wx:else class="sg-center">暂无维修记录</block>
+    </van-collapse-item>
+  </van-collapse>
+</view>

+ 1 - 0
mini/pages/use-record/index.wxss

xqd
@@ -0,0 +1 @@
+/* pages/use-record/index.wxss */

+ 19 - 0
routes/api.php

xqd xqd
@@ -46,6 +46,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\mini', 'prefix' =>
     $api->any('inner-devices/get', 'InnerDeviceController@get');
     $api->any('inner-devices/search', 'InnerDeviceController@search');
     $api->any('inner-devices/search2', 'InnerDeviceController@search2');
+    $api->any('inner-devices/detail', 'InnerDeviceController@detail');
 
     $api->any('specs/get', 'SpecController@get');
 
@@ -60,4 +61,22 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\mini', 'prefix' =>
     $api->any('orders/getRole', 'OrderController@getRole');
     $api->any('orders/check', 'OrderController@check');
     $api->any('orders/changePrice', 'OrderController@changePrice');
+
+    $api->any('repair-devices/create', 'RepairDeviceController@create');
+    $api->any('repair-devices/get', 'RepairDeviceController@get');
+
+    $api->any('use-records/get', 'UseRecordController@get');
+
+    $api->any('parts/get', 'PartController@get');
+
+    $api->any('notifications/getStat', 'NotificationController@getStat');
+    $api->any('notifications/get', 'NotificationController@get');
+    $api->any('notifications/detail', 'NotificationController@detail');
+    $api->any('notifications/change', 'NotificationController@change');
+
+    $api->any('data/getYearsAndMonths', 'DataController@getYearsAndMonths');
+    $api->any('data/getDateInfo', 'DataController@getDateInfo');
+    $api->any('data/getStat', 'DataController@getStat');
+
+    $api->any('device-names/get', 'DeviceNameController@get');
 });

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott