fix:权限

This commit is contained in:
大黑 2025-12-26 19:09:11 +08:00
parent d230b62ef1
commit aef6d7d67f
16 changed files with 281853 additions and 258 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,146 @@
{
"entry": "index.js",
"copyAssets": ["public/custom/apaas-custom-mydemo"],
"router": {
"apaas-custom-modalContorl":{
"name": "apaas-custom-modalContorl",
"path": "apaas-custom-modalContorl",
"meta": {
"title": "模板管理"
}
},
"apaas-custom-selfEnginedata":{
"name": "apaas-custom-selfEnginedata",
"path": "apaas-custom-selfEnginedata",
"meta": {
"title": "玉柴发动机数据"
}
},
"apaas-custom-otherEnginedata":{
"name": "apaas-custom-otherEnginedata",
"path": "apaas-custom-otherEnginedata",
"meta": {
"title": "竞品发动机数据"
}
},
"apaas-custom-checkData":{
"name": "apaas-custom-checkData",
"path": "apaas-custom-checkData",
"meta": {
"title": "数据检查"
}
},
"apaas-custom-report":{
"name": "apaas-custom-report",
"path": "apaas-custom-report",
"meta": {
"title": "对标报告"
}
},
"apaas-custom-reportList":{
"name": "apaas-custom-reportList",
"path": "apaas-custom-reportList",
"meta": {
"title": "报告列表"
}
},
"apaas-custom-reportDetail":{
"name": "apaas-custom-reportDetail",
"path": "apaas-custom-reportDetail",
"meta": {
"title": "报告详情"
}
},
"apaas-custom-reportCheck":{
"name": "apaas-custom-reportCheck",
"path": "apaas-custom-reportCheck",
"meta": {
"title": "报告检查"
}
},
"apaas-custom-modelDetail":{
"name": "apaas-custom-modelDetail",
"path": "apaas-custom-modelDetail",
"meta": {
"title": "系统参数管理"
}
},
"apaas-custom-engineDetail":{
"name": "apaas-custom-engineDetail",
"path": "apaas-custom-engineDetail",
"meta": {
"title": "发动机参数详情"
}
},
"apaas-custom-approvalManagement":{
"name": "apaas-custom-approvalManagement",
"path": "apaas-custom-approvalManagement",
"meta": {
"title": "模板审批管理"
}
},
"apaas-custom-toDoList":{
"name": "apaas-custom-toDoList",
"path": "apaas-custom-toDoList",
"meta": {
"title": "数据待办"
}
},
"apaas-custom-myDone":{
"name": "apaas-custom-myDone",
"path": "apaas-custom-myDone",
"meta": {
"title": "我的已办"
}
},
"apaas-custom-mySend":{
"name": "apaas-custom-mySend",
"path": "apaas-custom-mySend",
"meta": {
"title": "我发起的"
}
},
"apaas-custom-selfEngineCheck":{
"name": "apaas-custom-selfEngineCheck",
"path": "apaas-custom-selfEngineCheck",
"meta": {
"title": "玉柴发动机审核"
}
},
"apaas-custom-otherEngineCheck":{
"name": "apaas-custom-otherEngineCheck",
"path": "apaas-custom-otherEngineCheck",
"meta": {
"title": "竞品发动机审核"
}
},
"apaas-custom-managerData":{
"name": "apaas-custom-managerData",
"path": "apaas-custom-managerData",
"meta": {
"title": "责任人管理"
}
},
"apaas-custom-fillerData":{
"name": "apaas-custom-fillerData",
"path": "apaas-custom-fillerData",
"meta": {
"title": "填写人管理"
}
},
"apaas-custom-permissionManagement":{
"name": "apaas-custom-permissionManagement",
"path": "apaas-custom-permissionManagement",
"meta": {
"title": "权限管理"
}
}
},
"customWidgetList": [
{
"code": "mydemo",
"text": "mydemo"
}
],
"outputName": "apaas-custom-mydemo"
}

View File

@ -0,0 +1,10 @@
<meta charset="utf-8">
<title>apaas-custom-mydemo demo</title>
<script src="./apaas-custom-mydemo.umd.js"></script>
<link rel="stylesheet" href="./apaas-custom-mydemo.css">
<script>
console.log(apaas-custom-mydemo)
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -121,6 +121,11 @@
style="background: #E6A23C; padding: 4px 8px; color: white; border-radius: 20px;"
>审核中</span
>
<span
v-else-if="row[colConfig.prop] === 'DRAFT'"
style="background: #909399; padding: 4px 8px; color: white; border-radius: 20px;"
>草稿</span
>
<span
v-else-if="row[colConfig.prop] === 'COMPLETE'"
style="background: #67C23A; padding: 4px 8px; color: white; border-radius: 20px;"

View File

@ -18,7 +18,12 @@
>
<el-form ref="editForm" :model="formData" :rules="formRules" label-width="100px">
<el-form-item label="名称:" prop="name">
<el-input v-model="formData.templateName" placeholder="请输入名称" maxlength="100" />
<el-input
v-model="formData.templateName"
placeholder="请输入名称"
maxlength="100"
:disabled="!isNameEditable"
/>
</el-form-item>
</el-form>
<template v-slot:footer>
@ -45,6 +50,7 @@ export default {
currentRow: null,
userData: getAuthModule(),
mode: 'add', // 'add' 'edit'
currentStatus: '', //
formData: {
templateName: '',
template_status: '',
@ -63,12 +69,23 @@ export default {
computed: {
modalTitle() {
return this.mode === 'add' ? '添加模板' : '修改'
},
//
isNameEditable() {
//
if (this.mode === 'add') {
return true
}
//
const status = this.currentStatus || ''
return status !== '审核中' && status !== 'APPROVING' && status !== 'REVIEWING'
}
},
methods: {
showModal(row, mode = 'edit') {
showModal(row, mode = 'edit', status = '') {
this.mode = mode
this.currentRow = row
this.currentStatus = status || (row && row.status) || ''
//
if (mode === 'add') {
this.formData = {
@ -92,6 +109,7 @@ export default {
closeModal() {
this.visible = false
this.currentRow = null
this.currentStatus = ''
this.formData = {
templateName: '',
template_status: ''

View File

@ -34,13 +34,13 @@
</el-select>
</div>
<div class="search-actions">
<el-button type="primary" @click="handleDownloadImportTemplate">
<el-button v-if="hasTemplateManagementEditPermission()" type="primary" @click="handleDownloadImportTemplate">
下载导入模板
</el-button>
<el-button v-if="isAdmin()" class="import-btn" @click="handleImportTemplate()">
<el-button v-if="hasTemplateManagementEditPermission()" class="import-btn" @click="handleImportTemplate()">
导入参数模板
</el-button>
<el-button v-if="isAdmin()" type="primary" @click="handleAddTemplate()">
<el-button v-if="hasTemplateManagementEditPermission()" type="primary" @click="handleAddTemplate()">
添加参数模板
</el-button>
</div>
@ -104,7 +104,7 @@
</a>
<span class="link-separator"></span>
<a
v-if="row.status === 'DRAFT' && isAdmin()"
v-if="hasTemplateManagementEditPermission()"
href="javascript:void(0)"
class="el-link el-link--primary"
@click.stop="handleRowEdit(row)"
@ -348,9 +348,42 @@ export default {
return false
}
},
// 使 permissionPath
hasTemplateManagementEditPermission() {
// true
if (this.isAdmin()) {
return true
}
try {
const permissionDataStr = localStorage.getItem('user_self_role')
if (!permissionDataStr) {
return false
}
const permissionData = JSON.parse(permissionDataStr)
if (!Array.isArray(permissionData)) {
return false
}
// permissionPath "" parameterPer
// parameterPer 2 "" "2"
return permissionData.some((perm) => {
const permissionPath = perm.permissionPath || ''
const parameterPer = perm.parameterPer
return (
permissionPath === '参数模板管理' &&
(parameterPer === 2 ||
parameterPer === '2' ||
parameterPer === '编辑' ||
parameterPer === 2)
)
})
} catch (err) {
console.error('检查参数模板管理编辑权限失败:', err)
return false
}
},
//
loadUserSelfRole() {
localStorage.setItem('user_self_role', [])
// localStorage.setItem('user_self_role', [])
const request = {
...api.GET_USER_SELF_ROLE,
params: {
@ -369,8 +402,8 @@ export default {
}
// user_self_role menuPath "/"
this.filterTemplateManagementPermissions()
}
this.filterTemplateManagementPermissions()
})
.asyncErrorCatch((err) => {
console.error('获取用户自身角色失败:', err)
@ -750,7 +783,7 @@ export default {
})
},
handleRowEdit(row) {
this.$refs.editModal.showModal(row)
this.$refs.editModal.showModal(row, 'edit', row.status)
},
currentChange(currentPage) {
this.pagination.currentPage = currentPage
@ -927,7 +960,11 @@ export default {
} else {
const request = {
...api.EDIT_MODEL,
params: { ...formData, templateRowId: row.rowId }
params: {
...formData,
templateRowId: row.rowId,
orderNum: row.orderNum || '' // orderNum
}
}
this.$request(request)
.asyncThen((resp) => {

View File

@ -45,7 +45,7 @@
<el-button v-if="shouldShowButtons" class="right-button" @click="handleImport">
导入
</el-button>
<el-button class="right-button" @click="handleDownloadTemplate">
<el-button v-if="hasTemplateManagementPermission()" class="right-button" @click="handleDownloadTemplate">
下载导入模板
</el-button>
<el-button
@ -651,12 +651,20 @@ export default {
return this.versionList || []
},
shouldShowButtonsNew() {
//
if (!this.hasTemplateManagementPermission()) {
return false
}
// GET_MODEL_DETAIL status
const status = this.currentStatus || ''
return status === 'DRAFT' && this.isLatestVersion
},
//
shouldShowButtons() {
//
if (!this.hasTemplateManagementPermission()) {
return false
}
// GET_MODEL_DETAIL status
// DRAFT COMPLETE
const status = this.currentStatus || ''
@ -1241,6 +1249,36 @@ export default {
return false
}
},
// permissionPath: "/"
hasTemplateManagementPermission() {
//
if (this.isAdmin()) {
return true
}
const templateName = this.displayTemplateName
if (!templateName) {
return false
}
try {
const permissionDataStr = localStorage.getItem('user_self_role')
if (!permissionDataStr) {
return false
}
const permissionData = JSON.parse(permissionDataStr)
if (!Array.isArray(permissionData)) {
return false
}
// permissionPath "/"
const expectedPath = `参数模板管理/${templateName}`
return permissionData.some((perm) => {
const permissionPath = perm.permissionPath || ''
return permissionPath === expectedPath
})
} catch (err) {
console.error('检查参数模板管理权限失败:', err)
return false
}
},
// subsystempartsName
hasParameterEditPermission(subsystem, partsName) {
//

View File

@ -229,7 +229,7 @@ export default {
showOverflowTooltip: true,
minWidth: '120'
},
{
prop: 'applicant',
label: '申请人',

View File

@ -6,11 +6,11 @@
竞品发动机数据
</div>
<div class="operation">
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
<el-button class="import-button" @click="handleImport">
<el-button v-if="hasEngineDataEditPermission()" type="primary" @click="handleDownloadTemplate">下载模板</el-button>
<el-button v-if="hasEngineDataEditPermission()" class="import-button" @click="handleImport">
导入机型
</el-button>
<el-button type="primary" class="add-button" @click="handleAdd">
<el-button v-if="hasEngineDataEditPermission()" type="primary" class="add-button" @click="handleAdd">
添加机型
</el-button>
</div>
@ -185,7 +185,6 @@
</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<el-button @click="handleImportDialogClose">取消</el-button>
<el-button type="primary" :loading="importing" @click="handleImportConfirm">
开始导入
@ -343,6 +342,56 @@ export default {
this.loadData()
},
methods: {
// isAdmin === 1
isAdmin() {
try {
const permissionDataStr = localStorage.getItem('user_self_role')
if (!permissionDataStr) {
return false
}
const permissionData = JSON.parse(permissionDataStr)
if (!Array.isArray(permissionData)) {
return false
}
// isAdmin === 1
return permissionData.some((perm) => perm.isAdmin === 1 || perm.isAdmin === '1')
} catch (err) {
console.error('检查管理员权限失败:', err)
return false
}
},
//
hasEngineDataEditPermission() {
//
if (this.isAdmin()) {
return true
}
try {
const permissionDataStr = localStorage.getItem('user_self_role')
if (!permissionDataStr) {
return false
}
const permissionData = JSON.parse(permissionDataStr)
if (!Array.isArray(permissionData)) {
return false
}
// permissionPath "" parameterPer
// parameterPer 2 "" "2"
return permissionData.some((perm) => {
const permissionPath = perm.permissionPath || ''
const parameterPer = perm.parameterPer
return (
permissionPath === '竞品发动机数据' &&
(parameterPer === 2 ||
parameterPer === '2' ||
parameterPer === '编辑')
)
})
} catch (err) {
console.error('检查竞品发动机数据编辑权限失败:', err)
return false
}
},
//
loadUserSelfRole() {
const request = {

View File

@ -107,18 +107,18 @@
<span v-if="data.type === 'subsystem'" class="type-tag subsystem-tag">子系统</span>
<span v-if="data.type === 'parameter'" class="type-tag parameter-tag">参数类型</span> -->
</span>
<span v-if="data.type === 'subsystem' || data.type === 'parameter'" class="permission-checkboxes">
<span v-if="data.type === 'menu' || data.type === 'subsystem' || data.type === 'parameter' || data.type === 'template'" class="permission-checkboxes">
<el-checkbox
v-model="data.permissions.view"
size="small"
@change="data.type === 'subsystem' ? handleSubsystemPermissionChange(data, 'view') : handlePermissionChange(data, 'view')"
@change="handleNodePermissionChange(data, 'view')"
>
查看
</el-checkbox>
<el-checkbox
v-model="data.permissions.edit"
size="small"
@change="data.type === 'subsystem' ? handleSubsystemPermissionChange(data, 'edit') : handlePermissionChange(data, 'edit')"
@change="handleNodePermissionChange(data, 'edit')"
>
编辑
</el-checkbox>
@ -358,7 +358,9 @@ export default {
//
pendingPermissions: [],
//
menuList: ['模板管理', '玉柴发动机数据', '竞品发动机数据'],
menuList: ['参数模板管理', '玉柴发动机数据', '竞品发动机数据', '对标报告'],
//
templateList: [],
//
personConfigDialogVisible: false,
personConfigSubmitting: false,
@ -459,6 +461,7 @@ export default {
mounted() {
this.loadPermissionData()
this.loadParamList()
this.loadTemplateList()
this.loadDepartmentList()
this.getUserSelfRole()
},
@ -573,7 +576,12 @@ export default {
label: menuName,
type: 'menu',
children: null, // null
isLeaf: false // el-tree
//
isLeaf: menuName === '对标报告',
permissions: {
view: false,
edit: false
}
}
//
@ -599,8 +607,19 @@ export default {
resolve(this.menuTreeData || [])
return
}
//
//
if (node.data.type === 'menu') {
//
if (node.data.label === '对标报告') {
resolve([])
return
}
//
if (node.data.label === '参数模板管理') {
this.loadTemplateListForLazy(node.data, resolve)
return
}
//
this.loadMenuSubsystemsForLazy(node.data, resolve)
return
}
@ -609,9 +628,82 @@ export default {
this.loadSubsystemParametersForLazy(node.data, resolve)
return
}
//
//
resolve([])
},
//
loadTemplateList() {
const request = {
...api.GET_MODEL_LIST,
params: {
pageNumber: 1,
pageSize: 999
},
disableSuccessMsg: true
}
this.$request(request, false)
.asyncThen((resp) => {
const list = resp.data.result || []
this.templateList = list.map((item) => ({
templateId: item.rowId || item.id || '',
templateName: item.templateName || ''
}))
console.log('加载模板列表成功,模板数量:', this.templateList.length)
})
.asyncErrorCatch((err) => {
console.error('加载模板列表失败:', err)
this.templateList = []
})
},
//
loadTemplateListForLazy(menuNode, resolve) {
if (!this.templateList || this.templateList.length === 0) {
//
this.loadTemplateList()
//
setTimeout(() => {
this.buildTemplateNodes(menuNode, resolve)
}, 500)
return
}
this.buildTemplateNodes(menuNode, resolve)
},
//
buildTemplateNodes(menuNode, resolve) {
const templateNodes = []
this.templateList.forEach((template, templateIdx) => {
if (!template.templateName) {
return
}
const templateId = `${menuNode.id}-template-${templateIdx}`
const templateNode = {
id: templateId,
label: template.templateName,
type: 'template',
menuName: menuNode.label,
templateId: template.templateId,
templateName: template.templateName,
permissions: {
view: false,
edit: false
},
isLeaf: true, //
children: null
}
templateNodes.push(templateNode)
//
this.nodeMap[templateId] = templateNode
//
this.applyPendingPermissionsToNode(templateNode)
})
// 使 $nextTick
this.$nextTick(() => {
templateNodes.forEach((node) => {
this.applyPendingPermissionsToNode(node)
})
})
resolve(templateNodes)
},
//
loadMenuSubsystemsForLazy(menuNode, resolve) {
// subsystemPartsMap
@ -765,8 +857,20 @@ export default {
})
})
},
//
handlePermissionChange(data, permissionType) {
//
handleNodePermissionChange(data, permissionType) {
//
if (permissionType === 'edit' && data.permissions && data.permissions.edit === true) {
//
if (!data.permissions.view) {
this.$set(data.permissions, 'view', true)
}
//
if (data.id && this.nodeMap[data.id]) {
this.$set(this.nodeMap[data.id].permissions, 'view', true)
}
}
//
if (data.id && this.nodeMap[data.id]) {
// 使 $set
@ -776,8 +880,22 @@ export default {
data.permissions[permissionType]
)
}
//
this.updateSubsystemPermissionFromChildren(data)
// /
if (data.type === 'menu') {
this.handleMenuPermissionChange(data, permissionType)
} else if (data.type === 'subsystem') {
// /
this.handleSubsystemPermissionChange(data, permissionType)
this.updateMenuPermissionFromChildren(data)
} else if (data.type === 'template') {
//
this.updateMenuPermissionFromChildren(data)
} else if (data.type === 'parameter') {
//
this.updateSubsystemPermissionFromChildren(data)
}
//
this.$nextTick(() => {
if (this.$refs.form) {
@ -785,6 +903,265 @@ export default {
}
})
},
// /
handleMenuPermissionChange(menuNode, permissionType) {
const isChecked = menuNode.permissions[permissionType]
const menuName = menuNode.label || ''
//
if (permissionType === 'edit' && isChecked) {
this.$set(menuNode.permissions, 'view', true)
if (menuNode.id && this.nodeMap[menuNode.id]) {
this.$set(this.nodeMap[menuNode.id].permissions, 'view', true)
}
}
//
const setChildrenPermissions = (node) => {
if (node.children && Array.isArray(node.children)) {
node.children.forEach((childNode) => {
if (childNode.id && this.nodeMap[childNode.id]) {
const childNodeInMap = this.nodeMap[childNode.id]
//
if (!childNodeInMap.permissions) {
this.$set(childNodeInMap, 'permissions', { view: false, edit: false })
}
//
this.$set(childNodeInMap.permissions, permissionType, isChecked)
//
if (permissionType === 'edit' && isChecked) {
this.$set(childNodeInMap.permissions, 'view', true)
}
//
if (childNode.permissions) {
const newPermissions = {
...childNode.permissions,
[permissionType]: isChecked
}
//
if (permissionType === 'edit' && isChecked) {
newPermissions.view = true
}
this.$set(childNode, 'permissions', newPermissions)
}
//
setChildrenPermissions(childNode)
}
})
}
}
setChildrenPermissions(menuNode)
//
if (isChecked) {
// pendingPermissions
if (!this.pendingPermissions) {
this.pendingPermissions = []
}
const userId = getUserId()
const parameterPer = permissionType === 'view' ? 1 : 2
//
if (menuName === '参数模板管理') {
// /
this.templateList.forEach((template) => {
if (template.templateName) {
const permissionPath = `${menuName}/${template.templateName}`
//
const existingPerm = this.pendingPermissions.find(
(perm) => perm.permissionPath === permissionPath && perm.parameterPer === parameterPer
)
if (!existingPerm) {
this.pendingPermissions.push({
permissionPath: permissionPath,
parameterPer: parameterPer,
userId: userId
})
}
}
})
} else if (menuName === '玉柴发动机数据' || menuName === '竞品发动机数据') {
// //
Object.keys(this.subsystemPartsMap || {}).forEach((subsystemName) => {
const partsNames = this.subsystemPartsMap[subsystemName] || []
partsNames.forEach((partsName) => {
if (partsName) {
const permissionPath = `${menuName}/${subsystemName}/${partsName}`
//
const existingPerm = this.pendingPermissions.find(
(perm) => perm.permissionPath === permissionPath && perm.parameterPer === parameterPer
)
if (!existingPerm) {
this.pendingPermissions.push({
permissionPath: permissionPath,
parameterPer: parameterPer,
userId: userId
})
}
}
})
})
} else if (menuName === '对标报告') {
//
const menuPath = this.buildPermissionPath(menuNode)
if (menuPath) {
const existingPerm = this.pendingPermissions.find(
(perm) => perm.permissionPath === menuPath && perm.parameterPer === parameterPer
)
if (!existingPerm) {
this.pendingPermissions.push({
permissionPath: menuPath,
parameterPer: parameterPer,
userId: userId
})
}
}
}
//
if (permissionType === 'edit') {
const viewParameterPer = 1
if (menuName === '参数模板管理') {
this.templateList.forEach((template) => {
if (template.templateName) {
const permissionPath = `${menuName}/${template.templateName}`
const existingPerm = this.pendingPermissions.find(
(perm) => perm.permissionPath === permissionPath && perm.parameterPer === viewParameterPer
)
if (!existingPerm) {
this.pendingPermissions.push({
permissionPath: permissionPath,
parameterPer: viewParameterPer,
userId: userId
})
}
}
})
} else if (menuName === '玉柴发动机数据' || menuName === '竞品发动机数据') {
Object.keys(this.subsystemPartsMap || {}).forEach((subsystemName) => {
const partsNames = this.subsystemPartsMap[subsystemName] || []
partsNames.forEach((partsName) => {
if (partsName) {
const permissionPath = `${menuName}/${subsystemName}/${partsName}`
const existingPerm = this.pendingPermissions.find(
(perm) => perm.permissionPath === permissionPath && perm.parameterPer === viewParameterPer
)
if (!existingPerm) {
this.pendingPermissions.push({
permissionPath: permissionPath,
parameterPer: viewParameterPer,
userId: userId
})
}
}
})
})
} else if (menuName === '对标报告') {
const menuPath = this.buildPermissionPath(menuNode)
if (menuPath) {
const existingPerm = this.pendingPermissions.find(
(perm) => perm.permissionPath === menuPath && perm.parameterPer === viewParameterPer
)
if (!existingPerm) {
this.pendingPermissions.push({
permissionPath: menuPath,
parameterPer: viewParameterPer,
userId: userId
})
}
}
}
}
} else {
// pendingPermissions
if (this.pendingPermissions) {
const parameterPer = permissionType === 'view' ? 1 : 2
//
this.pendingPermissions = this.pendingPermissions.filter((perm) => {
//
if (perm.permissionPath && perm.permissionPath.startsWith(menuName + '/')) {
return perm.parameterPer !== parameterPer
}
//
if (menuName === '对标报告' && perm.permissionPath === menuName) {
return perm.parameterPer !== parameterPer
}
return true
})
//
if (permissionType === 'edit') {
const viewParameterPer = 1
this.pendingPermissions = this.pendingPermissions.filter((perm) => {
if (perm.permissionPath && perm.permissionPath.startsWith(menuName + '/')) {
return perm.parameterPer !== viewParameterPer
}
if (menuName === '对标报告' && perm.permissionPath === menuName) {
return perm.parameterPer !== viewParameterPer
}
return true
})
}
}
}
},
//
updateMenuPermissionFromChildren(node) {
let menuNode = null
// 使
if (node && node.type === 'menu') {
menuNode = node
} else if (node && node.menuName) {
//
menuNode = Object.values(this.nodeMap).find(
(n) => n.type === 'menu' && n.label === node.menuName
)
}
if (!menuNode) {
return
}
//
const allDescendants = []
const collectDescendants = (n) => {
if (n.children && Array.isArray(n.children)) {
n.children.forEach((child) => {
allDescendants.push(child)
collectDescendants(child)
})
}
}
collectDescendants(menuNode)
if (allDescendants.length === 0) {
//
return
}
//
const allViewChecked = allDescendants.every((child) => {
const childNode = this.nodeMap[child.id]
return childNode && childNode.permissions && childNode.permissions.view === true
})
const allEditChecked = allDescendants.every((child) => {
const childNode = this.nodeMap[child.id]
return childNode && childNode.permissions && childNode.permissions.edit === true
})
//
if (!menuNode.permissions) {
this.$set(menuNode, 'permissions', { view: false, edit: false })
}
this.$set(menuNode.permissions, 'view', allViewChecked)
this.$set(menuNode.permissions, 'edit', allEditChecked)
},
// -
handlePermissionChange(data, permissionType) {
this.handleNodePermissionChange(data, permissionType)
},
// /
handleSubsystemPermissionChange(data, permissionType) {
//
@ -796,20 +1173,40 @@ export default {
data.permissions[permissionType]
)
}
//
if (permissionType === 'edit' && data.permissions && data.permissions.edit === true) {
this.$set(data.permissions, 'view', true)
if (data.id && this.nodeMap[data.id]) {
this.$set(this.nodeMap[data.id].permissions, 'view', true)
}
}
//
const children = data.children || []
const isChecked = data.permissions[permissionType]
// /
children.forEach((childNode) => {
if (childNode.id && this.nodeMap[childNode.id]) {
//
if (!this.nodeMap[childNode.id].permissions) {
this.$set(this.nodeMap[childNode.id], 'permissions', { view: false, edit: false })
}
//
this.$set(this.nodeMap[childNode.id].permissions, permissionType, isChecked)
//
if (permissionType === 'edit' && isChecked) {
this.$set(this.nodeMap[childNode.id].permissions, 'view', true)
}
//
if (childNode.permissions) {
this.$set(childNode, 'permissions', {
const newPermissions = {
...childNode.permissions,
[permissionType]: isChecked
})
}
//
if (permissionType === 'edit' && isChecked) {
newPermissions.view = true
}
this.$set(childNode, 'permissions', newPermissions)
}
}
})
@ -1372,19 +1769,27 @@ export default {
}
}
// userOrDeptId "ID:"
const processedUserOrDeptId = userOrDeptId.map((id) => {
if (typeof id === 'string' && id.startsWith('ID:')) {
return id.substring(3) // "ID:" 3
}
return id
})
console.log('人员配置数据:', {
roleId: this.personConfigFormData.roleId,
roleName: this.personConfigFormData.roleName,
configType: this.personConfigFormData.configType,
isDept: isDept,
userOrDeptIds: userOrDeptId
userOrDeptIds: processedUserOrDeptId
})
const request = {
...api.GET_ROLE_PERMISSION_BING,
params: {
roleId: this.personConfigFormData.roleId,
userOrDeptIds: userOrDeptId,
userOrDeptIds: processedUserOrDeptId,
isDept: isDept
},
disableSuccessMsg: true
@ -1456,8 +1861,11 @@ export default {
Object.keys(this.nodeMap).forEach((key) => {
const node = this.nodeMap[key]
if (node && node.permissions) {
node.permissions.view = false
node.permissions.edit = false
this.$set(node.permissions, 'view', false)
this.$set(node.permissions, 'edit', false)
} else if (node && (node.type === 'menu' || node.type === 'template' || node.type === 'parameter')) {
//
this.$set(node, 'permissions', { view: false, edit: false })
}
})
},
@ -1472,8 +1880,8 @@ export default {
//
setPermissionsFromData(permissions) {
// permissions
// { id, subsystem, partsName, parameterPer }
// parameterPer "" ""
// { permissionPath, parameterPer, roleId, userId }
// parameterPer 12
const permArray = Array.isArray(permissions) ? permissions : []
//
@ -1482,68 +1890,71 @@ export default {
//
this.pendingPermissions = permArray
// subsystem partsName
const permissionMap = new Map() // key: `${subsystem}-${partsName}`, value: { view: boolean, edit: boolean }
// permissionPath
const permissionMap = new Map() // key: permissionPath, value: { view: boolean, edit: boolean }
permArray.forEach((perm) => {
const subsystem = perm.subsystem || ''
const partsName = perm.partsName || ''
const key = `${subsystem}-${partsName}`
const permissionPath = perm.permissionPath || ''
if (!permissionPath) {
return
}
if (!permissionMap.has(key)) {
permissionMap.set(key, {
subsystem: subsystem,
partsName: partsName,
if (!permissionMap.has(permissionPath)) {
permissionMap.set(permissionPath, {
permissionPath: permissionPath,
view: false,
edit: false
})
}
const permData = permissionMap.get(key)
if (perm.parameterPer === '查看') {
const permData = permissionMap.get(permissionPath)
// parameterPer 12
if (perm.parameterPer === 1 || perm.parameterPer === '1' || perm.parameterPer === '查看') {
permData.view = true
} else if (perm.parameterPer === '编辑') {
} else if (perm.parameterPer === 2 || perm.parameterPer === '2' || perm.parameterPer === '编辑') {
permData.edit = true
}
})
// subsystem partsName
permissionMap.forEach((permData, key) => {
// permissionPath
permissionMap.forEach((permData, permissionPath) => {
//
if (permData.edit && !permData.view) {
permData.view = true
}
Object.keys(this.nodeMap).forEach((nodeId) => {
const node = this.nodeMap[nodeId]
if (node && node.type === 'parameter') {
//
const subsystemMatch =
permData.subsystem && node.subsystem && permData.subsystem === node.subsystem
// partsName
const partsNameMatch =
permData.partsName &&
(node.partsName || node.parameterName || node.label) &&
permData.partsName === (node.partsName || node.parameterName || node.label)
if (!node) {
return
}
if (subsystemMatch && partsNameMatch) {
// 使 $set
const newPermissions = {
view: permData.view || false,
edit: permData.edit || false
}
this.$set(node, 'permissions', newPermissions)
console.log(
'设置已加载节点权限:',
node.id,
node.label,
{
subsystem: node.subsystem,
partsName: node.partsName || node.parameterName || node.label
},
newPermissions
)
// permissionPath
const nodePath = this.buildPermissionPath(node)
if (nodePath === permissionPath) {
// 使 $set
const newPermissions = {
view: permData.view || false,
edit: permData.edit || false
}
//
if (newPermissions.edit && !newPermissions.view) {
newPermissions.view = true
}
this.$set(node, 'permissions', newPermissions)
console.log(
'设置已加载节点权限:',
node.id,
node.label,
node.type,
permissionPath,
newPermissions
)
}
})
})
//
//
this.$nextTick(() => {
//
Object.keys(this.nodeMap).forEach((nodeId) => {
const node = this.nodeMap[nodeId]
if (node && node.type === 'subsystem' && node.children && node.children.length > 0) {
@ -1564,6 +1975,13 @@ export default {
}
}
})
//
Object.keys(this.nodeMap).forEach((nodeId) => {
const node = this.nodeMap[nodeId]
if (node && node.type === 'menu') {
this.updateMenuPermissionFromChildren(node)
}
})
})
console.log(
@ -1575,123 +1993,172 @@ export default {
},
//
applyPendingPermissionsToNode(node) {
if (
!node ||
node.type !== 'parameter' ||
!this.pendingPermissions ||
this.pendingPermissions.length === 0
) {
if (!node || !this.pendingPermissions || this.pendingPermissions.length === 0) {
return
}
// subsystem partsName
const matchingPerms = this.pendingPermissions.filter((perm) => {
//
const subsystemMatch = perm.subsystem && node.subsystem && perm.subsystem === node.subsystem
// partsName
const partsNameMatch =
perm.partsName &&
(node.partsName || node.parameterName || node.label) &&
perm.partsName === (node.partsName || node.parameterName || node.label)
//
const nodePath = this.buildPermissionPath(node)
if (!nodePath) {
return
}
return subsystemMatch && partsNameMatch
// permissionPath
const matchingPerms = this.pendingPermissions.filter((perm) => {
const permissionPath = perm.permissionPath || ''
return permissionPath === nodePath
})
if (matchingPerms.length > 0) {
//
if (!node.permissions) {
this.$set(node, 'permissions', { view: false, edit: false })
}
// parameterPer "" ""
let hasView = false
let hasEdit = false
matchingPerms.forEach((perm) => {
if (perm.parameterPer === '查看') {
hasView = true
} else if (perm.parameterPer === '编辑') {
hasEdit = true
}
})
// 使 $set
const newPermissions = {
view: hasView,
edit: hasEdit
}
// nodeMap
if (this.nodeMap[node.id]) {
this.$set(this.nodeMap[node.id], 'permissions', newPermissions)
}
//
this.$set(node, 'permissions', newPermissions)
console.log(
'应用权限到节点:',
node.id,
node.label,
{
menuName: node.menuName,
subsystem: node.subsystem,
parameterName: node.parameterName || node.label
},
newPermissions,
'匹配的权限:',
matchingPerms
)
//
this.$nextTick(() => {
this.updateSubsystemPermissionFromChildren(node)
})
//
if (matchingPerms.length === 0) {
return
}
//
if (!node.permissions) {
this.$set(node, 'permissions', { view: false, edit: false })
}
// parameterPer 12
let hasView = false
let hasEdit = false
matchingPerms.forEach((perm) => {
if (perm.parameterPer === 1 || perm.parameterPer === '1' || perm.parameterPer === '查看') {
hasView = true
} else if (perm.parameterPer === 2 || perm.parameterPer === '2' || perm.parameterPer === '编辑') {
hasEdit = true
}
})
//
if (hasEdit && !hasView) {
hasView = true
}
// 使 $set
const newPermissions = {
view: hasView,
edit: hasEdit
}
// nodeMap
if (this.nodeMap[node.id]) {
this.$set(this.nodeMap[node.id], 'permissions', newPermissions)
}
//
this.$set(node, 'permissions', newPermissions)
console.log(
'应用权限到节点:',
node.id,
node.label,
node.type,
nodePath,
newPermissions,
'匹配的权限:',
matchingPerms
)
//
this.$nextTick(() => {
if (node.type === 'parameter') {
this.updateSubsystemPermissionFromChildren(node)
} else if (node.type === 'subsystem') {
this.updateMenuPermissionFromChildren(node)
}
})
},
// permissionPath
buildPermissionPath(node) {
if (!node) {
return ''
}
//
if (node.type === 'menu') {
return node.label || ''
}
// /
if (node.type === 'subsystem') {
const menuName = node.menuName || ''
const subsystemName = node.subsystem || node.label || ''
return `${menuName}/${subsystemName}`
}
// //
if (node.type === 'parameter') {
const menuName = node.menuName || ''
const subsystemName = node.subsystem || ''
const parameterName = node.partsName || node.parameterName || node.label || ''
return `${menuName}/${subsystemName}/${parameterName}`
}
// /
if (node.type === 'template') {
const menuName = node.menuName || ''
const templateName = node.templateName || node.label || ''
return `${menuName}/${templateName}`
}
return ''
},
//
collectPermissions() {
const permissions = []
const roleId = this.formData.rowId || ''
const roleId = this.formData.rowId || '' // roleId
const userId = getUserId()
// nodeMap
// nodeMap
Object.keys(this.nodeMap).forEach((nodeId) => {
const node = this.nodeMap[nodeId]
if (node && node.type === 'parameter') {
//
const nodePermissions = node.permissions || { view: false, edit: false }
// partsName
const subsystem = node.subsystem || ''
const partsName = node.partsName || node.parameterName || node.label || ''
if (!node) {
return
}
// parameterPer = 1
if (nodePermissions.view) {
permissions.push({
roleId: roleId,
subsystem: subsystem,
partsName: partsName,
parameterPer: 1, // 1
userId: userId
})
//
const nodePermissions = node.permissions || { view: false, edit: false }
// view edit true
if (!nodePermissions.view && !nodePermissions.edit) {
return
}
//
const permissionPath = this.buildPermissionPath(node)
if (!permissionPath) {
return
}
//
if (nodePermissions.view) {
const perm = {
permissionPath: permissionPath,
parameterPer: 1, // 1
userId: userId
}
// parameterPer = 2
if (nodePermissions.edit) {
permissions.push({
roleId: roleId,
subsystem: subsystem,
partsName: partsName,
parameterPer: 2, // 2
userId: userId
})
// roleId
if (roleId) {
perm.roleId = roleId
}
permissions.push(perm)
}
//
if (nodePermissions.edit) {
const perm = {
permissionPath: permissionPath,
parameterPer: 2, // 2
userId: userId
}
// roleId
if (roleId) {
perm.roleId = roleId
}
permissions.push(perm)
}
})
console.log(
'收集到的权限:',
permissions,
'nodeMap中的参数节点数量:',
Object.keys(this.nodeMap).filter(
(id) => this.nodeMap[id] && this.nodeMap[id].type === 'parameter'
).length
)
console.log('收集到的权限:', permissions)
return permissions
},
//

View File

@ -6,11 +6,11 @@
玉柴发动机数据
</div>
<div class="operation">
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
<el-button class="import-button" @click="handleImport">
<el-button v-if="hasEngineDataEditPermission()" type="primary" @click="handleDownloadTemplate">下载模板</el-button>
<el-button v-if="hasEngineDataEditPermission()" class="import-button" @click="handleImport">
导入机型
</el-button>
<el-button type="primary" class="add-button" @click="handleAdd">
<el-button v-if="hasEngineDataEditPermission()" type="primary" class="add-button" @click="handleAdd">
添加机型
</el-button>
</div>
@ -109,7 +109,7 @@
查看
</a>
<a
v-if="row.distributeStatus != '已分发'"
v-if="row.distributeStatus != '已分发' && hasEngineDataEditPermission()"
href="javascript:void(0)"
class="el-link el-link--primary"
style="margin-left: 5px;"
@ -343,6 +343,56 @@ export default {
this.loadData()
},
methods: {
// isAdmin === 1
isAdmin() {
try {
const permissionDataStr = localStorage.getItem('user_self_role')
if (!permissionDataStr) {
return false
}
const permissionData = JSON.parse(permissionDataStr)
if (!Array.isArray(permissionData)) {
return false
}
// isAdmin === 1
return permissionData.some((perm) => perm.isAdmin === 1 || perm.isAdmin === '1')
} catch (err) {
console.error('检查管理员权限失败:', err)
return false
}
},
//
hasEngineDataEditPermission() {
//
if (this.isAdmin()) {
return true
}
try {
const permissionDataStr = localStorage.getItem('user_self_role')
if (!permissionDataStr) {
return false
}
const permissionData = JSON.parse(permissionDataStr)
if (!Array.isArray(permissionData)) {
return false
}
// permissionPath "" parameterPer
// parameterPer 2 "" "2"
return permissionData.some((perm) => {
const permissionPath = perm.permissionPath || ''
const parameterPer = perm.parameterPer
return (
permissionPath === '玉柴发动机数据' &&
(parameterPer === 2 ||
parameterPer === '2' ||
parameterPer === '编辑')
)
})
} catch (err) {
console.error('检查玉柴发动机数据编辑权限失败:', err)
return false
}
},
//
loadUserSelfRole() {
const request = {

View File

@ -1,6 +1,10 @@
<template>
<div class="apaas-custom-page-todo custom-page">
<template v-if="!showEngineDetail && !showEngineCheck && !showApprovalProgressDetail && !showReportDetail">
<template
v-if="
!showEngineDetail && !showEngineCheck && !showApprovalProgressDetail && !showReportDetail
"
>
<div class="page-header">
<div class="title">
我的待办
@ -35,13 +39,27 @@
@current-page-change="currentChange"
@select-data-change="selectDataChange"
>
<template v-for="(colConfig, index) in tableConfig.colConfigs" v-slot:[colConfig.customSlot]="{ row, rowIndex }">
<template
v-for="(colConfig, index) in tableConfig.colConfigs"
v-slot:[colConfig.customSlot]="{ row, rowIndex }"
>
<div v-if="colConfig.customSlot === 'options'" :key="'op' + index + '' + rowIndex">
<a href="javascript:void(0)" class="el-link el-link--primary" @click.stop="handleRowView(row)">查看</a>
</div>
<span style="width: 6px; display: inline-block"></span>
<div v-if="colConfig.customSlot === 'options'" :key="'op' + index + '' + rowIndex">
<a href="javascript:void(0)" class="el-link el-link--primary" @click.stop="handleRowBack(row)">退回</a>
<a
href="javascript:void(0)"
class="el-link el-link--primary"
@click.stop="handleRowView(row)"
>查看</a
>
<span
v-if="row.dataType === '数据维护'"
style="width: 6px; display: inline-block"
></span>
<a
href="javascript:void(0)"
class="el-link el-link--primary"
@click.stop="handleRowBack(row)"
>退回</a
>
</div>
</template>
@ -145,10 +163,29 @@ export default {
{ prop: 'currentNode', label: '当前环节', showOverflowTooltip: true, minWidth: '140' },
// { prop: 'statusCode', label: '', showOverflowTooltip: true, minWidth: '120' },
// { prop: 'modelName', label: '', showOverflowTooltip: true, minWidth: '120' },
{ prop: 'currentProcessor', label: '当前处理人', showOverflowTooltip: true, minWidth: '120' },
{
prop: 'currentProcessor',
label: '当前处理人',
showOverflowTooltip: true,
minWidth: '120'
},
{ prop: 'createdBy', label: '创建人', showOverflowTooltip: true, minWidth: '120' },
{ prop: 'creationDate', label: '创建时间', showOverflowTooltip: true, minWidth: '160', align: 'center', formatter: this.formatDateTime },
{ prop: 'options', label: '操作', customSlot: 'options', align: 'center', width: '100', fixed: 'right' }
{
prop: 'creationDate',
label: '创建时间',
showOverflowTooltip: true,
minWidth: '160',
align: 'center',
formatter: this.formatDateTime
},
{
prop: 'options',
label: '操作',
customSlot: 'options',
align: 'center',
width: '100',
fixed: 'right'
}
],
seqType: '',
seqConfig: {},
@ -168,6 +205,38 @@ export default {
rowClickEvent(row) {
console.warn(row)
},
//退
handleRowBack(row) {
this.$confirm('确定退回吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
const request = {
...api.HANDLE_FILLER_BACK,
params: {
userId: getUserId(),
steps: '填写人退回',
todoTaskId: row.id,
modelID: row.modelId
},
disableSuccessMsg: true
}
this.$request(request)
.asyncThen((resp) => {
this.$message.success('退回成功')
this.loadData()
})
.asyncErrorCatch((err) => {
console.error('退回失败:', err)
this.$message.error('退回失败')
})
})
.catch(() => {
this.$message.info('已取消')
})
},
handleRowView(row) {
//
const dataType = row.dataType || ''
@ -345,82 +414,82 @@ export default {
<style lang="scss">
.custom-page {
width: 100%;
height: 100%;
overflow-y: auto !important;
width: 100%;
height: 100%;
overflow-y: auto !important;
display: flex;
flex-direction: column;
.page-header {
display: flex;
flex-direction: column;
align-items: center;
height: 56px;
position: relative;
width: 100%;
min-height: 56px;
background: #fff;
border-bottom: 1px solid #ebeef5;
flex-shrink: 0;
.page-header {
display: flex;
align-items: center;
height: 56px;
position: relative;
width: 100%;
min-height: 56px;
background: #fff;
border-bottom: 1px solid #ebeef5;
flex-shrink: 0;
.title {
color: #303133;
font-weight: 700;
margin-left: 20px;
flex: 1;
font-size: 12px;
}
.operation {
display: flex;
min-width: 330px;
justify-content: flex-end !important;
margin-right: 20px;
}
.title {
color: #303133;
font-weight: 700;
margin-left: 20px;
flex: 1;
font-size: 12px;
}
.page-data-list {
.operation {
display: flex;
flex: 1;
min-height: 0;
padding: 20px;
.x-empty-page {
top: 0;
}
}
.engine-detail-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
}
.engine-check-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
}
.approval-progress-detail-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
.report-detail-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
min-width: 330px;
justify-content: flex-end !important;
margin-right: 20px;
}
}
.page-data-list {
display: flex;
flex: 1;
min-height: 0;
padding: 20px;
.x-empty-page {
top: 0;
}
}
.engine-detail-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
}
.engine-check-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
}
.approval-progress-detail-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
.report-detail-wrapper {
width: 100%;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
min-height: 0;
}
}
</style>