wip
This commit is contained in:
parent
c8167099ef
commit
8677bae4f4
|
|
@ -33,8 +33,6 @@ class TaxClassController extends Controller
|
|||
]
|
||||
];
|
||||
|
||||
dd($data);
|
||||
|
||||
return view('admin::pages.tax_classes.index', $data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,304 +0,0 @@
|
|||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title', '顾客管理')
|
||||
|
||||
@section('content')
|
||||
<div id="customer-app-form" class="card" v-cloak>
|
||||
<div class="card-body">
|
||||
<el-form :model="form" :rules="rules" ref="form" label-width="100px">
|
||||
<el-tabs v-model="customerTab">
|
||||
<el-tab-pane label="用户信息" name="customer">
|
||||
<div class="form-max-w">
|
||||
<el-form-item label="用户名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="用户名"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" placeholder="邮箱"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="form.password" placeholder="留空则保持原密码不变"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户组">
|
||||
<el-select v-model="form.customer_group_id" placeholder="请选择">
|
||||
<el-option v-for="item in source.customer_group" :key="item.id" :label="item.description.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm('form')">提交</el-button>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="地址管理" name="address" v-if="form.id">
|
||||
<button class="btn btn-primary mb-3" type="button" @click="editAddress">添加地址</button>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>名称</th>
|
||||
<th>电话</th>
|
||||
<th>注册来源</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-if="addresses.length">
|
||||
<tr v-for="address, index in addresses" :key="index">
|
||||
<td>@{{ index }}</td>
|
||||
<td>@{{ address.name }}</td>
|
||||
<td>@{{ address.phone }}</td>
|
||||
<td>222</td>
|
||||
<td>222</td>
|
||||
<td>
|
||||
<button class="btn btn-outline-secondary btn-sm" type="button"
|
||||
@click="editAddress(index)">编辑</button>
|
||||
<button class="btn btn-outline-danger btn-sm ml-1" type="button"
|
||||
@click="deleteAddress(address.id, index)">删除</button>
|
||||
</td>
|
||||
</tbody>
|
||||
<tbody v-else>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center">
|
||||
<span class="me-2">当前账号无地址</span>
|
||||
<el-link type="primary" @click="editAddress">新增地址</el-link>
|
||||
</td>
|
||||
</tbody>
|
||||
</table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<el-dialog title="编辑地址" :visible.sync="dialogAddress.show" width="600px"
|
||||
@close="closeAddressDialog('addressForm')">
|
||||
<el-form ref="addressForm" :rules="addressRules" :model="dialogAddress.form" label-width="100px">
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="dialogAddress.form.name"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="联系电话" prop="phone">
|
||||
<el-input maxlength="11" v-model="dialogAddress.form.phone"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="地址" required>
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<el-form-item>
|
||||
<el-select v-model="dialogAddress.form.country_id" filterable placeholder="选择国家" @change="countryChange">
|
||||
<el-option v-for="item in source.countries" :key="item.id" :label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<el-form-item prop="zone_id">
|
||||
<el-select v-model="dialogAddress.form.zone_id" filterable placeholder="选择省份">
|
||||
<el-option v-for="item in source.zones" :key="item.id" :label="item.name"
|
||||
:value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<el-form-item prop="city_id">
|
||||
<el-input v-model="dialogAddress.form.city_id" placeholder="输入 city"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="邮编" prop="zipcode">
|
||||
<el-input v-model="dialogAddress.form.zipcode"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="详细地址 1" prop="address_1">
|
||||
<el-input v-model="dialogAddress.form.address_1"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="详细地址 2">
|
||||
<el-input v-model="dialogAddress.form.address_2"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="addressFormSubmit('addressForm')">保存</el-button>
|
||||
<el-button @click="closeAddressDialog('addressForm')">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-dialog>
|
||||
</div>
|
||||
{{-- {{ admin_route($customer->id ? 'customers.update' : 'customers.store', $customer) }} --}}
|
||||
@endsection
|
||||
|
||||
@push('footer')
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#customer-app-form',
|
||||
data: {
|
||||
customerTab: 'customer',
|
||||
form: {
|
||||
id: @json($customer['id'] ?? null),
|
||||
name: @json($customer['name']),
|
||||
email: @json($customer['email']),
|
||||
password: '',
|
||||
customer_group_id: 1,
|
||||
status: @json($customer['status']) * 1,
|
||||
},
|
||||
|
||||
addresses: @json($customer['addresses'] ?? []),
|
||||
|
||||
source: {
|
||||
customer_group: @json($customer_groups ?? []),
|
||||
countries: @json($countries ?? []),
|
||||
zones: []
|
||||
},
|
||||
|
||||
dialogAddress: {
|
||||
show: false,
|
||||
index: null,
|
||||
form: {
|
||||
name: '',
|
||||
phone: '',
|
||||
country_id: @json(setting('country_id')) * 1,
|
||||
zipcode: '',
|
||||
zone_id: '',
|
||||
city_id: '',
|
||||
address_1: '',
|
||||
address_2: '',
|
||||
}
|
||||
},
|
||||
|
||||
rules: {
|
||||
name: [{required: true, message: '请输入用户名', trigger: 'blur'}, ],
|
||||
email: [
|
||||
{required: true, message: '请输入邮箱', trigger: 'blur'},
|
||||
{type: 'email', message: '请输入正确邮箱格式' ,trigger: 'blur'},
|
||||
],
|
||||
},
|
||||
|
||||
addressRules: {
|
||||
name: [{
|
||||
required: true,
|
||||
message: '请输入姓名',
|
||||
trigger: 'blur'
|
||||
}, ],
|
||||
phone: [{
|
||||
required: true,
|
||||
message: '请输入联系电话',
|
||||
trigger: 'blur'
|
||||
}, ],
|
||||
address_1: [{
|
||||
required: true,
|
||||
message: '请输入详细地址 1',
|
||||
trigger: 'blur'
|
||||
}, ],
|
||||
zone_id: [{
|
||||
required: true,
|
||||
message: '请选择省份',
|
||||
trigger: 'blur'
|
||||
}, ],
|
||||
city_id: [{
|
||||
required: true,
|
||||
message: '请填写 city',
|
||||
trigger: 'blur'
|
||||
}, ],
|
||||
}
|
||||
},
|
||||
|
||||
// 在挂载开始之前被调用:相关的 render 函数首次被调用
|
||||
beforeMount() {
|
||||
this.countryChange(this.dialogAddress.form.country_id);
|
||||
},
|
||||
|
||||
methods: {
|
||||
submitForm(form) {
|
||||
const self = this;
|
||||
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (!valid) {
|
||||
this.$message.error('请检查表单是否填写正确');
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: `/admin/customers/{{ $customer['id'] }}`,
|
||||
type: 'put',
|
||||
data: self.form,
|
||||
success: function(res) {
|
||||
self.$message.success(res.message);
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
editAddress(index) {
|
||||
if (typeof index == 'number') {
|
||||
this.dialogAddress.index = index;
|
||||
this.dialogAddress.form = JSON.parse(JSON.stringify(this.addresses[index]))
|
||||
}
|
||||
|
||||
this.dialogAddress.show = true
|
||||
},
|
||||
|
||||
deleteAddress(id, index) {
|
||||
const self = this;
|
||||
|
||||
$.ajax({
|
||||
url: `/admin/customers/{{ $customer['id'] }}/addresses/${id}`,
|
||||
type: 'delete',
|
||||
success: function(res) {
|
||||
self.$message.success(res.message);
|
||||
self.addresses.splice(index, 1)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
addressFormSubmit(form) {
|
||||
const self = this;
|
||||
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (!valid) {
|
||||
this.$message.error('请检查表单是否填写正确');
|
||||
return;
|
||||
}
|
||||
|
||||
const type = this.dialogAddress.form.id ? 'put' : 'post';
|
||||
|
||||
$.ajax({
|
||||
url: `/admin/customers/{{ $customer['id'] }}/addresses${type == 'put' ? '/' + this.dialogAddress.form.id : ''}`,
|
||||
data: self.dialogAddress.form,
|
||||
type: type,
|
||||
success: function(res) {
|
||||
if (type == 'post') {
|
||||
self.addresses.push(res.data)
|
||||
} else {
|
||||
self.addresses[self.dialogAddress.index] = res.data
|
||||
}
|
||||
self.$message.success(res.message);
|
||||
self.$refs[form].resetFields();
|
||||
self.dialogAddress.show = false
|
||||
self.dialogAddress.index = null;
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
closeAddressDialog(form) {
|
||||
this.$refs[form].resetFields();
|
||||
this.dialogAddress.show = false
|
||||
this.dialogAddress.index = null;
|
||||
},
|
||||
|
||||
countryChange(e) {
|
||||
const self = this;
|
||||
|
||||
$.ajax({
|
||||
url: `/admin/countries/${e}/zones`,
|
||||
type: 'get',
|
||||
success: function(res) {
|
||||
self.source.zones = res.data.zones;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
addCustomersFormSubmit(form) {
|
||||
const self = this;
|
||||
const type = this.dialog.type == 'add' ? 'post' : 'put';
|
||||
const url = this.dialog.type == 'add' ? '/admin/customer_groups' : '/admin/customer_groups/' + this.dialog.form.id;
|
||||
const url = this.dialog.type == 'add' ? 'customer_groups' : 'customer_groups/' + this.dialog.form.id;
|
||||
|
||||
this.$refs[form].validate((valid) => {
|
||||
if (!valid) {
|
||||
|
|
@ -187,7 +187,7 @@
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$http.delete('/admin/customer_groups/' + id).then((res) => {
|
||||
$http.delete('customer_groups/' + id).then((res) => {
|
||||
this.$message.success(res.message);
|
||||
self.customer_groups.splice(index, 1)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,192 @@
|
|||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title', '税类设置')
|
||||
|
||||
@section('content')
|
||||
@foreach($tax_classes as $tax_class)
|
||||
@dump($tax_class->title)
|
||||
@endforeach
|
||||
<div id="tax-classes-app" class="card" v-cloak>
|
||||
<div class="card-body">
|
||||
<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>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>名称</th>
|
||||
<th >操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="tax, index in tax_classes" :key="index">
|
||||
<td>@{{ tax.id }}</td>
|
||||
<td>@{{ tax.title }}</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(group.id, index)">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{-- {{ $tax_classes->links('admin::vendor/pagination/bootstrap-4') }} --}}
|
||||
</div>
|
||||
|
||||
<el-dialog title="创建税费" :visible.sync="dialog.show" width="700px"
|
||||
@close="closeCustomersDialog('form')" :close-on-click-modal="false">
|
||||
|
||||
<el-form ref="form" :rules="rules" :model="dialog.form" label-width="100px">
|
||||
<el-form-item label="税类名称" prop="title">
|
||||
<el-input v-model="dialog.form.title" placeholder="税类名称"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="dialog.form.description" placeholder="描述"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="税率">
|
||||
<table class="table table-bordered" style="line-height: 1.6;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>税率</th>
|
||||
<th>基于</th>
|
||||
<th>优先级</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="rates, index in dialog.form.rates" :key="index">
|
||||
<td>
|
||||
<el-select v-model="rates.tax_rate_id" size="mini" placeholder="请选择">
|
||||
<el-option v-for="tax in source.all_tax_rates" :key="tax.id" :label="tax.name" :value="tax.id"></el-option>
|
||||
</el-select>
|
||||
</td>
|
||||
<td>
|
||||
<el-select v-model="rates.based" size="mini" placeholder="请选择">
|
||||
<el-option v-for="base in source.bases" :key="base" :label="base" :value="base"></el-option>
|
||||
</el-select>
|
||||
</td>
|
||||
<td width="80px"><el-input v-model="rates.priority" size="mini" placeholder="优先级"></el-input></td>
|
||||
<td>
|
||||
<button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteRates(index)">删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<el-button type="primary" icon="el-icon-plus" size="small" plain @click="addRates">添加税率</el-button>
|
||||
</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')
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#tax-classes-app',
|
||||
|
||||
data: {
|
||||
tax_classes: @json($tax_classes ?? []),
|
||||
|
||||
source: {
|
||||
all_tax_rates: @json($all_tax_rates ?? []),
|
||||
bases: @json($bases ?? []),
|
||||
},
|
||||
|
||||
dialog: {
|
||||
show: false,
|
||||
index: null,
|
||||
type: 'add',
|
||||
form: {
|
||||
id: null,
|
||||
title: '',
|
||||
description: '',
|
||||
rates: [],
|
||||
},
|
||||
},
|
||||
|
||||
rules: {
|
||||
title: [{required: true,message: '请输入税类名称',trigger: 'blur'}, ],
|
||||
description: [{required: true,message: '请输入描述',trigger: 'blur'}, ],
|
||||
}
|
||||
},
|
||||
|
||||
beforeMount() {
|
||||
// this.source.languages.forEach(e => {
|
||||
// this.$set(this.dialog.form.name, e.code, '')
|
||||
// this.$set(this.dialog.form.description, e.code, '')
|
||||
// })
|
||||
},
|
||||
|
||||
methods: {
|
||||
checkedCreate(type, index) {
|
||||
this.dialog.show = true
|
||||
this.dialog.type = type
|
||||
|
||||
if (type == 'edit') {
|
||||
let tax = this.tax_classes[index];
|
||||
|
||||
this.dialog.form = {
|
||||
id: tax.id,
|
||||
title: tax.title,
|
||||
description: tax.description,
|
||||
rates: tax.rates,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addRates() {
|
||||
const tax_rate_id = this.source.all_tax_rates[0]?.id || 0;
|
||||
const based = this.source.bases[0] || '';
|
||||
|
||||
this.dialog.form.rates.push({tax_rate_id, based, priority: ''})
|
||||
},
|
||||
|
||||
deleteRates(index) {
|
||||
this.dialog.form.rates.splice(index, 1)
|
||||
},
|
||||
|
||||
addFormSubmit(form) {
|
||||
const self = this;
|
||||
const type = this.dialog.type == 'add' ? 'post' : 'put';
|
||||
const url = this.dialog.type == 'add' ? 'tax_classes' : 'tax_classes/' + 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);
|
||||
// this.tax_classes.push(res.data)
|
||||
// this.dialog.show = false
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
deleteCustomer(id, index) {
|
||||
const self = this;
|
||||
this.$confirm('确定要删除税类码?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
$http.delete('/admin/tax_classes/' + id).then((res) => {
|
||||
this.$message.success(res.message);
|
||||
self.tax_classes.splice(index, 1)
|
||||
})
|
||||
}).catch(()=>{})
|
||||
},
|
||||
|
||||
closeCustomersDialog(form) {
|
||||
Object.keys(this.dialog.form).forEach(key => this.dialog.form[key] = '')
|
||||
this.dialog.show = false
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
|
|
|||
Loading…
Reference in New Issue