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

修改bug

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