Zhouzhendong преди 5 години
родител
ревизия
bd6d745fa7

+ 4 - 1
app/Http/Controllers/LogisticController.php

@@ -119,7 +119,10 @@ class LogisticController extends Controller
 
     public function get()
     {
-        $logistics = app("LogisticService")->getSelection();
+        $type = \request("type");
+        $column = ['id','name'];
+        if (!$type)$column[] = "type";
+        $logistics = app("LogisticService")->getSelection($column,$type);
         return ["success"=>true,"data"=>$logistics];
     }
 }

+ 1 - 1
app/Services/LogisticService.php

@@ -19,7 +19,7 @@ Class LogisticService
         $this->cacheService=app('CacheService');
     }
     public function getSelection($column = ['id','name'], $type = '快递'){
-        return $this->cacheService->getOrExecute('LogisticAll_idName'.Str::studly($type),function()use($column,$type){
+        return $this->cacheService->getOrExecute('LogisticAll_'.implode("",$column).Str::studly($type),function()use($column,$type){
             $query = Logistic::query()->select($column);
             if ($type)$query->where(function ($query)use($type){
                 /** @var Builder $query */

+ 39 - 6
resources/views/customer/project/create.blade.php

@@ -176,6 +176,7 @@
                         items:[],
                         other_ranges:[],
                         ranges:[],
+                        logistics:[],
                     },
                 },
                 pool:{//基础数据选择池,以方便异步懒加载而非即时加载 例:units,owners等
@@ -198,7 +199,7 @@
                     storage:[],
                     operation:[],
                     express:[],
-                    logistic:{},
+                    logistic:[],
                 },
                 thisOperationItemIndex:-1,//当前选中的作业费子项下标,用以唤起特征模态框
                 operationItems:{},//控制作业费子项的渐入展开
@@ -325,7 +326,9 @@
                     if (!this.pool.provinces)this._getProvinces();
                     if (!this.pool.logistics){
                         this._getLogistics();
-
+                        setTimeout(()=>{
+                            $(".selectpicker").selectpicker('refresh');
+                        },500);
                     }
                 },
                 //加载物流
@@ -333,6 +336,12 @@
                     if (!this.pool.units) this._getUnits();
                     if (!this.pool.provinces)this._getProvinces();
                     if (!this.pool.cities)this._getCities();
+                    if (!this.pool.logistics){
+                        this._getLogistics();
+                        setTimeout(()=>{
+                            $(".selectpicker").selectpicker('refresh');
+                        },500);
+                    }
                 },
                 //获取单位
                 _getUnits(){
@@ -376,16 +385,13 @@
                 //获取承运商
                 _getLogistics(){
                     let url = "{{url('maintenance/logistic/get')}}";
-                    window.tempTip.postBasicRequest(url,{},res=>{
+                    window.tempTip.postBasicRequest(url,{type:''},res=>{
                         this.pool.logistics = res;
                         let mapping = [];
                         res.forEach(logistic=>{
                             mapping[logistic.id] = logistic.name;
                         });
                         this.poolMapping.logistics = mapping;
-                        setTimeout(()=>{
-                            $(".selectpicker").selectpicker('render');
-                        },500);
                         this.$forceUpdate();
                     });
                 },
@@ -401,6 +407,9 @@
                         case "express":
                             this._verifyExpress();
                             break;
+                        case "logistic":
+                            this._verifyLogistic();
+                            break;
                     }
                 },
                 _verifyStorage(){
@@ -509,12 +518,36 @@
                     this.selectedModel.express.unshift(this.model.express);
                     this.model.express = {
                         name:"",
+                        logistics:[],
                         initial_weight:"",
                         additional_weight:"",
                         items:[],
                     };
                     this.errors = [];
                     this.importError = [];
+                    $(".selectpicker").filter('.express').selectpicker('val',[]);
+                },
+                _verifyLogistic(){
+                    let error = {};
+                    if (!this.model.logistic.name) error.name = ["名称不得为空"];
+                    if (!this.model.logistic.unit_id) error.unit_id = ["单位一不得为空"];
+                    if (!this.model.logistic.unit_range) error.unit_range = ["区间值不得为空"];
+                    if (!this.model.logistic.other_unit_id) error.other_unit_id = ["单位二不得为空"];
+                    if (!this.model.logistic.other_unit_range) error.other_unit_range = ["区间值不得为空"];
+                    if (JSON.stringify(error) !== "{}"){
+                        this.errors = error;
+                        this.$forceUpdate();
+                        return;
+                    }
+                    this.selectedModel.logistic.unshift(this.model.logistic);
+                    this.model.logistic = {
+                            items:[],
+                            other_ranges:[],
+                            ranges:[],
+                    };
+                    this.errors = [];
+                    this.importError = [];
+                    $(".selectpicker").filter('.logistic').selectpicker('val',[]);
                 },
                 //增加作业费特征子项
                 addOperationItem(){

+ 2 - 2
resources/views/customer/project/part/_express.blade.php

@@ -5,9 +5,9 @@
 </div>
 <div class="row mt-3">
     <label class="col-3">承运商</label>
-    <label class="col-5"><select class="selectpicker" multiple data-live-search="true" title="承运商(多选)"
+    <label class="col-5"><select class="selectpicker express" multiple data-live-search="true" title="承运商(多选)"
             v-model="model.express.logistics" :class="errors.logistics ? 'is-invalid' : ''">
-        <option v-for="logistic in pool.logistics" :value="logistic.id">@{{ logistic.name }}</option>
+        <option v-for="logistic in pool.logistics" :value="logistic.id" v-if="logistic.type != '物流'">@{{ logistic.name }}</option>
     </select></label>
 </div>
 <div class="row mt-3">

+ 17 - 14
resources/views/customer/project/part/_logistic.blade.php

@@ -6,6 +6,13 @@
         <strong>@{{ errors.name[0] }}</strong>
     </span>
 </div>
+<div class="row mt-3">
+    <label class="col-2" for="logistic_id">承运商</label>
+    <select id="logistic_id" class="selectpicker logistic" multiple data-live-search="true" title="承运商(多选)"
+            v-model="model.logistic.logistics" :class="errors.logistics ? 'is-invalid' : ''">
+        <option v-for="logistic in pool.logistics" :value="logistic.id" v-if="logistic.type != '快递'">@{{ logistic.name }}</option>
+    </select>
+</div>
 <div class="row mt-3">
     <label for="logistic_pick_up_price" class="col-2">提货费</label>
     <input id="logistic_pick_up_price" type="number" min="0" step="0.01" class="col-3 form-control"
@@ -30,37 +37,33 @@
         <strong>@{{ errors.service_price[0] }}</strong>
     </span>
 </div>
-<div class="row mt-3">
+<div class="row mt-3 mb-0">
     <label for="logistic_unit_id" class="col-2"><b class="text-danger">* </b>单位一</label>
     <select id="logistic_unit_id" class="col-2 form-control"
             v-model="model.logistic.unit_id" :class="errors.unit_id ? 'is-invalid' : ''">
         <option v-for="unit in pool.units" :value="unit.id">@{{ unit.name }}</option>
     </select>
-    <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.unit_id">
-        <strong>@{{ errors.unit_id[0] }}</strong>
-    </span>
     <label for="logistic_unit_range" class="col-2 text-right"><b class="text-danger">*</b>区间值</label>
     <input id="logistic_unit_range" type="text" placeholder="文字描述区间逗号(,)间隔,示例:0-5,10-30,30-"
            v-model="model.logistic.unit_range" class="col-3 form-control" :class="errors.unit_range ? 'is-invalid' : ''" @change="changeRange('ranges')">
-    <span class="invalid-feedback mt-0 offset-6" role="alert" v-if="errors.unit_range">
-        <strong>@{{ errors.unit_range[0] }}</strong>
-    </span>
 </div>
-<div class="row mt-3">
+<div class="row mt-0">
+    <label class="offset-2 mt-0 col-3 small text-danger" v-if="errors.unit_id">@{{ errors.unit_id[0] }}</label>
+    <label class="offset-1 mt-0 col-5 small text-danger" v-if="errors.unit_range">@{{ errors.unit_range[0] }}</label>
+</div>
+<div class="row mt-3 mb-0">
     <label for="logistic_other_unit_id" class="col-2"><b class="text-danger">* </b>单位二</label>
     <select id="logistic_other_unit_id" class="col-2 form-control"
             v-model="model.logistic.other_unit_id" :class="errors.other_unit_id ? 'is-invalid' : ''">
         <option v-for="unit in pool.units" :value="unit.id">@{{ unit.name }}</option>
     </select>
-    <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.other_unit_id">
-        <strong>@{{ errors.other_unit_id[0] }}</strong>
-    </span>
     <label for="logistic_other_unit_range" class="col-2 text-right"><b class="text-danger">*</b>区间值</label>
     <input id="logistic_other_unit_range" type="text" placeholder="文字描述区间逗号(,)间隔,示例:0-5,10-30,30-"
            v-model="model.logistic.other_unit_range" class="col-3 form-control" :class="errors.other_unit_range ? 'is-invalid' : ''" @change="changeRange('other_ranges')">
-    <span class="invalid-feedback mt-0 offset-6" role="alert" v-if="errors.other_unit_range">
-        <strong>@{{ errors.other_unit_range[0] }}</strong>
-    </span>
+</div>
+<div class="row mt-0">
+    <label class="offset-2 mt-0 col-3 small text-danger" v-if="errors.other_unit_id">@{{ errors.other_unit_id[0] }}</label>
+    <label class="offset-1 mt-0 col-5 small text-danger" v-if="errors.other_unit_range">@{{ errors.other_unit_range[0] }}</label>
 </div>
 <div class="row mt-3">
     <label class="col-2">详情</label>

+ 1 - 1
resources/views/customer/project/part/_operation.blade.php

@@ -125,7 +125,7 @@
             </div>
             <div class="row mt-2">
                 <label class="col-3">数量</label>
-                <label class="col-5 mb-0"><input type="number" step="1" :class="errors['items.'+i+'.amount'] ? 'is-invalid' : ''" v-model="item.amount" class="form-control"></label>
+                <label class="col-5 mb-0"><input type="number" step="1" min="0" :class="errors['items.'+i+'.amount'] ? 'is-invalid' : ''" v-model="item.amount" class="form-control"></label>
             </div>
             <div class="row mt-0" v-if="errors['items.'+i+'.amount']">
                 <div class="offset-3"><small class="text-danger font-weight-bold ml-3">@{{ errors['items.'+i+'.amount'][0] }}</small></div>

+ 66 - 43
resources/views/customer/project/part/_three.blade.php

@@ -104,22 +104,20 @@
                     <tbody v-for="(express,i) in selectedModel.express">
                         <tr>
                             <td>
-                                <div class="text-overflow-warp-100">
-                                    <label v-for="(logistic,j) in express.logistics">
-                                        @{{ poolMapping.provinces[logistic] }}<label v-if="express.logistics && j<(express.logistics.length-1)">,</label>
-                                    </label>
+                                <div class="text-overflow-warp-100 small">
+                                    <label v-for="(logistic,j) in express.logistics" class="m-0">@{{ poolMapping.logistics[logistic] }}</label>
                                 </div>
                             </td>
                             <td>@{{ express.name }}</td>
                             <td>@{{ express.initial_weight }}</td>
                             <td>@{{ express.additional_weight }}</td>
-                            <td @click="show('express-item-'+i)">
+                            <td @click="show('express-item-'+i)" class="cursor-pointer">
                                 <span class="fa" :class="upList['express-item-'+i] ? 'fa-angle-double-right' : 'fa-angle-double-down'"></span>
                                 &nbsp;@{{ express.items.length }} 省份</td>
                         </tr>
                         <tr>
                             <td colspan="5">
-                                <div :id="'express-item-'+i">
+                                <div :id="'express-item-'+i" class="offset-3">
                                     <table class="table table-sm col-10">
                                         <tr>
                                             <th>省份</th>
@@ -137,26 +135,6 @@
                         </tr>
                     </tbody>
                 </table>
-               {{-- <div class="row">
-                    <label class="col-4">名称:<b>@{{ selectedModel.express.name }}</b></label>
-                    <label class="col-4">首重值(KG):<b>@{{ selectedModel.express.initial_weight }}</b></label>
-                    <label class="col-4">续重值(KG):<b>@{{ selectedModel.express.additional_weight }}</b></label>
-                </div>--}}
-                {{--<div class="row">
-                    <label class="text-primary col-2">详情</label>
-                    <table class="table table-sm col-10">
-                        <tr>
-                            <th>省份</th>
-                            <th>首重价格</th>
-                            <th>续重价格</th>
-                        </tr>
-                        <tr v-for="(item,i) in selectedModel.express.items">
-                            <td>@{{ poolMapping.provinces[item.province_id] }}</td>
-                            <td>@{{ item.initial_weight_price }}</td>
-                            <td>@{{ item.additional_weight_price }}</td>
-                        </tr>
-                    </table>
-                </div>--}}
             </div>
         </div>
         <div class="card" id="logistic-card">
@@ -164,26 +142,71 @@
                 <span class="pull-left font-weight-bold cursor-pointer" @click="show('logistic')"><span class="fa fa-truck"></span>&nbsp;物流</span>
             </div>
             <div class="card-body" id="logistic">
-                <div class="row">
-                    <label class="col-4">名称:<b>@{{ selectedModel.express.name }}</b></label>
-                    <label class="col-4">首重值(KG):<b>@{{ selectedModel.express.initial_weight }}</b></label>
-                    <label class="col-4">续重值(KG):<b>@{{ selectedModel.express.additional_weight }}</b></label>
-                </div>
-                <div class="row">
-                    <label class="text-primary col-2">详情</label>
-                    <table class="table table-sm col-10">
+                <table class="table table-sm">
+                    <tr>
+                        <th>承运商</th>
+                        <th>名称</th>
+                        <th>单位一</th>
+                        <th>一区间值</th>
+                        <th>单位二</th>
+                        <th>二区间值</th>
+                        <th>提货费</th>
+                        <th>燃油附加费</th>
+                        <th>信息服务费</th>
+                        <th>详情</th>
+                    </tr>
+                    <tbody v-for="(logistic,i) in selectedModel.logistic">
                         <tr>
-                            <th>省份</th>
-                            <th>首重价格</th>
-                            <th>续重价格</th>
+                            <td>
+                                <div class="text-overflow-warp-100 small">
+                                    <label v-for="(logistic,j) in logistic.logistics" class="m-0">@{{ poolMapping.logistics[logistic] }}</label>
+                                </div>
+                            </td>
+                            <td>@{{ logistic.name }}</td>
+                            <td>@{{ poolMapping.units[logistic.unit_id] }}</td>
+                            <td>@{{ logistic.unit_range }}</td>
+                            <td>@{{ poolMapping.units[logistic.other_unit_id] }}</td>
+                            <td>@{{ logistic.other_unit_range }}</td>
+                            <td>@{{ logistic.pick_up_price }}</td>
+                            <td>@{{ logistic.fuel_price }}</td>
+                            <td>@{{ logistic.service_price }}</td>
+                            <td @click="show('logistic-item-'+i)" class="cursor-pointer">
+                                <span class="fa" :class="upList['logistic-item-'+i] ? 'fa-angle-double-right' : 'fa-angle-double-down'"></span>
+                                &nbsp;@{{ logistic.items.length }} 地区
+                            </td>
                         </tr>
-                        <tr v-for="(item,i) in selectedModel.express.items">
-                            <td>@{{ poolMapping.provinces[item.province_id] }}</td>
-                            <td>@{{ item.initial_weight_price }}</td>
-                            <td>@{{ item.additional_weight_price }}</td>
+                        <tr>
+                            <td colspan="9">
+                                <div :id="'logistic-item-'+i" class="offset-1">
+                                    <table class="table table-sm">
+                                        <tr>
+                                            <th>省份</th>
+                                            <th>市区</th>
+                                            <th>单位</th>
+                                            <th>区间</th>
+                                            <th>单价</th>
+                                            <th>送货费</th>
+                                            <th>起始计费</th>
+                                            <th>起始计数</th>
+                                            <th>费率(%)</th>
+                                        </tr>
+                                        <tr v-for="item in logistic.items">
+                                            <td class="font-weight-bold">@{{ poolMapping.provinces[item.province_id] }}</td>
+                                            <td class="font-weight-bold">@{{ poolMapping.cities[item.city_id] }}</td>
+                                            <td>@{{ poolMapping.units[item.unit_id] }}</td>
+                                            <td>@{{ item.range }}</td>
+                                            <td>@{{ item.unit_price }}</td>
+                                            <td>@{{ item.delivery_fee }}</td>
+                                            <td>@{{ item.initial_fee }}</td>
+                                            <td>@{{ item.initial_amount }}</td>
+                                            <td>@{{ item.rate }}<span v-if="item.rate" class="font-weight-bold">&nbsp;%</span></td>
+                                        </tr>
+                                    </table>
+                                </div>
+                            </td>
                         </tr>
-                    </table>
-                </div>
+                    </tbody>
+                </table>
             </div>
         </div>
         <div class="card" id="directLogistic-card">