【增加】产品状态名称修改

This commit is contained in:
liqianjin 2023-08-11 15:16:23 +08:00
parent 1713d0712c
commit fa79136adc
11 changed files with 86 additions and 7 deletions

View File

@ -19,6 +19,7 @@ use Beike\Admin\View\Components\Form\InputLocale;
use Beike\Admin\View\Components\Form\RichText;
use Beike\Admin\View\Components\Form\Select;
use Beike\Admin\View\Components\Form\SwitchRadio;
use Beike\Admin\View\Components\Form\SwitchRadioStatus;
use Beike\Admin\View\Components\Form\Textarea;
use Beike\Admin\View\Components\Header;
use Beike\Admin\View\Components\NoData;
@ -139,6 +140,7 @@ class AdminServiceProvider extends ServiceProvider
'alert' => Alert::class,
'form-input-locale' => InputLocale::class,
'form-switch' => SwitchRadio::class,
'form-switch-status' => SwitchRadioStatus::class,
'form-input' => Input::class,
'form-select' => Select::class,
'form-image' => Image::class,

View File

@ -0,0 +1,26 @@
<?php
namespace Beike\Admin\View\Components\Form;
use Illuminate\View\Component;
class SwitchRadioStatus extends Component
{
public string $name;
public string $value;
public string $title;
public function __construct(string $name, string $value, string $title)
{
$this->name = $name;
$this->title = $title;
$this->value = $value;
}
public function render()
{
return view('admin::components.form.switch-radio-status');
}
}

View File

@ -61,7 +61,7 @@ class CartController extends Controller
$customer = current_customer();
$sku = ProductSku::query()
->whereRelation('product', 'active', '=', true)
// ->whereRelation('product', 'active', '=', true)
->findOrFail($skuId);
$cart = CartService::add($sku, $quantity, $customer);

View File

@ -57,7 +57,14 @@ class CheckoutController extends Controller
public function confirm()
{
try {
$data = (new CheckoutService)->confirm();
$checkoutService = new CheckoutService;
$selectedProducts = $checkoutService->selectedProducts->toArray();
foreach($selectedProducts as $product){
if($product['product']['active'] == FALSE){
return json_fail(trans('common.product_active_false'));
}
}
$data = $checkoutService->confirm();
return hook_filter('checkout.confirm.data', $data);
} catch (\Exception $e) {

View File

@ -29,7 +29,7 @@ class MenusController extends Controller
{
$products = ProductRepo::getBuilder(
[
'active' => 1,
// 'active' => 1,
'sort' => 'created_at',
'order' => 'desc',
])

View File

@ -0,0 +1,13 @@
<x-admin::form.row :title="$title">
<div class="mb-1 mt-2">
<div class="form-check form-check-inline">
<input class="form-check-input" id="{{ $name }}-1" type="radio" name="{{ $name }}" id="{{ $name }}-1" value="1" {{ $value ? 'checked' : '' }}>
<label class="form-check-label" for="{{ $name }}-1">{{ __('common.enable_status') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" id="{{ $name }}-0" type="radio" name="{{ $name }}" id="{{ $name }}-0" value="0" {{ !$value ? 'checked' : '' }}>
<label class="form-check-label" for="{{ $name }}-0">{{ __('common.disable_status') }}</label>
</div>
</div>
{{ $slot }}
</x-admin::form.row>

View File

@ -136,7 +136,7 @@
</div>
</x-admin::form.row>
<x-admin-form-switch name="active" :title="__('common.status')" :value="old('active', $product->active ?? 1)" />
<x-admin-form-switch-status name="active" :title="__('common.status')" :value="old('active', $product->active ?? 1)" />
@hook('admin.product.edit.extra')

View File

@ -135,9 +135,12 @@
<td>{{ $product['position'] }}</td>
@if ($type != 'trashed')
<td>
<div class="form-check form-switch">
<input class="form-check-input cursor-pointer" type="checkbox" role="switch" data-active="{{ $product['active'] ? true : false }}" data-id="{{ $product['id'] }}" @change="turnOnOff($event)" {{ $product['active'] ? 'checked' : '' }}>
</div>
{{-- <div class="form-check form-switch">--}}
{{-- <input class="form-check-input cursor-pointer" type="checkbox" role="switch" data-active="{{ $product['active'] ? true : false }}" data-id="{{ $product['id'] }}" @change="turnOnOff($event)" {{ $product['active'] ? 'checked' : '' }}>--}}
{{-- </div>--}}
<span class="{{ $product['active'] ? 'text-success' : 'text-secondary' }}">
{{ $product['active'] ? __('common.enable_status') : __('common.disable_status') }}
</span>
</td>
@endif
@hook('admin.product.list.column_value')

View File

@ -28,7 +28,9 @@ return [
'all' => 'All',
'status' => 'Status',
'enable' => 'Enable',
'enable_status' => 'Ordering of products',
'disable' => 'Disable',
'disable_status' => 'Indirect ordering of products',
'enabled' => 'Enabled',
'disabled' => 'Disabled',
'home' => 'Home',
@ -93,6 +95,7 @@ return [
'error_page' => 'The data you accessed does not exist or has been deleted~',
'error_page_btn' => 'Return to previous page',
'no_repeat' => 'Do not re-add',
'product_active_false' => 'Product active are indirect ordering of products',
'contacts' => 'Contacts',
'content' => 'Content',

View File

@ -27,7 +27,9 @@ return [
'all' => '全部',
'status' => '状态',
'enable' => '启用',
'enable_status' => '直接下单产品',
'disable' => '禁用',
'disable_status' => '非直接下单产品',
'enabled' => '启用',
'disabled' => '禁用',
'home' => '首页',
@ -92,6 +94,7 @@ return [
'error_page' => '您访问的数据不存在或已被删除~',
'error_page_btn' => '返回上一页',
'no_repeat' => '请勿重新添加',
'product_active_false' => '产品状态为非直接下单产品',
'contacts' => '联系人',
'content' => '内容',

View File

@ -203,6 +203,28 @@
@endif
@else
{{-- <div class="text-danger"><i class="bi bi-exclamation-circle-fill"></i> {{ __('product.has_been_inactive') }}</div>--}}
<div class="quantity-btns">
@hook('product.detail.buy.before')
@hookwrapper('product.detail.quantity.input')
<div class="quantity-wrap">
<input type="text" class="form-control" :disabled="!product.quantity" onkeyup="this.value=this.value.replace(/\D/g,'')" v-model="quantity" name="quantity">
<div class="right">
<i class="bi bi-chevron-up"></i>
<i class="bi bi-chevron-down"></i>
</div>
</div>
@endhookwrapper
@hookwrapper('product.detail.add_to_cart')
<button
class="btn btn-outline-dark ms-md-3 add-cart fw-bold"
:product-id="product.id"
:product-price="product.price"
:disabled="!product.quantity"
@click="addCart(false, this)"
><i class="bi bi-cart-fill me-1"></i>{{ __('shop/products.add_to_cart') }}
</button>
@endhookwrapper
</div>
@endif
<button
style="width: 16em;"