用户详情-收货地址

master
panqihua 2 years ago
parent cb9972642d
commit 203d98ead2
  1. 44
      src/api/platform/address.js
  2. 200
      src/views/platform/address.vue
  3. 12
      src/views/system/user/index.vue

@ -0,0 +1,44 @@
import request from "@/utils/request";
// 查询收货地址列表
export function listAddress(query) {
return request({
url: "/platform/address/list",
method: "get",
params: query,
});
}
// 查询收货地址详细
export function getAddress(id) {
return request({
url: "/platform/address/" + id,
method: "get",
});
}
// 新增收货地址
export function addAddress(data) {
return request({
url: "/platform/address",
method: "post",
data: data,
});
}
// 修改收货地址
export function updateAddress(data) {
return request({
url: "/platform/address",
method: "put",
data: data,
});
}
// 删除收货地址
export function delAddress(id) {
return request({
url: "/platform/address/" + id,
method: "delete",
});
}

@ -0,0 +1,200 @@
<template>
<div class="app-container">
<el-table v-loading="loading" :data="addressList" @selection-change="handleSelectionChange">
<el-table-column label="新创建时间" align="center" width="200">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="收货人" align="center" prop="consignee" />
<el-table-column label="电话" align="center" prop="phone" />
<el-table-column label="省" align="center" prop="province" />
<el-table-column label="市" align="center" prop="city" />
<el-table-column label="区" align="center" prop="area" />
<el-table-column label="详细地址" align="center" prop="address" />
<el-table-column label="是否默认" align="center">
<template slot-scope="scope">
{{ scope.row.isDefault ? '是' : '否' }}
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize" @pagination="getList" />
</div>
</template>
<script>
import { listAddress, getAddress, delAddress, addAddress, updateAddress } from "@/api/platform/address";
export default {
name: "Address",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
addressList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
consignee: null,
phone: null,
province: null,
city: null,
area: null,
address: null,
isDefault: null
},
//
form: {},
//
rules: {
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
],
consignee: [
{ required: true, message: "收货人不能为空", trigger: "blur" }
],
phone: [
{ required: true, message: "电话不能为空", trigger: "blur" }
],
province: [
{ required: true, message: "省不能为空", trigger: "blur" }
],
city: [
{ required: true, message: "市不能为空", trigger: "blur" }
],
area: [
{ required: true, message: "区不能为空", trigger: "blur" }
],
address: [
{ required: true, message: "详细地址不能为空", trigger: "blur" }
],
isDefault: [
{ required: true, message: "是否默认不能为空", trigger: "blur" }
]
}
};
},
created() {
this.getList();
},
methods: {
/** 查询收货地址列表 */
getList() {
this.loading = true;
listAddress(this.queryParams).then(response => {
this.addressList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
createTime: null,
consignee: null,
phone: null,
province: null,
city: null,
area: null,
address: null,
isDefault: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加收货地址";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getAddress(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改收货地址";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateAddress(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addAddress(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除收货地址编号为"' + ids + '"的数据项?').then(function () {
return delAddress(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => { });
},
/** 导出按钮操作 */
handleExport() {
this.download('system/address/export', {
...this.queryParams
}, `address_${new Date().getTime()}.xlsx`)
}
}
};
</script>

@ -123,14 +123,16 @@
</el-dialog>
<!-- 用户详情对话框 -->
<el-dialog :title="title" :visible.sync="detail.open" width="1000px" append-to-body>
<el-dialog :title="title" :visible.sync="detail.open" width="1200px" append-to-body @close="getList">
<el-tabs v-model="detail.activeName" type="card">
<el-tab-pane label="基本信息" name="base">
<base-form :reset="reset" :form="form" show-detail />
</el-tab-pane>
<el-tab-pane label="钱包明细" name="balance">钱包明细</el-tab-pane>
<el-tab-pane label="购买明细" name="pay_detail">购买明细</el-tab-pane>
<el-tab-pane label="收货地址" name="address">收货地址</el-tab-pane>
<el-tab-pane v-hasPermi="['platform:address:list']" label="收货地址" name="address">
<platform-address />
</el-tab-pane>
<el-tab-pane label="浏览记录" name="browser_history">浏览记录</el-tab-pane>
<el-tab-pane label="收藏记录" name="star_history">收藏记录</el-tab-pane>
<el-tab-pane label="购物车" name="cart">购物车</el-tab-pane>
@ -164,15 +166,15 @@
</template>
<script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, updateStatus } from "@/api/system/user";
import { listUser, getUser, delUser, resetUserPwd, changeUserStatus, updateStatus } from "@/api/system/user";
import { getToken } from "@/utils/auth";
import { getAvatar } from "../../../utils";
import baseForm from "./profile/baseForm"
import platformAddress from "@/views/platform/address"
export default {
name: "User",
dicts: ['sys_normal_disable', 'sys_user_sex'],
components: { baseForm },
components: { baseForm, platformAddress },
data() {
return {
//

Loading…
Cancel
Save