后台订单详情

This commit is contained in:
pushuo 2022-07-06 16:29:50 +08:00
parent 5ebfc8a447
commit 70d01b7fa2
12 changed files with 172 additions and 377 deletions

View File

@ -29,6 +29,10 @@ class OrderController extends Controller
public function show(Request $request, Order $order)
{
dd($order);
$data = [
'order' => $order,
];
return view('admin::pages.orders.form', $data);
}
}

View File

@ -40,7 +40,7 @@ class Sidebar extends Component
}
if (Str::startsWith($routeName, ['admin.orders.'])) {
$this->addLink('订单列表', admin_route('orders.index'), 'fa fa-tachometer-alt', false);
$this->addLink('订单列表', admin_route('orders.index'), 'fa fa-tachometer-alt', true);
}
return view('admin::components.sidebar');

View File

@ -47,7 +47,7 @@ body {
.main-content > #content {
flex: 1;
padding: 1rem 1rem 4rem;
margin-top: 42px;
margin-top: 44px;
overflow-y: auto;
}
@media screen and (max-width: 991px) {
@ -62,8 +62,7 @@ body {
left: 190px;
z-index: 9;
right: 0;
height: 43px;
line-height: 43px;
height: 44px;
padding: 0 28px;
background-color: #fff;
border-bottom: 1px solid #f1f1f1;
@ -311,12 +310,17 @@ hr.horizontal.dark {
padding: 1rem 1rem 0.3rem;
background-color: #fff;
font-weight: bold;
font-size: 0.8rem;
border-bottom: 0 solid rgba(0, 0, 0, 0.125);
}
.card .card-header:first-child {
border-radius: 1rem 1rem 0 0;
}
.card .card-header .card-title {
margin-bottom: 0;
padding-left: 10px;
border-left: 3px solid #fd560f;
line-height: 1;
}
.card .card-body {
padding: 1rem;
}
@ -329,10 +333,8 @@ table.table thead th {
white-space: nowrap;
}
table.table td {
border-bottom: 0;
font-size: 0.8125rem;
vertical-align: middle;
border-top: 1px solid #edf2f9;
}
table.table.table-striped > tbody > tr:nth-of-type(odd) {
background: transparent;

View File

@ -6803,7 +6803,7 @@
--bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
--bs-body-font-family: var(--bs-font-sans-serif);
--bs-body-font-size: 1rem;
--bs-body-font-size: 0.92rem;
--bs-body-font-weight: 400;
--bs-body-line-height: 1.5;
--bs-body-color: #212529;
@ -6855,47 +6855,47 @@ h6, .h6, h5, .h5, h4, .h4, h3, .h3, h2, .h2, h1, .h1 {
}
h1, .h1 {
font-size: calc(1.375rem + 1.5vw);
font-size: calc(1.355rem + 1.26vw);
}
@media (min-width: 1200px) {
h1, .h1 {
font-size: 2.5rem;
font-size: 2.3rem;
}
}
h2, .h2 {
font-size: calc(1.325rem + 0.9vw);
font-size: calc(1.309rem + 0.708vw);
}
@media (min-width: 1200px) {
h2, .h2 {
font-size: 2rem;
font-size: 1.84rem;
}
}
h3, .h3 {
font-size: calc(1.3rem + 0.6vw);
font-size: calc(1.286rem + 0.432vw);
}
@media (min-width: 1200px) {
h3, .h3 {
font-size: 1.75rem;
font-size: 1.61rem;
}
}
h4, .h4 {
font-size: calc(1.275rem + 0.3vw);
font-size: calc(1.263rem + 0.156vw);
}
@media (min-width: 1200px) {
h4, .h4 {
font-size: 1.5rem;
font-size: 1.38rem;
}
}
h5, .h5 {
font-size: 1.25rem;
font-size: 1.15rem;
}
h6, .h6 {
font-size: 1rem;
font-size: 0.92rem;
}
p {
@ -7234,7 +7234,7 @@ progress {
}
.lead {
font-size: 1.25rem;
font-size: 1.15rem;
font-weight: 300;
}
@ -7328,7 +7328,7 @@ progress {
.blockquote {
margin-bottom: 1rem;
font-size: 1.25rem;
font-size: 1.15rem;
}
.blockquote > :last-child {
margin-bottom: 0;
@ -8715,7 +8715,7 @@ progress {
margin-bottom: 1rem;
color: #212529;
vertical-align: top;
border-color: #dee2e6;
border-color: #e9ecef;
}
.table > :not(caption) > * > * {
padding: 0.5rem 0.5rem;
@ -8916,13 +8916,13 @@ progress {
.col-form-label-lg {
padding-top: calc(0.5rem + 1px);
padding-bottom: calc(0.5rem + 1px);
font-size: 1.25rem;
font-size: 1.15rem;
}
.col-form-label-sm {
padding-top: calc(0.25rem + 1px);
padding-bottom: calc(0.25rem + 1px);
font-size: 0.875rem;
font-size: 0.805rem;
}
.form-text {
@ -8935,7 +8935,7 @@ progress {
display: block;
width: 100%;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-size: 0.92rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
@ -9076,7 +9076,7 @@ progress {
.form-control-sm {
min-height: calc(1.5em + 0.5rem + 2px);
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
font-size: 0.805rem;
border-radius: 0.2rem;
}
.form-control-sm::-webkit-file-upload-button {
@ -9101,7 +9101,7 @@ progress {
.form-control-lg {
min-height: calc(1.5em + 1rem + 2px);
padding: 0.5rem 1rem;
font-size: 1.25rem;
font-size: 1.15rem;
border-radius: 0.3rem;
}
.form-control-lg::-webkit-file-upload-button {
@ -9155,7 +9155,7 @@ textarea.form-control-lg {
width: 100%;
padding: 0.375rem 2.25rem 0.375rem 0.75rem;
-moz-padding-start: calc(0.75rem - 3px);
font-size: 1rem;
font-size: 0.92rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
@ -9197,7 +9197,7 @@ textarea.form-control-lg {
padding-top: 0.25rem;
padding-bottom: 0.25rem;
padding-left: 0.5rem;
font-size: 0.875rem;
font-size: 0.805rem;
border-radius: 0.2rem;
}
@ -9205,13 +9205,13 @@ textarea.form-control-lg {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
padding-left: 1rem;
font-size: 1.25rem;
font-size: 1.15rem;
border-radius: 0.3rem;
}
.form-check {
display: block;
min-height: 1.5rem;
min-height: 1.38rem;
padding-left: 1.7em;
margin-bottom: 0.125rem;
}
@ -9509,7 +9509,7 @@ textarea.form-control-lg {
display: flex;
align-items: center;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-size: 0.92rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
@ -9525,7 +9525,7 @@ textarea.form-control-lg {
.input-group-lg > .input-group-text,
.input-group-lg > .btn {
padding: 0.5rem 1rem;
font-size: 1.25rem;
font-size: 1.15rem;
border-radius: 0.3rem;
}
@ -9534,7 +9534,7 @@ textarea.form-control-lg {
.input-group-sm > .input-group-text,
.input-group-sm > .btn {
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
font-size: 0.805rem;
border-radius: 0.2rem;
}
@ -9575,7 +9575,7 @@ textarea.form-control-lg {
max-width: 100%;
padding: 0.25rem 0.5rem;
margin-top: 0.1rem;
font-size: 0.875rem;
font-size: 0.805rem;
color: #fff;
background-color: rgba(25, 135, 84, 0.9);
border-radius: 0;
@ -9664,7 +9664,7 @@ textarea.form-control-lg {
max-width: 100%;
padding: 0.25rem 0.5rem;
margin-top: 0.1rem;
font-size: 0.875rem;
font-size: 0.805rem;
color: #fff;
background-color: rgba(220, 53, 69, 0.9);
border-radius: 0;
@ -9752,7 +9752,7 @@ textarea.form-control-lg {
background-color: transparent;
border: 1px solid transparent;
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-size: 0.92rem;
border-radius: 0;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
@ -10227,13 +10227,13 @@ textarea.form-control-lg {
.btn-lg, .btn-group-lg > .btn {
padding: 0.5rem 1rem;
font-size: 1.25rem;
font-size: 1.15rem;
border-radius: 0.3rem;
}
.btn-sm, .btn-group-sm > .btn {
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
font-size: 0.805rem;
border-radius: 0.2rem;
}
@ -10305,7 +10305,7 @@ textarea.form-control-lg {
min-width: 10rem;
padding: 0.5rem 0;
margin: 0;
font-size: 1rem;
font-size: 0.92rem;
color: #212529;
text-align: left;
list-style: none;
@ -10539,7 +10539,7 @@ textarea.form-control-lg {
display: block;
padding: 0.5rem 1rem;
margin-bottom: 0;
font-size: 0.875rem;
font-size: 0.805rem;
color: #6c757d;
white-space: nowrap;
}
@ -10792,10 +10792,10 @@ textarea.form-control-lg {
justify-content: space-between;
}
.navbar-brand {
padding-top: 0.3125rem;
padding-bottom: 0.3125rem;
padding-top: 0.3275rem;
padding-bottom: 0.3275rem;
margin-right: 1rem;
font-size: 1.25rem;
font-size: 1.15rem;
white-space: nowrap;
}
.navbar-nav {
@ -10826,7 +10826,7 @@ textarea.form-control-lg {
.navbar-toggler {
padding: 0.25rem 0.75rem;
font-size: 1.25rem;
font-size: 1.15rem;
line-height: 1;
background-color: transparent;
border: 1px solid transparent;
@ -11412,7 +11412,7 @@ textarea.form-control-lg {
align-items: center;
width: 100%;
padding: 1rem 1.25rem;
font-size: 1rem;
font-size: 0.92rem;
color: #212529;
text-align: left;
background-color: #fff;
@ -11600,7 +11600,7 @@ textarea.form-control-lg {
.pagination-lg .page-link {
padding: 0.75rem 1.5rem;
font-size: 1.25rem;
font-size: 1.15rem;
}
.pagination-lg .page-item:first-child .page-link {
border-top-left-radius: 0.3rem;
@ -11613,7 +11613,7 @@ textarea.form-control-lg {
.pagination-sm .page-link {
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
font-size: 0.805rem;
}
.pagination-sm .page-item:first-child .page-link {
border-top-left-radius: 0.2rem;
@ -11759,7 +11759,7 @@ textarea.form-control-lg {
display: flex;
height: 1rem;
overflow: hidden;
font-size: 0.75rem;
font-size: 0.69rem;
background-color: #e9ecef;
border-radius: 0;
}
@ -12515,7 +12515,7 @@ textarea.form-control-lg {
word-spacing: normal;
white-space: normal;
line-break: auto;
font-size: 0.875rem;
font-size: 0.805rem;
word-wrap: break-word;
opacity: 0;
}
@ -12617,7 +12617,7 @@ textarea.form-control-lg {
word-spacing: normal;
white-space: normal;
line-break: auto;
font-size: 0.875rem;
font-size: 0.805rem;
word-wrap: break-word;
background-color: #fff;
background-clip: padding-box;
@ -12711,7 +12711,7 @@ textarea.form-control-lg {
.popover-header {
padding: 0.5rem 1rem;
margin-bottom: 0;
font-size: 1rem;
font-size: 0.92rem;
background-color: #f0f0f0;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
border-top-left-radius: calc(0.3rem - 1px);
@ -14336,27 +14336,27 @@ textarea.form-control-lg {
}
.fs-1 {
font-size: calc(1.375rem + 1.5vw) !important;
font-size: calc(1.355rem + 1.26vw) !important;
}
.fs-2 {
font-size: calc(1.325rem + 0.9vw) !important;
font-size: calc(1.309rem + 0.708vw) !important;
}
.fs-3 {
font-size: calc(1.3rem + 0.6vw) !important;
font-size: calc(1.286rem + 0.432vw) !important;
}
.fs-4 {
font-size: calc(1.275rem + 0.3vw) !important;
font-size: calc(1.263rem + 0.156vw) !important;
}
.fs-5 {
font-size: 1.25rem !important;
font-size: 1.15rem !important;
}
.fs-6 {
font-size: 1rem !important;
font-size: 0.92rem !important;
}
.fst-italic {
@ -17970,19 +17970,19 @@ textarea.form-control-lg {
}
@media (min-width: 1200px) {
.fs-1 {
font-size: 2.5rem !important;
font-size: 2.3rem !important;
}
.fs-2 {
font-size: 2rem !important;
font-size: 1.84rem !important;
}
.fs-3 {
font-size: 1.75rem !important;
font-size: 1.61rem !important;
}
.fs-4 {
font-size: 1.5rem !important;
font-size: 1.38rem !important;
}
}
@media print {

View File

@ -22,24 +22,26 @@ hr.horizontal.dark {
}
.card {
// box-shadow: 0 20px 27px 0 rgba(0, 0, 0, .05);
// box-shadow: 0 0.75rem 1.5rem rgb(18 38 63 / 3%);
box-shadow: rgba(0, 0, 0, .1) 0px 1px 4px 0px;
// border: 0 solid rgba(0,0,0,.125);
// border: 1px solid #edf2f9;
border: none;
// border-radius: 0.5rem;
.card-header {
padding: 1rem 1rem .3rem;
background-color: #fff;
font-weight: bold;
font-size: .8rem;
// font-size: .8rem;
border-bottom: 0 solid rgba(0,0,0,.125);
&:first-child {
border-radius: 1rem 1rem 0 0;
}
.card-title {
margin-bottom: 0;
padding-left: 10px;
border-left: 3px solid $primary;
line-height: 1;
}
}
.card-body {
@ -60,10 +62,10 @@ table.table {
}
td {
border-bottom: 0;
// border-bottom: 0;
font-size: .8125rem;
vertical-align: middle;
border-top: 1px solid #edf2f9;
// border-top: 1px solid #edf2f9;
}
&.table-striped>tbody>tr {

View File

@ -8,8 +8,6 @@
// @modified 2021-08-24 15:07:05
//
$main_color: #fd560f;
body {
// min-height: 100vh;
// background-color: #f9f9f9;
@ -45,7 +43,7 @@ body {
> #content {
flex: 1;
padding: 1rem 1rem 4rem;
margin-top: 42px;
margin-top: 44px;
overflow-y: auto;
@media screen and (max-width: 991px) {
@ -60,8 +58,7 @@ body {
left: 190px;
z-index: 9;
right: 0;
height: 43px;
line-height: 43px;
height: 44px;
padding: 0 28px;
background-color: #fff;
border-bottom: 1px solid #f1f1f1;
@ -116,7 +113,7 @@ body {
}
& ~ input:checked ~ .toggle-outside {
background-color: $main_color;
background-color: $primary;
.toggle-inside {
left: 23px;
@ -199,7 +196,7 @@ body.page-seller-product {
}
&:active {
color: $main_color;
color: $primary;
}
}
}

View File

@ -63,7 +63,7 @@
bottom: 0;
width: 100%;
height: 3px;
background-color: $main_color;
background-color: $primary;
}
}

View File

@ -39,7 +39,7 @@
&.active, &:hover {
a {
color: $main_color;
color: $primary;
background-color: #f4f4f4;
}
}
@ -53,7 +53,7 @@
width: 2px;
height: 100%;
z-index: 1;
background: $main_color;
background: $primary;
}
}
}

View File

@ -8,7 +8,7 @@
// @modified 2022-05-09 11:36:06
//
$main_color: #fd560f;
$primary: #fd560f;
@import 'global';
@import 'vue';

View File

@ -10,6 +10,7 @@
$primary: #fd560f;
$border-radius: 0;
$font-size-base: 0.92rem;
$form-check-input-width: 1.2em;
$form-switch-width: 2.6em;
$link-decoration: none;
@ -19,6 +20,8 @@ $form-floating-input-padding-b: .625rem;
$form-floating-padding-y: .8rem;
$form-floating-height: 50px;
$table-border-color: #e9ecef;
@import './bootstrap-icons';
@import 'node_modules/bootstrap-5.1.3/scss/bootstrap';
// @import 'node_modules/bootstrap/scss/bootstrap';

View File

@ -62,8 +62,8 @@ body.page-login {
button[type="submit"] {
font-size: 1rem;
background-image: linear-gradient(310deg, $main_color, #fdb504);
// background-image: linear-gradient(310deg, $main_color, #fdb504);
background-image: linear-gradient(310deg, $primary, #fdb504);
// background-image: linear-gradient(310deg, $primary, #fdb504);
border: none;
}

View File

@ -1,304 +1,91 @@
@extends('admin::layouts.master')
@section('title', '顾客管理')
@section('title', '订单详情')
@section('content')
<div id="customer-app-form" class="card" v-cloak>
{{-- {{ dd($order) }} --}}
<div class="card mb-4">
<div class="card-header"><h6 class="card-title">订单详情</h6></div>
<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 class="row">
<div class="col-4">
<table class="table table-borderless">
<tbody>
<tr>
<td>订单编号:</td>
<td>{{ $order->number }}</td>
</tr>
<tr>
<td>付款方式:</td>
<td>{{ $order->payment_method_name }}</td>
</tr>
<tr>
<td>总计:</td>
<td>{{ $order->total }}</td>
</tr>
<tr>
<td>状态:</td>
<td>{{ $order->status }}</td>
</tr>
</tbody>
</table>
</div>
<div class="col-4">
<table class="table table-borderless">
<tbody>
<tr>
<td>客户姓名:</td>
<td>{{ $order->customer_name }}</td>
</tr>
<tr>
<td>生成日期:</td>
<td>{{ $order->created_at }}</td>
</tr>
<tr>
<td>修改日期:</td>
<td>{{ $order->updated_at }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="card mb-4">
<div class="card-header"><h6 class="card-title">商品信息</h6></div>
<div class="card-body">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<td>ID</td>
<td>商品</td>
<td>价格</td>
<td>数量</td>
<td>sku</td>
</tr>
</thead>
<tbody>
@foreach ($order->orderProducts as $product)
<tr>
<td>{{ $product->id }}</td>
<td>{{ $product->name }}</td>
<td>{{ $product->price }}</td>
<td>{{ $product->quantity }}</td>
<td>{{ $product->product_sku }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="card mb-4">
<div class="card-header"><h6 class="card-title">订单操作日志</h6></div>
<div class="card-body">
</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