添加:物流添加续重范围填写项
This commit is contained in:
parent
8e34333803
commit
e6882598fe
|
|
@ -11,6 +11,7 @@ use Beike\Admin\View\DesignBuilders\Product;
|
||||||
use Beike\Libraries\Weight;
|
use Beike\Libraries\Weight;
|
||||||
use Beike\Models\Country;
|
use Beike\Models\Country;
|
||||||
use Beike\Models\Logistics;
|
use Beike\Models\Logistics;
|
||||||
|
use Beike\Models\LogisticsWeight;
|
||||||
use Beike\Repositories\CategoryRepo;
|
use Beike\Repositories\CategoryRepo;
|
||||||
use Beike\Repositories\CountryRepo;
|
use Beike\Repositories\CountryRepo;
|
||||||
use Beike\Repositories\LanguageRepo;
|
use Beike\Repositories\LanguageRepo;
|
||||||
|
|
@ -121,7 +122,7 @@ class LogisticsController extends Controller
|
||||||
|
|
||||||
return redirect()->to($this->getRedirect())->with('success', trans('common.updated_success'));
|
return redirect()->to($this->getRedirect())->with('success', trans('common.updated_success'));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return redirect(admin_route('products.edit', $product))->withErrors(['error' => $e->getMessage()]);
|
return redirect(admin_route('logistics.index'))->withErrors(['error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,6 +172,8 @@ class LogisticsController extends Controller
|
||||||
// 获取
|
// 获取
|
||||||
$countryIds = (array)explode(',',$logistics->country_ids);
|
$countryIds = (array)explode(',',$logistics->country_ids);
|
||||||
$logistics->country_ids = CountryRepo::getInList($countryIds);
|
$logistics->country_ids = CountryRepo::getInList($countryIds);
|
||||||
|
$logistics->logistics_weights = LogisticsWeight::getList($logistics->id);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'logistics' => $logistics,
|
'logistics' => $logistics,
|
||||||
'types' => $types,
|
'types' => $types,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Beike\Admin\Services;
|
namespace Beike\Admin\Services;
|
||||||
|
|
||||||
use Beike\Models\Logistics;
|
use Beike\Models\Logistics;
|
||||||
|
use Beike\Models\LogisticsWeight;
|
||||||
use Beike\Models\Product;
|
use Beike\Models\Product;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
|
@ -67,6 +68,23 @@ class LogisticsService
|
||||||
$logistics->save();
|
$logistics->save();
|
||||||
|
|
||||||
if ($isUpdating) {}
|
if ($isUpdating) {}
|
||||||
|
// 续重范围处理
|
||||||
|
$continuationWeightList = (array) ($data['continuation_weight_list'] ? : []);
|
||||||
|
if(count($continuationWeightList)){
|
||||||
|
$logisticsId = $logistics->id;
|
||||||
|
$newWeightList = array_filter(array_map(function($item) use ($logisticsId){
|
||||||
|
if($item['max'] > 0){
|
||||||
|
$item['logistics_id'] = $logisticsId;
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
},$continuationWeightList));
|
||||||
|
// 删除旧数据
|
||||||
|
LogisticsWeight::query()->where('logistics_id',$logisticsId)->delete();
|
||||||
|
// 添加新数据
|
||||||
|
LogisticsWeight::query()->insert($newWeightList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Beike\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class LogisticsWeight extends Base{
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'logistics_id',
|
||||||
|
'min',
|
||||||
|
'max',
|
||||||
|
];
|
||||||
|
/**
|
||||||
|
* Common: 根据物流ID获取全部续重范围
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/08/28 17:36
|
||||||
|
* @param $logisticsId
|
||||||
|
* @return array|mixed[]
|
||||||
|
*/
|
||||||
|
public static function getList($logisticsId){
|
||||||
|
$list = self::query()->where('logistics_id',$logisticsId)->orderBy('id','asc')->get();
|
||||||
|
|
||||||
|
return $list ? $list->toArray() : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -154,15 +154,44 @@
|
||||||
:value="old('add_weight', $logistics->add_weight ?? '')" step="any" required>
|
:value="old('add_weight', $logistics->add_weight ?? '')" step="any" required>
|
||||||
{{ __('admin/logistics.unit',['unit'=>__('product.g')]) }}
|
{{ __('admin/logistics.unit',['unit'=>__('product.g')]) }}
|
||||||
</x-admin-form-input>
|
</x-admin-form-input>
|
||||||
<x-admin-form-input name="continuation_weight_fee" type="number"
|
<x-admin-form-input name="continuation_weight_fee" type="number" :title="__('admin/logistics.continuation_weight_fee')" :value="old('continuation_weight_fee', $logistics->continuation_weight_fee ?? '')" step="any" required>
|
||||||
:title="__('admin/logistics.continuation_weight_fee')"
|
{{ __('admin/logistics.unit',['unit'=>'USD']) }}
|
||||||
:value="old('continuation_weight_fee', $logistics->continuation_weight_fee ?? '')"
|
|
||||||
step="any" required>
|
|
||||||
{{ __('admin/logistics.unit',['unit'=>'USD']) }}
|
|
||||||
</x-admin-form-input>
|
|
||||||
<x-admin-form-input name="throwing_ratio" type="number" :title="__('admin/logistics.throwing_ratio')"
|
|
||||||
:value="old('throwing_ratio', $logistics->throwing_ratio ?? '')" step="any" required>
|
|
||||||
</x-admin-form-input>
|
</x-admin-form-input>
|
||||||
|
{{-- 续重范围 START --------------------------------------------------------}}
|
||||||
|
<x-admin::form.row :title="__('admin/logistics.continuation_weight_max')">
|
||||||
|
{{--续重范围列表--}}
|
||||||
|
<div class="d-flex mb-2 wp-600" v-for="(cwItem,cwIndex) in continuation_weight_list" :key="cwIndex">
|
||||||
|
<input type="number"
|
||||||
|
:name="'continuation_weight_list[' + cwIndex +'][min]'"
|
||||||
|
@input="continuationWeightChange($event,'min',cwIndex)"
|
||||||
|
:value="cwItem['min'] ?? 0"
|
||||||
|
precision="2"
|
||||||
|
step="0.01"
|
||||||
|
class="form-control" style="flex: 0 0 130px" />
|
||||||
|
<div style="width: 40px;line-height: 34px;text-align:center"> - </div>
|
||||||
|
<input type="number"
|
||||||
|
:name="'continuation_weight_list[' + cwIndex +'][max]'"
|
||||||
|
@input="continuationWeightChange($event,'max',cwIndex)"
|
||||||
|
:value="cwItem['max'] ?? 0"
|
||||||
|
precision="2"
|
||||||
|
step="0.01"
|
||||||
|
class="form-control" style="flex: 0 0 130px" />
|
||||||
|
<div style="width: 40px;line-height: 34px;text-align:center"> {{ __('product.g') }} </div>
|
||||||
|
<div style="width: 40px;line-height: 34px;text-align:center">
|
||||||
|
<button type="button" class="btn btn-danger" @click="continuationWeightRemove(cwIndex)" style="margin-left: 10px;">
|
||||||
|
<i class="bi bi-trash-fill"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{--续重范围添加--}}
|
||||||
|
<button type="button" class=" btn btn-primary" @click="continuationWeightAdd">
|
||||||
|
<i class="bi bi-plus"></i>
|
||||||
|
</button>
|
||||||
|
</x-admin::form.row>
|
||||||
|
{{-- 续重范围 END --------------------------------------------------------}}
|
||||||
|
|
||||||
|
|
||||||
|
<x-admin-form-input name="throwing_ratio" type="number" :title="__('admin/logistics.throwing_ratio')" :value="old('throwing_ratio', $logistics->throwing_ratio ?? '')" step="any" required></x-admin-form-input>
|
||||||
{{-- <x-admin-form-input name="continuation_weight_max" type="number" :title="__('admin/logistics.continuation_weight_max')" :value="old('continuation_weight_max', $logistics->continuation_weight_max ?? '')" step="any" required />--}}
|
{{-- <x-admin-form-input name="continuation_weight_max" type="number" :title="__('admin/logistics.continuation_weight_max')" :value="old('continuation_weight_max', $logistics->continuation_weight_max ?? '')" step="any" required />--}}
|
||||||
</span>
|
</span>
|
||||||
<span v-if="form.type === 'num'">
|
<span v-if="form.type === 'num'">
|
||||||
|
|
@ -177,11 +206,11 @@
|
||||||
|
|
||||||
{{-- <x-admin-form-input name="num_fee" type="number" :title="__('admin/logistics.num_fee')" :value="old('num_fee', $logistics->continuation_weight_fee ?? '')" step="any" required />--}}
|
{{-- <x-admin-form-input name="num_fee" type="number" :title="__('admin/logistics.num_fee')" :value="old('num_fee', $logistics->continuation_weight_fee ?? '')" step="any" required />--}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<x-admin::form.row :title="__('admin/logistics.day')">
|
<x-admin::form.row :title="__('admin/logistics.day')">
|
||||||
<div class="d-flex wp-400">
|
<div class="d-flex wp-400">
|
||||||
<input type="number" name="day_min" placeholder="{{ __('admin/logistics.day_min') }}" value="{{ old('day_min', $logistics->day_min ?? '') }}" class="form-control" style="flex: 0 0 95px" /><div style="width: 40px;line-height: 34px;text-align:center"> - </div>
|
<input type="number" name="day_min" placeholder="{{ __('admin/logistics.day_min') }}" value="{{ old('day_min', $logistics->day_min ?? '') }}" class="form-control" style="flex: 0 0 130px" /><div style="width: 40px;line-height: 34px;text-align:center"> - </div>
|
||||||
<input type="number" name="day_max" placeholder="{{ __('admin/logistics.day_max') }}" value="{{ old('day_max', $logistics->day_max ?? '') }}" class="form-control" style="flex: 0 0 95px" /><div style="width: 40px;line-height: 34px;text-align:center">{{ __('admin/logistics.work_day') }}</div>
|
<input type="number" name="day_max" placeholder="{{ __('admin/logistics.day_max') }}" value="{{ old('day_max', $logistics->day_max ?? '') }}" class="form-control" style="flex: 0 0 130px" /><div style="width: 40px;line-height: 34px;text-align:center">{{ __('admin/logistics.work_day') }}</div>
|
||||||
</div>
|
</div>
|
||||||
</x-admin::form.row>
|
</x-admin::form.row>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -272,6 +301,8 @@
|
||||||
rules: {},
|
rules: {},
|
||||||
// 已选择国家列表
|
// 已选择国家列表
|
||||||
country_list: @json($logistics->country_ids ?? []),
|
country_list: @json($logistics->country_ids ?? []),
|
||||||
|
// 续重范围
|
||||||
|
continuation_weight_list: @json($logistics->logistics_weights ?? []),
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
// variant value 重复次数
|
// variant value 重复次数
|
||||||
|
|
@ -688,7 +719,34 @@
|
||||||
// 国家信息改变
|
// 国家信息改变
|
||||||
changeCountry(info){
|
changeCountry(info){
|
||||||
this.country_list = info;
|
this.country_list = info;
|
||||||
|
},
|
||||||
|
// 续重范围 - 添加续重范围信息
|
||||||
|
continuationWeightAdd(){
|
||||||
|
let _this = this;
|
||||||
|
let weightList = Object.assign({}, _this.continuation_weight_list);
|
||||||
|
let length = Object.values(weightList).length || 0;
|
||||||
|
weightList[length] = {
|
||||||
|
min: 0,
|
||||||
|
max: 0
|
||||||
|
};
|
||||||
|
|
||||||
|
_this.continuation_weight_list = Object.values(weightList);
|
||||||
|
},
|
||||||
|
// 续重范围 - 续重范围改变
|
||||||
|
continuationWeightChange(e,field = 'min',cwIndex = 0){
|
||||||
|
let value = e.currentTarget.value || e.target.value;
|
||||||
|
this.continuation_weight_list[cwIndex][field] = value || 0;
|
||||||
|
},
|
||||||
|
// 续重范围 - 删除续重范围
|
||||||
|
continuationWeightRemove(cwIndex){
|
||||||
|
let _this = this;
|
||||||
|
let weightList = Object.assign({}, _this.continuation_weight_list);
|
||||||
|
delete weightList[cwIndex];
|
||||||
|
|
||||||
|
_this.continuation_weight_list = Object.values(weightList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue