fix:优化我的常用
This commit is contained in:
parent
4e1b7168a5
commit
2ab9517ed0
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
@ -160,12 +160,12 @@
|
||||
<el-dialog
|
||||
:title="approvalDialogTitle"
|
||||
:visible.sync="approvalDialogVisible"
|
||||
width="500px"
|
||||
width="600px"
|
||||
:close-on-click-modal="false"
|
||||
append-to-body
|
||||
@close="handleApprovalDialogClose"
|
||||
>
|
||||
<el-form ref="approvalForm" :model="approvalFormData" :rules="approvalFormRules" label-width="80px">
|
||||
<el-form ref="approvalForm" :model="approvalFormData" :rules="approvalFormRules" label-width="100px">
|
||||
<el-form-item
|
||||
:label="approvalActionType === 'reject' ? '退回意见:' : '提交意见:'"
|
||||
prop="opinion"
|
||||
@ -173,7 +173,7 @@
|
||||
<el-input
|
||||
v-model="approvalFormData.opinion"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:rows="2"
|
||||
:placeholder="approvalActionType === 'reject' ? '请输入退回意见' : '请输入提交意见'"
|
||||
/>
|
||||
</el-form-item>
|
||||
@ -715,7 +715,8 @@ export default {
|
||||
this.approvalSubmitting = true
|
||||
const request = {
|
||||
...api.HANDLE_APPROVAL,
|
||||
params: submitData
|
||||
params: submitData,
|
||||
disableSuccessMsg: true
|
||||
}
|
||||
|
||||
this.$request(request)
|
||||
@ -725,12 +726,19 @@ export default {
|
||||
this.getApprovalSpet()
|
||||
this.getApprovalChange()
|
||||
// 通知父组件刷新数据
|
||||
this.$message({
|
||||
message: '审批提交成功',
|
||||
type: 'success'
|
||||
})
|
||||
this.$emit('refresh')
|
||||
this.approvalSubmitting = false
|
||||
})
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('审批提交失败:', err)
|
||||
this.$message.error('审批提交失败,请重试')
|
||||
this.$message({
|
||||
message: '审批提交失败,请重试',
|
||||
type: 'error'
|
||||
})
|
||||
this.approvalSubmitting = false
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@ -969,8 +969,8 @@ export default {
|
||||
max: chart.yAxisMax !== null && chart.yAxisMax !== '' ? chart.yAxisMax : 100,
|
||||
interval: 20,
|
||||
axisLabel: {
|
||||
formatter: '{value}%',
|
||||
color: '#606266'
|
||||
formatter: '{value}',
|
||||
color: '#000'
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
|
||||
@ -398,54 +398,14 @@ export default {
|
||||
return a.parameterName.localeCompare(b.parameterName)
|
||||
})
|
||||
|
||||
// 过滤:1. 手动隐藏的参数 2. 不在常用配置中的参数(如果已选择常用且树节点选中)
|
||||
// 过滤:只过滤隐藏的参数(hiddenParams 中已经包含了根据常用配置应该隐藏的参数)
|
||||
// 不再在这里对常用配置进行过滤,因为 hideMissingParamsByNode 已经处理了
|
||||
return allParams.filter(param => {
|
||||
// 过滤手动隐藏的参数(使用新的key格式:subsystemName-parameterName)
|
||||
// 过滤隐藏的参数(使用新的key格式:subsystemName-parameterName)
|
||||
const key = `${param.subsystemName}-${param.parameterName}`
|
||||
if (this.hiddenParams.includes(key)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// 如果已选择常用配置,需要检查参数是否在常用中
|
||||
// 注意:这里 param 已经在 allParams 中,说明它已经通过了树节点选中状态的过滤
|
||||
// 所以如果参数不在常用中,即使树节点选中也不显示
|
||||
if (this.currentCommonConfig && this.currentCommonConfig.subsystems) {
|
||||
// 查找该参数是否在常用配置中(支持精确匹配和包含匹配)
|
||||
const subsystemConfig = this.currentCommonConfig.subsystems.find(s => {
|
||||
return s.subsystem === param.subsystemName ||
|
||||
s.subsystem.includes(param.subsystemName) ||
|
||||
param.subsystemName.includes(s.subsystem)
|
||||
})
|
||||
if (!subsystemConfig) {
|
||||
// 如果该子系统不在常用配置中,不显示该参数(即使树节点选中)
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查 parameterId 或 parameterName 是否在常用配置的 parameters 中
|
||||
// 优先使用 parameterId 匹配,其次使用 parameterName 匹配
|
||||
if (param.parameterId) {
|
||||
const isInCommon = subsystemConfig.parameters.some(
|
||||
p => p.parameterId === param.parameterId
|
||||
)
|
||||
if (!isInCommon) {
|
||||
// 参数不在常用中,即使树节点选中也不显示
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
// 如果找不到 parameterId,使用 parameterName 匹配(支持精确匹配和包含匹配)
|
||||
const isInCommon = subsystemConfig.parameters.some(p => {
|
||||
return p.parameterName === param.parameterName ||
|
||||
(p.parameterName && param.parameterName &&
|
||||
(p.parameterName.includes(param.parameterName) ||
|
||||
param.parameterName.includes(p.parameterName)))
|
||||
})
|
||||
if (!isInCommon) {
|
||||
// 参数不在常用中,即使树节点选中也不显示
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
},
|
||||
@ -580,6 +540,11 @@ export default {
|
||||
// 如果树节点未选中,参数不显示(可以通过选中树节点恢复)
|
||||
// 如果树节点选中但参数不在常用中,参数不显示(即使选中树节点也不显示)
|
||||
this.checkedKeys = checkedInfo.checkedKeys
|
||||
|
||||
// 如果已选择常用配置,后续的树节点选择变化时,不再根据常用配置过滤
|
||||
// 而是正常显示参数(只根据树节点和全部参数)
|
||||
// 不再调用 hideMissingParamsByNode,让参数正常显示
|
||||
|
||||
// 如果有已添加的机型,根据新选中的树节点重新加载参数数据
|
||||
this.reloadModelDetailsForCheckedNodes()
|
||||
},
|
||||
@ -1047,14 +1012,7 @@ export default {
|
||||
// 保存常用配置
|
||||
this.currentCommonConfig = selectedFavorite.data
|
||||
|
||||
// 按照节点比较参数,自动隐藏缺少的参数
|
||||
this.hideMissingParamsByNode()
|
||||
|
||||
// 根据可显示的参数更新树节点选中状态
|
||||
// 注意:不再调用 hideParamsNotInCommon,而是让 displayParams 自动过滤
|
||||
// 如果树节点未选中,参数不显示(可以通过选中树节点恢复)
|
||||
// 如果树节点选中但参数不在常用中,参数不显示(即使选中树节点也不显示)
|
||||
// 确保树数据和节点映射已经准备好
|
||||
// 1. 先根据常用配置选中树节点
|
||||
if (this.allTreeData && this.allTreeData.length > 0 && Object.keys(this.allNodeMap).length > 0) {
|
||||
this.updateCheckedKeysByDisplayParams()
|
||||
} else {
|
||||
@ -1062,6 +1020,13 @@ export default {
|
||||
// 这个逻辑在 loadTreeData 的 loadAllParametersData 完成后已经处理了
|
||||
console.log('树数据还未加载完成,等待加载完成后再更新选中状态')
|
||||
}
|
||||
|
||||
// 2. 根据树节点和全部参数显示参数(displayParams 已经自动处理)
|
||||
// 3. 比较当前显示的参数和常用配置中的参数,找出不在常用中的参数,隐藏它们
|
||||
// 使用 $nextTick 确保树节点选中状态已经更新,displayParams 已经计算
|
||||
this.$nextTick(() => {
|
||||
this.hideParamsNotInCommonByDisplayParams()
|
||||
})
|
||||
},
|
||||
// 下载
|
||||
handleDownloadComparisonData() {
|
||||
@ -1272,9 +1237,9 @@ export default {
|
||||
this.$refs.paramTree.setCheckedKeys([])
|
||||
}
|
||||
}
|
||||
})
|
||||
// 如果有已添加的机型,根据新选中的树节点重新加载参数数据
|
||||
this.reloadModelDetailsForCheckedNodes()
|
||||
})
|
||||
},
|
||||
// 重建节点映射
|
||||
rebuildNodeMap(nodes, parentLabel = null) {
|
||||
@ -1292,13 +1257,21 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
// 按照节点比较参数,自动隐藏缺少的参数
|
||||
hideMissingParamsByNode() {
|
||||
// 根据当前显示的参数和常用配置比较,找出不在常用中的参数并隐藏
|
||||
// 逻辑:比较当前显示的参数(根据树节点和全部参数)和常用配置中的参数
|
||||
// 当前显示的参数中不在常用配置中的,就是应该隐藏的参数
|
||||
hideParamsNotInCommonByDisplayParams() {
|
||||
if (!this.currentCommonConfig || !this.currentCommonConfig.subsystems) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.allParametersData || Object.keys(this.allParametersData).length === 0) {
|
||||
// 获取当前显示的参数(根据树节点和全部参数,不受常用配置影响)
|
||||
// 这里需要获取当前的 displayParams,但 displayParams 是一个 computed 属性
|
||||
// 它会根据 hiddenParams 过滤,所以我们需要手动计算所有应该显示的参数
|
||||
const { subsystemNames, parameterTypes, subsystemTypes } = this.getSelectedSubsystemsAndTypes()
|
||||
|
||||
// 如果没有选中任何节点,不隐藏参数
|
||||
if (subsystemNames.length === 0 && parameterTypes.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1318,56 +1291,95 @@ export default {
|
||||
commonParamsMap.set(subsystemName, paramKeys)
|
||||
})
|
||||
|
||||
// 遍历所有参数数据,按节点比较并找出缺少的参数
|
||||
const paramsToHide = []
|
||||
Object.keys(this.allParametersData).forEach(subsystemName => {
|
||||
// 获取当前根据树节点应该显示的所有参数(不受常用配置影响)
|
||||
const currentDisplayParams = []
|
||||
subsystemNames.forEach(subsystemName => {
|
||||
const paramList = this.allParametersData[subsystemName]
|
||||
if (!Array.isArray(paramList) || paramList.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取该节点在常用配置中的参数集合
|
||||
const commonParamKeys = commonParamsMap.get(subsystemName) || new Set()
|
||||
|
||||
// 如果该节点不在常用配置中,隐藏该节点下的所有参数
|
||||
if (!commonParamsMap.has(subsystemName)) {
|
||||
paramList.forEach(item => {
|
||||
const parameterName = item.parameterName || ''
|
||||
const key = `${subsystemName}-${parameterName}`
|
||||
if (!paramsToHide.includes(key)) {
|
||||
paramsToHide.push(key)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 如果该节点在常用配置中,比较参数数量
|
||||
// 找出全部参数中有但常用配置中没有的参数
|
||||
paramList.forEach(item => {
|
||||
const parameterName = item.parameterName || ''
|
||||
const parameterId = item.parameterId || ''
|
||||
const partsName = item.partsName || ''
|
||||
const subsystem = item.subsystem || subsystemName
|
||||
|
||||
// 确定用于匹配和显示的零部件名称(partsName)
|
||||
const displayPartsName = partsName === '/' ? subsystem : partsName
|
||||
|
||||
// 检查该参数是否在当前选中的树节点下
|
||||
let isInSelectedNodes = false
|
||||
if (parameterTypes.length === 0) {
|
||||
// 如果只选中了父节点(子系统),该子系统下的所有参数都在选中节点下
|
||||
isInSelectedNodes = true
|
||||
} else {
|
||||
// 如果选中了子节点(零部件),检查是否匹配
|
||||
isInSelectedNodes = parameterTypes.includes(displayPartsName) ||
|
||||
subsystemTypes.includes(`${subsystemName}-${displayPartsName}`)
|
||||
|
||||
// 如果该参数不匹配任何已选中的子节点,检查该子系统是否被直接选中(作为父节点)
|
||||
if (!isInSelectedNodes) {
|
||||
const isSubsystemDirectlySelected = this.checkedKeys.some(nodeId => {
|
||||
const nodeInfo = this.nodeMap[nodeId]
|
||||
return nodeInfo &&
|
||||
nodeInfo.isParent &&
|
||||
nodeInfo.label === subsystemName &&
|
||||
!this.checkedKeys.some(childNodeId => {
|
||||
const childNodeInfo = this.nodeMap[childNodeId]
|
||||
return childNodeInfo &&
|
||||
!childNodeInfo.isParent &&
|
||||
childNodeInfo.parentLabel === subsystemName
|
||||
})
|
||||
})
|
||||
|
||||
if (isSubsystemDirectlySelected && (partsName === '/' || displayPartsName === subsystemName)) {
|
||||
isInSelectedNodes = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果该参数在当前选中的树节点下,添加到当前显示参数列表
|
||||
if (isInSelectedNodes) {
|
||||
currentDisplayParams.push({
|
||||
subsystemName,
|
||||
parameterName,
|
||||
parameterId,
|
||||
partsName
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 比较当前显示的参数和常用配置中的参数,找出不在常用中的参数
|
||||
const paramsToHide = []
|
||||
currentDisplayParams.forEach(param => {
|
||||
const subsystemName = param.subsystemName
|
||||
const parameterName = param.parameterName
|
||||
const parameterId = param.parameterId
|
||||
|
||||
// 判断该子系统是否在常用配置中
|
||||
const isSubsystemInCommon = commonParamsMap.has(subsystemName)
|
||||
const commonParamKeys = commonParamsMap.get(subsystemName) || new Set()
|
||||
|
||||
// 使用 parameterId 或 parameterName 作为匹配键
|
||||
const matchKey = parameterId || parameterName
|
||||
|
||||
// 检查该参数是否在常用配置中
|
||||
const isInCommon = commonParamKeys.has(matchKey)
|
||||
const isInCommon = isSubsystemInCommon && commonParamKeys.has(matchKey)
|
||||
|
||||
if (!isInCommon) {
|
||||
// 该参数不在常用配置中,需要隐藏
|
||||
// 该参数在当前显示中,但不在常用配置中,需要隐藏
|
||||
const key = `${subsystemName}-${parameterName}`
|
||||
if (!paramsToHide.includes(key)) {
|
||||
paramsToHide.push(key)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 将缺少的参数添加到隐藏列表(不重复添加)
|
||||
paramsToHide.forEach(key => {
|
||||
if (!this.hiddenParams.includes(key)) {
|
||||
this.hiddenParams.push(key)
|
||||
}
|
||||
})
|
||||
// 清空所有 hiddenParams,然后重新添加应该隐藏的参数
|
||||
// 注意:这会丢失手动隐藏的参数,但根据用户需求,选择常用后应该重新计算
|
||||
this.hiddenParams = paramsToHide
|
||||
},
|
||||
// 根据常用配置隐藏不在范围内的参数(旧方法,保留以备用)
|
||||
hideParamsNotInCommon() {
|
||||
@ -1792,11 +1804,13 @@ export default {
|
||||
this.loadAllParametersData().then(() => {
|
||||
// 如果已选择常用配置,根据可显示的参数更新选中状态
|
||||
if (this.currentCommonConfig) {
|
||||
// 先隐藏不在常用范围内的参数
|
||||
// 不再调用 hideParamsNotInCommon,让 displayParams 自动过滤
|
||||
// 然后根据可显示的参数更新树节点选中状态
|
||||
// 1. 先根据常用配置选中树节点
|
||||
this.$nextTick(() => {
|
||||
this.updateCheckedKeysByDisplayParams()
|
||||
// 2. 然后比较当前显示的参数和常用配置中的参数,找出不在常用中的参数,隐藏它们
|
||||
this.$nextTick(() => {
|
||||
this.hideParamsNotInCommonByDisplayParams()
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// 否则全选
|
||||
@ -1845,10 +1859,14 @@ export default {
|
||||
})
|
||||
}
|
||||
this.allParametersData = result
|
||||
// 首次进入页面时,保存完整的参数数据
|
||||
this.savedAllParametersData = JSON.parse(JSON.stringify(result))
|
||||
// 参数数据加载完成后,调用获取常用列表
|
||||
this.loadFavoritesList()
|
||||
} else {
|
||||
this.allParametersData = {}
|
||||
// 首次进入页面时,保存完整的参数数据(即使是空对象)
|
||||
this.savedAllParametersData = {}
|
||||
// 即使没有数据,也调用获取常用列表
|
||||
this.loadFavoritesList()
|
||||
}
|
||||
@ -1856,6 +1874,8 @@ export default {
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('获取所有参数数据失败:', err)
|
||||
this.allParametersData = {}
|
||||
// 首次进入页面时,保存完整的参数数据(即使是空对象)
|
||||
this.savedAllParametersData = {}
|
||||
// 即使失败,也调用获取常用列表
|
||||
this.loadFavoritesList()
|
||||
})
|
||||
|
||||
@ -816,25 +816,37 @@ export default {
|
||||
)
|
||||
if (requiredStepsWithoutHandlers.length > 0) {
|
||||
const stepNames = requiredStepsWithoutHandlers.map((step) => step.name).join('、')
|
||||
this.$message.warning(`请为必填环节"${stepNames}"选择处理人`)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: `请为必填环节"${stepNames}"选择处理人`
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.currentLaunchRow) {
|
||||
this.$message.error('缺少报告信息')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '缺少报告信息'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 流程主题必填
|
||||
const processTitle = (this.launchProcessTitle || '').trim()
|
||||
if (!processTitle) {
|
||||
this.$message.warning('请填写流程主题')
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '请填写流程主题'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const reportId = this.currentLaunchRow.reportId || this.currentLaunchRow.id
|
||||
if (!reportId) {
|
||||
this.$message.error('缺少报告ID')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '缺少报告ID'
|
||||
})
|
||||
return
|
||||
}
|
||||
const nodeList = this.launchWorkflowSteps.map((step, index) => ({
|
||||
@ -870,7 +882,10 @@ export default {
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('发起失败:', err)
|
||||
this.launching = false
|
||||
this.$message.error('发起失败,请重试')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '发起失败,请重试'
|
||||
})
|
||||
})
|
||||
},
|
||||
handleLaunchRemoteSearch(query, stepIndex) {
|
||||
@ -1310,12 +1325,18 @@ export default {
|
||||
handleApprovalSubmit() {
|
||||
// 验证是否选择了审核结果
|
||||
if (!this.approvalFormData.result) {
|
||||
this.$message.warning('请选择审核结果(通过或退回)')
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '请选择审核结果(通过或退回)'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.currentApprovalRow) {
|
||||
this.$message.error('缺少审批信息')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '缺少审批信息'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@ -1344,7 +1365,10 @@ export default {
|
||||
.asyncErrorCatch((err) => {
|
||||
console.error('审批提交失败:', err)
|
||||
this.approvalSubmitting = false
|
||||
this.$message.error('审批提交失败,请重试')
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '审批提交失败,请重试'
|
||||
})
|
||||
})
|
||||
},
|
||||
pageSizeChange(size) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user