添加:物流管理 - 添加前台默认展示国家
This commit is contained in:
parent
4032cfaaa1
commit
3c96766442
|
|
@ -15,6 +15,7 @@ use Beike\Repositories\CategoryRepo;
|
||||||
use Beike\Repositories\CountryRepo;
|
use Beike\Repositories\CountryRepo;
|
||||||
use Beike\Repositories\LanguageRepo;
|
use Beike\Repositories\LanguageRepo;
|
||||||
use Beike\Repositories\LogisticsRepo;
|
use Beike\Repositories\LogisticsRepo;
|
||||||
|
use Beike\Repositories\SettingRepo;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class LogisticsController extends Controller
|
class LogisticsController extends Controller
|
||||||
|
|
@ -31,10 +32,14 @@ class LogisticsController extends Controller
|
||||||
$logistics = LogisticsResource::collection($logisticsList);
|
$logistics = LogisticsResource::collection($logisticsList);
|
||||||
$logisticsFormat = $logistics->jsonSerialize();
|
$logisticsFormat = $logistics->jsonSerialize();
|
||||||
|
|
||||||
|
|
||||||
|
$countries = LogisticsRepo::getDefaultCountries();
|
||||||
$data = [
|
$data = [
|
||||||
'logistics_format' => $logisticsFormat,
|
'logistics_format' => $logisticsFormat,
|
||||||
'logistics' => $logistics,
|
'logistics' => $logistics,
|
||||||
'type' => 'logistics',
|
'type' => 'logistics',
|
||||||
|
'default_countries' => $countries,
|
||||||
|
'default_countries_name' => is_array($countries) ? array_values($countries)[0]['name'] : ''
|
||||||
];
|
];
|
||||||
|
|
||||||
$data = hook_filter('admin.logistics.index.data', $data);
|
$data = hook_filter('admin.logistics.index.data', $data);
|
||||||
|
|
@ -166,7 +171,6 @@ 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);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'logistics' => $logistics,
|
'logistics' => $logistics,
|
||||||
'types' => $types,
|
'types' => $types,
|
||||||
|
|
@ -227,4 +231,22 @@ class LogisticsController extends Controller
|
||||||
{
|
{
|
||||||
LogisticsRepo::forceDeleteTrashed();
|
LogisticsRepo::forceDeleteTrashed();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Common: 设置默认物流国家
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/08/25 13:48
|
||||||
|
* @return array
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function defaultCountries(){
|
||||||
|
$country = request()->post('country');
|
||||||
|
SettingRepo::storeValue('default_country', $country,'logistics','plugin');
|
||||||
|
|
||||||
|
return json_success(trans('common.updated_success'), []);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,7 @@ Route::prefix($adminName)
|
||||||
Route::middleware('can:logistics_show')->get('logistics/{logistics}/edit', [Controllers\LogisticsController::class, 'edit'])->name('logistics.edit');
|
Route::middleware('can:logistics_show')->get('logistics/{logistics}/edit', [Controllers\LogisticsController::class, 'edit'])->name('logistics.edit');
|
||||||
Route::middleware('can:logistics_update')->put('logistics/{logistics}', [Controllers\LogisticsController::class, 'update'])->name('logistics.update');
|
Route::middleware('can:logistics_update')->put('logistics/{logistics}', [Controllers\LogisticsController::class, 'update'])->name('logistics.update');
|
||||||
Route::middleware('can:logistics_delete')->delete('logistics/{logistics}', [Controllers\LogisticsController::class, 'destroy'])->name('logistics.destroy');
|
Route::middleware('can:logistics_delete')->delete('logistics/{logistics}', [Controllers\LogisticsController::class, 'destroy'])->name('logistics.destroy');
|
||||||
|
Route::middleware('can:logistics_default_countries')->post('logistics/default_countries', [Controllers\LogisticsController::class, 'defaultCountries'])->name('logistics.default_countries');
|
||||||
|
|
||||||
// 区域组
|
// 区域组
|
||||||
Route::middleware('can:regions_index')->get('regions', [Controllers\RegionController::class, 'index'])->name('regions.index');
|
Route::middleware('can:regions_index')->get('regions', [Controllers\RegionController::class, 'index'])->name('regions.index');
|
||||||
|
|
|
||||||
|
|
@ -373,4 +373,18 @@ class LogisticsRepo
|
||||||
|
|
||||||
$products->forceDelete();
|
$products->forceDelete();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Common: 获取默认国家
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/08/25 13:50
|
||||||
|
* @param false $isGetInfo
|
||||||
|
* @return array|mixed
|
||||||
|
*/
|
||||||
|
public static function getDefaultCountries($isGetInfo = false){
|
||||||
|
$set = plugin_setting('logistics.default_country');
|
||||||
|
if($set && !$isGetInfo) $set = array_column([$set],null,'id');
|
||||||
|
|
||||||
|
return $set ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,21 @@
|
||||||
.fcm-content .fcm-footer .title{
|
.fcm-content .fcm-footer .title{
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
.default-countries{
|
||||||
|
margin-left: 30px!important;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: flex-start;
|
||||||
|
font-size: 15px;
|
||||||
|
-webkit-user-select: none; /* Safari */
|
||||||
|
-moz-user-select: none; /* Firefox */
|
||||||
|
-ms-user-select: none; /* IE 10+ */
|
||||||
|
user-select: none; /* 标准语法 */
|
||||||
|
}
|
||||||
|
.countries-select-btn{
|
||||||
|
color: #409eff;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@if ($errors->has('error'))
|
@if ($errors->has('error'))
|
||||||
<x-admin-alert type="danger" msg="{{ $errors->first('error') }}" class="mt-4" />
|
<x-admin-alert type="danger" msg="{{ $errors->first('error') }}" class="mt-4" />
|
||||||
|
|
@ -54,11 +69,17 @@
|
||||||
<div class="card h-min-600">
|
<div class="card h-min-600">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
<div class="d-flex justify-content-between my-4">
|
<div class="d-flex my-4">
|
||||||
@if ($type != 'trashed')
|
@if ($type != 'trashed')
|
||||||
<a href="{{ admin_route('logistics.create') }}" class="me-1 nowrap">
|
<a href="{{ admin_route('logistics.create') }}" class="me-1 nowrap">
|
||||||
<button class="btn btn-primary">{{ __('admin/logistics.logistics_create') }}</button>
|
<button class="btn btn-primary">{{ __('admin/logistics.logistics_create') }}</button>
|
||||||
</a>
|
</a>
|
||||||
|
<div class="default-countries">
|
||||||
|
{{ __('admin/logistics.default_countries') }}:
|
||||||
|
<span class="countries-select-btn" @click="$refs['select-countries'].showSelectCountries()">
|
||||||
|
@{{ showCurrentCountry() }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
@else
|
@else
|
||||||
@if ($logistics->total())
|
@if ($logistics->total())
|
||||||
<button class="btn btn-primary" @click="clearRestore">{{ __('admin/logistics.clear_restore') }}</button>
|
<button class="btn btn-primary" @click="clearRestore">{{ __('admin/logistics.clear_restore') }}</button>
|
||||||
|
|
@ -161,12 +182,15 @@
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<select-countries ref="select-countries" :country_list="country_list" @change-info="changeCountry" :is_single="true"></select-countries>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@hook('admin.product.list.content.footer')
|
@hook('admin.product.list.content.footer')
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('footer')
|
@push('footer')
|
||||||
|
@include('shared.select-countries')
|
||||||
<script>
|
<script>
|
||||||
let app = new Vue({
|
let app = new Vue({
|
||||||
el: '#product-app',
|
el: '#product-app',
|
||||||
|
|
@ -183,8 +207,9 @@
|
||||||
},
|
},
|
||||||
selectedIds: [],
|
selectedIds: [],
|
||||||
productIds: @json($logistics->pluck('id')),
|
productIds: @json($logistics->pluck('id')),
|
||||||
|
country_list: @json($default_countries ?? []),
|
||||||
|
default_countries_name: "{{ $default_countries_name ?? ''}}",
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
allSelected: {
|
allSelected: {
|
||||||
get(e) {
|
get(e) {
|
||||||
|
|
@ -195,11 +220,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
bk.addFilterCondition(this);
|
bk.addFilterCondition(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
turnOnOff() {
|
turnOnOff() {
|
||||||
let id = event.currentTarget.getAttribute("data-id");
|
let id = event.currentTarget.getAttribute("data-id");
|
||||||
|
|
@ -211,7 +234,6 @@
|
||||||
location.reload();
|
location.reload();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
batchDelete() {
|
batchDelete() {
|
||||||
this.$confirm('{{ __('admin/product.confirm_batch_product') }}', '{{ __('common.text_hint') }}', {
|
this.$confirm('{{ __('admin/product.confirm_batch_product') }}', '{{ __('common.text_hint') }}', {
|
||||||
confirmButtonText: '{{ __('common.confirm') }}',
|
confirmButtonText: '{{ __('common.confirm') }}',
|
||||||
|
|
@ -224,7 +246,6 @@
|
||||||
})
|
})
|
||||||
}).catch(()=>{});
|
}).catch(()=>{});
|
||||||
},
|
},
|
||||||
|
|
||||||
batchActive(type) {
|
batchActive(type) {
|
||||||
this.$confirm('{{ __('admin/product.confirm_batch_status') }}', '{{ __('common.text_hint') }}', {
|
this.$confirm('{{ __('admin/product.confirm_batch_status') }}', '{{ __('common.text_hint') }}', {
|
||||||
confirmButtonText: '{{ __('common.confirm') }}',
|
confirmButtonText: '{{ __('common.confirm') }}',
|
||||||
|
|
@ -237,22 +258,18 @@
|
||||||
})
|
})
|
||||||
}).catch(()=>{});
|
}).catch(()=>{});
|
||||||
},
|
},
|
||||||
|
|
||||||
search() {
|
search() {
|
||||||
this.filter.page = '';
|
this.filter.page = '';
|
||||||
location = bk.objectToUrlParams(this.filter, this.url)
|
location = bk.objectToUrlParams(this.filter, this.url)
|
||||||
},
|
},
|
||||||
|
|
||||||
checkedOrderBy(orderBy) {
|
checkedOrderBy(orderBy) {
|
||||||
this.filter.order_by = orderBy;
|
this.filter.order_by = orderBy;
|
||||||
location = bk.objectToUrlParams(this.filter, this.url)
|
location = bk.objectToUrlParams(this.filter, this.url)
|
||||||
},
|
},
|
||||||
|
|
||||||
resetSearch() {
|
resetSearch() {
|
||||||
this.filter = bk.clearObjectValue(this.filter)
|
this.filter = bk.clearObjectValue(this.filter)
|
||||||
location = bk.objectToUrlParams(this.filter, this.url)
|
location = bk.objectToUrlParams(this.filter, this.url)
|
||||||
},
|
},
|
||||||
|
|
||||||
copyProduct(index) {
|
copyProduct(index) {
|
||||||
const id = this.productIds[index];
|
const id = this.productIds[index];
|
||||||
|
|
||||||
|
|
@ -277,7 +294,6 @@
|
||||||
})
|
})
|
||||||
}).catch(()=>{});
|
}).catch(()=>{});
|
||||||
},
|
},
|
||||||
|
|
||||||
restoreProduct(index) {
|
restoreProduct(index) {
|
||||||
const id = this.productIds[index];
|
const id = this.productIds[index];
|
||||||
|
|
||||||
|
|
@ -289,7 +305,6 @@
|
||||||
})
|
})
|
||||||
}).catch(()=>{});;
|
}).catch(()=>{});;
|
||||||
},
|
},
|
||||||
|
|
||||||
clearRestore() {
|
clearRestore() {
|
||||||
this.$confirm('{{ __('admin/product.confirm_delete_restore') }}', '{{ __('common.text_hint') }}', {
|
this.$confirm('{{ __('admin/product.confirm_delete_restore') }}', '{{ __('common.text_hint') }}', {
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
|
|
@ -298,7 +313,25 @@
|
||||||
location.reload();
|
location.reload();
|
||||||
})
|
})
|
||||||
}).catch(()=>{});;
|
}).catch(()=>{});;
|
||||||
|
},
|
||||||
|
// 默认国家信息改变
|
||||||
|
changeCountry(info){
|
||||||
|
let _this = this;
|
||||||
|
_this.country_list = info;
|
||||||
|
let singleInfo = Object.values(info)[0];
|
||||||
|
$http.post('logistics/default_countries',{ country: singleInfo }).then((res) => {
|
||||||
|
_this.default_countries_name = singleInfo.name;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 当前选择国家文字显示
|
||||||
|
showCurrentCountry(){
|
||||||
|
let name = this.default_countries_name;
|
||||||
|
if(!name) name = "{{ __('admin/customer.choose_country') }}";
|
||||||
|
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* order.php
|
* order.php
|
||||||
*
|
|
||||||
* @copyright 2022 beikeshop.com - All Rights Reserved
|
* @copyright 2022 beikeshop.com - All Rights Reserved
|
||||||
* @link https://beikeshop.com
|
* @link https://beikeshop.com
|
||||||
* @author Edward Yang <yangjin@guangda.work>
|
* @author Edward Yang <yangjin@guangda.work>
|
||||||
* @created 2022-08-02 14:22:41
|
* @created 2022-08-02 14:22:41
|
||||||
* @modified 2022-08-02 14:22:41
|
* @modified 2022-08-02 14:22:41
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'logistics_index' => 'Index',
|
'logistics_index' => 'Index',
|
||||||
'logistics_name' => 'Logistics Name',
|
'logistics_name' => 'Logistics Name',
|
||||||
|
|
@ -22,11 +20,9 @@ return [
|
||||||
'clear_restore' => 'Empty Recycle Bin',
|
'clear_restore' => 'Empty Recycle Bin',
|
||||||
'logistics_filter_index' => 'View Filters',
|
'logistics_filter_index' => 'View Filters',
|
||||||
'logistics_filter_update' => 'Modify Filters',
|
'logistics_filter_update' => 'Modify Filters',
|
||||||
|
|
||||||
'batch_delete' => 'Batch Delete',
|
'batch_delete' => 'Batch Delete',
|
||||||
'batch_active' => 'Batch Active',
|
'batch_active' => 'Batch Active',
|
||||||
'batch_inactive' => 'Batch Inactive',
|
'batch_inactive' => 'Batch Inactive',
|
||||||
|
|
||||||
'basic_information' => 'Basic Information',
|
'basic_information' => 'Basic Information',
|
||||||
'product_details' => 'Product details',
|
'product_details' => 'Product details',
|
||||||
'product_relations' => 'Related Logistics',
|
'product_relations' => 'Related Logistics',
|
||||||
|
|
@ -50,33 +46,32 @@ return [
|
||||||
'width' => 'Width',
|
'width' => 'Width',
|
||||||
'height' => 'Height',
|
'height' => 'Height',
|
||||||
'weight_class' => 'weight unit',
|
'weight_class' => 'weight unit',
|
||||||
|
|
||||||
'confirm_batch_product' => 'Are you sure you want to delete the selected logistics in batches? ',
|
'confirm_batch_product' => 'Are you sure you want to delete the selected logistics in batches? ',
|
||||||
'confirm_batch_status' => 'Confirm to modify the status of the selected logistics in batches? ',
|
'confirm_batch_status' => 'Confirm to modify the status of the selected logistics in batches? ',
|
||||||
'confirm_batch_restore' => 'Confirm to restore the selected product? ',
|
'confirm_batch_restore' => 'Confirm to restore the selected product? ',
|
||||||
'confirm_delete_restore' => 'Are you sure you want to empty the recycle bin? ',
|
'confirm_delete_restore' => 'Are you sure you want to empty the recycle bin? ',
|
||||||
'warehouse_name' => 'Warehouse name',
|
'warehouse_name' => 'Warehouse name',
|
||||||
'type'=>'Type',
|
'type' => 'Type',
|
||||||
|
'first_weight' => 'First weight',
|
||||||
'first_weight'=>'First weight',
|
'first_weight_fee' => 'First weight fee',
|
||||||
'first_weight_fee'=>'First weight fee',
|
'continuation_weight_max' => 'Continuation weight max',
|
||||||
'continuation_weight_max'=>'Continuation weight max',
|
'add_weight' => 'Add weight',
|
||||||
'add_weight'=>'Add weight',
|
'continuation_weight_fee' => 'Continuation weight fee',
|
||||||
'continuation_weight_fee'=>'Continuation weight fee',
|
'num_fee' => 'Num fee',
|
||||||
'num_fee'=>'Num fee',
|
'throwing_ratio' => 'Throwing ratio',
|
||||||
'throwing_ratio'=>'Throwing ratio',
|
'day_min' => 'Day min',
|
||||||
'day_min'=>'Day min',
|
'day_max' => 'Day max',
|
||||||
'day_max'=>'Day max',
|
'day' => 'Day',
|
||||||
'day'=>'Day',
|
'work_day' => 'Work day',
|
||||||
'work_day'=>'Work day',
|
'type_weight' => 'Billing by weight',
|
||||||
'type_weight'=>'Billing by weight',
|
'type_num' => 'Quantity based billing',
|
||||||
'type_num'=>'Quantity based billing',
|
'type_free' => 'Merchant package shipping',
|
||||||
'type_free'=>'Merchant package shipping',
|
'first_num' => 'First num',
|
||||||
'first_num'=>'First num',
|
'first_num_fee' => 'First num fee',
|
||||||
'first_num_fee'=>'First num fee',
|
'add_num' => 'Add num',
|
||||||
'add_num'=>'Add num',
|
'continuation_num_fee' => 'Continuation num fee',
|
||||||
'continuation_num_fee'=>'Continuation num fee',
|
'freight_calculation_method' => 'Freight calculation method',
|
||||||
'freight_calculation_method'=>'Freight calculation method',
|
|
||||||
'logistics_duration' => 'Delivery within :day working days after shipment',
|
'logistics_duration' => 'Delivery within :day working days after shipment',
|
||||||
'unit' => 'unit::unit',
|
'unit' => 'unit::unit',
|
||||||
|
'default_countries' => 'Default display country for the front desk',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -78,4 +78,5 @@ return [
|
||||||
'freight_calculation_method' => '运费计算方式',
|
'freight_calculation_method' => '运费计算方式',
|
||||||
'logistics_duration' => '发货后:day个工作日内交货',
|
'logistics_duration' => '发货后:day个工作日内交货',
|
||||||
'unit' => '单位::unit',
|
'unit' => '单位::unit',
|
||||||
|
'default_countries' => '前台默认展示国家',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,10 @@
|
||||||
default: {},
|
default: {},
|
||||||
type: [Object,Array]
|
type: [Object,Array]
|
||||||
},
|
},
|
||||||
|
is_single: {
|
||||||
|
default: false,
|
||||||
|
type: Boolean
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
|
@ -213,7 +217,9 @@
|
||||||
// 点击当前国家
|
// 点击当前国家
|
||||||
clickCountries(item){
|
clickCountries(item){
|
||||||
let _this = this;
|
let _this = this;
|
||||||
let countryIds = Object.assign({}, _this.country_list);
|
// 判断:单选 || 多选
|
||||||
|
let countryIds = {};// 单选
|
||||||
|
if(!_this.is_single) countryIds = Object.assign({}, _this.country_list);// 多选
|
||||||
// 判断:根据是否已经存在进行对应的存在 不存在-添加;存在-删除
|
// 判断:根据是否已经存在进行对应的存在 不存在-添加;存在-删除
|
||||||
if(_this.isSelected(item)) delete countryIds[item.id];// 存在-删除
|
if(_this.isSelected(item)) delete countryIds[item.id];// 存在-删除
|
||||||
else countryIds[item.id] = item;// 不存在 添加
|
else countryIds[item.id] = item;// 不存在 添加
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue