Ver Fonte

自定义字段功能

LD há 5 anos atrás
pai
commit
8b6e7d4560

+ 15 - 0
app/CustomField.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class CustomField extends Model
+{
+    protected $fillable=['table',
+        'field',
+        'present_name',
+        'authority_name',
+        'condition_field',
+        'condition_value'];
+}

+ 90 - 0
app/Http/Controllers/CustomFieldController.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\CustomField;
+use Illuminate\Http\Request;
+
+class CustomFieldController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+    public function indexAtRejectedBill()
+    {
+        $customFields=CustomField::where('table','rejected_bills')->get();
+        return view('rejected.customField.index',compact('customFields'));
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\CustomField  $customField
+     * @return \Illuminate\Http\Response
+     */
+    public function show(CustomField $customField)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\CustomField  $customField
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(CustomField $customField)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\CustomField  $customField
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, CustomField $customField)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\CustomField  $customField
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(CustomField $customField)
+    {
+        //
+    }
+}

+ 1 - 1
app/RejectedBill.php

@@ -22,7 +22,7 @@ class RejectedBill extends Model
     protected $fillable=['id_owner','order_number','sender','mobile_sender',
         'logistic_number','logistic_number_return','id_logistic_return',
         'is_loaded','fee_collected','remark','id_operator','is_checked'
-        ,'is_finished','checked_numbers','remark'];
+        ,'is_finished','checked_numbers','remark','common_01','common_02'];
 
     protected $appends = ['owner_name','logistic_name','created_at_short'
         ,'is_loaded_str','goods_amount','is_loaded_null','operator_name'];

+ 12 - 0
database/factories/CustomFieldFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\CustomField;
+use Faker\Generator as Faker;
+
+$factory->define(CustomField::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

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

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddFieldsRejectedBills extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('rejected_bills', function (Blueprint $table) {
+            $table->string('common_01')->nullable()->comment('额外定义通用字段,见定义自段表');
+            $table->string('common_02')->nullable()->comment('额外定义通用字段,见定义自段表');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('authorities',function (Blueprint $table){
+            $table->string('common01')->delete();
+            $table->string('common02')->delete();
+        });
+    }
+}

+ 42 - 0
database/migrations/2020_06_12_135840_create_custom_fields_table.php

@@ -0,0 +1,42 @@
+<?php
+
+use App\Authority;
+use App\CustomField;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateCustomFieldsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('custom_fields', function (Blueprint $table) {
+            $table->id();
+            $table->string('table')->index()->comment('定义目标的表');
+            $table->string('field')->index()->comment('定义目标表的字段');
+            $table->string('present_name')->index()->comment('所呈现的字段名');
+            $table->string('authority_id')->comment('对应的权限');
+            $table->string('condition_field')->nullable()->comment('条件字段,用来作为定义该字段权限和显示名的依据');
+            $table->string('condition_value')->nullable()->comment('条件字段值,用来作为定义该字段权限和显示名的依据');
+            $table->timestamps();
+        });
+        CustomField::create(['table'=>'rejected_bills','field'=>'common_01','present_name'=>'寄件方省','authority_name'=>'退货管理-查询-客户定义-爱奇艺','condition_field'=>'id_owner','condition_value'=>'66']);
+        CustomField::create(['table'=>'rejected_bills','field'=>'common_02','present_name'=>'退件重量','authority_name'=>'退货管理-查询-客户定义-爱奇艺','condition_field'=>'id_owner','condition_value'=>'66']);
+        if(!Authority::where('name','退货管理-查询-客户定义-爱奇艺')->first())(new Authority(['name'=>'退货管理-查询-客户定义-爱奇艺','alias_name'=>'退货管理-查询-客户定义-爱奇艺']))->save();
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('custom_fields');
+    }
+}

+ 16 - 0
database/seeds/CustomFieldSeeder.php

@@ -0,0 +1,16 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class CustomFieldSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        //
+    }
+}

+ 1 - 1
package-lock.json

@@ -8782,7 +8782,7 @@
         },
         "socket.io-client": {
             "version": "2.3.0",
-            "resolved": "https://registry.npm.taobao.org/socket.io-client/download/socket.io-client-2.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsocket.io-client%2Fdownload%2Fsocket.io-client-2.3.0.tgz",
+            "resolved": "https://registry.npm.taobao.org/socket.io-client/download/socket.io-client-2.3.0.tgz",
             "integrity": "sha1-FNW6LgC5vNFFrkQ6uWs/hsvMG7Q=",
             "requires": {
                 "backo2": "1.0.2",

+ 50 - 0
resources/views/rejected/customField/create.blade.php

@@ -0,0 +1,50 @@
+@extends('layouts.app')
+@section('title')创建自定义字段@endsection
+
+@section('content')
+    <div id="nav2">
+        @component('rejected.menu')@endcomponent
+        @component('rejected.customField.menu')@endcomponent
+    </div>
+    <div class="container-fluid">
+        <div class="card col-md-8 offset-md-2">
+            <div class="card-body">
+                @if(Session::has('successTip'))
+                    <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
+                @endif
+                <form method="POST" action="{{ url('rejected/customField') }}">
+                    @csrf
+                    <div class="form-group row">
+                        <label for="name" class="col-2 col-form-label text-right">自定义字段名称</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control @error('name') is-invalid @enderror"
+                                   name="name" autocomplete="off" value="{{ old('name') }}" required>
+                            @error('name')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="code" class="col-2 col-form-label text-right">自定义字段代码</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control @error('code') is-invalid @enderror"
+                                   name="code" autocomplete="off" value="{{ old('code') }}" required>
+                            @error('code')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <div class="col-8 offset-2">
+                            <input type="submit" class="btn btn-success form-control">
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+@endsection

+ 56 - 0
resources/views/rejected/customField/edit.blade.php

@@ -0,0 +1,56 @@
+@extends('layouts.app')
+@section('title')编辑自定义字段@endsection
+
+@section('content')
+    <div id="nav2">
+        @component('rejected.menu')
+        @endcomponent
+        @component('rejected.customField.menu')
+                <li class="nav-item">
+                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
+                </li>
+        @endcomponent
+    </div>
+    <div class="container-fluid">
+        <div class="card">
+            <div class="card-body">
+                @if(Session::has('successTip'))
+                    <div class="alert alert-success h1">{{Session::get('successTip')}}!</div>
+                @endif
+                <form method="POST" action='{{url("rejected/customField/{$customField->id}")}}'>
+                    @csrf
+                    @method('PUT')
+                    <div class="form-group row">
+                        <label for="name" class="col-2 col-form-label text-right">自定义字段名称</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control @error('name') is-invalid @enderror"
+                                   name="name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$customField->name}}@endif" required>
+                            @error('name')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <label for="code" class="col-2 col-form-label text-right">自定义字段代码</label>
+                        <div class="col-8">
+                            <input type="text" class="form-control @error('code') is-invalid @enderror"
+                                   name="code" autocomplete="off" value="@if(old('code')){{old('code')}}@else{{$customField->code}}@endif" required>
+                            @error('code')
+                            <span class="invalid-feedback" role="alert">
+                                <strong>{{ $message }}</strong>
+                            </span>
+                            @enderror
+                        </div>
+                    </div>
+                    <div class="form-group row">
+                        <div class="col-8 offset-2">
+                            <input type="submit" class="btn btn-outline-dark form-control">
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+@endsection

+ 62 - 0
resources/views/rejected/customField/index.blade.php

@@ -0,0 +1,62 @@
+@extends('layouts.app')
+@section('title')自定义字段@endsection
+
+@section('content')
+    <span id="nav2">
+        @component('rejected.menu')@endcomponent
+        @component('rejected.customField.menu')@endcomponent
+    </span>
+    <div class="container-fluid">
+        <div class="card">
+            <div class="card-body">
+                @if(Session::has('successTip'))
+                    <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
+                @endif
+                <table class="table table-striped table-sm" id="list">
+                    <tr>
+                        <th>ID</th>
+                        <th>目标字段</th>
+                        <th>字段显示名</th>
+                        <th>对应权限</th>
+                        <th>货主</th>
+                        <th>创建时间</th>
+                        <th>操作</th>
+                    </tr>
+                    <tr v-for="customField in customFields">
+                        <td class="text-muted">@{{customField.id}}</td>
+                        <td class="text-muted">@{{customField.field}}</td>
+                        <td>@{{customField.present_name}}</td>
+                        <td>@{{customField.authority_name}}</td>
+                        <td>@{{customField.owner_name}}</td>
+                        <td class="text-muted">@{{customField.created_at}}</td>
+                        <td>
+                            @can('自定义字段-编辑')
+                            <button class="btn btn-sm btn-outline-primary" @click="edit(customField.id)">改</button> @endcan
+                        </td>
+                    </tr>
+                </table>
+                {{$customFields->links()}}
+            </div>
+        </div>
+    </div>
+@endsection
+
+@section('lastScript')
+    <script>
+        new Vue({
+            el:"#list",
+            data:{
+                customFields:[
+                    @foreach( $customFields as $customField )
+                    {id:'{{$customField->id}}',name:'{{$customField->name}}',code:'{{$customField->code}}',created_at:'{{$customField->created_at}}'},
+                    @endforeach
+                ],
+            },
+            methods:{
+                edit:function(id){
+                    location.href = "{{url('rejected/customField')}}/"+id+"/edit";
+                },
+            }
+        });
+    </script>
+@endsection

+ 4 - 0
resources/views/rejected/menuRelating.blade.php

@@ -13,6 +13,10 @@
                 <li class="nav-item">
                     <a class="nav-link text-dark" href="{{url('maintenance/qualityLabel')}}" :class="{active:isActive('qualityLabel',2)}">品质标签</a>
                 </li> @endcan
+            @can('品质标签')
+                <li class="nav-item">
+                    <a class="nav-link text-dark" href="{{url('maintenance/qualityLabel')}}" :class="{active:isActive('qualityLabel',2)}">品质标签</a>
+                </li> @endcan
         </ul>
     </div>
 </div>