李浩杰 пре 4 година
родитељ
комит
2be56c797d

+ 1 - 0
app/Http/Controllers/Admin/InnerDeviceController.php

xqd
@@ -70,6 +70,7 @@ class InnerDeviceController extends BaseController
             $item->spec_name = $item->spec ? $item->spec->name : '';
             $item->status = $item->getStatusLabel();
             $item->work_point_name = $item->workPoint ? $item->workPoint->name : '';
+            $item->project_name = $item->project ? $item->project->name : '';
         }
 
 

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

xqd xqd xqd
@@ -41,6 +41,12 @@ class OrderDeviceController extends BaseController
         return view($this->view_path . 'rent-list', compact('model', 'model_name','pre_uri'));
     }
 
+    public function rent()
+    {
+        list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
+        return view($this->view_path . 'rent', compact('model', 'model_name','pre_uri'));
+    }
+
     public function applyList()
     {
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
@@ -78,6 +84,7 @@ class OrderDeviceController extends BaseController
                 $item->number = $item->inner_device ? $item->inner_device->number : '';
                 $item->device_name_name = $item->inner_device ? ($item->inner_device->device_name ? $item->inner_device->device_name->name : '') : '';
                 $item->spec_name = $item->inner_device ? ($item->inner_device->spec ? $item->inner_device->spec->name : '') : '';
+                $item->project_name = $item->project ? $item->project->name : '';
                 $item->work_point_name = $item->inner_device ? ($item->inner_device->workPoint ? $item->inner_device->workPoint->name : '') : '';
                 $item->status_label = $item->inner_device ? $item->inner_device->getStatusLabel() : '';
             }
@@ -85,6 +92,7 @@ class OrderDeviceController extends BaseController
             foreach ($items as $item) {
                 $item->user_name = $item->user ? $item->user->name : '';
                 $item->project_name = $item->project ? $item->project->name : '';
+                $item->work_point_name = $item->order ? ($item->order->workPoint ? $item->order->workPoint->name : '') : '';
                 $item->money = ($item->price * $item->quantity) / 100;
                 $item->device_type_name = $item->device ? $item->device->name : '';
                 $item->device_name_name = $item->device_name ? $item->device_name->name : '';

+ 4 - 3
app/Http/Controllers/Admin/TestController.php

xqd xqd
@@ -2,8 +2,10 @@
 
 namespace App\Http\Controllers\Admin;
 
+use App\Models\Project;
 use App\Models\User;
 use App\Models\UserAuth;
+use App\Models\WorkPoint;
 use Illuminate\Http\Request;
 
 
@@ -11,10 +13,9 @@ class TestController extends Controller
 {
     public function index(Request $request)
     {
-        User::where('id', '>', 0)->update(['open_id' => '', 'phone' => '']);
-        UserAuth::where('id', '>', 0)->delete();
 
-        dd('--------');
+
+        dd( WorkPoint::find(22)->project);
 //    	return view('admin.test.index');
     }
 }

+ 6 - 2
app/Http/Controllers/Admin/WorkPointController.php

xqd xqd xqd xqd
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers\Admin;
 
 use App\Models\Option;
+use App\Models\Project;
 use App\Models\ProjectRole;
 use App\Models\WorkPoint;
 use Illuminate\Http\Request;
@@ -61,6 +62,7 @@ class WorkPointController extends BaseController
 
         foreach ($items as $item) {
             $item->status_label = $item->getNameOrLabel('status', 'label');
+            $item->project_name = $item->project ? $item->project->name : '';
         }
 
         return response()->json(['code' => 0, 'message' => '', 'count' => $items->total(), 'data' => $items->items()]);
@@ -69,8 +71,9 @@ class WorkPointController extends BaseController
     public function create()
     {
         $status_options = $this->model->getStatusOptions();
+        $projects = Project::getOptions();
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
-        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri', 'status_options'));
+        return view($this->view_path . 'create', compact('model', 'model_name','pre_uri', 'status_options', 'projects'));
     }
 
     public function store(Request $request)
@@ -90,8 +93,9 @@ class WorkPointController extends BaseController
     {
         if(empty($request->input('id')) || empty($item = $this->model->find($request->input('id')))) return back()->withErrors(['sg_error_info' => '找不到要编辑的数据']);
         $status_options = $this->model->getStatusOptions();
+        $projects = Project::getOptions();
         list($model, $model_name, $pre_uri) = array($this->model, $this->model_name, $this->pre_uri);
-        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'status_options'));
+        return view($this->view_path . 'edit', compact('model', 'model_name', 'pre_uri', 'item', 'status_options', 'projects'));
     }
 
     public function update(Request $request)

+ 4 - 0
app/Http/Controllers/Api/mini/InnerDeviceController.php

xqd
@@ -32,6 +32,10 @@ class InnerDeviceController extends BaseController
                 $items = $items->where($equal_item, '=', $request->input($equal_item));
             }
         }
+        if($request->input('status') == 'using') {
+            $using_id = Option::get('inner_devices', 'status', 'using');
+            $items->where('status', $using_id);
+        }
         $items = $items->get();
         return $this->success(['data' => $items]);
     }

+ 7 - 2
app/Http/Controllers/Api/mini/WorkPointController.php

xqd
@@ -21,12 +21,17 @@ class WorkPointController extends BaseController
 
     public function get(Request $request)
     {
+        $items = $this->model;
+        if($request->input('project_id')) {
+            $items = $items->where('project_id', $request->input('project_id'));
+        }
         if($request->input('type') == 'drop_menu') {
-            $items = $this->model->select('name as text', 'id as value')->get();
+
+            $items = $items->select('name as text', 'id as value')->get();
             $items = $items->prepend(collect(['text' => '所需工点', 'value' => '']));
             return $this->success(['data' => $items]);
         }
-        $items = $this->model->get();
+        $items = $items->get();
         return $this->success(['data' => $items]);
     }
 }

+ 5 - 0
app/Models/OrderDevice.php

xqd
@@ -38,4 +38,9 @@ class OrderDevice extends BaseModel
     {
         return $this->belongsTo('App\Models\User', 'user_id');
     }
+
+    public function order()
+    {
+        return $this->belongsTo('App\Models\Order', 'order_id');
+    }
 }

+ 5 - 0
app/Models/WorkPoint.php

xqd
@@ -11,4 +11,9 @@ class WorkPoint extends BaseModel
             ['column', 'status']
         ])->get();
     }
+
+    public function project()
+    {
+        return $this->belongsTo('App\Models\Project', 'project_id');
+    }
 }

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

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

+ 2 - 2
mini/app.json

xqd
@@ -1,13 +1,13 @@
 {
   "pages": [
     "pages/index/index",
+    "pages/filter-data/index",
+    "pages/filter/index",
     "pages/account/index",
     "pages/user/index",
     "pages/bind/index",
     "pages/data-center/index",
-    "pages/filter-data/index",
     "pages/data/index",
-    "pages/filter/index",
     "pages/add-inner-device/index",
     "pages/project/index",
     "pages/repair/index",

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

xqd
@@ -56,7 +56,7 @@ Page({
   init() {
     var order_id = this.data.order_id
     api.getProject(this)
-    api.getByName(this, 'work-points/get', 'work_points');
+    api.getByName(this, 'work-points/get', 'work_points', {project_id: this.data.id});
     if (order_id) {
       var that = this
 

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

xqd
@@ -64,7 +64,7 @@ Page({
       order_id
     })
     api.getProject(this)
-    api.getByName(this, 'work-points/get', 'work_points');
+    api.getByName(this, 'work-points/get', 'work_points', {project_id: id});
     api.getByName(this, 'devices/getThreeLevel', 'device_types');
     api.getByName(this, 'rent-types/get', 'rent_types');
     if(order_id) {

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

xqd
@@ -52,14 +52,14 @@
             <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" active-color="#1989fa">
                 <van-dropdown-item value="{{ item }}" options="{{ specs }}" bind:change="onDropChange"
-                  data-name="spec_ids" data-index="{{index}}"  disabled="{{ device_name_ids.length > 1 }}"/>
+                  data-name="spec_ids" data-index="{{index}}"  disabled="{{ device_name_ids.length > 1 || device_ids.length > 1 }}"/>
               </van-dropdown-menu>
               <van-button icon="cross" color="#1989fa" type="danger" bindtap="delete"
                 data-name="spec_ids" data-index="{{index}}" disabled="{{index == 0}}"></van-button>
             </view>
           </view>
           <view class="sg-margin-tb">
-            <van-button type="primary" block icon="plus" color="#1989fa" bindtap="add" data-name="spec_ids">新增</van-button>
+            <van-button type="primary" block icon="plus" color="#1989fa" bindtap="add" data-name="spec_ids" disabled="{{ device_name_ids.length > 1 || device_ids.length > 1 }}">新增</van-button>
           </view>
         </view>
       </van-tab>

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

xqd
@@ -42,7 +42,6 @@ Page({
       }
     });
     api.getByName(this, 'getUserInfo', 'userInfo', {}, function(res) {
-      console.log(res)
       app.updateUserInfo(res);
     });
   },

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

xqd xqd
@@ -45,7 +45,7 @@ Page({
     })
     api.getProject(this)
     api.getByName(this, 'work-points/get', 'work_points');
-    api.getByName(this, 'inner-devices/get', 'inner_devices', {project_id:id});
+    api.getByName(this, 'inner-devices/get', 'inner_devices', {project_id:id, status: 'using'});
   },
 
   switchChecked(e) {
@@ -89,6 +89,11 @@ Page({
       success: function(res) {
         if(res.code == 0) {
           util.success('操作成功')
+          setTimeout(function() {
+            wx.navigateBack({
+              delta: 0,
+            })
+          }, 1000)
         }
       }
     })

+ 1 - 1
mini/utils/env.js

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

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

xqd
@@ -55,7 +55,7 @@
                     url: '{{ $pre_uri }}' + 'get',
                     cellMinWidth: 80,
                     cols: [[
-                        { field: 'id', title: 'ID', align: 'center' },
+                        // { field: 'id', title: 'ID', align: 'center' },
                         { field: 'name', title: '名称', align: 'center' },
                         { field: 'sort', title: '排序', align: 'center' },
                         { title: '操作', align:'center', toolbar: '#sg-table-bar' }

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

xqd
@@ -202,6 +202,7 @@
                         { field: 'manufacturer', title: '生产厂家', align: 'center' },
                         { field: 'shape', title: '外形尺寸', align: 'center' },
                         { field: 'quantity', title: '数量', align: 'center' },
+                        { field: 'project_name', title: '在用项目', align: 'center' },
                         { field: 'work_point_name', title: '目前工点', align: 'center' },
                         { field: 'status', title: '状态', align: 'center' },
                         { title: '操作', align:'center', toolbar: '#sg-table-bar', width: '200' },

+ 1 - 0
resources/views/admin/order-devices/apply-list.blade.php

xqd
@@ -58,6 +58,7 @@
                     cols: [[
                         { field: 'id', title: 'ID', align: 'center' },
                         { field: 'order_id', title: '订单ID', align: 'center' },
+                        { field: 'project_name', title: '项目', align: 'center' },
                         { field: 'number', title: '固定资产编号', align: 'center' },
                         { field: 'device_name_name', title: '租赁设备名称', align: 'center' },
                         { field: 'spec_name', title: '设备规格型号', align: 'center' },

+ 2 - 0
resources/views/admin/order-devices/rent-list.blade.php

xqd
@@ -58,6 +58,8 @@
                     cols: [[
                         { field: 'id', title: 'ID', align: 'center' },
                         { field: 'order_id', title: '订单ID', align: 'center' },
+                        { field: 'project_name', title: '项目', align: 'center' },
+                        { field: 'work_point_name', title: '工点', align: 'center' },
                         { field: 'device_type_name', title: '租赁设备类型', align: 'center' },
                         { field: 'device_name_name', title: '租赁设备名称', align: 'center' },
                         { field: 'spec_name', title: '设备规格型号', align: 'center' },

+ 226 - 0
resources/views/admin/order-devices/rent.blade.php

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

+ 1 - 0
resources/views/admin/work-points/create.blade.php

xqd
@@ -12,6 +12,7 @@
             <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">
 
                 {{ csrf_field() }}
+                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_id', 'label' => '所属项目', 'selected_id' => (old('data') ? old('data')['project_id'] : ''), 'options' => $projects])
                 @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
                 @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => (old('data') ? old('data')['status'] : ''), 'options' => $status_options])
                 <div class="layui-form-item">

+ 1 - 0
resources/views/admin/work-points/edit.blade.php

xqd
@@ -13,6 +13,7 @@
 
                 {{ csrf_field() }}
                 <input type="hidden" name="id" value="{{ $item->id }}">
+                @include('share.layui-form-item', ['type' => 'select', 'name' => 'project_id', 'label' => '所属项目', 'selected_id' => $item->project_id, 'options' => $projects])
                 @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '名称', 'required' => true, 'value' => ($item->name ? $item->name : '')])
                 @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => $item->status, 'options' => $status_options])
                 <div class="layui-form-item">

+ 1 - 0
resources/views/admin/work-points/index.blade.php

xqd
@@ -62,6 +62,7 @@
                     cellMinWidth: 80,
                     cols: [[
                         { field: 'id', title: 'ID', align: 'center' },
+                        { field: 'project_name', title: '所属项目', align: 'center' },
                         { field: 'name', title: '名称', align: 'center' },
                         { field: 'status_label', title: '状态', align: 'center' },
                         { title: '操作', align:'center', toolbar: '#sg-table-bar' }