Commit ea6b09d8 authored by shangtx's avatar shangtx

feat: 用户管理

parent acc9ef70
......@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.png">
<title>房屋线上修缮系统</title>
<title>城市匠人管理系统</title>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=8uuOYfYHUCjgSm0uEelyMxaLcaQSRiM0"></script>
</head>
<body>
......
import {axios} from '@/util/axios/request'
const BANNER_URL = '/user'
export function getPage(data) {
return axios({
url: `${BANNER_URL}/page`,
method: 'post',
data
})
}
export function save(data) {
return axios({
url: BANNER_URL,
method: 'put',
data,
})
}
......@@ -15,7 +15,7 @@ export const constantRouterMap = [
{
path: 'login',
name: 'login',
component: () => import('@/views/user/Login')
component: () => import('@/views/system/Login')
}
]
},
......
......@@ -109,18 +109,18 @@ export { bizCode, bizCodeMapping };
*/
export function getCodeOptions(codes, valueFiled) {
if(!valueFiled) {
valueFiled = 'valueInt';
valueFiled = 'code';
}
return getCommonCode(codes).then(({ data: { data } }) => {
return getCommonCode(codes).then(({ data }) => {
const codeMapping = {};
const options = {};
Object.keys(data).forEach((k) => {
const codeArray = data[k];
const map = {};
options[k] = codeArray.map(c => {
map[c[valueFiled]] = c['name'];
map[c[valueFiled]] = c['value'];
return {
title: c['name'],
title: c['value'],
value: c[valueFiled]
};
});
......
<template>
<table-template :soul="this">
<template #avatar="{ record }">
<a-avatar :src="record.avatar" />
</template>
<template #userType="{ record }">
<span
>{{record.roleTypeValue}} &nbsp;
<a-dropdown :trigger="['click']">
<a><a-icon type="edit" @click="(e) => e.preventDefault()" /></a>
<a-menu slot="overlay" @click="({ key }) => edit(key, record)">
<a-menu-item key="0"> 修改为 普通用户 </a-menu-item>
<a-menu-item key="1"> 修改为 客服 </a-menu-item>
<a-menu-item key="2"> 修改为 估价员 </a-menu-item>
</a-menu>
</a-dropdown>
</span>
</template>
</table-template>
</template>
<script>
import { TableTemplate, TableScript, SearchType } from '@/components/table'
import { getPage, save } from '@/api/user'
import dayjs from 'dayjs'
const columns = [
{ title: '头像', scopedSlots: { customRender: 'avatar' }, width: 120 },
{
title: '用户名',
dataIndex: 'userName',
width: 120,
filter: { type: SearchType.STRING }
},
{ title: '昵称', dataIndex: 'nickName' },
{ title: '手机', dataIndex: 'phone', filter: { type: SearchType.STRING } },
{ title: '微信唯一id', dataIndex: 'unionId' },
{ title: '小程序id', dataIndex: 'openId' },
{
title: '用户类型',
dataIndex: 'roleType',
hidden: true,
enum: 'BIZ0001',
filter: { type: SearchType.ENUM }
},
{ title: '用户类型', scopedSlots: { customRender: 'userType' } },
{
title: '注册时间',
dataIndex: 'createTime',
width: 180,
filter: { type: SearchType.RANGE },
customRender: (text) => dayjs(text).format('YYYY-MM-DD HH:mm:ss')
}
]
export default {
name: 'UserList',
mixins: [TableScript],
components: { TableTemplate },
data() {
return {
columns,
useYScroll: true,
codes: [['BIZ0001'], []]
}
},
methods: {
queryData: getPage,
edit(key, record) {
if (key == record.roleType) {
return
}
if (key != 0 && !record.phone) {
this.$message.error('用户未绑定手机号')
return
}
save({ id: record.id, roleType: key }).then(({ code }) => {
if (code == 200) {
this.$message.success('保存成功')
this.reset()
}
})
}
}
}
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment