|
@@ -1,6 +1,9 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="address-add">
|
|
<div class="address-add">
|
|
|
<el-form :model="addressForm" :rules="rules" ref="addressForm" label-width="100px">
|
|
<el-form :model="addressForm" :rules="rules" ref="addressForm" label-width="100px">
|
|
|
|
|
+ <el-form-item label="地址ID" v-if="$route.query.addressid">
|
|
|
|
|
+ <el-input disabled v-model="addressForm.addressid"></el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="地址名称" prop="addressname">
|
|
<el-form-item label="地址名称" prop="addressname">
|
|
|
<el-input v-model="addressForm.addressname"></el-input>
|
|
<el-input v-model="addressForm.addressname"></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -13,7 +16,9 @@
|
|
|
|
|
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
|
<!-- 提交按钮 -->
|
|
<!-- 提交按钮 -->
|
|
|
- <el-button type="primary" @click="submitForm('addressForm')">立即创建</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" @click="submitForm('addressForm')">
|
|
|
|
|
+ {{$route.query.addressid?"更新":"添加"}}地址
|
|
|
|
|
+ </el-button>
|
|
|
<!-- 重置按钮 -->
|
|
<!-- 重置按钮 -->
|
|
|
<el-button @click="resetForm('addressForm')">重置</el-button>
|
|
<el-button @click="resetForm('addressForm')">重置</el-button>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -21,12 +26,13 @@
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<script>
|
|
<script>
|
|
|
- import { addAddress } from "@/api/address";
|
|
|
|
|
|
|
+ import { addOrUpdateAddress } from "@/api/address";
|
|
|
export default{
|
|
export default{
|
|
|
name:"AddressAdd",
|
|
name:"AddressAdd",
|
|
|
data(){
|
|
data(){
|
|
|
return{
|
|
return{
|
|
|
addressForm:{
|
|
addressForm:{
|
|
|
|
|
+ addressid:"",
|
|
|
addressname:"",
|
|
addressname:"",
|
|
|
longitude:"",
|
|
longitude:"",
|
|
|
latitude:""
|
|
latitude:""
|
|
@@ -45,6 +51,13 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ mounted(){
|
|
|
|
|
+ // 从路由参数中获取地址信息
|
|
|
|
|
+ if(this.$route.query.addressid){
|
|
|
|
|
+ // 赋值给表单数据
|
|
|
|
|
+ this.addressForm = {...this.$route.query}
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
methods:{
|
|
methods:{
|
|
|
// 添加地址按钮
|
|
// 添加地址按钮
|
|
|
submitForm(formName){
|
|
submitForm(formName){
|
|
@@ -52,7 +65,7 @@
|
|
|
this.$refs[formName].validate((valid) => {
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if(valid){
|
|
if(valid){
|
|
|
// 发送请求添加地址
|
|
// 发送请求添加地址
|
|
|
- addAddress(this.addressForm).then(()=>{
|
|
|
|
|
|
|
+ addOrUpdateAddress(this.addressForm).then(()=>{
|
|
|
// 弹框提示成功
|
|
// 弹框提示成功
|
|
|
this.$message({
|
|
this.$message({
|
|
|
message: '地址添加成功!',
|
|
message: '地址添加成功!',
|