!45 前台子分类显示等

* 优化前台子分类显示、优化规格批量修改、商品详情页保存开启前台验证
* 分类页显示子分类
This commit is contained in:
蒲硕 2023-02-27 10:32:41 +00:00 committed by Edward Yang
parent 46b9ebfa41
commit 32b35e32c1
15 changed files with 88 additions and 46 deletions

View File

@ -5,6 +5,7 @@ namespace Beike\Shop\Http\Controllers;
use Beike\Models\Category;
use Beike\Repositories\CategoryRepo;
use Beike\Repositories\ProductRepo;
use Beike\Shop\Http\Resources\CategoryDetail;
use Beike\Shop\Http\Resources\ProductSimple;
use Illuminate\Http\Request;
@ -28,6 +29,7 @@ class CategoryController extends Controller
$data = [
'all_categories' => CategoryRepo::getTwoLevelCategories(),
'category' => $category,
'children' => CategoryDetail::collection($category->activeChildren)->jsonSerialize(),
'filter_data' => [
'attr' => ProductRepo::getFilterAttribute($filterData),
'price' => ProductRepo::getFilterPrice($filterData),

View File

@ -28,7 +28,7 @@ hr.horizontal.dark {
color: #dc3545 !important;
font-weight: bold;
position: relative;
padding-left: 17px;
padding-left: 17px !important;
&:before {
content: '\F333';

View File

@ -10,6 +10,7 @@
<script src="{{ asset('vendor/vue/2.7/vue.js') }}"></script>
<script src="{{ asset('vendor/element-ui/2.15.9/index.js') }}"></script>
{{-- <script src="{{ asset('vendor/element-ui/2.15.6/js.js') }}"></script> --}}
<script src="{{ asset('vendor/cookie/js.cookie.min.js') }}"></script>
<script src="{{ asset('vendor/jquery/jquery-3.6.0.min.js') }}"></script>
<script src="{{ asset('vendor/layer/3.5.1/layer.js') }}"></script>
<script src="{{ asset('vendor/vue/batch_select.js') }}"></script>
@ -21,6 +22,20 @@
<script src="{{ asset('vendor/element-ui/language/' . locale() . '.js') }}"></script>
@endif
<title>beike filemanager</title>
<script>
@if (locale() != 'zh_cn')
ELEMENT.locale(ELEMENT.lang['{{ locale() }}'])
@endif
const lang = {
file_manager: '{{ __('admin/file_manager.file_manager') }}',
}
const config = {
beike_version: '{{ config('beike.version') }}',
api_url: '{{ config('beike.api_url') }}',
app_url: '{{ config('app.url') }}',
}
</script>
</head>
<body class="page-filemanager">

View File

@ -409,7 +409,7 @@
</div>
<x-admin::form.row title="">
<button type="button" @click="productsSubmit" class="btn btn-primary btn-submit mt-3 btn-lg">{{ __('common.save') }}</button>
<button type="submit" @click="productsSubmit" class="btn btn-primary btn-submit mt-3 btn-lg">{{ __('common.save') }}</button>
</x-admin::form.row>
<el-dialog
@ -482,7 +482,7 @@
sku: @json($product->skus[0]['sku'] ?? ''),
status: @json($product->skus[0]['status'] ?? false),
variables: @json($product->variables ?? []),
skus: @json($product->skus ?? []),
skus: @json(old('skus', $product->skus) ?? []),
},
variablesBatch: {
@ -588,10 +588,6 @@
if (!this.editing.isVariable) {
this.source.variables = [];
}
setTimeout(() => {
$('form#app').submit();
}, 0);
},
relationsQuerySearch(keyword, cb) {
@ -656,48 +652,44 @@
batchSettingVariant() {
// 要修改的 skuIndex 下标
let setSkuIndex = [];
const skus = JSON.parse(JSON.stringify(this.form.skus));
this.form.skus.forEach((sku, skuIndex) => {
this.variablesBatch.variables.forEach((variantIndex, index) => {
if (variantIndex !== '') {
// 根据 variantIndex, index修改 sku.variants[index] 的值
if (sku.variants[index] == variantIndex) {
setSkuIndex.push(skuIndex);
}
return;
}
// 如果 variantIndex 全部为空,就把所有的 skuIndex 都加入到 setSkuIndex 中
if (this.variablesBatch.variables.every(v => v === '')) {
setSkuIndex.push(skuIndex);
skus.forEach((sku, skuIndex) => {
this.variablesBatch.variables.forEach((v, i) => {
if (v === '') {
// sku.variants 数据中 i 的值修改为
sku.variants[i] = '';
}
})
// 修改 skuIndex 下标对应的 sku
setSkuIndex.forEach((index) => {
if (this.variablesBatch.model) {
this.form.skus[index].model = this.variablesBatch.model + '-' + (index + 1);
}
if (this.variablesBatch.sku) {
this.form.skus[index].sku = this.variablesBatch.sku + '-' + (index + 1);
}
if (this.variablesBatch.image) {
this.form.skus[index].images = [this.variablesBatch.image];
}
if (this.variablesBatch.price) {
this.form.skus[index].price = this.variablesBatch.price;
}
if (this.variablesBatch.origin_price) {
this.form.skus[index].origin_price = this.variablesBatch.origin_price;
}
if (this.variablesBatch.cost_price) {
this.form.skus[index].cost_price = this.variablesBatch.cost_price;
}
if (this.variablesBatch.quantity) {
this.form.skus[index].quantity = this.variablesBatch.quantity;
}
})
if (this.variablesBatch.variables.toString() === sku.variants.toString()) {
setSkuIndex.push(skuIndex);
}
})
// 修改 skuIndex 下标对应的 sku
setSkuIndex.forEach((index) => {
if (this.variablesBatch.model) {
this.form.skus[index].model = this.variablesBatch.model + '-' + (index + 1);
}
if (this.variablesBatch.sku) {
this.form.skus[index].sku = this.variablesBatch.sku + '-' + (index + 1);
}
if (this.variablesBatch.image) {
this.form.skus[index].images = [this.variablesBatch.image];
}
if (this.variablesBatch.price) {
this.form.skus[index].price = this.variablesBatch.price;
}
if (this.variablesBatch.origin_price) {
this.form.skus[index].origin_price = this.variablesBatch.origin_price;
}
if (this.variablesBatch.cost_price) {
this.form.skus[index].cost_price = this.variablesBatch.cost_price;
}
if (this.variablesBatch.quantity) {
this.form.skus[index].quantity = this.variablesBatch.quantity;
}
})
// this.variablesBatch 对象内除了 variables 之外的值都清空

View File

@ -27,6 +27,21 @@ body.page-categories {
}
}
.children-wrap {
@media (max-width: 992px) {
display: none;
}
a {
color: #333;
margin-right: 4px;
&:hover {
color: $primary;
}
}
}
.style-wrap {
label {
cursor: pointer;

View File

@ -11,4 +11,5 @@
return [
'name' => 'Kategoriename',
'children' => 'Subcategory',
];

View File

@ -11,4 +11,5 @@
return [
'name' => 'Name',
'children' => 'Subcategory',
];

View File

@ -11,4 +11,5 @@
return [
'name' => 'nombre de la categoría',
'children' => 'Subcategory',
];

View File

@ -11,4 +11,5 @@
return [
'name' => 'Nom de catégorie',
'children' => 'Subcategory',
];

View File

@ -11,4 +11,5 @@
return [
'name' => 'Nome della categoria',
'children' => 'Subcategory',
];

View File

@ -11,4 +11,5 @@
return [
'name' => '種別名',
'children' => 'サブカテゴリ',
];

View File

@ -11,4 +11,5 @@
return [
'name' => 'Название категории',
'children' => 'Subcategory',
];

View File

@ -11,4 +11,5 @@
return [
'name' => '分类名称',
'children' => '子分类',
];

View File

@ -11,4 +11,5 @@
return [
'name' => '分類名稱',
'children' => '子分類',
];

View File

@ -1,6 +1,6 @@
<div class="product-tool d-flex justify-content-between align-items-center mb-4">
@if (!is_mobile())
<div class="style-wrap">
<div class="style-wrap d-flex align-items-center">
<label class="{{ !request('style_list') || request('style_list') == 'grid' ? 'active' : ''}} grid"
data-bs-toggle="tooltip"
data-bs-placement="top"
@ -17,6 +17,15 @@
<svg viewBox="0 0 19 19" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><rect width="5" height="5"></rect><rect x="7" height="5" width="12"></rect><rect y="7" width="5" height="5"></rect><rect x="7" y="7" height="5" width="12"></rect><rect y="14" width="5" height="5"></rect><rect x="7" y="14" height="5" width="12"></rect></svg>
<input class="d-none" value="list" type="radio" name="style_list">
</label>
@if ($children)
<div class="children-wrap ms-4 me-2">
<span class="text-secondary">{{ __('category.children') }}</span>
@foreach ($children as $item)
<a href="{{ $item['url'] }}">{{ $item['name'] }}</a>
@endforeach
</div>
@endif
</div>
@endif
<div class="d-flex align-items-center">