fix:bug
This commit is contained in:
parent
f280a779b3
commit
94897e9265
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
@ -189,11 +189,6 @@
|
|||||||
添加/修改公式
|
添加/修改公式
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="chart.chartType === 'scatter'" class="config-item">
|
|
||||||
<el-checkbox v-model="chart.scatterTrendline" @change="updateChart(index)">
|
|
||||||
显示趋势线
|
|
||||||
</el-checkbox>
|
|
||||||
</div>
|
|
||||||
<div v-if="chart.chartType !== 'pie'" class="config-item">
|
<div v-if="chart.chartType !== 'pie'" class="config-item">
|
||||||
<span class="config-label">Y轴范围:</span>
|
<span class="config-label">Y轴范围:</span>
|
||||||
<el-input
|
<el-input
|
||||||
@ -254,25 +249,20 @@
|
|||||||
class="formula-dialog"
|
class="formula-dialog"
|
||||||
>
|
>
|
||||||
<div class="formula-dialog-content">
|
<div class="formula-dialog-content">
|
||||||
<div class="formula-input-section">
|
<el-form :model="formulaFormData" label-width="100px">
|
||||||
<el-form-item label="公式名称:" required>
|
<el-form-item label="公式名称:" required>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="formulaName"
|
v-model="formulaFormData.name"
|
||||||
placeholder="请输入公式名称"
|
placeholder="请输入公式名称"
|
||||||
maxlength="50"
|
maxlength="50"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div class="formula-input-section">
|
<el-form-item label="参数1:" required>
|
||||||
<span class="formula-label">*计算公式:</span>
|
|
||||||
<div class="formula-editor">
|
|
||||||
<div v-for="(item, index) in formulaItems" :key="index" class="formula-item">
|
|
||||||
<el-select
|
<el-select
|
||||||
v-if="item.type === 'param'"
|
v-model="formulaFormData.param1"
|
||||||
v-model="item.value"
|
placeholder="请选择参数"
|
||||||
class="formula-select"
|
style="width: 100%"
|
||||||
placeholder="选择参数"
|
|
||||||
@change="updateFormula"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="opt in yAxisParamOptions"
|
v-for="opt in yAxisParamOptions"
|
||||||
@ -281,12 +271,12 @@
|
|||||||
:value="opt.value"
|
:value="opt.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="运算符:" required>
|
||||||
<el-select
|
<el-select
|
||||||
v-else-if="item.type === 'operator'"
|
v-model="formulaFormData.operator"
|
||||||
v-model="item.value"
|
placeholder="请选择运算符"
|
||||||
class="formula-select"
|
style="width: 100%"
|
||||||
placeholder="选择运算符"
|
|
||||||
@change="updateFormula"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="opt in operatorOptions"
|
v-for="opt in operatorOptions"
|
||||||
@ -295,28 +285,33 @@
|
|||||||
:value="opt.value"
|
:value="opt.value"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<i class="el-icon-delete formula-delete-icon" @click="removeFormulaItem(index)"></i>
|
</el-form-item>
|
||||||
</div>
|
<el-form-item label="参数2:" required>
|
||||||
<div v-if="formulaItems.length === 0" class="formula-empty-hint">
|
<el-select
|
||||||
请添加参数和运算符
|
v-model="formulaFormData.param2"
|
||||||
</div>
|
placeholder="请选择参数"
|
||||||
</div>
|
style="width: 100%"
|
||||||
</div>
|
>
|
||||||
</div>
|
<el-option
|
||||||
<div class="formula-buttons">
|
v-for="opt in yAxisParamOptions"
|
||||||
<el-button type="primary" :disabled="yAxisParamOptions.length === 0" @click="addFormulaParam">
|
:key="opt.value"
|
||||||
添加参数
|
:label="opt.label"
|
||||||
</el-button>
|
:value="opt.value"
|
||||||
<el-button type="primary" @click="addFormulaOperator">
|
/>
|
||||||
添加符号
|
</el-select>
|
||||||
</el-button>
|
</el-form-item>
|
||||||
|
<el-form-item label="公式预览:">
|
||||||
|
<div class="formula-preview">
|
||||||
|
{{ getFormulaPreview() }}
|
||||||
</div>
|
</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<span slot="footer" class="dialog-footer">
|
<span slot="footer" class="dialog-footer">
|
||||||
<el-button @click="handleFormulaDialogClose">
|
<el-button @click="handleFormulaDialogClose">
|
||||||
取消
|
取消
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" :disabled="!formulaName || formulaItems.length === 0" @click="handleSaveFormula">
|
<el-button type="primary" :disabled="!isFormulaValid" @click="handleSaveFormula">
|
||||||
确定
|
确定
|
||||||
</el-button>
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
@ -379,14 +374,18 @@ export default {
|
|||||||
formulaDialogVisible: false,
|
formulaDialogVisible: false,
|
||||||
currentFormulaChartIndex: -1,
|
currentFormulaChartIndex: -1,
|
||||||
currentFormulaId: null, // 当前编辑的公式ID(如果为null则是新增)
|
currentFormulaId: null, // 当前编辑的公式ID(如果为null则是新增)
|
||||||
formulaName: '', // 公式名称
|
formulaFormData: {
|
||||||
|
name: '',
|
||||||
|
param1: '',
|
||||||
|
operator: '+',
|
||||||
|
param2: ''
|
||||||
|
},
|
||||||
isResizing: false,
|
isResizing: false,
|
||||||
resizingChartIndex: -1,
|
resizingChartIndex: -1,
|
||||||
resizeStartY: 0,
|
resizeStartY: 0,
|
||||||
resizeStartHeight: 0,
|
resizeStartHeight: 0,
|
||||||
formulaItems: [],
|
|
||||||
// 已保存的公式列表
|
// 已保存的公式列表
|
||||||
savedFormulas: [], // 格式: [{ id: 'formula1', name: '公式1', formulaItems: [...] }]
|
savedFormulas: [], // 格式: [{ id: 'formula1', name: '公式1', param1: '参数1', operator: '+', param2: '参数2' }]
|
||||||
formulaIdCounter: 0, // 公式ID计数器
|
formulaIdCounter: 0, // 公式ID计数器
|
||||||
operatorOptions: [
|
operatorOptions: [
|
||||||
{ label: '+', value: '+' },
|
{ label: '+', value: '+' },
|
||||||
@ -396,6 +395,19 @@ export default {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
// 验证公式是否有效
|
||||||
|
isFormulaValid() {
|
||||||
|
return !!(
|
||||||
|
this.formulaFormData.name &&
|
||||||
|
this.formulaFormData.name.trim() &&
|
||||||
|
this.formulaFormData.param1 &&
|
||||||
|
this.formulaFormData.param2 &&
|
||||||
|
this.formulaFormData.operator &&
|
||||||
|
this.formulaFormData.param1 !== this.formulaFormData.param2
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
activeTab: {
|
activeTab: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
@ -451,13 +463,7 @@ export default {
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
// 目前使用假数据
|
// 目前使用假数据
|
||||||
this.yAxisParamOptions = [
|
this.yAxisParamOptions = []
|
||||||
{ label: '参数1', value: 'param1' },
|
|
||||||
{ label: '参数2', value: 'param2' },
|
|
||||||
{ label: '参数3', value: 'param3' },
|
|
||||||
{ label: '参数4', value: 'param4' },
|
|
||||||
{ label: '参数5', value: 'param5' }
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
handleTabClick(tab) {
|
handleTabClick(tab) {
|
||||||
// Tab切换时的处理逻辑
|
// Tab切换时的处理逻辑
|
||||||
@ -694,8 +700,8 @@ export default {
|
|||||||
let formulaData = null
|
let formulaData = null
|
||||||
if (chart.yAxisFormula) {
|
if (chart.yAxisFormula) {
|
||||||
const selectedFormula = this.savedFormulas.find(f => f.id === chart.yAxisFormula)
|
const selectedFormula = this.savedFormulas.find(f => f.id === chart.yAxisFormula)
|
||||||
if (selectedFormula && selectedFormula.formulaItems && selectedFormula.formulaItems.length > 0) {
|
if (selectedFormula && selectedFormula.param1 && selectedFormula.param2 && selectedFormula.operator) {
|
||||||
formulaData = this.calculateFormula(selectedFormula.formulaItems, xAxisData, xAxisDataMap)
|
formulaData = this.calculateFormula(selectedFormula, xAxisData, xAxisDataMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,8 +731,7 @@ export default {
|
|||||||
trigger: 'item',
|
trigger: 'item',
|
||||||
formatter(params) {
|
formatter(params) {
|
||||||
const value = parseFloat(params.value).toFixed(2)
|
const value = parseFloat(params.value).toFixed(2)
|
||||||
const percent = parseFloat(params.percent).toFixed(2)
|
return `${params.seriesName}<br/>${params.name}: ${value} `
|
||||||
return `${params.seriesName}<br/>${params.name}: ${value}% (${percent}%)`
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
@ -837,15 +842,15 @@ export default {
|
|||||||
const formulaName = selectedFormula ? selectedFormula.name : '公式'
|
const formulaName = selectedFormula ? selectedFormula.name : '公式'
|
||||||
series.push({
|
series.push({
|
||||||
name: formulaName,
|
name: formulaName,
|
||||||
type: 'line',
|
type: chartType === 'bar' ? 'bar' : chartType === 'scatter' ? 'scatter' : 'line',
|
||||||
data: formulaData,
|
data: formulaData,
|
||||||
lineStyle: {
|
lineStyle: {
|
||||||
color: '#F56C6C',
|
color: '#F56C6C',
|
||||||
type: 'dashed',
|
type: 'dashed',
|
||||||
width: 2
|
width: 2
|
||||||
},
|
},
|
||||||
symbol: 'circle',
|
symbol: chartType === 'scatter' ? 'diamond' : 'circle',
|
||||||
symbolSize: 6,
|
symbolSize: chartType === 'scatter' ? 8 : 6,
|
||||||
itemStyle: { color: '#F56C6C' }
|
itemStyle: { color: '#F56C6C' }
|
||||||
})
|
})
|
||||||
legendData.push(formulaName)
|
legendData.push(formulaName)
|
||||||
@ -907,13 +912,13 @@ export default {
|
|||||||
let result = `${params[0].axisValue}<br/>`
|
let result = `${params[0].axisValue}<br/>`
|
||||||
params.forEach((item) => {
|
params.forEach((item) => {
|
||||||
if (item.value !== undefined && item.value !== null && item.value !== '') {
|
if (item.value !== undefined && item.value !== null && item.value !== '') {
|
||||||
result += `${item.marker}${item.seriesName}: ${item.value}%<br/>`
|
result += `${item.marker}${item.seriesName}: ${item.value}<br/>`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
if (params.value !== undefined && params.value !== null && params.value !== '') {
|
if (params.value !== undefined && params.value !== null && params.value !== '') {
|
||||||
return `${params.seriesName}<br/>${params.marker}${params.name}: ${params.value}%`
|
return `${params.seriesName}<br/>${params.marker}${params.name}: ${params.value}`
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
@ -1033,19 +1038,8 @@ export default {
|
|||||||
const chart = this.chartList[index]
|
const chart = this.chartList[index]
|
||||||
if (!chart) return
|
if (!chart) return
|
||||||
|
|
||||||
// 如果选择了公式,加载该公式的内容并更新图表
|
// 如果选择了公式,更新图表
|
||||||
if (chart.yAxisFormula) {
|
|
||||||
const selectedFormula = this.savedFormulas.find(f => f.id === chart.yAxisFormula)
|
|
||||||
if (selectedFormula) {
|
|
||||||
// 将公式应用到当前图表
|
|
||||||
chart.formulaItems = JSON.parse(JSON.stringify(selectedFormula.formulaItems))
|
|
||||||
this.updateChart(index)
|
this.updateChart(index)
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 如果清空选择,清空公式
|
|
||||||
chart.formulaItems = []
|
|
||||||
this.updateChart(index)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
startEditTitle(index) {
|
startEditTitle(index) {
|
||||||
const chart = this.chartList[index]
|
const chart = this.chartList[index]
|
||||||
@ -1063,6 +1057,16 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 获取公式预览文本
|
||||||
|
getFormulaPreview() {
|
||||||
|
if (!this.formulaFormData.param1 || !this.formulaFormData.param2 || !this.formulaFormData.operator) {
|
||||||
|
return '请选择参数和运算符'
|
||||||
|
}
|
||||||
|
const param1Label = this.yAxisParamOptions.find(opt => opt.value === this.formulaFormData.param1)?.label || this.formulaFormData.param1
|
||||||
|
const param2Label = this.yAxisParamOptions.find(opt => opt.value === this.formulaFormData.param2)?.label || this.formulaFormData.param2
|
||||||
|
const operatorLabel = this.operatorOptions.find(opt => opt.value === this.formulaFormData.operator)?.label || this.formulaFormData.operator
|
||||||
|
return `${param1Label} ${operatorLabel} ${param2Label}`
|
||||||
|
},
|
||||||
handleEditFormula(index) {
|
handleEditFormula(index) {
|
||||||
this.currentFormulaChartIndex = index
|
this.currentFormulaChartIndex = index
|
||||||
const chart = this.chartList[index]
|
const chart = this.chartList[index]
|
||||||
@ -1074,57 +1078,39 @@ export default {
|
|||||||
const existingFormula = this.savedFormulas.find(f => f.id === chart.yAxisFormula)
|
const existingFormula = this.savedFormulas.find(f => f.id === chart.yAxisFormula)
|
||||||
if (existingFormula) {
|
if (existingFormula) {
|
||||||
this.currentFormulaId = existingFormula.id
|
this.currentFormulaId = existingFormula.id
|
||||||
this.formulaName = existingFormula.name
|
this.formulaFormData = {
|
||||||
this.formulaItems = JSON.parse(JSON.stringify(existingFormula.formulaItems))
|
name: existingFormula.name || '',
|
||||||
|
param1: existingFormula.param1 || '',
|
||||||
|
operator: existingFormula.operator || '+',
|
||||||
|
param2: existingFormula.param2 || ''
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果找不到公式,创建新的
|
// 如果找不到公式,创建新的
|
||||||
this.currentFormulaId = null
|
this.currentFormulaId = null
|
||||||
this.formulaName = ''
|
this.formulaFormData = {
|
||||||
this.formulaItems = JSON.parse(JSON.stringify(chart.formulaItems || []))
|
name: '',
|
||||||
|
param1: '',
|
||||||
|
operator: '+',
|
||||||
|
param2: ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 创建新公式
|
// 创建新公式
|
||||||
this.currentFormulaId = null
|
this.currentFormulaId = null
|
||||||
this.formulaName = ''
|
this.formulaFormData = {
|
||||||
this.formulaItems = JSON.parse(JSON.stringify(chart.formulaItems || []))
|
name: '',
|
||||||
|
param1: '',
|
||||||
|
operator: '+',
|
||||||
|
param2: ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.formulaDialogVisible = true
|
this.formulaDialogVisible = true
|
||||||
},
|
},
|
||||||
addFormulaParam() {
|
|
||||||
// 使用第一个可用的Y轴参数作为默认值
|
|
||||||
const defaultParam = this.yAxisParamOptions.length > 0 ? this.yAxisParamOptions[0].value : ''
|
|
||||||
this.formulaItems.push({ type: 'param', value: defaultParam })
|
|
||||||
this.updateFormula()
|
|
||||||
},
|
|
||||||
addFormulaOperator() {
|
|
||||||
this.formulaItems.push({ type: 'operator', value: '+' })
|
|
||||||
this.updateFormula()
|
|
||||||
},
|
|
||||||
removeFormulaItem(index) {
|
|
||||||
this.formulaItems.splice(index, 1)
|
|
||||||
this.updateFormula()
|
|
||||||
},
|
|
||||||
updateFormula() {
|
|
||||||
// 更新公式显示
|
|
||||||
},
|
|
||||||
handleSaveFormula() {
|
handleSaveFormula() {
|
||||||
// 验证公式名称
|
// 验证公式
|
||||||
if (!this.formulaName || this.formulaName.trim() === '') {
|
if (!this.isFormulaValid) {
|
||||||
this.$message.warning('请输入公式名称')
|
this.$message.warning('请完整填写公式信息,且两个参数不能相同')
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证公式内容
|
|
||||||
if (this.formulaItems.length === 0) {
|
|
||||||
this.$message.warning('请至少添加一个参数')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证公式格式(至少需要一个参数)
|
|
||||||
const paramCount = this.formulaItems.filter(item => item.type === 'param').length
|
|
||||||
if (paramCount < 1) {
|
|
||||||
this.$message.warning('公式至少需要包含一个参数')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1134,16 +1120,23 @@ export default {
|
|||||||
// 修改已存在的公式
|
// 修改已存在的公式
|
||||||
const formulaIndex = this.savedFormulas.findIndex(f => f.id === formulaId)
|
const formulaIndex = this.savedFormulas.findIndex(f => f.id === formulaId)
|
||||||
if (formulaIndex >= 0) {
|
if (formulaIndex >= 0) {
|
||||||
this.savedFormulas[formulaIndex].name = this.formulaName.trim()
|
this.savedFormulas[formulaIndex] = {
|
||||||
this.savedFormulas[formulaIndex].formulaItems = JSON.parse(JSON.stringify(this.formulaItems))
|
...this.savedFormulas[formulaIndex],
|
||||||
|
name: this.formulaFormData.name.trim(),
|
||||||
|
param1: this.formulaFormData.param1,
|
||||||
|
operator: this.formulaFormData.operator,
|
||||||
|
param2: this.formulaFormData.param2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 创建新公式
|
// 创建新公式
|
||||||
formulaId = `formula_${this.formulaIdCounter++}`
|
formulaId = `formula_${this.formulaIdCounter++}`
|
||||||
this.savedFormulas.push({
|
this.savedFormulas.push({
|
||||||
id: formulaId,
|
id: formulaId,
|
||||||
name: this.formulaName.trim(),
|
name: this.formulaFormData.name.trim(),
|
||||||
formulaItems: JSON.parse(JSON.stringify(this.formulaItems))
|
param1: this.formulaFormData.param1,
|
||||||
|
operator: this.formulaFormData.operator,
|
||||||
|
param2: this.formulaFormData.param2
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,7 +1145,6 @@ export default {
|
|||||||
const chart = this.chartList[this.currentFormulaChartIndex]
|
const chart = this.chartList[this.currentFormulaChartIndex]
|
||||||
if (chart) {
|
if (chart) {
|
||||||
chart.yAxisFormula = formulaId
|
chart.yAxisFormula = formulaId
|
||||||
chart.formulaItems = JSON.parse(JSON.stringify(this.formulaItems))
|
|
||||||
this.updateChart(this.currentFormulaChartIndex)
|
this.updateChart(this.currentFormulaChartIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1164,16 +1156,19 @@ export default {
|
|||||||
this.formulaDialogVisible = false
|
this.formulaDialogVisible = false
|
||||||
this.currentFormulaChartIndex = -1
|
this.currentFormulaChartIndex = -1
|
||||||
this.currentFormulaId = null
|
this.currentFormulaId = null
|
||||||
this.formulaName = ''
|
this.formulaFormData = {
|
||||||
this.formulaItems = []
|
name: '',
|
||||||
|
param1: '',
|
||||||
|
operator: '+',
|
||||||
|
param2: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 计算公式结果
|
// 计算公式结果(新格式:param1, operator, param2)
|
||||||
calculateFormula(formulaItems, xAxisData, xAxisDataMap) {
|
calculateFormula(formula, xAxisData, xAxisDataMap) {
|
||||||
if (!formulaItems || formulaItems.length === 0) {
|
if (!formula || !formula.param1 || !formula.param2 || !formula.operator) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将公式转换为可执行的表达式
|
|
||||||
const formulaData = []
|
const formulaData = []
|
||||||
|
|
||||||
xAxisData.forEach(xValue => {
|
xAxisData.forEach(xValue => {
|
||||||
@ -1181,59 +1176,34 @@ export default {
|
|||||||
let result = null
|
let result = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 构建计算栈
|
// 获取参数1的值
|
||||||
const stack = []
|
const param1Value = this.getParamValueFromData(formula.param1, xValue, xAxisDataMap)
|
||||||
|
// 获取参数2的值
|
||||||
|
const param2Value = this.getParamValueFromData(formula.param2, xValue, xAxisDataMap)
|
||||||
|
|
||||||
formulaItems.forEach(item => {
|
if (param1Value !== null && param1Value !== undefined && param2Value !== null && param2Value !== undefined) {
|
||||||
if (item.type === 'param') {
|
const num1 = parseFloat(param1Value)
|
||||||
// 参数:从数据中获取值
|
const num2 = parseFloat(param2Value)
|
||||||
const paramValue = this.getParamValueFromData(item.value, xValue, xAxisDataMap)
|
|
||||||
if (paramValue !== null && paramValue !== undefined) {
|
|
||||||
const numValue = parseFloat(paramValue)
|
|
||||||
if (!isNaN(numValue)) {
|
|
||||||
stack.push(numValue)
|
|
||||||
} else {
|
|
||||||
stack.push(null)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stack.push(null)
|
|
||||||
}
|
|
||||||
} else if (item.type === 'operator') {
|
|
||||||
// 运算符:执行计算
|
|
||||||
if (stack.length >= 2) {
|
|
||||||
const b = stack.pop()
|
|
||||||
const a = stack.pop()
|
|
||||||
|
|
||||||
if (a !== null && b !== null && !isNaN(a) && !isNaN(b)) {
|
if (!isNaN(num1) && !isNaN(num2)) {
|
||||||
let calcResult = null
|
switch (formula.operator) {
|
||||||
switch (item.value) {
|
|
||||||
case '+':
|
case '+':
|
||||||
calcResult = a + b
|
result = num1 + num2
|
||||||
break
|
break
|
||||||
case '-':
|
case '-':
|
||||||
calcResult = a - b
|
result = num1 - num2
|
||||||
break
|
break
|
||||||
case '*':
|
case '*':
|
||||||
calcResult = a * b
|
result = num1 * num2
|
||||||
break
|
break
|
||||||
case '/':
|
case '/':
|
||||||
calcResult = b !== 0 ? a / b : null
|
result = num2 !== 0 ? num1 / num2 : null
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
calcResult = null
|
result = null
|
||||||
}
|
|
||||||
stack.push(calcResult)
|
|
||||||
} else {
|
|
||||||
stack.push(null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
// 栈顶元素就是结果
|
|
||||||
if (stack.length === 1) {
|
|
||||||
result = stack[0]
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('计算公式失败:', err)
|
console.error('计算公式失败:', err)
|
||||||
result = null
|
result = null
|
||||||
@ -1708,63 +1678,16 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.formula-dialog-content {
|
.formula-dialog-content {
|
||||||
.formula-note {
|
.formula-preview {
|
||||||
color: #f56c6c;
|
|
||||||
font-size: 12px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formula-input-section {
|
|
||||||
.formula-label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formula-editor {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
background: #f5f7fa;
|
background: #f5f7fa;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
min-height: 50px;
|
|
||||||
align-items: center;
|
|
||||||
border: 1px solid #dcdfe6;
|
border: 1px solid #dcdfe6;
|
||||||
|
font-size: 14px;
|
||||||
.formula-item {
|
color: #303133;
|
||||||
|
min-height: 40px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
|
||||||
|
|
||||||
.formula-select {
|
|
||||||
width: 120px;
|
|
||||||
|
|
||||||
::v-deep .el-input__inner {
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.formula-delete-icon {
|
|
||||||
cursor: pointer;
|
|
||||||
color: #909399;
|
|
||||||
font-size: 16px;
|
|
||||||
margin-left: 4px;
|
|
||||||
padding: 4px;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #f56c6c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.formula-buttons {
|
|
||||||
margin-top: 16px;
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,9 +20,6 @@
|
|||||||
<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" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="排序号:" prop="orderNum">
|
|
||||||
<el-input-number v-model="formData.orderNum" placeholder="请输入排序号" min="0" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
@ -51,12 +48,10 @@ export default {
|
|||||||
formData: {
|
formData: {
|
||||||
templateName: '',
|
templateName: '',
|
||||||
template_status: '',
|
template_status: '',
|
||||||
createdBy: '',
|
createdBy: ''
|
||||||
orderNum: ''
|
|
||||||
},
|
},
|
||||||
formRules: {
|
formRules: {
|
||||||
templateName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
templateName: [{ required: true, message: '请输入名称', trigger: 'blur' }]
|
||||||
orderNum: [{ required: true, message: '请输入排序号', trigger: 'blur' }]
|
|
||||||
},
|
},
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ label: '草稿', value: '草稿' },
|
{ label: '草稿', value: '草稿' },
|
||||||
|
|||||||
@ -1256,13 +1256,18 @@ export default {
|
|||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
},
|
},
|
||||||
shouldShowSection(sectionName) {
|
shouldShowSection(sectionName) {
|
||||||
// 如果选中了"整车参数",不显示子系统参数
|
// 如果选中了"整车参数",且没有选中任何其他非整车参数的节点,则不显示子系统参数
|
||||||
if (this.isWholeEngineParamsSelected && !this.checkedKeys.some(nodeId => {
|
if (this.isWholeEngineParamsSelected) {
|
||||||
|
// 检查是否有选中任何非整车参数的节点(不管是父节点还是子节点)
|
||||||
|
const hasNonWholeEngineParamsNode = this.checkedKeys.some(nodeId => {
|
||||||
const nodeInfo = this.nodeMap[nodeId]
|
const nodeInfo = this.nodeMap[nodeId]
|
||||||
return nodeInfo && !nodeInfo.isWholeEngineParams && !nodeInfo.isParent
|
return nodeInfo && !nodeInfo.isWholeEngineParams
|
||||||
})) {
|
})
|
||||||
|
// 如果没有选中任何非整车参数的节点,则不显示子系统参数
|
||||||
|
if (!hasNonWholeEngineParamsNode) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// sectionName是参数类型(如"基本规格"),需要检查是否有对应的数据
|
// sectionName是参数类型(如"基本规格"),需要检查是否有对应的数据
|
||||||
const data = this.versionData[this.currentVersionId] || {}
|
const data = this.versionData[this.currentVersionId] || {}
|
||||||
if (!data[sectionName] || data[sectionName].length === 0) {
|
if (!data[sectionName] || data[sectionName].length === 0) {
|
||||||
@ -1286,12 +1291,6 @@ export default {
|
|||||||
// 如果选中的是父节点,检查该section的数据是否属于该父节点
|
// 如果选中的是父节点,检查该section的数据是否属于该父节点
|
||||||
if (nodeInfo.isParent) {
|
if (nodeInfo.isParent) {
|
||||||
const sectionData = data[sectionName] || []
|
const sectionData = data[sectionName] || []
|
||||||
// 如果 sectionName 等于子系统名称,说明这是零部件名称为 "/" 的分组
|
|
||||||
// 这种情况下,sectionName 就是子系统名称,所以直接匹配
|
|
||||||
if (sectionName === nodeInfo.label) {
|
|
||||||
hasMatch = true
|
|
||||||
} else {
|
|
||||||
// 否则检查该section的数据是否属于该父节点
|
|
||||||
const hasDataInSubsystem = sectionData.some(
|
const hasDataInSubsystem = sectionData.some(
|
||||||
(param) => param.subsystemName === nodeInfo.label
|
(param) => param.subsystemName === nodeInfo.label
|
||||||
)
|
)
|
||||||
@ -1300,7 +1299,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return hasMatch
|
return hasMatch
|
||||||
},
|
},
|
||||||
|
|||||||
@ -347,6 +347,30 @@ export default {
|
|||||||
// 检查是否在 parameterTypes 中,或者是否在 subsystemTypes 中(格式:子系统名称-零部件名称)
|
// 检查是否在 parameterTypes 中,或者是否在 subsystemTypes 中(格式:子系统名称-零部件名称)
|
||||||
shouldInclude = parameterTypes.includes(displayPartsName) ||
|
shouldInclude = parameterTypes.includes(displayPartsName) ||
|
||||||
subsystemTypes.includes(`${subsystemName}-${displayPartsName}`)
|
subsystemTypes.includes(`${subsystemName}-${displayPartsName}`)
|
||||||
|
|
||||||
|
// 如果该参数不匹配任何已选中的子节点,检查该子系统是否被直接选中(作为父节点)
|
||||||
|
// 如果子系统被直接选中,且该参数的 partsName 是 '/',也应该包含
|
||||||
|
if (!shouldInclude) {
|
||||||
|
// 检查该子系统是否被直接选中(作为父节点,没有子节点被选中)
|
||||||
|
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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 如果子系统被直接选中,且该参数的 partsName 是 '/',包含该参数
|
||||||
|
if (isSubsystemDirectlySelected && (partsName === '/' || displayPartsName === subsystemName)) {
|
||||||
|
shouldInclude = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldInclude) {
|
if (shouldInclude) {
|
||||||
@ -1023,6 +1047,9 @@ export default {
|
|||||||
// 保存常用配置
|
// 保存常用配置
|
||||||
this.currentCommonConfig = selectedFavorite.data
|
this.currentCommonConfig = selectedFavorite.data
|
||||||
|
|
||||||
|
// 按照节点比较参数,自动隐藏缺少的参数
|
||||||
|
this.hideMissingParamsByNode()
|
||||||
|
|
||||||
// 根据可显示的参数更新树节点选中状态
|
// 根据可显示的参数更新树节点选中状态
|
||||||
// 注意:不再调用 hideParamsNotInCommon,而是让 displayParams 自动过滤
|
// 注意:不再调用 hideParamsNotInCommon,而是让 displayParams 自动过滤
|
||||||
// 如果树节点未选中,参数不显示(可以通过选中树节点恢复)
|
// 如果树节点未选中,参数不显示(可以通过选中树节点恢复)
|
||||||
@ -1112,7 +1139,6 @@ export default {
|
|||||||
console.error('下载失败:', err)
|
console.error('下载失败:', err)
|
||||||
console.log('下载失败,请稍后重试')
|
console.log('下载失败,请稍后重试')
|
||||||
})
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
// 根据可显示的参数更新树节点选中状态(不改变树数据)
|
// 根据可显示的参数更新树节点选中状态(不改变树数据)
|
||||||
updateCheckedKeysByDisplayParams() {
|
updateCheckedKeysByDisplayParams() {
|
||||||
@ -1266,7 +1292,84 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 根据常用配置隐藏不在范围内的参数
|
// 按照节点比较参数,自动隐藏缺少的参数
|
||||||
|
hideMissingParamsByNode() {
|
||||||
|
if (!this.currentCommonConfig || !this.currentCommonConfig.subsystems) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.allParametersData || Object.keys(this.allParametersData).length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建常用配置中的参数映射:subsystem -> Set<parameterKey>
|
||||||
|
// parameterKey 格式:优先使用 parameterId,如果没有则使用 parameterName
|
||||||
|
const commonParamsMap = new Map()
|
||||||
|
this.currentCommonConfig.subsystems.forEach(subsystemConfig => {
|
||||||
|
const subsystemName = subsystemConfig.subsystem
|
||||||
|
const paramKeys = new Set()
|
||||||
|
subsystemConfig.parameters.forEach(p => {
|
||||||
|
// 优先使用 parameterId,如果没有则使用 parameterName
|
||||||
|
const key = p.parameterId || p.parameterName
|
||||||
|
if (key) {
|
||||||
|
paramKeys.add(key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
commonParamsMap.set(subsystemName, paramKeys)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 遍历所有参数数据,按节点比较并找出缺少的参数
|
||||||
|
const paramsToHide = []
|
||||||
|
Object.keys(this.allParametersData).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 || ''
|
||||||
|
// 使用 parameterId 或 parameterName 作为匹配键
|
||||||
|
const matchKey = parameterId || parameterName
|
||||||
|
|
||||||
|
// 检查该参数是否在常用配置中
|
||||||
|
const isInCommon = 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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 根据常用配置隐藏不在范围内的参数(旧方法,保留以备用)
|
||||||
hideParamsNotInCommon() {
|
hideParamsNotInCommon() {
|
||||||
if (!this.currentCommonConfig || !this.currentCommonConfig.subsystems) {
|
if (!this.currentCommonConfig || !this.currentCommonConfig.subsystems) {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -37,10 +37,10 @@
|
|||||||
<el-button type="primary" @click="handleDownloadImportTemplate">
|
<el-button type="primary" @click="handleDownloadImportTemplate">
|
||||||
下载导入模板
|
下载导入模板
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button class="import-btn" @click="handleImportTemplate()">
|
<el-button v-if="isAdmin()" class="import-btn" @click="handleImportTemplate()">
|
||||||
导入参数模板
|
导入参数模板
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" @click="handleAddTemplate()">
|
<el-button v-if="isAdmin()" 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'"
|
v-if="row.status === 'DRAFT' && isAdmin()"
|
||||||
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)"
|
||||||
@ -330,6 +330,24 @@ 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
|
||||||
|
}
|
||||||
|
},
|
||||||
// 加载用户自身角色权限
|
// 加载用户自身角色权限
|
||||||
loadUserSelfRole() {
|
loadUserSelfRole() {
|
||||||
localStorage.setItem('user_self_role', [])
|
localStorage.setItem('user_self_role', [])
|
||||||
|
|||||||
@ -1217,20 +1217,36 @@ export default {
|
|||||||
const checkSubsystem = subsystem || this.displayTemplateName
|
const checkSubsystem = subsystem || this.displayTemplateName
|
||||||
return this.checkPermission('模板管理', checkSubsystem, '编辑')
|
return this.checkPermission('模板管理', checkSubsystem, '编辑')
|
||||||
},
|
},
|
||||||
|
// 检查是否是管理员(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
|
||||||
|
}
|
||||||
|
},
|
||||||
// 检查参数是否有编辑权限(根据subsystem和partsName匹配)
|
// 检查参数是否有编辑权限(根据subsystem和partsName匹配)
|
||||||
hasParameterEditPermission(subsystem, partsName) {
|
hasParameterEditPermission(subsystem, partsName) {
|
||||||
|
// 如果是管理员,拥有全部权限
|
||||||
|
if (this.isAdmin()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
if (!subsystem || !partsName) {
|
if (!subsystem || !partsName) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// 优先使用传入的权限数组
|
// 优先使用传入的权限数组
|
||||||
if (this.templateManagementPermissions && this.templateManagementPermissions.length > 0) {
|
if (this.templateManagementPermissions && this.templateManagementPermissions.length > 0) {
|
||||||
const templateName = this.displayTemplateName
|
|
||||||
const matchedPermissions = this.templateManagementPermissions.filter((perm) => {
|
const matchedPermissions = this.templateManagementPermissions.filter((perm) => {
|
||||||
// 检查 subsystem 是否匹配 templateName
|
|
||||||
if (templateName && perm.subsystem !== templateName) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查 subsystem 是否匹配
|
// 检查 subsystem 是否匹配
|
||||||
if (perm.subsystem !== subsystem) {
|
if (perm.subsystem !== subsystem) {
|
||||||
return false
|
return false
|
||||||
@ -1247,7 +1263,7 @@ export default {
|
|||||||
|
|
||||||
return matchedPermissions.length > 0
|
return matchedPermissions.length > 0
|
||||||
}
|
}
|
||||||
// 如果没有传入权限数组,从 localStorage 读取
|
// 如果没有传入权限数组,从 localStorage 读取 user_self_role
|
||||||
try {
|
try {
|
||||||
const permissionDataStr = localStorage.getItem('user_self_role')
|
const permissionDataStr = localStorage.getItem('user_self_role')
|
||||||
if (!permissionDataStr) {
|
if (!permissionDataStr) {
|
||||||
@ -1258,27 +1274,20 @@ export default {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找匹配的权限:menuPath包含"模板管理",subsystem匹配,partsName匹配,且parameterPer为"编辑"
|
// 查找匹配的权限:subsystem匹配,partsName匹配,且parameterPer为"编辑"
|
||||||
const templateName = this.displayTemplateName
|
|
||||||
const matchedPermissions = permissionData.filter((perm) => {
|
const matchedPermissions = permissionData.filter((perm) => {
|
||||||
// 检查 menuPath 是否匹配
|
// 如果 menuPath 存在,检查是否包含"模板管理"(可选检查)
|
||||||
const menuMatch = perm.menuPath && perm.menuPath.includes('模板管理')
|
if (perm.menuPath && perm.menuPath.trim() !== '' && !perm.menuPath.includes('模板管理')) {
|
||||||
if (!menuMatch) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查 subsystem 是否匹配 templateName(如果 templateName 存在)
|
|
||||||
if (templateName && perm.subsystem !== templateName) {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查 subsystem 是否匹配
|
// 检查 subsystem 是否匹配
|
||||||
if (perm.subsystem !== subsystem) {
|
if (!perm.subsystem || perm.subsystem !== subsystem) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查 partsName 是否匹配
|
// 检查 partsName 是否匹配
|
||||||
if (perm.partsName !== partsName) {
|
if (!perm.partsName || perm.partsName !== partsName) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1297,6 +1306,10 @@ export default {
|
|||||||
if (!row) {
|
if (!row) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// 如果是管理员,拥有全部权限,可以直接编辑/删除
|
||||||
|
if (this.isAdmin()) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
// 如果该行的 createdBy 等于当前用户ID,可以编辑/删除
|
// 如果该行的 createdBy 等于当前用户ID,可以编辑/删除
|
||||||
if (row.createdBy === getUserId()) {
|
if (row.createdBy === getUserId()) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@ -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,9 +39,17 @@
|
|||||||
@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
|
||||||
|
href="javascript:void(0)"
|
||||||
|
class="el-link el-link--primary"
|
||||||
|
@click.stop="handleRowView(row)"
|
||||||
|
>查看</a
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -140,10 +152,29 @@
|
|||||||
{ 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: {},
|
||||||
@ -165,12 +196,12 @@
|
|||||||
},
|
},
|
||||||
handleRowView(row) {
|
handleRowView(row) {
|
||||||
// 根据流程主题判断打开哪种页面
|
// 根据流程主题判断打开哪种页面
|
||||||
const processTitle = row.processTitle || ''
|
const dataType = row.dataType
|
||||||
const isFillParameterMode = processTitle === '数据维护'
|
const isFillParameterMode = dataType === '数据维护'
|
||||||
const isResponsibleDispatchMode = processTitle === '任务分解'
|
const isResponsibleDispatchMode = dataType === '任务分解'
|
||||||
const isInApprovalMode = processTitle === '数据审批'
|
const isInApprovalMode = dataType === '数据审批'
|
||||||
const isModelCheck = processTitle === '模板审核'
|
const isModelCheck = dataType === '模板审核'
|
||||||
const isReportCheck = processTitle === '对标报告审核'
|
const isReportCheck = dataType === '对标报告审核'
|
||||||
|
|
||||||
// 设置引擎型号信息
|
// 设置引擎型号信息
|
||||||
this.currentModel = row.modelName || row.productFullName || ''
|
this.currentModel = row.modelName || row.productFullName || ''
|
||||||
@ -200,6 +231,7 @@
|
|||||||
this.currentApprovalDetail = {
|
this.currentApprovalDetail = {
|
||||||
flowId: row.documentNo || '',
|
flowId: row.documentNo || '',
|
||||||
templateId: row.modelId || '',
|
templateId: row.modelId || '',
|
||||||
|
id: row.documentNo || '',
|
||||||
...row
|
...row
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -420,4 +452,3 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@ -186,12 +186,12 @@ export default {
|
|||||||
},
|
},
|
||||||
handleRowView(row) {
|
handleRowView(row) {
|
||||||
// 根据流程主题判断打开哪种页面
|
// 根据流程主题判断打开哪种页面
|
||||||
const processTitle = row.processTitle || ''
|
const dataType = row.dataType || ''
|
||||||
const isFillParameterMode = processTitle === '数据维护'
|
const isFillParameterMode = dataType === '数据维护'
|
||||||
const isResponsibleDispatchMode = processTitle === '任务分解'
|
const isResponsibleDispatchMode = dataType === '任务分解'
|
||||||
const isInApprovalMode = processTitle === '数据审批'
|
const isInApprovalMode = dataType === '数据审批'
|
||||||
const isModelCheck = processTitle === '模板审核'
|
const isModelCheck = dataType === '模板审核'
|
||||||
const isReportCheck = processTitle === '对标报告审核'
|
const isReportCheck = dataType === '对标报告审核'
|
||||||
|
|
||||||
// 设置引擎型号信息
|
// 设置引擎型号信息
|
||||||
this.currentModel = row.modelName || row.productFullName || ''
|
this.currentModel = row.modelName || row.productFullName || ''
|
||||||
|
|||||||
@ -1037,6 +1037,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const file = this.selectedFile
|
const file = this.selectedFile
|
||||||
|
console.log(file,2222);
|
||||||
|
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
formData.append('createBy', getUserId())
|
formData.append('createBy', getUserId())
|
||||||
@ -1095,6 +1097,7 @@ export default {
|
|||||||
const fileUrl = await this.handleFileUpload()
|
const fileUrl = await this.handleFileUpload()
|
||||||
// 将文件路径存储到 formData 中
|
// 将文件路径存储到 formData 中
|
||||||
this.createFormData.fileUrl = fileUrl || ''
|
this.createFormData.fileUrl = fileUrl || ''
|
||||||
|
this.createFormData.fileName = this.selectedFile.name
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('文件上传失败:', err)
|
console.error('文件上传失败:', err)
|
||||||
this.$message.error('文件上传失败,请重试')
|
this.$message.error('文件上传失败,请重试')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user