新增账号新增编辑表单,账号列表页面优化
This commit is contained in:
parent
ec77c6dd50
commit
e9f40021bc
@ -79,6 +79,16 @@
|
|||||||
:scroll="{ x: 'max-content' }"
|
:scroll="{ x: 'max-content' }"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column ,record}">
|
<template #bodyCell="{ column ,record}">
|
||||||
|
<template v-if="column.key === 'state'">
|
||||||
|
<a-tag
|
||||||
|
v-if="record.state == '0'"
|
||||||
|
color="#f50"
|
||||||
|
>禁用</a-tag>
|
||||||
|
<a-tag
|
||||||
|
v-if="record.state == '1'"
|
||||||
|
color="#87d068"
|
||||||
|
>启用</a-tag>
|
||||||
|
</template>
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a @click="handleAdd('编辑账号',record)">编辑</a>
|
<a @click="handleAdd('编辑账号',record)">编辑</a>
|
||||||
@ -120,37 +130,37 @@ const formModel = ref(null);
|
|||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: '所属地区',
|
title: '所属地区',
|
||||||
dataIndex: 'orgName',
|
dataIndex: 'zoneName',
|
||||||
width: 200,
|
width: 200,
|
||||||
key: 'orgName',
|
key: 'zoneName',
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '用户名称',
|
title: '用户名称',
|
||||||
|
dataIndex: 'username',
|
||||||
|
width: 200,
|
||||||
|
key: 'username',
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户账号',
|
||||||
|
dataIndex: 'phone',
|
||||||
|
width: 200,
|
||||||
|
key: 'phone',
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '角色类型',
|
||||||
dataIndex: 'roleName',
|
dataIndex: 'roleName',
|
||||||
width: 200,
|
width: 200,
|
||||||
key: 'roleName',
|
key: 'roleName',
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: '用户账号',
|
|
||||||
dataIndex: 'roleDescription',
|
|
||||||
width: 200,
|
|
||||||
key: 'roleDescription',
|
|
||||||
align: 'center'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '角色类型',
|
|
||||||
dataIndex: 'staffCount',
|
|
||||||
width: 200,
|
|
||||||
key: 'staffCount',
|
|
||||||
align: 'center'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
dataIndex: 'webCount',
|
dataIndex: 'state',
|
||||||
width: 200,
|
width: 200,
|
||||||
key: 'webCount',
|
key: 'state',
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -169,16 +179,9 @@ const columns = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
dataIndex: 'appletCount',
|
dataIndex: 'createdAt',
|
||||||
width: 200,
|
width: 200,
|
||||||
key: 'appletCount',
|
key: 'createdAt',
|
||||||
align: 'center'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '登录日志',
|
|
||||||
dataIndex: 'appletCount',
|
|
||||||
width: 200,
|
|
||||||
key: 'appletCount',
|
|
||||||
align: 'center'
|
align: 'center'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -244,9 +247,12 @@ const handleAdd = async (title, record) => {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (formModel.value) {
|
if (formModel.value) {
|
||||||
const params = record == null ? {} : {
|
const params = record == null ? {} : {
|
||||||
roleName: record['roleName'],
|
staffId: record['staffId'],
|
||||||
roleDescription: record['roleDescription'],
|
roleId: record['roleId'] == null ? [] : record['roleId'].split(","),
|
||||||
roleId: record['roleId'],
|
zoneId: record['zoneId'] == null ? [] : record['zoneId'].split(","),
|
||||||
|
phone: record['phone'],
|
||||||
|
username: record['username'],
|
||||||
|
state: record['state'],
|
||||||
orgId: record['orgId']
|
orgId: record['orgId']
|
||||||
}
|
}
|
||||||
formModel.value.openForm(params);
|
formModel.value.openForm(params);
|
||||||
|
|||||||
@ -16,28 +16,38 @@
|
|||||||
label="角色名称"
|
label="角色名称"
|
||||||
:label-col="{ span: 4 }"
|
:label-col="{ span: 4 }"
|
||||||
:wrapper-col="{ span: 12 }"
|
:wrapper-col="{ span: 12 }"
|
||||||
name="roleName"
|
name="roleId"
|
||||||
required
|
required
|
||||||
:rules="[{ required: true, message: '请输角色名称' }]"
|
:rules="[{ required: true, message: '请选择角色名称' }]"
|
||||||
>
|
>
|
||||||
<a-input
|
<a-select
|
||||||
v-model:value="form.roleName"
|
mode="multiple"
|
||||||
placeholder="请输角色名称"
|
style="width: 100%"
|
||||||
/>
|
placeholder="请选择角色名称"
|
||||||
|
v-model:value="form.roleId"
|
||||||
|
>
|
||||||
|
<a-select-option
|
||||||
|
v-for="(item) in roleLit"
|
||||||
|
:key="item.id"
|
||||||
|
:value="item.id"
|
||||||
|
>{{ item.name }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
label="角色描述"
|
label="手机号码"
|
||||||
:label-col="{ span: 4 }"
|
:label-col="{ span: 4 }"
|
||||||
:wrapper-col="{ span: 12 }"
|
:wrapper-col="{ span: 12 }"
|
||||||
name="roleDescription"
|
name="phone"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请输入手机号码' }]"
|
||||||
>
|
>
|
||||||
<a-input
|
<a-input
|
||||||
v-model:value="form.roleDescription"
|
v-model:value="form.phone"
|
||||||
placeholder="请输入角色描述"
|
placeholder="请输入手机号码"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@ -45,53 +55,57 @@
|
|||||||
<a-row>
|
<a-row>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item
|
<a-form-item
|
||||||
label="菜单权限配置"
|
label="用户名称"
|
||||||
:label-col="{ span: 4 }"
|
:label-col="{ span: 4 }"
|
||||||
:wrapper-col="{ span: 21 }"
|
:wrapper-col="{ span: 12 }"
|
||||||
name="roleDescription"
|
name="username"
|
||||||
|
:extra="extraText"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请输入用户名称' }]"
|
||||||
>
|
>
|
||||||
<a-tabs v-model:activeKey="activeKey">
|
<a-input
|
||||||
<a-tab-pane
|
v-model:value="form.username"
|
||||||
key="1"
|
placeholder="请输入用户名称"
|
||||||
tab="运营后台"
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item
|
||||||
|
label="账号状态"
|
||||||
|
:label-col="{ span: 4 }"
|
||||||
|
:wrapper-col="{ span: 12 }"
|
||||||
|
name="state"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请选择账号状态' }]"
|
||||||
>
|
>
|
||||||
<div style="border: solid 1px #ddd;margin-top: -15px;">
|
<a-radio-group
|
||||||
<a-tree
|
v-model:value="form.state"
|
||||||
v-if="treeDataByWeb.length"
|
name="radioGroup"
|
||||||
defaultExpandAll
|
|
||||||
v-model:checkedKeys="checkedKeysByWeb"
|
|
||||||
@check="checkNodeByWeb"
|
|
||||||
v-model:tree-data="treeDataByWeb"
|
|
||||||
checkable
|
|
||||||
>
|
>
|
||||||
<template #title="{ description }">
|
<a-radio value="1">启用</a-radio>
|
||||||
{{ description }}
|
<a-radio value="0">禁用</a-radio>
|
||||||
</template>
|
</a-radio-group>
|
||||||
</a-tree>
|
</a-form-item>
|
||||||
</div>
|
</a-col>
|
||||||
|
</a-row>
|
||||||
</a-tab-pane>
|
<a-row>
|
||||||
<a-tab-pane
|
<a-col :span="24">
|
||||||
key="2"
|
<a-form-item
|
||||||
tab="运维小程序"
|
label="关联行政区"
|
||||||
force-render
|
:label-col="{ span: 4 }"
|
||||||
|
:wrapper-col="{ span: 12 }"
|
||||||
|
name="zoneId"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请选择关联行政区' }]"
|
||||||
>
|
>
|
||||||
<div style="border: solid 1px #ddd;margin-top: -15px;">
|
<a-checkbox-group
|
||||||
<a-tree
|
v-model:value="form.zoneId"
|
||||||
v-if="treeDataByApplet.length"
|
name="channel"
|
||||||
v-model:checkedKeys="checkedKeysByApplet"
|
:options="options"
|
||||||
@check="checkNodeByApplet"
|
@change="changeZoneId"
|
||||||
:tree-data="treeDataByApplet"
|
/>
|
||||||
defaultExpandAll
|
|
||||||
checkable
|
|
||||||
>
|
|
||||||
<template #title="{ description }">
|
|
||||||
{{ description }}
|
|
||||||
</template>
|
|
||||||
</a-tree>
|
|
||||||
</div>
|
|
||||||
</a-tab-pane>
|
|
||||||
</a-tabs>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -101,140 +115,84 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { callUser } from '@/apis/call.js'
|
import { callUser, callOperate } from '@/apis/call.js'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import _, { constant } from 'lodash'
|
import _, { constant } from 'lodash'
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const form = ref({});
|
const form = ref({
|
||||||
const activeKey = ref("1")
|
state: "1"
|
||||||
const checkedKeysByWeb = ref([])
|
});
|
||||||
const checkedKeysByApplet = ref([])
|
const roleLit = ref([])
|
||||||
const treeDataByWeb = ref([])
|
|
||||||
const treeDataByApplet = ref([])
|
|
||||||
const treeDataList = ref([])
|
|
||||||
const roleIdRef = ref(null);
|
|
||||||
const isAdd = ref(true);
|
const isAdd = ref(true);
|
||||||
const spinning = ref(false);
|
const spinning = ref(false);
|
||||||
const tipContent = ref("加载中...");
|
const tipContent = ref("加载中...");
|
||||||
|
const options = ref([])
|
||||||
|
const staffIdRef = ref(null);
|
||||||
|
const zoneId = ref([]);
|
||||||
|
const extraText = ref("新增账号默认密码为“123456”")
|
||||||
|
|
||||||
|
|
||||||
const openForm = (params = {}) => {
|
const openForm = (params = {}) => {
|
||||||
isAdd.value = true;
|
|
||||||
form.value = { ...params }
|
|
||||||
loadPermissionsList(params['roleId']);
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadPermissionsList = (roleId = null) => {
|
isAdd.value = true;
|
||||||
callUser("/permissions/list", {}, "get").then((res) => {
|
callOperate("/ebikeOrgZone/listZoneByLogin", {}, "get").then((res) => {
|
||||||
if (res.code != 200) {
|
if (res.code != 200) {
|
||||||
message.error(res.message)
|
message.error(res.message);
|
||||||
treeDataByWeb.value = []
|
return;
|
||||||
treeDataByApplet.value = []
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
const dataList = res.data.map((item) => {
|
const data = res.data.map(item => {
|
||||||
return { ...item, key: item.permId }
|
return { label: item['zoneName'], value: item['zoneId'] }
|
||||||
})
|
})
|
||||||
treeDataList.value = dataList;
|
options.value = data;
|
||||||
const newDataListByWeb = buildTreeWithChildren(dataList, 1)
|
});
|
||||||
const newDataList = buildTreeWithChildren(dataList, 2)
|
callUser("/roles/listByOrgId", {}, "get").then((res) => {
|
||||||
treeDataByWeb.value = [{ description: "全部", key: "all", children: [...newDataListByWeb] }]
|
if (res.code != 200) {
|
||||||
treeDataByApplet.value = [{ description: "全部", key: "all", children: [...newDataList] }]
|
message.error(res.message);
|
||||||
if (roleId) {
|
return;
|
||||||
|
}
|
||||||
|
const data = res.data.map(item => {
|
||||||
|
return { id: item['roleId'], name: item['roleName'] }
|
||||||
|
})
|
||||||
|
roleLit.value = data;
|
||||||
|
if (params['staffId']) {
|
||||||
isAdd.value = false;
|
isAdd.value = false;
|
||||||
roleIdRef.value = roleId
|
extraText.value = ""
|
||||||
callUser("/rolePermissions/getRolePermissionsByRoleId/" + roleId, {}, "get").then((res) => {
|
staffIdRef.value = params['staffId']
|
||||||
if (res.code == 200) {
|
form.value = { ...params }
|
||||||
const webKeys = res.data.filter(item => item['permType'] == "1").map(item => {
|
|
||||||
return item['permId']
|
|
||||||
});
|
|
||||||
const appletKeys = res.data.filter(item => item['permType'] == "2").map(item => {
|
|
||||||
return item['permId']
|
|
||||||
});
|
|
||||||
checkedKeysByWeb.value = webKeys;
|
|
||||||
checkedKeysByApplet.value = appletKeys;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
callOperate("/ebikesysrcostset/createSnowflakeId", {}, "get").then(res => {
|
callOperate("/ebikesysrcostset/createSnowflakeId", {}, "get").then(res => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
roleIdRef.value = res.data;
|
staffIdRef.value = res.data;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const checkNodeByWeb = (checkKeys, nodes) => {
|
|
||||||
const checkNodes = nodes.checkedNodes.filter(item => item['key'] != "all")
|
|
||||||
const leafKeys = getLeafKeys(checkNodes);
|
|
||||||
checkedKeysByWeb.value = leafKeys
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkNodeByApplet = (checkKeys, nodes) => {
|
|
||||||
const checkNodes = nodes.checkedNodes.filter(item => item['key'] != "all")
|
|
||||||
const leafKeys = getLeafKeys(checkNodes);
|
|
||||||
checkedKeysByApplet.value = leafKeys
|
|
||||||
}
|
|
||||||
|
|
||||||
const getLeafKeys = (nodes) => {
|
|
||||||
let leafKeys = [];
|
|
||||||
nodes.forEach(node => {
|
|
||||||
if (!node.children || node.children.length === 0) {
|
|
||||||
leafKeys.push(node.key);
|
|
||||||
} else {
|
|
||||||
getLeafKeys(node.children)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return leafKeys;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildTreeWithChildren = (data, where) => {
|
const changeZoneId = (zoneIds) => {
|
||||||
const map = new Map();
|
const data = options.value.filter(item => zoneIds.includes(item['value']));
|
||||||
const roots = [];
|
const zone = data.map(item => {
|
||||||
data.forEach(item => {
|
return { zoneName: item['label'], zoneId: item['value'] }
|
||||||
map.set(item.permId, { ...item });
|
})
|
||||||
});
|
zoneId.value = zone
|
||||||
data.forEach(item => {
|
|
||||||
if (item['permType'] == where) {
|
|
||||||
const child = map.get(item.permId);
|
|
||||||
child.code = child.permCode;
|
|
||||||
if (item.parentId === null || item.parentId === undefined) {
|
|
||||||
roots.push(child);
|
|
||||||
} else {
|
|
||||||
const parent = map.get(item.parentId);
|
|
||||||
if (parent) {
|
|
||||||
parent.children = parent.children || [];
|
|
||||||
child.code = child.permCode.replace(parent.permCode + ".", '');
|
|
||||||
parent.children.push(child);
|
|
||||||
} else {
|
|
||||||
roots.push(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return roots;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const formSave = (callBack) => {
|
const formSave = (callBack) => {
|
||||||
formRef.value.validate().then((res) => {
|
formRef.value.validate().then((res) => {
|
||||||
tipContent.value = "保存中..."
|
tipContent.value = "保存中..."
|
||||||
spinning.value = true;
|
spinning.value = true;
|
||||||
let url = "rolePermissionsAdd";
|
let url = "staffInfoAdd";
|
||||||
if (!isAdd.value) {
|
if (!isAdd.value) {
|
||||||
url = "rolePermissionsUpdate"
|
url = "staffInfoUpdate"
|
||||||
}
|
}
|
||||||
|
isAdd.value = false;
|
||||||
const params = _.cloneDeep(form.value);
|
const params = _.cloneDeep(form.value);
|
||||||
params['roleId'] = roleIdRef.value;
|
params['staffId'] = staffIdRef.value;
|
||||||
params['rolePermissions'] = []
|
params['zoneId'] = zoneId.value;
|
||||||
checkedKeysByWeb.value.map(item => {
|
callUser("/staff/" + url, params).then((res) => {
|
||||||
params['rolePermissions'].push({ permId: item })
|
|
||||||
})
|
|
||||||
checkedKeysByApplet.value.map(item => {
|
|
||||||
params['rolePermissions'].push({ permId: item })
|
|
||||||
})
|
|
||||||
callUser("/roles/" + url, params).then((res) => {
|
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
|
message.success(res.message)
|
||||||
if (callBack) {
|
if (callBack) {
|
||||||
res.data = params;
|
res.data = params;
|
||||||
callBack(res);
|
callBack(res);
|
||||||
|
|||||||
@ -156,10 +156,13 @@ const formSave = (onCallBack) => {
|
|||||||
callOperate("/ebikeSysRoperateset/" + url, params).then(res => {
|
callOperate("/ebikeSysRoperateset/" + url, params).then(res => {
|
||||||
spinning.value = false;
|
spinning.value = false;
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
|
message.success(res.message)
|
||||||
if (onCallBack) {
|
if (onCallBack) {
|
||||||
res.data = params;
|
res.data = params;
|
||||||
onCallBack(res);
|
onCallBack(res);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
message.error(res.message)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
@ -224,6 +224,7 @@ const formSave = (callBack) => {
|
|||||||
if (!isAdd.value) {
|
if (!isAdd.value) {
|
||||||
url = "rolePermissionsUpdate"
|
url = "rolePermissionsUpdate"
|
||||||
}
|
}
|
||||||
|
isAdd.value = false;
|
||||||
const params = _.cloneDeep(form.value);
|
const params = _.cloneDeep(form.value);
|
||||||
params['roleId'] = roleIdRef.value;
|
params['roleId'] = roleIdRef.value;
|
||||||
params['rolePermissions'] = []
|
params['rolePermissions'] = []
|
||||||
@ -235,6 +236,7 @@ const formSave = (callBack) => {
|
|||||||
})
|
})
|
||||||
callUser("/roles/" + url, params).then((res) => {
|
callUser("/roles/" + url, params).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
|
message.success(res.message)
|
||||||
if (callBack) {
|
if (callBack) {
|
||||||
res.data = params;
|
res.data = params;
|
||||||
callBack(res);
|
callBack(res);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user