fix:权限
This commit is contained in:
parent
d230b62ef1
commit
aef6d7d67f
140338
apaas-custom-mydemo/apaas-custom-mydemo.common.js
Normal file
140338
apaas-custom-mydemo/apaas-custom-mydemo.common.js
Normal file
File diff suppressed because one or more lines are too long
1
apaas-custom-mydemo/apaas-custom-mydemo.css
Normal file
1
apaas-custom-mydemo/apaas-custom-mydemo.css
Normal file
File diff suppressed because one or more lines are too long
140348
apaas-custom-mydemo/apaas-custom-mydemo.umd.js
Normal file
140348
apaas-custom-mydemo/apaas-custom-mydemo.umd.js
Normal file
File diff suppressed because one or more lines are too long
19
apaas-custom-mydemo/apaas-custom-mydemo.umd.min.js
vendored
Normal file
19
apaas-custom-mydemo/apaas-custom-mydemo.umd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
146
apaas-custom-mydemo/apaas.json
Normal file
146
apaas-custom-mydemo/apaas.json
Normal 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"
|
||||||
|
}
|
||||||
10
apaas-custom-mydemo/demo.html
Normal file
10
apaas-custom-mydemo/demo.html
Normal 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>
|
||||||
BIN
apaas-custom-mydemo/static/custom/apaas-custom-mydemo/1.jpg
Normal file
BIN
apaas-custom-mydemo/static/custom/apaas-custom-mydemo/1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@ -121,6 +121,11 @@
|
|||||||
style="background: #E6A23C; padding: 4px 8px; color: white; border-radius: 20px;"
|
style="background: #E6A23C; padding: 4px 8px; color: white; border-radius: 20px;"
|
||||||
>审核中</span
|
>审核中</span
|
||||||
>
|
>
|
||||||
|
<span
|
||||||
|
v-else-if="row[colConfig.prop] === 'DRAFT'"
|
||||||
|
style="background: #909399; padding: 4px 8px; color: white; border-radius: 20px;"
|
||||||
|
>草稿</span
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
v-else-if="row[colConfig.prop] === 'COMPLETE'"
|
v-else-if="row[colConfig.prop] === 'COMPLETE'"
|
||||||
style="background: #67C23A; padding: 4px 8px; color: white; border-radius: 20px;"
|
style="background: #67C23A; padding: 4px 8px; color: white; border-radius: 20px;"
|
||||||
|
|||||||
@ -18,7 +18,12 @@
|
|||||||
>
|
>
|
||||||
<el-form ref="editForm" :model="formData" :rules="formRules" label-width="100px">
|
<el-form ref="editForm" :model="formData" :rules="formRules" label-width="100px">
|
||||||
<el-form-item label="名称:" prop="name">
|
<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-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
@ -45,6 +50,7 @@ export default {
|
|||||||
currentRow: null,
|
currentRow: null,
|
||||||
userData: getAuthModule(),
|
userData: getAuthModule(),
|
||||||
mode: 'add', // 'add' 或 'edit'
|
mode: 'add', // 'add' 或 'edit'
|
||||||
|
currentStatus: '', // 当前模板的状态
|
||||||
formData: {
|
formData: {
|
||||||
templateName: '',
|
templateName: '',
|
||||||
template_status: '',
|
template_status: '',
|
||||||
@ -63,12 +69,23 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
modalTitle() {
|
modalTitle() {
|
||||||
return this.mode === 'add' ? '添加模板' : '修改'
|
return this.mode === 'add' ? '添加模板' : '修改'
|
||||||
|
},
|
||||||
|
// 判断名称是否可编辑(审批中不能编辑名称)
|
||||||
|
isNameEditable() {
|
||||||
|
// 如果是新增模式,名称可编辑
|
||||||
|
if (this.mode === 'add') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// 如果是修改模式,审批中不能编辑名称
|
||||||
|
const status = this.currentStatus || ''
|
||||||
|
return status !== '审核中' && status !== 'APPROVING' && status !== 'REVIEWING'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showModal(row, mode = 'edit') {
|
showModal(row, mode = 'edit', status = '') {
|
||||||
this.mode = mode
|
this.mode = mode
|
||||||
this.currentRow = row
|
this.currentRow = row
|
||||||
|
this.currentStatus = status || (row && row.status) || ''
|
||||||
// 初始化表单数据
|
// 初始化表单数据
|
||||||
if (mode === 'add') {
|
if (mode === 'add') {
|
||||||
this.formData = {
|
this.formData = {
|
||||||
@ -92,6 +109,7 @@ export default {
|
|||||||
closeModal() {
|
closeModal() {
|
||||||
this.visible = false
|
this.visible = false
|
||||||
this.currentRow = null
|
this.currentRow = null
|
||||||
|
this.currentStatus = ''
|
||||||
this.formData = {
|
this.formData = {
|
||||||
templateName: '',
|
templateName: '',
|
||||||
template_status: ''
|
template_status: ''
|
||||||
|
|||||||
@ -34,13 +34,13 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-actions">
|
<div class="search-actions">
|
||||||
<el-button type="primary" @click="handleDownloadImportTemplate">
|
<el-button v-if="hasTemplateManagementEditPermission()" type="primary" @click="handleDownloadImportTemplate">
|
||||||
下载导入模板
|
下载导入模板
|
||||||
</el-button>
|
</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>
|
||||||
<el-button v-if="isAdmin()" type="primary" @click="handleAddTemplate()">
|
<el-button v-if="hasTemplateManagementEditPermission()" type="primary" @click="handleAddTemplate()">
|
||||||
添加参数模板
|
添加参数模板
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -104,7 +104,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<span class="link-separator"></span>
|
<span class="link-separator"></span>
|
||||||
<a
|
<a
|
||||||
v-if="row.status === 'DRAFT' && isAdmin()"
|
v-if="hasTemplateManagementEditPermission()"
|
||||||
href="javascript:void(0)"
|
href="javascript:void(0)"
|
||||||
class="el-link el-link--primary"
|
class="el-link el-link--primary"
|
||||||
@click.stop="handleRowEdit(row)"
|
@click.stop="handleRowEdit(row)"
|
||||||
@ -348,9 +348,42 @@ export default {
|
|||||||
return false
|
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() {
|
loadUserSelfRole() {
|
||||||
localStorage.setItem('user_self_role', [])
|
// localStorage.setItem('user_self_role', [])
|
||||||
const request = {
|
const request = {
|
||||||
...api.GET_USER_SELF_ROLE,
|
...api.GET_USER_SELF_ROLE,
|
||||||
params: {
|
params: {
|
||||||
@ -369,8 +402,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 遍历 user_self_role 数组,查找 menuPath 为 "数据录入/模板管理" 的内容
|
// 遍历 user_self_role 数组,查找 menuPath 为 "数据录入/模板管理" 的内容
|
||||||
this.filterTemplateManagementPermissions()
|
|
||||||
}
|
}
|
||||||
|
this.filterTemplateManagementPermissions()
|
||||||
})
|
})
|
||||||
.asyncErrorCatch((err) => {
|
.asyncErrorCatch((err) => {
|
||||||
console.error('获取用户自身角色失败:', err)
|
console.error('获取用户自身角色失败:', err)
|
||||||
@ -750,7 +783,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleRowEdit(row) {
|
handleRowEdit(row) {
|
||||||
this.$refs.editModal.showModal(row)
|
this.$refs.editModal.showModal(row, 'edit', row.status)
|
||||||
},
|
},
|
||||||
currentChange(currentPage) {
|
currentChange(currentPage) {
|
||||||
this.pagination.currentPage = currentPage
|
this.pagination.currentPage = currentPage
|
||||||
@ -927,7 +960,11 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
const request = {
|
const request = {
|
||||||
...api.EDIT_MODEL,
|
...api.EDIT_MODEL,
|
||||||
params: { ...formData, templateRowId: row.rowId }
|
params: {
|
||||||
|
...formData,
|
||||||
|
templateRowId: row.rowId,
|
||||||
|
orderNum: row.orderNum || '' // 同步修改 orderNum
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.$request(request)
|
this.$request(request)
|
||||||
.asyncThen((resp) => {
|
.asyncThen((resp) => {
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
<el-button v-if="shouldShowButtons" class="right-button" @click="handleImport">
|
<el-button v-if="shouldShowButtons" class="right-button" @click="handleImport">
|
||||||
导入
|
导入
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button class="right-button" @click="handleDownloadTemplate">
|
<el-button v-if="hasTemplateManagementPermission()" class="right-button" @click="handleDownloadTemplate">
|
||||||
下载导入模板
|
下载导入模板
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@ -651,12 +651,20 @@ export default {
|
|||||||
return this.versionList || []
|
return this.versionList || []
|
||||||
},
|
},
|
||||||
shouldShowButtonsNew() {
|
shouldShowButtonsNew() {
|
||||||
|
// 首先检查是否有参数模板管理的权限
|
||||||
|
if (!this.hasTemplateManagementPermission()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
// 根据 GET_MODEL_DETAIL 接口返回的 status 控制发起审批按钮
|
// 根据 GET_MODEL_DETAIL 接口返回的 status 控制发起审批按钮
|
||||||
const status = this.currentStatus || ''
|
const status = this.currentStatus || ''
|
||||||
return status === 'DRAFT' && this.isLatestVersion
|
return status === 'DRAFT' && this.isLatestVersion
|
||||||
},
|
},
|
||||||
// 检查是否应该显示按钮(维护参数、导入)
|
// 检查是否应该显示按钮(维护参数、导入)
|
||||||
shouldShowButtons() {
|
shouldShowButtons() {
|
||||||
|
// 首先检查是否有参数模板管理的权限
|
||||||
|
if (!this.hasTemplateManagementPermission()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
// 根据 GET_MODEL_DETAIL 接口返回的 status 控制维护参数和导入按钮
|
// 根据 GET_MODEL_DETAIL 接口返回的 status 控制维护参数和导入按钮
|
||||||
// 检查状态是否为 DRAFT 或 COMPLETE,且当前版本是最新版本
|
// 检查状态是否为 DRAFT 或 COMPLETE,且当前版本是最新版本
|
||||||
const status = this.currentStatus || ''
|
const status = this.currentStatus || ''
|
||||||
@ -1241,6 +1249,36 @@ export default {
|
|||||||
return false
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
// 检查参数是否有编辑权限(根据subsystem和partsName匹配)
|
// 检查参数是否有编辑权限(根据subsystem和partsName匹配)
|
||||||
hasParameterEditPermission(subsystem, partsName) {
|
hasParameterEditPermission(subsystem, partsName) {
|
||||||
// 如果是管理员,拥有全部权限
|
// 如果是管理员,拥有全部权限
|
||||||
|
|||||||
@ -229,7 +229,7 @@ export default {
|
|||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
minWidth: '120'
|
minWidth: '120'
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
prop: 'applicant',
|
prop: 'applicant',
|
||||||
label: '申请人',
|
label: '申请人',
|
||||||
|
|||||||
@ -6,11 +6,11 @@
|
|||||||
竞品发动机数据
|
竞品发动机数据
|
||||||
</div>
|
</div>
|
||||||
<div class="operation">
|
<div class="operation">
|
||||||
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
|
<el-button v-if="hasEngineDataEditPermission()" type="primary" @click="handleDownloadTemplate">下载模板</el-button>
|
||||||
<el-button class="import-button" @click="handleImport">
|
<el-button v-if="hasEngineDataEditPermission()" class="import-button" @click="handleImport">
|
||||||
导入机型
|
导入机型
|
||||||
</el-button>
|
</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>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -185,7 +185,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
|
|
||||||
<el-button @click="handleImportDialogClose">取消</el-button>
|
<el-button @click="handleImportDialogClose">取消</el-button>
|
||||||
<el-button type="primary" :loading="importing" @click="handleImportConfirm">
|
<el-button type="primary" :loading="importing" @click="handleImportConfirm">
|
||||||
开始导入
|
开始导入
|
||||||
@ -343,6 +342,56 @@ export default {
|
|||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
loadUserSelfRole() {
|
||||||
const request = {
|
const request = {
|
||||||
|
|||||||
@ -107,18 +107,18 @@
|
|||||||
<span v-if="data.type === 'subsystem'" class="type-tag subsystem-tag">子系统</span>
|
<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 v-if="data.type === 'parameter'" class="type-tag parameter-tag">参数类型</span> -->
|
||||||
</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
|
<el-checkbox
|
||||||
v-model="data.permissions.view"
|
v-model="data.permissions.view"
|
||||||
size="small"
|
size="small"
|
||||||
@change="data.type === 'subsystem' ? handleSubsystemPermissionChange(data, 'view') : handlePermissionChange(data, 'view')"
|
@change="handleNodePermissionChange(data, 'view')"
|
||||||
>
|
>
|
||||||
查看
|
查看
|
||||||
</el-checkbox>
|
</el-checkbox>
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
v-model="data.permissions.edit"
|
v-model="data.permissions.edit"
|
||||||
size="small"
|
size="small"
|
||||||
@change="data.type === 'subsystem' ? handleSubsystemPermissionChange(data, 'edit') : handlePermissionChange(data, 'edit')"
|
@change="handleNodePermissionChange(data, 'edit')"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-checkbox>
|
</el-checkbox>
|
||||||
@ -358,7 +358,9 @@ export default {
|
|||||||
// 待应用的权限数据(用于懒加载模式下延迟应用权限)
|
// 待应用的权限数据(用于懒加载模式下延迟应用权限)
|
||||||
pendingPermissions: [],
|
pendingPermissions: [],
|
||||||
// 固定的父级菜单列表
|
// 固定的父级菜单列表
|
||||||
menuList: ['模板管理', '玉柴发动机数据', '竞品发动机数据'],
|
menuList: ['参数模板管理', '玉柴发动机数据', '竞品发动机数据', '对标报告'],
|
||||||
|
// 模板列表数据(用于参数模板管理的二级节点)
|
||||||
|
templateList: [],
|
||||||
// 人员配置相关
|
// 人员配置相关
|
||||||
personConfigDialogVisible: false,
|
personConfigDialogVisible: false,
|
||||||
personConfigSubmitting: false,
|
personConfigSubmitting: false,
|
||||||
@ -459,6 +461,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.loadPermissionData()
|
this.loadPermissionData()
|
||||||
this.loadParamList()
|
this.loadParamList()
|
||||||
|
this.loadTemplateList()
|
||||||
this.loadDepartmentList()
|
this.loadDepartmentList()
|
||||||
this.getUserSelfRole()
|
this.getUserSelfRole()
|
||||||
},
|
},
|
||||||
@ -573,7 +576,12 @@ export default {
|
|||||||
label: menuName,
|
label: menuName,
|
||||||
type: 'menu',
|
type: 'menu',
|
||||||
children: null, // 初始为 null,懒加载时加载
|
children: null, // 初始为 null,懒加载时加载
|
||||||
isLeaf: false // 明确标记为非叶子节点,让 el-tree 显示展开按钮
|
// 对标报告没有子级,自己这一级就带有权限
|
||||||
|
isLeaf: menuName === '对标报告',
|
||||||
|
permissions: {
|
||||||
|
view: false,
|
||||||
|
edit: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存菜单节点映射
|
// 保存菜单节点映射
|
||||||
@ -599,8 +607,19 @@ export default {
|
|||||||
resolve(this.menuTreeData || [])
|
resolve(this.menuTreeData || [])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 如果节点是菜单类型,加载其子系统(第二级)
|
// 如果节点是菜单类型
|
||||||
if (node.data.type === 'menu') {
|
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)
|
this.loadMenuSubsystemsForLazy(node.data, resolve)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -609,9 +628,82 @@ export default {
|
|||||||
this.loadSubsystemParametersForLazy(node.data, resolve)
|
this.loadSubsystemParametersForLazy(node.data, resolve)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 其他节点(参数类型)都是叶子节点,不需要加载
|
// 其他节点(参数类型、模板类型)都是叶子节点,不需要加载
|
||||||
resolve([])
|
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) {
|
loadMenuSubsystemsForLazy(menuNode, resolve) {
|
||||||
// 从subsystemPartsMap中获取子系统列表
|
// 从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]) {
|
if (data.id && this.nodeMap[data.id]) {
|
||||||
// 使用 $set 确保响应式更新
|
// 使用 $set 确保响应式更新
|
||||||
@ -776,8 +880,22 @@ export default {
|
|||||||
data.permissions[permissionType]
|
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(() => {
|
this.$nextTick(() => {
|
||||||
if (this.$refs.form) {
|
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) {
|
handleSubsystemPermissionChange(data, permissionType) {
|
||||||
// 同步更新节点映射中的权限
|
// 同步更新节点映射中的权限
|
||||||
@ -796,20 +1173,40 @@ export default {
|
|||||||
data.permissions[permissionType]
|
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 children = data.children || []
|
||||||
const isChecked = data.permissions[permissionType]
|
const isChecked = data.permissions[permissionType]
|
||||||
// 全选/取消全选所有子节点
|
// 全选/取消全选所有子节点
|
||||||
children.forEach((childNode) => {
|
children.forEach((childNode) => {
|
||||||
if (childNode.id && this.nodeMap[childNode.id]) {
|
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)
|
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) {
|
if (childNode.permissions) {
|
||||||
this.$set(childNode, 'permissions', {
|
const newPermissions = {
|
||||||
...childNode.permissions,
|
...childNode.permissions,
|
||||||
[permissionType]: isChecked
|
[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('人员配置数据:', {
|
console.log('人员配置数据:', {
|
||||||
roleId: this.personConfigFormData.roleId,
|
roleId: this.personConfigFormData.roleId,
|
||||||
roleName: this.personConfigFormData.roleName,
|
roleName: this.personConfigFormData.roleName,
|
||||||
configType: this.personConfigFormData.configType,
|
configType: this.personConfigFormData.configType,
|
||||||
isDept: isDept,
|
isDept: isDept,
|
||||||
userOrDeptIds: userOrDeptId
|
userOrDeptIds: processedUserOrDeptId
|
||||||
})
|
})
|
||||||
|
|
||||||
const request = {
|
const request = {
|
||||||
...api.GET_ROLE_PERMISSION_BING,
|
...api.GET_ROLE_PERMISSION_BING,
|
||||||
params: {
|
params: {
|
||||||
roleId: this.personConfigFormData.roleId,
|
roleId: this.personConfigFormData.roleId,
|
||||||
userOrDeptIds: userOrDeptId,
|
userOrDeptIds: processedUserOrDeptId,
|
||||||
isDept: isDept
|
isDept: isDept
|
||||||
},
|
},
|
||||||
disableSuccessMsg: true
|
disableSuccessMsg: true
|
||||||
@ -1456,8 +1861,11 @@ export default {
|
|||||||
Object.keys(this.nodeMap).forEach((key) => {
|
Object.keys(this.nodeMap).forEach((key) => {
|
||||||
const node = this.nodeMap[key]
|
const node = this.nodeMap[key]
|
||||||
if (node && node.permissions) {
|
if (node && node.permissions) {
|
||||||
node.permissions.view = false
|
this.$set(node.permissions, 'view', false)
|
||||||
node.permissions.edit = 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) {
|
setPermissionsFromData(permissions) {
|
||||||
// permissions 格式是数组,每个元素包含:
|
// permissions 格式是数组,每个元素包含:
|
||||||
// { id, subsystem, partsName, parameterPer }
|
// { permissionPath, parameterPer, roleId, userId }
|
||||||
// parameterPer 是字符串:"查看" 或 "编辑"
|
// parameterPer 是数字:1是查看,2是编辑
|
||||||
const permArray = Array.isArray(permissions) ? permissions : []
|
const permArray = Array.isArray(permissions) ? permissions : []
|
||||||
|
|
||||||
// 先重置所有权限
|
// 先重置所有权限
|
||||||
@ -1482,68 +1890,71 @@ export default {
|
|||||||
// 保存权限数据,用于懒加载模式下延迟应用
|
// 保存权限数据,用于懒加载模式下延迟应用
|
||||||
this.pendingPermissions = permArray
|
this.pendingPermissions = permArray
|
||||||
|
|
||||||
// 处理权限数据:按 subsystem 和 partsName 分组,合并同一节点的查看和编辑权限
|
// 处理权限数据:按 permissionPath 分组,合并同一节点的查看和编辑权限
|
||||||
const permissionMap = new Map() // key: `${subsystem}-${partsName}`, value: { view: boolean, edit: boolean }
|
const permissionMap = new Map() // key: permissionPath, value: { view: boolean, edit: boolean }
|
||||||
permArray.forEach((perm) => {
|
permArray.forEach((perm) => {
|
||||||
const subsystem = perm.subsystem || ''
|
const permissionPath = perm.permissionPath || ''
|
||||||
const partsName = perm.partsName || ''
|
if (!permissionPath) {
|
||||||
const key = `${subsystem}-${partsName}`
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!permissionMap.has(key)) {
|
if (!permissionMap.has(permissionPath)) {
|
||||||
permissionMap.set(key, {
|
permissionMap.set(permissionPath, {
|
||||||
subsystem: subsystem,
|
permissionPath: permissionPath,
|
||||||
partsName: partsName,
|
|
||||||
view: false,
|
view: false,
|
||||||
edit: false
|
edit: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const permData = permissionMap.get(key)
|
const permData = permissionMap.get(permissionPath)
|
||||||
if (perm.parameterPer === '查看') {
|
// parameterPer 是数字:1是查看,2是编辑
|
||||||
|
if (perm.parameterPer === 1 || perm.parameterPer === '1' || perm.parameterPer === '查看') {
|
||||||
permData.view = true
|
permData.view = true
|
||||||
} else if (perm.parameterPer === '编辑') {
|
} else if (perm.parameterPer === 2 || perm.parameterPer === '2' || perm.parameterPer === '编辑') {
|
||||||
permData.edit = true
|
permData.edit = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 根据 subsystem 和 partsName 匹配节点并设置权限(只设置已加载的节点)
|
// 根据 permissionPath 匹配节点并设置权限(只设置已加载的节点)
|
||||||
permissionMap.forEach((permData, key) => {
|
permissionMap.forEach((permData, permissionPath) => {
|
||||||
|
// 如果只有编辑权限,自动添加查看权限
|
||||||
|
if (permData.edit && !permData.view) {
|
||||||
|
permData.view = true
|
||||||
|
}
|
||||||
Object.keys(this.nodeMap).forEach((nodeId) => {
|
Object.keys(this.nodeMap).forEach((nodeId) => {
|
||||||
const node = this.nodeMap[nodeId]
|
const node = this.nodeMap[nodeId]
|
||||||
if (node && node.type === 'parameter') {
|
if (!node) {
|
||||||
// 匹配子系统
|
return
|
||||||
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 (subsystemMatch && partsNameMatch) {
|
// 构建节点的权限路径,与权限数据中的 permissionPath 进行比较
|
||||||
// 使用 $set 确保响应式更新,直接替换整个权限对象
|
const nodePath = this.buildPermissionPath(node)
|
||||||
const newPermissions = {
|
if (nodePath === permissionPath) {
|
||||||
view: permData.view || false,
|
// 使用 $set 确保响应式更新,直接替换整个权限对象
|
||||||
edit: permData.edit || false
|
const newPermissions = {
|
||||||
}
|
view: permData.view || false,
|
||||||
this.$set(node, 'permissions', newPermissions)
|
edit: permData.edit || false
|
||||||
console.log(
|
|
||||||
'设置已加载节点权限:',
|
|
||||||
node.id,
|
|
||||||
node.label,
|
|
||||||
{
|
|
||||||
subsystem: node.subsystem,
|
|
||||||
partsName: node.partsName || node.parameterName || node.label
|
|
||||||
},
|
|
||||||
newPermissions
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
// 如果只有编辑权限,自动添加查看权限
|
||||||
|
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(() => {
|
this.$nextTick(() => {
|
||||||
|
// 更新子系统节点的权限状态(根据子节点)
|
||||||
Object.keys(this.nodeMap).forEach((nodeId) => {
|
Object.keys(this.nodeMap).forEach((nodeId) => {
|
||||||
const node = this.nodeMap[nodeId]
|
const node = this.nodeMap[nodeId]
|
||||||
if (node && node.type === 'subsystem' && node.children && node.children.length > 0) {
|
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(
|
console.log(
|
||||||
@ -1575,123 +1993,172 @@ export default {
|
|||||||
},
|
},
|
||||||
// 将待应用的权限应用到新加载的节点
|
// 将待应用的权限应用到新加载的节点
|
||||||
applyPendingPermissionsToNode(node) {
|
applyPendingPermissionsToNode(node) {
|
||||||
if (
|
if (!node || !this.pendingPermissions || this.pendingPermissions.length === 0) {
|
||||||
!node ||
|
|
||||||
node.type !== 'parameter' ||
|
|
||||||
!this.pendingPermissions ||
|
|
||||||
this.pendingPermissions.length === 0
|
|
||||||
) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找匹配的权限数据:根据 subsystem 和 partsName 匹配
|
// 构建节点的权限路径
|
||||||
const matchingPerms = this.pendingPermissions.filter((perm) => {
|
const nodePath = this.buildPermissionPath(node)
|
||||||
// 匹配子系统
|
if (!nodePath) {
|
||||||
const subsystemMatch = perm.subsystem && node.subsystem && perm.subsystem === node.subsystem
|
return
|
||||||
// 匹配零部件名称(partsName)
|
}
|
||||||
const partsNameMatch =
|
|
||||||
perm.partsName &&
|
|
||||||
(node.partsName || node.parameterName || node.label) &&
|
|
||||||
perm.partsName === (node.partsName || node.parameterName || node.label)
|
|
||||||
|
|
||||||
return subsystemMatch && partsNameMatch
|
// 根据 permissionPath 匹配权限
|
||||||
|
const matchingPerms = this.pendingPermissions.filter((perm) => {
|
||||||
|
const permissionPath = perm.permissionPath || ''
|
||||||
|
return permissionPath === nodePath
|
||||||
})
|
})
|
||||||
|
|
||||||
if (matchingPerms.length > 0) {
|
// 如果没有匹配的权限,直接返回
|
||||||
// 确保权限对象存在
|
if (matchingPerms.length === 0) {
|
||||||
if (!node.permissions) {
|
return
|
||||||
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 (!node.permissions) {
|
||||||
|
this.$set(node, 'permissions', { view: false, edit: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 应用权限:parameterPer 是数字:1是查看,2是编辑
|
||||||
|
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() {
|
collectPermissions() {
|
||||||
const permissions = []
|
const permissions = []
|
||||||
const roleId = this.formData.rowId || ''
|
const roleId = this.formData.rowId || '' // 编辑时有roleId,新增时为空
|
||||||
const userId = getUserId()
|
const userId = getUserId()
|
||||||
|
|
||||||
// 直接从 nodeMap 中收集所有参数节点,确保包含所有已加载的节点
|
// 遍历 nodeMap,收集所有类型的权限节点
|
||||||
Object.keys(this.nodeMap).forEach((nodeId) => {
|
Object.keys(this.nodeMap).forEach((nodeId) => {
|
||||||
const node = this.nodeMap[nodeId]
|
const node = this.nodeMap[nodeId]
|
||||||
if (node && node.type === 'parameter') {
|
if (!node) {
|
||||||
// 确保权限对象存在
|
return
|
||||||
const nodePermissions = node.permissions || { view: false, edit: false }
|
}
|
||||||
// 获取子系统名称和partsName
|
|
||||||
const subsystem = node.subsystem || ''
|
|
||||||
const partsName = node.partsName || node.parameterName || node.label || ''
|
|
||||||
|
|
||||||
// 如果选中了查看权限,添加一条记录(parameterPer = 1)
|
// 确保权限对象存在
|
||||||
if (nodePermissions.view) {
|
const nodePermissions = node.permissions || { view: false, edit: false }
|
||||||
permissions.push({
|
|
||||||
roleId: roleId,
|
// 只收集有权限的节点(view 或 edit 为 true)
|
||||||
subsystem: subsystem,
|
if (!nodePermissions.view && !nodePermissions.edit) {
|
||||||
partsName: partsName,
|
return
|
||||||
parameterPer: 1, // 1是查看
|
}
|
||||||
userId: userId
|
|
||||||
})
|
// 构建权限路径
|
||||||
|
const permissionPath = this.buildPermissionPath(node)
|
||||||
|
if (!permissionPath) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收集查看权限
|
||||||
|
if (nodePermissions.view) {
|
||||||
|
const perm = {
|
||||||
|
permissionPath: permissionPath,
|
||||||
|
parameterPer: 1, // 1是查看
|
||||||
|
userId: userId
|
||||||
}
|
}
|
||||||
// 如果选中了编辑权限,添加一条记录(parameterPer = 2)
|
// 编辑时添加 roleId
|
||||||
if (nodePermissions.edit) {
|
if (roleId) {
|
||||||
permissions.push({
|
perm.roleId = roleId
|
||||||
roleId: roleId,
|
|
||||||
subsystem: subsystem,
|
|
||||||
partsName: partsName,
|
|
||||||
parameterPer: 2, // 2是编辑
|
|
||||||
userId: userId
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
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(
|
|
||||||
'收集到的权限:',
|
console.log('收集到的权限:', permissions)
|
||||||
permissions,
|
|
||||||
'nodeMap中的参数节点数量:',
|
|
||||||
Object.keys(this.nodeMap).filter(
|
|
||||||
(id) => this.nodeMap[id] && this.nodeMap[id].type === 'parameter'
|
|
||||||
).length
|
|
||||||
)
|
|
||||||
return permissions
|
return permissions
|
||||||
},
|
},
|
||||||
// 关闭对话框
|
// 关闭对话框
|
||||||
|
|||||||
@ -6,11 +6,11 @@
|
|||||||
玉柴发动机数据
|
玉柴发动机数据
|
||||||
</div>
|
</div>
|
||||||
<div class="operation">
|
<div class="operation">
|
||||||
<el-button type="primary" @click="handleDownloadTemplate">下载模板</el-button>
|
<el-button v-if="hasEngineDataEditPermission()" type="primary" @click="handleDownloadTemplate">下载模板</el-button>
|
||||||
<el-button class="import-button" @click="handleImport">
|
<el-button v-if="hasEngineDataEditPermission()" class="import-button" @click="handleImport">
|
||||||
导入机型
|
导入机型
|
||||||
</el-button>
|
</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>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@ -109,7 +109,7 @@
|
|||||||
查看
|
查看
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
v-if="row.distributeStatus != '已分发'"
|
v-if="row.distributeStatus != '已分发' && hasEngineDataEditPermission()"
|
||||||
href="javascript:void(0)"
|
href="javascript:void(0)"
|
||||||
class="el-link el-link--primary"
|
class="el-link el-link--primary"
|
||||||
style="margin-left: 5px;"
|
style="margin-left: 5px;"
|
||||||
@ -343,6 +343,56 @@ export default {
|
|||||||
this.loadData()
|
this.loadData()
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
loadUserSelfRole() {
|
||||||
const request = {
|
const request = {
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="apaas-custom-page-todo custom-page">
|
<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="page-header">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
我的待办
|
我的待办
|
||||||
@ -35,13 +39,27 @@
|
|||||||
@current-page-change="currentChange"
|
@current-page-change="currentChange"
|
||||||
@select-data-change="selectDataChange"
|
@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">
|
<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>
|
<a
|
||||||
</div>
|
href="javascript:void(0)"
|
||||||
<span style="width: 6px; display: inline-block"></span>
|
class="el-link el-link--primary"
|
||||||
<div v-if="colConfig.customSlot === 'options'" :key="'op' + index + '' + rowIndex">
|
@click.stop="handleRowView(row)"
|
||||||
<a href="javascript:void(0)" class="el-link el-link--primary" @click.stop="handleRowBack(row)">退回</a>
|
>查看</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -145,10 +163,29 @@ export default {
|
|||||||
{ prop: 'currentNode', label: '当前环节', showOverflowTooltip: true, minWidth: '140' },
|
{ prop: 'currentNode', label: '当前环节', showOverflowTooltip: true, minWidth: '140' },
|
||||||
// { prop: 'statusCode', label: '状态代号', showOverflowTooltip: true, minWidth: '120' },
|
// { prop: 'statusCode', label: '状态代号', showOverflowTooltip: true, minWidth: '120' },
|
||||||
// { prop: 'modelName', 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: '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: '',
|
seqType: '',
|
||||||
seqConfig: {},
|
seqConfig: {},
|
||||||
@ -168,6 +205,38 @@ export default {
|
|||||||
rowClickEvent(row) {
|
rowClickEvent(row) {
|
||||||
console.warn(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) {
|
handleRowView(row) {
|
||||||
// 根据流程主题判断打开哪种页面
|
// 根据流程主题判断打开哪种页面
|
||||||
const dataType = row.dataType || ''
|
const dataType = row.dataType || ''
|
||||||
@ -345,82 +414,82 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.custom-page {
|
.custom-page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow-y: auto !important;
|
overflow-y: auto !important;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.page-header {
|
||||||
display: flex;
|
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 {
|
.title {
|
||||||
display: flex;
|
color: #303133;
|
||||||
align-items: center;
|
font-weight: 700;
|
||||||
height: 56px;
|
margin-left: 20px;
|
||||||
position: relative;
|
flex: 1;
|
||||||
width: 100%;
|
font-size: 12px;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-data-list {
|
.operation {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
min-width: 330px;
|
||||||
min-height: 0;
|
justify-content: flex-end !important;
|
||||||
padding: 20px;
|
margin-right: 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user