parent
cb9972642d
commit
203d98ead2
@ -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> |
Loading…
Reference in new issue