优化:国家支持图标设置

This commit is contained in:
wuhui_zzw 2023-08-25 11:08:31 +08:00
parent 1dd22c3e02
commit 4032cfaaa1
4 changed files with 20 additions and 22 deletions

View File

@ -33,7 +33,7 @@ class CountryController extends Controller
public function store(Request $request)
{
$country = CountryRepo::create($request->only('name', 'code', 'sort_order', 'status'));
$country = CountryRepo::create($request->only('name', 'icon', 'code', 'sort_order', 'status'));
hook_action('admin.country.store.after', $country);
@ -42,7 +42,7 @@ class CountryController extends Controller
public function update(Request $request, int $id)
{
$country = CountryRepo::update($id, $request->only('name', 'code', 'sort_order', 'status'));
$country = CountryRepo::update($id, $request->only('name', 'icon', 'code', 'sort_order', 'status'));
hook_action('admin.country.store.after', $country);

View File

@ -18,7 +18,7 @@ class Country extends Base
{
use HasFactory;
protected $fillable = ['name', 'country_id', 'code', 'sort_order', 'status'];
protected $fillable = ['name','icon', 'country_id', 'code', 'sort_order', 'status'];
public function zones(): HasMany
{

View File

@ -26,6 +26,7 @@ class CountryRepo
{
return [
'name' => $data['name'] ?? '',
'icon' => $data['icon'] ?? '',
'code' => $data['code'] ?? '',
'sort_order' => (int) $data['sort_order'] ?? 0,
'status' => (bool) $data['status'] ?? 0,

View File

@ -14,6 +14,7 @@
<tr>
<th>ID</th>
<th>{{ __('common.name') }}</th>
<th>{{ __('currency.icon') }}</th>
<th>{{ __('currency.code') }}</th>
<th>{{ __('common.created_at') }}</th>
<th>{{ __('common.updated_at') }}</th>
@ -26,6 +27,11 @@
<tr v-for="country, index in country.data" :key="index">
<td>@{{ country.id }}</td>
<td>@{{ country.name }}</td>
<td>
<div class="wh-50 border d-flex justify-content-center rounded-2 align-items-center">
<img :src="thumbnail(country.icon)" class="img-fluid rounded-2">
</div>
</td>
<td>@{{ country.code }}</td>
<td>@{{ country.created_at }}</td>
<td>@{{ country.updated_at }}</td>
@ -48,26 +54,23 @@
:total="country.total"></el-pagination>
</div>
<el-dialog title="{{ __('admin/common.country') }}" :visible.sync="dialog.show" width="600px"
@close="closeCustomersDialog('form')" :close-on-click-modal="false">
<el-dialog title="{{ __('admin/common.country') }}" :visible.sync="dialog.show" width="600px" @close="closeCustomersDialog('form')" :close-on-click-modal="false">
<el-form ref="form" :rules="rules" :model="dialog.form" label-width="130px">
<el-form-item label="{{ __('admin/country.country_name') }}" prop="name">
<el-input v-model="dialog.form.name" placeholder="{{ __('admin/country.country_name') }}"></el-input>
</el-form-item>
<el-form-item label="{{ __('currency.icon') }}" prop="icon" required>
<vue-image v-model="dialog.form.icon"></vue-image>
</el-form-item>
<el-form-item label="{{ __('common.sort_order') }}">
<el-input v-model="dialog.form.sort_order" placeholder="{{ __('common.sort_order') }}"></el-input>
</el-form-item>
<el-form-item label="{{ __('currency.code') }}">
<el-input v-model="dialog.form.code" placeholder="{{ __('currency.code') }}"></el-input>
</el-form-item>
<el-form-item label="{{ __('common.status') }}">
<el-switch v-model="dialog.form.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item class="mt-5">
<el-button type="primary" @click="addFormSubmit('form')">{{ __('common.save') }}</el-button>
<el-button @click="closeCustomersDialog('form')">{{ __('common.cancel') }}</el-button>
@ -79,15 +82,12 @@
@push('footer')
@include('admin::shared.vue-image')
<script>
new Vue({
el: '#tax-classes-app',
data: {
country: @json($country ?? []),
page: 1,
dialog: {
show: false,
index: null,
@ -100,25 +100,26 @@
status: 1,
},
},
rules: {
name: [{required: true,message: '{{ __('common.error_required', ['name' => __('admin/country.country_name')]) }}',trigger: 'blur'}, ],
name: [
{required: true,message: '{{ __('common.error_required', ['name' => __('admin/country.country_name')]) }}',trigger: 'blur'},
],
icon: [
{required: true,message: '{{ __('admin/brand.error_upload') }}',trigger: 'blur'},
],
}
},
watch: {
page: function() {
this.loadData();
},
},
methods: {
loadData() {
$http.get(`countries?page=${this.page}`).then((res) => {
this.country = res.data.country;
})
},
checkedCreate(type, index) {
this.dialog.show = true
this.dialog.type = type
@ -128,7 +129,6 @@
this.dialog.form = JSON.parse(JSON.stringify(this.country.data[index]));
}
},
statusChange(e, index) {
const id = this.country.data[index].id;
@ -136,7 +136,6 @@
// layer.msg(res.message);
// })
},
addFormSubmit(form) {
const self = this;
const type = this.dialog.type == 'add' ? 'post' : 'put';
@ -161,7 +160,6 @@
})
});
},
deleteCustomer(id, index) {
const self = this;
this.$confirm('{{ __('common.confirm_delete') }}', '{{ __('common.text_hint') }}', {
@ -176,7 +174,6 @@
})
}).catch(()=>{})
},
closeCustomersDialog(form) {
this.$refs[form].resetFields();
Object.keys(this.dialog.form).forEach(key => this.dialog.form[key] = '')