语言管理

This commit is contained in:
pushuo 2022-08-05 11:53:41 +08:00
parent 9f4ebf7ffe
commit 72b0ca6640
2 changed files with 152 additions and 106 deletions

View File

@ -1,80 +0,0 @@
@extends('admin::layouts.master')
@section('title', '货币管理')
@section('content')
<div id="currency-app-form" class="card">
<div class="card-body">
<form action="{{ admin_route('currencies.store') }}" method="post">
@csrf
<div class="form-group">
<label class="form-label" id="name">名称</label>
<input type="input" name="name" value="{{ old('name') }}" class="form-control" placeholder="名称">
@error('name')
<x-admin::form.error :message="$message" />
@enderror
</div>
<div class="form-group">
<label class="form-label" id="code">编码</label>
<input type="input" name="code" value="{{ old('code') }}" class="form-control" placeholder="编码">
@error('code')
<x-admin::form.error :message="$message" />
@enderror
</div>
<div class="form-group">
<label class="form-label" id="symbol_left">左符号</label>
<input type="input" name="symbol_left" value="{{ old('symbol_left') }}" class="form-control"
placeholder="左符号">
@error('symbol_left')
<x-admin::form.error :message="$message" />
@enderror
</div>
<div class="form-group">
<label class="form-label" id="symbol_right">右符号</label>
<input type="input" name="symbol_right" value="{{ old('symbol_right') }}" class="form-control"
placeholder="右符号">
@error('symbol_right')
<x-admin::form.error :message="$message" />
@enderror
</div>
<div class="form-group">
<label class="form-label" id="decimal_place">小数位数</label>
<input type="input" name="decimal_place" value="{{ old('decimal_place') }}" class="form-control"
placeholder="小数位数">
@error('decimal_place')
<x-admin::form.error :message="$message" />
@enderror
</div>
<div class="form-group">
<label class="form-label" id="value">汇率值</label>
<input type="input" name="value" value="{{ old('value') }}" class="form-control" placeholder="汇率值">
@error('value')
<x-admin::form.error :message="$message" />
@enderror
</div>
<div class="form-group">
<label class="form-label" id="status">状态</label>
<input type="input" name="status" class="form-control" placeholder="状态">
@error('status')
<x-admin::form.error :message="$message" />
@enderror
</div>
@if (session('error'))
<div class="alert alert-success">
{{ session('error') }}
</div>
@endif
<button type="submit" class="btn btn-primary mb-4">确定</button>
</form>
</div>
</div>
@endsection

View File

@ -1,12 +1,12 @@
@extends('admin::layouts.master')
@section('title', '货币管理')
@section('title', '语言管理')
@section('content')
<div id="customer-app" class="card">
<div class="card-body">
<div class="d-flex justify-content-between my-4">
<a href="{{ admin_route('languages.create') }}" class="btn btn-primary">创建</a>
<div id="tax-classes-app" class="card" v-cloak>
<div class="card-body h-min-600">
<div class="d-flex justify-content-between mb-4">
<button type="button" class="btn btn-primary" @click="checkedCreate('add', null)">添加</button>
</div>
<table class="table">
<thead>
@ -14,33 +14,159 @@
<th>#</th>
<th>名称</th>
<th>编码</th>
<th>货币左符号</th>
<th>货币右符号</th>
<th>小数位数</th>
<th>汇率值</th>
<th>图标</th>
<th>排序</th>
<th>状态</th>
<th>操作</th>
<th class="text-end">操作</th>
</tr>
</thead>
<tbody>
@foreach ($languages as $currency)
<tr>
<td>{{ $currency['id'] }}</td>
<td>{{ $currency['name'] }}</td>
<td>{{ $currency['code'] }}</td>
<td>{{ $currency['symbol_left'] }}</td>
<td>{{ $currency['symbol_right'] }}</td>
<td>{{ $currency['decimal_place'] }}</td>
<td>{{ $currency['value'] }}</td>
<td>{{ $currency['status'] }}</td>
<td>
<a class="btn btn-outline-secondary btn-sm"
href="{{ admin_route('languages.edit', [$currency['id']]) }}">编辑</a>
</td>
</tr>
@endforeach
<tr v-for="language, index in languages" :key="index">
<td>@{{ language.id }}</td>
<td>@{{ language.name }}</td>
<td>@{{ language.code }}</td>
<td>@{{ language.image }}</td>
<td>@{{ language.sort_order }}</td>
<td>@{{ language.status }}</td>
<td class="text-end">
<button class="btn btn-outline-secondary btn-sm" @click="checkedCreate('edit', index)">编辑</button>
<button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteCustomer(language.id, index)">删除</button>
</td>
</tr>
</tbody>
</table>
{{-- {{ $languages->links('admin::vendor/pagination/bootstrap-4') }} --}}
</div>
<el-dialog title="税率" :visible.sync="dialog.show" width="500px"
@close="closeCustomersDialog('form')" :close-on-click-modal="false">
<el-form ref="form" :rules="rules" :model="dialog.form" label-width="100px">
<el-form-item label="code" prop="name">
<el-input v-model="dialog.form.name" placeholder="code"></el-input>
</el-form-item>
<el-form-item label="编码" prop="code">
<el-input v-model="dialog.form.code" placeholder="编码"></el-input>
</el-form-item>
<el-form-item label="图标" prop="image">
<vue-image v-model="dialog.form.image"></vue-image>
</el-form-item>
<el-form-item label="排序">
<el-input v-model="dialog.form.sort_order" placeholder="排序"></el-input>
</el-form-item>
<el-form-item label=" 状态">
<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')">保存</el-button>
<el-button @click="closeCustomersDialog('form')">取消</el-button>
</el-form-item>
</el-form>
</el-dialog>
</div>
@endsection
@push('footer')
@include('admin::shared.vue-image')
<script>
new Vue({
el: '#tax-classes-app',
data: {
languages: @json($languages ?? []),
dialog: {
show: false,
index: null,
type: 'add',
form: {
id: null,
name: '',
code: '',
image: '',
sort_order: '',
status: 1,
},
},
rules: {
name: [{required: true,message: '请输入名称',trigger: 'blur'}, ],
code: [{required: true,message: '请输入编码',trigger: 'blur'}, ],
image: [{required: true,message: '请选择图标',trigger: 'blur'}, ],
}
},
methods: {
checkedCreate(type, index) {
this.dialog.show = true
this.dialog.type = type
this.dialog.index = index
if (type == 'edit') {
let tax = this.languages[index];
this.dialog.form = {
id: tax.id,
name: tax.name,
code: tax.code,
image: tax.image,
sort_order: tax.sort_order,
status: tax.status,
}
}
},
addFormSubmit(form) {
const self = this;
const type = this.dialog.type == 'add' ? 'post' : 'put';
const url = this.dialog.type == 'add' ? 'languages' : 'languages/' + this.dialog.form.id;
this.$refs[form].validate((valid) => {
if (!valid) {
this.$message.error('请检查表单是否填写正确');
return;
}
$http[type](url, this.dialog.form).then((res) => {
this.$message.success(res.message);
if (this.dialog.type == 'add') {
this.languages.push(res.data)
} else {
this.languages[this.dialog.index] = res.data
}
this.dialog.show = false
})
});
},
deleteCustomer(id, index) {
const self = this;
this.$confirm('确定要删除语言码?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$http.delete('languages/' + id).then((res) => {
this.$message.success(res.message);
self.languages.splice(index, 1)
})
}).catch(()=>{})
},
closeCustomersDialog(form) {
Object.keys(this.dialog.form).forEach(key => this.dialog.form[key] = '')
this.dialog.show = false
this.$refs[form].resetFields();
}
}
})
</script>
@endpush