hookehuyr

fix: 优化规则检查中字段初始化的逻辑

只重置在规则中出现过的字段的disabled状态,避免不必要的初始化操作
1 <!-- 1 <!--
2 * @Date: 2022-07-18 10:22:22 2 * @Date: 2022-07-18 10:22:22
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-07-03 11:08:36 4 + * @LastEditTime: 2025-07-03 17:44:43
5 * @FilePath: /data-table/src/views/index.vue 5 * @FilePath: /data-table/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -712,11 +712,21 @@ const mergeAndDeduplicate = (data) => { ...@@ -712,11 +712,21 @@ const mergeAndDeduplicate = (data) => {
712 const checkRules = () => { 712 const checkRules = () => {
713 const rule_list = formInfo.value['rule_list'] ? [...formInfo.value['rule_list']] : []; 713 const rule_list = formInfo.value['rule_list'] ? [...formInfo.value['rule_list']] : [];
714 714
715 - // 初始化所有字段的规则 715 + // 收集所有规则中涉及的字段
716 + const fieldsInRules = new Set();
717 + rule_list.forEach(rule => {
718 + if (rule.field_names && Array.isArray(rule.field_names)) {
719 + rule.field_names.forEach(fieldName => {
720 + fieldsInRules.add(fieldName);
721 + });
722 + }
723 + });
724 +
725 + // 初始化字段规则,只重置在规则中出现过的字段
716 formData.value.forEach(item => { 726 formData.value.forEach(item => {
717 item.x_rules = []; 727 item.x_rules = [];
718 - // 重置disabled状态,避免上次规则影响 728 + // 只重置在规则中出现过的字段的disabled状态
719 - if (item.component_props) { 729 + if (fieldsInRules.has(item.key) && item.component_props) {
720 item.component_props.disabled = false; 730 item.component_props.disabled = false;
721 } 731 }
722 }); 732 });
......