mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 04:54:58 +08:00
角色管理和远程连接时间格式错误修复
This commit is contained in:
parent
15c9b35f1b
commit
e349bdbecf
|
@ -1,13 +1,27 @@
|
|||
import {getData} from "@/utils/request";
|
||||
import request, {getData} from "@/utils/request";
|
||||
|
||||
const getRoleListUrl = '/admin/role/list'
|
||||
const getRoleListUrl = '/admin/role/page';
|
||||
const roleUrl = "/admin/role";
|
||||
|
||||
export function getRoleList() {
|
||||
export function getRoleList(current: number, size: number, name?: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getData(getRoleListUrl).then((res: any) => {
|
||||
const params: any[] = ["current=" + current, "size=" + size];
|
||||
if (name) params.push("roleName=" + name);
|
||||
getData(getRoleListUrl + "?" + params.join("&")).then((res: any) => {
|
||||
resolve(res.data)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
resolve(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function addRole(role: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.postForm(roleUrl, role).then((res: any) => {
|
||||
resolve(res.data);
|
||||
}).catch(err => {
|
||||
resolve(err);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -3,19 +3,16 @@
|
|||
<el-form-item label="角色名称" prop="roleName">
|
||||
<el-input v-model="formData.roleName" placeholder="请输入角色名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色标识" prop="roleMark">
|
||||
<el-input v-model="formData.roleMark" placeholder="请输入角色标识" :disabled="type === 'edit'"></el-input>
|
||||
<el-form-item label="角色标识" prop="roleCode">
|
||||
<el-input v-model="formData.roleCode" placeholder="请输入角色标识" :disabled="type === 'edit'"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色描述" prop="roleRemark">
|
||||
<el-input v-model="formData.roleRemark" type="textarea" :rows="3" placeholder="请输入角色描述"></el-input>
|
||||
<el-form-item label="角色描述" prop="roleDesc">
|
||||
<el-input v-model="formData.roleDesc" type="textarea" :rows="3" placeholder="请输入角色描述"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据权限" prop="dataPermissions">
|
||||
<!-- <el-select v-model="formData.dataPermissions" placeholder="请选择角色">
|
||||
<el-option v-for="item in dataPermissionsOption" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>-->
|
||||
<el-form-item label="数据权限">
|
||||
<div class="tree-container">
|
||||
<el-tree ref="treeRef" :key="treeKey" :props="treeProps" :data="treeData" :default-expanded-keys="expandedKey"
|
||||
<el-tree ref="treeRef" :props="treeProps" :data="treeData"
|
||||
:default-expanded-keys="expandedKey"
|
||||
node-key="id"
|
||||
show-checkbox @check-change="checkChange"/>
|
||||
</div>
|
||||
|
@ -32,49 +29,51 @@
|
|||
import {onMounted, reactive, ref} from 'vue'
|
||||
import {ElMessage} from 'element-plus'
|
||||
import {getMenuData} from '@/static-data/menu'
|
||||
import * as roleApi from "@/api/role";
|
||||
import * as menuApi from "@/api/menu";
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
const props = defineProps({
|
||||
type: String
|
||||
})
|
||||
const dataPermissionsOption = [
|
||||
{label: '全部', value: '全部'},
|
||||
]
|
||||
defineExpose({
|
||||
resetData,
|
||||
})
|
||||
const rules = reactive({
|
||||
roleName: [
|
||||
{required: true, message: '请输入角色名称', trigger: ['blur', 'change']},
|
||||
],
|
||||
roleMark: [
|
||||
roleCode: [
|
||||
{required: true, message: '请输入角色标识', trigger: ['blur', 'change']},
|
||||
],
|
||||
dataPermissions: [
|
||||
{required: true, message: '请选择数据权限', trigger: ['blur', 'change']},
|
||||
]
|
||||
})
|
||||
const formRef = ref()
|
||||
const formData = ref({
|
||||
id: '',
|
||||
roleId: '',
|
||||
roleName: '',
|
||||
roleMark: '',
|
||||
roleRemark: '',
|
||||
dataPermissions: '',
|
||||
roleCode: '',
|
||||
roleDesc: '',
|
||||
menuIds: []
|
||||
} as any)
|
||||
const treeRef = ref();
|
||||
const treeProps = {
|
||||
label: 'menuName',
|
||||
label: 'name',
|
||||
children: 'children'
|
||||
}
|
||||
const expandedKey = ref<string[]>([])
|
||||
const treeData = ref()
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
resetData()
|
||||
treeData.value = getMenuData()
|
||||
getMenuTree();
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
formData,
|
||||
resetData,
|
||||
})
|
||||
const getMenuTree = () => {
|
||||
menuApi.getMenuTree().then((res: any) => {
|
||||
treeData.value = res.data;
|
||||
})
|
||||
}
|
||||
|
||||
function close() {
|
||||
emit('close')
|
||||
|
@ -83,10 +82,10 @@ function close() {
|
|||
function resetData() {
|
||||
formRef.value.resetFields()
|
||||
formData.value = {
|
||||
id: '',
|
||||
roleId: '',
|
||||
roleName: '',
|
||||
roleMark: '',
|
||||
roleRemark: '',
|
||||
roleCode: '',
|
||||
roleDesc: '',
|
||||
dataPermissions: '',
|
||||
}
|
||||
}
|
||||
|
@ -94,13 +93,24 @@ function resetData() {
|
|||
const saveData = async () => {
|
||||
await formRef.value.validate((valid: any, fields: any) => {
|
||||
if (valid) {
|
||||
ElMessage.success('保存成功!')
|
||||
close()
|
||||
} else {
|
||||
// console.log('error submit!', fields)
|
||||
const form = Object.assign({}, formData.value);
|
||||
form.menuIds = form.menuIds.join(",");
|
||||
roleApi.addRole(form).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
ElMessage.success('保存成功!');
|
||||
close();
|
||||
} else {
|
||||
ElMessage.error(res.msg ? res.msg : "保存失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const checkChange = () => {
|
||||
formData.value.menuIds = treeRef.value.getCheckedKeys();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
|
|
@ -59,6 +59,7 @@ const isFormDialog = ref(false)
|
|||
const formDialogTitle = ref('')
|
||||
const queryParams = ref('')
|
||||
const tableData = ref([] as any)
|
||||
const tableMap: any = {};
|
||||
|
||||
onMounted(() => {
|
||||
initData();
|
||||
|
@ -84,32 +85,31 @@ function resetSearch() {
|
|||
function getMenuTree(name?: string) {
|
||||
menuApi.getMenuTree(name).then((res: any) => {
|
||||
tableData.value = res.data;
|
||||
updateMenuTree(res.data, tableData.value);
|
||||
initTableMap(tableData.value);
|
||||
})
|
||||
}
|
||||
|
||||
function updateMenuTree(source: any[], target: any[]) {
|
||||
target.forEach((row: any) => {
|
||||
function initTableMap(data: any) {
|
||||
data.forEach((row: any, i: number) => {
|
||||
handleInitTree(row, i, []);
|
||||
});
|
||||
}
|
||||
|
||||
const queryData = (e: any) => {
|
||||
loading.value = true
|
||||
tableData.value = []
|
||||
setTimeout(() => {
|
||||
while (tableData.value.length < 10) {
|
||||
tableData.value.push({
|
||||
id: tableData.value.length,
|
||||
menuName: e.menuName,
|
||||
order: tableData.value.length + 1,
|
||||
icon: 'icon-shouye-zhihui',
|
||||
route: '/permissions-manage',
|
||||
type: '菜单',
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
}, 200);
|
||||
function handleInitTree(row: any, i: number, pArr: any) {
|
||||
// 当前序列
|
||||
const cArr: any = [].concat(pArr);
|
||||
cArr.push(i);
|
||||
|
||||
tableMap[row.id] = cArr;
|
||||
row.indexArr = cArr;
|
||||
if (row.children) {
|
||||
row.children.forEach((row: any, i: number) => {
|
||||
handleInitTree(row, i, cArr);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const addData = (menu?: any) => {
|
||||
isFormDialog.value = true
|
||||
formDialogTitle.value = '添加'
|
||||
|
@ -141,6 +141,7 @@ const removeData = (e?: any) => {
|
|||
ElMessage.error(res.msg ? res.msg : "删除失败");
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
})
|
||||
}
|
||||
const editData = (e: any) => {
|
||||
|
|
|
@ -1,63 +1,65 @@
|
|||
<template>
|
||||
<div class="table-page">
|
||||
<div class="search-part" v-show="isSearch">
|
||||
<div class="search-cell">
|
||||
<span class="label">角色名称</span>
|
||||
<el-input v-model="queryParams" placeholder="请输入角色名称"></el-input>
|
||||
</div>
|
||||
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
|
||||
<el-button icon="Refresh" @click="queryParams = {}">重置</el-button>
|
||||
</div>
|
||||
<div class="button-part" style="justify-content: space-between;">
|
||||
<div>
|
||||
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
|
||||
<el-button icon="FirstAidKit" @click="importData">导入</el-button>
|
||||
<el-button icon="Delete" @click="removeData()">删除</el-button>
|
||||
</div>
|
||||
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="queryData({})" @downloadBtn="exportData('角色数据', tableData)"></TableAbility>
|
||||
</div>
|
||||
<div class="table-part">
|
||||
<el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip
|
||||
@row-click="tableRowClick">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column type="index" label="#" width="55" align="center" />
|
||||
<el-table-column property="roleName" label="角色名称" width="120" align="center" />
|
||||
<el-table-column property="roleMark" label="角色标识" width="180" align="center" />
|
||||
<el-table-column property="roleRemark" label="角色描述" width="120" align="center" />
|
||||
<el-table-column property="dataPermissions" label="数据权限" width="120" align="center" />
|
||||
<el-table-column label="创建时间" width="220" align="center">
|
||||
<template #default="scope">{{ scope.row.createdTime }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<span @click.stop>
|
||||
<el-button link icon="RefreshLeft" @click="empower(scope.row)">授权</el-button>
|
||||
<el-button link icon="EditPen" @click="editData(scope.row)">修改</el-button>
|
||||
<el-button link icon="Delete" @click="removeData(scope.row)">删除</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="pagination-part">
|
||||
<CommonPagination :total="100" @paginationChange="paginationChange" />
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="30%">
|
||||
<RoleForm ref="RoleFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'" @close="isFormDialog = false" />
|
||||
</el-dialog>
|
||||
<ImportDialog ref="importDialogRef" title="角色导入" templateUrl="#" importUrl="#" />
|
||||
<EmpowerDialog ref="empowerDialogRef" />
|
||||
<div class="table-page">
|
||||
<div class="search-part" v-show="isSearch">
|
||||
<div class="search-cell">
|
||||
<span class="label">角色名称</span>
|
||||
<el-input v-model="queryParams" placeholder="请输入角色名称"></el-input>
|
||||
</div>
|
||||
<el-button type="primary" icon="Search" @click="search">查询</el-button>
|
||||
<el-button icon="Refresh" @click="resetSearch">重置</el-button>
|
||||
</div>
|
||||
<div class="button-part" style="justify-content: space-between;">
|
||||
<div>
|
||||
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
|
||||
<el-button icon="FirstAidKit" @click="importData">导入</el-button>
|
||||
<el-button icon="Delete" @click="removeData()">删除</el-button>
|
||||
</div>
|
||||
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="init"
|
||||
@downloadBtn="exportData('角色数据', tableData)"></TableAbility>
|
||||
</div>
|
||||
<div class="table-part">
|
||||
<el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip
|
||||
@row-click="tableRowClick">
|
||||
<el-table-column type="selection" width="55"/>
|
||||
<el-table-column type="index" label="#" width="55" align="center"/>
|
||||
<el-table-column property="roleName" label="角色名称" width="120" align="center"/>
|
||||
<el-table-column property="roleCode" label="角色标识" width="180" align="center"/>
|
||||
<el-table-column property="roleDesc" label="角色描述" width="120" align="center"/>
|
||||
<el-table-column property="dataPermissions" label="数据权限" width="120" align="center"/>
|
||||
<el-table-column label="创建时间" width="220" align="center">
|
||||
<template #default="scope">{{ scope.row.createTime }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<div @click.stop>
|
||||
<el-button link icon="RefreshLeft" @click="empower(scope.row)">授权</el-button>
|
||||
<el-button link icon="EditPen" @click="editData(scope.row)">修改</el-button>
|
||||
<el-button link icon="Delete" @click="removeData(scope.row)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="pagination-part">
|
||||
<CommonPagination :total="total" @paginationChange="paginationChange"/>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="30%">
|
||||
<RoleForm ref="RoleFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'" @close="isFormDialog = false"/>
|
||||
</el-dialog>
|
||||
<ImportDialog ref="importDialogRef" title="角色导入" templateUrl="#" importUrl="#"/>
|
||||
<EmpowerDialog ref="empowerDialogRef"/>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import {ref} from 'vue'
|
||||
import {onMounted, ref} from 'vue'
|
||||
import {dateFormater} from '@/utils/date-util'
|
||||
import {exportData, tableRemoveRow} from '@/utils/table-util'
|
||||
import CommonPagination from '@/components/common-pagination.vue'
|
||||
import RoleForm from './form/role-form.vue'
|
||||
import ImportDialog from '@/components/import-dialog.vue'
|
||||
import EmpowerDialog from './form/empower-dialog.vue'
|
||||
import * as roleApi from "@/api/role";
|
||||
|
||||
const tableRef = ref()
|
||||
const RoleFormRef = ref()
|
||||
|
@ -69,64 +71,82 @@ const isFormDialog = ref(false)
|
|||
const formDialogTitle = ref('')
|
||||
const queryParams = ref("")
|
||||
const tableData = ref([] as any)
|
||||
let current = 0;
|
||||
let size = 10;
|
||||
const total = ref(0);
|
||||
|
||||
queryData({ roleName: '测试' })
|
||||
onMounted(() => {
|
||||
init();
|
||||
})
|
||||
|
||||
function queryData(e: any) {
|
||||
loading.value = true
|
||||
tableData.value = []
|
||||
setTimeout(() => {
|
||||
while (tableData.value.length < 10) {
|
||||
tableData.value.push({
|
||||
roleName: e.roleName || '测试',
|
||||
roleMark: 'ROLE_ADMIN',
|
||||
roleRemark: '超级管理员',
|
||||
dataPermissions: '全部',
|
||||
createdTime: dateFormater('yyyy-MM-dd HH:mm:ss'),
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
}, 200);
|
||||
function init() {
|
||||
loading.value = true
|
||||
total.value = 0;
|
||||
current = 0;
|
||||
tableData.value = [];
|
||||
getRoleList();
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
function getRoleList() {
|
||||
roleApi.getRoleList(current, size, queryParams.value).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
total.value = res.data.total
|
||||
tableData.value = res.data.records
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function search() {
|
||||
init();
|
||||
}
|
||||
|
||||
function resetSearch() {
|
||||
queryParams.value = "";
|
||||
init();
|
||||
}
|
||||
|
||||
const addData = () => {
|
||||
isFormDialog.value = true
|
||||
formDialogTitle.value = '添加'
|
||||
setTimeout(() => {
|
||||
RoleFormRef.value.resetData()
|
||||
}, 0)
|
||||
isFormDialog.value = true
|
||||
formDialogTitle.value = '添加'
|
||||
setTimeout(() => {
|
||||
RoleFormRef.value.resetData()
|
||||
}, 0)
|
||||
}
|
||||
const importData = () => {
|
||||
setTimeout(() => {
|
||||
importDialogRef.value.open()
|
||||
}, 0);
|
||||
setTimeout(() => {
|
||||
importDialogRef.value.open()
|
||||
}, 0);
|
||||
}
|
||||
const removeData = (e?: any) => {
|
||||
const selectRow = e || tableRef.value.getSelectionRows()
|
||||
tableRemoveRow({ data: selectRow }, (res: boolean) => {
|
||||
if (res) {
|
||||
// console.log('调用删除', selectRow)
|
||||
}
|
||||
})
|
||||
const selectRow = e || tableRef.value.getSelectionRows()
|
||||
tableRemoveRow({data: selectRow}, (res: boolean) => {
|
||||
if (res) {
|
||||
// console.log('调用删除', selectRow)
|
||||
}
|
||||
})
|
||||
}
|
||||
const empower = (e: any) => {
|
||||
setTimeout(() => {
|
||||
empowerDialogRef.value.open()
|
||||
})
|
||||
setTimeout(() => {
|
||||
empowerDialogRef.value.open()
|
||||
})
|
||||
}
|
||||
const editData = (e: any) => {
|
||||
isFormDialog.value = true
|
||||
formDialogTitle.value = '修改'
|
||||
setTimeout(() => {
|
||||
RoleFormRef.value.resetData()
|
||||
RoleFormRef.value.formData = JSON.parse(JSON.stringify(e))
|
||||
}, 0)
|
||||
isFormDialog.value = true
|
||||
formDialogTitle.value = '修改'
|
||||
setTimeout(() => {
|
||||
RoleFormRef.value.resetData()
|
||||
// RoleFormRef.value.formData = JSON.parse(JSON.stringify(e))
|
||||
}, 0)
|
||||
}
|
||||
const tableRowClick = (row: any) => {
|
||||
tableRef.value.toggleRowSelection(row)
|
||||
tableRef.value.toggleRowSelection(row)
|
||||
}
|
||||
|
||||
const paginationChange = (page: number, size: number) => {
|
||||
|
||||
const paginationChange = (page: number, s: number) => {
|
||||
current = page
|
||||
size = s
|
||||
getRoleList()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ const confirmRemote = () => {
|
|||
ElMessage.success('连接成功!')
|
||||
patientInfo.value.isRemote = true
|
||||
patientInfo.value.taskName = '远程控制' + (patientInfo.value.index + 1)
|
||||
patientInfo.value.date = dateFormater("yyyy-MM-dd", patientInfo.value.date)
|
||||
patientInfo.value.date = dateFormater("yyyyMMdd", patientInfo.value.date)
|
||||
unsubscribeLastTask();
|
||||
remoteWsStore.$patch({currentTaskIndex: patientInfo.value.index})
|
||||
remoteWsStore.setRemoteLog({
|
||||
|
|
Loading…
Reference in New Issue
Block a user