Merge branch 'dev'

This commit is contained in:
Edward Yang 2022-08-31 20:05:59 +08:00
commit 5e1f89aa81
21 changed files with 214 additions and 64 deletions

View File

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

View File

@ -0,0 +1,27 @@
<?php
/**
* RmaReasonDetail.php
*
* @copyright 2022 opencart.cn - All Rights Reserved
* @link http://www.guangdawangluo.com
* @author TL <mengwb@opencart.cn>
* @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)
];
}
}

View File

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

View File

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

View File

@ -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(),
];

View File

@ -0,0 +1,25 @@
<?php
/**
* RmaReasonDetail.php
*
* @copyright 2022 opencart.cn - All Rights Reserved
* @link http://www.guangdawangluo.com
* @author TL <mengwb@opencart.cn>
* @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()] ?? '',
];
}
}

View File

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

View File

@ -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();
});
}

View File

@ -28,7 +28,8 @@
<td>@{{ brand.sort_order }}</td>
<td>@{{ brand.first }}</td>
<td>
<span :class="brand.status ? 'text-success' : 'text-secondary'">@{{ brand.status ? '启用' : '禁用' }}</span>
<span class="text-success" v-if="brand.status">{{ __('common.enabled') }}</span>
<span class="text-secondary" v-else>{{ __('common.disabled') }}</span>
</td>
<td>
<button class="btn btn-outline-secondary btn-sm" @click="checkedCreate('edit', index)">{{ __('common.edit') }}</button>
@ -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'}, ],
}
},

View File

@ -13,7 +13,8 @@
<div class="custom-tree-node d-flex align-items-center justify-content-between w-100" slot-scope="{ node, data }">
<div><span>@{{ data.name }}</span></div>
<div class="d-flex align-items-center">
<span :class="['me-4', 'badge', 'bg-' + (data.active ? 'success' : 'secondary')]">@{{ data.active ? '启用' : '禁用' }}</span>
<span class="me-4 badge bg-success" v-if="data.active">{{ __('common.enabled') }}</span>
<span class="me-4 badge bg-secondary" v-else>{{ __('common.disabled') }}</span>
<div>
<a :href="data.url_edit" class="btn btn-outline-secondary btn-sm">{{ __('common.edit') }}</a>
<a class="btn btn-outline-danger btn-sm" @click="removeCategory(node, data)">{{ __('common.delete') }}</a>
@ -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) => {

View File

@ -17,6 +17,9 @@
<link rel="stylesheet" href="{{ asset('vendor/element-ui/2.15.9/index.css') }}">
<link href="{{ mix('build/beike/admin/css/filemanager.css') }}" rel="stylesheet">
<script src="{{ mix('build/beike/admin/js/app.js') }}"></script>
@if (locale() != 'zh_cn')
<script src="{{ asset('vendor/element-ui/language/' . locale() . '.js') }}"></script>
@endif
<title>beike filemanager</title>
</head>
@ -31,17 +34,17 @@
<div>@{{ node.label }}</div>
{{-- v-if="node.isCurrent" --}}
<div class="right">
<el-tooltip class="item" effect="dark" content="创建文件夹" placement="top">
<el-tooltip class="item" effect="dark" content="{{ __('admin/file_manager.create_folder') }}" placement="top">
<span @click.stop="() => {openInputBox('addFolder', node, data)}"><i
class="el-icon-circle-plus-outline"></i></span>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="重命名" placement="top">
<el-tooltip class="item" effect="dark" content="{{ __('admin/file_manager.rename') }}" placement="top">
<span v-if="node.level != 1" @click.stop="() => {openInputBox('renameFolder', node, data)}"><i
class="el-icon-edit"></i></span>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="删除" placement="top">
<el-tooltip class="item" effect="dark" content="{{ __('common.delete') }}" placement="top">
<span v-if="node.level != 1" @click.stop="() => {deleteFolder(node, data)}"><i
class="el-icon-delete"></i></span>
</el-tooltip>
@ -54,18 +57,18 @@
<div class="filemanager-content" v-loading="loading" element-loading-background="rgba(255, 255, 255, 0.5)">
<div class="content-head">
<div class="left d-flex">
<el-button class="me-5" size="small" icon="el-icon-check" type="primary" @click="fileChecked" :disabled="!!!selectImageIndex.length">选择</el-button>
<el-button class="me-5" size="small" icon="el-icon-check" type="primary" @click="fileChecked" :disabled="!!!selectImageIndex.length">{{ __('admin/builder.modules_choose') }}</el-button>
<el-link :underline="false" :disabled="!!!selectImageIndex.length" icon="el-icon-download"
@click="downloadImages">下载</el-link>
@click="downloadImages">{{ __('admin/file_manager.download') }}</el-link>
<el-link :underline="false" :disabled="!!!selectImageIndex.length" @click="deleteFile"
icon="el-icon-delete">删除</el-link>
icon="el-icon-delete">{{ __('common.delete') }}</el-link>
<el-link :underline="false" :disabled="selectImageIndex.length == 1 ? false : true"
@click="openInputBox('image')" icon="el-icon-edit">重命名</el-link>
@click="openInputBox('image')" icon="el-icon-edit">{{ __('admin/file_manager.rename') }}</el-link>
<el-link :underline="false" :disabled="!!!images.length && !!!selectImageIndex.length"
@click="selectAll()" icon="el-icon-finished">全选</el-link>
@click="selectAll()" icon="el-icon-finished">{{ __('common.select_all') }}</el-link>
</div>
<div class="right">
<el-button size="small" plain type="primary" @click="openUploadFile" icon="el-icon-upload2">上传文件</el-button>
<el-button size="small" plain type="primary" @click="openUploadFile" icon="el-icon-upload2">{{ __('admin/file_manager.upload_files') }}</el-button>
</div>
</div>
<div v-if="images.length" class="content-center"
@ -79,7 +82,7 @@
</div>
</div>
</div>
<el-empty v-else description="没有文件"></el-empty>
<el-empty v-else description="{{ __('admin/file_manager.no_file') }}"></el-empty>
<div class="content-footer">
<div class="right"></div>
<div class="pagination-wrap">
@ -104,15 +107,15 @@
</div>
</div>
<el-dialog title="上传文件" top="12vh" :visible.sync="uploadFileDialog.show" width="500px"
<el-dialog title="{{ __('admin/file_manager.upload_files') }}" top="12vh" :visible.sync="uploadFileDialog.show" width="500px"
@close="uploadFileDialogClose" custom-class="upload-wrap">
<el-upload class="photos-upload" target="photos-upload" id="photos-upload" element-loading-text="图片上传中..."
<el-upload class="photos-upload" target="photos-upload" id="photos-upload" element-loading-text="{{ __('admin/file_manager.image_uploading') }}..."
element-loading-background="rgba(0, 0, 0, 0.6)" drag action="" :show-file-list="false"
accept=".jpg,.jpeg,.png,.JPG,.JPEG,.PNG,.mp4,.MP4" :before-upload="beforePhotoUpload"
:on-success="handlePhotoSuccess" :on-change="handleUploadChange" :http-request="uploadFile"
:multiple="true">
<i class="el-icon-upload"></i>
<div class="el-upload__text">点击上传,或将图片拖到此处</div>
<div class="el-upload__text">{{ __('admin/file_manager.click_upload') }}</div>
</el-upload>
<div class="upload-image">
<div v-for="image, index in uploadFileDialog.images" :key="index" class="list">
@ -127,6 +130,9 @@
</div>
<script>
@if (locale() != 'zh_cn')
ELEMENT.locale(ELEMENT.lang['{{ locale() }}'])
@endif
var callback = null;
var app = new Vue({
@ -146,7 +152,7 @@
selectImageIndex: [],
treeData: [{
name: '图片空间',
name: '{{ __('admin/file_manager.picture_space') }}',
path: '/',
children: @json($directories)
}],

View File

@ -58,10 +58,6 @@
<tr v-for="language, index in rmaReasons" :key="index">
<td>@{{ language.id }}</td>
<td>@{{ language.name }}</td>
<td>
<span v-if="language.status" class="text-success">{{ __('common.enable') }}</span>
<span v-else class="text-secondary">{{ __('common.disable') }}</span>
</td>
<td class="text-end">
<button class="btn btn-outline-secondary btn-sm" @click="checkedCreate('edit', index)">{{ __('common.edit') }}</button>
<button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteCustomer(language.id, index)">{{ __('common.delete') }}</button>
@ -69,8 +65,6 @@
</tr>
</tbody>
</table>
{{-- {{ $languages->links('admin::vendor/pagination/bootstrap-4') }} --}}
</div>
<el-dialog title="{{ __('admin/common.rma_reasons_index') }}" :visible.sync="dialog.show" width="500px"
@ -140,11 +134,17 @@
this.dialog.form = {
id: tax.id,
name: tax.name,
name: tax.names,
}
}
},
loadData() {
$http.get(`rma_reasons?page=${this.page}`).then((res) => {
this.rmaReasons = res.data.rmaReasons;
})
},
statusChange(e, index) {
const id = this.rmaReasons[index].id;
@ -160,17 +160,13 @@
this.$refs[form].validate((valid) => {
if (!valid) {
this.$message.error('请检查表单是否填写正确');
this.$message.error('{{ __('common.error_form') }}');
return;
}
$http[type](url, this.dialog.form).then((res) => {
this.$message.success(res.message);
if (this.dialog.type == 'add') {
this.rmaReasons.push(res.data)
} else {
this.rmaReasons[this.dialog.index] = res.data
}
this.loadData();
this.dialog.show = false
})
@ -179,12 +175,12 @@
deleteCustomer(id, index) {
const self = this;
this.$confirm('确定要删除语言吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
this.$confirm('{{ __('common.confirm_delete') }}', '{{ __('common.text_hint') }}', {
confirmButtonText: '{{ __('common.confirm') }}',
cancelButtonText: '{{ __('common.cancel') }}',
type: 'warning'
}).then(() => {
$http.delete('rmaReasons/' + id).then((res) => {
$http.delete('rma_reasons/' + id).then((res) => {
this.$message.success(res.message);
self.rmaReasons.splice(index, 1)
})
@ -194,6 +190,7 @@
closeCustomersDialog(form) {
this.$refs[form].resetFields();
Object.keys(this.dialog.form).forEach(key => this.dialog.form[key] = '')
this.dialog.form.name = {};
this.dialog.show = false
}
}

View File

@ -124,8 +124,8 @@
},
rules: {
title: [{required: true,message: '请输入税类名称',trigger: 'blur'}, ],
description: [{required: true,message: '请输入描述',trigger: 'blur'}, ],
title: [{required: true,message: "{{ __('common.error_required', ['name' => __('admin/region.name')])}}",trigger: 'blur'}, ],
description: [{required: true,message: '{{ __('common.error_required', ['name' => __('admin/region.describe')])}}',trigger: 'blur'}, ],
}
},

View File

@ -96,7 +96,7 @@
source: {
all_tax_rates: @json($all_tax_rates ?? []),
regions: @json($regions ?? []),
types: [{value:'percent', name: '百分比'}, {value:'flat', name: '固定税率'}]
types: [{value:'percent', name: '{{ __('admin/tax_rate.percentage') }}'}, {value:'flat', name: '{{ __('admin/tax_rate.fixed_tax_rate') }}'}]
},
dialog: {
@ -113,8 +113,8 @@
},
rules: {
name: [{required: true,message: '请输入税种',trigger: 'blur'}, ],
rate: [{required: true,message: '请输入税率',trigger: 'blur'}, ],
name: [{required: true,message: '{{ __('common.error_required', ['name' => __('admin/tax_rate.tax_rate.tax')])}}',trigger: 'blur'}, ],
rate: [{required: true,message: '{{ __('common.error_required', ['name' => __('admin/tax_rate.tax_rate')])}}',trigger: 'blur'}, ],
}
},
@ -149,7 +149,7 @@
this.$refs[form].validate((valid) => {
if (!valid) {
this.$message.error('请检查表单是否填写正确');
this.$message.error('{{ __('common.error_form') }}');
return;
}
@ -168,9 +168,9 @@
deleteCustomer(id, index) {
const self = this;
this.$confirm('确定要删除税类吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
this.$confirm('{{ __('common.confirm_delete') }}', '{{ __('common.text_hint') }}', {
confirmButtonText: '{{ __('common.confirm') }}',
cancelButtonText: '{{ __('common.cancel') }}',
type: 'warning'
}).then(() => {
$http.delete('tax_rates/' + id).then((res) => {

View File

@ -16,5 +16,6 @@ return [
'brands_create' => 'Create',
'brands_show' => 'Detail',
'brands_update' => 'Edit',
'brands_delete' => 'Delete'
'brands_delete' => 'Delete',
'error_upload' => 'Please upload icon'
];

View File

@ -17,4 +17,12 @@ return [
'directory_already_exist' => 'The directory not exist!',
'directory_not_empty' => 'The directory not empty!',
'target_not_exist' => 'The target file/directory not exist!',
'create_folder' => 'Create folder',
'rename' => 'Rename',
'download' => 'Download',
'upload_files' => 'Upload Files',
'click_upload' => 'Click upload, or drag image here',
'image_uploading' => 'Image Uploading',
'no_file' => 'No File',
'picture_space' => 'Picture Space',
];

View File

@ -16,6 +16,8 @@ return [
'tax_rate' => 'Tax Rate',
'type' => 'Type',
'area' => 'Area',
'percentage' => 'Percentage',
'fixed_tax_rate' => 'Fixed Tax Rate',
'tax_rates_index' => 'Index',
'tax_rates_create' => 'Create',
'tax_rates_show' => 'Detail',

View File

@ -16,5 +16,6 @@ return [
'brands_create' => '创建品牌',
'brands_show' => '品牌详情',
'brands_update' => '更新品牌',
'brands_delete' => '删除品牌'
'brands_delete' => '删除品牌',
'error_upload' => '请上传图标'
];

View File

@ -17,4 +17,12 @@ return [
'directory_already_exist' => '目录已存在',
'directory_not_empty' => '该目录不为空',
'target_not_exist' => '原始文件或者文件夹不存在',
'create_folder' => '创建文件夹',
'rename' => '重命名',
'download' => '下载',
'upload_files' => '上传文件',
'click_upload' => '点击上传,或将图片拖到此处',
'image_uploading' => '图片上传中',
'no_file' => '没有文件',
'picture_space' => '图片空间',
];

View File

@ -16,6 +16,8 @@ return [
'tax_rate' => '税率',
'type' => '类型',
'area' => '区域',
'percentage' => '百分比',
'fixed_tax_rate' => '固定税率',
'tax_rates_index' => '税率列表',
'tax_rates_create' => '创建税率',
'tax_rates_show' => '税率详情',

View File

@ -10,9 +10,9 @@
<div class="container" id="address-app">
<x-shop-breadcrumb type="rma" value="{{ $rma->id }}" />
<div class="row">
<x-shop-sidebar/>
<x-shop-sidebar />
<div class="col-12 col-md-9">
<div class="card h-min-600">
@ -20,7 +20,66 @@
<h5 class="card-title">{{ __('shop/account.rma.rma_info.index') }}</h5>
</div>
<div class="card-body h-600">
{{-- {{ dd($rma) }} --}}
<div class="bg-light rounded-3 p-3 mb-4" style="background: #f6f9fc;">
<div class="d-flex align-items-center">
<div class="left wh-70">
<img src="{{ $orderProduct->image }}" class="img-fluid">
</div>
<div class="right ms-3">
<div class="name mb-2 fw-bold fs-5">{{ $orderProduct->name }}</div>
<div class="price">{{ $orderProduct->price }} x {{ $orderProduct->quantity }}</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 mb-4">
<label class="form-label">{{ __('shop/account.rma.rma_form.service_type') }}</label>
@foreach ($types as $key => $item)
@if ($key == $rma->type)
<div>{{ $item}}</div>
@endif
@endforeach
</div>
<div class="col-sm-6 mb-4">
<label class="form-label">{{ __('shop/account.rma.rma_form.return_quantity') }}</label>
<div>{{ $rma->quantity }}</div>
</div>
<div class="col-sm-6 mb-4">
<label class="form-label">{{ __('shop/account.rma.rma_form.unpacked') }}</label>
<div>
@if ($rma->opened)
{{ __('common.yes') }}
@else
{{ __('common.no') }}
@endif
</div>
</div>
<div class="col-sm-6 mb-4">
<label class="form-label">{{ __('shop/account.rma.creation_time') }}</label>
<div>
{{ $rma->created_at }}
</div>
</div>
<div class="col-sm-6 mb-4">
<label class="form-label">{{ __('shop/account.rma.rma_form.return_reason') }}</label>
<div>
@foreach ($reasons as $item)
@if ($rma->rma_reason_id == $item['id'])
{{$item['name']}}
@endif
@endforeach
</div>
</div>
<div class="col-sm-6 mb-4">
<label class="form-label">{{ __('shop/account.rma.rma_form.remark') }}</label>
<div>{{$rma->comment}}</div>
</div>
</div>
</div>
</div>
</div>
@ -29,5 +88,4 @@
@endsection
@push('add-scripts')
@endpush