提交 db81d638 authored 作者: kxjia's avatar kxjia

修改bug

上级 2a980e8a
......@@ -233,8 +233,7 @@
</vxe-checkbox-group>
<template v-if="ccopt.otherOption">
<div style="margin-top: 5px; margin-left: 20px">
其他:
<vxe-input
其他:<vxe-input
v-model="formData[row.code + '_' + ccopt.otherField]"
:disabled="
!(
......@@ -254,8 +253,7 @@
</vxe-radio-group>
<template v-if="ccopt.otherOption && formData[row.code + '_' + ccopt.field] === '其他'">
<div style="margin-top: 5px; margin-left: 20px">
其他:
<vxe-input v-model="formData[row.code + '_' + ccopt.otherField]" style="width: 200px"></vxe-input>
其他:<vxe-input v-model="formData[row.code + '_' + ccopt.otherField]" style="width: 200px"></vxe-input>
</div>
</template>
</template>
......@@ -276,11 +274,12 @@
/>
<span class="unit"> {{ item.unit }}</span>
<!-- 帮助图标 -->
<!-- 帮助图标 - 修改这里 -->
<span
v-if="item.hasValidFormula"
v-if="showHelpIcon(row.code, item.field, item)"
class="help-icon"
@click.stop="toggleTooltip(row.code, item.field)"
title="点击查看校验规则"
>
?
</span>
......@@ -290,6 +289,7 @@
v-if="inputErrors[getFieldKey(row.code, item.field)]"
class="error-icon"
@click.stop="toggleErrorTooltip(row.code, item.field)"
title="点击查看错误详情"
>
<i class="vxe-icon-error"></i>
</span>
......@@ -315,7 +315,7 @@
<!-- 校验规则提示 -->
<div
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field)"
v-if="showTooltip && hoveredKey === getFieldKey(row.code, item.field) && item.matchedFormula"
class="tooltip"
@click.stop
>
......@@ -345,7 +345,7 @@
import HistoryFillCheck from './check/historyFillCheck.vue';
import ValidationDrawer from './check/ValidationDrawer.vue';
import { tableFormData } from '../../data/tb6.data';
import { ref, reactive, nextTick, onMounted, toRaw, computed } from 'vue';
import { ref, reactive, nextTick, onMounted, toRaw, computed, watch } from 'vue';
import { VxeUI, VxeToolbarInstance, VxeToolbarPropTypes } from 'vxe-table';
import { batchSaveOrUpdate, queryRecord, batchSaveOrUpdateBeforeDelete } from '../../record/BaosongTaskRecord.api';
import { queryAllTplItemForUser, findUserRightForTplItem } from '../../alloc/BaosongTaskAlloc.api';
......@@ -377,6 +377,7 @@
const hoveredKey = ref('');
const showErrorTooltip = ref(false);
const hoveredErrorKey = ref('');
const isInitialized = ref(false);
interface FormData {
id: number | null;
......@@ -428,6 +429,9 @@
validFormula.value = await getTblvalidFormula({
tplid: queryParam.value.tplId,
});
console.log('获取到的权限:', userAllocItems.value.length);
console.log('获取到的公式:', validFormula.value.length);
} catch (error) {
console.error('获取权限或验证公式失败:', error);
}
......@@ -435,6 +439,14 @@
await setTplItemMap();
await setFormItemRight();
await setData();
// 标记初始化完成
isInitialized.value = true;
// 延迟刷新一次,确保问号图标显示
setTimeout(() => {
refreshHelpIcons();
}, 300);
});
const loading = ref(false);
......@@ -448,6 +460,23 @@
return `${rowCode}_${field}`;
};
// 添加帮助图标显示条件计算
const showHelpIcon = (rowCode: string, field: string, item: any): boolean => {
// 如果已经有 hasValidFormula 属性,直接使用
if (item.hasValidFormula !== undefined) {
return item.hasValidFormula === true;
}
// 否则重新计算
const key = getFieldKey(rowCode, field);
const hasRight = userAllocItems.value.includes(key);
if (!hasRight) return false;
const formulaResult = findEarliestFormulaForField(validFormula.value, field);
return !!formulaResult.formula;
};
const saveBatch = async () => {
try {
formValues.value = [];
......@@ -458,7 +487,7 @@
} else {
VxeUI.modal.message({ content: '没有需要保存的数据', status: 'warning' });
}
} catch (error) {
} catch (error: any) {
VxeUI.modal.message({ content: `保存失败: ${error.message}`, status: 'error' });
} finally {
loading.value = false;
......@@ -673,6 +702,10 @@
};
const setFormItemRight = () => {
console.log('开始设置表单权限...');
console.log('userAllocItems 数量:', userAllocItems.value.length);
console.log('validFormula 数量:', validFormula.value.length);
tableFormData.forEach((row: any) => {
if (row.content && Array.isArray(row.content)) {
row.content.forEach((item: any) => {
......@@ -680,15 +713,25 @@
const key = getFieldKey(row.code, item.field);
item.hasRight = userAllocItems.value.includes(key);
console.log(`字段 ${key}: hasRight = ${item.hasRight}`);
if (item.hasRight) {
const { formula } = findEarliestFormulaForField(validFormula.value, item.field);
item.hasValidFormula = !!formula;
item.matchedFormula = formula;
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field);
item.hasValidFormula = !!formulaResult.formula;
item.matchedFormula = formulaResult.formula || null;
console.log(`字段 ${key}: hasValidFormula = ${item.hasValidFormula}`);
} else {
item.hasValidFormula = false;
item.matchedFormula = null;
}
}
});
}
});
console.log('表单权限设置完成');
};
const findEarliestFormulaForField = (
......@@ -729,6 +772,35 @@
historyDrawerVisible.value = false;
};
// 添加刷新帮助图标的方法
const refreshHelpIcons = () => {
console.log('刷新帮助图标...');
tableFormData.forEach((row: any) => {
if (row.content && Array.isArray(row.content)) {
row.content.forEach((item: any) => {
if (item.field) {
const key = getFieldKey(row.code, item.field);
const hasRight = userAllocItems.value.includes(key);
if (hasRight) {
const formulaResult = findEarliestFormulaForField(validFormula.value, item.field);
item.hasValidFormula = !!formulaResult.formula;
item.matchedFormula = formulaResult.formula || null;
} else {
item.hasValidFormula = false;
item.matchedFormula = null;
}
}
});
}
});
// 强制更新视图
nextTick(() => {
console.log('帮助图标刷新完成');
});
};
// 原有检查方法
async function checkDataOrig() {
let tplName = queryParam.value.tplName;
......@@ -837,7 +909,7 @@
nextTick();
child.setFormData(tableDatas);
}
} catch (error) {
} catch (error: any) {
VxeUI.modal.message({
content: `加载数据失败: ${error.message}`,
status: 'error',
......@@ -859,7 +931,7 @@
let strKey = item.pcode + '_' + item.xmlcode;
tplItemMap.value[strKey] = { pid: item.pid, itemid: item.id, formTp: item.formTp, code: item.xmlcode };
});
} catch (error) {
} catch (error: any) {
VxeUI.modal.message({ content: `加载数据失败: ${error.message}`, status: 'error' });
} finally {
}
......@@ -1098,9 +1170,24 @@
background: #e6f7ff;
border-radius: 50%;
transition: all 0.3s;
opacity: 0;
animation: fadeIn 0.5s forwards;
animation-delay: 0.3s;
&:hover {
background: #bae7ff;
transform: scale(1.1);
}
}
@keyframes fadeIn {
from {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论