增加权限管理页面
This commit is contained in:
parent
b2ca8d1992
commit
b3713dcbd6
@ -227,7 +227,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//showModelMessage("蓝牙未就绪");
|
showModelMessage("蓝牙未就绪");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
@ -236,7 +236,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
errmsg = "蓝牙未就绪";
|
errmsg = "蓝牙未就绪";
|
||||||
//showModelMessage("蓝牙未就绪");
|
showModelMessage("蓝牙未就绪");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -269,6 +269,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
api.callEbikeInfo("getBikeINfoData?bikeCode=" + blueTooth.value.bikeCode).then((res)=>{
|
api.callEbikeInfo("getBikeINfoData?bikeCode=" + blueTooth.value.bikeCode).then((res)=>{
|
||||||
|
console.log("EbikeInfo",res)
|
||||||
if(res.code == 200 && res.data){
|
if(res.code == 200 && res.data){
|
||||||
if(res.data.ecuCode != ""){
|
if(res.data.ecuCode != ""){
|
||||||
blueTooth.value.ecuCode = res.data.ecuCode;
|
blueTooth.value.ecuCode = res.data.ecuCode;
|
||||||
@ -360,6 +361,7 @@
|
|||||||
success(res) {
|
success(res) {
|
||||||
if(res.errno == 0){
|
if(res.errno == 0){
|
||||||
uni.onBluetoothDeviceFound(function (res) {
|
uni.onBluetoothDeviceFound(function (res) {
|
||||||
|
console.log("onBluetoothDeviceFound",res)
|
||||||
const devices = res.devices;
|
const devices = res.devices;
|
||||||
for(let i=0;i < devices.length; i++){
|
for(let i=0;i < devices.length; i++){
|
||||||
if(devices[i].localName == sn){
|
if(devices[i].localName == sn){
|
||||||
@ -373,14 +375,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
//showModelMessage("未发现蓝牙设备");
|
showModelMessage("未发现蓝牙设备");
|
||||||
//停止搜索
|
//停止搜索
|
||||||
stopBluetoothDevicesDiscovery();
|
stopBluetoothDevicesDiscovery();
|
||||||
}, 120000);
|
}, 120000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
//showModelMessage("未发现蓝牙设备");
|
showModelMessage("未发现蓝牙设备");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -390,7 +392,7 @@
|
|||||||
uni.createBLEConnection({
|
uni.createBLEConnection({
|
||||||
deviceId: blueTooth.value.deviceId,
|
deviceId: blueTooth.value.deviceId,
|
||||||
success(res) {
|
success(res) {
|
||||||
//console.log("createBLEConnection success",res);
|
console.log("createBLEConnection success",res);
|
||||||
blueTooth.value.blueState.load=='';
|
blueTooth.value.blueState.load=='';
|
||||||
blueTooth.value.blueState.detectionState = "open";
|
blueTooth.value.blueState.detectionState = "open";
|
||||||
blueTooth.value.blueState.msg = "已连接";
|
blueTooth.value.blueState.msg = "已连接";
|
||||||
@ -400,7 +402,7 @@
|
|||||||
blueTooth.value.openBatteryHouse.btuDisabled = false;
|
blueTooth.value.openBatteryHouse.btuDisabled = false;
|
||||||
blueTooth.value.closeBatteryHouse.btuDisabled = false;
|
blueTooth.value.closeBatteryHouse.btuDisabled = false;
|
||||||
uni.onBLEConnectionStateChange(function (res) {
|
uni.onBLEConnectionStateChange(function (res) {
|
||||||
//console.log("onBLEConnectionStateChange",res);
|
console.log("onBLEConnectionStateChange",res);
|
||||||
if(!res.connected && blueTooth.value.autoBlueState){
|
if(!res.connected && blueTooth.value.autoBlueState){
|
||||||
blueTooth.value.blueState.btuDisabled = false;
|
blueTooth.value.blueState.btuDisabled = false;
|
||||||
blueTooth.value.openLock.btuDisabled = true;
|
blueTooth.value.openLock.btuDisabled = true;
|
||||||
@ -415,7 +417,7 @@
|
|||||||
startNotify();
|
startNotify();
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
//console.log("createBLEConnection err",err);
|
console.log("createBLEConnection err",err);
|
||||||
blueTooth.value.blueSignal = "-";
|
blueTooth.value.blueSignal = "-";
|
||||||
blueTooth.value.blueState.btuDisabled = false;
|
blueTooth.value.blueState.btuDisabled = false;
|
||||||
blueTooth.value.openLock.btuDisabled = true;
|
blueTooth.value.openLock.btuDisabled = true;
|
||||||
@ -436,7 +438,7 @@
|
|||||||
serviceId: serviceId,
|
serviceId: serviceId,
|
||||||
characteristicId: characteristicId,
|
characteristicId: characteristicId,
|
||||||
success(res) {
|
success(res) {
|
||||||
//console.log("notifyBLECharacteristicValueChange success",res);
|
console.log("notifyBLECharacteristicValueChange success",res);
|
||||||
//stopDiscovery();
|
//stopDiscovery();
|
||||||
uni.onBLECharacteristicValueChange(function(res){
|
uni.onBLECharacteristicValueChange(function(res){
|
||||||
var hex = bufTohex(res.value);
|
var hex = bufTohex(res.value);
|
||||||
|
|||||||
@ -74,6 +74,10 @@ const pages = [
|
|||||||
path: '/OrgManage',
|
path: '/OrgManage',
|
||||||
name: '品牌商管理',
|
name: '品牌商管理',
|
||||||
isMenu: true
|
isMenu: true
|
||||||
|
},{
|
||||||
|
path: '/PermManage',
|
||||||
|
name: '权限管理',
|
||||||
|
isMenu: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
154
ebike-operate/src/views/SysManage/PermManage/index.vue
Normal file
154
ebike-operate/src/views/SysManage/PermManage/index.vue
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 数据操作 -->
|
||||||
|
<a-space style="margin-bottom: 10px">
|
||||||
|
<a-button style="background-color: #5cc750" type="primary" class="ele-btn-icon" @click="handleAdd">
|
||||||
|
<template #icon>
|
||||||
|
<plus-outlined />
|
||||||
|
</template>
|
||||||
|
<span>新增</span>
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
<a-table bordered
|
||||||
|
:columns="columns"
|
||||||
|
:dataSource="dataSource"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'action'">
|
||||||
|
<a @click="handleDeal(record)">编辑</a>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
<!-- 编辑权限信息 -->
|
||||||
|
<a-modal
|
||||||
|
v-model:open="open"
|
||||||
|
:title="openTitle"
|
||||||
|
@ok="handleOkModal"
|
||||||
|
@cancel="handleCancelModal"
|
||||||
|
width="800px"
|
||||||
|
:maskClosable="false"
|
||||||
|
>
|
||||||
|
<PermForm ref="formModel"></PermForm>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { ref, onMounted, nextTick } from 'vue';
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { callUser } from '@/apis/call.js'
|
||||||
|
import PermForm from '@/views/form/permmanage/permform.vue'
|
||||||
|
|
||||||
|
const open = ref(false);
|
||||||
|
const openTitle = ref('权限信息');
|
||||||
|
const formModel = ref(null);
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
title: '权限编码',
|
||||||
|
dataIndex: 'code',
|
||||||
|
key: 'code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '权限名称',
|
||||||
|
dataIndex: 'description',
|
||||||
|
key: 'description',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '级别',
|
||||||
|
dataIndex: 'level',
|
||||||
|
key: 'level',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
|
width: 200,
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
// 表格行数据
|
||||||
|
const dataSource = ref([])
|
||||||
|
const data = ref([]);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getData();
|
||||||
|
})
|
||||||
|
|
||||||
|
const getData = async () => {
|
||||||
|
callUser("/permissions/list", {},"get").then((res) => {
|
||||||
|
if (res.code != 200) {
|
||||||
|
message.error(res.message)
|
||||||
|
dataSource.value = []
|
||||||
|
data.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data.value = res.data
|
||||||
|
data.value = data.value.map((item) => {
|
||||||
|
return { ...item, key: item.permId }
|
||||||
|
})
|
||||||
|
dataSource.value = buildTreeWithChildren(data.value)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildTreeWithChildren = (data) => {
|
||||||
|
const map = new Map();
|
||||||
|
const roots = [];
|
||||||
|
data.forEach(item => {
|
||||||
|
map.set(item.permId, { ...item });
|
||||||
|
});
|
||||||
|
data.forEach(item => {
|
||||||
|
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 handleAdd = async () => {
|
||||||
|
open.value = true;
|
||||||
|
nextTick(() => {
|
||||||
|
if (formModel.value) {
|
||||||
|
formModel.value.openForm({});
|
||||||
|
} else {
|
||||||
|
console.log('formModel is not ready yet');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDeal = async (record) => {
|
||||||
|
open.value = true;
|
||||||
|
nextTick(() => {
|
||||||
|
if (formModel.value) {
|
||||||
|
formModel.value.openForm({ ...record });
|
||||||
|
} else {
|
||||||
|
console.log('formModel is not ready yet');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理停车点申请modal确定
|
||||||
|
*/
|
||||||
|
const handleOkModal = () => {
|
||||||
|
formModel.value.formSave(bres => {
|
||||||
|
open.value = false;
|
||||||
|
if(bres){
|
||||||
|
getData()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleCancelModal = () => {
|
||||||
|
formModel.value.resetAll(bres => {
|
||||||
|
if(bres) open.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
274
ebike-operate/src/views/form/permmanage/permform.vue
Normal file
274
ebike-operate/src/views/form/permmanage/permform.vue
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
<template>
|
||||||
|
<a-form
|
||||||
|
:model="form"
|
||||||
|
ref="formRef"
|
||||||
|
label-align="left"
|
||||||
|
:label-col="{ span: 6 }"
|
||||||
|
:wrapper-col="{ span: 18 }"
|
||||||
|
>
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item
|
||||||
|
label="权限名称"
|
||||||
|
:label-col="{ span: 3 }"
|
||||||
|
:wrapper-col="{ span: 21 }"
|
||||||
|
name="description"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请输入权限名称' }]"
|
||||||
|
>
|
||||||
|
<a-input v-model:value="form.description" placeholder="请输入权限名称" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-row>
|
||||||
|
<a-col :xs="24">
|
||||||
|
<a-form-item
|
||||||
|
label="父级权限"
|
||||||
|
:label-col="{ span: 3 }"
|
||||||
|
:wrapper-col="{ span: 21 }"
|
||||||
|
name="parentId"
|
||||||
|
>
|
||||||
|
<a-input
|
||||||
|
style="display: none;"
|
||||||
|
v-model:value="form.parentId"
|
||||||
|
/>
|
||||||
|
<a-cascader
|
||||||
|
v-model:value="parentValues"
|
||||||
|
:options="parentOptions"
|
||||||
|
:load-data="loadParentData"
|
||||||
|
change-on-select
|
||||||
|
placeholder="请选择父级权限"
|
||||||
|
@change="changeParent"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item
|
||||||
|
label="权限编码"
|
||||||
|
:label-col="{ span: 3 }"
|
||||||
|
:wrapper-col="{ span: 21 }"
|
||||||
|
name="code"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请输入权限编码' }]"
|
||||||
|
>
|
||||||
|
<a-input v-model:value="form.code" placeholder="请输入权限编码" :addon-before="form.pcode" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-row>
|
||||||
|
<a-col :xs="24">
|
||||||
|
<a-form-item
|
||||||
|
label="类型"
|
||||||
|
:label-col="{ span: 3 }"
|
||||||
|
:wrapper-col="{ span: 21 }"
|
||||||
|
name="type"
|
||||||
|
required
|
||||||
|
:rules="[{ required: true, message: '请选择类型' }]"
|
||||||
|
>
|
||||||
|
<a-select v-model:value="form.type" placeholder="请选择类型">
|
||||||
|
<a-select-option v-for="(item) in typeList" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { callUser } from '@/apis/call.js'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { dataFormat } from '@/utils/tools'
|
||||||
|
|
||||||
|
const formRef = ref();
|
||||||
|
const formData = () => ({
|
||||||
|
permId: "",
|
||||||
|
description: "",
|
||||||
|
permCode: "",
|
||||||
|
level: "",
|
||||||
|
parentId: "",
|
||||||
|
type: "",
|
||||||
|
pcode: "",
|
||||||
|
code: ""
|
||||||
|
});
|
||||||
|
const form = ref(formData());
|
||||||
|
const data = ref([]);
|
||||||
|
const parentValues = ref([])
|
||||||
|
const parentOptions = ref([])
|
||||||
|
const typeList = ref([{
|
||||||
|
id: 0,
|
||||||
|
name: '最高权限'
|
||||||
|
},{
|
||||||
|
id: 1,
|
||||||
|
name: '页面权限'
|
||||||
|
},{
|
||||||
|
id: 2,
|
||||||
|
name: '按钮权限'
|
||||||
|
},{
|
||||||
|
id: 3,
|
||||||
|
name: '接口权限'
|
||||||
|
}])
|
||||||
|
|
||||||
|
const openForm = (params = {}) => {
|
||||||
|
form.value = {
|
||||||
|
...formData()
|
||||||
|
}
|
||||||
|
loadParentData(params);
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadPermData = (permId) => {
|
||||||
|
if (permId) {
|
||||||
|
callUser("/permissions/getInfo/"+ permId, {}, "get").then(res => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
if (res.data) {
|
||||||
|
form.value = {
|
||||||
|
...res.data
|
||||||
|
};
|
||||||
|
const permCode = res.data.permCode;
|
||||||
|
if(res.data.parentId === null || res.data.parentId === undefined){
|
||||||
|
form.value.code = permCode;
|
||||||
|
form.value.pcode = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
form.value.code = permCode.substring(permCode.lastIndexOf('.') + 1);
|
||||||
|
form.value.pcode = permCode.substring(0, permCode.lastIndexOf('.'));
|
||||||
|
}
|
||||||
|
if(parentOptions.value.length > 0){
|
||||||
|
parentValues.value = getParentValues(parentOptions.value, res.data.permId);
|
||||||
|
console.log(parentValues.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message.error(res.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getParentValues(tree, targetId, path = []) {
|
||||||
|
for (const node of tree) {
|
||||||
|
if (node.permId === targetId) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
if (node.children) {
|
||||||
|
const result = getParentValues(node.children, targetId, [...path, node.permId]);
|
||||||
|
if (result) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // 未找到目标节点
|
||||||
|
}
|
||||||
|
|
||||||
|
const loadParentData = (params) => {
|
||||||
|
parentOptions.value = [];
|
||||||
|
callUser("/permissions/list", {},"get").then((res) => {
|
||||||
|
if (res.code != 200) {
|
||||||
|
message.error(res.message)
|
||||||
|
parentOptions.value = []
|
||||||
|
data.value = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data.value = res.data
|
||||||
|
data.value = data.value.map((item) => {
|
||||||
|
return { ...item, value: item.permId, label: item.description }
|
||||||
|
})
|
||||||
|
parentOptions.value = buildTreeWithChildren(data.value)
|
||||||
|
|
||||||
|
if (params['permId']) {
|
||||||
|
loadPermData(params['permId']);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildTreeWithChildren = (data) => {
|
||||||
|
const map = new Map();
|
||||||
|
const roots = [];
|
||||||
|
data.forEach(item => {
|
||||||
|
map.set(item.permId, { ...item });
|
||||||
|
});
|
||||||
|
data.forEach(item => {
|
||||||
|
const child = map.get(item.permId);
|
||||||
|
if (item.parentId === null || item.parentId === undefined) {
|
||||||
|
roots.push(child);
|
||||||
|
} else {
|
||||||
|
const parent = map.get(item.parentId);
|
||||||
|
if (parent) {
|
||||||
|
parent.children = parent.children || [];
|
||||||
|
parent.children.push(child);
|
||||||
|
} else {
|
||||||
|
roots.push(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeParent = (data) => {
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
|
const formSave = (callBack) => {
|
||||||
|
formRef.value.validate().then(() => {
|
||||||
|
let params = {
|
||||||
|
orgId: "",
|
||||||
|
orgName: "",
|
||||||
|
orgCode: "",
|
||||||
|
createdTime: dataFormat(new Date(),'yyyy-MM-dd HH:mm:ss'),
|
||||||
|
}
|
||||||
|
if (form.value.orgId) {
|
||||||
|
params = {
|
||||||
|
...form.value
|
||||||
|
}
|
||||||
|
callUser("/organizations/update", params).then(res => {
|
||||||
|
if (res.code != 200) {
|
||||||
|
message.error(res.message);
|
||||||
|
if (callBack) {
|
||||||
|
callBack(false, res);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (callBack) {
|
||||||
|
callBack(true, res);
|
||||||
|
}
|
||||||
|
resetAll();
|
||||||
|
}).catch(error => {
|
||||||
|
if (callBack) {
|
||||||
|
callBack(false, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
callUser("/organizations/save", params).then(res => {
|
||||||
|
if (res.code!= 200) {
|
||||||
|
message.error(res.message);
|
||||||
|
if (callBack) {
|
||||||
|
callBack(false, res);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (callBack) {
|
||||||
|
callBack(true, res);
|
||||||
|
}
|
||||||
|
resetAll();
|
||||||
|
}).catch(error => {
|
||||||
|
if (callBack) {
|
||||||
|
callBack(false, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetAll = (callBack) => {
|
||||||
|
Object.assign(form.value, formData());
|
||||||
|
data.value = [];
|
||||||
|
parentOptions.value = [];
|
||||||
|
formRef.value.resetFields();
|
||||||
|
if (callBack) {
|
||||||
|
callBack(true, form.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ openForm, formSave, resetAll });
|
||||||
|
</script>
|
||||||
Loading…
x
Reference in New Issue
Block a user