hookehuyr

🐞 fix(规则应用): 处理规则问题:收作用的规则字段如果隐藏,它设置的相应字段也需要隐藏

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: 2024-07-24 10:45:46 4 + * @LastEditTime: 2024-07-27 10:26:54
5 * @FilePath: /data-table/src/views/index.vue 5 * @FilePath: /data-table/src/views/index.vue
6 * @Description: 首页 6 * @Description: 首页
7 --> 7 -->
...@@ -875,6 +875,33 @@ const checkRules = () => { ...@@ -875,6 +875,33 @@ const checkRules = () => {
875 } 875 }
876 } 876 }
877 item['component_props']['disabled'] = item.field_rules?.mode === 'SHOW' ? !condition : condition; 877 item['component_props']['disabled'] = item.field_rules?.mode === 'SHOW' ? !condition : condition;
878 + /**
879 + * 处理规则问题:收作用的规则字段如果隐藏,它设置的相应字段也需要隐藏
880 + */
881 + // 有规则的字段集合
882 + let rule_keys = formInfo.value['rule_list']
883 + .map(item => item.expr_list[0])
884 + .map(item => item.field_name);
885 + //
886 + let hide_fields = []; // 规则字段下面可以应用规则的字段
887 + formData.value?.forEach(item => {
888 + item.field_rules?.expr_list?.forEach(expr => {
889 + if (rule_keys?.includes(item.key)) {
890 + // 已隐藏字段
891 + if (item.component_props.disabled) {
892 + formInfo.value['rule_list']?.forEach(rule => {
893 + if (rule.expr_list[0]['field_name'] === item.key) {
894 + hide_fields = rule.field_names;
895 + }
896 + })
897 + }
898 + }
899 + });
900 + })
901 + // 隐藏字段集合里面有当前字段
902 + if (hide_fields.includes(item.key)) {
903 + item['component_props']['disabled'] = true;
904 + }
878 } 905 }
879 }); 906 });
880 } 907 }
......