Commit a5b765ee643ede3d9d75fc42eba3b5c6d430d091

Authored by fengtao
1 parent d7360a85

fix:DEFECT-861 场景联动切换组织刷新未刷新条件筛选数据

@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 }; 55 };
56 }); 56 });
57 }); 57 });
58 - const handleSuccess = async (val: { id: string }) => { 58 + const handleSuccess = async (opt) => {
59 const res = await getScriptManageMeList(); 59 const res = await getScriptManageMeList();
60 selectOptions.value = res.map((m) => { 60 selectOptions.value = res.map((m) => {
61 return { 61 return {
@@ -63,7 +63,9 @@ @@ -63,7 +63,9 @@
63 value: m.id, 63 value: m.id,
64 }; 64 };
65 }); 65 });
66 - selectScript.script = val.id; 66 + if (opt.text !== 'test') {
  67 + selectScript.script = opt?.res?.id;
  68 + }
67 }; 69 };
68 70
69 const [register] = useForm({ 71 const [register] = useForm({
@@ -7,90 +7,117 @@ @@ -7,90 +7,117 @@
7 </template> 7 </template>
8 8
9 <template v-for="(item, index) in conditionScreeningList" :key="item"> 9 <template v-for="(item, index) in conditionScreeningList" :key="item">
10 - <ConditionScreeningForm :conditionScreeningList="conditionScreeningList" :ref="refItem.conditionScreeningRefs"  
11 - :index="index" @deleteConditionForm="deleteConditionForm" /> 10 + <ConditionScreeningForm
  11 + :conditionScreeningList="conditionScreeningList"
  12 + :ref="refItem.conditionScreeningRefs"
  13 + :index="index"
  14 + @deleteConditionForm="deleteConditionForm"
  15 + />
12 </template> 16 </template>
13 </CollapseContainer> 17 </CollapseContainer>
14 18
15 <div class="flex justify-between"> 19 <div class="flex justify-between">
16 - <a-button :disabled="isViewDisabledBtn=='isView'?true:false" type="primary" class="mt-4 ml-2"  
17 - @click="addConditionForm">新增条件筛选</a-button>  
18 - <a-button :disabled="isViewDisabledBtn=='isView'?true:false" type="primary" class="mt-4 mr-2" @click="preView"  
19 - v-if="isPreview">保存</a-button> 20 + <a-button
  21 + :disabled="isViewDisabledBtn == 'isView' ? true : false"
  22 + type="primary"
  23 + class="mt-4 ml-2"
  24 + @click="addConditionForm"
  25 + >新增条件筛选</a-button
  26 + >
  27 + <a-button
  28 + :disabled="isViewDisabledBtn == 'isView' ? true : false"
  29 + type="primary"
  30 + class="mt-4 mr-2"
  31 + @click="preView"
  32 + v-if="isPreview"
  33 + >保存</a-button
  34 + >
20 </div> 35 </div>
21 </div> 36 </div>
22 </template> 37 </template>
23 38
24 <script lang="ts" setup> 39 <script lang="ts" setup>
25 -import { unref, ref } from 'vue';  
26 -import ConditionScreeningForm from './ConditionScreeningForm.vue';  
27 -import { conditionPreView } from '../config/formatData.ts';  
28 -import { CollapseContainer } from '/@/components/Container/index';  
29 -import RichText from './RichText.vue';  
30 -const props = defineProps({  
31 - childGetFieldsValue: {  
32 - type: Function,  
33 - required: true,  
34 - },  
35 -});  
36 -const refItem = {  
37 - conditionScreeningRefs: ref([]),  
38 -};  
39 -const isViewDisabledBtn = window.localStorage.getItem('isViewDisabledBtn')  
40 -const isPreview = ref(true);  
41 -const collapseContainerRef = ref();  
42 -const conditionScreeningList = ref([Date.now()]);  
43 -const addConditionForm = () => {  
44 - if (!unref(isPreview)) {  
45 - collapseContainerRef.value.handleExpand();  
46 - }  
47 - unref(conditionScreeningList).push(Date.now());  
48 - const lastIndex = refItem.conditionScreeningRefs.value.length - 1;  
49 - refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField(  
50 - {  
51 - field: 'AND',  
52 - label: '和',  
53 - component: 'Input',  
54 - slot: 'and',  
55 - // labelWidth: 50,  
56 - colProps: { span: 3 }, 40 + import { unref, ref } from 'vue';
  41 + import ConditionScreeningForm from './ConditionScreeningForm.vue';
  42 + import { conditionPreView } from '../config/formatData.ts';
  43 + import { CollapseContainer } from '/@/components/Container/index';
  44 + import RichText from './RichText.vue';
  45 + const props = defineProps({
  46 + childGetFieldsValue: {
  47 + type: Function,
  48 + required: true,
57 }, 49 },
58 - 'value'  
59 - );  
60 -};  
61 -const handleExpand = (show) => {  
62 - isPreview.value = show;  
63 -}; 50 + });
  51 + const refItem = {
  52 + conditionScreeningRefs: ref([]),
  53 + };
  54 + const isViewDisabledBtn = window.localStorage.getItem('isViewDisabledBtn');
  55 + const isPreview = ref(true);
  56 + const collapseContainerRef = ref();
  57 + const conditionScreeningList = ref([Date.now()]);
  58 + const addConditionForm = () => {
  59 + if (!unref(isPreview)) {
  60 + collapseContainerRef.value.handleExpand();
  61 + }
  62 + unref(conditionScreeningList).push(Date.now());
  63 + const lastIndex = refItem.conditionScreeningRefs.value.length - 1;
  64 + refItem.conditionScreeningRefs.value[lastIndex]?.appendSchemaByField(
  65 + {
  66 + field: 'AND',
  67 + label: '和',
  68 + component: 'Input',
  69 + slot: 'and',
  70 + // labelWidth: 50,
  71 + colProps: { span: 3 },
  72 + },
  73 + 'value'
  74 + );
  75 + };
  76 + const handleExpand = (show) => {
  77 + isPreview.value = show;
  78 + };
64 79
65 -const otherAttribute = ref([]);  
66 -// 预览条件筛选结果  
67 -const preView = async () => {  
68 - const attributes = [];  
69 - const fieldsValue = props.childGetFieldsValue();  
70 - for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) {  
71 - const valid = await unref(refItem.conditionScreeningRefs)[i].validate();  
72 - if (!valid) return;  
73 - attributes.push({  
74 - ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(),  
75 - attribute: fieldsValue.type2,  
76 - });  
77 - }  
78 - otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType);  
79 - collapseContainerRef.value.handleExpand();  
80 -}; 80 + const otherAttribute = ref([]);
  81 + // 预览条件筛选结果
  82 + const preView = async () => {
  83 + const attributes = [];
  84 + const fieldsValue = props.childGetFieldsValue();
  85 + for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) {
  86 + const valid = await unref(refItem.conditionScreeningRefs)[i].validate();
  87 + if (!valid) return;
  88 + attributes.push({
  89 + ...unref(refItem.conditionScreeningRefs)[i].getFieldsValue(),
  90 + attribute: fieldsValue.type2,
  91 + });
  92 + }
  93 + otherAttribute.value = conditionPreView(attributes, fieldsValue.operationType);
  94 + // collapseContainerRef.value.handleExpand();
  95 + collapseContainerRef.value.show = true;
  96 + };
81 97
82 -const resetFilter = () => {  
83 - otherAttribute.value = [];  
84 -};  
85 -const deleteConditionForm = (index) => {  
86 - unref(conditionScreeningList).splice(index, 1);  
87 - const lastIndex = refItem.conditionScreeningRefs.value.length - 2;  
88 - refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND');  
89 -}; 98 + //ft add 表单数据置空
  99 + const resetConditionScreenForm = () => {
  100 + // conditionScreeningList.value = [];
  101 + resetFilter();
  102 + for (let i = 0; i < unref(refItem.conditionScreeningRefs).length; i++) {
  103 + unref(refItem.conditionScreeningRefs)[i]?.resetConditionScreenForm();
  104 + }
  105 + };
  106 + //ft add 表单数据置空
90 107
91 -defineExpose({  
92 - refItem,  
93 - conditionScreeningList,  
94 - otherAttribute,  
95 -}); 108 + const resetFilter = () => {
  109 + otherAttribute.value = [];
  110 + };
  111 + const deleteConditionForm = (index) => {
  112 + unref(conditionScreeningList).splice(index, 1);
  113 + const lastIndex = refItem.conditionScreeningRefs.value.length - 2;
  114 + refItem.conditionScreeningRefs.value[lastIndex]?.removeSchemaByFiled('AND');
  115 + };
  116 +
  117 + defineExpose({
  118 + refItem,
  119 + conditionScreeningList,
  120 + otherAttribute,
  121 + resetConditionScreenForm,
  122 + });
96 </script> 123 </script>
@@ -57,12 +57,16 @@ @@ -57,12 +57,16 @@
57 const deleteConditionForm = (index: number) => { 57 const deleteConditionForm = (index: number) => {
58 emit('deleteConditionForm', index); 58 emit('deleteConditionForm', index);
59 }; 59 };
  60 + // ft add
  61 + const resetConditionScreenForm = () => resetFields();
  62 + // ft add
60 defineExpose({ 63 defineExpose({
61 appendSchemaByField, 64 appendSchemaByField,
62 removeSchemaByFiled, 65 removeSchemaByFiled,
63 getFieldsValue, 66 getFieldsValue,
64 setFieldsValue, 67 setFieldsValue,
65 validate, 68 validate,
  69 + resetConditionScreenForm,
66 }); 70 });
67 </script> 71 </script>
68 72
@@ -98,6 +98,13 @@ @@ -98,6 +98,13 @@
98 }); 98 });
99 99
100 const alarmScheduleRef = ref<InstanceType<typeof AlarmSchedule>>(); 100 const alarmScheduleRef = ref<InstanceType<typeof AlarmSchedule>>();
  101 +
  102 + //ft-add
  103 + const resetConditionForm = () => {
  104 + conditionScreeningRef?.value?.resetConditionScreenForm();
  105 + };
  106 + //ft-add
  107 +
101 const getFieldsValueFunc = () => { 108 const getFieldsValueFunc = () => {
102 const predicate = conditionScreeningRef?.value?.refItem?.conditionScreeningRefs?.value?.map( 109 const predicate = conditionScreeningRef?.value?.refItem?.conditionScreeningRefs?.value?.map(
103 (item) => item.getFieldsValue() 110 (item) => item.getFieldsValue()
@@ -215,7 +222,10 @@ @@ -215,7 +222,10 @@
215 }); 222 });
216 }; 223 };
217 //TODO-fengtao 224 //TODO-fengtao
218 - const resetFieldsValueFunc = () => resetFields(); 225 + const resetFieldsValueFunc = () => {
  226 + resetConditionForm();
  227 + resetFields();
  228 + };
219 // 回显数据函数 229 // 回显数据函数
220 const setFieldsFormValueFun = (fieldsValue) => { 230 const setFieldsFormValueFun = (fieldsValue) => {
221 setFieldsValue(fieldsValue); 231 setFieldsValue(fieldsValue);
@@ -245,7 +245,14 @@ @@ -245,7 +245,14 @@
245 const setFieldsFormValueFun = (fieldsValue) => { 245 const setFieldsFormValueFun = (fieldsValue) => {
246 setFieldsValue(fieldsValue); 246 setFieldsValue(fieldsValue);
247 }; 247 };
248 - const resetFieldsValueFunc = () => resetFields(); 248 + //ft-add
  249 + const resetConditionForm = () => {};
  250 +
  251 + //ft-add
  252 + const resetFieldsValueFunc = () => {
  253 + resetFields();
  254 + resetConditionForm();
  255 + };
249 256
250 const orgIdItem = ref(''); 257 const orgIdItem = ref('');
251 const isUpdateItem = ref(''); 258 const isUpdateItem = ref('');
@@ -379,6 +386,7 @@ @@ -379,6 +386,7 @@
379 setRichText, 386 setRichText,
380 refItem, 387 refItem,
381 clearRuleList, 388 clearRuleList,
  389 + resetConditionForm,
382 }); 390 });
383 </script> 391 </script>
384 392