@@ -12,12 +12,16 @@ import org.linlinjava.litemall.db.service.LitemallUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin/user")
|
||||
@Validated
|
||||
@@ -38,4 +42,17 @@ public class AdminUserController {
|
||||
List<LitemallUser> userList = userService.querySelective(username, mobile, page, limit, sort, order);
|
||||
return ResponseUtil.okList(userList);
|
||||
}
|
||||
@RequiresPermissions("admin:user:list")
|
||||
@RequiresPermissionsDesc(menu = {"用户管理", "会员管理"}, button = "查询")
|
||||
@GetMapping("/detail")
|
||||
public Object userDetail(@NotNull Integer id) {
|
||||
LitemallUser user=userService.findById(id);
|
||||
return ResponseUtil.ok(user);
|
||||
}
|
||||
@RequiresPermissions("admin:user:list")
|
||||
@RequiresPermissionsDesc(menu = {"用户管理", "会员管理"}, button = "查询")
|
||||
@PostMapping("/update")
|
||||
public Object userUpdate(@RequestBody LitemallUser user) {
|
||||
return ResponseUtil.ok(userService.updateById(user));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,22 @@ export function fetchList(query) {
|
||||
})
|
||||
}
|
||||
|
||||
export function userDetail(id) {
|
||||
return request({
|
||||
url: '/user/detail',
|
||||
method: 'get',
|
||||
params: {id}
|
||||
})
|
||||
}
|
||||
|
||||
export function updateUser(data) {
|
||||
return request({
|
||||
url: '/user/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function listAddress(query) {
|
||||
return request({
|
||||
url: '/address/list',
|
||||
@@ -47,4 +63,3 @@ export function listHistory(query) {
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<!-- 查询和其他操作 -->
|
||||
<div class="filter-container">
|
||||
<el-input v-model="listQuery.username" clearable class="filter-item" style="width: 200px;" placeholder="请输入用户名"/>
|
||||
<el-input v-model="listQuery.userId" clearable class="filter-item" style="width: 200px;" placeholder="请输入用户Id"/>
|
||||
<el-input v-model="listQuery.mobile" clearable class="filter-item" style="width: 200px;" placeholder="请输入手机号"/>
|
||||
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
|
||||
<el-button :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button>
|
||||
@@ -36,16 +37,49 @@
|
||||
<el-tag>{{ statusDic[scope.row.status] }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" size="mini" @click="handleDetail(scope.row)">详情</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
|
||||
|
||||
<!-- 用户编辑对话框 -->
|
||||
<el-dialog :visible.sync="userDialogVisible" title="用户编辑">
|
||||
<el-form ref="userDetail" :model="userDetail" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="userDetail.username" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户昵称" prop="nickname">
|
||||
<el-input v-model="userDetail.nickname" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户密码" prop="mobile">
|
||||
<el-input v-model="userDetail.password" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户手机" prop="mobile">
|
||||
<el-input v-model="userDetail.mobile" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户性别" prop="gender">
|
||||
<el-select v-model="userDetail.gender" placeholder="请选择"><el-option v-for="(item, index) in genderDic" :key="index" :label="item" :value="index" /></el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户等级" prop="userLevel">
|
||||
<el-select v-model="userDetail.userLevel" placeholder="请选择"><el-option v-for="(item, index) in levelDic" :key="index" :label="item" :value="index" /></el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="userDetail.status" placeholder="请选择"><el-option v-for="(item, index) in statusDic" :key="index" :label="item" :value="index" /></el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="userDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleUserUpdate">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList } from '@/api/user'
|
||||
import { fetchList ,userDetail ,updateUser } from '@/api/user'
|
||||
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
|
||||
|
||||
export default {
|
||||
@@ -61,13 +95,17 @@ export default {
|
||||
limit: 20,
|
||||
username: undefined,
|
||||
mobile: undefined,
|
||||
userId: undefined,
|
||||
sort: 'add_time',
|
||||
order: 'desc'
|
||||
},
|
||||
downloadLoading: false,
|
||||
genderDic: ['未知', '男', '女'],
|
||||
levelDic: ['普通用户', 'VIP用户', '高级VIP用户'],
|
||||
statusDic: ['可用', '禁用', '注销']
|
||||
statusDic: ['可用', '禁用', '注销'],
|
||||
userDialogVisible: false,
|
||||
userDetail:{
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -76,15 +114,34 @@ export default {
|
||||
methods: {
|
||||
getList() {
|
||||
this.listLoading = true
|
||||
fetchList(this.listQuery).then(response => {
|
||||
this.list = response.data.data.list
|
||||
this.total = response.data.data.total
|
||||
this.listLoading = false
|
||||
}).catch(() => {
|
||||
this.list = []
|
||||
this.total = 0
|
||||
this.listLoading = false
|
||||
})
|
||||
if(this.listQuery.userId){
|
||||
userDetail(this.listQuery.userId).then(response => {
|
||||
this.list = [];
|
||||
if(response.data.data){
|
||||
this.list.push(response.data.data)
|
||||
this.total = 1
|
||||
this.listLoading = false
|
||||
}else{
|
||||
this.list = []
|
||||
this.total = 0
|
||||
this.listLoading = false
|
||||
}
|
||||
}).catch(() => {
|
||||
this.list = []
|
||||
this.total = 0
|
||||
this.listLoading = false
|
||||
})
|
||||
}else{
|
||||
fetchList(this.listQuery).then(response => {
|
||||
this.list = response.data.data.list
|
||||
this.total = response.data.data.total
|
||||
this.listLoading = false
|
||||
}).catch(() => {
|
||||
this.list = []
|
||||
this.total = 0
|
||||
this.listLoading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1
|
||||
@@ -98,6 +155,26 @@ export default {
|
||||
excel.export_json_to_excel2(tHeader, this.list, filterVal, '用户信息')
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
handleDetail(row) {
|
||||
this.userDetail = row
|
||||
this.userDialogVisible = true
|
||||
},
|
||||
handleUserUpdate(){
|
||||
updateUser(this.userDetail)
|
||||
.then((response) => {
|
||||
this.userDialogVisible = false
|
||||
this.$notify.success({
|
||||
title: '成功',
|
||||
message: '更新用户成功'
|
||||
})
|
||||
})
|
||||
.catch(response => {
|
||||
this.$notify.error({
|
||||
title: '失败',
|
||||
message: response.data.errmsg
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user