diff --git a/beike/Admin/Http/Controllers/RmaReasonController.php b/beike/Admin/Http/Controllers/RmaReasonController.php index 6415ef6f..83d6df3c 100644 --- a/beike/Admin/Http/Controllers/RmaReasonController.php +++ b/beike/Admin/Http/Controllers/RmaReasonController.php @@ -11,6 +11,7 @@ namespace Beike\Admin\Http\Controllers; +use Beike\Admin\Http\Resources\RmaReasonDetail; use Beike\Repositories\RmaReasonRepo; use Beike\Repositories\LanguageRepo; use Exception; @@ -21,11 +22,16 @@ class RmaReasonController extends Controller public function index(Request $request) { $rmaReasons = RmaReasonRepo::list($request->only('name')); + $data = [ 'languages' => LanguageRepo::all(), - 'rmaReasons' => $rmaReasons, + 'rmaReasons' => RmaReasonDetail::collection($rmaReasons)->jsonSerialize(), ]; + if ($request->expectsJson()) { + return json_success(trans('common.success'), $data); + } + return view('admin::pages.rma_reasons.index', $data); } diff --git a/beike/Admin/Http/Resources/RmaReasonDetail.php b/beike/Admin/Http/Resources/RmaReasonDetail.php new file mode 100644 index 00000000..19027255 --- /dev/null +++ b/beike/Admin/Http/Resources/RmaReasonDetail.php @@ -0,0 +1,27 @@ + + * @created 2022-08-31 11:56:28 + * @modified 2022-08-31 11:56:28 + */ + +namespace Beike\Admin\Http\Resources; + +use Beike\Repositories\RmaRepo; +use Illuminate\Http\Resources\Json\JsonResource; + +class RmaReasonDetail extends JsonResource +{ + public function toArray($request): array + { + return [ + 'id' => $this->id, + 'name' => json_decode($this->name, true)[locale()] ?? '', + 'names' => json_decode($this->name, true) + ]; + } +} diff --git a/beike/Models/Rma.php b/beike/Models/Rma.php index 9fdfd3bb..b420afc1 100644 --- a/beike/Models/Rma.php +++ b/beike/Models/Rma.php @@ -38,7 +38,7 @@ class Rma extends Base public function reason() :BelongsTo { - return $this->belongsTo(RmaReason::class, 'rma_reason_id', 'id')->where('locale', locale()); + return $this->belongsTo(RmaReason::class, 'rma_reason_id', 'id'); } public function histories() :HasMany diff --git a/beike/Repositories/RmaReasonRepo.php b/beike/Repositories/RmaReasonRepo.php index 0c9d0cbd..d4de573b 100644 --- a/beike/Repositories/RmaReasonRepo.php +++ b/beike/Repositories/RmaReasonRepo.php @@ -29,6 +29,7 @@ class RmaReasonRepo */ public static function create($data) { + $data['name'] = json_encode($data['name']); $item = RmaReason::query()->create($data); return $item; } @@ -47,6 +48,7 @@ class RmaReasonRepo if (!$reason) { throw new Exception("退换货原因id $reason 不存在"); } + $data['name'] = json_encode($data['name']); $reason->update($data); return $reason; } @@ -78,10 +80,11 @@ class RmaReasonRepo */ public static function list(array $data = []) { - $builder = RmaReason::query()->where('locale', locale()); + $builder = RmaReason::query(); if (isset($data['name'])) { - $builder->where('name', 'like', "%{$data['name']}%"); + $locale = locale(); + $builder->whereJsonContains("name->$locale", 'like', "%{$data['name']}%"); } return $builder->get(); diff --git a/beike/Shop/Http/Controllers/Account/RmaController.php b/beike/Shop/Http/Controllers/Account/RmaController.php index 3eed43f9..ea80b5e5 100644 --- a/beike/Shop/Http/Controllers/Account/RmaController.php +++ b/beike/Shop/Http/Controllers/Account/RmaController.php @@ -15,6 +15,7 @@ use App\Http\Controllers\Controller; use Beike\Repositories\RmaReasonRepo; use Beike\Repositories\RmaRepo; use Beike\Shop\Http\Requests\RmaRequest; +use Beike\Shop\Http\Resources\Account\RmaReasonDetail; use Beike\Shop\Services\RmaService; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; @@ -40,9 +41,12 @@ class RmaController extends Controller */ public function show(int $id) { + $rma = RmaRepo::find($id); $data = [ - 'rma' => RmaRepo::find($id), + 'rma' => $rma, + 'orderProduct' => OrderProductRepo::find($rma->order_product_id), 'statuses' => RmaRepo::getStatuses(), + 'reasons' => RmaReasonDetail::collection(RmaReasonRepo::list())->jsonSerialize(), 'types' => RmaRepo::getTypes(), ]; @@ -54,7 +58,7 @@ class RmaController extends Controller $data = [ 'orderProduct' => OrderProductRepo::find($orderProductId), 'statuses' => RmaRepo::getStatuses(), - 'reasons' => RmaReasonRepo::list()->toArray(), + 'reasons' => RmaReasonDetail::collection(RmaReasonRepo::list())->jsonSerialize(), 'types' => RmaRepo::getTypes(), ]; diff --git a/beike/Shop/Http/Resources/Account/RmaReasonDetail.php b/beike/Shop/Http/Resources/Account/RmaReasonDetail.php new file mode 100644 index 00000000..79a9fe1e --- /dev/null +++ b/beike/Shop/Http/Resources/Account/RmaReasonDetail.php @@ -0,0 +1,25 @@ + + * @created 2022-08-31 11:56:28 + * @modified 2022-08-31 11:56:28 + */ + +namespace Beike\Shop\Http\Resources\Account; + +use Illuminate\Http\Resources\Json\JsonResource; + +class RmaReasonDetail extends JsonResource +{ + public function toArray($request): array + { + return [ + 'id' => $this->id, + 'name' => json_decode($this->name, true)[locale()] ?? '', + ]; + } +} diff --git a/beike/Shop/Http/Resources/RmaDetail.php b/beike/Shop/Http/Resources/RmaDetail.php index 13d76e63..04599e9e 100644 --- a/beike/Shop/Http/Resources/RmaDetail.php +++ b/beike/Shop/Http/Resources/RmaDetail.php @@ -35,7 +35,7 @@ class RmaDetail extends JsonResource 'product_name' => $this->product_name, 'name' => $this->name, 'sku' => $this->sku, - 'reason' => $this->reason->name ?? '', + 'reason' => json_decode($this->reason->name, true)[locale()] ?? '', 'type_text' => $this->type_text, ]; } diff --git a/database/migrations/2022_07_29_021003_return_table.php b/database/migrations/2022_07_29_021003_return_table.php index 5928f061..bca46bc0 100644 --- a/database/migrations/2022_07_29_021003_return_table.php +++ b/database/migrations/2022_07_29_021003_return_table.php @@ -40,9 +40,9 @@ class ReturnTable extends Migration $table->timestamps(); }); Schema::create('rma_reasons', function (Blueprint $table) { - $table->bigInteger('id'); - $table->string('locale'); - $table->string('name'); + $table->id(); + $table->json('name'); // 值示例: {"en":"cannot to use","zh_cn":"无法使用"} + $table->timestamps(); }); } diff --git a/resources/beike/admin/views/pages/brands/index.blade.php b/resources/beike/admin/views/pages/brands/index.blade.php index 3141aa52..f15a2d84 100644 --- a/resources/beike/admin/views/pages/brands/index.blade.php +++ b/resources/beike/admin/views/pages/brands/index.blade.php @@ -28,7 +28,8 @@ @{{ brand.sort_order }} @{{ brand.first }} - @{{ brand.status ? '启用' : '禁用' }} + {{ __('common.enabled') }} + {{ __('common.disabled') }} @@ -106,9 +107,9 @@ }, rules: { - name: [{required: true,message: '请输入名称',trigger: 'blur'}, ], - first: [{required: true,message: '请输入首字母',trigger: 'blur'}, ], - logo: [{required: true,message: '请上传图标',trigger: 'change'}, ], + name: [{required: true,message: '{{ __('common.error_required', ['name' => __('common.name')])}}',trigger: 'blur'}, ], + first: [{required: true,message: '{{ __('common.error_required', ['name' => __('brand.first_letter')])}}',trigger: 'blur'}, ], + logo: [{required: true,message: '{{ __('admin/brand.error_upload') }}',trigger: 'change'}, ], } }, diff --git a/resources/beike/admin/views/pages/categories/index.blade.php b/resources/beike/admin/views/pages/categories/index.blade.php index 5bb7ed50..1ca3cfc5 100644 --- a/resources/beike/admin/views/pages/categories/index.blade.php +++ b/resources/beike/admin/views/pages/categories/index.blade.php @@ -13,7 +13,8 @@
@{{ data.name }}
- @{{ data.active ? '启用' : '禁用' }} + {{ __('common.enabled') }} + {{ __('common.disabled') }}
{{ __('common.edit') }} {{ __('common.delete') }} @@ -40,9 +41,9 @@ methods: { removeCategory(node, data) { - this.$confirm('确定要删除分类吗?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', + this.$confirm('{{ __('common.confirm_delete') }}', '{{ __('common.text_hint') }}', { + confirmButtonText: '{{ __('common.confirm') }}', + cancelButtonText: '{{ __('common.cancel') }}', type: 'warning' }).then(() => { $http.delete(`/categories/${data.id}`).then((res) => { diff --git a/resources/beike/admin/views/pages/file_manager/index.blade.php b/resources/beike/admin/views/pages/file_manager/index.blade.php index ca2d3f4f..11deffb0 100644 --- a/resources/beike/admin/views/pages/file_manager/index.blade.php +++ b/resources/beike/admin/views/pages/file_manager/index.blade.php @@ -17,6 +17,9 @@ + @if (locale() != 'zh_cn') + + @endif beike filemanager @@ -31,17 +34,17 @@
@{{ node.label }}
{{-- v-if="node.isCurrent" --}}
- + - + - + @@ -54,18 +57,18 @@
- 选择 + {{ __('admin/builder.modules_choose') }} 下载 + @click="downloadImages">{{ __('admin/file_manager.download') }} 删除 + icon="el-icon-delete">{{ __('common.delete') }} 重命名 + @click="openInputBox('image')" icon="el-icon-edit">{{ __('admin/file_manager.rename') }} 全选 + @click="selectAll()" icon="el-icon-finished">{{ __('common.select_all') }}
- 上传文件 + {{ __('admin/file_manager.upload_files') }}
- + - - -
点击上传,或将图片拖到此处
+
{{ __('admin/file_manager.click_upload') }}
@@ -127,6 +130,9 @@