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

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\LanguageRepo;
use Beike\Repositories\LogisticsRepo;
use Beike\Repositories\SettingRepo;
use Illuminate\Http\Request;
class LogisticsController extends Controller
@ -31,10 +32,14 @@ class LogisticsController extends Controller
$logistics = LogisticsResource::collection($logisticsList);
$logisticsFormat = $logistics->jsonSerialize();
$countries = LogisticsRepo::getDefaultCountries();
$data = [
'logistics_format' => $logisticsFormat,
'logistics' => $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);
@ -166,7 +171,6 @@ class LogisticsController extends Controller
// 获取
$countryIds = (array)explode(',',$logistics->country_ids);
$logistics->country_ids = CountryRepo::getInList($countryIds);
$data = [
'logistics' => $logistics,
'types' => $types,
@ -227,4 +231,22 @@ class LogisticsController extends Controller
{
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_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_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');

View File

@ -373,4 +373,18 @@ class LogisticsRepo
$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{
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>
@if ($errors->has('error'))
<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-body">
<div class="d-flex justify-content-between my-4">
<div class="d-flex my-4">
@if ($type != 'trashed')
<a href="{{ admin_route('logistics.create') }}" class="me-1 nowrap">
<button class="btn btn-primary">{{ __('admin/logistics.logistics_create') }}</button>
</a>
<div class="default-countries">
{{ __('admin/logistics.default_countries') }}
<span class="countries-select-btn" @click="$refs['select-countries'].showSelectCountries()">
@{{ showCurrentCountry() }}
</span>
</div>
@else
@if ($logistics->total())
<button class="btn btn-primary" @click="clearRestore">{{ __('admin/logistics.clear_restore') }}</button>
@ -161,12 +182,15 @@
@endif
</div>
</div>
<select-countries ref="select-countries" :country_list="country_list" @change-info="changeCountry" :is_single="true"></select-countries>
</div>
@hook('admin.product.list.content.footer')
@endsection
@push('footer')
@include('shared.select-countries')
<script>
let app = new Vue({
el: '#product-app',
@ -183,8 +207,9 @@
},
selectedIds: [],
productIds: @json($logistics->pluck('id')),
country_list: @json($default_countries ?? []),
default_countries_name: "{{ $default_countries_name ?? ''}}",
},
computed: {
allSelected: {
get(e) {
@ -195,11 +220,9 @@
}
}
},
created() {
bk.addFilterCondition(this);
},
methods: {
turnOnOff() {
let id = event.currentTarget.getAttribute("data-id");
@ -211,7 +234,6 @@
location.reload();
})
},
batchDelete() {
this.$confirm('{{ __('admin/product.confirm_batch_product') }}', '{{ __('common.text_hint') }}', {
confirmButtonText: '{{ __('common.confirm') }}',
@ -224,7 +246,6 @@
})
}).catch(()=>{});
},
batchActive(type) {
this.$confirm('{{ __('admin/product.confirm_batch_status') }}', '{{ __('common.text_hint') }}', {
confirmButtonText: '{{ __('common.confirm') }}',
@ -237,22 +258,18 @@
})
}).catch(()=>{});
},
search() {
this.filter.page = '';
location = bk.objectToUrlParams(this.filter, this.url)
},
checkedOrderBy(orderBy) {
this.filter.order_by = orderBy;
location = bk.objectToUrlParams(this.filter, this.url)
},
resetSearch() {
this.filter = bk.clearObjectValue(this.filter)
location = bk.objectToUrlParams(this.filter, this.url)
},
copyProduct(index) {
const id = this.productIds[index];
@ -277,7 +294,6 @@
})
}).catch(()=>{});
},
restoreProduct(index) {
const id = this.productIds[index];
@ -289,7 +305,6 @@
})
}).catch(()=>{});;
},
clearRestore() {
this.$confirm('{{ __('admin/product.confirm_delete_restore') }}', '{{ __('common.text_hint') }}', {
type: 'warning'
@ -298,7 +313,25 @@
location.reload();
})
}).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>

View File

@ -1,82 +1,77 @@
<?php
/**
* order.php
*
* @copyright 2022 beikeshop.com - All Rights Reserved
* @link https://beikeshop.com
* @author Edward Yang <yangjin@guangda.work>
* @created 2022-08-02 14:22:41
* @modified 2022-08-02 14:22:41
*/
return [
'logistics_index' => 'Index',
'logistics_name' => 'Logistics Name',
'logistics_img' => 'Logistics Image',
'logistics_create' => 'Create',
'logistics_show' => 'Detail',
'logistics_update' => 'Edit',
'logistics_delete' => 'Delete',
'logistics_trashed' => 'Trashed',
'logistics_restore' => 'Restore',
'clear_restore' => 'Empty Recycle Bin',
'logistics_filter_index' => 'View Filters',
'logistics_filter_update' => 'Modify Filters',
'batch_delete' => 'Batch Delete',
'batch_active' => 'Batch Active',
'batch_inactive' => 'Batch Inactive',
'basic_information' => 'Basic Information',
'product_details' => 'Product details',
'product_relations' => 'Related Logistics',
'stocks' => 'Product inventory',
'model' => 'Model',
'price' => 'Price',
'origin_price' => 'Original Price',
'cost_price' => 'Cost Price',
'quantity' => 'Quantity',
'enable_multi_spec' => 'Enable multi-spec',
'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',
'video_help' => 'If the prompt exceeds the system size limit, please modify the php.ini parameter post_max_size',
'add_variable' => 'Add Specs',
'add_variable_value' => 'Add Specification Value',
'add_variable_image' => 'Add Spec Image',
'default_main_product' => 'Default main product',
'modify_order' => 'Double-click to modify, drag to adjust the order',
'weight_text' => 'weight',
'length_width_height' => 'Length, width and height',
'length' => 'Length',
'width' => 'Width',
'height' => 'Height',
'weight_class' => 'weight unit',
'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_restore' => 'Confirm to restore the selected product? ',
'confirm_delete_restore' => 'Are you sure you want to empty the recycle bin? ',
'warehouse_name' => 'Warehouse name',
'type'=>'Type',
'first_weight'=>'First weight',
'first_weight_fee'=>'First weight fee',
'continuation_weight_max'=>'Continuation weight max',
'add_weight'=>'Add weight',
'continuation_weight_fee'=>'Continuation weight fee',
'num_fee'=>'Num fee',
'throwing_ratio'=>'Throwing ratio',
'day_min'=>'Day min',
'day_max'=>'Day max',
'day'=>'Day',
'work_day'=>'Work day',
'type_weight'=>'Billing by weight',
'type_num'=>'Quantity based billing',
'type_free'=>'Merchant package shipping',
'first_num'=>'First num',
'first_num_fee'=>'First num fee',
'add_num'=>'Add num',
'continuation_num_fee'=>'Continuation num fee',
'freight_calculation_method'=>'Freight calculation method',
'logistics_index' => 'Index',
'logistics_name' => 'Logistics Name',
'logistics_img' => 'Logistics Image',
'logistics_create' => 'Create',
'logistics_show' => 'Detail',
'logistics_update' => 'Edit',
'logistics_delete' => 'Delete',
'logistics_trashed' => 'Trashed',
'logistics_restore' => 'Restore',
'clear_restore' => 'Empty Recycle Bin',
'logistics_filter_index' => 'View Filters',
'logistics_filter_update' => 'Modify Filters',
'batch_delete' => 'Batch Delete',
'batch_active' => 'Batch Active',
'batch_inactive' => 'Batch Inactive',
'basic_information' => 'Basic Information',
'product_details' => 'Product details',
'product_relations' => 'Related Logistics',
'stocks' => 'Product inventory',
'model' => 'Model',
'price' => 'Price',
'origin_price' => 'Original Price',
'cost_price' => 'Cost Price',
'quantity' => 'Quantity',
'enable_multi_spec' => 'Enable multi-spec',
'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',
'video_help' => 'If the prompt exceeds the system size limit, please modify the php.ini parameter post_max_size',
'add_variable' => 'Add Specs',
'add_variable_value' => 'Add Specification Value',
'add_variable_image' => 'Add Spec Image',
'default_main_product' => 'Default main product',
'modify_order' => 'Double-click to modify, drag to adjust the order',
'weight_text' => 'weight',
'length_width_height' => 'Length, width and height',
'length' => 'Length',
'width' => 'Width',
'height' => 'Height',
'weight_class' => 'weight unit',
'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_restore' => 'Confirm to restore the selected product? ',
'confirm_delete_restore' => 'Are you sure you want to empty the recycle bin? ',
'warehouse_name' => 'Warehouse name',
'type' => 'Type',
'first_weight' => 'First weight',
'first_weight_fee' => 'First weight fee',
'continuation_weight_max' => 'Continuation weight max',
'add_weight' => 'Add weight',
'continuation_weight_fee' => 'Continuation weight fee',
'num_fee' => 'Num fee',
'throwing_ratio' => 'Throwing ratio',
'day_min' => 'Day min',
'day_max' => 'Day max',
'day' => 'Day',
'work_day' => 'Work day',
'type_weight' => 'Billing by weight',
'type_num' => 'Quantity based billing',
'type_free' => 'Merchant package shipping',
'first_num' => 'First num',
'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',
'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
*/
return [
'logistics_index' => '物流列表',
'logistics_name' => '物流名称',
'logistics_img' => '物流图片',
'logistics_create' => '创建物流',
'logistics_show' => '物流详情',
'logistics_update' => '更新物流',
'logistics_delete' => '删除物流',
'logistics_trashed' => '回收站',
'logistics_restore' => '恢复回收站',
'clear_restore' => '清空回收站',
'logistics_filter_index' => '查看高级筛选',
'logistics_filter_update' => '修改高级筛选',
'batch_delete' => '批量删除',
'batch_active' => '批量上架',
'batch_inactive' => '批量下架',
'basic_information' => '基础信息',
'product_details' => '物流详情',
'product_relations' => '相关物流',
'stocks' => '物流库存',
'model' => '型号',
'price' => '价格',
'origin_price' => '原价',
'cost_price' => '成本价',
'quantity' => '数量',
'enable_multi_spec' => '启用多规格',
'image_help' => '第一张图片将作为物流主图,支持同时上传多张图片,多张图片之间可随意调整位置',
'video_help' => '如果提示超出系统大小限制,请修改 php.ini 参数 post_max_size',
'add_variable' => '添加规格',
'add_variable_value' => '添加规格值',
'add_variable_image' => '添加规格图片',
'default_main_product' => '默认主物流',
'modify_order' => '双击修改、拖动调整顺序',
'weight_text' => '重量',
'length_width_height' => '长宽高',
'length' => '长',
'width' => '宽',
'height' => '高',
'weight_class' => '重量单位',
'logistics_index' => '物流列表',
'logistics_name' => '物流名称',
'logistics_img' => '物流图片',
'logistics_create' => '创建物流',
'logistics_show' => '物流详情',
'logistics_update' => '更新物流',
'logistics_delete' => '删除物流',
'logistics_trashed' => '回收站',
'logistics_restore' => '恢复回收站',
'clear_restore' => '清空回收站',
'logistics_filter_index' => '查看高级筛选',
'logistics_filter_update' => '修改高级筛选',
'batch_delete' => '批量删除',
'batch_active' => '批量上架',
'batch_inactive' => '批量下架',
'basic_information' => '基础信息',
'product_details' => '物流详情',
'product_relations' => '相关物流',
'stocks' => '物流库存',
'model' => '型号',
'price' => '价格',
'origin_price' => '原价',
'cost_price' => '成本价',
'quantity' => '数量',
'enable_multi_spec' => '启用多规格',
'image_help' => '第一张图片将作为物流主图,支持同时上传多张图片,多张图片之间可随意调整位置',
'video_help' => '如果提示超出系统大小限制,请修改 php.ini 参数 post_max_size',
'add_variable' => '添加规格',
'add_variable_value' => '添加规格值',
'add_variable_image' => '添加规格图片',
'default_main_product' => '默认主物流',
'modify_order' => '双击修改、拖动调整顺序',
'weight_text' => '重量',
'length_width_height' => '长宽高',
'length' => '长',
'width' => '宽',
'height' => '高',
'weight_class' => '重量单位',
'confirm_batch_product' => '确认要批量删除选中的物流吗?',
'confirm_batch_status' => '确认要批量修改选中的物流的状态吗?',
'confirm_batch_restore' => '确认要恢复选中的物流吗?',
@ -77,5 +77,6 @@ return [
'continuation_num_fee' => '续件运费',
'freight_calculation_method' => '运费计算方式',
'logistics_duration' => '发货后:day个工作日内交货',
'unit' => '单位::unit',
'unit' => '单位::unit',
'default_countries' => '前台默认展示国家',
];

View File

@ -159,6 +159,10 @@
default: {},
type: [Object,Array]
},
is_single: {
default: false,
type: Boolean
}
},
data: function () {
return {
@ -213,7 +217,9 @@
// 点击当前国家
clickCountries(item){
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];// 存在-删除
else countryIds[item.id] = item;// 不存在 添加