添加:物流管理 - 添加前台默认展示国家

This commit is contained in:
wuhui_zzw 2023-08-25 14:16:09 +08:00
parent 4032cfaaa1
commit 3c96766442
7 changed files with 195 additions and 123 deletions

View File

@ -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'), []);
}
} }

View File

@ -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');

View File

@ -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 ?? [];
}
} }

View File

@ -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>

View File

@ -1,82 +1,77 @@
<?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',
'logistics_img' => 'Logistics Image', 'logistics_img' => 'Logistics Image',
'logistics_create' => 'Create', 'logistics_create' => 'Create',
'logistics_show' => 'Detail', 'logistics_show' => 'Detail',
'logistics_update' => 'Edit', 'logistics_update' => 'Edit',
'logistics_delete' => 'Delete', 'logistics_delete' => 'Delete',
'logistics_trashed' => 'Trashed', 'logistics_trashed' => 'Trashed',
'logistics_restore' => 'Restore', 'logistics_restore' => 'Restore',
'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',
'product_details' => 'Product details',
'basic_information' => 'Basic Information', 'product_relations' => 'Related Logistics',
'product_details' => 'Product details', 'stocks' => 'Product inventory',
'product_relations' => 'Related Logistics', 'model' => 'Model',
'stocks' => 'Product inventory', 'price' => 'Price',
'model' => 'Model', 'origin_price' => 'Original Price',
'price' => 'Price', 'cost_price' => 'Cost Price',
'origin_price' => 'Original Price', 'quantity' => 'Quantity',
'cost_price' => 'Cost Price', 'enable_multi_spec' => 'Enable multi-spec',
'quantity' => 'Quantity', 'image_help' => 'The first picture will be used as the main picture of the product, and multiple pictures can be uploaded at the same time, and the position of multiple pictures can be adjusted at will',
'enable_multi_spec' => 'Enable multi-spec', 'video_help' => 'If the prompt exceeds the system size limit, please modify the php.ini parameter post_max_size',
'image_help' => 'The first picture will be used as the main picture of the product, and multiple pictures can be uploaded at the same time, and the position of multiple pictures can be adjusted at will', 'add_variable' => 'Add Specs',
'video_help' => 'If the prompt exceeds the system size limit, please modify the php.ini parameter post_max_size', 'add_variable_value' => 'Add Specification Value',
'add_variable' => 'Add Specs', 'add_variable_image' => 'Add Spec Image',
'add_variable_value' => 'Add Specification Value', 'default_main_product' => 'Default main product',
'add_variable_image' => 'Add Spec Image', 'modify_order' => 'Double-click to modify, drag to adjust the order',
'default_main_product' => 'Default main product', 'weight_text' => 'weight',
'modify_order' => 'Double-click to modify, drag to adjust the order', 'length_width_height' => 'Length, width and height',
'weight_text' => 'weight', 'length' => 'Length',
'length_width_height' => 'Length, width and height', 'width' => 'Width',
'length' => 'Length', 'height' => 'Height',
'width' => 'Width', 'weight_class' => 'weight unit',
'height' => 'Height', 'confirm_batch_product' => 'Are you sure you want to delete the selected logistics in batches? ',
'weight_class' => 'weight unit', '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_product' => 'Are you sure you want to delete the selected logistics in batches? ', 'confirm_delete_restore' => 'Are you sure you want to empty the recycle bin? ',
'confirm_batch_status' => 'Confirm to modify the status of the selected logistics in batches? ', 'warehouse_name' => 'Warehouse name',
'confirm_batch_restore' => 'Confirm to restore the selected product? ', 'type' => 'Type',
'confirm_delete_restore' => 'Are you sure you want to empty the recycle bin? ', 'first_weight' => 'First weight',
'warehouse_name' => 'Warehouse name', 'first_weight_fee' => 'First weight fee',
'type'=>'Type', 'continuation_weight_max' => 'Continuation weight max',
'add_weight' => 'Add weight',
'first_weight'=>'First weight', 'continuation_weight_fee' => 'Continuation weight fee',
'first_weight_fee'=>'First weight fee', 'num_fee' => 'Num fee',
'continuation_weight_max'=>'Continuation weight max', 'throwing_ratio' => 'Throwing ratio',
'add_weight'=>'Add weight', 'day_min' => 'Day min',
'continuation_weight_fee'=>'Continuation weight fee', 'day_max' => 'Day max',
'num_fee'=>'Num fee', 'day' => 'Day',
'throwing_ratio'=>'Throwing ratio', 'work_day' => 'Work day',
'day_min'=>'Day min', 'type_weight' => 'Billing by weight',
'day_max'=>'Day max', 'type_num' => 'Quantity based billing',
'day'=>'Day', 'type_free' => 'Merchant package shipping',
'work_day'=>'Work day', 'first_num' => 'First num',
'type_weight'=>'Billing by weight', 'first_num_fee' => 'First num fee',
'type_num'=>'Quantity based billing', 'add_num' => 'Add num',
'type_free'=>'Merchant package shipping', 'continuation_num_fee' => 'Continuation num fee',
'first_num'=>'First num', 'freight_calculation_method' => 'Freight calculation method',
'first_num_fee'=>'First num fee',
'add_num'=>'Add num',
'continuation_num_fee'=>'Continuation num fee',
'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',
]; ];

View File

@ -8,44 +8,44 @@
* @modified 2022-08-02 14:22:41 * @modified 2022-08-02 14:22:41
*/ */
return [ return [
'logistics_index' => '物流列表', 'logistics_index' => '物流列表',
'logistics_name' => '物流名称', 'logistics_name' => '物流名称',
'logistics_img' => '物流图片', 'logistics_img' => '物流图片',
'logistics_create' => '创建物流', 'logistics_create' => '创建物流',
'logistics_show' => '物流详情', 'logistics_show' => '物流详情',
'logistics_update' => '更新物流', 'logistics_update' => '更新物流',
'logistics_delete' => '删除物流', 'logistics_delete' => '删除物流',
'logistics_trashed' => '回收站', 'logistics_trashed' => '回收站',
'logistics_restore' => '恢复回收站', 'logistics_restore' => '恢复回收站',
'clear_restore' => '清空回收站', 'clear_restore' => '清空回收站',
'logistics_filter_index' => '查看高级筛选', 'logistics_filter_index' => '查看高级筛选',
'logistics_filter_update' => '修改高级筛选', 'logistics_filter_update' => '修改高级筛选',
'batch_delete' => '批量删除', 'batch_delete' => '批量删除',
'batch_active' => '批量上架', 'batch_active' => '批量上架',
'batch_inactive' => '批量下架', 'batch_inactive' => '批量下架',
'basic_information' => '基础信息', 'basic_information' => '基础信息',
'product_details' => '物流详情', 'product_details' => '物流详情',
'product_relations' => '相关物流', 'product_relations' => '相关物流',
'stocks' => '物流库存', 'stocks' => '物流库存',
'model' => '型号', 'model' => '型号',
'price' => '价格', 'price' => '价格',
'origin_price' => '原价', 'origin_price' => '原价',
'cost_price' => '成本价', 'cost_price' => '成本价',
'quantity' => '数量', 'quantity' => '数量',
'enable_multi_spec' => '启用多规格', 'enable_multi_spec' => '启用多规格',
'image_help' => '第一张图片将作为物流主图,支持同时上传多张图片,多张图片之间可随意调整位置', 'image_help' => '第一张图片将作为物流主图,支持同时上传多张图片,多张图片之间可随意调整位置',
'video_help' => '如果提示超出系统大小限制,请修改 php.ini 参数 post_max_size', 'video_help' => '如果提示超出系统大小限制,请修改 php.ini 参数 post_max_size',
'add_variable' => '添加规格', 'add_variable' => '添加规格',
'add_variable_value' => '添加规格值', 'add_variable_value' => '添加规格值',
'add_variable_image' => '添加规格图片', 'add_variable_image' => '添加规格图片',
'default_main_product' => '默认主物流', 'default_main_product' => '默认主物流',
'modify_order' => '双击修改、拖动调整顺序', 'modify_order' => '双击修改、拖动调整顺序',
'weight_text' => '重量', 'weight_text' => '重量',
'length_width_height' => '长宽高', 'length_width_height' => '长宽高',
'length' => '长', 'length' => '长',
'width' => '宽', 'width' => '宽',
'height' => '高', 'height' => '高',
'weight_class' => '重量单位', 'weight_class' => '重量单位',
'confirm_batch_product' => '确认要批量删除选中的物流吗?', 'confirm_batch_product' => '确认要批量删除选中的物流吗?',
'confirm_batch_status' => '确认要批量修改选中的物流的状态吗?', 'confirm_batch_status' => '确认要批量修改选中的物流的状态吗?',
'confirm_batch_restore' => '确认要恢复选中的物流吗?', 'confirm_batch_restore' => '确认要恢复选中的物流吗?',
@ -77,5 +77,6 @@ return [
'continuation_num_fee' => '续件运费', 'continuation_num_fee' => '续件运费',
'freight_calculation_method' => '运费计算方式', 'freight_calculation_method' => '运费计算方式',
'logistics_duration' => '发货后:day个工作日内交货', 'logistics_duration' => '发货后:day个工作日内交货',
'unit' => '单位::unit', 'unit' => '单位::unit',
'default_countries' => '前台默认展示国家',
]; ];

View File

@ -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;// 不存在 添加